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

Unified Diff: webrtc/modules/audio_coding/main/acm2/rent_a_codec.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: review fixes 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/rent_a_codec.cc
diff --git a/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc
new file mode 100644
index 0000000000000000000000000000000000000000..45542093e807d50610a7e9bdd8fdd2fd50ad2f67
--- /dev/null
+++ b/webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "webrtc/modules/audio_coding/main/acm2/rent_a_codec.h"
+
+#include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h"
+#include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h"
+
+namespace webrtc {
+namespace acm2 {
+
+rtc::Maybe<RentACodec::CodecId> RentACodec::CodecIdByParams(
+ const char* payload_name,
+ int sampling_freq_hz,
+ int channels) {
+ return CodecIdFromIndex(
+ ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels));
+}
+
+rtc::Maybe<CodecInst> RentACodec::CodecInstById(CodecId codec_id) {
+ rtc::Maybe<int> mi = CodecIndexFromId(codec_id);
+ return mi ? rtc::Maybe<CodecInst>(Database()[*mi]) : rtc::Maybe<CodecInst>();
+}
+
+rtc::Maybe<CodecInst> RentACodec::CodecInstByParams(const char* payload_name,
+ int sampling_freq_hz,
+ int channels) {
+ rtc::Maybe<CodecId> codec_id =
+ CodecIdByParams(payload_name, sampling_freq_hz, channels);
+ if (!codec_id)
+ return rtc::Maybe<CodecInst>();
+ rtc::Maybe<CodecInst> ci = CodecInstById(*codec_id);
+ RTC_DCHECK(ci);
+
+ // 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.
+ ci->channels = channels;
+
+ return ci;
+}
+
+bool RentACodec::IsCodecValid(const CodecInst& codec_inst) {
+ return ACMCodecDB::CodecNumber(codec_inst) >= 0;
+}
+
+rtc::ArrayView<const CodecInst> RentACodec::Database() {
+ return rtc::ArrayView<const CodecInst>(ACMCodecDB::database_,
+ NumberOfCodecs());
+}
+
+} // namespace acm2
+} // namespace webrtc
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/rent_a_codec.h ('k') | webrtc/modules/audio_coding/main/audio_coding_module.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698