blob: 8b1bb908f31824f9d375eee13e245c9c2b630846 [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"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020021#include "modules/audio_processing/aec3/echo_remover.h"
22#include "modules/audio_processing/aec3/render_delay_buffer.h"
23#include "modules/audio_processing/aec3/render_delay_controller.h"
peahd0263542017-01-03 04:20:34 -080024
25namespace webrtc {
26
27// Class for performing echo cancellation on 64 sample blocks of audio data.
28class BlockProcessor {
29 public:
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020030 static BlockProcessor* Create(const EchoCanceller3Config& config,
Per Åhgrend112c752019-09-02 13:56:56 +000031 int sample_rate_hz);
peah69221db2017-01-27 03:28:19 -080032 // Only used for testing purposes.
33 static BlockProcessor* Create(
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020034 const EchoCanceller3Config& config,
peah69221db2017-01-27 03:28:19 -080035 int sample_rate_hz,
36 std::unique_ptr<RenderDelayBuffer> render_buffer);
37 static BlockProcessor* Create(
Gustaf Ullbergbd83b912017-10-18 12:32:42 +020038 const EchoCanceller3Config& config,
peah69221db2017-01-27 03:28:19 -080039 int sample_rate_hz,
40 std::unique_ptr<RenderDelayBuffer> render_buffer,
41 std::unique_ptr<RenderDelayController> delay_controller,
42 std::unique_ptr<EchoRemover> echo_remover);
43
peahd0263542017-01-03 04:20:34 -080044 virtual ~BlockProcessor() = default;
45
Gustaf Ullberg332150d2017-11-22 14:17:39 +010046 // Get current metrics.
47 virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0;
48
Per Åhgrend0fa8202018-04-18 09:35:13 +020049 // Provides an optional external estimate of the audio buffer delay.
50 virtual void SetAudioBufferDelay(size_t delay_ms) = 0;
51
peahd0263542017-01-03 04:20:34 -080052 // Processes a block of capture data.
53 virtual void ProcessCapture(
peah69221db2017-01-27 03:28:19 -080054 bool echo_path_gain_change,
55 bool capture_signal_saturation,
Per Åhgrend112c752019-09-02 13:56:56 +000056 std::vector<std::vector<float>>* capture_block) = 0;
peahd0263542017-01-03 04:20:34 -080057
peahcf02cf12017-04-05 14:18:07 -070058 // Buffers a block of render data supplied by a FrameBlocker object.
59 virtual void BufferRender(
Per Åhgrend112c752019-09-02 13:56:56 +000060 const std::vector<std::vector<float>>& render_block) = 0;
peahd0263542017-01-03 04:20:34 -080061
62 // Reports whether echo leakage has been detected in the echo canceller
63 // output.
peah69221db2017-01-27 03:28:19 -080064 virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0;
peahd0263542017-01-03 04:20:34 -080065};
66
67} // namespace webrtc
68
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020069#endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_