peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 13 | |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 14 | #include "absl/types/optional.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 15 | #include "api/array_view.h" |
Gustaf Ullberg | 3646f97 | 2018-02-14 15:19:04 +0100 | [diff] [blame] | 16 | #include "api/audio/echo_canceller3_config.h" |
Per Åhgren | a76ef9d | 2018-01-25 07:01:34 +0100 | [diff] [blame] | 17 | #include "modules/audio_processing/aec3/delay_estimate.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "modules/audio_processing/aec3/downsampled_render_buffer.h" |
| 19 | #include "modules/audio_processing/aec3/render_delay_buffer.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "modules/audio_processing/logging/apm_data_dumper.h" |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
| 23 | |
| 24 | // Class for aligning the render and capture signal using a RenderDelayBuffer. |
| 25 | class RenderDelayController { |
| 26 | public: |
Gustaf Ullberg | bd83b91 | 2017-10-18 12:32:42 +0200 | [diff] [blame] | 27 | static RenderDelayController* Create(const EchoCanceller3Config& config, |
| 28 | int sample_rate_hz); |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 29 | virtual ~RenderDelayController() = default; |
| 30 | |
Per Åhgren | 8b7d206 | 2018-10-30 23:44:40 +0100 | [diff] [blame] | 31 | // Resets the delay controller. If the delay confidence is reset, the reset |
| 32 | // behavior is as if the call is restarted. |
| 33 | virtual void Reset(bool reset_delay_confidence) = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 34 | |
Per Åhgren | 4712776 | 2018-02-13 12:59:33 +0100 | [diff] [blame] | 35 | // Logs a render call. |
| 36 | virtual void LogRenderCall() = 0; |
| 37 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 38 | // Aligns the render buffer content with the capture signal. |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 39 | virtual absl::optional<DelayEstimate> GetDelay( |
Per Åhgren | c59a576 | 2017-12-11 21:34:19 +0100 | [diff] [blame] | 40 | const DownsampledRenderBuffer& render_buffer, |
Per Åhgren | 5c532d3 | 2018-03-22 00:29:25 +0100 | [diff] [blame] | 41 | size_t render_delay_buffer_delay, |
Gustaf Ullberg | ee84d39 | 2019-09-10 09:36:43 +0200 | [diff] [blame] | 42 | const std::vector<std::vector<float>>& capture) = 0; |
Gustaf Ullberg | 777cf26 | 2018-11-22 16:02:34 +0100 | [diff] [blame] | 43 | |
| 44 | // Returns true if clockdrift has been detected. |
| 45 | virtual bool HasClockdrift() const = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 46 | }; |
| 47 | } // namespace webrtc |
| 48 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 49 | #endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ |