Add 7.1 surround sound support

This commit is contained in:
Cameron Gutman 2020-04-03 00:11:41 -07:00
parent d9d2668473
commit 85de16b41b
2 changed files with 22 additions and 9 deletions

View File

@ -156,16 +156,20 @@ typedef struct _DECODE_UNIT {
#define AUDIO_CONFIGURATION_STEREO MAKE_AUDIO_CONFIGURATION(2, 0x3)
// Specifies that the audio stream should be in 5.1 surround sound if the PC is able
#define AUDIO_CONFIGURATION_51_SURROUND MAKE_AUDIO_CONFIGURATION(6, 0xFC)
#define AUDIO_CONFIGURATION_51_SURROUND MAKE_AUDIO_CONFIGURATION(6, 0x3F)
// Specifies that the audio stream should be in 7.1 surround sound if the PC is able
#define AUDIO_CONFIGURATION_71_SURROUND MAKE_AUDIO_CONFIGURATION(8, 0x63F)
// Specifies an audio configuration by channel count and channel mask
// See https://docs.microsoft.com/en-us/windows-hardware/drivers/audio/channel-mask for channelMask values
// NOTE: Not all combinations are supported by GFE and/or this library.
#define MAKE_AUDIO_CONFIGURATION(channelCount, channelMask) \
(((channelMask) << 16) | (channelCount << 8) | 0xCA)
// Helper macros for retreiving channel count and channel mask from the audio configuration
#define CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(x) (((x) >> 8) & 0xFF)
#define CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(x) (((x) >> 16) & 0xFF)
#define CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(x) (((x) >> 16) & 0xFFFF)
// Helper macro to retreive the surroundAudioInfo parameter value that must be passed in
// the /launch and /resume HTTPS requests when starting the session.
@ -173,7 +177,7 @@ typedef struct _DECODE_UNIT {
(CHANNEL_MASK_FROM_AUDIO_CONFIGURATION(x) << 16 | CHANNEL_COUNT_FROM_AUDIO_CONFIGURATION(x))
// The maximum number of channels supported
#define AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT 6
#define AUDIO_CONFIGURATION_MAX_CHANNEL_COUNT 8
// Passed to DecoderRendererSetup to indicate that the following video stream will be
// in H.264 High Profile.
@ -264,8 +268,10 @@ void LiInitializeVideoCallbacks(PDECODER_RENDERER_CALLBACKS drCallbacks);
// 1 - Front Right
// 2 - Center
// 3 - LFE
// 4 - Surround Left
// 5 - Surround Right
// 4 - Back Left
// 5 - Back Right
// 6 - Side Left
// 7 - Side Right
//
// If the mapping order does not match the channel order of the audio renderer, you may swap
// the values in the mismatched indices until the mapping array matches the desired channel order.

View File

@ -518,11 +518,18 @@ static int parseOpusConfigurations(PRTSP_MESSAGE response) {
}
// GFE's normal-quality channel mapping differs from the one our clients use.
// They use FL FR C RL RR LFE, but we use FL FR C LFE RL RR. We'll need
// They use FL FR C RL RR SL SR LFE, but we use FL FR C LFE RL RR SL SR. We'll need
// to swap the mappings to match the expected values.
if (channelCount == 6) {
SWAP_CHANNEL(&NormalQualityOpusConfig, 3, 4);
SWAP_CHANNEL(&NormalQualityOpusConfig, 3, 5);
if (channelCount == 6 || channelCount == 8) {
OPUS_MULTISTREAM_CONFIGURATION originalMapping = NormalQualityOpusConfig;
// LFE comes after C
NormalQualityOpusConfig.mapping[3] = originalMapping.mapping[channelCount - 1];
// Slide everything else up
memcpy(&NormalQualityOpusConfig.mapping[4],
&originalMapping.mapping[3],
channelCount - 4);
}
// If this configuration is compatible with high quality mode, we may have another