2017-01-27 03:28:19 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_
|
2017-01-27 03:28:19 -08:00
|
|
|
|
|
|
|
|
#include <stddef.h>
|
2017-04-05 14:18:07 -07:00
|
|
|
#include <array>
|
2017-01-27 03:28:19 -08:00
|
|
|
#include <vector>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/array_view.h"
|
2018-02-14 15:19:04 +01:00
|
|
|
#include "api/audio/echo_canceller3_config.h"
|
|
|
|
|
#include "api/optional.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/aec3/aec3_common.h"
|
|
|
|
|
#include "modules/audio_processing/aec3/downsampled_render_buffer.h"
|
|
|
|
|
#include "modules/audio_processing/aec3/fft_data.h"
|
|
|
|
|
#include "modules/audio_processing/aec3/render_buffer.h"
|
2017-04-05 14:18:07 -07:00
|
|
|
|
2017-01-27 03:28:19 -08:00
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Class for buffering the incoming render blocks such that these may be
|
|
|
|
|
// extracted with a specified delay.
|
|
|
|
|
class RenderDelayBuffer {
|
|
|
|
|
public:
|
2017-12-01 23:01:44 +01:00
|
|
|
enum class BufferingEvent {
|
|
|
|
|
kNone,
|
|
|
|
|
kRenderUnderrun,
|
|
|
|
|
kRenderOverrun,
|
|
|
|
|
kApiCallSkew,
|
|
|
|
|
kRenderDataLost
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static RenderDelayBuffer* Create(const EchoCanceller3Config& config,
|
|
|
|
|
size_t num_bands);
|
2017-01-27 03:28:19 -08:00
|
|
|
virtual ~RenderDelayBuffer() = default;
|
|
|
|
|
|
2017-12-01 23:01:44 +01:00
|
|
|
// Resets the buffer alignment.
|
2017-04-05 14:18:07 -07:00
|
|
|
virtual void Reset() = 0;
|
|
|
|
|
|
2017-12-01 23:01:44 +01:00
|
|
|
// Inserts a block into the buffer.
|
|
|
|
|
virtual BufferingEvent Insert(
|
|
|
|
|
const std::vector<std::vector<float>>& block) = 0;
|
2017-01-27 03:28:19 -08:00
|
|
|
|
2017-04-05 14:18:07 -07:00
|
|
|
// Updates the buffers one step based on the specified buffer delay. Returns
|
2017-12-01 23:01:44 +01:00
|
|
|
// an enum indicating whether there was a special event that occurred.
|
2017-12-11 21:34:19 +01:00
|
|
|
virtual BufferingEvent PrepareCaptureProcessing() = 0;
|
2017-01-27 03:28:19 -08:00
|
|
|
|
2017-12-11 21:34:19 +01:00
|
|
|
// Sets the buffer delay and returns a bool indicating whether the delay
|
|
|
|
|
// changed.
|
|
|
|
|
virtual bool SetDelay(size_t delay) = 0;
|
2017-01-27 03:28:19 -08:00
|
|
|
|
|
|
|
|
// Gets the buffer delay.
|
2017-12-11 21:34:19 +01:00
|
|
|
virtual rtc::Optional<size_t> Delay() const = 0;
|
2017-01-27 03:28:19 -08:00
|
|
|
|
2017-12-01 23:01:44 +01:00
|
|
|
// Gets the buffer delay.
|
|
|
|
|
virtual size_t MaxDelay() const = 0;
|
|
|
|
|
|
2017-04-05 14:18:07 -07:00
|
|
|
// Returns the render buffer for the echo remover.
|
2017-12-11 21:34:19 +01:00
|
|
|
virtual RenderBuffer* GetRenderBuffer() = 0;
|
2017-01-27 03:28:19 -08:00
|
|
|
|
2017-04-05 14:18:07 -07:00
|
|
|
// Returns the downsampled render buffer.
|
|
|
|
|
virtual const DownsampledRenderBuffer& GetDownsampledRenderBuffer() const = 0;
|
2017-12-11 21:34:19 +01:00
|
|
|
|
|
|
|
|
// Returns whether the current delay is noncausal.
|
2018-01-25 07:01:34 +01:00
|
|
|
virtual bool CausalDelay(size_t delay) const = 0;
|
2017-12-11 21:34:19 +01:00
|
|
|
|
|
|
|
|
// Returns the maximum non calusal offset that can occur in the delay buffer.
|
|
|
|
|
static int DelayEstimatorOffset(const EchoCanceller3Config& config);
|
2017-01-27 03:28:19 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_
|