Add support for HDR streaming

This commit is contained in:
Cameron Gutman 2017-10-11 23:21:43 -07:00
parent d2229fd6a8
commit a135ceaa9a
3 changed files with 31 additions and 3 deletions

View File

@ -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

View File

@ -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;
}

View File

@ -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) {