在此先感谢您的帮助!
我正在尝试在 Mac OS 上使用 Swift 中的Linphone SDK记录调用,并且无法将路径传递给函数:
func linphone_call_params_set_record_file(_ cp: OpaquePointer!, _ path: UnsafePointer<Int8>!)
可以正常工作(SDK 是用 C 编写的,尽管我使用 Swift 和桥接头来访问它)。Linphone SDK 工作正常,我可以通过编程方式拨打和接听电话,并提供完整的音频支持。
在尝试调用通话记录器时,我向该函数传递了一个路径 ( pathtofile
),例如:
let pathtofile = "/Users/Alex/Safety/1.wav"
我想存储录音文件的地方。
func SafetyNetAVRecorderInitializer(pathtofile: String) -> Bool {
// Convert pathtofile to UnsafePointer<Int8>.
let cpathtofile = (pathtofile as NSString).utf8String
let path = UnsafeMutablePointer<Int8>(mutating: cpathtofile)
// Actually begin call recording.
if currentcall != nil {
let currentcallparameters = linphone_call_get_current_params(currentcall)
linphone_call_params_set_record_file (currentcallparameters, path)
linphone_call_start_recording(currentcall)
return true
}
return false
}
上没有遇到运行时错误linphone_call_params_set_record_file()
,但是当我尝试调用linphone_call_start_recording()
时,录制没有开始,并且在控制台中打印了一个错误,内容如下:
ortp-error-linphone_call_start_recording():没有指定输出文件。使用 linphone_call_params_set_record_file()。
如何正确传递有效路径linphone_call_params_set_record_file()
?我试过直接传递一个普通的 SwiftString
而不是UnsafePointer<Int8>
无济于事。我只是误解了 C 中路径的格式吗?
供参考,SDK方法源为:
void linphone_call_params_set_record_file(LinphoneCallParams *cp, const char *path){
if (cp->record_file){
ms_free(cp->record_file);
cp->record_file=NULL;
}
if (path) cp->record_file=ms_strdup(path);
}
再次感谢!