peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_ |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 13 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame^] | 14 | #include <stddef.h> |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 15 | #include <memory> |
| 16 | #include <vector> |
| 17 | |
Yves Gerey | 988cc08 | 2018-10-23 12:03:01 +0200 | [diff] [blame^] | 18 | #include "api/audio/echo_canceller3_config.h" |
| 19 | #include "api/audio/echo_control.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #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" |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 23 | |
| 24 | namespace webrtc { |
| 25 | |
| 26 | // Class for performing echo cancellation on 64 sample blocks of audio data. |
| 27 | class BlockProcessor { |
| 28 | public: |
Gustaf Ullberg | 11539f0 | 2018-10-15 13:40:29 +0200 | [diff] [blame] | 29 | // Create a block processor with the legacy render buffering. |
Gustaf Ullberg | bd83b91 | 2017-10-18 12:32:42 +0200 | [diff] [blame] | 30 | static BlockProcessor* Create(const EchoCanceller3Config& config, |
| 31 | int sample_rate_hz); |
Gustaf Ullberg | 11539f0 | 2018-10-15 13:40:29 +0200 | [diff] [blame] | 32 | // Create a block processor with the new render buffering. |
| 33 | static BlockProcessor* Create2(const EchoCanceller3Config& config, |
| 34 | int sample_rate_hz); |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 35 | // Only used for testing purposes. |
| 36 | static BlockProcessor* Create( |
Gustaf Ullberg | bd83b91 | 2017-10-18 12:32:42 +0200 | [diff] [blame] | 37 | const EchoCanceller3Config& config, |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 38 | int sample_rate_hz, |
| 39 | std::unique_ptr<RenderDelayBuffer> render_buffer); |
Gustaf Ullberg | 11539f0 | 2018-10-15 13:40:29 +0200 | [diff] [blame] | 40 | static BlockProcessor* Create2( |
| 41 | const EchoCanceller3Config& config, |
| 42 | int sample_rate_hz, |
| 43 | std::unique_ptr<RenderDelayBuffer> render_buffer); |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 44 | static BlockProcessor* Create( |
Gustaf Ullberg | bd83b91 | 2017-10-18 12:32:42 +0200 | [diff] [blame] | 45 | const EchoCanceller3Config& config, |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 46 | 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 Ullberg | 11539f0 | 2018-10-15 13:40:29 +0200 | [diff] [blame] | 50 | 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); |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 56 | |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 57 | virtual ~BlockProcessor() = default; |
| 58 | |
Gustaf Ullberg | 332150d | 2017-11-22 14:17:39 +0100 | [diff] [blame] | 59 | // Get current metrics. |
| 60 | virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0; |
| 61 | |
Per Ã…hgren | d0fa820 | 2018-04-18 09:35:13 +0200 | [diff] [blame] | 62 | // Provides an optional external estimate of the audio buffer delay. |
| 63 | virtual void SetAudioBufferDelay(size_t delay_ms) = 0; |
| 64 | |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 65 | // Processes a block of capture data. |
| 66 | virtual void ProcessCapture( |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 67 | bool echo_path_gain_change, |
| 68 | bool capture_signal_saturation, |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 69 | std::vector<std::vector<float>>* capture_block) = 0; |
| 70 | |
peah | cf02cf1 | 2017-04-05 14:18:07 -0700 | [diff] [blame] | 71 | // 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; |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 74 | |
| 75 | // Reports whether echo leakage has been detected in the echo canceller |
| 76 | // output. |
peah | 69221db | 2017-01-27 03:28:19 -0800 | [diff] [blame] | 77 | virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0; |
peah | d026354 | 2017-01-03 04:20:34 -0800 | [diff] [blame] | 78 | }; |
| 79 | |
| 80 | } // namespace webrtc |
| 81 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 82 | #endif // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_ |