blob: 11ba989d7af3db374b45f1d0d856e4aa865216a5 [file] [log] [blame]
Gustaf Ullberg8e467df2018-02-05 14:39:38 +01001/*
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 Ullbergfd4ce502018-02-15 10:09:09 +010011#ifndef API_AUDIO_ECHO_CONTROL_H_
12#define API_AUDIO_ECHO_CONTROL_H_
Gustaf Ullberg8e467df2018-02-05 14:39:38 +010013
14#include <memory>
15
Per Åhgren4e5c7092019-11-01 20:44:11 +010016#include "rtc_base/checks.h"
17
Gustaf Ullberg8e467df2018-02-05 14:39:38 +010018namespace webrtc {
19
20class AudioBuffer;
21
22// Interface for an acoustic echo cancellation (AEC) submodule.
23class 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 echo_path_change) = 0;
33
34 struct Metrics {
35 double echo_return_loss;
36 double echo_return_loss_enhancement;
37 int delay_ms;
38 };
39
40 // Collect current metrics from the echo controller.
41 virtual Metrics GetMetrics() const = 0;
42
Per Åhgrend0fa8202018-04-18 09:35:13 +020043 // Provides an optional external estimate of the audio buffer delay.
Gustaf Ullbergb394a562019-10-25 09:40:50 +020044 virtual void SetAudioBufferDelay(int delay_ms) = 0;
Per Åhgrend0fa8202018-04-18 09:35:13 +020045
Gustaf Ullberg8675eee2019-10-09 13:34:36 +020046 // Returns wheter the signal is altered.
47 virtual bool ActiveProcessing() const = 0;
48
Gustaf Ullberg8e467df2018-02-05 14:39:38 +010049 virtual ~EchoControl() {}
50};
51
52// Interface for a factory that creates EchoControllers.
53class EchoControlFactory {
54 public:
55 virtual std::unique_ptr<EchoControl> Create(int sample_rate_hz) = 0;
Per Åhgren4e5c7092019-11-01 20:44:11 +010056 // TODO(peah): Make pure virtual.
57 virtual std::unique_ptr<EchoControl> Create(int sample_rate_hz,
58 int num_render_channels,
59 int num_capture_channels) {
60 RTC_NOTREACHED();
61 return nullptr;
62 }
63
Gustaf Ullberg8e467df2018-02-05 14:39:38 +010064 virtual ~EchoControlFactory() = default;
65};
66} // namespace webrtc
67
Gustaf Ullbergfd4ce502018-02-15 10:09:09 +010068#endif // API_AUDIO_ECHO_CONTROL_H_