tor-browser

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

render_delay_buffer.h (2914B)


      1 /*
      2 *  Copyright (c) 2017 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_RENDER_DELAY_BUFFER_H_
     12 #define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_
     13 
     14 #include <stddef.h>
     15 
     16 
     17 #include "api/audio/echo_canceller3_config.h"
     18 #include "modules/audio_processing/aec3/block.h"
     19 #include "modules/audio_processing/aec3/downsampled_render_buffer.h"
     20 #include "modules/audio_processing/aec3/render_buffer.h"
     21 
     22 namespace webrtc {
     23 
     24 // Class for buffering the incoming render blocks such that these may be
     25 // extracted with a specified delay.
     26 class RenderDelayBuffer {
     27 public:
     28  enum class BufferingEvent {
     29    kNone,
     30    kRenderUnderrun,
     31    kRenderOverrun,
     32    kApiCallSkew
     33  };
     34 
     35  static RenderDelayBuffer* Create(const EchoCanceller3Config& config,
     36                                   int sample_rate_hz,
     37                                   size_t num_render_channels);
     38  virtual ~RenderDelayBuffer() = default;
     39 
     40  // Resets the buffer alignment.
     41  virtual void Reset() = 0;
     42 
     43  // Inserts a block into the buffer.
     44  virtual BufferingEvent Insert(const Block& block) = 0;
     45 
     46  // Updates the buffers one step based on the specified buffer delay. Returns
     47  // an enum indicating whether there was a special event that occurred.
     48  virtual BufferingEvent PrepareCaptureProcessing() = 0;
     49 
     50  // Called on capture blocks where PrepareCaptureProcessing is not called.
     51  virtual void HandleSkippedCaptureProcessing() = 0;
     52 
     53  // Sets the buffer delay and returns a bool indicating whether the delay
     54  // changed.
     55  virtual bool AlignFromDelay(size_t delay) = 0;
     56 
     57  // Sets the buffer delay from the most recently reported external delay.
     58  virtual void AlignFromExternalDelay() = 0;
     59 
     60  // Gets the buffer delay.
     61  virtual size_t Delay() const = 0;
     62 
     63  // Gets the buffer delay.
     64  virtual size_t MaxDelay() const = 0;
     65 
     66  // Returns the render buffer for the echo remover.
     67  virtual RenderBuffer* GetRenderBuffer() = 0;
     68 
     69  // Returns the downsampled render buffer.
     70  virtual const DownsampledRenderBuffer& GetDownsampledRenderBuffer() const = 0;
     71 
     72  // Returns the maximum non calusal offset that can occur in the delay buffer.
     73  static int DelayEstimatorOffset(const EchoCanceller3Config& config);
     74 
     75  // Provides an optional external estimate of the audio buffer delay.
     76  virtual void SetAudioBufferDelay(int delay_ms) = 0;
     77 
     78  // Returns whether an external delay estimate has been reported via
     79  // SetAudioBufferDelay.
     80  virtual bool HasReceivedBufferDelay() = 0;
     81 };
     82 
     83 }  // namespace webrtc
     84 
     85 #endif  // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_BUFFER_H_