5

我正在开发一个基于Linphone-iPhone的项目,该项目需要拍摄当前视频流的快照(输入和输出)。

我在 liblinphone 中找到了这个“ linphone_call_take_video_snapshot ”并试了一下。代码很简单,运行没有任何错误,但保存文件的大小始终为0 kb

这是代码:

- (void)capture {
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *file_path = [documentsDirectory stringByAppendingPathComponent:@"snapshot.jpeg"];
    LinphoneCall *call = linphone_core_get_current_call([LinphoneManager getLc]);
    const char *c_file_path = [file_path cStringUsingEncoding:NSUTF8StringEncoding];
    int ret = linphone_call_take_video_snapshot(call, c_file_path);

    if (ret >= 0 && [[NSFileManager defaultManager] fileExistsAtPath:file_path]) {
        UIImageWriteToSavedPhotosAlbum([UIImage imageWithContentsOfFile:file_path], nil,nil,nil);
    }
}

linphone_call_take_video_snapshot真的有用吗如果是这样,我做错了什么?

4

0 回答 0