minyue | 0de1c13 | 2016-03-17 02:39:30 -0700 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_ |
minyue | 0de1c13 | 2016-03-17 02:39:30 -0700 | [diff] [blame] | 13 | |
| 14 | #include <memory> |
| 15 | #include <string> |
| 16 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 17 | #include "common_audio/channel_buffer.h" |
| 18 | #include "modules/audio_processing/include/audio_processing.h" |
| 19 | #include "rtc_base/ignore_wundef.h" |
minyue | 0de1c13 | 2016-03-17 02:39:30 -0700 | [diff] [blame] | 20 | |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 21 | RTC_PUSH_IGNORING_WUNDEF() |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 22 | #include "modules/audio_processing/debug.pb.h" |
kwiberg | 77eab70 | 2016-09-28 17:42:01 -0700 | [diff] [blame] | 23 | RTC_POP_IGNORING_WUNDEF() |
| 24 | |
minyue | 0de1c13 | 2016-03-17 02:39:30 -0700 | [diff] [blame] | 25 | namespace webrtc { |
| 26 | namespace test { |
| 27 | |
| 28 | class DebugDumpReplayer { |
| 29 | public: |
| 30 | DebugDumpReplayer(); |
| 31 | ~DebugDumpReplayer(); |
| 32 | |
| 33 | // Set dump file |
| 34 | bool SetDumpFile(const std::string& filename); |
| 35 | |
| 36 | // Return next event. |
Danil Chapovalov | db9f7ab | 2018-06-19 10:50:11 +0200 | [diff] [blame] | 37 | absl::optional<audioproc::Event> GetNextEvent() const; |
minyue | 0de1c13 | 2016-03-17 02:39:30 -0700 | [diff] [blame] | 38 | |
| 39 | // Run the next event. Returns true if succeeded. |
| 40 | bool RunNextEvent(); |
| 41 | |
| 42 | const ChannelBuffer<float>* GetOutput() const; |
| 43 | StreamConfig GetOutputConfig() const; |
| 44 | |
| 45 | private: |
| 46 | // Following functions are facilities for replaying debug dumps. |
| 47 | void OnInitEvent(const audioproc::Init& msg); |
| 48 | void OnStreamEvent(const audioproc::Stream& msg); |
| 49 | void OnReverseStreamEvent(const audioproc::ReverseStream& msg); |
| 50 | void OnConfigEvent(const audioproc::Config& msg); |
Alex Loiko | 6234722 | 2018-09-10 10:18:07 +0200 | [diff] [blame^] | 51 | void OnRuntimeSettingEvent(const audioproc::RuntimeSetting& msg); |
minyue | 0de1c13 | 2016-03-17 02:39:30 -0700 | [diff] [blame] | 52 | |
| 53 | void MaybeRecreateApm(const audioproc::Config& msg); |
| 54 | void ConfigureApm(const audioproc::Config& msg); |
| 55 | |
| 56 | void LoadNextMessage(); |
| 57 | |
| 58 | // Buffer for APM input/output. |
| 59 | std::unique_ptr<ChannelBuffer<float>> input_; |
| 60 | std::unique_ptr<ChannelBuffer<float>> reverse_; |
| 61 | std::unique_ptr<ChannelBuffer<float>> output_; |
| 62 | |
| 63 | std::unique_ptr<AudioProcessing> apm_; |
| 64 | |
| 65 | FILE* debug_file_; |
| 66 | |
| 67 | StreamConfig input_config_; |
| 68 | StreamConfig reverse_config_; |
| 69 | StreamConfig output_config_; |
| 70 | |
| 71 | bool has_next_event_; |
| 72 | audioproc::Event next_event_; |
| 73 | }; |
| 74 | |
| 75 | } // namespace test |
| 76 | } // namespace webrtc |
| 77 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 78 | #endif // MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_ |