From 91d11b3cdd3ab20600aadb92929e4d48ff4f7422 Mon Sep 17 00:00:00 2001 From: "bjornv@webrtc.org" Date: Tue, 5 Mar 2013 16:53:09 +0000 Subject: [PATCH] Adds new AEC API to audio_processing. One unit test added. Tested with audioproc_unittest and trybots TEST=none BUG=none Review URL: https://webrtc-codereview.appspot.com/1154004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3613 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_processing/echo_cancellation_impl.cc | 9 +++++++++ webrtc/modules/audio_processing/echo_cancellation_impl.h | 5 +++-- .../modules/audio_processing/include/audio_processing.h | 8 ++++++++ webrtc/modules/audio_processing/test/unit_test.cc | 7 +++++++ 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index 72a70b9cfc..09d210c9c1 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -313,6 +313,15 @@ int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { return apm_->kNoError; } +struct AecCore* EchoCancellationImpl::aec_core() const { + CriticalSectionScoped crit_scoped(apm_->crit()); + if (!is_component_enabled()) { + return NULL; + } + Handle* my_handle = static_cast(handle(0)); + return WebRtcAec_aec_core(my_handle); +} + int EchoCancellationImpl::Initialize() { int err = ProcessingComponent::Initialize(); if (err != apm_->kNoError || !is_component_enabled()) { diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.h b/webrtc/modules/audio_processing/echo_cancellation_impl.h index 0f3f2bae01..fa5ba85689 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.h +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.h @@ -11,8 +11,8 @@ #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ -#include "audio_processing.h" -#include "processing_component.h" +#include "webrtc/modules/audio_processing/include/audio_processing.h" +#include "webrtc/modules/audio_processing/processing_component.h" namespace webrtc { class AudioProcessingImpl; @@ -51,6 +51,7 @@ class EchoCancellationImpl : public EchoCancellation, virtual int enable_delay_logging(bool enable); virtual bool is_delay_logging_enabled() const; virtual int GetDelayMetrics(int* median, int* std); + virtual struct AecCore* aec_core() const; // ProcessingComponent implementation. virtual void* CreateHandle() const; diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h index 6f0966754c..5e0c02c1ad 100644 --- a/webrtc/modules/audio_processing/include/audio_processing.h +++ b/webrtc/modules/audio_processing/include/audio_processing.h @@ -16,6 +16,8 @@ #include "webrtc/modules/interface/module.h" #include "webrtc/typedefs.h" +struct AecCore; + namespace webrtc { class AudioFrame; @@ -342,6 +344,12 @@ class EchoCancellation { // last call to |GetDelayMetrics()|. virtual int GetDelayMetrics(int* median, int* std) = 0; + // Returns a pointer to the low level AEC component. In case of multiple + // channels, the pointer to the first one is returned. A NULL pointer is + // returned when the AEC component is disabled or has not been initialized + // successfully. + virtual struct AecCore* aec_core() const = 0; + protected: virtual ~EchoCancellation() {} }; diff --git a/webrtc/modules/audio_processing/test/unit_test.cc b/webrtc/modules/audio_processing/test/unit_test.cc index 5866a5fd02..bc7c1442e7 100644 --- a/webrtc/modules/audio_processing/test/unit_test.cc +++ b/webrtc/modules/audio_processing/test/unit_test.cc @@ -805,6 +805,13 @@ TEST_F(ApmTest, EchoCancellation) { EXPECT_TRUE(apm_->echo_cancellation()->is_enabled()); EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(false)); EXPECT_FALSE(apm_->echo_cancellation()->is_enabled()); + + EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(true)); + EXPECT_TRUE(apm_->echo_cancellation()->is_enabled()); + EXPECT_TRUE(apm_->echo_cancellation()->aec_core() != NULL); + EXPECT_EQ(apm_->kNoError, apm_->echo_cancellation()->Enable(false)); + EXPECT_FALSE(apm_->echo_cancellation()->is_enabled()); + EXPECT_FALSE(apm_->echo_cancellation()->aec_core() != NULL); } TEST_F(ApmTest, EchoCancellationReportsCorrectDelays) {