Fix high-quality surround sound breaking audio when streaming over the Internet or IPv6

This commit is contained in:
Cameron Gutman 2019-08-04 15:05:40 -07:00
parent c322ed9437
commit a9780361a3
5 changed files with 14 additions and 1 deletions

View File

@ -319,11 +319,13 @@ int startAudioStream(void* audioContext, int arFlags) {
int err;
OPUS_MULTISTREAM_CONFIGURATION chosenConfig;
// TODO: Get these from RTSP ANNOUNCE surround-params
if (StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_STEREO) {
chosenConfig = opusStereoConfig;
}
else if (StreamConfig.audioConfiguration == AUDIO_CONFIGURATION_51_SURROUND) {
if (HighQualitySurroundEnabled) {
LC_ASSERT(HighQualitySurroundSupported);
chosenConfig = opus51HighSurroundConfig;
}
else {

View File

@ -18,6 +18,7 @@ DECODER_RENDERER_CALLBACKS VideoCallbacks;
AUDIO_RENDERER_CALLBACKS AudioCallbacks;
int NegotiatedVideoFormat;
volatile int ConnectionInterrupted;
int HighQualitySurroundSupported;
int HighQualitySurroundEnabled;
int OriginalVideoBitrate;
int AudioPacketDuration;

View File

@ -20,6 +20,7 @@ extern DECODER_RENDERER_CALLBACKS VideoCallbacks;
extern AUDIO_RENDERER_CALLBACKS AudioCallbacks;
extern int NegotiatedVideoFormat;
extern volatile int ConnectionInterrupted;
extern int HighQualitySurroundSupported;
extern int HighQualitySurroundEnabled;
extern int OriginalVideoBitrate;
extern int AudioPacketDuration;

View File

@ -566,6 +566,15 @@ int performRtspHandshake(void) {
NegotiatedVideoFormat = VIDEO_FORMAT_H264;
}
// Check if high bitrate surround sound is available before attempting to request it.
// TODO: Parse these surround-params so we can get rid of our hardcoded Opus mappings
if (strstr(response.payload, "surround-params=660")) {
HighQualitySurroundSupported = 1;
}
else {
HighQualitySurroundSupported = 0;
}
freeMessage(&response);
}

View File

@ -362,7 +362,7 @@ static PSDP_OPTION getAttributesList(char*urlSafeAddr) {
if (AppVersionQuad[0] >= 7) {
// Decide to use HQ audio based on the original video bitrate, not the HEVC-adjusted value
if (OriginalVideoBitrate >= HIGH_AUDIO_BITRATE_THRESHOLD && audioChannelCount > 2 &&
(AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0) {
HighQualitySurroundSupported && (AudioCallbacks.capabilities & CAPABILITY_SLOW_OPUS_DECODER) == 0) {
// Enable high quality mode for surround sound
err |= addAttributeString(&optionHead, "x-nv-audio.surround.AudioQuality", "1");