blob: 01a83ae5f77a6910d326ea02c8d6a8333141e054 [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>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
peahd0263542017-01-03 04:20:34 -080016#include <memory>
17#include <vector>
18
Yves Gerey988cc082018-10-23 12:03:01 +020019#include "api/audio/echo_canceller3_config.h"
20#include "api/audio/echo_control.h"
Gustaf Ullbergd3ead1a2022-05-23 10:39:53 +020021#include "modules/audio_processing/aec3/block.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "modules/audio_processing/aec3/echo_remover.h"
23#include "modules/audio_processing/aec3/render_delay_buffer.h"
24#include "modules/audio_processing/aec3/render_delay_controller.h"
peahd0263542017-01-03 04:20:34 -080025
26namespace webrtc {
27
28// Class for performing echo cancellation on 64 sample blocks of audio data.
29class BlockProcessor {
30 public:
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020031 static BlockProcessor* Create(const EchoCanceller3Config& config,
Per Åhgrence202a02019-09-02 17:01:19 +020032 int sample_rate_hz,
33 size_t num_render_channels,
34 size_t num_capture_channels);
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,
Per Åhgrence202a02019-09-02 17:01:19 +020039 size_t num_render_channels,
40 size_t num_capture_channels,
peah69221db2017-01-27 03:28:19 -080041 std::unique_ptr<RenderDelayBuffer> render_buffer);
42 static BlockProcessor* Create(
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020043 const EchoCanceller3Config& config,
peah69221db2017-01-27 03:28:19 -080044 int sample_rate_hz,
Per Åhgrence202a02019-09-02 17:01:19 +020045 size_t num_render_channels,
46 size_t num_capture_channels,
peah69221db2017-01-27 03:28:19 -080047 std::unique_ptr<RenderDelayBuffer> render_buffer,
48 std::unique_ptr<RenderDelayController> delay_controller,
49 std::unique_ptr<EchoRemover> echo_remover);
50
peahd0263542017-01-03 04:20:34 -080051 virtual ~BlockProcessor() = default;
52
Gustaf Ullberg332150d2017-11-22 14:17:39 +010053 // Get current metrics.
54 virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0;
55
Per Åhgrend0fa8202018-04-18 09:35:13 +020056 // Provides an optional external estimate of the audio buffer delay.
Gustaf Ullberg3cb61042019-10-24 15:52:10 +020057 virtual void SetAudioBufferDelay(int delay_ms) = 0;
Per Åhgrend0fa8202018-04-18 09:35:13 +020058
peahd0263542017-01-03 04:20:34 -080059 // Processes a block of capture data.
Gustaf Ullbergd3ead1a2022-05-23 10:39:53 +020060 virtual void ProcessCapture(bool echo_path_gain_change,
61 bool capture_signal_saturation,
62 Block* linear_output,
63 Block* capture_block) = 0;
peahd0263542017-01-03 04:20:34 -080064
peahcf02cf12017-04-05 14:18:07 -070065 // Buffers a block of render data supplied by a FrameBlocker object.
Gustaf Ullbergd3ead1a2022-05-23 10:39:53 +020066 virtual void BufferRender(const Block& render_block) = 0;
peahd0263542017-01-03 04:20:34 -080067
68 // Reports whether echo leakage has been detected in the echo canceller
69 // output.
peah69221db2017-01-27 03:28:19 -080070 virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0;
Per Åhgren8ee1ec82021-03-11 06:33:45 +000071
72 // Specifies whether the capture output will be used. The purpose of this is
73 // to allow the block processor to deactivate some of the processing when the
74 // resulting output is anyway not used, for instance when the endpoint is
75 // muted.
76 virtual void SetCaptureOutputUsage(bool capture_output_used) = 0;
peahd0263542017-01-03 04:20:34 -080077};
78
79} // namespace webrtc
80
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020081#endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_