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 | |
| 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_ |
| 13 | |
| 14 | #include <stddef.h> |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 15 | #include <array> |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 16 | #include <vector> |
| 17 | |
kwiberg | 529662a | 2017-09-04 05:43:17 -0700 | [diff] [blame] | 18 | #include "webrtc/api/array_view.h" |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 19 | #include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
| 20 | #include "webrtc/modules/audio_processing/aec3/downsampled_render_buffer.h" |
| 21 | #include "webrtc/modules/audio_processing/aec3/fft_data.h" |
| 22 | #include "webrtc/modules/audio_processing/aec3/render_buffer.h" |
| 23 | |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 24 | namespace webrtc { |
| 25 | |
| 26 | // Class for buffering the incoming render blocks such that these may be |
| 27 | // extracted with a specified delay. |
| 28 | class RenderDelayBuffer { |
| 29 | public: |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 30 | static RenderDelayBuffer* Create(size_t num_bands); |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 31 | virtual ~RenderDelayBuffer() = default; |
| 32 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 33 | // Resets the buffer data. |
| 34 | virtual void Reset() = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 35 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 36 | // Inserts a block into the buffer and returns true if the insert is |
| 37 | // successful. |
| 38 | virtual bool Insert(const std::vector<std::vector<float>>& block) = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 39 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 40 | // Updates the buffers one step based on the specified buffer delay. Returns |
| 41 | // true if there was no overrun, otherwise returns false. |
| 42 | virtual bool UpdateBuffers() = 0; |
| 43 | |
| 44 | // Sets the buffer delay. |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 45 | virtual void SetDelay(size_t delay) = 0; |
| 46 | |
| 47 | // Gets the buffer delay. |
| 48 | virtual size_t Delay() const = 0; |
| 49 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 50 | // Returns the render buffer for the echo remover. |
| 51 | virtual const RenderBuffer& GetRenderBuffer() const = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 52 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 53 | // Returns the downsampled render buffer. |
| 54 | virtual const DownsampledRenderBuffer& GetDownsampledRenderBuffer() const = 0; |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 55 | }; |
| 56 | |
| 57 | } // namespace webrtc |
| 58 | |
| 59 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_ |