tor-browser

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

aec_dump.h (4620B)


      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_INCLUDE_AEC_DUMP_H_
     12 #define MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_
     13 
     14 #include <stdint.h>
     15 
     16 #include <optional>
     17 #include <string>
     18 
     19 #include "absl/base/attributes.h"
     20 #include "api/audio/audio_processing.h"
     21 #include "api/audio/audio_view.h"
     22 #include "modules/audio_processing/include/audio_frame_view.h"
     23 
     24 namespace webrtc {
     25 
     26 // Struct for passing current config from APM without having to
     27 // include protobuf headers.
     28 struct InternalAPMConfig {
     29  InternalAPMConfig();
     30  InternalAPMConfig(const InternalAPMConfig&);
     31  InternalAPMConfig(InternalAPMConfig&&);
     32 
     33  InternalAPMConfig& operator=(const InternalAPMConfig&);
     34  InternalAPMConfig& operator=(InternalAPMConfig&&) = delete;
     35 
     36  bool operator==(const InternalAPMConfig& other) const;
     37 
     38  bool aec_enabled = false;
     39  bool aec_delay_agnostic_enabled = false;
     40  bool aec_drift_compensation_enabled = false;
     41  bool aec_extended_filter_enabled = false;
     42  int aec_suppression_level = 0;
     43  bool aecm_enabled = false;
     44  bool aecm_comfort_noise_enabled = false;
     45  int aecm_routing_mode = 0;
     46  bool agc_enabled = false;
     47  int agc_mode = 0;
     48  bool agc_limiter_enabled = false;
     49  bool hpf_enabled = false;
     50  bool ns_enabled = false;
     51  int ns_level = 0;
     52  bool transient_suppression_enabled = false;
     53  bool noise_robust_agc_enabled = false;
     54  bool pre_amplifier_enabled = false;
     55  float pre_amplifier_fixed_gain_factor = 1.f;
     56  std::string experiments_description = "";
     57 };
     58 
     59 // An interface for recording configuration and input/output streams
     60 // of the Audio Processing Module. The recordings are called
     61 // 'aec-dumps' and are stored in a protobuf format defined in
     62 // debug.proto.
     63 // The Write* methods are always safe to call concurrently or
     64 // otherwise for all implementing subclasses. The intended mode of
     65 // operation is to create a protobuf object from the input, and send
     66 // it away to be written to file asynchronously.
     67 class AecDump {
     68 public:
     69  struct AudioProcessingState {
     70    int delay;
     71    int drift;
     72    std::optional<int> applied_input_volume;
     73    bool keypress;
     74  };
     75 
     76  virtual ~AecDump() = default;
     77 
     78  // Logs Event::Type INIT message.
     79  virtual void WriteInitMessage(const ProcessingConfig& api_format,
     80                                int64_t time_now_ms) = 0;
     81  ABSL_DEPRECATED("")
     82  void WriteInitMessage(const ProcessingConfig& api_format) {
     83    WriteInitMessage(api_format, 0);
     84  }
     85 
     86  // Logs Event::Type STREAM message. To log an input/output pair,
     87  // call the AddCapture* and AddAudioProcessingState methods followed
     88  // by a WriteCaptureStreamMessage call.
     89  virtual void AddCaptureStreamInput(
     90      const AudioFrameView<const float>& src) = 0;
     91  virtual void AddCaptureStreamInput(MonoView<const float> channel) = 0;
     92  virtual void AddCaptureStreamOutput(
     93      const AudioFrameView<const float>& src) = 0;
     94  virtual void AddCaptureStreamOutput(MonoView<const float> channel) = 0;
     95  virtual void AddCaptureStreamInput(const int16_t* const data,
     96                                     int num_channels,
     97                                     int samples_per_channel) = 0;
     98  virtual void AddCaptureStreamOutput(const int16_t* const data,
     99                                      int num_channels,
    100                                      int samples_per_channel) = 0;
    101  virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
    102  virtual void WriteCaptureStreamMessage() = 0;
    103 
    104  // Logs Event::Type REVERSE_STREAM message.
    105  virtual void WriteRenderStreamMessage(const int16_t* const data,
    106                                        int num_channels,
    107                                        int samples_per_channel) = 0;
    108  virtual void WriteRenderStreamMessage(
    109      const AudioFrameView<const float>& src) = 0;
    110  virtual void WriteRenderStreamMessage(const float* const* data,
    111                                        int num_channels,
    112                                        int samples_per_channel) = 0;
    113 
    114  virtual void WriteRuntimeSetting(
    115      const AudioProcessing::RuntimeSetting& runtime_setting) = 0;
    116 
    117  // Logs Event::Type CONFIG message.
    118  virtual void WriteConfig(const InternalAPMConfig& config) = 0;
    119 };
    120 }  // namespace webrtc
    121 
    122 #endif  // MODULES_AUDIO_PROCESSING_INCLUDE_AEC_DUMP_H_