mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-17 14:21:30 +00:00
Add support for HDR streaming
This commit is contained in:
@@ -37,6 +37,14 @@ typedef struct _STREAM_CONFIGURATION {
|
|||||||
// if the server is able to provide one.
|
// if the server is able to provide one.
|
||||||
int supportsHevc;
|
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
|
// Specifies the percentage that the specified bitrate will be adjusted
|
||||||
// when an HEVC stream will be delivered. This allows clients to opt to
|
// 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
|
// reduce bandwidth when HEVC is chosen as the video codec rather than
|
||||||
|
|||||||
@@ -538,8 +538,8 @@ int performRtspHandshake(void) {
|
|||||||
if (StreamConfig.supportsHevc && strstr(response.payload, "sprop-parameter-sets=AAAAAU")) {
|
if (StreamConfig.supportsHevc && strstr(response.payload, "sprop-parameter-sets=AAAAAU")) {
|
||||||
NegotiatedVideoFormat = VIDEO_FORMAT_H265;
|
NegotiatedVideoFormat = VIDEO_FORMAT_H265;
|
||||||
|
|
||||||
// Apply bitrate adjustment for HEVC if the client requested one
|
// Apply bitrate adjustment for SDR HEVC if the client requested one
|
||||||
if (StreamConfig.hevcBitratePercentageMultiplier != 0) {
|
if (StreamConfig.hevcBitratePercentageMultiplier != 0 && !StreamConfig.enableHdr) {
|
||||||
StreamConfig.bitrate *= StreamConfig.hevcBitratePercentageMultiplier;
|
StreamConfig.bitrate *= StreamConfig.hevcBitratePercentageMultiplier;
|
||||||
StreamConfig.bitrate /= 100;
|
StreamConfig.bitrate /= 100;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -283,6 +283,16 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
|
|||||||
|
|
||||||
// Disable slicing on HEVC
|
// Disable slicing on HEVC
|
||||||
err |= addAttributeString(&optionHead, "x-nv-video[0].videoEncoderSlicesPerFrame", "1");
|
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 {
|
else {
|
||||||
unsigned char slicesPerFrame;
|
unsigned char slicesPerFrame;
|
||||||
@@ -290,6 +300,16 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
|
|||||||
err |= addAttributeString(&optionHead, "x-nv-clientSupportHevc", "0");
|
err |= addAttributeString(&optionHead, "x-nv-clientSupportHevc", "0");
|
||||||
err |= addAttributeString(&optionHead, "x-nv-vqos[0].bitStreamFormat", "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
|
// Use slicing for increased performance on some decoders
|
||||||
slicesPerFrame = (unsigned char)(VideoCallbacks.capabilities >> 24);
|
slicesPerFrame = (unsigned char)(VideoCallbacks.capabilities >> 24);
|
||||||
if (slicesPerFrame == 0) {
|
if (slicesPerFrame == 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user