ios10 iphone5s voip siphon pjsip2.5.5 Error opening sound device

若如初见. 提交于 2019-12-08 01:44:43

问题


Someone could tell me why this happen?

iOS10, iPhone5s, VOIP Siphon pjsip2.5.5.

These issue was not appear every time,it came sometimes when you want to make call or answer call (add at:20161226).

Error opening sound device:

14:06:03.137742 pjsua_aud.c  ....Set sound device: capture=-1, playback=-2

14:06:03.137775 pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@16000/1/20ms

14:06:03.137837 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.147404 acquire_call enter,call_id:2
14:06:03.233365 level:4,msg:14:06:03.233    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@44100/1/20ms

14:06:03.233488 level:4,msg:14:06:03.233 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.263379 AVAudioSessionRouteChangeNotification ..changeReason..3
14:06:03.439201    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@48000/1/20ms

14:06:03.444813 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.518592    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@32000/1/20ms

14:06:03.518731 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.587808    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@16000/1/20ms

14:06:03.587936 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.659660    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@8000/1/20ms

14:06:03.659837 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.734433    pjsua_aud.c  .....Unable to open sound device: Unknown OpenSSL error 503317117 [status=506637]

14:06:03.734512    pjsua_aud.c  ....Error opening sound device: Unknown OpenSSL error 503317117 [status=506637]

14:06:03.734534    pjsua_aud.c  ...Conf connect: 0 --> 2

14:06:03.734555    pjsua_aud.c  ....Set sound device: capture=-1, playback=-2

14:06:03.734586    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@16000/1/20ms

14:06:03.734651 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.799718    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@44100/1/20ms

14:06:03.799847 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.868825    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@48000/1/20ms

14:06:03.869031 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:03.936294    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@32000/1/20ms

14:06:03.936423 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:04.006834    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@16000/1/20ms

14:06:04.006962 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:04.075150    pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@8000/1/20ms

14:06:04.075288 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

14:06:04.144082    pjsua_aud.c  .....Unable to open sound device: Unknown OpenSSL error 503317117 [status=506637]

14:06:04.144165    pjsua_aud.c  ....Error opening sound device: Unknown OpenSSL error 503317117 [status=506637]

14:06:04.144186 pjsua_conf_connect:pjsua_conf_connect_value 506637 ret 506637

today(2016-12-16),I get the same bug,but the error number is different(iphone5 ios10.1.1 siphone pjsip2.5.5)

316-981188544 2016-12-16 10:52:29.160553 pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@44100/1/20ms

316-981188544 2016-12-16 10:52:29.160689 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

316-981188544 2016-12-16 10:52:29.167254 pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@48000/1/20ms

316-981188544 2016-12-16 10:52:29.167391 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

316-981188544 2016-12-16 10:52:29.172857 pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@32000/1/20ms

316-981188544 2016-12-16 10:52:29.172994 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

316-981188544 2016-12-16 10:52:29.178400 pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@16000/1/20ms

316-981188544 2016-12-16 10:52:29.178539 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

316-981188544 2016-12-16 10:52:29.184486 pjsua_aud.c  .....Opening sound device (speaker + mic) PCM@8000/1/20ms

316-981188544 2016-12-16 10:52:29.184631 coreaudio_dev.  ......Using VoiceProcessingIO audio unit

316-981188544 2016-12-16 10:52:29.195032 pjsua_aud.c  .....Unable to open sound device: Unknown error -1701297535 [status=-1701297535]

316-981188544 2016-12-16 10:52:29.195105 pjsua_aud.c  ....Error opening sound device: Unknown error -1701297535 [status=-1701297535]

回答1:


Step 1: At first open info.plist file in your xcode project in Supporting Files Folder and click "+" in Information property list.

Step 2: Select and Add Privacy - Microphone Usage Description in the list.

Step 3: Add the value Microphone in the Privacy - Microphone Usage Description.

Now Compile and run your project.




回答2:


At last,I fix this bug with IOS's CallKit,take a look at this website: https://trac.pjsip.org/repos/ticket/1941

Details: CallKit framework allows apps to use the native phone UI to receive incoming calls and make outgoing calls. In order to achieve this, CallKit requires the call audio to start only when audio session has been activated, thus it's recommended that when using PJSIP, you open the sound device only when necessary. It can be done by:

Starting PJSIP with no sound device (by calling pjsua_set_no_snd_dev() after startup). Close the sound device when unused, also with the same API (pjsua_set_no_snd_dev()). Upon audio session activation, open the sound device with the API pjsua_set_snd_dev(). Below is an example on how to integrate CallKit with PJSIP, with the delegate functions taken from ​Speakerbox sample app provided by Apple.

To make outgoing call:

func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
        /* 1. We must not start call audio here, and can only do so
         *    once the audio session has been activated by the system
         *    after having its priority elevated. So, make sure that the sound
         *    device is closed at this point.
         */

        /* 2. Provide your own implementation to configure
         *    the audio session here.
         */
        configureAudioSession()

        /* 3. Make call with pjsua_call_make_call().
         *    Then use pjsua's on_call_state() callback to report significant
         *    events in the call's lifecycle, by calling iOS API
         *    CXProvider.reportOutgoingCall(with: startedConnectingAt:) and
         *    CXProvider.reportOutgoingCall(with: ConnectedAt:)
         */

        /* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(),
         *    otherwise call action.fail().
         */
    }

To handle incoming call:

 func provider(_ provider: CXProvider, perform action: CXAnswerCallAction) {
        /* 1. We must not start call audio here, and can only do so
         *    once the audio session has been activated by the system
         *    after having its priority elevated. So, make sure that the sound
         *    device is closed at this point.
         */

        /* 2. Provide your own implementation to configure
         *    the audio session here.
         */
        configureAudioSession()

        /* 3. Answer the call with pjsua_call_answer().
         */

        /* 4. If step (3) above returns PJ_SUCCESS, call action.fulfill(),
         *    otherwise call action.fail().
         */
    }

To start sound device:

func provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession) {
    /* Start call audio media, now that the audio session has been
     * activated after having its priority boosted.
     *
     * Call pjsua API pjsua_set_snd_dev() here.
     */
}



回答3:


My issue was that, when I played a sound on incoming calls I set the AudioSession caterogry Playback like:

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)

I changed it to Play and record:

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)

and it worked after that. So if you somewhere in your code set the audio session to playback, change it to play and record.

@Altanai

func setAudioSessionActive(active: Bool) -> Bool{
    let sessionInterface = AVAudioSession.sharedInstance()
    do{
        try sessionInterface.setActive(active)

        if(active){
            if(sessionInterface.category != AVAudioSessionCategoryPlayAndRecord){
                try sessionInterface.setCategory(AVAudioSessionCategoryPlayAndRecord)
            }
            if(sessionInterface.mode != AVAudioSessionModeVoiceChat){
                try sessionInterface.setMode(AVAudioSessionModeVoiceChat)
            }
        }
        return true
    }
    catch let error{
        return false
    }
}

func configureAudioSession(){
    let sessionInterface = AVAudioSession.sharedInstance()

    do{
        if(sessionInterface.responds(to: #selector(AVAudioSession.setCategory(_:with:)))){
            try sessionInterface.setCategory(AVAudioSessionCategoryPlayAndRecord, with: AVAudioSessionCategoryOptions.allowBluetooth)
        }
        else{
            try sessionInterface.setCategory(AVAudioSessionCategoryPlayAndRecord)
        }
        try sessionInterface.setMode(AVAudioSessionModeVoiceChat)

    }
    catch let error{
        NSLog("SipManager - configureAudioSession error: \(error)")
    }
}


来源:https://stackoverflow.com/questions/40989940/ios10-iphone5s-voip-siphon-pjsip2-5-5-error-opening-sound-device

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!