From e60a7ef75f02559e7c5271f4e08f815af5f4a8cc Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sat, 14 Dec 2019 14:32:47 -0800 Subject: [PATCH] Add color space and color range options --- src/Limelight.h | 18 ++++++++++++++++++ src/SdpGenerator.c | 5 +++++ 2 files changed, 23 insertions(+) diff --git a/src/Limelight.h b/src/Limelight.h index 0b92ea8..56ac0a6 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -18,6 +18,16 @@ extern "C" { #define STREAM_CFG_REMOTE 1 #define STREAM_CFG_AUTO 2 +// Values for the 'colorSpace' field below. +// Rec. 2020 is only supported with HEVC video streams. +#define COLORSPACE_REC_601 0 +#define COLORSPACE_REC_709 1 +#define COLORSPACE_REC_2020 2 + +// Values for the 'colorRange' field below +#define COLOR_RANGE_LIMITED 0 +#define COLOR_RANGE_FULL 1 + typedef struct _STREAM_CONFIGURATION { // Dimensions in pixels of the desired video stream int width; @@ -68,6 +78,14 @@ typedef struct _STREAM_CONFIGURATION { // of GFE for enhanced frame pacing. int clientRefreshRateX100; + // If specified, sets the encoder colorspace to the provided COLORSPACE_* + // option (listed above). If not set, the encoder will default to Rec 601. + int colorSpace; + + // If specified, sets the encoder color range to the provided COLOR_RANGE_* + // option (listed above). If not set, the encoder will default to Limited. + int colorRange; + // AES encryption data for the remote input stream. This must be // the same as what was passed as rikey and rikeyid // in /launch and /resume requests. diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index cd45ff9..fc22e25 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -393,6 +393,11 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { AudioPacketDuration = 5; } + if (AppVersionQuad[0] >= 7) { + sprintf(payloadStr, "%d", (StreamConfig.colorSpace << 1) | StreamConfig.colorRange); + err |= addAttributeString(&optionHead, "x-nv-video[0].encoderCscMode", payloadStr); + } + if (err == 0) { return optionHead; }