diff --git a/src/Limelight-internal.h b/src/Limelight-internal.h index 2622220..33b59c6 100644 --- a/src/Limelight-internal.h +++ b/src/Limelight-internal.h @@ -45,6 +45,13 @@ extern SS_PING VideoPingPayload; #define SS_FF_CONTROLLER_TOUCH_EVENTS 0x02 extern uint32_t SunshineFeatureFlags; +// ServerCodecModeSupport values +#define SCM_H264 0x00001 +#define SCM_HEVC 0x00100 +#define SCM_HEVC_MAIN10 0x00200 +#define SCM_AV1_MAIN8 0x10000 // Sunshine extension +#define SCM_AV1_MAIN10 0x20000 // Sunshine extension + #ifndef UINT24_MAX #define UINT24_MAX 0xFFFFFF #endif diff --git a/src/Limelight.h b/src/Limelight.h index 8b890b1..e6d0f11 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -65,15 +65,8 @@ typedef struct _STREAM_CONFIGURATION { // See VIDEO_FORMAT constants below. int supportedVideoFormats; - // Specifies that the client is requesting an HDR video stream. - // - // This should only be set if: - // 1) The client decoder supports a 10-bit format (as set in supportedVideoFormats) - // 2) The server has support for HDR as indicated by ServerCodecModeSupport in /serverinfo - // - // See ConnListenerSetHdrMode() for a callback to indicate when to set - // the client display into HDR mode. - bool enableHdr; + // Specifies the 'ServerCodecModeSupport' from the /serverinfo response. + int serverCodecModeSupport; // Specifies the percentage that the specified bitrate will be adjusted // when an HEVC stream will be delivered. This allows clients to opt to diff --git a/src/RtspConnection.c b/src/RtspConnection.c index b4f6baa..df7accb 100644 --- a/src/RtspConnection.c +++ b/src/RtspConnection.c @@ -904,8 +904,8 @@ int performRtspHandshake(PSERVER_INFORMATION serverInfo) { goto Exit; } - if ((StreamConfig.supportedVideoFormats & VIDEO_FORMAT_MASK_AV1) && strstr(response.payload, "a=rtpmap:200 AV1/90000")) { - if (StreamConfig.enableHdr) { + if ((StreamConfig.supportedVideoFormats & VIDEO_FORMAT_MASK_AV1) && strstr(response.payload, "AV1/90000")) { + if (StreamConfig.serverCodecModeSupport & SCM_AV1_MAIN10) { NegotiatedVideoFormat = VIDEO_FORMAT_AV1_MAIN10; } else { @@ -925,7 +925,7 @@ int performRtspHandshake(PSERVER_INFORMATION serverInfo) { // server can support HEVC. For some reason, they still set the MIME type of the HEVC // format to H264, so we can't just look for the HEVC MIME type. What we'll do instead is // look for the base 64 encoded VPS NALU prefix that is unique to the HEVC bitstream. - if (StreamConfig.enableHdr) { + if (StreamConfig.serverCodecModeSupport & SCM_HEVC_MAIN10) { NegotiatedVideoFormat = VIDEO_FORMAT_H265_MAIN10; } else { diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index ee32c75..f5a8daa 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -349,31 +349,11 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { if (NegotiatedVideoFormat & VIDEO_FORMAT_MASK_AV1) { err |= addAttributeString(&optionHead, "x-nv-vqos[0].bitStreamFormat", "2"); - - if (AppVersionQuad[0] >= 7) { - // Enable HDR if requested - if (StreamConfig.enableHdr) { - err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "1"); - } - else { - err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "0"); - } - } } else if (NegotiatedVideoFormat & VIDEO_FORMAT_MASK_H265) { err |= addAttributeString(&optionHead, "x-nv-clientSupportHevc", "1"); err |= addAttributeString(&optionHead, "x-nv-vqos[0].bitStreamFormat", "1"); - if (AppVersionQuad[0] >= 7) { - // Enable HDR if requested - if (StreamConfig.enableHdr) { - err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "1"); - } - else { - err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "0"); - } - } - if (!APP_VERSION_AT_LEAST(7, 1, 408)) { // This disables split frame encode on GFE 3.10 which seems to produce broken // HEVC output at 1080p60 (full of artifacts even on the SHIELD itself, go figure). @@ -383,22 +363,19 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { } } else { - err |= addAttributeString(&optionHead, "x-nv-clientSupportHevc", "0"); err |= addAttributeString(&optionHead, "x-nv-vqos[0].bitStreamFormat", "0"); - - if (AppVersionQuad[0] >= 7) { - // HDR is not supported on H.264 - err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "0"); - } - - // We shouldn't be able to reach this path with enableHdr set. If we did, that means - // the server or client doesn't support HEVC and the client didn't do the correct checks - // before requesting HDR streaming. - LC_ASSERT(!StreamConfig.enableHdr); } if (AppVersionQuad[0] >= 7) { + // Enable HDR if requested + if (NegotiatedVideoFormat & VIDEO_FORMAT_MASK_10BIT) { + err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "1"); + } + else { + err |= addAttributeString(&optionHead, "x-nv-video[0].dynamicRangeMode", "0"); + } + // If the decoder supports reference frame invalidation, that indicates it also supports // the maximum number of reference frames allowed by the codec. Even if we can't use RFI // due to lack of host support, we can still allow the host to pick a number of reference