1

I have this delegate method

-(void)airPlayServer:(id)server sampleBufferReceived:(CMSampleBufferRef)sampleBuffer
{
}

which gives me sampleBuffer.

Now I need to know how can I use AVSampleBufferDisplayLayer to render my sampleBuffer. I know we have to use - enqueueSampleBuffer - but I am new to iOS so how can we do it?

I don't want to convert sampleBuffer to CGImage and then draw it.

Code example is highly appreciated :)

Abid Mehmood
  • 145
  • 1
  • 9

1 Answers1

3

Like so:

   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];
MoDJ
  • 4,309
  • 2
  • 30
  • 65