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>
|
2019-07-05 19:08:33 +02:00
|
|
|
|
2017-01-27 03:28:19 -08:00
|
|
|
#include <vector>
|
|
|
|
|
|
2018-02-14 15:19:04 +01:00
|
|
|
#include "api/audio/echo_canceller3_config.h"
|
2022-05-23 10:39:53 +02:00
|
|
|
#include "modules/audio_processing/aec3/block.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/aec3/downsampled_render_buffer.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,
|
2018-10-15 13:40:29 +02:00
|
|
|
kApiCallSkew
|
2017-12-01 23:01:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static RenderDelayBuffer* Create(const EchoCanceller3Config& config,
|
2019-09-02 17:01:19 +02:00
|
|
|
int sample_rate_hz,
|
|
|
|
|
size_t num_render_channels);
|
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.
|
2022-05-23 10:39:53 +02:00
|
|
|
virtual BufferingEvent Insert(const Block& 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
|
|
|
|
2020-07-27 15:45:30 +02:00
|
|
|
// Called on capture blocks where PrepareCaptureProcessing is not called.
|
|
|
|
|
virtual void HandleSkippedCaptureProcessing() = 0;
|
|
|
|
|
|
2017-12-11 21:34:19 +01:00
|
|
|
// Sets the buffer delay and returns a bool indicating whether the delay
|
|
|
|
|
// changed.
|
2019-04-05 16:23:50 +02:00
|
|
|
virtual bool AlignFromDelay(size_t delay) = 0;
|
|
|
|
|
|
|
|
|
|
// Sets the buffer delay from the most recently reported external delay.
|
|
|
|
|
virtual void AlignFromExternalDelay() = 0;
|
2017-01-27 03:28:19 -08:00
|
|
|
|
|
|
|
|
// Gets the buffer delay.
|
2018-03-22 00:29:25 +01:00
|
|
|
virtual 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 the maximum non calusal offset that can occur in the delay buffer.
|
|
|
|
|
static int DelayEstimatorOffset(const EchoCanceller3Config& config);
|
2018-04-18 09:35:13 +02:00
|
|
|
|
|
|
|
|
// Provides an optional external estimate of the audio buffer delay.
|
2019-10-24 15:52:10 +02:00
|
|
|
virtual void SetAudioBufferDelay(int delay_ms) = 0;
|
2019-04-05 16:23:50 +02:00
|
|
|
|
|
|
|
|
// Returns whether an external delay estimate has been reported via
|
|
|
|
|
// SetAudioBufferDelay.
|
|
|
|
|
virtual bool HasReceivedBufferDelay() = 0;
|
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_
|