我有这个委托(delegate)方法
-(void)airPlayServer:(id)server sampleBufferReceived:(CMSampleBufferRef)sampleBuffer
{
}
这给了我
sampleBuffer
.现在我需要知道如何使用
AVSampleBufferDisplayLayer
渲染我的 sampleBuffer。我知道我们必须使用 - enqueueSampleBuffer
- 但我是 iOS 新手,我们该怎么做呢?我不想将 sampleBuffer 转换为 CGImage 然后绘制它。
代码示例受到高度赞赏:)
最佳答案
像这样:
CMSampleBufferRef sampleBufferRef = ...;
// Force display as soon as possible
CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sampleBufferRef, YES);
CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachments, 0);
CFDictionarySetValue(dict, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue);
[sampleBufferLayer enqueueSampleBuffer:sampleBufferRef];
[sampleBufferLayer setNeedsDisplay];
关于ios - 我们如何使用 AVSampleBufferDisplayLayer 来渲染 CMSampleBufferRef?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54454403/