ios10 iphone5s voip siphon pjsip2.5.5打开声音设备时出错

时间:2016-12-06 07:25:11

标签: ios c voip pjsip siphon

有人可以告诉我为什么会这样吗?

iOS10,iPhone5s,VOIP Siphon pjsip2.5.5。

这些问题并非每次都出现,有时候您想拨打电话或接听电话(添加于:20161226)。

打开声音设备时出错:

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

今天(2016-12-16),我得到了同样的错误,但错误号不同(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]

3 个答案:

答案 0 :(得分:2)

第1步:首先在支持文件文件夹中的xcode项目中打开 info.plist 文件,然后点击中的" +" 信息属性列表

步骤2:在列表中选择并添加隐私 - 麦克风使用说明

步骤3:在隐私权 - 麦克风使用说明中添加值麦克风

现在编译并运行您的项目。

答案 1 :(得分:1)

我的问题是,当我在来电时播放声音时,我将AudioSession caterogry Playback设置为:

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)

我将其更改为播放和录制:

try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)

然后它起作用了。因此,如果您在代码中的某个位置将音频会话设置为播放,请将其更改为播放和录制。

@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)")
    }
}

答案 2 :(得分:0)

最后,我用IOS的CallKit解决了这个问题,看看这个网站:https://trac.pjsip.org/repos/ticket/1941

详细信息:CallKit框架允许应用使用本机手机用户界面接听来电并拨打电话。为了实现这一点,CallKit要求呼叫音频仅在音频会话被激活时启动,因此建议在使用PJSIP时,仅在必要时打开声音设备。它可以通过以下方式完成:

在没有声音设备的情况下启动PJSIP(通过在启动后调用pjsua_set_no_snd_dev())。未使用时关闭声音设备,也使用相同的API(pjsua_set_no_snd_dev())。音频会话激活后,使用API​​ pjsua_set_snd_dev()打开声音设备。下面是一个关于如何将CallKit与PJSIP集成的示例,其代理功能取自Apple提供的Speakerbox示例应用程序。

拨打电话:

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().
         */
    }

处理来电:

 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().
         */
    }

启动声音设备:

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.
     */
}