From c0596ad1df9828d5ede020681317494405188821 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 25 Sep 2017 21:36:23 -0700 Subject: [PATCH] Add the ability for clients to reduce bitrate when HEVC is used --- src/Limelight.h | 6 ++++++ src/RtspConnection.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Limelight.h b/src/Limelight.h index 6c76888..3a7069f 100644 --- a/src/Limelight.h +++ b/src/Limelight.h @@ -37,6 +37,12 @@ typedef struct _STREAM_CONFIGURATION { // if the server is able to provide one. int supportsHevc; + // 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 + // (or in addition to) improving image quality. + int hevcBitratePercentageMultiplier; + // 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/RtspConnection.c b/src/RtspConnection.c index 2871bae..47df008 100644 --- a/src/RtspConnection.c +++ b/src/RtspConnection.c @@ -537,6 +537,12 @@ int performRtspHandshake(void) { // look for the base 64 encoded VPS NALU prefix that is unique to the HEVC bitstream. 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) { + StreamConfig.bitrate *= StreamConfig.hevcBitratePercentageMultiplier; + StreamConfig.bitrate /= 100; + } } else { NegotiatedVideoFormat = VIDEO_FORMAT_H264;