Gustaf Ullberg | 8e467df | 2018-02-05 14:39:38 +0100 | [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 | |
Gustaf Ullberg | fd4ce50 | 2018-02-15 10:09:09 +0100 | [diff] [blame] | 11 | #ifndef API_AUDIO_ECHO_CONTROL_H_ |
| 12 | #define API_AUDIO_ECHO_CONTROL_H_ |
Gustaf Ullberg | 8e467df | 2018-02-05 14:39:38 +0100 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | |
| 16 | namespace webrtc { |
| 17 | |
| 18 | class AudioBuffer; |
| 19 | |
| 20 | // Interface for an acoustic echo cancellation (AEC) submodule. |
| 21 | class EchoControl { |
| 22 | public: |
| 23 | // Analysis (not changing) of the render signal. |
| 24 | virtual void AnalyzeRender(AudioBuffer* render) = 0; |
| 25 | |
| 26 | // Analysis (not changing) of the capture signal. |
| 27 | virtual void AnalyzeCapture(AudioBuffer* capture) = 0; |
| 28 | |
| 29 | // Processes the capture signal in order to remove the echo. |
| 30 | virtual void ProcessCapture(AudioBuffer* capture, bool echo_path_change) = 0; |
| 31 | |
| 32 | struct Metrics { |
| 33 | double echo_return_loss; |
| 34 | double echo_return_loss_enhancement; |
| 35 | int delay_ms; |
| 36 | }; |
| 37 | |
| 38 | // Collect current metrics from the echo controller. |
| 39 | virtual Metrics GetMetrics() const = 0; |
| 40 | |
Per Åhgren | d0fa820 | 2018-04-18 09:35:13 +0200 | [diff] [blame] | 41 | // Provides an optional external estimate of the audio buffer delay. |
Gustaf Ullberg | 3cb6104 | 2019-10-24 15:52:10 +0200 | [diff] [blame] | 42 | virtual void SetAudioBufferDelay(size_t delay_ms) {} |
| 43 | virtual void SetAudioBufferDelay(int delay_ms) { |
| 44 | // Default to old implementation. |
| 45 | SetAudioBufferDelay(static_cast<size_t>(delay_ms)); |
| 46 | } |
Per Åhgren | d0fa820 | 2018-04-18 09:35:13 +0200 | [diff] [blame] | 47 | |
Gustaf Ullberg | 8675eee | 2019-10-09 13:34:36 +0200 | [diff] [blame] | 48 | // Returns wheter the signal is altered. |
| 49 | virtual bool ActiveProcessing() const = 0; |
| 50 | |
Gustaf Ullberg | 8e467df | 2018-02-05 14:39:38 +0100 | [diff] [blame] | 51 | virtual ~EchoControl() {} |
| 52 | }; |
| 53 | |
| 54 | // Interface for a factory that creates EchoControllers. |
| 55 | class EchoControlFactory { |
| 56 | public: |
| 57 | virtual std::unique_ptr<EchoControl> Create(int sample_rate_hz) = 0; |
| 58 | virtual ~EchoControlFactory() = default; |
| 59 | }; |
| 60 | } // namespace webrtc |
| 61 | |
Gustaf Ullberg | fd4ce50 | 2018-02-15 10:09:09 +0100 | [diff] [blame] | 62 | #endif // API_AUDIO_ECHO_CONTROL_H_ |