blob: 9ee4a6349e389b561c56d86ad07e46b4068afcb1 [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
11#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_
13
14#include <memory>
15#include <string>
16
17#include "webrtc/common_audio/channel_buffer.h"
minyue0de1c132016-03-17 02:39:30 -070018#include "webrtc/modules/audio_processing/include/audio_processing.h"
Edward Lemurc20978e2017-07-06 19:44:34 +020019#include "webrtc/rtc_base/ignore_wundef.h"
minyue0de1c132016-03-17 02:39:30 -070020
kwiberg77eab702016-09-28 17:42:01 -070021RTC_PUSH_IGNORING_WUNDEF()
22#include "webrtc/modules/audio_processing/debug.pb.h"
23RTC_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.
37 rtc::Optional<audioproc::Event> GetNextEvent() const;
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);
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
77#endif // WEBRTC_MODULES_AUDIO_PROCESSING_TEST_DEBUG_DUMP_REPLAYER_H_