将CallKit用于pjsip iOS应用时,断开GSM来电后无音频

在收到GSM呼叫时,我选择保留并接受选项。 我从控制器收到回叫,并且将VoIP呼叫置于保留状态。 普通的GSM通话音频看起来不错。 现在,当用户使用CallKit接口断开GSM呼叫时,我将从固定的操作中获得回调。 我未接通我的pjsip VoIP呼叫。
一旦我收到呼叫工具包

的停用通知,
  

pjsua_aud.c ..关闭iPhone IO设备的声音播放设备和   iPhone IO设备声音捕获设备
17:52:26.666
  coreaudio_dev.c ..core音频流已停止
17:52:26.667
  pjsua_app.c。打开声音设备-99 -99开启
17:52:26.667
  pjsua_aud.c。打开空声音设备..

一旦我通过didactivate方法收到媒体处于活动状态的通知, 我尝试使用pjsip方法连接声音端口。 但不幸的是,我收到以下消息:

  

[aurioc] AURemoteIO.cpp:1590:Start:AUIOClient_StartIO失败(-66637)

     

audio didactivate AudioSession
14:33:31.783?VERBOSE-didactivate   2019-12-17 14:33:31 1576573411.781775
14:33:31.783?VERBOSE-   audiotest类别AVAudioSessionCategoryPlayAndRecord
14:33:31.783?   VERBOSE-音频测试模式AVAudioSessionmodeVoiceChat
14:33:31.783?   VERBOSE-audiotest isInputAvailable true
14:33:31.784?VERBOSE-   audiotest isOtherAudioPlaying true
14:33:31.784 VER VERBOSE-   audiotest recordPermission 1735552628
14:33:31.784?VERBOSE-   audiotest routeSharingPolicy 1

     

pjsua_app.c。打开声音设备-1 -2打开
18:00:12.304
  pjsua_aud.c。打开声音设备(扬声器+麦克风)   PCM @ 16000/1 / 20ms
18:00:12.304 coreaudio_dev.c ..使用   VoiceProcessingIO音频单元
[aurioc] 1540:AUIOClient_StartIO   失败(-66637)

因此,当尝试将播放设备和捕获设备设置为默认值时,pjsip无法打开。

我听不到任何声音。由于没有音频,我的媒体服务器会在20秒后断开我的通话。 我在激活方法中检查了音频模式和类别。 它们是正确的voiceChatModeplayAndRecord类别。 我检查了记录许可权,它似乎已启用。 但是即使在GSM通话断开后,我仍然认为isOtherAudioPlaying是正确的。 但是在断开voip通话并进行新的voip通话后,我的应用程序成功连接到iPhone io设备的回放和捕获设备。


这是我在固定方法

中所做的
func provider(_ provider: CXProvider,perform action: CXSetHeldCallaction) {
        SwiftyBeaver.verbose("Starting action CXSetHeldCallaction!!")
        if action.isOnHold{
            SwiftyBeaver.verbose("called for set hold")
        }else{
            SwiftyBeaver.verbose("called for set unhold")
        }


        if !isHoldAndMakeCall && !handleGsmCallHoldState && action.isOnHold{
            SwiftyBeaver.verbose("let put call on hold")
            for (_,dict) in AppDelegate.callDetails.enumerated(){

                SwiftyBeaver.verbose("Key callId now is: \(dict.key)")
                SwiftyBeaver.verbose("dict.value.callUUID while enumerating:\(String(describing: dict.value.callUUID))")
                SwiftyBeaver.verbose("action.callUUID right now is: \(action.callUUID)")
                if action.callUUID == dict.value.callUUID{
                    SwiftyBeaver.verbose("action fulfill CXSetHeldCallaction to be executed  for call id:\(dict.key)")
                    SwiftyBeaver.verbose("Call State right now is: \(String(describing: dict.value.callState ))")
                    SwiftyBeaver.verbose("Call type right now is: \(String(describing: dict.value.callType ))")
                    SwiftyBeaver.verbose("Call id right now is: \(String(describing: dict.value.remotePartyName ))")
                    call_hold(pjsua_call_id(dict.key))
                    isHoldAndacceptCall = true
                    //setting this helps us to show addCallViewController which has screen to show two calls in interface
                    SwiftyBeaver.verbose("Setting isHoldAndacceptCall here!!")
                    break
                }
            }
        }


        if handleGsmCallHoldState && !action.isOnHold{

            var timeToDelay:Double = 1.0
            handleGsmCallHoldState = false
            DispatchQueue.main.asyncAfter(deadline: .now() + timeToDelay){
                SwiftyBeaver.verbose("Setting handleGsmCallHoldState false!!")
                un_hold(pjsua_call_id(AppDelegate.callDetails.keys.first!))
            }
            do {
                try AVAudioSession.sharedInstance().setactive(true,options: .notifyOthersOnDeactivation)
            }catch{
                SwiftyBeaver.error("error in setactive  \(error.localizedDescription)")
            }
        }
        action.fulfill()
        SwiftyBeaver.verbose("Finished CXSetHeldCallaction!!")

    }
wuyangzhijy 回答:将CallKit用于pjsip iOS应用时,断开GSM来电后无音频

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2907973.html

大家都在问