debug_dump_replayer.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. #ifndef MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
  11. #define MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
  12. #include <memory>
  13. #include <string>
  14. #include "common_audio/channel_buffer.h"
  15. #include "modules/audio_processing/include/audio_processing.h"
  16. #include "rtc_base/ignore_wundef.h"
  17. RTC_PUSH_IGNORING_WUNDEF()
  18. #include "modules/audio_processing/debug.pb.h"
  19. RTC_POP_IGNORING_WUNDEF()
  20. namespace webrtc {
  21. namespace test {
  22. class DebugDumpReplayer {
  23. public:
  24. DebugDumpReplayer();
  25. ~DebugDumpReplayer();
  26. // Set dump file
  27. bool SetDumpFile(const std::string& filename);
  28. // Return next event.
  29. absl::optional<audioproc::Event> GetNextEvent() const;
  30. // Run the next event. Returns true if succeeded.
  31. bool RunNextEvent();
  32. const ChannelBuffer<float>* GetOutput() const;
  33. StreamConfig GetOutputConfig() const;
  34. private:
  35. // Following functions are facilities for replaying debug dumps.
  36. void OnInitEvent(const audioproc::Init& msg);
  37. void OnStreamEvent(const audioproc::Stream& msg);
  38. void OnReverseStreamEvent(const audioproc::ReverseStream& msg);
  39. void OnConfigEvent(const audioproc::Config& msg);
  40. void OnRuntimeSettingEvent(const audioproc::RuntimeSetting& msg);
  41. void MaybeRecreateApm(const audioproc::Config& msg);
  42. void ConfigureApm(const audioproc::Config& msg);
  43. void LoadNextMessage();
  44. // Buffer for APM input/output.
  45. std::unique_ptr<ChannelBuffer<float>> input_;
  46. std::unique_ptr<ChannelBuffer<float>> reverse_;
  47. std::unique_ptr<ChannelBuffer<float>> output_;
  48. std::unique_ptr<AudioProcessing> apm_;
  49. FILE* debug_file_;
  50. StreamConfig input_config_;
  51. StreamConfig reverse_config_;
  52. StreamConfig output_config_;
  53. bool has_next_event_;
  54. audioproc::Event next_event_;
  55. };
  56. } // namespace test
  57. } // namespace webrtc
  58. #endif // MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_