diff --git a/src/Limelight.h b/src/Limelight.h index 3a7069f..26531cf 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -37,6 +37,14 @@ typedef struct _STREAM_CONFIGURATION { // if the server is able to provide one. int supportsHevc; + // Specifies that the client is requesting an HDR H.265 video stream. + // + // This should only be set if: + // 1) The client decoder supports HEVC Main10 profile (supportsHevc must be set too) + // 2) The server has support for HDR as indicated by ServerCodecModeSupport in /serverinfo + // 3) The app supports HDR as indicated by IsHdrSupported in /applist + int enableHdr; + // Specifies the percentage that the specified bitrate will be adjusted // when an HEVC stream will be delivered. This allows clients to opt to // reduce bandwidth when HEVC is chosen as the video codec rather than diff --git a/src/RtspConnection.c b/src/RtspConnection.c index 47df008..2ff839f 100644 --- a/src/RtspConnection.c +++ b/src/RtspConnection.c @@ -538,8 +538,8 @@ int performRtspHandshake(void) { if (StreamConfig.supportsHevc && strstr(response.payload, "sprop-parameter-sets=AAAAAU")) { NegotiatedVideoFormat = VIDEO_FORMAT_H265; - // Apply bitrate adjustment for HEVC if the client requested one - if (StreamConfig.hevcBitratePercentageMultiplier != 0) { + // Apply bitrate adjustment for SDR HEVC if the client requested one + if (StreamConfig.hevcBitratePercentageMultiplier != 0 && !StreamConfig.enableHdr) { StreamConfig.bitrate *= StreamConfig.hevcBitratePercentageMultiplier; StreamConfig.bitrate /= 100; } diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index 6349ad5..f0ed86d 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -283,13 +283,33 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { // Disable slicing on HEVC err |= addAttributeString(&optionHead, "x-nv-video[0].videoEncoderSlicesPerFrame", "1"); + + if (AppVersionQuad[0] >= 5) { + // 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 { unsigned char slicesPerFrame; err |= addAttributeString(&optionHead, "x-nv-clientSupportHevc", "0"); err |= addAttributeString(&optionHead, "x-nv-vqos[0].bitStreamFormat", "0"); - + + if (AppVersionQuad[0] >= 5) { + // 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); + // Use slicing for increased performance on some decoders slicesPerFrame = (unsigned char)(VideoCallbacks.capabilities >> 24); if (slicesPerFrame == 0) {