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

Unified Diff: webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc

Issue 1702943002: Pass ownership of external encoders to the ACM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 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/codecs/cng/audio_encoder_cng.cc
diff --git a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
index 5daf7be30469ce75b87b683fa7d8c8e2f9e21d20..3b48131a754e7f33ce8ded0d5cb259e584d7ae93 100644
--- a/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
+++ b/webrtc/modules/audio_coding/codecs/cng/audio_encoder_cng.cc
@@ -13,6 +13,7 @@
#include <algorithm>
#include <memory>
#include <limits>
+#include <utility>
namespace webrtc {
@@ -35,6 +36,20 @@ std::unique_ptr<CNG_enc_inst, CngInstDeleter> CreateCngInst(
} // namespace
+AudioEncoderCng::Config::Config() = default;
+
+// TODO(kwiberg): =default this when Visual Studio learns to handle it.
+AudioEncoderCng::Config::Config(Config&& c)
+ : num_channels(c.num_channels),
+ payload_type(c.payload_type),
+ speech_encoder(std::move(c.speech_encoder)),
+ vad_mode(c.vad_mode),
+ sid_frame_interval_ms(c.sid_frame_interval_ms),
+ num_cng_coefficients(c.num_cng_coefficients),
+ vad(c.vad) {}
+
+AudioEncoderCng::Config::~Config() = default;
+
bool AudioEncoderCng::Config::IsOk() const {
if (num_channels != 1)
return false;
@@ -51,15 +66,16 @@ bool AudioEncoderCng::Config::IsOk() const {
return true;
}
-AudioEncoderCng::AudioEncoderCng(const Config& config)
- : speech_encoder_(config.speech_encoder),
+AudioEncoderCng::AudioEncoderCng(Config&& config)
+ : speech_encoder_(
+ ([&] { RTC_CHECK(config.IsOk()) << "Invalid configuration."; }(),
+ std::move(config.speech_encoder))),
cng_payload_type_(config.payload_type),
num_cng_coefficients_(config.num_cng_coefficients),
sid_frame_interval_ms_(config.sid_frame_interval_ms),
last_frame_active_(true),
vad_(config.vad ? std::unique_ptr<Vad>(config.vad)
: CreateVad(config.vad_mode)) {
- RTC_CHECK(config.IsOk()) << "Invalid configuration.";
cng_inst_ = CreateCngInst(SampleRateHz(), sid_frame_interval_ms_,
num_cng_coefficients_);
}

Powered by Google App Engine
This is Rietveld 408576698