Question

I'm using pjsua2 with Android build version 2.2.1. I can put a call on hold using:

    CallOpParam prm = new CallOpParam();
    prm.setOptions(pjsua_call_flag.PJSUA_CALL_UPDATE_CONTACT.swigValue());

    try {
        currentCall.setHold(prm)
    } catch(Exception e) {
        e.printStackTrace();
    }

To unhold call I tried this, but does not work:

    CallOpParam prm = new CallOpParam();
    prm.setOptions(pjsua_call_flag.PJSUA_CALL_UNHOLD.swigValue());

    try {
        currentCall.reinvite(prm);
    } catch(Exception e) {
        e.printStackTrace();
    }

Is that a bug of pjsua? How should I call the reinvite method?

Was it helpful?

Solution

Look my code:

public void holdCall() {
    CallOpParam prm = new CallOpParam(true);

    try {
        currentCall.setHold(prm);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public void unHoldCall() {
    CallOpParam prm = new CallOpParam(true);

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

According to this issue, it's necessary to set flag on CallOpParam.

The constant PJSUA_CALL_UNHOLD == 1, but I couldn't use PJSUA_CALL_UNHOLD directly.

I'm using Asterisk and it's working.

OTHER TIPS

To unhold the call I need this in version 2.4.5:

CallOpParam prm = new CallOpParam();
CallSetting opt = prm.getOpt();
opt.setAudioCount(1);
opt.setVideoCount(0);
opt.setFlag(pjsua_call_flag.PJSUA_CALL_UNHOLD.swigValue());
call.reinvite(prm);

Here is another example:

public void setHold(boolean hold) {
    CallOpParam param = new CallOpParam();

    try {
        if (hold) {
            setHold(param);
        } else {
            CallSetting opt = param.getOpt();
            opt.setAudioCount(1);
            opt.setVideoCount(0);
            opt.setFlag(pjsua_call_flag.PJSUA_CALL_UNHOLD.swigValue());
            reinvite(param);
        }
    } catch (Exception exc) {
        String operation = hold ? "hold" : "unhold";
        Logger.error(LOG_TAG, "Error : ", exc);
    }
}

You can find here the full implementation.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top