blob: aa5d72735a3ab22c81f9e1b40fe9d4424575a123 [file] [log] [blame]
minyue0de1c132016-03-17 02:39:30 -07001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
12#define MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
minyue0de1c132016-03-17 02:39:30 -070013
14#include <memory>
15#include <string>
16
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020017#include "common_audio/channel_buffer.h"
18#include "modules/audio_processing/include/audio_processing.h"
19#include "rtc_base/ignore_wundef.h"
minyue0de1c132016-03-17 02:39:30 -070020
kwiberg77eab702016-09-28 17:42:01 -070021RTC_PUSH_IGNORING_WUNDEF()
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020022#include "modules/audio_processing/debug.pb.h"
kwiberg77eab702016-09-28 17:42:01 -070023RTC_POP_IGNORING_WUNDEF()
24
minyue0de1c132016-03-17 02:39:30 -070025namespace webrtc {
26namespace test {
27
28class 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 Chapovalovdb9f7ab2018-06-19 10:50:11 +020037 absl::optional<audioproc::Event> GetNextEvent() const;
minyue0de1c132016-03-17 02:39:30 -070038
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);
51
52 void MaybeRecreateApm(const audioproc::Config& msg);
53 void ConfigureApm(const audioproc::Config& msg);
54
55 void LoadNextMessage();
56
57 // Buffer for APM input/output.
58 std::unique_ptr<ChannelBuffer<float>> input_;
59 std::unique_ptr<ChannelBuffer<float>> reverse_;
60 std::unique_ptr<ChannelBuffer<float>> output_;
61
62 std::unique_ptr<AudioProcessing> apm_;
63
64 FILE* debug_file_;
65
66 StreamConfig input_config_;
67 StreamConfig reverse_config_;
68 StreamConfig output_config_;
69
70 bool has_next_event_;
71 audioproc::Event next_event_;
72};
73
74} // namespace test
75} // namespace webrtc
76
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020077#endif // MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_