diff --git a/src/Limelight.h b/src/Limelight.h index 0a937ff..a7078a3 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -172,6 +172,18 @@ typedef struct _DECODE_UNIT { // Head of the buffer chain (never NULL) PLENTRY bufferList; + + // Determines if this frame is SDR or HDR + // + // Note: This is not currently parsed from the actual bitstream, so if your + // client has access to a bitstream parser, prefer that over this field. + bool hdrActive; + + // Provides the colorspace of this frame (see COLORSPACE_* defines above) + // + // Note: This is not currently parsed from the actual bitstream, so if your + // client has access to a bitstream parser, prefer that over this field. + uint8_t colorspace; } DECODE_UNIT, *PDECODE_UNIT; // Specifies that the audio stream should be encoded in stereo (default) diff --git a/src/VideoDepacketizer.c b/src/VideoDepacketizer.c index 69d5ad6..c86c868 100644 --- a/src/VideoDepacketizer.c +++ b/src/VideoDepacketizer.c @@ -453,6 +453,13 @@ static void reassembleFrame(int frameNumber) { qdu->decodeUnit.presentationTimeMs = firstPacketPresentationTime; qdu->decodeUnit.enqueueTimeMs = LiGetMillis(); + // These might be wrong for a few frames during a transition between SDR and HDR, + // but the effects shouldn't very noticable since that's an infrequent operation. + // + // If we start sending this state in the frame header, we can make it 100% accurate. + qdu->decodeUnit.hdrActive = LiGetCurrentHostDisplayHdrMode(); + qdu->decodeUnit.colorspace = (uint8_t)(qdu->decodeUnit.hdrActive ? COLORSPACE_REC_2020 : StreamConfig.colorSpace); + // IDR frames will have leading CSD buffers if (nalChainHead->bufferType != BUFFER_TYPE_PICDATA) { qdu->decodeUnit.frameType = FRAME_TYPE_IDR;