Switch to using AudioEncoderOpus instead of ACMOpus
This change switches from the old codec wrapper ACMOpus to the new
AudioEncoderOpus wrapped in an ACMGenericCodecWrapper.
BUG=4228
TEST=Please, try the Opus codec extensively.
COAUTHOR=kwiberg@webrtc.org
R=tina.legrand@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/33259004
Cr-Commit-Position: refs/heads/master@{#8341}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8341 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
index e37e8f6..693efa5 100644
--- a/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
+++ b/webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc
@@ -20,6 +20,16 @@
const int kMinBitrateBps = 500;
const int kMaxBitrateBps = 512000;
+// TODO(tlegrand): Remove this code when we have proper APIs to set the
+// complexity at a higher level.
+#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 as
+// default, to save encoder complexity.
+const int kDefaultComplexity = 5;
+#else
+const int kDefaultComplexity = 9;
+#endif
+
// We always encode at 48 kHz.
const int kSampleRateHz = 48000;
@@ -42,7 +52,8 @@
application(kVoip),
bitrate_bps(64000),
fec_enabled(false),
- max_playback_rate_hz(48000) {
+ max_playback_rate_hz(48000),
+ complexity(kDefaultComplexity) {
}
bool AudioEncoderOpus::Config::IsOk() const {
@@ -52,6 +63,8 @@
return false;
if (bitrate_bps < kMinBitrateBps || bitrate_bps > kMaxBitrateBps)
return false;
+ if (complexity < 0 || complexity > 10)
+ return false;
return true;
}
@@ -75,6 +88,8 @@
}
CHECK_EQ(0,
WebRtcOpus_SetMaxPlaybackRate(inst_, config.max_playback_rate_hz));
+ CHECK_EQ(0, WebRtcOpus_SetComplexity(inst_, config.complexity));
+
}
AudioEncoderOpus::~AudioEncoderOpus() {
diff --git a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h
index c45388b..b615f81 100644
--- a/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h
+++ b/webrtc/modules/audio_coding/codecs/opus/interface/audio_encoder_opus.h
@@ -38,6 +38,7 @@
int bitrate_bps;
bool fec_enabled;
int max_playback_rate_hz;
+ int complexity;
};
explicit AudioEncoderOpus(const Config& config);
diff --git a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
index 9971317..c366295 100644
--- a/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
+++ b/webrtc/modules/audio_coding/main/acm2/acm_codec_database.cc
@@ -695,7 +695,9 @@
#endif
} else if (!STR_CASE_CMP(codec_inst.plname, "opus")) {
#ifdef WEBRTC_CODEC_OPUS
- return new ACMOpus(kOpus, enable_red);
+ return new ACMGenericCodecWrapper(codec_inst, cng_pt_nb, cng_pt_wb,
+ cng_pt_swb, cng_pt_fb, enable_red,
+ red_payload_type);
#endif
} else if (!STR_CASE_CMP(codec_inst.plname, "speex")) {
#ifdef WEBRTC_CODEC_SPEEX