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 
11 #ifndef MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_
12 #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_
13 
14 #include <memory>
15 #include <vector>
16 
17 #include "modules/audio_processing/aec3/echo_remover.h"
18 #include "modules/audio_processing/aec3/render_delay_buffer.h"
19 #include "modules/audio_processing/aec3/render_delay_controller.h"
20 
21 namespace webrtc {
22 
23 // Class for performing echo cancellation on 64 sample blocks of audio data.
24 class BlockProcessor {
25  public:
26   static BlockProcessor* Create(const EchoCanceller3Config& config,
27                                 int sample_rate_hz);
28   // Only used for testing purposes.
29   static BlockProcessor* Create(
30       const EchoCanceller3Config& config,
31       int sample_rate_hz,
32       std::unique_ptr<RenderDelayBuffer> render_buffer);
33   static BlockProcessor* Create(
34       const EchoCanceller3Config& config,
35       int sample_rate_hz,
36       std::unique_ptr<RenderDelayBuffer> render_buffer,
37       std::unique_ptr<RenderDelayController> delay_controller,
38       std::unique_ptr<EchoRemover> echo_remover);
39 
40   virtual ~BlockProcessor() = default;
41 
42   // Get current metrics.
43   virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0;
44 
45   // Processes a block of capture data.
46   virtual void ProcessCapture(
47       bool echo_path_gain_change,
48       bool capture_signal_saturation,
49       std::vector<std::vector<float>>* capture_block) = 0;
50 
51   // Buffers a block of render data supplied by a FrameBlocker object.
52   virtual void BufferRender(
53       const std::vector<std::vector<float>>& render_block) = 0;
54 
55   // Reports whether echo leakage has been detected in the echo canceller
56   // output.
57   virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0;
58 };
59 
60 }  // namespace webrtc
61 
62 #endif  // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_
63