webrtc_m130/modules/audio_processing/echo_cancellation_proxy.cc
Sergey Silkin 271812a893 Revert "Remove APM internal usage of EchoCancellation"
This reverts commit 1a03960e632a04e2ff866f2048cc36146af83e41.

Reason for revert: breaks downstream projects.

Original change's description:
> Remove APM internal usage of EchoCancellation
> 
> This CL:
>  - Changes EchoCancellationImpl to inherit privately from
>    EchoCancellation.
>  - Removes usage of AudioProcessing::echo_cancellation() inside most of
>    the audio processing module and unit tests.
>  - Default-enables metrics collection in AEC2.
> 
> This CL breaks audioproc_f backwards compatibility: It can no longer
> use all recorded settings (drift compensation, suppression level), but
> prints an error message when such settings are encountered.
> 
> Some code in audio_processing_unittest.cc still uses the old interface.
> I'll handle that in a separate change, as it is not as straightforward
> to preserve coverage.
> 
> Bug: webrtc:9535
> Change-Id: Ia4d4b8d117ccbe516e5345c15d37298418590686
> Reviewed-on: https://webrtc-review.googlesource.com/97603
> Commit-Queue: Sam Zackrisson <saza@webrtc.org>
> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#24724}

TBR=gustaf@webrtc.org,saza@webrtc.org

Change-Id: Ifdc4235f9c5ee8a8a5d32cc8e1dda0853b941693
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9535
Reviewed-on: https://webrtc-review.googlesource.com/100305
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Commit-Queue: Sergey Silkin <ssilkin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24729}
2018-09-13 14:55:30 +00:00

101 lines
3.5 KiB
C++

/*
* Copyright (c) 2018 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.
*/
#include "modules/audio_processing/echo_cancellation_proxy.h"
namespace webrtc {
EchoCancellationProxy::EchoCancellationProxy(
AudioProcessing* audio_processing,
EchoCancellation* echo_cancellation)
: audio_processing_(audio_processing),
echo_cancellation_(echo_cancellation) {}
EchoCancellationProxy::~EchoCancellationProxy() = default;
int EchoCancellationProxy::Enable(bool enable) {
// Change the config in APM to mirror the applied settings.
// TODO(bugs.webrtc.org/9535): Remove the call to EchoCancellation::Enable
// when APM starts taking the config into account.
AudioProcessing::Config apm_config = audio_processing_->GetConfig();
bool aec2_enabled = apm_config.echo_canceller.enabled &&
!apm_config.echo_canceller.mobile_mode;
if ((aec2_enabled && !enable) || (!aec2_enabled && enable)) {
apm_config.echo_canceller.enabled = enable;
apm_config.echo_canceller.mobile_mode = false;
audio_processing_->ApplyConfig(apm_config);
}
echo_cancellation_->Enable(enable);
return AudioProcessing::kNoError;
}
bool EchoCancellationProxy::is_enabled() const {
return echo_cancellation_->is_enabled();
}
int EchoCancellationProxy::enable_drift_compensation(bool enable) {
return echo_cancellation_->enable_drift_compensation(enable);
}
bool EchoCancellationProxy::is_drift_compensation_enabled() const {
return echo_cancellation_->is_drift_compensation_enabled();
}
void EchoCancellationProxy::set_stream_drift_samples(int drift) {
echo_cancellation_->set_stream_drift_samples(drift);
}
int EchoCancellationProxy::stream_drift_samples() const {
return echo_cancellation_->stream_drift_samples();
}
int EchoCancellationProxy::set_suppression_level(
EchoCancellation::SuppressionLevel level) {
return echo_cancellation_->set_suppression_level(level);
}
EchoCancellation::SuppressionLevel EchoCancellationProxy::suppression_level()
const {
return echo_cancellation_->suppression_level();
}
bool EchoCancellationProxy::stream_has_echo() const {
return echo_cancellation_->stream_has_echo();
}
int EchoCancellationProxy::enable_metrics(bool enable) {
return echo_cancellation_->enable_metrics(enable);
}
bool EchoCancellationProxy::are_metrics_enabled() const {
return echo_cancellation_->are_metrics_enabled();
}
int EchoCancellationProxy::GetMetrics(Metrics* metrics) {
return echo_cancellation_->GetMetrics(metrics);
}
int EchoCancellationProxy::enable_delay_logging(bool enable) {
return echo_cancellation_->enable_delay_logging(enable);
}
bool EchoCancellationProxy::is_delay_logging_enabled() const {
return echo_cancellation_->is_delay_logging_enabled();
}
int EchoCancellationProxy::GetDelayMetrics(int* median, int* std) {
return echo_cancellation_->GetDelayMetrics(median, std);
}
int EchoCancellationProxy::GetDelayMetrics(int* median,
int* std,
float* fraction_poor_delays) {
return echo_cancellation_->GetDelayMetrics(median, std, fraction_poor_delays);
}
struct AecCore* EchoCancellationProxy::aec_core() const {
return echo_cancellation_->aec_core();
}
} // namespace webrtc