From 3f83072c26969a667f7d1d07603559c0ed0f3ece Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Wed, 11 Jun 2014 04:48:11 +0000 Subject: [PATCH] modules/audio_processing: Adds a config for reported delays There are platforms and devices where the reported delays are untrusted and we currently solve that with an extended filter length and a slightly more conservative delay handling. With this change we give the user the possibility to turn off reported system delay values completely. - Includes new unit tests. TESTED=trybots and manual testing R=aluebs@webrtc.org, kwiberg@webrtc.org Review URL: https://webrtc-codereview.appspot.com/13629004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6391 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../echo_cancellation_impl.cc | 1 + .../echo_cancellation_impl_unittest.cc | 30 +++++++++++++++++++ .../include/audio_processing.h | 12 ++++++++ 3 files changed, 43 insertions(+) diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index 8cf3410b3..e770f9fe3 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -323,6 +323,7 @@ int EchoCancellationImpl::Initialize() { void EchoCancellationImpl::SetExtraOptions(const Config& config) { delay_correction_enabled_ = config.Get().enabled; + reported_delay_enabled_ = config.Get().enabled; Configure(); } diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl_unittest.cc b/webrtc/modules/audio_processing/echo_cancellation_impl_unittest.cc index eeea2587e..49bcf9459 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl_unittest.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl_unittest.cc @@ -48,4 +48,34 @@ TEST(EchoCancellationInternalTest, DelayCorrection) { EXPECT_EQ(0, WebRtcAec_delay_correction_enabled(aec_core)); } +TEST(EchoCancellationInternalTest, ReportedDelay) { + scoped_ptr ap(AudioProcessing::Create(0)); + EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL); + + EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true)); + EXPECT_TRUE(ap->echo_cancellation()->is_enabled()); + + AecCore* aec_core = ap->echo_cancellation()->aec_core(); + ASSERT_TRUE(aec_core != NULL); + // Enabled by default. + EXPECT_EQ(1, WebRtcAec_reported_delay_enabled(aec_core)); + + Config config; + config.Set(new ReportedDelay(false)); + ap->SetExtraOptions(config); + EXPECT_EQ(0, WebRtcAec_reported_delay_enabled(aec_core)); + + // Retains setting after initialization. + EXPECT_EQ(ap->kNoError, ap->Initialize()); + EXPECT_EQ(0, WebRtcAec_reported_delay_enabled(aec_core)); + + config.Set(new ReportedDelay(true)); + ap->SetExtraOptions(config); + EXPECT_EQ(1, WebRtcAec_reported_delay_enabled(aec_core)); + + // Retains setting after initialization. + EXPECT_EQ(ap->kNoError, ap->Initialize()); + EXPECT_EQ(1, WebRtcAec_reported_delay_enabled(aec_core)); +} + } // namespace webrtc diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h index 15e01b95f..77c3f3add 100644 --- a/webrtc/modules/audio_processing/include/audio_processing.h +++ b/webrtc/modules/audio_processing/include/audio_processing.h @@ -53,6 +53,18 @@ struct DelayCorrection { bool enabled; }; +// Use to disable the reported system delays. By disabling the reported system +// delays the echo cancellation algorithm assumes the process and reverse +// streams to be aligned. This configuration only applies to EchoCancellation +// and not EchoControlMobile and is set with AudioProcessing::SetExtraOptions(). +// Note that by disabling reported system delays the EchoCancellation may +// regress in performance. +struct ReportedDelay { + ReportedDelay() : enabled(true) {} + explicit ReportedDelay(bool enabled) : enabled(enabled) {} + bool enabled; +}; + // Must be provided through AudioProcessing::Create(Confg&). It will have no // impact if used with AudioProcessing::SetExtraOptions(). struct ExperimentalAgc {