Add PostProcessing interface to audio processing module.
This CL adds an interface for a generic PostProcessing module that
is optionally added to the APM at construction time.
(Parenthetically this CL also adds a missing lock check to
InitializeGainController2.)
Bug: webrtc:8201
Change-Id: I7de64cf8d5335ecec450da8a961660906141d42a
Reviewed-on: https://webrtc-review.googlesource.com/1570
Commit-Queue: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Per Ã…hgren <peah@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#19973}
diff --git a/modules/audio_processing/include/audio_processing.h b/modules/audio_processing/include/audio_processing.h
index f8df3e9..6baa691 100644
--- a/modules/audio_processing/include/audio_processing.h
+++ b/modules/audio_processing/include/audio_processing.h
@@ -23,6 +23,7 @@
#include "modules/audio_processing/beamformer/array_util.h"
#include "modules/audio_processing/include/config.h"
#include "rtc_base/arraysize.h"
+#include "rtc_base/deprecation.h"
#include "rtc_base/platform_file.h"
#include "rtc_base/refcount.h"
#include "typedefs.h" // NOLINT(build/include)
@@ -32,6 +33,7 @@
struct AecCore;
class AecDump;
+class AudioBuffer;
class AudioFrame;
class NonlinearBeamformer;
@@ -45,6 +47,7 @@
class HighPassFilter;
class LevelEstimator;
class NoiseSuppression;
+class PostProcessing;
class VoiceDetection;
// Use to enable the extended filter mode in the AEC, along with robustness
@@ -359,9 +362,15 @@
static AudioProcessing* Create();
// Allows passing in an optional configuration at create-time.
static AudioProcessing* Create(const webrtc::Config& config);
- // Only for testing.
+ // Deprecated. Use the Create below, with nullptr PostProcessing.
+ RTC_DEPRECATED
static AudioProcessing* Create(const webrtc::Config& config,
NonlinearBeamformer* beamformer);
+ // Allows passing in optional user-defined processing modules.
+ static AudioProcessing* Create(
+ const webrtc::Config& config,
+ std::unique_ptr<PostProcessing> capture_post_processor,
+ NonlinearBeamformer* beamformer);
~AudioProcessing() override {}
// Initializes internal states, while retaining all user settings. This
@@ -1087,6 +1096,19 @@
virtual ~NoiseSuppression() {}
};
+// Interface for a post processing submodule.
+class PostProcessing {
+ public:
+ // (Re-)Initializes the submodule.
+ virtual void Initialize(int sample_rate_hz, int num_channels) = 0;
+ // Processes the given capture or render signal.
+ virtual void Process(AudioBuffer* audio) = 0;
+ // Returns a string representation of the module state.
+ virtual std::string ToString() const = 0;
+
+ virtual ~PostProcessing() {}
+};
+
// The voice activity detection (VAD) component analyzes the stream to
// determine if voice is present. A facility is also provided to pass in an
// external VAD decision.