tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

block_processor.h (3349B)


      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 <stddef.h>
     15 
     16 #include <memory>
     17 
     18 #include "api/audio/echo_canceller3_config.h"
     19 #include "api/audio/echo_control.h"
     20 #include "api/audio/neural_residual_echo_estimator.h"
     21 #include "api/environment/environment.h"
     22 #include "modules/audio_processing/aec3/block.h"
     23 #include "modules/audio_processing/aec3/echo_remover.h"
     24 #include "modules/audio_processing/aec3/render_delay_buffer.h"
     25 #include "modules/audio_processing/aec3/render_delay_controller.h"
     26 
     27 namespace webrtc {
     28 
     29 // Class for performing echo cancellation on 64 sample blocks of audio data.
     30 class BlockProcessor {
     31 public:
     32  static std::unique_ptr<BlockProcessor> Create(
     33      const Environment& env,
     34      const EchoCanceller3Config& config,
     35      int sample_rate_hz,
     36      size_t num_render_channels,
     37      size_t num_capture_channels,
     38      NeuralResidualEchoEstimator* neural_residual_echo_estimator);
     39  // Only used for testing purposes.
     40  static std::unique_ptr<BlockProcessor> Create(
     41      const Environment& env,
     42      const EchoCanceller3Config& config,
     43      int sample_rate_hz,
     44      size_t num_render_channels,
     45      size_t num_capture_channels,
     46      std::unique_ptr<RenderDelayBuffer> render_buffer,
     47      NeuralResidualEchoEstimator* neural_residual_echo_estimator);
     48  static std::unique_ptr<BlockProcessor> Create(
     49      const EchoCanceller3Config& config,
     50      int sample_rate_hz,
     51      size_t num_render_channels,
     52      size_t num_capture_channels,
     53      std::unique_ptr<RenderDelayBuffer> render_buffer,
     54      std::unique_ptr<RenderDelayController> delay_controller,
     55      std::unique_ptr<EchoRemover> echo_remover);
     56 
     57  virtual ~BlockProcessor() = default;
     58 
     59  // Get current metrics.
     60  virtual void GetMetrics(EchoControl::Metrics* metrics) const = 0;
     61 
     62  // Provides an optional external estimate of the audio buffer delay.
     63  virtual void SetAudioBufferDelay(int delay_ms) = 0;
     64 
     65  // Processes a block of capture data.
     66  virtual void ProcessCapture(bool echo_path_gain_change,
     67                              bool capture_signal_saturation,
     68                              Block* linear_output,
     69                              Block* capture_block) = 0;
     70 
     71  // Buffers a block of render data supplied by a FrameBlocker object.
     72  virtual void BufferRender(const Block& render_block) = 0;
     73 
     74  // Reports whether echo leakage has been detected in the echo canceller
     75  // output.
     76  virtual void UpdateEchoLeakageStatus(bool leakage_detected) = 0;
     77 
     78  // Specifies whether the capture output will be used. The purpose of this is
     79  // to allow the block processor to deactivate some of the processing when the
     80  // resulting output is anyway not used, for instance when the endpoint is
     81  // muted.
     82  virtual void SetCaptureOutputUsage(bool capture_output_used) = 0;
     83 };
     84 
     85 }  // namespace webrtc
     86 
     87 #endif  // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_H_