From 679f6e83bb66a39eee1933aeab312f1764b7b540 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 27 Jul 2018 19:04:25 -0700 Subject: [PATCH] Fix HEVC streams requiring a higher bitrate to enable high quality surround audio --- src/Connection.c | 2 ++ src/Limelight-internal.h | 1 + src/SdpGenerator.c | 3 ++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Connection.c b/src/Connection.c index b763043..7a49403 100644 --- a/src/Connection.c +++ b/src/Connection.c @@ -19,6 +19,7 @@ AUDIO_RENDERER_CALLBACKS AudioCallbacks; int NegotiatedVideoFormat; volatile int ConnectionInterrupted; int HighQualitySurroundEnabled; +int OriginalVideoBitrate; // Connection stages static const char* stageNames[STAGE_MAX] = { @@ -223,6 +224,7 @@ int LiStartConnection(PSERVER_INFORMATION serverInfo, PSTREAM_CONFIGURATION stre NegotiatedVideoFormat = 0; memcpy(&StreamConfig, streamConfig, sizeof(StreamConfig)); + OriginalVideoBitrate = streamConfig->bitrate; RemoteAddrString = strdup(serverInfo->address); // FEC only works in 16 byte chunks, so we must round down diff --git a/src/Limelight-internal.h b/src/Limelight-internal.h index b3e8e84..10bcb8d 100644 --- a/src/Limelight-internal.h +++ b/src/Limelight-internal.h @@ -21,6 +21,7 @@ extern AUDIO_RENDERER_CALLBACKS AudioCallbacks; extern int NegotiatedVideoFormat; extern volatile int ConnectionInterrupted; extern int HighQualitySurroundEnabled; +extern int OriginalVideoBitrate; #ifndef UINT24_MAX #define UINT24_MAX 0xFFFFFF diff --git a/src/SdpGenerator.c b/src/SdpGenerator.c index f6e17dc..94127c5 100644 --- a/src/SdpGenerator.c +++ b/src/SdpGenerator.c @@ -362,7 +362,8 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) { } if (AppVersionQuad[0] >= 7) { - if (StreamConfig.bitrate > HIGH_BITRATE_THRESHOLD && audioChannelCount > 2) { + // Decide to use HQ audio based on the original video bitrate, not the HEVC-adjusted value + if (OriginalVideoBitrate >= HIGH_BITRATE_THRESHOLD && audioChannelCount > 2) { // Enable high quality mode for surround sound err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "1");