问题
When getting incoming GSM calls, I choose hold and accept option.
I get the callback from my controller and I put my VoIP call on hold.
Normal GSM call audio looks good.
Now, when the user disconnects the GSM call using CallKit
interface, I get the callback from my setheld action.
I unhold my pjsip
VoIP call.
Once i recieve deactivate from call kit
pjsua_aud.c ..Closing iPhone IO device sound playback device and iPhone IO device sound capture device
17:52:26.666
coreaudio_dev.c ..core audio stream stopped
17:52:26.667
pjsua_app.c .Turning sound device -99 -99 ON
17:52:26.667
pjsua_aud.c .Opening null sound device..
Once I get the notification that my media is active from didActivate
method,
I try to connect my sound ports using pjsip
method.
But unfortunately, I get the following message:
[aurioc] AURemoteIO.cpp:1590:Start: AUIOClient_StartIO failed (-66637)
audio didActivate AudioSession
14:33:31.783 💜 VERBOSE - didActivate 2019-12-17 14:33:31 1576573411.781775
14:33:31.783 💜 VERBOSE- audiotest category AVAudioSessionCategoryPlayAndRecord
14:33:31.783 💜 VERBOSE - audiotest mode AVAudioSessionModeVoiceChat
14:33:31.783 💜 VERBOSE - audiotest isInputAvailable true
14:33:31.784 💜 VERBOSE - audiotest isOtherAudioPlaying true
14:33:31.784 💜 VERBOSE - audiotest recordPermission 1735552628
14:33:31.784 💜 VERBOSE - audiotest routeSharingPolicy 1pjsua_app.c .Turning sound device -1 -2 ON
18:00:12.304
pjsua_aud.c .Opening sound device (speaker + mic) PCM@16000/1/20ms
18:00:12.304 coreaudio_dev.c ..Using VoiceProcessingIO audio unit
[aurioc] 1540: AUIOClient_StartIO failed (-66637)
So when trying to set playback device and capture device to default values pjsip fails to open.
And I am not able to hear any sound. My media server disconnects my call after 20 seconds as there is no audio.
I have checked audio mode and category in did activate method.
They are correct as voiceChatMode
and playAndRecord
category.
I checked for record permission and it seems to be enabled.
But I see isOtherAudioPlaying
to be true even after the GSM call is disconnected.
But after disconnecting the voip call and making a new voip call,my app successfully connects to iPhone io device playback and capture device.
This is what i do in my setheld method
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!!")
}
来源:https://stackoverflow.com/questions/59370625/no-audio-after-incoming-gsm-call-disconnected-when-using-callkit-for-pjsip-ios-a