如何在Android上用pjsip发送dtmf?

时间:2016-04-26 08:35:55

标签: android sip voip pjsip

我试图在拨打电话时发送dtmf。 为了做到这一点,我使用

mCall.dialDtmf(String.valueOf(dtmf));

m调用它是PjSip的调用形式。 调用此函数时,我会捕获异常:

04-25 16:03:57.867 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err: java.lang.Exception: Title:       pjsua_call_dial_dtmf(id, &pj_digits)
04-25 16:03:57.867 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err: Code:        70013
04-25 16:03:57.867 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err: Description: Invalid operation (PJ_EINVALIDOP)
04-25 16:03:57.867 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err: Location:    ../src/pjsua2/call.cpp:551
04-25 16:03:57.879 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at org.pjsip.pjsua2.pjsua2JNI.Call_dialDtmf(Native Method)
04-25 16:03:57.879 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at org.pjsip.pjsua2.Call.dialDtmf(Call.java:143)
04-25 16:03:57.879 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at com.kaymera.kphoneapp.voipEngine.PJCall.dialDtmf(PJCall.java:115)
04-25 16:03:57.879 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at com.kaymera.kphoneapp.voipEngine.calls.VoipCall.sendDTMF(VoipCall.java:149)
04-25 16:03:57.879 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at kphoneapp.kymera.kvoip.myapplication.MainActivity.generateDtmf(MainActivity.java:223)
04-25 16:03:57.880 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at kphoneapp.kymera.kvoip.myapplication.MainActivity$$ViewBinder$11.doClick(MainActivity$$ViewBinder.java:110)
04-25 16:03:57.880 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at butterknife.internal.DebouncingOnClickListener.onClick(DebouncingOnClickListener.java:22)
04-25 16:03:57.880 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at android.view.View.performClick(View.java:4764)
04-25 16:03:57.880 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at android.view.View$PerformClick.run(View.java:19844)
04-25 16:03:57.880 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at android.os.Handler.handleCallback(Handler.java:739)
04-25 16:03:57.880 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
04-25 16:03:57.881 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at android.os.Looper.loop(Looper.java:135)
04-25 16:03:57.881 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:5349)
04-25 16:03:57.881 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
04-25 16:03:57.881 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at java.lang.reflect.Method.invoke(Method.java:372)
04-25 16:03:57.881 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:908)
04-25 16:03:57.881 19670-19670/kphoneapp.kymera.kvoip.myapplication W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

我该如何解决?

1 个答案:

答案 0 :(得分:3)

我有类似的问题,事情是服务器使用不同的DTMF方法。

dialDtmf方法在我的服务器使用SIP INFO调用DTMF时使用RFC 2833。

这是适用于我的服务器的代码:

CallSendRequestParam prm = new CallSendRequestParam();
prm.setMethod("INFO");
SipTxOption txo = new SipTxOption();
txo.setContentType(" application/dtmf-relay");
txo.setMsgBody("Signal=" + String.valueOf(code) + "\n" + "Duration=160");
prm.setTxOption(txo);
call.sendRequest(prm);