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

Unified Diff: webrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc

Issue 2930243003: Opus implementation of the AudioEncoderFactoryTemplate API (Closed)
Patch Set: rebase Created 3 years, 6 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/api/audio_codecs/opus/audio_encoder_opus_config.cc
diff --git a/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc b/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d4e12e8ce8facb09e6c58d583c23c146f0a58180
--- /dev/null
+++ b/webrtc/api/audio_codecs/opus/audio_encoder_opus_config.cc
@@ -0,0 +1,67 @@
+/*
+ * Copyright (c) 2017 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/api/audio_codecs/opus/audio_encoder_opus_config.h"
+
+namespace webrtc {
+
+namespace {
+
+#if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM)
+// If we are on Android, iOS and/or ARM, use a lower complexity setting by
ossu 2017/06/16 09:53:53 Is this comment copied from somewhere? Otherwise,
kwiberg-webrtc 2017/06/16 12:44:14 Yes, it's a copy. :-) And yes, it's a tautology---
+// default, to save encoder complexity.
+constexpr int kDefaultComplexity = 5;
+#else
+constexpr int kDefaultComplexity = 9;
+#endif
+
+constexpr int kDefaultLowRateComplexity =
+ WEBRTC_OPUS_VARIABLE_COMPLEXITY ? 9 : kDefaultComplexity;
+
+} // namespace
+
+constexpr int AudioEncoderOpusConfig::kDefaultFrameSizeMs;
+constexpr int AudioEncoderOpusConfig::kMinBitrateBps;
+constexpr int AudioEncoderOpusConfig::kMaxBitrateBps;
+
+AudioEncoderOpusConfig::AudioEncoderOpusConfig()
+ : frame_size_ms(kDefaultFrameSizeMs),
ossu 2017/06/16 09:53:53 Would it be preferable to have these directly in t
the sun 2017/06/16 12:44:10 +1
kwiberg-webrtc 2017/06/16 12:44:14 The defaults used to be in the header, but I moved
ossu 2017/06/16 13:18:27 Alright. I guess if you're going to modify the par
+ num_channels(1),
+ application(ApplicationMode::kVoip),
+ bitrate_bps(32000),
+ fec_enabled(false),
+ cbr_enabled(false),
+ max_playback_rate_hz(48000),
+ complexity(kDefaultComplexity),
+ low_rate_complexity(kDefaultLowRateComplexity),
+ complexity_threshold_bps(12500),
+ complexity_threshold_window_bps(1500),
+ dtx_enabled(false),
+ uplink_bandwidth_update_interval_ms(200) {}
+AudioEncoderOpusConfig::AudioEncoderOpusConfig(const AudioEncoderOpusConfig&) =
+ default;
+AudioEncoderOpusConfig::~AudioEncoderOpusConfig() = default;
+AudioEncoderOpusConfig& AudioEncoderOpusConfig::operator=(
+ const AudioEncoderOpusConfig&) = default;
+
+bool AudioEncoderOpusConfig::IsOk() const {
+ if (frame_size_ms <= 0 || frame_size_ms % 10 != 0)
ossu 2017/06/16 09:53:53 Is this strictly true, though? Eh, nvm: is this ho
kwiberg-webrtc 2017/06/16 12:44:14 Supporting < 10 ms frames would be difficult, yes.
ossu 2017/06/16 13:18:27 Agreed.
+ return false;
+ if (num_channels != 1 && num_channels != 2)
+ return false;
+ if (bitrate_bps < kMinBitrateBps || bitrate_bps > kMaxBitrateBps)
+ return false;
+ if (complexity < 0 || complexity > 10)
+ return false;
+ if (low_rate_complexity < 0 || low_rate_complexity > 10)
+ return false;
+ return true;
+}
+} // namespace webrtc

Powered by Google App Engine
This is Rietveld 408576698