blob: 1678fc79c037044ff1fdd867d6feec7814ea1efa [file] [log] [blame]
peah69221db2017-01-27 03:28:19 -08001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_
peah69221db2017-01-27 03:28:19 -080013
14#include <stddef.h>
peahcf02cf12017-04-05 14:18:07 -070015#include <array>
peah69221db2017-01-27 03:28:19 -080016#include <vector>
17
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020018#include "api/array_view.h"
19#include "modules/audio_processing/aec3/aec3_common.h"
20#include "modules/audio_processing/aec3/downsampled_render_buffer.h"
21#include "modules/audio_processing/aec3/fft_data.h"
22#include "modules/audio_processing/aec3/render_buffer.h"
peahcf02cf12017-04-05 14:18:07 -070023
peah69221db2017-01-27 03:28:19 -080024namespace webrtc {
25
26// Class for buffering the incoming render blocks such that these may be
27// extracted with a specified delay.
28class RenderDelayBuffer {
29 public:
peahcf02cf12017-04-05 14:18:07 -070030 static RenderDelayBuffer* Create(size_t num_bands);
peah69221db2017-01-27 03:28:19 -080031 virtual ~RenderDelayBuffer() = default;
32
peahcf02cf12017-04-05 14:18:07 -070033 // Resets the buffer data.
34 virtual void Reset() = 0;
peah69221db2017-01-27 03:28:19 -080035
peahcf02cf12017-04-05 14:18:07 -070036 // 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;
peah69221db2017-01-27 03:28:19 -080039
peahcf02cf12017-04-05 14:18:07 -070040 // 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.
peah69221db2017-01-27 03:28:19 -080045 virtual void SetDelay(size_t delay) = 0;
46
47 // Gets the buffer delay.
48 virtual size_t Delay() const = 0;
49
peahcf02cf12017-04-05 14:18:07 -070050 // Returns the render buffer for the echo remover.
51 virtual const RenderBuffer& GetRenderBuffer() const = 0;
peah69221db2017-01-27 03:28:19 -080052
peahcf02cf12017-04-05 14:18:07 -070053 // Returns the downsampled render buffer.
54 virtual const DownsampledRenderBuffer& GetDownsampledRenderBuffer() const = 0;
peah69221db2017-01-27 03:28:19 -080055};
56
57} // namespace webrtc
58
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020059#endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_