blob: e8b1fbdd235cc852e92d02d7fd04244ad03b385b [file] [log] [blame]
Sam Zackrisson74ed7342018-08-16 10:54:07 +02001/*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "modules/audio_processing/echo_cancellation_proxy.h"
12
13namespace webrtc {
14
15EchoCancellationProxy::EchoCancellationProxy(
16 AudioProcessing* audio_processing,
17 EchoCancellation* echo_cancellation)
18 : audio_processing_(audio_processing),
19 echo_cancellation_(echo_cancellation) {}
20
21EchoCancellationProxy::~EchoCancellationProxy() = default;
22
23int EchoCancellationProxy::Enable(bool enable) {
24 // Change the config in APM to mirror the applied settings.
25 // TODO(bugs.webrtc.org/9535): Remove the call to EchoCancellation::Enable
26 // when APM starts taking the config into account.
27 AudioProcessing::Config apm_config = audio_processing_->GetConfig();
28 bool aec2_enabled = apm_config.echo_canceller.enabled &&
29 !apm_config.echo_canceller.mobile_mode;
30 if ((aec2_enabled && !enable) || (!aec2_enabled && enable)) {
31 apm_config.echo_canceller.enabled = enable;
32 apm_config.echo_canceller.mobile_mode = false;
33 audio_processing_->ApplyConfig(apm_config);
34 }
35 echo_cancellation_->Enable(enable);
36 return AudioProcessing::kNoError;
37}
38
39bool EchoCancellationProxy::is_enabled() const {
40 return echo_cancellation_->is_enabled();
41}
42
43int EchoCancellationProxy::enable_drift_compensation(bool enable) {
44 return echo_cancellation_->enable_drift_compensation(enable);
45}
46
47bool EchoCancellationProxy::is_drift_compensation_enabled() const {
48 return echo_cancellation_->is_drift_compensation_enabled();
49}
50
51void EchoCancellationProxy::set_stream_drift_samples(int drift) {
52 echo_cancellation_->set_stream_drift_samples(drift);
53}
54
55int EchoCancellationProxy::stream_drift_samples() const {
56 return echo_cancellation_->stream_drift_samples();
57}
58
59int EchoCancellationProxy::set_suppression_level(
60 EchoCancellation::SuppressionLevel level) {
61 return echo_cancellation_->set_suppression_level(level);
62}
63
64EchoCancellation::SuppressionLevel EchoCancellationProxy::suppression_level()
65 const {
66 return echo_cancellation_->suppression_level();
67}
68
69bool EchoCancellationProxy::stream_has_echo() const {
70 return echo_cancellation_->stream_has_echo();
71}
72int EchoCancellationProxy::enable_metrics(bool enable) {
73 return echo_cancellation_->enable_metrics(enable);
74}
75bool EchoCancellationProxy::are_metrics_enabled() const {
76 return echo_cancellation_->are_metrics_enabled();
77}
78int EchoCancellationProxy::GetMetrics(Metrics* metrics) {
79 return echo_cancellation_->GetMetrics(metrics);
80}
81int EchoCancellationProxy::enable_delay_logging(bool enable) {
82 return echo_cancellation_->enable_delay_logging(enable);
83}
84bool EchoCancellationProxy::is_delay_logging_enabled() const {
85 return echo_cancellation_->is_delay_logging_enabled();
86}
87int EchoCancellationProxy::GetDelayMetrics(int* median, int* std) {
88 return echo_cancellation_->GetDelayMetrics(median, std);
89}
90int EchoCancellationProxy::GetDelayMetrics(int* median,
91 int* std,
92 float* fraction_poor_delays) {
93 return echo_cancellation_->GetDelayMetrics(median, std, fraction_poor_delays);
94}
95
96struct AecCore* EchoCancellationProxy::aec_core() const {
97 return echo_cancellation_->aec_core();
98}
99
100} // namespace webrtc