echo_control.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef API_AUDIO_ECHO_CONTROL_H_
  11. #define API_AUDIO_ECHO_CONTROL_H_
  12. #include <memory>
  13. #include "rtc_base/checks.h"
  14. namespace webrtc {
  15. class AudioBuffer;
  16. // Interface for an acoustic echo cancellation (AEC) submodule.
  17. class EchoControl {
  18. public:
  19. // Analysis (not changing) of the render signal.
  20. virtual void AnalyzeRender(AudioBuffer* render) = 0;
  21. // Analysis (not changing) of the capture signal.
  22. virtual void AnalyzeCapture(AudioBuffer* capture) = 0;
  23. // Processes the capture signal in order to remove the echo.
  24. virtual void ProcessCapture(AudioBuffer* capture, bool level_change) = 0;
  25. // As above, but also returns the linear filter output.
  26. virtual void ProcessCapture(AudioBuffer* capture,
  27. AudioBuffer* linear_output,
  28. bool level_change) = 0;
  29. struct Metrics {
  30. double echo_return_loss;
  31. double echo_return_loss_enhancement;
  32. int delay_ms;
  33. };
  34. // Collect current metrics from the echo controller.
  35. virtual Metrics GetMetrics() const = 0;
  36. // Provides an optional external estimate of the audio buffer delay.
  37. virtual void SetAudioBufferDelay(int delay_ms) = 0;
  38. // Returns wheter the signal is altered.
  39. virtual bool ActiveProcessing() const = 0;
  40. virtual ~EchoControl() {}
  41. };
  42. // Interface for a factory that creates EchoControllers.
  43. class EchoControlFactory {
  44. public:
  45. virtual std::unique_ptr<EchoControl> Create(int sample_rate_hz,
  46. int num_render_channels,
  47. int num_capture_channels) = 0;
  48. virtual ~EchoControlFactory() = default;
  49. };
  50. } // namespace webrtc
  51. #endif // API_AUDIO_ECHO_CONTROL_H_