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