blob: 5f7ec7c17c3c86b7892b30f3b1cb85fb0e1db655 [file] [log] [blame]
peahd0263542017-01-03 04:20:34 -08001/*
2 * Copyright (c) 2016 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_BLOCK_PROCESSOR_H_
12#define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_
peahd0263542017-01-03 04:20:34 -080013
Yves Gerey988cc082018-10-23 12:03:01 +020014#include <stddef.h>
peahd0263542017-01-03 04:20:34 -080015#include <memory>
16#include <vector>
17
Yves Gerey988cc082018-10-23 12:03:01 +020018#include "api/audio/echo_canceller3_config.h"
19#include "api/audio/echo_control.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/audio_processing/aec3/echo_remover.h"
21#include "modules/audio_processing/aec3/render_delay_buffer.h"
22#include "modules/audio_processing/aec3/render_delay_controller.h"
peahd0263542017-01-03 04:20:34 -080023
24namespace webrtc {
25
26// Class for performing echo cancellation on 64 sample blocks of audio data.
27class BlockProcessor {
28 public:
Gustaf Ullberg11539f02018-10-15 13:40:29 +020029 // Create a block processor with the legacy render buffering.
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020030 static BlockProcessor* Create(const EchoCanceller3Config& config,
31 int sample_rate_hz);
Gustaf Ullberg11539f02018-10-15 13:40:29 +020032 // Create a block processor with the new render buffering.
33 static BlockProcessor* Create2(const EchoCanceller3Config& config,
34 int sample_rate_hz);
peah69221db2017-01-27 03:28:19 -080035 // Only used for testing purposes.
36 static BlockProcessor* Create(
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020037 const EchoCanceller3Config& config,
peah69221db2017-01-27 03:28:19 -080038 int sample_rate_hz,
39 std::unique_ptr<RenderDelayBuffer> render_buffer);
Gustaf Ullberg11539f02018-10-15 13:40:29 +020040 static BlockProcessor* Create2(
41 const EchoCanceller3Config& config,
42 int sample_rate_hz,
43 std::unique_ptr<RenderDelayBuffer> render_buffer);
peah69221db2017-01-27 03:28:19 -080044 static BlockProcessor* Create(
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020045 const EchoCanceller3Config& config,
peah69221db2017-01-27 03:28:19 -080046 int sample_rate_hz,
47 std::unique_ptr<RenderDelayBuffer> render_buffer,
48 std::unique_ptr<RenderDelayController> delay_controller,
49 std::unique_ptr<EchoRemover> echo_remover);
Gustaf Ullberg11539f02018-10-15 13:40:29 +020050 static BlockProcessor* Create2(
51 const EchoCanceller3Config& config,
52 int sample_rate_hz,
53 std::unique_ptr<RenderDelayBuffer> render_buffer,
54 std::unique_ptr<RenderDelayController> delay_controller,
55 std::unique_ptr<EchoRemover> echo_remover);
peah69221db2017-01-27 03:28:19 -080056
peahd0263542017-01-03 04:20:34 -080057 virtual ~BlockProcessor() = default;
58
Gustaf Ullberg332150d2017-11-22 14:17:39 +010059 // Get current metrics.
60 virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0;
61
Per Ã…hgrend0fa8202018-04-18 09:35:13 +020062 // Provides an optional external estimate of the audio buffer delay.
63 virtual void SetAudioBufferDelay(size_t delay_ms) = 0;
64
peahd0263542017-01-03 04:20:34 -080065 // Processes a block of capture data.
66 virtual void ProcessCapture(
peah69221db2017-01-27 03:28:19 -080067 bool echo_path_gain_change,
68 bool capture_signal_saturation,
peahd0263542017-01-03 04:20:34 -080069 std::vector<std::vector<float>>* capture_block) = 0;
70
peahcf02cf12017-04-05 14:18:07 -070071 // Buffers a block of render data supplied by a FrameBlocker object.
72 virtual void BufferRender(
73 const std::vector<std::vector<float>>& render_block) = 0;
peahd0263542017-01-03 04:20:34 -080074
75 // Reports whether echo leakage has been detected in the echo canceller
76 // output.
peah69221db2017-01-27 03:28:19 -080077 virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0;
peahd0263542017-01-03 04:20:34 -080078};
79
80} // namespace webrtc
81
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_