Added a builder class for the AudioProcessingModule.

As the number of injectable components of the APM increases, it is become increasingly unwieldy to keep expanding the Create function with more parameters. This builder class should make it easier to inject more components in the future.

Bug: webrtc:8668
Change-Id: If91547527760486c2a4daa9696bee22ec1d7675e
Reviewed-on: https://webrtc-review.googlesource.com/34651
Commit-Queue: Ivo Creusen <ivoc@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Sam Zackrisson <saza@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21425}
This commit is contained in:
Ivo Creusen
2017-12-22 11:35:59 +01:00
committed by Commit Bot
parent b4834b3696
commit 5ec7e12760
3 changed files with 80 additions and 4 deletions

View File

@ -318,6 +318,45 @@ struct AudioProcessingImpl::ApmPrivateSubmodules {
std::unique_ptr<CustomProcessing> render_pre_processor;
};
AudioProcessingBuilder::AudioProcessingBuilder() = default;
AudioProcessingBuilder::~AudioProcessingBuilder() = default;
AudioProcessingBuilder& AudioProcessingBuilder::SetCapturePostProcessing(
std::unique_ptr<CustomProcessing> capture_post_processing) {
capture_post_processing_ = std::move(capture_post_processing);
return *this;
}
AudioProcessingBuilder& AudioProcessingBuilder::SetRenderPreProcessing(
std::unique_ptr<CustomProcessing> render_pre_processing) {
render_pre_processing_ = std::move(render_pre_processing);
return *this;
}
AudioProcessingBuilder& AudioProcessingBuilder::SetEchoControlFactory(
std::unique_ptr<EchoControlFactory> echo_control_factory) {
echo_control_factory_ = std::move(echo_control_factory);
return *this;
}
AudioProcessingBuilder& AudioProcessingBuilder::SetNonlinearBeamformer(
std::unique_ptr<NonlinearBeamformer> nonlinear_beamformer) {
nonlinear_beamformer_ = std::move(nonlinear_beamformer);
return *this;
}
AudioProcessing* AudioProcessingBuilder::Create() {
webrtc::Config config;
return Create(config);
}
AudioProcessing* AudioProcessingBuilder::Create(const webrtc::Config& config) {
return AudioProcessing::Create(config, std::move(capture_post_processing_),
std::move(render_pre_processing_),
std::move(echo_control_factory_),
nonlinear_beamformer_.release());
}
AudioProcessing* AudioProcessing::Create() {
webrtc::Config config;
return Create(config, nullptr, nullptr, nullptr, nullptr);