render_delay_controller.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*
  2. * Copyright (c) 2017 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_RENDER_DELAY_CONTROLLER_H_
  11. #define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_
  12. #include "absl/types/optional.h"
  13. #include "api/array_view.h"
  14. #include "api/audio/echo_canceller3_config.h"
  15. #include "modules/audio_processing/aec3/delay_estimate.h"
  16. #include "modules/audio_processing/aec3/downsampled_render_buffer.h"
  17. #include "modules/audio_processing/aec3/render_delay_buffer.h"
  18. #include "modules/audio_processing/logging/apm_data_dumper.h"
  19. namespace webrtc {
  20. // Class for aligning the render and capture signal using a RenderDelayBuffer.
  21. class RenderDelayController {
  22. public:
  23. static RenderDelayController* Create(const EchoCanceller3Config& config,
  24. int sample_rate_hz,
  25. size_t num_capture_channels);
  26. virtual ~RenderDelayController() = default;
  27. // Resets the delay controller. If the delay confidence is reset, the reset
  28. // behavior is as if the call is restarted.
  29. virtual void Reset(bool reset_delay_confidence) = 0;
  30. // Logs a render call.
  31. virtual void LogRenderCall() = 0;
  32. // Aligns the render buffer content with the capture signal.
  33. virtual absl::optional<DelayEstimate> GetDelay(
  34. const DownsampledRenderBuffer& render_buffer,
  35. size_t render_delay_buffer_delay,
  36. const std::vector<std::vector<float>>& capture) = 0;
  37. // Returns true if clockdrift has been detected.
  38. virtual bool HasClockdrift() const = 0;
  39. };
  40. } // namespace webrtc
  41. #endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_