我目前正在使用 pjSIP 和 swift 开发 iOS 应用程序。
我在 .c 文件中找到了一个用于拨打电话的方法,就这样吧
void makeCall(const char *destUri){
...
status = pjsua_call_make_call(...
}
Run Code Online (Sandbox Code Playgroud)
我得到了一个从主线程调用的快速方法,该方法从 C 文件调用 makeCall 函数。
如果我这样做,应用程序会崩溃,并提示我需要在调用 pjLib 函数之前将线程注册到 pjSIP。
要将线程注册到 pjSIP,我需要调用函数pj_thread_register
我尝试将线程添加为 UnsafeMutablePointer。
我的电话现在看起来像这样:
void makeCall(const char *destUri, long threadDesc, pj_thread_t **thread){
...
pj_thread_register(NULL, &threadDesc, thread);
status = pjsua_call_make_call(...
}
internal static func makeSIPCall(numberToCall: String){
...
let destination = ... //my call destination
let thread : NSThread = NSThread.currentThread()
let observer = UnsafeMutablePointer<CopaquePointer>(Unmanaged.passUnretained(thread.self).toOpue())
makeCall(destination, Int(thread.description)! as Clong, observer)
}
Run Code Online (Sandbox Code Playgroud)
线程 …