Index: webrtc/api/audio_codecs/g722/audio_decoder_g722.cc |
diff --git a/webrtc/api/audio_codecs/g722/audio_decoder_g722.cc b/webrtc/api/audio_codecs/g722/audio_decoder_g722.cc |
index e4cb1b7d69340c28a4ec1ff8ace39c842dd4e744..346a7f2779c36345b3087f81e0741898f0d85275 100644 |
--- a/webrtc/api/audio_codecs/g722/audio_decoder_g722.cc |
+++ b/webrtc/api/audio_codecs/g722/audio_decoder_g722.cc |
@@ -23,8 +23,10 @@ namespace webrtc { |
rtc::Optional<AudioDecoderG722::Config> AudioDecoderG722::SdpToConfig( |
const SdpAudioFormat& format) { |
return STR_CASE_CMP(format.name.c_str(), "g722") == 0 && |
- format.clockrate_hz == 8000 |
- ? rtc::Optional<Config>(Config()) |
+ format.clockrate_hz == 8000 && |
+ (format.num_channels == 1 || format.num_channels == 2) |
+ ? rtc::Optional<Config>( |
+ Config{rtc::dchecked_cast<int>(format.num_channels)}) |
: rtc::Optional<Config>(); |
} |
@@ -35,7 +37,14 @@ void AudioDecoderG722::AppendSupportedDecoders( |
std::unique_ptr<AudioDecoder> AudioDecoderG722::MakeAudioDecoder( |
Config config) { |
- return rtc::MakeUnique<AudioDecoderG722Impl>(); |
+ switch (config.num_channels) { |
+ case 1: |
+ return rtc::MakeUnique<AudioDecoderG722Impl>(); |
+ case 2: |
+ return rtc::MakeUnique<AudioDecoderG722StereoImpl>(); |
+ default: |
+ return nullptr; |
+ } |
} |
} // namespace webrtc |