Added EchoCanceller3Factory.
Added EchoCanceller3Factory that implements EchoControlFactory and can be used for injecting EchoCanceller3 into Audio Processing Module. Renamed InitializeEchoCanceller3 to InitializeEchoController. Bug: webrtc:8346 Change-Id: I47078da6a49aca1ee41f6a9d5b7b8e91bb5c11a3 Reviewed-on: https://webrtc-review.googlesource.com/9220 Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20299}
This commit is contained in:
parent
a8264dbdd9
commit
8eb9c7d838
@ -359,4 +359,18 @@ void EchoCanceller3::EmptyRenderQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
EchoCanceller3Factory::EchoCanceller3Factory(
|
||||
const AudioProcessing::Config::EchoCanceller3& config)
|
||||
: config_(config) {
|
||||
// Revert to default configuration if needed.
|
||||
if (!EchoCanceller3::Validate(config_)) {
|
||||
config_ = AudioProcessing::Config::EchoCanceller3();
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<EchoControl> EchoCanceller3Factory::Create(int sample_rate_hz) {
|
||||
return std::unique_ptr<EchoControl>(
|
||||
new EchoCanceller3(config_, sample_rate_hz, true));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -133,6 +133,16 @@ class EchoCanceller3 : public EchoControl {
|
||||
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(EchoCanceller3);
|
||||
};
|
||||
|
||||
class EchoCanceller3Factory : public EchoControlFactory {
|
||||
public:
|
||||
EchoCanceller3Factory();
|
||||
EchoCanceller3Factory(const AudioProcessing::Config::EchoCanceller3& config);
|
||||
std::unique_ptr<EchoControl> Create(int sample_rate_hz) override;
|
||||
|
||||
private:
|
||||
AudioProcessing::Config::EchoCanceller3 config_;
|
||||
};
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_AUDIO_PROCESSING_AEC3_ECHO_CANCELLER3_H_
|
||||
|
||||
@ -553,7 +553,7 @@ int AudioProcessingImpl::InitializeLocked() {
|
||||
public_submodules_->level_estimator->Initialize();
|
||||
InitializeLevelController();
|
||||
InitializeResidualEchoDetector();
|
||||
InitializeEchoCanceller3();
|
||||
InitializeEchoController();
|
||||
InitializeGainController2();
|
||||
InitializePostProcessor();
|
||||
|
||||
@ -688,23 +688,13 @@ void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) {
|
||||
LOG(LS_INFO) << "Highpass filter activated: "
|
||||
<< config_.high_pass_filter.enabled;
|
||||
|
||||
// TODO(gustaf): Do this outside of APM.
|
||||
config_ok = EchoCanceller3::Validate(config_.echo_canceller3);
|
||||
if (!config_ok) {
|
||||
LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl
|
||||
<< "echo canceller 3: "
|
||||
<< EchoCanceller3::ToString(config_.echo_canceller3)
|
||||
<< std::endl
|
||||
<< "Reverting to default parameter set";
|
||||
config_.echo_canceller3 = AudioProcessing::Config::EchoCanceller3();
|
||||
}
|
||||
|
||||
// TODO(gustaf): Enable EchoCanceller3 by injection, not configuration.
|
||||
if (config.echo_canceller3.enabled !=
|
||||
capture_nonlocked_.echo_canceller3_enabled) {
|
||||
// Inject EchoCanceller3 if requested.
|
||||
if (config.echo_canceller3.enabled && !echo_control_factory_) {
|
||||
capture_nonlocked_.echo_canceller3_enabled =
|
||||
config_.echo_canceller3.enabled;
|
||||
InitializeEchoCanceller3();
|
||||
echo_control_factory_ = std::unique_ptr<EchoControlFactory>(
|
||||
new EchoCanceller3Factory(config.echo_canceller3));
|
||||
InitializeEchoController();
|
||||
LOG(LS_INFO) << "Echo canceller 3 activated: "
|
||||
<< capture_nonlocked_.echo_canceller3_enabled;
|
||||
}
|
||||
@ -1702,14 +1692,10 @@ void AudioProcessingImpl::InitializeLowCutFilter() {
|
||||
}
|
||||
}
|
||||
|
||||
void AudioProcessingImpl::InitializeEchoCanceller3() {
|
||||
void AudioProcessingImpl::InitializeEchoController() {
|
||||
if (echo_control_factory_) {
|
||||
private_submodules_->echo_controller =
|
||||
echo_control_factory_->Create(proc_sample_rate_hz());
|
||||
} else if (capture_nonlocked_.echo_canceller3_enabled) {
|
||||
// TODO(gustaf): Remove once injection is used.
|
||||
private_submodules_->echo_controller.reset(new EchoCanceller3(
|
||||
config_.echo_canceller3, proc_sample_rate_hz(), true));
|
||||
} else {
|
||||
private_submodules_->echo_controller.reset();
|
||||
}
|
||||
|
||||
@ -224,7 +224,7 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||
void InitializeResidualEchoDetector()
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_);
|
||||
void InitializeLowCutFilter() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
||||
void InitializeEchoCanceller3() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
||||
void InitializeEchoController() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
||||
void InitializeGainController2() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
||||
void InitializePostProcessor() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_capture_);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user