diff options
author | andrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-07-25 18:28:29 +0000 |
---|---|---|
committer | andrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d> | 2013-07-25 18:28:29 +0000 |
commit | 61e596fc49443971219aa3989b200407d919f6c5 (patch) | |
tree | ea446c6e6bce0e4ea76c1c76c2b34f082583f2a6 /webrtc | |
parent | c46967dc53a5f54e0126ba0fe5fdeafd9b584a38 (diff) | |
download | webrtc-61e596fc49443971219aa3989b200407d919f6c5.tar.gz |
Add a Config class interface to AudioProcessing for passing options.
Pass the Config down to all AudioProcessing components.
Also add an EchoCancellationImplWrapper to optionally create different
EchoCancellationImpls.
BUG=2117
TBR=turaj@webrtc.org
TESTED=git try
Review URL: https://webrtc-codereview.appspot.com/1843004
git-svn-id: http://webrtc.googlecode.com/svn/trunk@4400 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'webrtc')
10 files changed, 77 insertions, 15 deletions
diff --git a/webrtc/common.h b/webrtc/common.h index 766f5b55b9..6ead4098d3 100644 --- a/webrtc/common.h +++ b/webrtc/common.h @@ -8,8 +8,8 @@ * be found in the AUTHORS file in the root of the source tree. */ -#ifndef WEBRTC_COMMON_H -#define WEBRTC_COMMON_H +#ifndef WEBRTC_COMMON_H_ +#define WEBRTC_COMMON_H_ #include <map> @@ -38,14 +38,14 @@ namespace webrtc { class Config { public: // Returns the option if set or a default constructed one. - // Callers that access options to often are encouraged to cache the result. + // Callers that access options too often are encouraged to cache the result. // Returned references are owned by this. // // Requires std::is_default_constructible<T> template<typename T> const T& Get() const; // Set the option, deleting any previous instance of the same. - // This instance gets ownership of the newly setted value. + // This instance gets ownership of the newly set value. template<typename T> void Set(T* value); Config() {} @@ -116,5 +116,7 @@ void Config::Set(T* value) { delete it; it = new Option<T>(value); } + } // namespace webrtc -#endif // WEBRTC_COMMON_H + +#endif // WEBRTC_COMMON_H_ diff --git a/webrtc/modules/audio_processing/audio_processing.gypi b/webrtc/modules/audio_processing/audio_processing.gypi index 680ad282e3..88941ea7d3 100644 --- a/webrtc/modules/audio_processing/audio_processing.gypi +++ b/webrtc/modules/audio_processing/audio_processing.gypi @@ -60,6 +60,7 @@ 'audio_processing_impl.h', 'echo_cancellation_impl.cc', 'echo_cancellation_impl.h', + 'echo_cancellation_impl_wrapper.h', 'echo_control_mobile_impl.cc', 'echo_control_mobile_impl.h', 'gain_control_impl.cc', diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc index 922490b7c7..ac5fa9bb72 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.cc +++ b/webrtc/modules/audio_processing/audio_processing_impl.cc @@ -13,7 +13,7 @@ #include <assert.h> #include "webrtc/modules/audio_processing/audio_buffer.h" -#include "webrtc/modules/audio_processing/echo_cancellation_impl.h" +#include "webrtc/modules/audio_processing/echo_cancellation_impl_wrapper.h" #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" #include "webrtc/modules/audio_processing/gain_control_impl.h" #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" @@ -76,7 +76,7 @@ AudioProcessingImpl::AudioProcessingImpl(int id) num_reverse_channels_(1), num_input_channels_(1), num_output_channels_(1) { - echo_cancellation_ = new EchoCancellationImpl(this); + echo_cancellation_ = EchoCancellationImplWrapper::Create(this); component_list_.push_back(echo_cancellation_); echo_control_mobile_ = new EchoControlMobileImpl(this); @@ -181,6 +181,12 @@ int AudioProcessingImpl::InitializeLocked() { return kNoError; } +void AudioProcessingImpl::SetExtraOptions(const Config& config) { + std::list<ProcessingComponent*>::iterator it; + for (it = component_list_.begin(); it != component_list_.end(); ++it) + (*it)->SetExtraOptions(config); +} + int AudioProcessingImpl::set_sample_rate_hz(int rate) { CriticalSectionScoped crit_scoped(crit_); if (rate == sample_rate_hz_) { diff --git a/webrtc/modules/audio_processing/audio_processing_impl.h b/webrtc/modules/audio_processing/audio_processing_impl.h index 4be5f0f025..831eabb8c6 100644 --- a/webrtc/modules/audio_processing/audio_processing_impl.h +++ b/webrtc/modules/audio_processing/audio_processing_impl.h @@ -21,7 +21,7 @@ namespace webrtc { class AudioBuffer; class CriticalSectionWrapper; -class EchoCancellationImpl; +class EchoCancellationImplWrapper; class EchoControlMobileImpl; class FileWrapper; class GainControlImpl; @@ -58,6 +58,7 @@ class AudioProcessingImpl : public AudioProcessing { // AudioProcessing methods. virtual int Initialize(); virtual int InitializeLocked(); + virtual void SetExtraOptions(const Config& config); virtual int set_sample_rate_hz(int rate); virtual int sample_rate_hz() const; virtual int set_num_channels(int input_channels, int output_channels); @@ -92,7 +93,7 @@ class AudioProcessingImpl : public AudioProcessing { int id_; - EchoCancellationImpl* echo_cancellation_; + EchoCancellationImplWrapper* echo_cancellation_; EchoControlMobileImpl* echo_control_mobile_; GainControlImpl* gain_control_; HighPassFilterImpl* high_pass_filter_; diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc index a32fb3364f..47ee802483 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc @@ -54,6 +54,11 @@ AudioProcessing::Error MapError(int err) { } } // namespace +EchoCancellationImplWrapper* EchoCancellationImplWrapper::Create( + const AudioProcessingImpl* audioproc) { + return new EchoCancellationImpl(audioproc); +} + EchoCancellationImpl::EchoCancellationImpl(const AudioProcessingImpl* apm) : ProcessingComponent(apm), apm_(apm), diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.h b/webrtc/modules/audio_processing/echo_cancellation_impl.h index fa5ba85689..74d9ecf1e5 100644 --- a/webrtc/modules/audio_processing/echo_cancellation_impl.h +++ b/webrtc/modules/audio_processing/echo_cancellation_impl.h @@ -11,21 +11,21 @@ #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ #define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ -#include "webrtc/modules/audio_processing/include/audio_processing.h" -#include "webrtc/modules/audio_processing/processing_component.h" +#include "webrtc/modules/audio_processing/echo_cancellation_impl_wrapper.h" namespace webrtc { + class AudioProcessingImpl; class AudioBuffer; -class EchoCancellationImpl : public EchoCancellation, - public ProcessingComponent { +class EchoCancellationImpl : public EchoCancellationImplWrapper { public: explicit EchoCancellationImpl(const AudioProcessingImpl* apm); virtual ~EchoCancellationImpl(); - int ProcessRenderAudio(const AudioBuffer* audio); - int ProcessCaptureAudio(AudioBuffer* audio); + // EchoCancellationImplWrapper implementation. + virtual int ProcessRenderAudio(const AudioBuffer* audio); + virtual int ProcessCaptureAudio(AudioBuffer* audio); // EchoCancellation implementation. virtual bool is_enabled() const; @@ -71,6 +71,7 @@ class EchoCancellationImpl : public EchoCancellation, bool stream_has_echo_; bool delay_logging_enabled_; }; + } // namespace webrtc #endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_H_ diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl_wrapper.h b/webrtc/modules/audio_processing/echo_cancellation_impl_wrapper.h new file mode 100644 index 0000000000..f1c03f32d6 --- /dev/null +++ b/webrtc/modules/audio_processing/echo_cancellation_impl_wrapper.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2013 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_ECHO_CANCELLATION_IMPL_WRAPPER_H_ +#define WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_WRAPPER_H_ + +#include "webrtc/modules/audio_processing/include/audio_processing.h" +#include "webrtc/modules/audio_processing/processing_component.h" + +namespace webrtc { + +class AudioProcessingImpl; +class AudioBuffer; + +class EchoCancellationImplWrapper : public virtual EchoCancellation, + public virtual ProcessingComponent { + public: + static EchoCancellationImplWrapper* Create( + const AudioProcessingImpl* audioproc); + virtual ~EchoCancellationImplWrapper() {} + + virtual int ProcessRenderAudio(const AudioBuffer* audio) = 0; + virtual int ProcessCaptureAudio(AudioBuffer* audio) = 0; +}; + +} // namespace webrtc + +#endif // WEBRTC_MODULES_AUDIO_PROCESSING_ECHO_CANCELLATION_IMPL_WRAPPER_H_ diff --git a/webrtc/modules/audio_processing/include/audio_processing.h b/webrtc/modules/audio_processing/include/audio_processing.h index 510b1a079e..3fb80b08ca 100644 --- a/webrtc/modules/audio_processing/include/audio_processing.h +++ b/webrtc/modules/audio_processing/include/audio_processing.h @@ -13,6 +13,7 @@ #include <stddef.h> // size_t +#include "webrtc/common.h" #include "webrtc/modules/interface/module.h" #include "webrtc/typedefs.h" @@ -132,6 +133,10 @@ class AudioProcessing : public Module { // existing values. Otherwise they are no-ops. virtual int Initialize() = 0; + // Pass down additional options which don't have explicit setters. This + // ensures the options are applied immediately. + virtual void SetExtraOptions(const Config& config) = 0; + // Sets the sample |rate| in Hz for both the primary and reverse audio // streams. 8000, 16000 or 32000 Hz are permitted. virtual int set_sample_rate_hz(int rate) = 0; diff --git a/webrtc/modules/audio_processing/include/mock_audio_processing.h b/webrtc/modules/audio_processing/include/mock_audio_processing.h index c2ab7349d3..9a36fe84e8 100644 --- a/webrtc/modules/audio_processing/include/mock_audio_processing.h +++ b/webrtc/modules/audio_processing/include/mock_audio_processing.h @@ -181,6 +181,8 @@ class MockAudioProcessing : public AudioProcessing { MOCK_METHOD0(Initialize, int()); + MOCK_METHOD1(SetExtraOptions, + void(const Config& config)); MOCK_METHOD1(set_sample_rate_hz, int(int rate)); MOCK_CONST_METHOD0(sample_rate_hz, diff --git a/webrtc/modules/audio_processing/processing_component.h b/webrtc/modules/audio_processing/processing_component.h index f1f367e23d..a5ee1859ee 100644 --- a/webrtc/modules/audio_processing/processing_component.h +++ b/webrtc/modules/audio_processing/processing_component.h @@ -16,14 +16,17 @@ #include "webrtc/modules/audio_processing/include/audio_processing.h" namespace webrtc { + class AudioProcessingImpl; class ProcessingComponent { public: + ProcessingComponent() {} explicit ProcessingComponent(const AudioProcessingImpl* apm); virtual ~ProcessingComponent(); virtual int Initialize(); + virtual void SetExtraOptions(const Config& config) {} virtual int Destroy(); bool is_component_enabled() const; @@ -48,6 +51,7 @@ class ProcessingComponent { bool enabled_; int num_handles_; }; + } // namespace webrtc #endif // WEBRTC_MODULES_AUDIO_PROCESSING_PROCESSING_COMPONENT_H__ |