blob: fd298348f4778e90e1af1266a694dcec1149a874 [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_control_mobile_proxy.h"
12
13namespace webrtc {
14
15EchoControlMobileProxy::EchoControlMobileProxy(
16 AudioProcessing* audio_processing,
Sam Zackrisson05a70042018-09-28 13:39:13 +000017 EchoControlMobile* echo_control_mobile)
Sam Zackrisson74ed7342018-08-16 10:54:07 +020018 : audio_processing_(audio_processing),
19 echo_control_mobile_(echo_control_mobile) {}
20
21EchoControlMobileProxy::~EchoControlMobileProxy() = default;
22
23int EchoControlMobileProxy::Enable(bool enable) {
Sam Zackrisson05a70042018-09-28 13:39:13 +000024 // Change the config in APM to mirror the applied settings.
25 // TODO(bugs.webrtc.org/9535): Remove the call to EchoControlMobile::Enable
26 // when APM starts taking the config into account.
Sam Zackrisson74ed7342018-08-16 10:54:07 +020027 AudioProcessing::Config apm_config = audio_processing_->GetConfig();
28 bool aecm_enabled = apm_config.echo_canceller.enabled &&
29 apm_config.echo_canceller.mobile_mode;
30 if ((aecm_enabled && !enable) || (!aecm_enabled && enable)) {
31 apm_config.echo_canceller.enabled = enable;
32 apm_config.echo_canceller.mobile_mode = true;
33 audio_processing_->ApplyConfig(apm_config);
34 }
Sam Zackrisson05a70042018-09-28 13:39:13 +000035 echo_control_mobile_->Enable(enable);
Sam Zackrisson74ed7342018-08-16 10:54:07 +020036 return AudioProcessing::kNoError;
37}
38
39bool EchoControlMobileProxy::is_enabled() const {
40 return echo_control_mobile_->is_enabled();
41}
42
43int EchoControlMobileProxy::set_routing_mode(RoutingMode mode) {
Sam Zackrisson05a70042018-09-28 13:39:13 +000044 return echo_control_mobile_->set_routing_mode(mode);
Sam Zackrisson74ed7342018-08-16 10:54:07 +020045}
46
47EchoControlMobile::RoutingMode EchoControlMobileProxy::routing_mode() const {
Sam Zackrisson05a70042018-09-28 13:39:13 +000048 return echo_control_mobile_->routing_mode();
Sam Zackrisson74ed7342018-08-16 10:54:07 +020049}
50
51int EchoControlMobileProxy::enable_comfort_noise(bool enable) {
Sam Zackrisson05a70042018-09-28 13:39:13 +000052 return echo_control_mobile_->enable_comfort_noise(enable);
Sam Zackrisson74ed7342018-08-16 10:54:07 +020053}
54
55bool EchoControlMobileProxy::is_comfort_noise_enabled() const {
Sam Zackrisson05a70042018-09-28 13:39:13 +000056 return echo_control_mobile_->is_comfort_noise_enabled();
Sam Zackrisson74ed7342018-08-16 10:54:07 +020057}
58
59int EchoControlMobileProxy::SetEchoPath(const void* echo_path,
60 size_t size_bytes) {
Sam Zackrisson05a70042018-09-28 13:39:13 +000061 return echo_control_mobile_->SetEchoPath(echo_path, size_bytes);
Sam Zackrisson74ed7342018-08-16 10:54:07 +020062}
63
64int EchoControlMobileProxy::GetEchoPath(void* echo_path,
65 size_t size_bytes) const {
Sam Zackrisson05a70042018-09-28 13:39:13 +000066 return echo_control_mobile_->GetEchoPath(echo_path, size_bytes);
Sam Zackrisson74ed7342018-08-16 10:54:07 +020067}
68
69} // namespace webrtc