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

Unified Diff: webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc

Issue 1673213002: AudioCodingModule: Add methods for injecting external encoder stacks (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: more docs Created 4 years, 10 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/acm2/audio_coding_module_impl.cc
diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
index a7d9df457c1133c79db9752116a106837ed99bf7..34bf87f0f2407706449fefa0128f9abe3133cd21 100644
--- a/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
+++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_impl.cc
@@ -221,16 +221,28 @@ void AudioCodingModuleImpl::RegisterExternalSendCodec(
encoder_stack_ = encoder_factory_->rent_a_codec.RentEncoderStack(sp);
}
+void AudioCodingModuleImpl::VisitEncoder(const EncoderVisitor& ev) {
hlundin-webrtc 2016/02/10 09:45:46 Rename function to ModifyEncoder, or something sim
+ rtc::CritScope lock(&acm_crit_sect_);
+
+ // Wipe the encoder factory, so that everything that relies on it will fail.
+ // We don't want the complexity of supporting swapping back and forth.
+ encoder_factory_.reset();
+
+ encoder_stack_ = ev(encoder_stack_);
+}
+
// Get current send codec.
rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const {
rtc::CritScope lock(&acm_crit_sect_);
- auto* ci = encoder_factory_->codec_manager.GetCodecInst();
- if (ci) {
- return rtc::Optional<CodecInst>(*ci);
+ if (encoder_factory_) {
+ auto* ci = encoder_factory_->codec_manager.GetCodecInst();
+ if (ci) {
+ return rtc::Optional<CodecInst>(*ci);
+ }
}
- auto* enc = encoder_factory_->codec_manager.GetStackParams()->speech_encoder;
- if (enc) {
- return rtc::Optional<CodecInst>(CodecManager::ForgeCodecInst(enc));
+ if (encoder_stack_) {
+ return rtc::Optional<CodecInst>(
+ CodecManager::ForgeCodecInst(encoder_stack_));
}
return rtc::Optional<CodecInst>();
}
@@ -580,10 +592,22 @@ int AudioCodingModuleImpl::PlayoutFrequency() const {
return receiver_.last_output_sample_rate_hz();
}
-// Register possible receive codecs, can be called multiple times,
-// for codecs, CNG (NB, WB and SWB), DTMF, RED.
int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
rtc::CritScope lock(&acm_crit_sect_);
+ auto* ef = encoder_factory_.get();
+ return RegisterReceiveCodecUnlocked(
+ codec, [ef] { return ef->rent_a_codec.RentIsacDecoder(); });
+}
+
+int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec,
+ const DecoderFactory& df) {
+ rtc::CritScope lock(&acm_crit_sect_);
+ return RegisterReceiveCodecUnlocked(codec, df);
+}
+
+int AudioCodingModuleImpl::RegisterReceiveCodecUnlocked(
+ const CodecInst& codec,
+ const DecoderFactory& df) {
RTC_DCHECK(receiver_initialized_);
if (codec.channels > 2) {
LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels;
@@ -610,10 +634,7 @@ int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
// not own its decoder.
return receiver_.AddCodec(
*codec_index, codec.pltype, codec.channels, codec.plfreq,
- STR_CASE_CMP(codec.plname, "isac") == 0
- ? encoder_factory_->rent_a_codec.RentIsacDecoder()
- : nullptr,
- codec.plname);
+ STR_CASE_CMP(codec.plname, "isac") == 0 ? df() : nullptr, codec.plname);
}
int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
« no previous file with comments | « webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h ('k') | webrtc/modules/audio_coding/include/audio_coding_module.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698