我遇到了类似问题的问题:Why AVSampleBufferDisplayLayer stops showing CMSampleBuffers taken from AVCaptureVideoDataOutput's delegate?
并尝试了这个问题的建议。
但是当我粘贴这段代码时:
let attachments: CFArray = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, true)!;
print(CFArrayGetCount(attachments)) // printing 1
let dict = CFArrayGetValueAtIndex(attachments, 0) as! CFMutableDictionary;
CFDictionarySetValue(dict,
unsafeBitCast(kCMSampleAttachmentKey_DisplayImmediately, to: UnsafeRawPointer.self),
unsafeBitCast(kCFBooleanTrue, to: UnsafeRawPointer.self));
应用程序在转换为CFMutableDictionary时崩溃。
我做错了什么?