Toggle AECs via AudioProcessing::Config

This allows clients to stop using the old pointer-to-submodule interfaces
for enabling/disabling AEC2 and AECM.

The legacy suppression level flag for AEC2 is not yet activated.

NoTry=TRUE

Bug: webrtc:9535
Change-Id: Ie2c3378d832a6b393aec656d96597f85e299f500
Reviewed-on: https://webrtc-review.googlesource.com/94771
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24328}
This commit is contained in:
Sam Zackrisson
2018-08-17 16:26:14 +02:00
committed by Commit Bot
parent 3229d65fd0
commit b3b47ad7e6
4 changed files with 21 additions and 13 deletions

View File

@ -677,6 +677,13 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
rtc::CritScope cs_render(&crit_render_);
rtc::CritScope cs_capture(&crit_capture_);
static_cast<EchoCancellation*>(public_submodules_->echo_cancellation.get())
->Enable(config_.echo_canceller.enabled &&
!config_.echo_canceller.mobile_mode);
static_cast<EchoControlMobile*>(public_submodules_->echo_control_mobile.get())
->Enable(config_.echo_canceller.enabled &&
config_.echo_canceller.mobile_mode);
InitializeLowCutFilter();
RTC_LOG(LS_INFO) << "Highpass filter activated: "

View File

@ -178,25 +178,26 @@ bool FrameDataAreEqual(const AudioFrame& frame1, const AudioFrame& frame2) {
}
void EnableAllAPComponents(AudioProcessing* ap) {
AudioProcessing::Config apm_config = ap->GetConfig();
apm_config.echo_canceller.enabled = true;
#if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE)
EXPECT_NOERR(ap->echo_control_mobile()->Enable(true));
apm_config.echo_canceller.mobile_mode = true;
EXPECT_NOERR(ap->gain_control()->set_mode(GainControl::kAdaptiveDigital));
EXPECT_NOERR(ap->gain_control()->Enable(true));
#elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE)
apm_config.echo_canceller.mobile_mode = false;
EXPECT_NOERR(ap->echo_cancellation()->enable_drift_compensation(true));
EXPECT_NOERR(ap->echo_cancellation()->enable_metrics(true));
EXPECT_NOERR(ap->echo_cancellation()->enable_delay_logging(true));
EXPECT_NOERR(ap->echo_cancellation()->set_suppression_level(
EchoCancellation::SuppressionLevel::kModerateSuppression));
EXPECT_NOERR(ap->echo_cancellation()->Enable(true));
EXPECT_NOERR(ap->gain_control()->set_mode(GainControl::kAdaptiveAnalog));
EXPECT_NOERR(ap->gain_control()->set_analog_level_limits(0, 255));
EXPECT_NOERR(ap->gain_control()->Enable(true));
#endif
AudioProcessing::Config apm_config;
apm_config.high_pass_filter.enabled = true;
ap->ApplyConfig(apm_config);

View File

@ -200,10 +200,11 @@ void DebugDumpReplayer::MaybeRecreateApm(const audioproc::Config& msg) {
void DebugDumpReplayer::ConfigureApm(const audioproc::Config& msg) {
AudioProcessing::Config apm_config;
// AEC configs.
// AEC2/AECM configs.
RTC_CHECK(msg.has_aec_enabled());
RTC_CHECK_EQ(AudioProcessing::kNoError,
apm_->echo_cancellation()->Enable(msg.aec_enabled()));
RTC_CHECK(msg.has_aecm_enabled());
apm_config.echo_canceller.enabled = msg.aec_enabled() || msg.aecm_enabled();
apm_config.echo_canceller.mobile_mode = msg.aecm_enabled();
RTC_CHECK(msg.has_aec_drift_compensation_enabled());
RTC_CHECK_EQ(AudioProcessing::kNoError,
@ -216,11 +217,6 @@ void DebugDumpReplayer::ConfigureApm(const audioproc::Config& msg) {
static_cast<EchoCancellation::SuppressionLevel>(
msg.aec_suppression_level())));
// AECM configs.
RTC_CHECK(msg.has_aecm_enabled());
RTC_CHECK_EQ(AudioProcessing::kNoError,
apm_->echo_control_mobile()->Enable(msg.aecm_enabled()));
RTC_CHECK(msg.has_aecm_comfort_noise_enabled());
RTC_CHECK_EQ(AudioProcessing::kNoError,
apm_->echo_control_mobile()->enable_comfort_noise(

View File

@ -403,6 +403,7 @@ TEST_F(DebugDumpTest, VerifyRefinedAdaptiveFilterExperimentalString) {
TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringInclusive) {
Config config;
AudioProcessing::Config apm_config;
apm_config.echo_canceller.enabled = true;
config.Set<RefinedAdaptiveFilter>(new RefinedAdaptiveFilter(true));
// Arbitrarily set clipping gain to 17, which will never be the default.
config.Set<ExperimentalAgc>(new ExperimentalAgc(true, 0, 17));
@ -463,6 +464,7 @@ TEST_F(DebugDumpTest, VerifyCombinedExperimentalStringExclusive) {
TEST_F(DebugDumpTest, VerifyAec3ExperimentalString) {
Config config;
AudioProcessing::Config apm_config;
apm_config.echo_canceller.enabled = true;
DebugDumpGenerator generator(config, apm_config, true);
generator.StartRecording();
generator.Process(100);
@ -533,9 +535,11 @@ TEST_F(DebugDumpTest, VerifyEmptyExperimentalString) {
TEST_F(DebugDumpTest, ToggleAecLevel) {
Config config;
DebugDumpGenerator generator(config, AudioProcessing::Config());
AudioProcessing::Config apm_config;
apm_config.echo_canceller.enabled = true;
apm_config.echo_canceller.mobile_mode = false;
DebugDumpGenerator generator(config, apm_config);
EchoCancellation* aec = generator.apm()->echo_cancellation();
EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(true));
EXPECT_EQ(AudioProcessing::kNoError,
aec->set_suppression_level(EchoCancellation::kLowSuppression));
generator.StartRecording();