通过PJSIP协议保持和取消sip呼叫



我正在开发VOIP android应用程序,该应用程序可以发出和接收sip呼叫。按照"http://trac.pjsip.org/repos/wiki/Getting-Started/Android"中的描述构建pjsip库。

1。持有

    MainActivity.prm.setOptions(pjsua_call_flag.PJSUA_CALL_UPDATE_CONTACT
            .swigValue());
    try {
        MainActivity.currentCall.setHold(MainActivity.prm);
    } catch (Exception e) {
        e.printStackTrace();
    }

我在pjsip文档中找到了这段代码,但是这段代码不适用于将呼叫保持。没有错误信息返回。

2。释放

    MainActivity.prm = new CallOpParam(true);
    MainActivity.prm.getOpt().setFlag(1);
    try {
        MainActivity.currentCall.reinvite(MainActivity.prm);
    } catch (Exception e) {
        e.printStackTrace();
    }

谢谢。

下面是我的保持和取消保持代码:

public void setHold(boolean hold) {
    if ((localHold && hold) || (!localHold && !hold)) return;
    if(currentCall == null) return;
    CallOpParam param = new CallOpParam(true);
    try {
        if (hold) {
            currentCall.setHold(param);
            localHold = true;
        } else {
            CallSetting opt = param.getOpt();
            opt.setAudioCount(1);
            opt.setVideoCount(0);
            opt.setFlag(pjsua_call_flag.PJSUA_CALL_UNHOLD.swigValue());
            currentCall.reinvite(param);
            localHold = false;
        }
    } catch (Exception e) {}
}

最新更新