pjsip-2.7.1使用ios CallKit调用pjsua_set_snd_dev时断言失败

时间:2017-12-08 08:28:22

标签: voip pjsip callkit

在我将pjsip从v2.6更新到v2.7.1之后,我的应用程序将使用函数pjsua_set_snd_dev()来断言失败。 根据pjsip的票#1941:

拨打电话:

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

当调用pjsua API pjsua_set_snd_dev()时,显示:

  

断言失败:(param&& id!= PJMEDIA_AUD_INVALID_DEV),功能   pjmedia_aud_dev_default_param,file ../src/pjmedia/audiodev.c,line   487。

我发现v2.7.1,在pjsua_set_no_snd_dev()中,有

  

pjsua_var.cap_dev = PJSUA_SND_NO_DEV; pjsua_var.play_dev =   PJSUA_SND_NO_DEV;

但是在v2.6中,没有这个。

PJSUA_SND_NO_DEV和PJMEDIA_AUD_INVALID_DEV与-3相同。

这是一个错误,还是我混淆了什么?

1 个答案:

答案 0 :(得分:0)

史蒂夫,你已经添加了

App提供IP语音服务 功能

中所需的背景模式

或者您可以直接在 Info.plist

中添加