block_processor.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Copyright (c) 2016 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 MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_
  11. #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_
  12. #include <stddef.h>
  13. #include <memory>
  14. #include <vector>
  15. #include "api/audio/echo_canceller3_config.h"
  16. #include "api/audio/echo_control.h"
  17. #include "modules/audio_processing/aec3/echo_remover.h"
  18. #include "modules/audio_processing/aec3/render_delay_buffer.h"
  19. #include "modules/audio_processing/aec3/render_delay_controller.h"
  20. namespace webrtc {
  21. // Class for performing echo cancellation on 64 sample blocks of audio data.
  22. class BlockProcessor {
  23. public:
  24. static BlockProcessor* Create(const EchoCanceller3Config& config,
  25. int sample_rate_hz,
  26. size_t num_render_channels,
  27. size_t num_capture_channels);
  28. // Only used for testing purposes.
  29. static BlockProcessor* Create(
  30. const EchoCanceller3Config& config,
  31. int sample_rate_hz,
  32. size_t num_render_channels,
  33. size_t num_capture_channels,
  34. std::unique_ptr<RenderDelayBuffer> render_buffer);
  35. static BlockProcessor* Create(
  36. const EchoCanceller3Config& config,
  37. int sample_rate_hz,
  38. size_t num_render_channels,
  39. size_t num_capture_channels,
  40. std::unique_ptr<RenderDelayBuffer> render_buffer,
  41. std::unique_ptr<RenderDelayController> delay_controller,
  42. std::unique_ptr<EchoRemover> echo_remover);
  43. virtual ~BlockProcessor() = default;
  44. // Get current metrics.
  45. virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0;
  46. // Provides an optional external estimate of the audio buffer delay.
  47. virtual void SetAudioBufferDelay(int delay_ms) = 0;
  48. // Processes a block of capture data.
  49. virtual void ProcessCapture(
  50. bool echo_path_gain_change,
  51. bool capture_signal_saturation,
  52. std::vector<std::vector<std::vector<float>>>* linear_output,
  53. std::vector<std::vector<std::vector<float>>>* capture_block) = 0;
  54. // Buffers a block of render data supplied by a FrameBlocker object.
  55. virtual void BufferRender(
  56. const std::vector<std::vector<std::vector<float>>>& render_block) = 0;
  57. // Reports whether echo leakage has been detected in the echo canceller
  58. // output.
  59. virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0;
  60. };
  61. } // namespace webrtc
  62. #endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_