I've been struggling with AVSampleBufferDisplayLayer being really choppy with a lot of motion. When there was motion in my live stream, it would be come pixelated and half frozen with multiple frames displaying at once. However, once I added the following piece of code, everything was solved:
VTDecodeFrameFlags flags = kVTDecodeFrame_EnableAsynchronousDecompression
| kVTDecodeFrame_EnableTemporalProcessing;
VTDecodeInfoFlags flagOut;
VTDecompressionSessionDecodeFrame(decompressionSession, sampleBuffer, flags,
(void*)CFBridgingRetain(NULL), &flagOut);
Note that I did create the decompression session before, but I don't actually do anything in the callback. I am still calling enqueueSampleBuffer: on AVSampleBufferDisplayLayer and that is how the video is displayed on the screen.
Do you have to call VTDecompressionSessionDecodeFrame for AVSampleBufferDisplayLayer to display correctly? I thought AVSampleBufferDisplayLayerr would use VTDecompressionSessionDecodeFrame internally. Is this due to being on the iOS Simulator?