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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 14 | #include "api/array_view.h" |
| 15 | #include "api/optional.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/include/audio_processing.h" |
| 19 | #include "modules/audio_processing/logging/apm_data_dumper.h" |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 20 | |
| 21 | namespace webrtc { |
| 22 | |
| 23 | // Class for aligning the render and capture signal using a RenderDelayBuffer. |
| 24 | class RenderDelayController { |
| 25 | public: |
peah | 4fed3c0 | 2017-08-30 06:58:44 -0700 | [diff] [blame] | 26 | static RenderDelayController* Create( |
| 27 | const AudioProcessing::Config::EchoCanceller3& config, |
| 28 | int sample_rate_hz); |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 29 | virtual ~RenderDelayController() = default; |
| 30 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 31 | // Resets the delay controller. |
| 32 | virtual void Reset() = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 33 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 34 | // Receives the externally used delay. |
| 35 | virtual void SetDelay(size_t render_delay) = 0; |
| 36 | |
| 37 | // Aligns the render buffer content with the capture signal. |
| 38 | virtual size_t GetDelay(const DownsampledRenderBuffer& render_buffer, |
| 39 | rtc::ArrayView<const float> capture) = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 40 | |
| 41 | // Returns an approximate value for the headroom in the buffer alignment. |
| 42 | virtual rtc::Optional<size_t> AlignmentHeadroomSamples() const = 0; |
| 43 | }; |
| 44 | } // namespace webrtc |
| 45 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 46 | #endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_H_ |