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

Unified Diff: webrtc/modules/audio_coding/main/acm2/audio_coding_module.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.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
index 8a0980e6190f3d6526a594a83c6d465937ee14a3..7754a9c375b772b0513ef537994d72a448e3e533 100644
--- a/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
+++ b/webrtc/modules/audio_coding/main/acm2/audio_coding_module.cc
@@ -12,8 +12,8 @@
#include "webrtc/base/checks.h"
#include "webrtc/common_types.h"
-#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
#include "webrtc/modules/audio_coding/main/acm2/audio_coding_module_impl.h"
+#include "webrtc/modules/audio_coding/main/acm2/rent_a_codec.h"
#include "webrtc/system_wrappers/interface/clock.h"
#include "webrtc/system_wrappers/interface/trace.h"
@@ -38,29 +38,32 @@ AudioCodingModule* AudioCodingModule::Create(const Config& config) {
return new acm2::AudioCodingModuleImpl(config);
}
-// Get number of supported codecs
int AudioCodingModule::NumberOfCodecs() {
- return acm2::ACMCodecDB::kNumCodecs;
+ return static_cast<int>(acm2::RentACodec::NumberOfCodecs());
}
-// Get supported codec parameters with id
int AudioCodingModule::Codec(int list_id, CodecInst* codec) {
- // Get the codec settings for the codec with the given list ID
- return acm2::ACMCodecDB::Codec(list_id, codec);
+ auto codec_id = acm2::RentACodec::CodecIdFromIndex(list_id);
+ if (!codec_id)
+ return -1;
+ auto ci = acm2::RentACodec::CodecInstById(*codec_id);
+ if (!ci)
+ return -1;
+ *codec = *ci;
+ return 0;
}
-// Get supported codec parameters with name, frequency and number of channels.
int AudioCodingModule::Codec(const char* payload_name,
CodecInst* codec,
hlundin-webrtc 2015/10/27 13:52:02 Order of parameters is wrong for this method. |cod
kwiberg-webrtc 2015/10/27 14:43:23 This method is going away, so I decided to not cha
hlundin-webrtc 2015/10/27 15:31:27 Acknowledged.
int sampling_freq_hz,
int channels) {
- int codec_id;
-
- // Get the id of the codec from the database.
- codec_id = acm2::ACMCodecDB::CodecId(
+ rtc::Maybe<CodecInst> ci = acm2::RentACodec::CodecInstByParams(
payload_name, sampling_freq_hz, channels);
- if (codec_id < 0) {
- // We couldn't find a matching codec, set the parameters to unacceptable
+ if (ci) {
+ *codec = *ci;
+ return 0;
+ } else {
+ // We couldn't find a matching codec, so set the parameters to unacceptable
// values and return.
codec->plname[0] = '\0';
codec->pltype = -1;
@@ -69,35 +72,26 @@ int AudioCodingModule::Codec(const char* payload_name,
codec->plfreq = 0;
return -1;
}
-
- // Get default codec settings.
- acm2::ACMCodecDB::Codec(codec_id, codec);
-
- // Keep the number of channels from the function call. For most codecs it
- // will be the same value as in default codec settings, but not for all.
- codec->channels = channels;
-
- return 0;
}
-// Get supported codec Index with name, frequency and number of channels.
int AudioCodingModule::Codec(const char* payload_name,
int sampling_freq_hz,
int channels) {
- return acm2::ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels);
+ rtc::Maybe<acm2::RentACodec::CodecId> ci = acm2::RentACodec::CodecIdByParams(
+ payload_name, sampling_freq_hz, channels);
+ if (!ci)
+ return -1;
+ rtc::Maybe<int> i = acm2::RentACodec::CodecIndexFromId(*ci);
+ return i ? *i : -1;
}
// Checks the validity of the parameters of the given codec
bool AudioCodingModule::IsCodecValid(const CodecInst& codec) {
- int codec_number = acm2::ACMCodecDB::CodecNumber(codec);
-
- if (codec_number < 0) {
+ bool valid = acm2::RentACodec::IsCodecValid(codec);
+ if (!valid)
WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1,
"Invalid codec setting");
- return false;
- } else {
- return true;
- }
+ return valid;
}
} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698