Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(767)

Unified Diff: webrtc/modules/audio_coding/main/acm2/acm_receiver.cc

Issue 1424083002: Make an enum class out of NetEqDecoder, and hide the neteq_decoders_ table (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
index 611b06aa1f26af3e1d49db2337a153e7003b05d9..1d4458532c47b4ef671dc70479d972b05cae4f3b 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_receiver.cc
@@ -439,15 +439,17 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
int channels,
int sample_rate_hz,
AudioDecoder* audio_decoder) {
- assert(acm_codec_id >= -1); // -1 means external decoder
- NetEqDecoder neteq_decoder = (acm_codec_id == -1)
- ? kDecoderArbitrary
- : ACMCodecDB::neteq_decoders_[acm_codec_id];
-
- // Make sure the right decoder is registered for Opus.
- if (neteq_decoder == kDecoderOpus && channels == 2) {
- neteq_decoder = kDecoderOpus_2ch;
- }
+ const auto neteq_decoder = [acm_codec_id, channels]() -> NetEqDecoder {
+ if (acm_codec_id == -1)
+ return NetEqDecoder::kDecoderArbitrary; // External decoder.
+ const rtc::Maybe<RentACodec::CodecId> cid =
+ RentACodec::CodecIdFromIndex(acm_codec_id);
+ RTC_DCHECK(cid) << "Invalid codec index: " << acm_codec_id;
+ const rtc::Maybe<NetEqDecoder> ned =
+ RentACodec::NetEqDecoderFromCodecId(*cid, channels);
+ RTC_DCHECK(ned) << "Invalid codec ID: " << static_cast<int>(*cid);
+ return *ned;
+ }();
CriticalSectionScoped lock(crit_sect_.get());
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc ('k') | webrtc/modules/audio_coding/main/acm2/rent_a_codec.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698