简体   繁体   English

使用PJSIP保持和取消保持Sip呼叫

[英]Hold and Unhold sip call using the PJSIP

I developing VOIP android application that make and receive the sip call.I Build the pjsip lilbrary as described in " http://trac.pjsip.org/repos/wiki/Getting-Started/Android ". 我开发了可以进行sip调用的VOIP android应用程序。我按照“ http://trac.pjsip.org/repos/wiki/Getting-Started/Android ”中的说明构建了pjsip库。

1. Hold 1.按住

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

I found this code on pjsip documentation,but this code does not work for put a call on Hold.There is no error message return. 我在pjsip文档中找到了此代码,但是此代码不适用于将呼叫置于保留状态。没有错误消息返回。

2.Unhold 2.取消

    MainActivity.prm = new CallOpParam(true);

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

Thanks. 谢谢。

Here is my code for hold and unHold: 这是我用于保持和取消保持的代码:

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) {}
}

I hope it's helpful. 希望对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM