From 71b953cdd2dfcd434cd7237f0de8f0f64ac9bd84 Mon Sep 17 00:00:00 2001 From: Felipe Cavalcanti Date: Mon, 28 Nov 2022 08:51:10 -0300 Subject: [PATCH] Fix black screen in HDR mode in newer AppleTV 4K Models --- Limelight/Stream/VideoDecoderRenderer.m | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/Limelight/Stream/VideoDecoderRenderer.m b/Limelight/Stream/VideoDecoderRenderer.m index 7333c65..a74c509 100644 --- a/Limelight/Stream/VideoDecoderRenderer.m +++ b/Limelight/Stream/VideoDecoderRenderer.m @@ -330,11 +330,12 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit); CMSampleBufferRef sampleBuffer; - status = CMSampleBufferCreate(kCFAllocatorDefault, + CMSampleTimingInfo sampleTiming = {kCMTimeInvalid, CMTimeMake(pts, 1000), kCMTimeInvalid}; + + status = CMSampleBufferCreateReady(kCFAllocatorDefault, frameBlockBuffer, - true, NULL, - NULL, formatDesc, 1, 0, - NULL, 0, NULL, + formatDesc, 1, 1, + &sampleTiming, 0, NULL, &sampleBuffer); if (status != noErr) { Log(LOG_E, @"CMSampleBufferCreate failed: %d", (int)status); @@ -342,22 +343,6 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit); CFRelease(frameBlockBuffer); return DR_NEED_IDR; } - - CFArrayRef attachments = CMSampleBufferGetSampleAttachmentsArray(sampleBuffer, YES); - CFMutableDictionaryRef dict = (CFMutableDictionaryRef)CFArrayGetValueAtIndex(attachments, 0); - - CFDictionarySetValue(dict, kCMSampleAttachmentKey_DisplayImmediately, kCFBooleanTrue); - CFDictionarySetValue(dict, kCMSampleAttachmentKey_IsDependedOnByOthers, kCFBooleanTrue); - - if (frameType == FRAME_TYPE_PFRAME) { - // P-frame - CFDictionarySetValue(dict, kCMSampleAttachmentKey_NotSync, kCFBooleanTrue); - CFDictionarySetValue(dict, kCMSampleAttachmentKey_DependsOnOthers, kCFBooleanTrue); - } else { - // I-frame - CFDictionarySetValue(dict, kCMSampleAttachmentKey_NotSync, kCFBooleanFalse); - CFDictionarySetValue(dict, kCMSampleAttachmentKey_DependsOnOthers, kCFBooleanFalse); - } // Enqueue the next frame [self->displayLayer enqueueSampleBuffer:sampleBuffer];