tor-browser

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

debug_dump_replayer.h (2286B)


      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_TEST_DEBUG_DUMP_REPLAYER_H_
     12 #define MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
     13 
     14 #include <cstdio>
     15 #include <memory>
     16 #include <optional>
     17 
     18 #include "absl/strings/string_view.h"
     19 #include "api/audio/audio_processing.h"
     20 #include "api/scoped_refptr.h"
     21 #include "common_audio/channel_buffer.h"
     22 
     23 // Generated at build-time by the protobuf compiler.
     24 #include "modules/audio_processing/debug.pb.h"
     25 
     26 namespace webrtc {
     27 namespace test {
     28 
     29 class DebugDumpReplayer {
     30 public:
     31  DebugDumpReplayer();
     32  ~DebugDumpReplayer();
     33 
     34  // Set dump file
     35  bool SetDumpFile(absl::string_view filename);
     36 
     37  // Return next event.
     38  std::optional<audioproc::Event> GetNextEvent() const;
     39 
     40  // Run the next event. Returns true if succeeded.
     41  bool RunNextEvent();
     42 
     43  const ChannelBuffer<float>* GetOutput() const;
     44  StreamConfig GetOutputConfig() const;
     45 
     46 private:
     47  // Following functions are facilities for replaying debug dumps.
     48  void OnInitEvent(const audioproc::Init& msg);
     49  void OnStreamEvent(const audioproc::Stream& msg);
     50  void OnReverseStreamEvent(const audioproc::ReverseStream& msg);
     51  void OnConfigEvent(const audioproc::Config& msg);
     52  void OnRuntimeSettingEvent(const audioproc::RuntimeSetting& msg);
     53 
     54  void MaybeRecreateApm(const audioproc::Config& msg);
     55  void ConfigureApm(const audioproc::Config& msg);
     56 
     57  void LoadNextMessage();
     58 
     59  // Buffer for APM input/output.
     60  std::unique_ptr<ChannelBuffer<float>> input_;
     61  std::unique_ptr<ChannelBuffer<float>> reverse_;
     62  std::unique_ptr<ChannelBuffer<float>> output_;
     63 
     64  scoped_refptr<AudioProcessing> apm_;
     65 
     66  FILE* debug_file_;
     67 
     68  StreamConfig input_config_;
     69  StreamConfig reverse_config_;
     70  StreamConfig output_config_;
     71 
     72  bool has_next_event_;
     73  audioproc::Event next_event_;
     74 };
     75 
     76 }  // namespace test
     77 }  // namespace webrtc
     78 
     79 #endif  // MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_