| 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 | #ifndef API_AUDIO_ECHO_CONTROL_H_ |
| 12 | #define API_AUDIO_ECHO_CONTROL_H_ |
| 13 |
| 14 | #include <memory> |
| 15 |
| 16 | #include "rtc_base/checks.h" |
| 17 |
| 18 | namespace webrtc { |
| 19 |
| 20 | class AudioBuffer; |
| 21 |
| 22 | // Interface for an acoustic echo cancellation (AEC) submodule. |
| 23 | class EchoControl { |
| 24 | public: |
| 25 | // Analysis (not changing) of the render signal. |
| 26 | virtual void AnalyzeRender(AudioBuffer* render) = 0; |
| 27 |
| 28 | // Analysis (not changing) of the capture signal. |
| 29 | virtual void AnalyzeCapture(AudioBuffer* capture) = 0; |
| 30 |
| 31 | // Processes the capture signal in order to remove the echo. |
| 32 | virtual void ProcessCapture(AudioBuffer* capture, bool level_change) = 0; |
| 33 |
| 34 | // As above, but also returns the linear filter output. |
| 35 | virtual void ProcessCapture(AudioBuffer* capture, |
| 36 | AudioBuffer* linear_output, |
| 37 | bool level_change) = 0; |
| 38 |
| 39 | struct Metrics { |
| 40 | double echo_return_loss; |
| 41 | double echo_return_loss_enhancement; |
| 42 | int delay_ms; |
| 43 | }; |
| 44 |
| 45 | // Collect current metrics from the echo controller. |
| 46 | virtual Metrics GetMetrics() const = 0; |
| 47 |
| 48 | // Provides an optional external estimate of the audio buffer delay. |
| 49 | virtual void SetAudioBufferDelay(int delay_ms) = 0; |
| 50 |
| 51 | // Specifies whether the capture output will be used. The purpose of this is |
| 52 | // to allow the echo controller to deactivate some of the processing when the |
| 53 | // resulting output is anyway not used, for instance when the endpoint is |
| 54 | // muted. |
| 55 | // TODO(b/177830919): Make pure virtual. |
| 56 | virtual void SetCaptureOutputUsage(bool capture_output_used) {} |
| 57 |
| 58 | // Returns wheter the signal is altered. |
| 59 | virtual bool ActiveProcessing() const = 0; |
| 60 |
| 61 | virtual ~EchoControl() {} |
| 62 | }; |
| 63 |
| 64 | // Interface for a factory that creates EchoControllers. |
| 65 | class EchoControlFactory { |
| 66 | public: |
| 67 | virtual std::unique_ptr<EchoControl> Create(int sample_rate_hz, |
| 68 | int num_render_channels, |
| 69 | int num_capture_channels) = 0; |
| 70 |
| 71 | virtual ~EchoControlFactory() = default; |
| 72 | }; |
| 73 | } // namespace webrtc |
| 74 |
| 75 | #endif // API_AUDIO_ECHO_CONTROL_H_ |
| 76 |