From e0eae3cec6f986ed756e644c596d897ce79646d8 Mon Sep 17 00:00:00 2001 From: peah Date: Wed, 14 Dec 2016 01:16:23 -0800 Subject: [PATCH] This CL adds the basic framework for AEC3 in the audio processing module. It will be followed by a number of other CLs that extends this framework. BUG=webrtc:6018 Review-Url: https://codereview.webrtc.org/2567513003 Cr-Commit-Position: refs/heads/master@{#15593} --- webrtc/modules/audio_processing/BUILD.gn | 2 + .../modules/audio_processing/aec/aec_core.cc | 10 --- .../modules/audio_processing/aec/aec_core.h | 9 +-- .../audio_processing/aec3/echo_canceller3.cc | 57 +++++++++++++ .../audio_processing/aec3/echo_canceller3.h | 48 +++++++++++ .../audio_processing/audio_processing_impl.cc | 80 +++++++++++++++++-- .../audio_processing/audio_processing_impl.h | 4 + .../echo_cancellation_impl.cc | 17 +--- .../audio_processing/echo_cancellation_impl.h | 2 - .../include/audio_processing.h | 19 ++--- .../modules/audio_processing/include/config.h | 8 +- .../test/aec_dump_based_simulator.cc | 2 +- .../test/audio_processing_simulator.cc | 2 +- .../audio_processing/test/debug_dump_test.cc | 14 ++-- 14 files changed, 208 insertions(+), 66 deletions(-) create mode 100644 webrtc/modules/audio_processing/aec3/echo_canceller3.cc create mode 100644 webrtc/modules/audio_processing/aec3/echo_canceller3.h diff --git a/webrtc/modules/audio_processing/BUILD.gn b/webrtc/modules/audio_processing/BUILD.gn index 6ad77750a5..0aea170673 100644 --- a/webrtc/modules/audio_processing/BUILD.gn +++ b/webrtc/modules/audio_processing/BUILD.gn @@ -26,6 +26,8 @@ rtc_static_library("audio_processing") { "aec/aec_resampler.h", "aec/echo_cancellation.cc", "aec/echo_cancellation.h", + "aec3/echo_canceller3.cc", + "aec3/echo_canceller3.h", "aecm/aecm_core.cc", "aecm/aecm_core.h", "aecm/echo_control_mobile.cc", diff --git a/webrtc/modules/audio_processing/aec/aec_core.cc b/webrtc/modules/audio_processing/aec/aec_core.cc index 814c38b4ba..f9e96ace04 100644 --- a/webrtc/modules/audio_processing/aec/aec_core.cc +++ b/webrtc/modules/audio_processing/aec/aec_core.cc @@ -1500,7 +1500,6 @@ AecCore* WebRtcAec_CreateAec(int instance_count) { WebRtc_set_lookahead(aec->delay_estimator, kLookaheadBlocks); #endif aec->extended_filter_enabled = 0; - aec->aec3_enabled = 0; aec->refined_adaptive_filter_enabled = false; // Assembly optimization @@ -2014,15 +2013,6 @@ int WebRtcAec_delay_agnostic_enabled(AecCore* self) { return self->delay_agnostic_enabled; } -void WebRtcAec_enable_aec3(AecCore* self, int enable) { - self->aec3_enabled = (enable != 0); -} - -int WebRtcAec_aec3_enabled(AecCore* self) { - RTC_DCHECK(self->aec3_enabled == 0 || self->aec3_enabled == 1); - return self->aec3_enabled; -} - void WebRtcAec_enable_refined_adaptive_filter(AecCore* self, bool enable) { self->refined_adaptive_filter_enabled = enable; SetAdaptiveFilterStepSize(self); diff --git a/webrtc/modules/audio_processing/aec/aec_core.h b/webrtc/modules/audio_processing/aec/aec_core.h index 0c491980c2..78cb787fa7 100644 --- a/webrtc/modules/audio_processing/aec/aec_core.h +++ b/webrtc/modules/audio_processing/aec/aec_core.h @@ -239,8 +239,7 @@ struct AecCore { int delay_agnostic_enabled; // 1 = extended filter mode enabled, 0 = disabled. int extended_filter_enabled; - // 1 = next generation aec mode enabled, 0 = disabled. - int aec3_enabled; + // 1 = refined filter adaptation aec mode enabled, 0 = disabled. bool refined_adaptive_filter_enabled; // Runtime selection of number of filter partitions. @@ -310,12 +309,6 @@ void WebRtcAec_enable_delay_agnostic(AecCore* self, int enable); // enabled and zero if disabled. int WebRtcAec_delay_agnostic_enabled(AecCore* self); -// Non-zero enables, zero disables. -void WebRtcAec_enable_aec3(AecCore* self, int enable); - -// Returns 1 if the next generation aec is enabled and zero if disabled. -int WebRtcAec_aec3_enabled(AecCore* self); - // Turns on/off the refined adaptive filter feature. void WebRtcAec_enable_refined_adaptive_filter(AecCore* self, bool enable); diff --git a/webrtc/modules/audio_processing/aec3/echo_canceller3.cc b/webrtc/modules/audio_processing/aec3/echo_canceller3.cc new file mode 100644 index 0000000000..e69ccdcbc6 --- /dev/null +++ b/webrtc/modules/audio_processing/aec3/echo_canceller3.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2016 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_processing/aec3/echo_canceller3.h" + +#include "webrtc/base/atomicops.h" +#include "webrtc/system_wrappers/include/logging.h" + +namespace webrtc { + +int EchoCanceller3::instance_count_ = 0; + +EchoCanceller3::EchoCanceller3(int sample_rate_hz, bool use_anti_hum_filter) { + int band_sample_rate_hz = (sample_rate_hz == 8000 ? sample_rate_hz : 16000); + frame_length_ = rtc::CheckedDivExact(band_sample_rate_hz, 100); + + LOG(LS_INFO) << "AEC3 created : " + << "{ instance_count: " << instance_count_ << "}"; + instance_count_ = rtc::AtomicOps::Increment(&instance_count_); +} + +EchoCanceller3::~EchoCanceller3() = default; + +bool EchoCanceller3::AnalyzeRender(AudioBuffer* render) { + RTC_DCHECK_EQ(1u, render->num_channels()); + RTC_DCHECK_EQ(frame_length_, render->num_frames_per_band()); + return true; +} + +void EchoCanceller3::AnalyzeCapture(AudioBuffer* capture) {} + +void EchoCanceller3::ProcessCapture(AudioBuffer* capture, + bool known_echo_path_change) { + RTC_DCHECK_EQ(1u, capture->num_channels()); + RTC_DCHECK_EQ(frame_length_, capture->num_frames_per_band()); +} + +std::string EchoCanceller3::ToString( + const AudioProcessing::Config::EchoCanceller3& config) { + std::stringstream ss; + ss << "{" + << "enabled: " << (config.enabled ? "true" : "false") << "}"; + return ss.str(); +} + +bool EchoCanceller3::Validate( + const AudioProcessing::Config::EchoCanceller3& config) { + return true; +} + +} // namespace webrtc diff --git a/webrtc/modules/audio_processing/aec3/echo_canceller3.h b/webrtc/modules/audio_processing/aec3/echo_canceller3.h new file mode 100644 index 0000000000..c65ecdea75 --- /dev/null +++ b/webrtc/modules/audio_processing/aec3/echo_canceller3.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016 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. + */ + +#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ + +#include + +#include "webrtc/base/constructormagic.h" +#include "webrtc/modules/audio_processing/audio_buffer.h" + +namespace webrtc { + +class EchoCanceller3 { + public: + EchoCanceller3(int sample_rate_hz, bool use_anti_hum_filter); + ~EchoCanceller3(); + // Analyzes and stores an internal copy of the split-band domain render + // signal. + bool AnalyzeRender(AudioBuffer* farend); + // Analyzes the full-band domain capture signal to detect signal saturation. + void AnalyzeCapture(AudioBuffer* capture); + // Processes the split-band domain capture signal in order to remove any echo + // present in the signal. + void ProcessCapture(AudioBuffer* capture, bool known_echo_path_change); + + // Validates a config. + static bool Validate(const AudioProcessing::Config::EchoCanceller3& config); + // Dumps a config to a string. + static std::string ToString( + const AudioProcessing::Config::EchoCanceller3& config); + + private: + static int instance_count_; + size_t frame_length_; + + RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCanceller3); +}; +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_ diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 5ca9275f0e..ce71461b2e 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -20,6 +20,7 @@ #include "webrtc/common_audio/include/audio_util.h" #include "webrtc/common_audio/signal_processing/include/signal_processing_library.h" #include "webrtc/modules/audio_processing/aec/aec_core.h" +#include "webrtc/modules/audio_processing/aec3/echo_canceller3.h" #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h" #include "webrtc/modules/audio_processing/audio_buffer.h" #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" @@ -167,6 +168,7 @@ bool AudioProcessingImpl::ApmSubmoduleStates::Update( bool beamformer_enabled, bool adaptive_gain_controller_enabled, bool level_controller_enabled, + bool echo_canceller3_enabled, bool voice_activity_detector_enabled, bool level_estimator_enabled, bool transient_suppressor_enabled) { @@ -184,6 +186,7 @@ bool AudioProcessingImpl::ApmSubmoduleStates::Update( changed |= (adaptive_gain_controller_enabled != adaptive_gain_controller_enabled_); changed |= (level_controller_enabled != level_controller_enabled_); + changed |= (echo_canceller3_enabled != echo_canceller3_enabled_); changed |= (level_estimator_enabled != level_estimator_enabled_); changed |= (voice_activity_detector_enabled != voice_activity_detector_enabled_); @@ -198,6 +201,7 @@ bool AudioProcessingImpl::ApmSubmoduleStates::Update( beamformer_enabled_ = beamformer_enabled; adaptive_gain_controller_enabled_ = adaptive_gain_controller_enabled; level_controller_enabled_ = level_controller_enabled; + echo_canceller3_enabled_ = echo_canceller3_enabled; level_estimator_enabled_ = level_estimator_enabled; voice_activity_detector_enabled_ = voice_activity_detector_enabled; transient_suppressor_enabled_ = transient_suppressor_enabled; @@ -224,14 +228,15 @@ bool AudioProcessingImpl::ApmSubmoduleStates::CaptureMultiBandProcessingActive() const { return low_cut_filter_enabled_ || echo_canceller_enabled_ || mobile_echo_controller_enabled_ || noise_suppressor_enabled_ || - beamformer_enabled_ || adaptive_gain_controller_enabled_; + beamformer_enabled_ || adaptive_gain_controller_enabled_ || + echo_canceller3_enabled_; } bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandSubModulesActive() const { return RenderMultiBandProcessingActive() || echo_canceller_enabled_ || mobile_echo_controller_enabled_ || adaptive_gain_controller_enabled_ || - residual_echo_detector_enabled_; + residual_echo_detector_enabled_ || echo_canceller3_enabled_; } bool AudioProcessingImpl::ApmSubmoduleStates::RenderMultiBandProcessingActive() @@ -271,6 +276,7 @@ struct AudioProcessingImpl::ApmPrivateSubmodules { std::unique_ptr low_cut_filter; std::unique_ptr level_controller; std::unique_ptr residual_echo_detector; + std::unique_ptr echo_canceller3; }; AudioProcessing* AudioProcessing::Create() { @@ -433,10 +439,18 @@ int AudioProcessingImpl::MaybeInitialize( } int AudioProcessingImpl::InitializeLocked() { - const int capture_audiobuffer_num_channels = - capture_nonlocked_.beamformer_enabled - ? formats_.api_format.input_stream().num_channels() - : formats_.api_format.output_stream().num_channels(); + int capture_audiobuffer_num_channels; + if (private_submodules_->echo_canceller3) { + // TODO(peah): Ensure that the echo canceller can operate on more than one + // microphone channel. + RTC_DCHECK(!capture_nonlocked_.beamformer_enabled); + capture_audiobuffer_num_channels = 1; + } else { + capture_audiobuffer_num_channels = + capture_nonlocked_.beamformer_enabled + ? formats_.api_format.input_stream().num_channels() + : formats_.api_format.output_stream().num_channels(); + } const int render_audiobuffer_num_output_frames = formats_.api_format.reverse_output_stream().num_frames() == 0 ? formats_.render_processing_format.num_frames() @@ -508,6 +522,7 @@ int AudioProcessingImpl::InitializeLocked() { public_submodules_->level_estimator->Initialize(); InitializeLevelController(); InitializeResidualEchoDetector(); + InitializeEchoCanceller3(); #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP if (debug_dump_.debug_file->is_open()) { @@ -561,7 +576,9 @@ int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) { submodule_states_.RenderMultiBandSubModulesActive()); // TODO(aluebs): Remove this restriction once we figure out why the 3-band // splitting filter degrades the AEC performance. - if (render_processing_rate > kSampleRate32kHz) { + // TODO(peah): Verify that the band splitting is needed for the AEC3. + if (render_processing_rate > kSampleRate32kHz && + !capture_nonlocked_.echo_canceller3_enabled) { render_processing_rate = submodule_states_.RenderMultiBandProcessingActive() ? kSampleRate32kHz : kSampleRate16kHz; @@ -629,6 +646,25 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) { LOG(LS_INFO) << "Highpass filter activated: " << config_.high_pass_filter.enabled; + + config_ok = EchoCanceller3::Validate(config_.echo_canceller3); + if (!config_ok) { + LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl + << "echo canceller 3: " + << EchoCanceller3::ToString(config_.echo_canceller3) + << std::endl + << "Reverting to default parameter set"; + config_.echo_canceller3 = AudioProcessing::Config::EchoCanceller3(); + } + + if (config.echo_canceller3.enabled != + capture_nonlocked_.echo_canceller3_enabled) { + capture_nonlocked_.echo_canceller3_enabled = + config_.echo_canceller3.enabled; + InitializeEchoCanceller3(); + LOG(LS_INFO) << "Echo canceller 3 activated: " + << capture_nonlocked_.echo_canceller3_enabled; + } } void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { @@ -1108,6 +1144,10 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { levels.peak, 1, RmsLevel::kMinLevelDb, 64); } + if (private_submodules_->echo_canceller3) { + private_submodules_->echo_canceller3->AnalyzeCapture(capture_buffer); + } + if (constants_.use_experimental_agc && public_submodules_->gain_control->is_enabled()) { private_submodules_->agc_manager->AnalyzePreProcess( @@ -1128,7 +1168,9 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { capture_buffer->set_num_channels(1); } - if (private_submodules_->low_cut_filter) { + // TODO(peah): Move the AEC3 low-cut filter to this place. + if (private_submodules_->low_cut_filter && + !private_submodules_->echo_canceller3) { private_submodules_->low_cut_filter->Process(capture_buffer); } RETURN_ON_ERR( @@ -1142,6 +1184,10 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() { return AudioProcessing::kStreamParameterNotSetError; } + if (private_submodules_->echo_canceller3) { + private_submodules_->echo_canceller3->ProcessCapture(capture_buffer, false); + } + RETURN_ON_ERR(public_submodules_->echo_cancellation->ProcessCaptureAudio( capture_buffer, stream_delay_ms())); @@ -1381,6 +1427,12 @@ int AudioProcessingImpl::ProcessRenderStreamLocked() { #endif QueueRenderAudio(render_buffer); + // TODO(peah): Perform the queueing ínside QueueRenderAudiuo(). + if (private_submodules_->echo_canceller3) { + if (!private_submodules_->echo_canceller3->AnalyzeRender(render_buffer)) { + // TODO(peah): Lock and empty render queue, and try again. + } + } if (submodule_states_.RenderMultiBandProcessingActive() && SampleRateSupportsMultiBand( @@ -1604,6 +1656,7 @@ bool AudioProcessingImpl::UpdateActiveSubmoduleStates() { capture_nonlocked_.beamformer_enabled, public_submodules_->gain_control->is_enabled(), capture_nonlocked_.level_controller_enabled, + capture_nonlocked_.echo_canceller3_enabled, public_submodules_->voice_detection->is_enabled(), public_submodules_->level_estimator->is_enabled(), capture_.transient_suppressor_enabled); @@ -1652,6 +1705,14 @@ void AudioProcessingImpl::InitializeLowCutFilter() { private_submodules_->low_cut_filter.reset(); } } +void AudioProcessingImpl::InitializeEchoCanceller3() { + if (capture_nonlocked_.echo_canceller3_enabled) { + private_submodules_->echo_canceller3.reset( + new EchoCanceller3(proc_sample_rate_hz(), true)); + } else { + private_submodules_->echo_canceller3.reset(); + } +} void AudioProcessingImpl::InitializeLevelController() { private_submodules_->level_controller->Initialize(proc_sample_rate_hz()); @@ -1857,6 +1918,9 @@ int AudioProcessingImpl::WriteConfigMessage(bool forced) { if (constants_.agc_clipped_level_min != kClippedLevelMin) { experiments_description += "AgcClippingLevelExperiment;"; } + if (capture_nonlocked_.echo_canceller3_enabled) { + experiments_description += "EchoCanceller3;"; + } config.set_experiments_description(experiments_description); std::string serialized_config = config.SerializeAsString(); diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h index 0375a25328..ae4d89b131 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.h +++ b/webrtc/modules/audio_processing/audio_processing_impl.h @@ -168,6 +168,7 @@ class AudioProcessingImpl : public AudioProcessing { bool beamformer_enabled, bool adaptive_gain_controller_enabled, bool level_controller_enabled, + bool echo_canceller3_enabled, bool voice_activity_detector_enabled, bool level_estimator_enabled, bool transient_suppressor_enabled); @@ -186,6 +187,7 @@ class AudioProcessingImpl : public AudioProcessing { bool beamformer_enabled_ = false; bool adaptive_gain_controller_enabled_ = false; bool level_controller_enabled_ = false; + bool echo_canceller3_enabled_ = false; bool level_estimator_enabled_ = false; bool voice_activity_detector_enabled_ = false; bool transient_suppressor_enabled_ = false; @@ -251,6 +253,7 @@ class AudioProcessingImpl : public AudioProcessing { void InitializeResidualEchoDetector() EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); void InitializeLowCutFilter() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); + void InitializeEchoCanceller3() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); void EmptyQueuedRenderAudio(); void AllocateRenderQueue() @@ -382,6 +385,7 @@ class AudioProcessingImpl : public AudioProcessing { bool beamformer_enabled; bool intelligibility_enabled; bool level_controller_enabled = false; + bool echo_canceller3_enabled = false; } capture_nonlocked_; struct ApmRenderState { diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index f6a0bcde7a..9918bb4738 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -106,8 +106,7 @@ EchoCancellationImpl::EchoCancellationImpl(rtc::CriticalSection* crit_render, stream_has_echo_(false), delay_logging_enabled_(false), extended_filter_enabled_(false), - delay_agnostic_enabled_(false), - aec3_enabled_(false) { + delay_agnostic_enabled_(false) { RTC_DCHECK(crit_render); RTC_DCHECK(crit_capture); } @@ -341,18 +340,9 @@ bool EchoCancellationImpl::is_delay_agnostic_enabled() const { return delay_agnostic_enabled_; } -bool EchoCancellationImpl::is_aec3_enabled() const { - rtc::CritScope cs(crit_capture_); - return aec3_enabled_; -} - std::string EchoCancellationImpl::GetExperimentsDescription() { rtc::CritScope cs(crit_capture_); - std::string description = (aec3_enabled_ ? "AEC3;" : ""); - if (refined_adaptive_filter_enabled_) { - description += "RefinedAdaptiveFilter;"; - } - return description; + return refined_adaptive_filter_enabled_ ? "RefinedAdaptiveFilter;" : ""; } bool EchoCancellationImpl::is_refined_adaptive_filter_enabled() const { @@ -473,7 +463,6 @@ void EchoCancellationImpl::SetExtraOptions(const webrtc::Config& config) { delay_agnostic_enabled_ = config.Get().enabled; refined_adaptive_filter_enabled_ = config.Get().enabled; - aec3_enabled_ = config.Get().enabled; } Configure(); } @@ -493,8 +482,6 @@ int EchoCancellationImpl::Configure() { extended_filter_enabled_ ? 1 : 0); WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(canceller->state()), delay_agnostic_enabled_ ? 1 : 0); - WebRtcAec_enable_aec3(WebRtcAec_aec_core(canceller->state()), - aec3_enabled_ ? 1 : 0); WebRtcAec_enable_refined_adaptive_filter( WebRtcAec_aec_core(canceller->state()), refined_adaptive_filter_enabled_); diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.h b/webrtc/modules/audio_processing/echo_cancellation_impl.h index 03be98529a..19da98196e 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.h +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.h @@ -44,7 +44,6 @@ class EchoCancellationImpl : public EchoCancellation { void SetExtraOptions(const webrtc::Config& config); bool is_delay_agnostic_enabled() const; bool is_extended_filter_enabled() const; - bool is_aec3_enabled() const; std::string GetExperimentsDescription(); bool is_refined_adaptive_filter_enabled() const; @@ -104,7 +103,6 @@ class EchoCancellationImpl : public EchoCancellation { bool delay_logging_enabled_ GUARDED_BY(crit_capture_); bool extended_filter_enabled_ GUARDED_BY(crit_capture_); bool delay_agnostic_enabled_ GUARDED_BY(crit_capture_); - bool aec3_enabled_ GUARDED_BY(crit_capture_); bool refined_adaptive_filter_enabled_ GUARDED_BY(crit_capture_) = false; std::vector> cancellers_; diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h index d03c7f4ab4..d1a711dfa6 100644 --- a/webrtc/modules/audio_processing/include/audio_processing.h +++ b/webrtc/modules/audio_processing/include/audio_processing.h @@ -68,17 +68,6 @@ struct ExtendedFilter { bool enabled; }; -// Enables the next generation AEC functionality. This feature replaces the -// standard methods for echo removal in the AEC. This configuration only applies -// to EchoCancellation and not EchoControlMobile. It can be set in the -// constructor or using AudioProcessing::SetExtraOptions(). -struct EchoCanceller3 { - EchoCanceller3() : enabled(false) {} - explicit EchoCanceller3(bool enabled) : enabled(enabled) {} - static const ConfigOptionID identifier = ConfigOptionID::kEchoCanceller3; - bool enabled; -}; - // Enables the refined linear filter adaptation in the echo canceller. // This configuration only applies to EchoCancellation and not // EchoControlMobile. It can be set in the constructor @@ -274,6 +263,14 @@ class AudioProcessing { struct HighPassFilter { bool enabled = false; } high_pass_filter; + + // Enables the next generation AEC functionality. This feature replaces the + // standard methods for echo removal in the AEC. + // The functionality is not yet activated in the code and turning this on + // does not yet have the desired behavior. + struct EchoCanceller3 { + bool enabled = false; + } echo_canceller3; }; // TODO(mgraczyk): Remove once all methods that use ChannelLayout are gone. diff --git a/webrtc/modules/audio_processing/include/config.h b/webrtc/modules/audio_processing/include/config.h index 615e3fa3ec..0473d2d8cb 100644 --- a/webrtc/modules/audio_processing/include/config.h +++ b/webrtc/modules/audio_processing/include/config.h @@ -24,16 +24,16 @@ enum class ConfigOptionID { kMyExperimentForTest, kAlgo1CostFunctionForTest, kTemporalLayersFactory, // Deprecated - kNetEqCapacityConfig, // Deprecated - kNetEqFastAccelerate, // Deprecated - kVoicePacing, // Deprecated + kNetEqCapacityConfig, // Deprecated + kNetEqFastAccelerate, // Deprecated + kVoicePacing, // Deprecated kExtendedFilter, kDelayAgnostic, kExperimentalAgc, kExperimentalNs, kBeamforming, kIntelligibility, - kEchoCanceller3, + kEchoCanceller3, // Deprecated kAecRefinedAdaptiveFilter, kLevelControl }; diff --git a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc index b117dbbebe..10d4fcdf6f 100644 --- a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc +++ b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc @@ -491,7 +491,7 @@ void AecDumpBasedSimulator::HandleMessage( } if (settings_.use_aec3) { - config.Set(new EchoCanceller3(*settings_.use_aec3)); + apm_config.echo_canceller3.enabled = *settings_.use_aec3; } if (settings_.use_lc) { diff --git a/webrtc/modules/audio_processing/test/audio_processing_simulator.cc b/webrtc/modules/audio_processing/test/audio_processing_simulator.cc index ddfc562aaf..27b3803a19 100644 --- a/webrtc/modules/audio_processing/test/audio_processing_simulator.cc +++ b/webrtc/modules/audio_processing/test/audio_processing_simulator.cc @@ -268,7 +268,7 @@ void AudioProcessingSimulator::CreateAudioProcessor() { config.Set(new Intelligibility(*settings_.use_ie)); } if (settings_.use_aec3) { - config.Set(new EchoCanceller3(*settings_.use_aec3)); + apm_config.echo_canceller3.enabled = *settings_.use_aec3; } if (settings_.use_lc) { apm_config.level_controller.enabled = *settings_.use_lc; diff --git a/webrtc/modules/audio_processing/test/debug_dump_test.cc b/webrtc/modules/audio_processing/test/debug_dump_test.cc index ebf899f82a..d67a73e40c 100644 --- a/webrtc/modules/audio_processing/test/debug_dump_test.cc +++ b/webrtc/modules/audio_processing/test/debug_dump_test.cc @@ -377,11 +377,12 @@ TEST_F(DebugDumpTest, VerifyRefinedAdaptiveFilterExperimentalString) { TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) { Config config; + AudioProcessing::Config apm_config; config.Set(new RefinedAdaptiveFilter(true)); - config.Set(new EchoCanceller3(true)); // Arbitrarily set clipping gain to 17, which will never be the default. config.Set(new ExperimentalAgc(true, 0, 17)); - DebugDumpGenerator generator(config, AudioProcessing::Config()); + apm_config.echo_canceller3.enabled = true; + DebugDumpGenerator generator(config, apm_config); generator.StartRecording(); generator.Process(100); generator.StopRecording(); @@ -398,7 +399,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) { ASSERT_TRUE(msg->has_experiments_description()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "RefinedAdaptiveFilter", msg->experiments_description().c_str()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, "AEC3", + EXPECT_PRED_FORMAT2(testing::IsSubstring, "EchoCanceller3", msg->experiments_description().c_str()); EXPECT_PRED_FORMAT2(testing::IsSubstring, "AgcClippingLevelExperiment", msg->experiments_description().c_str()); @@ -436,8 +437,9 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringExclusive) { TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) { Config config; - config.Set(new EchoCanceller3(true)); - DebugDumpGenerator generator(config, AudioProcessing::Config()); + AudioProcessing::Config apm_config; + apm_config.echo_canceller3.enabled = true; + DebugDumpGenerator generator(config, apm_config); generator.StartRecording(); generator.Process(100); generator.StopRecording(); @@ -452,7 +454,7 @@ TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) { if (event->type() == audioproc::Event::CONFIG) { const audioproc::Config* msg = &event->config(); ASSERT_TRUE(msg->has_experiments_description()); - EXPECT_PRED_FORMAT2(testing::IsSubstring, "AEC3", + EXPECT_PRED_FORMAT2(testing::IsSubstring, "EchoCanceller3", msg->experiments_description().c_str()); } }