简体   繁体   中英

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 ".

1. Hold

    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.

2.Unhold

    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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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