blob: 8f5de407523ed2398ba778f92f8012b3f3dd1d04 [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:
Per Ã…hgren38e2d952017-11-17 14:54:28 +010030 static RenderDelayBuffer* Create(size_t num_bands,
31 size_t down_sampling_factor,
32 size_t downsampled_render_buffer_size,
33 size_t render_delay_buffer_size);
peah69221db2017-01-27 03:28:19 -080034 virtual ~RenderDelayBuffer() = default;
35
peahcf02cf12017-04-05 14:18:07 -070036 // Resets the buffer data.
37 virtual void Reset() = 0;
peah69221db2017-01-27 03:28:19 -080038
peahcf02cf12017-04-05 14:18:07 -070039 // Inserts a block into the buffer and returns true if the insert is
40 // successful.
41 virtual bool Insert(const std::vector<std::vector<float>>& block) = 0;
peah69221db2017-01-27 03:28:19 -080042
peahcf02cf12017-04-05 14:18:07 -070043 // Updates the buffers one step based on the specified buffer delay. Returns
44 // true if there was no overrun, otherwise returns false.
45 virtual bool UpdateBuffers() = 0;
46
47 // Sets the buffer delay.
peah69221db2017-01-27 03:28:19 -080048 virtual void SetDelay(size_t delay) = 0;
49
50 // Gets the buffer delay.
51 virtual size_t Delay() const = 0;
52
peahcf02cf12017-04-05 14:18:07 -070053 // Returns the render buffer for the echo remover.
54 virtual const RenderBuffer& GetRenderBuffer() const = 0;
peah69221db2017-01-27 03:28:19 -080055
peahcf02cf12017-04-05 14:18:07 -070056 // Returns the downsampled render buffer.
57 virtual const DownsampledRenderBuffer& GetDownsampledRenderBuffer() const = 0;
peah69221db2017-01-27 03:28:19 -080058};
59
60} // namespace webrtc
61
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020062#endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_