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

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

Issue 1412683006: RentACodec: New class that takes over part of ACMCodecDB's job (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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/audio_coding_module_impl.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
index 467e749ccecd73609a83086bdee3d8e22774337b..667bc91b1f0e0060a8e5253dd50bc107576b85e6 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.cc
@@ -36,20 +36,12 @@ namespace {
// TODO(turajs): the same functionality is used in NetEq. If both classes
// need them, make it a static function in ACMCodecDB.
-bool IsCodecRED(const CodecInst* codec) {
- return (STR_CASE_CMP(codec->plname, "RED") == 0);
+bool IsCodecRED(const CodecInst& codec) {
+ return (STR_CASE_CMP(codec.plname, "RED") == 0);
}
-bool IsCodecRED(int index) {
- return (IsCodecRED(&ACMCodecDB::database_[index]));
-}
-
-bool IsCodecCN(const CodecInst* codec) {
- return (STR_CASE_CMP(codec->plname, "CN") == 0);
-}
-
-bool IsCodecCN(int index) {
- return (IsCodecCN(&ACMCodecDB::database_[index]));
+bool IsCodecCN(const CodecInst& codec) {
+ return (STR_CASE_CMP(codec.plname, "CN") == 0);
}
// Stereo-to-mono can be used as in-place.
@@ -513,11 +505,12 @@ int AudioCodingModuleImpl::InitializeReceiverSafe() {
receiver_.FlushBuffers();
// Register RED and CN.
- for (int i = 0; i < ACMCodecDB::kNumCodecs; i++) {
- if (IsCodecRED(i) || IsCodecCN(i)) {
- uint8_t pl_type = static_cast<uint8_t>(ACMCodecDB::database_[i].pltype);
- int fs = ACMCodecDB::database_[i].plfreq;
- if (receiver_.AddCodec(i, pl_type, 1, fs, NULL) < 0) {
+ auto db = RentACodec::Database();
+ for (size_t i = 0; i < db.size(); i++) {
+ if (IsCodecRED(db[i]) || IsCodecCN(db[i])) {
+ uint8_t pl_type = static_cast<uint8_t>(db[i].pltype);
hlundin-webrtc 2015/10/27 13:52:02 const, or maybe move to the line where it is used
kwiberg-webrtc 2015/10/27 14:43:23 Done.
+ int fs = db[i].plfreq;
hlundin-webrtc 2015/10/27 13:52:02 Same again.
kwiberg-webrtc 2015/10/27 14:43:23 Done.
+ if (receiver_.AddCodec(static_cast<int>(i), pl_type, 1, fs, NULL) < 0) {
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, id_,
"Cannot register master codec.");
return -1;
@@ -561,11 +554,14 @@ int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
return -1;
}
- int codec_id = ACMCodecDB::ReceiverCodecNumber(codec);
- if (codec_id < 0 || codec_id >= ACMCodecDB::kNumCodecs) {
+ auto codec_id =
+ RentACodec::CodecIdByParams(codec.plname, codec.plfreq, codec.channels);
+ if (!codec_id) {
LOG_F(LS_ERROR) << "Wrong codec params to be registered as receive codec";
return -1;
}
+ auto codec_index = RentACodec::CodecIndexFromId(*codec_id);
+ RTC_CHECK(codec_index);
hlundin-webrtc 2015/10/27 13:52:02 Add << *codec_id or something similar, so that the
kwiberg-webrtc 2015/10/27 14:43:23 Done.
// Check if the payload-type is valid.
if (!ACMCodecDB::ValidPayloadType(codec.pltype)) {
@@ -576,7 +572,7 @@ int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
// Get |decoder| associated with |codec|. |decoder| is NULL if |codec| does
// not own its decoder.
- return receiver_.AddCodec(codec_id, codec.pltype, codec.channels,
+ return receiver_.AddCodec(*codec_index, codec.pltype, codec.channels,
codec.plfreq,
codec_manager_.GetAudioDecoder(codec));
}

Powered by Google App Engine
This is Rietveld 408576698