Sam Zackrisson | 74ed734 | 2018-08-16 10:54:07 +0200 | [diff] [blame] | 1 | /* |
| 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 | |
| 13 | namespace webrtc { |
| 14 | |
| 15 | EchoControlMobileProxy::EchoControlMobileProxy( |
| 16 | AudioProcessing* audio_processing, |
| 17 | EchoControlMobile* echo_control_mobile) |
| 18 | : audio_processing_(audio_processing), |
| 19 | echo_control_mobile_(echo_control_mobile) {} |
| 20 | |
| 21 | EchoControlMobileProxy::~EchoControlMobileProxy() = default; |
| 22 | |
| 23 | int 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 | |
| 39 | bool EchoControlMobileProxy::is_enabled() const { |
| 40 | return echo_control_mobile_->is_enabled(); |
| 41 | } |
| 42 | |
| 43 | int EchoControlMobileProxy::set_routing_mode(RoutingMode mode) { |
| 44 | return echo_control_mobile_->set_routing_mode(mode); |
| 45 | } |
| 46 | |
| 47 | EchoControlMobile::RoutingMode EchoControlMobileProxy::routing_mode() const { |
| 48 | return echo_control_mobile_->routing_mode(); |
| 49 | } |
| 50 | |
| 51 | int EchoControlMobileProxy::enable_comfort_noise(bool enable) { |
| 52 | return echo_control_mobile_->enable_comfort_noise(enable); |
| 53 | } |
| 54 | |
| 55 | bool EchoControlMobileProxy::is_comfort_noise_enabled() const { |
| 56 | return echo_control_mobile_->is_comfort_noise_enabled(); |
| 57 | } |
| 58 | |
| 59 | int EchoControlMobileProxy::SetEchoPath(const void* echo_path, |
| 60 | size_t size_bytes) { |
| 61 | return echo_control_mobile_->SetEchoPath(echo_path, size_bytes); |
| 62 | } |
| 63 | |
| 64 | int 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 |