gpt4 book ai didi

ios - 后台 CallKit 音频初始化错误 - 第一次通话后音频无法正常工作

转载 作者:行者123 更新时间:2023-11-29 06:01:34 29 4
gpt4 key购买 nike

我最近在我的 iOS 应用程序中添加了 pjsip VoIP 功能。当应用程序处于事件状态时,使用 pjsip 没有任何问题,我可以毫无问题地接听和调用电话。

但我的后台声音设备似乎有问题。我从后台收到的第一个电话工作正常,我听到声音并且可以正常关闭它。

问题是在第一次通话后,当我接受来自后台的通话时,我听不到任何声音。如果我在应用程序处于事件状态时调用或接听电话,然后转到后台并接听电话,也会发生同样的情况。当我关闭应用程序时,来自后台的第一个调用再次正常工作。

我不知道是什么原因导致的。

我尝试通过 CallManager 手动关闭所有调用,并在服务器端终止调用时调用 CXEndCallAction,以获取 CallKit正确关闭。

我很乐意发布具体的代码段落,但目前,我不知道问题出在哪里......

<小时/>

更新:

我发现 pjsip coreaudio 第二次初始化不同。

现在的问题是,如何正确重置 pjsip 中的 CoreAudio?

调用初始化成功:

11:03:01.615 tsx0x1030710a8  .....State changed from Trying to 
Proceeding, event=TX_MSG
11:03:01.615 dlg0x1030840a8 ......Transaction tsx0x1030710a8 state changed to Proceeding
2019-02-13 11:03:01.615745+0100 VarioCallCTI[11928:2820452] Incoming call from "Matthias" <sip:238@80.80.245.33>
11:03:01.618 pjsua_aud.c ..Set sound device: capture=0, playback=0
11:03:01.618 pjsua_aud.c !Set sound device: capture=0, playback=0
11:03:01.619 pjsua_aud.c !...Opening sound device PCM@16000/1/20ms
11:03:01.619 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.808024+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 16000 Hz, Int16> inf< 1 ch, 16000 Hz, Int16>)
11:03:01.851 pjsua_aud.c ...Opening sound device PCM@44100/1/20ms
11:03:01.851 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.859854+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 44100 Hz, Int16> inf< 1 ch, 44100 Hz, Int16>)
11:03:01.860 pjsua_aud.c ...Opening sound device PCM@48000/1/20ms
11:03:01.860 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.867061+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 48000 Hz, Int16> inf< 1 ch, 48000 Hz, Int16>)
11:03:01.867 pjsua_aud.c ...Opening sound device PCM@32000/1/20ms
11:03:01.867 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.874321+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 32000 Hz, Int16> inf< 1 ch, 32000 Hz, Int16>)
11:03:01.875 pjsua_aud.c ...Opening sound device PCM@16000/1/20ms
11:03:01.875 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.881126+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 16000 Hz, Int16> inf< 1 ch, 16000 Hz, Int16>)
11:03:01.881 pjsua_aud.c ...Opening sound device PCM@8000/1/20ms
11:03:01.881 coreaudio_dev. ....Using VoiceProcessingIO audio unit
2019-02-13 11:03:01.888214+0100 VarioCallCTI[11928:2820452] [aurioc] 1029: failed: '!int' (enable 3, outf< 1 ch, 8000 Hz, Int16> inf< 1 ch, 8000 Hz, Int16>)
11:03:01.888 pjsua_aud.c ...Unable to open sound device: Unknown error -560117684 [status=-560117684]
Error in Setting of Audio Devices - IncomingCall
TESTPRINT FOR NOTIFICATION INFO: eingehender anruf von 238
TESTPRINT FOR NOTIFICATION INFO: 238

调用初始化失败:

    11:03:49.840 tsx0x103064ea8  .....State changed from Trying to Proceeding, event=TX_MSG
11:03:49.840 dlg0x1030906a8 ......Transaction tsx0x103064ea8 state changed to Proceeding
2019-02-13 11:03:49.841013+0100 VarioCallCTI[11928:2820906] Incoming call from "Matthias" <sip:238@80.80.245.33>
11:03:49.842 pjsua_aud.c ..Set sound device: capture=0, playback=0

11:03:49.842 pjsua_aud.c ...Opening sound device PCM@16000/1/20ms
11:03:49.842 coreaudio_dev. ....Using VoiceProcessingIO audio unit
11:03:49.847 pjsua_aud.c !Set sound device: capture=0, playback=0
2019-02-13 11:03:50.276837+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Speaker (type: Speaker)
2019-02-13 11:03:50.277597+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
2019-02-13 11:03:50.292488+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
2019-02-13 11:03:50.293379+0100 VarioCallCTI[11928:2820280] [avas] AVAudioSessionPortImpl.mm:56:ValidateRequiredFields: Unknown selected data source for Port Receiver (type: Receiver)
11:03:50.383 coreaudio_dev. !....core audio stream started
Setting of Audio Devices Successfull - IncomingCall











TESTPRINT FOR NOTIFICATION INFO: eingehender anruf von 238
TESTPRINT FOR NOTIFICATION INFO: 238

最佳答案

我已经找到解决问题的方法了。

由于 PJSIP Library Init 导致 coreAudio 在 iOS 所需的优先级提升完全完成之前进行初始化,因此我必须打开 CallKit 并在 CallKit - ProviderDelegate 内的 PJSIP 服务器上注册

  func reportIncomingCall(uuid: UUID, handle: String, hasVideo: Bool = false, completion: ((NSError?) -> Void)?) {
let update = CXCallUpdate()
update.remoteHandle = CXHandle(type: .generic, value: handle)
update.hasVideo = hasVideo
//MARK: Final Working Solution
print("Starting PJSIP after PUSH")
pjsipfunctions.init().registersip(mainUser.sipData["User"], mainUser.sipData["Password"], mainUser.sipData["Server"])

provider.reportNewIncomingCall(with: uuid, update: update) { error in
if error == nil {
let call = Call(uuid: uuid, handle: handle)
self.callManager.add(call: call)
userTerminatedCall = false

}

completion?(error as? NSError)
}
}
}

关于ios - 后台 CallKit 音频初始化错误 - 第一次通话后音频无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54627373/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com