diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h index 84c8846a57..b9fc2123b7 100644 --- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h +++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.h @@ -100,9 +100,9 @@ class ACMCodecDB { // samples, and max number of channels that are supported. // neteq_decoders_ - list of supported decoders in NetEQ. static const CodecInst database_[kMaxNumCodecs]; - static const CodecSettings codec_settings_[kMaxNumCodecs]; private: + static const CodecSettings codec_settings_[kMaxNumCodecs]; static const NetEqDecoder neteq_decoders_[kMaxNumCodecs]; friend class RentACodec; diff --git a/webrtc/modules/audio_coding/main/acm2/codec_manager.cc b/webrtc/modules/audio_coding/main/acm2/codec_manager.cc index f9b77e8985..fce6bd7a08 100644 --- a/webrtc/modules/audio_coding/main/acm2/codec_manager.cc +++ b/webrtc/modules/audio_coding/main/acm2/codec_manager.cc @@ -63,8 +63,14 @@ int IsValidSendCodec(const CodecInst& send_codec, bool is_primary_encoder) { return -1; } - if (ACMCodecDB::codec_settings_[codec_id].channel_support < - send_codec.channels) { + const rtc::Maybe supported_num_channels = [codec_id, &send_codec] { + auto cid = RentACodec::CodecIdFromIndex(codec_id); + return cid ? RentACodec::IsSupportedNumChannels(*cid, send_codec.channels) + : rtc::Maybe(); + }(); + if (!supported_num_channels) + return -1; + if (!*supported_num_channels) { WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, dummy_id, "%d number of channels not supportedn for %s.", send_codec.channels, send_codec.plname); diff --git a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc index bee0275efe..76dc7bbf47 100644 --- a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc +++ b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc @@ -50,6 +50,14 @@ bool RentACodec::IsCodecValid(const CodecInst& codec_inst) { return ACMCodecDB::CodecNumber(codec_inst) >= 0; } +rtc::Maybe RentACodec::IsSupportedNumChannels(CodecId codec_id, + int num_channels) { + auto i = CodecIndexFromId(codec_id); + return i ? rtc::Maybe(ACMCodecDB::codec_settings_[*i].channel_support >= + num_channels) + : rtc::Maybe(); +} + rtc::ArrayView RentACodec::Database() { return rtc::ArrayView(ACMCodecDB::database_, NumberOfCodecs()); diff --git a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h index 02749f7423..24ae121a47 100644 --- a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h +++ b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.h @@ -154,6 +154,9 @@ class RentACodec { static bool IsCodecValid(const CodecInst& codec_inst); static rtc::ArrayView Database(); + static rtc::Maybe IsSupportedNumChannels(CodecId codec_id, + int num_channels); + static rtc::Maybe NetEqDecoderFromCodecId(CodecId codec_id, int num_channels); };