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,
17 EchoControlMobile* echo_control_mobile)
18 : audio_processing_(audio_processing),
19 echo_control_mobile_(echo_control_mobile) {}
20
21EchoControlMobileProxy::~EchoControlMobileProxy() = default;
22
23int EchoControlMobileProxy::Enable(bool enable) {
24 // 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.
27 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 }
35 echo_control_mobile_->Enable(enable);
36 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) {
44 return echo_control_mobile_->set_routing_mode(mode);
45}
46
47EchoControlMobile::RoutingMode EchoControlMobileProxy::routing_mode() const {
48 return echo_control_mobile_->routing_mode();
49}
50
51int EchoControlMobileProxy::enable_comfort_noise(bool enable) {
52 return echo_control_mobile_->enable_comfort_noise(enable);
53}
54
55bool EchoControlMobileProxy::is_comfort_noise_enabled() const {
56 return echo_control_mobile_->is_comfort_noise_enabled();
57}
58
59int EchoControlMobileProxy::SetEchoPath(const void* echo_path,
60 size_t size_bytes) {
61 return echo_control_mobile_->SetEchoPath(echo_path, size_bytes);
62}
63
64int EchoControlMobileProxy::GetEchoPath(void* echo_path,
65 size_t size_bytes) const {
66 return echo_control_mobile_->GetEchoPath(echo_path, size_bytes);
67}
68
69} // namespace webrtc