我正在尝试通过在 Android 中构建 cordova 插件来构建 pjsip 并拨打基本电话。以下函数位于名为的 cordova 插件中
公共类 PJSIP 扩展 CordovaPlugin{ .... }
private void makeCall(String number,String hostip ) {
String buddy_uri = "sip:"+number+"@"+hostip;
MyAccount account = null;
AccountConfig accCfg = null;
accCfg = new AccountConfig();
accCfg.setIdUri("sip:localhost");
accCfg.getNatConfig().setIceEnabled(true);
accCfg.getVideoConfig().setAutoTransmitOutgoing(true);
accCfg.getVideoConfig().setAutoShowIncoming(true);
MyAccount acc = new MyAccount(accCfg);
account = acc;
MyCall call = new MyCall(account, -1);
CallOpParam prm = new CallOpParam(true);
try {
call.makeCall(buddy_uri, prm);
} catch (Exception e) {
call.delete();
return;
}
currentCall = call;
Run Code Online (Sandbox Code Playgroud)
}
我收到的错误如下:
A/libc: ../src/pj/os_core_unix.c:692: pj_thread_this: 断言“!”从未知/外部线程调用 pjlib。您必须在调用任何 pjlib 函数之前使用 pj_thread_register() 注册外部线程。”失败
我检查了一下,垃圾收集器似乎有问题,但我不知道如何修复它。
谢谢
在 pjsip 中,每个调用都必须来自 pjsip 已知的线程。
在你的EndPoint对象上有一个方法可以帮助你做到这一点。基本上,我只是创建了一个静态方法checkThread来帮助我注册currentThread.
我在访问 pjsip 对象的每个方法的开头调用此方法。您需要同步此方法。
public static synchronized void checkThread() {
try {
if (mEndpoint != null && !mEndpoint.libIsThreadRegistered())
mEndpoint.libRegisterThread(Thread.currentThread().getName());
} catch (Exception e) {
Log.w("SIP", "Threading: libRegisterThread failed: " + e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud)
现在访问 sip 对象的每个方法都必须如下所示:
public void makeCall(String number) {
checkThread();
//...do your stuff...
}
Run Code Online (Sandbox Code Playgroud)
希望这有帮助,干杯。
| 归档时间: |
|
| 查看次数: |
1686 次 |
| 最近记录: |