blob: 4139149024b5cebe2d3af1b2e1992dc1514bffca [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);
Alex Loiko62347222018-09-10 10:18:07 +020051 void OnRuntimeSettingEvent(const audioproc::RuntimeSetting& msg);
minyue0de1c132016-03-17 02:39:30 -070052
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 Bonadei92ea95e2017-09-15 06:47:31 +020078#endif // MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_