blob: 2b474bfa01bdbb17ed20c89f57babc8f43edbabe [file] [log] [blame]
andrew@webrtc.orgcb181212011-10-26 00:27:17 +00001/*
2 * Copyright (c) 2011 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// Commandline tool to unpack audioproc debug files.
12//
13// The debug files are dumped as protobuf blobs. For analysis, it's necessary
14// to unpack the file into its component parts: audio and other data.
15
16#include <stdio.h>
17
kwiberg62eaacf2016-02-17 06:39:05 -080018#include <memory>
19
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/audio_processing/test/protobuf_utils.h"
21#include "modules/audio_processing/test/test_utils.h"
22#include "rtc_base/flags.h"
23#include "rtc_base/format_macros.h"
24#include "rtc_base/ignore_wundef.h"
Mirko Bonadei71207422017-09-15 13:58:09 +020025#include "typedefs.h" // NOLINT(build/include)
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000026
kwiberg77eab702016-09-28 17:42:01 -070027RTC_PUSH_IGNORING_WUNDEF()
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020028#include "modules/audio_processing/debug.pb.h"
kwiberg77eab702016-09-28 17:42:01 -070029RTC_POP_IGNORING_WUNDEF()
30
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000031// TODO(andrew): unpack more of the data.
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +000032DEFINE_string(input_file, "input", "The name of the input stream file.");
33DEFINE_string(output_file, "ref_out",
andrew@webrtc.orgcd824382011-11-11 19:13:36 +000034 "The name of the reference output stream file.");
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +000035DEFINE_string(reverse_file, "reverse",
andrew@webrtc.orgcd824382011-11-11 19:13:36 +000036 "The name of the reverse input stream file.");
37DEFINE_string(delay_file, "delay.int32", "The name of the delay file.");
38DEFINE_string(drift_file, "drift.int32", "The name of the drift file.");
39DEFINE_string(level_file, "level.int32", "The name of the level file.");
andrew@webrtc.orgce8e0772014-02-12 15:28:30 +000040DEFINE_string(keypress_file, "keypress.bool", "The name of the keypress file.");
Sam Zackrissonf61475d2018-05-11 11:34:49 +020041DEFINE_string(callorder_file,
42 "callorder",
43 "The name of the render/capture call order file.");
andrew@webrtc.orgcd824382011-11-11 19:13:36 +000044DEFINE_string(settings_file, "settings.txt", "The name of the settings file.");
45DEFINE_bool(full, false,
46 "Unpack the full set of files (normally not needed).");
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +000047DEFINE_bool(raw, false, "Write raw data instead of a WAV file.");
Bjorn Volcker40a6d592015-05-06 10:51:34 +020048DEFINE_bool(text,
49 false,
50 "Write non-audio files as text files instead of binary files.");
oprypin6e09d872017-08-31 03:21:39 -070051DEFINE_bool(help, false, "Print this message.");
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000052
Minyue13b96ba2015-10-03 00:39:14 +020053#define PRINT_CONFIG(field_name) \
54 if (msg.has_##field_name()) { \
55 fprintf(settings_file, " " #field_name ": %d\n", msg.field_name()); \
56 }
57
Alex Loiko5feb30e2018-04-16 13:52:32 +020058#define PRINT_CONFIG_FLOAT(field_name) \
59 if (msg.has_##field_name()) { \
60 fprintf(settings_file, " " #field_name ": %f\n", msg.field_name()); \
61 }
62
andrew@webrtc.orga8b97372014-03-10 22:26:12 +000063namespace webrtc {
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000064
andrew@webrtc.orga8b97372014-03-10 22:26:12 +000065using audioproc::Event;
66using audioproc::ReverseStream;
67using audioproc::Stream;
68using audioproc::Init;
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000069
Sam Zackrissonf61475d2018-05-11 11:34:49 +020070namespace {
71
andrew@webrtc.orga8b97372014-03-10 22:26:12 +000072void WriteData(const void* data, size_t size, FILE* file,
73 const std::string& filename) {
74 if (fwrite(data, size, 1, file) != 1) {
75 printf("Error when writing to %s\n", filename.c_str());
76 exit(1);
77 }
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000078}
79
Sam Zackrissonf61475d2018-05-11 11:34:49 +020080void WriteCallOrderData(const bool render_call,
81 FILE* file,
82 const std::string& filename) {
83 const char call_type = render_call ? 'r' : 'c';
84 WriteData(&call_type, sizeof(call_type), file, filename.c_str());
85}
86
87} // namespace
88
andrew@webrtc.orga8b97372014-03-10 22:26:12 +000089int do_main(int argc, char* argv[]) {
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000090 std::string program_name = argv[0];
91 std::string usage = "Commandline tool to unpack audioproc debug files.\n"
92 "Example usage:\n" + program_name + " debug_dump.pb\n";
andrew@webrtc.orgcb181212011-10-26 00:27:17 +000093
oprypin6e09d872017-08-31 03:21:39 -070094 if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) ||
95 FLAG_help || argc < 2) {
96 printf("%s", usage.c_str());
97 if (FLAG_help) {
98 rtc::FlagList::Print(nullptr, false);
99 return 0;
100 }
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000101 return 1;
102 }
103
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000104 FILE* debug_file = OpenFile(argv[1], "rb");
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000105
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000106 Event event_msg;
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000107 int frame_count = 0;
pkasting25702cb2016-01-08 13:50:27 -0800108 size_t reverse_samples_per_channel = 0;
109 size_t input_samples_per_channel = 0;
110 size_t output_samples_per_channel = 0;
Peter Kasting69558702016-01-12 16:26:35 -0800111 size_t num_reverse_channels = 0;
112 size_t num_input_channels = 0;
113 size_t num_output_channels = 0;
kwiberg62eaacf2016-02-17 06:39:05 -0800114 std::unique_ptr<WavWriter> reverse_wav_file;
115 std::unique_ptr<WavWriter> input_wav_file;
116 std::unique_ptr<WavWriter> output_wav_file;
117 std::unique_ptr<RawFile> reverse_raw_file;
118 std::unique_ptr<RawFile> input_raw_file;
119 std::unique_ptr<RawFile> output_raw_file;
Minyue13b96ba2015-10-03 00:39:14 +0200120
Sam Zackrissonf61475d2018-05-11 11:34:49 +0200121 std::stringstream callorder_raw_name;
122 callorder_raw_name << FLAG_callorder_file << ".char";
123 FILE* callorder_char_file = OpenFile(callorder_raw_name.str(), "wb");
oprypin6e09d872017-08-31 03:21:39 -0700124 FILE* settings_file = OpenFile(FLAG_settings_file, "wb");
Minyue13b96ba2015-10-03 00:39:14 +0200125
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000126 while (ReadMessageFromFile(debug_file, &event_msg)) {
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000127 if (event_msg.type() == Event::REVERSE_STREAM) {
128 if (!event_msg.has_reverse_stream()) {
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000129 printf("Corrupt input file: ReverseStream missing.\n");
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000130 return 1;
131 }
132
133 const ReverseStream msg = event_msg.reverse_stream();
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000134 if (msg.has_data()) {
oprypin6e09d872017-08-31 03:21:39 -0700135 if (FLAG_raw && !reverse_raw_file) {
136 reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) +
137 ".pcm"));
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000138 }
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000139 // TODO(aluebs): Replace "num_reverse_channels *
140 // reverse_samples_per_channel" with "msg.data().size() /
141 // sizeof(int16_t)" and so on when this fix in audio_processing has made
142 // it into stable: https://webrtc-codereview.appspot.com/15299004/
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000143 WriteIntData(reinterpret_cast<const int16_t*>(msg.data().data()),
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000144 num_reverse_channels * reverse_samples_per_channel,
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000145 reverse_wav_file.get(),
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000146 reverse_raw_file.get());
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000147 } else if (msg.channel_size() > 0) {
oprypin6e09d872017-08-31 03:21:39 -0700148 if (FLAG_raw && !reverse_raw_file) {
149 reverse_raw_file.reset(new RawFile(std::string(FLAG_reverse_file) +
150 ".float"));
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000151 }
kwiberg62eaacf2016-02-17 06:39:05 -0800152 std::unique_ptr<const float* []> data(
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000153 new const float* [num_reverse_channels]);
Peter Kasting69558702016-01-12 16:26:35 -0800154 for (size_t i = 0; i < num_reverse_channels; ++i) {
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000155 data[i] = reinterpret_cast<const float*>(msg.channel(i).data());
156 }
157 WriteFloatData(data.get(),
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000158 reverse_samples_per_channel,
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000159 num_reverse_channels,
160 reverse_wav_file.get(),
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000161 reverse_raw_file.get());
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000162 }
Sam Zackrissonf61475d2018-05-11 11:34:49 +0200163 if (FLAG_full) {
164 WriteCallOrderData(true /* render_call */, callorder_char_file,
165 FLAG_callorder_file);
166 }
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000167 } else if (event_msg.type() == Event::STREAM) {
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000168 frame_count++;
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000169 if (!event_msg.has_stream()) {
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000170 printf("Corrupt input file: Stream missing.\n");
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000171 return 1;
172 }
173
174 const Stream msg = event_msg.stream();
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000175 if (msg.has_input_data()) {
oprypin6e09d872017-08-31 03:21:39 -0700176 if (FLAG_raw && !input_raw_file) {
177 input_raw_file.reset(new RawFile(std::string(FLAG_input_file) +
178 ".pcm"));
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000179 }
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000180 WriteIntData(reinterpret_cast<const int16_t*>(msg.input_data().data()),
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000181 num_input_channels * input_samples_per_channel,
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000182 input_wav_file.get(),
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000183 input_raw_file.get());
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000184 } else if (msg.input_channel_size() > 0) {
oprypin6e09d872017-08-31 03:21:39 -0700185 if (FLAG_raw && !input_raw_file) {
186 input_raw_file.reset(new RawFile(std::string(FLAG_input_file) +
187 ".float"));
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000188 }
kwiberg62eaacf2016-02-17 06:39:05 -0800189 std::unique_ptr<const float* []> data(
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000190 new const float* [num_input_channels]);
Peter Kasting69558702016-01-12 16:26:35 -0800191 for (size_t i = 0; i < num_input_channels; ++i) {
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000192 data[i] = reinterpret_cast<const float*>(msg.input_channel(i).data());
193 }
194 WriteFloatData(data.get(),
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000195 input_samples_per_channel,
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000196 num_input_channels,
197 input_wav_file.get(),
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000198 input_raw_file.get());
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000199 }
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000200
201 if (msg.has_output_data()) {
oprypin6e09d872017-08-31 03:21:39 -0700202 if (FLAG_raw && !output_raw_file) {
203 output_raw_file.reset(new RawFile(std::string(FLAG_output_file) +
204 ".pcm"));
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000205 }
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000206 WriteIntData(reinterpret_cast<const int16_t*>(msg.output_data().data()),
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000207 num_output_channels * output_samples_per_channel,
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000208 output_wav_file.get(),
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000209 output_raw_file.get());
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000210 } else if (msg.output_channel_size() > 0) {
oprypin6e09d872017-08-31 03:21:39 -0700211 if (FLAG_raw && !output_raw_file) {
212 output_raw_file.reset(new RawFile(std::string(FLAG_output_file) +
213 ".float"));
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000214 }
kwiberg62eaacf2016-02-17 06:39:05 -0800215 std::unique_ptr<const float* []> data(
kwiberg@webrtc.org00b8f6b2015-02-26 14:34:55 +0000216 new const float* [num_output_channels]);
Peter Kasting69558702016-01-12 16:26:35 -0800217 for (size_t i = 0; i < num_output_channels; ++i) {
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000218 data[i] =
219 reinterpret_cast<const float*>(msg.output_channel(i).data());
220 }
221 WriteFloatData(data.get(),
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000222 output_samples_per_channel,
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000223 num_output_channels,
224 output_wav_file.get(),
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000225 output_raw_file.get());
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000226 }
227
oprypin6e09d872017-08-31 03:21:39 -0700228 if (FLAG_full) {
Sam Zackrissonf61475d2018-05-11 11:34:49 +0200229 WriteCallOrderData(false /* render_call */, callorder_char_file,
230 FLAG_callorder_file);
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000231 if (msg.has_delay()) {
oprypin6e09d872017-08-31 03:21:39 -0700232 static FILE* delay_file = OpenFile(FLAG_delay_file, "wb");
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000233 int32_t delay = msg.delay();
oprypin6e09d872017-08-31 03:21:39 -0700234 if (FLAG_text) {
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200235 fprintf(delay_file, "%d\n", delay);
236 } else {
oprypin6e09d872017-08-31 03:21:39 -0700237 WriteData(&delay, sizeof(delay), delay_file, FLAG_delay_file);
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200238 }
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000239 }
240
241 if (msg.has_drift()) {
oprypin6e09d872017-08-31 03:21:39 -0700242 static FILE* drift_file = OpenFile(FLAG_drift_file, "wb");
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000243 int32_t drift = msg.drift();
oprypin6e09d872017-08-31 03:21:39 -0700244 if (FLAG_text) {
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200245 fprintf(drift_file, "%d\n", drift);
246 } else {
oprypin6e09d872017-08-31 03:21:39 -0700247 WriteData(&drift, sizeof(drift), drift_file, FLAG_drift_file);
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200248 }
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000249 }
250
251 if (msg.has_level()) {
oprypin6e09d872017-08-31 03:21:39 -0700252 static FILE* level_file = OpenFile(FLAG_level_file, "wb");
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000253 int32_t level = msg.level();
oprypin6e09d872017-08-31 03:21:39 -0700254 if (FLAG_text) {
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200255 fprintf(level_file, "%d\n", level);
256 } else {
oprypin6e09d872017-08-31 03:21:39 -0700257 WriteData(&level, sizeof(level), level_file, FLAG_level_file);
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200258 }
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000259 }
andrew@webrtc.orgce8e0772014-02-12 15:28:30 +0000260
261 if (msg.has_keypress()) {
oprypin6e09d872017-08-31 03:21:39 -0700262 static FILE* keypress_file = OpenFile(FLAG_keypress_file, "wb");
andrew@webrtc.orgce8e0772014-02-12 15:28:30 +0000263 bool keypress = msg.keypress();
oprypin6e09d872017-08-31 03:21:39 -0700264 if (FLAG_text) {
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200265 fprintf(keypress_file, "%d\n", keypress);
266 } else {
267 WriteData(&keypress, sizeof(keypress), keypress_file,
oprypin6e09d872017-08-31 03:21:39 -0700268 FLAG_keypress_file);
Bjorn Volcker40a6d592015-05-06 10:51:34 +0200269 }
andrew@webrtc.orgce8e0772014-02-12 15:28:30 +0000270 }
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000271 }
Minyue13b96ba2015-10-03 00:39:14 +0200272 } else if (event_msg.type() == Event::CONFIG) {
273 if (!event_msg.has_config()) {
274 printf("Corrupt input file: Config missing.\n");
275 return 1;
276 }
277 const audioproc::Config msg = event_msg.config();
278
279 fprintf(settings_file, "APM re-config at frame: %d\n", frame_count);
280
281 PRINT_CONFIG(aec_enabled);
282 PRINT_CONFIG(aec_delay_agnostic_enabled);
283 PRINT_CONFIG(aec_drift_compensation_enabled);
284 PRINT_CONFIG(aec_extended_filter_enabled);
285 PRINT_CONFIG(aec_suppression_level);
286 PRINT_CONFIG(aecm_enabled);
287 PRINT_CONFIG(aecm_comfort_noise_enabled);
288 PRINT_CONFIG(aecm_routing_mode);
289 PRINT_CONFIG(agc_enabled);
290 PRINT_CONFIG(agc_mode);
291 PRINT_CONFIG(agc_limiter_enabled);
292 PRINT_CONFIG(noise_robust_agc_enabled);
293 PRINT_CONFIG(hpf_enabled);
294 PRINT_CONFIG(ns_enabled);
295 PRINT_CONFIG(ns_level);
296 PRINT_CONFIG(transient_suppression_enabled);
Alejandro Luebsc9b0c262016-05-16 15:32:38 -0700297 PRINT_CONFIG(intelligibility_enhancer_enabled);
Alex Loiko5feb30e2018-04-16 13:52:32 +0200298 PRINT_CONFIG(pre_amplifier_enabled);
299 PRINT_CONFIG_FLOAT(pre_amplifier_fixed_gain_factor);
300
peah7789fe72016-04-15 01:19:44 -0700301 if (msg.has_experiments_description()) {
302 fprintf(settings_file, " experiments_description: %s\n",
303 msg.experiments_description().c_str());
304 }
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000305 } else if (event_msg.type() == Event::INIT) {
306 if (!event_msg.has_init()) {
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000307 printf("Corrupt input file: Init missing.\n");
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000308 return 1;
309 }
310
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000311 const Init msg = event_msg.init();
312 // These should print out zeros if they're missing.
313 fprintf(settings_file, "Init at frame: %d\n", frame_count);
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000314 int input_sample_rate = msg.sample_rate();
315 fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate);
316 int output_sample_rate = msg.output_sample_rate();
317 fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate);
318 int reverse_sample_rate = msg.reverse_sample_rate();
319 fprintf(settings_file,
320 " Reverse sample rate: %d\n",
321 reverse_sample_rate);
322 num_input_channels = msg.num_input_channels();
Peter Kasting69558702016-01-12 16:26:35 -0800323 fprintf(settings_file, " Input channels: %" PRIuS "\n",
324 num_input_channels);
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000325 num_output_channels = msg.num_output_channels();
Peter Kasting69558702016-01-12 16:26:35 -0800326 fprintf(settings_file, " Output channels: %" PRIuS "\n",
327 num_output_channels);
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000328 num_reverse_channels = msg.num_reverse_channels();
Peter Kasting69558702016-01-12 16:26:35 -0800329 fprintf(settings_file, " Reverse channels: %" PRIuS "\n",
330 num_reverse_channels);
andrew@webrtc.orgcd824382011-11-11 19:13:36 +0000331
332 fprintf(settings_file, "\n");
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000333
334 if (reverse_sample_rate == 0) {
335 reverse_sample_rate = input_sample_rate;
336 }
337 if (output_sample_rate == 0) {
338 output_sample_rate = input_sample_rate;
339 }
340
pkasting25702cb2016-01-08 13:50:27 -0800341 reverse_samples_per_channel =
342 static_cast<size_t>(reverse_sample_rate / 100);
343 input_samples_per_channel =
344 static_cast<size_t>(input_sample_rate / 100);
345 output_samples_per_channel =
346 static_cast<size_t>(output_sample_rate / 100);
aluebs@webrtc.orgbac07262014-09-03 13:39:01 +0000347
oprypin6e09d872017-08-31 03:21:39 -0700348 if (!FLAG_raw) {
aluebs@webrtc.org021e76f2014-09-04 18:12:00 +0000349 // The WAV files need to be reset every time, because they cant change
350 // their sample rate or number of channels.
aluebsf03a8d42016-06-17 09:41:41 -0700351 std::stringstream reverse_name;
oprypin6e09d872017-08-31 03:21:39 -0700352 reverse_name << FLAG_reverse_file << frame_count << ".wav";
aluebsf03a8d42016-06-17 09:41:41 -0700353 reverse_wav_file.reset(new WavWriter(reverse_name.str(),
andrew@webrtc.orga3ed7132014-10-31 21:51:03 +0000354 reverse_sample_rate,
355 num_reverse_channels));
aluebsf03a8d42016-06-17 09:41:41 -0700356 std::stringstream input_name;
oprypin6e09d872017-08-31 03:21:39 -0700357 input_name << FLAG_input_file << frame_count << ".wav";
aluebsf03a8d42016-06-17 09:41:41 -0700358 input_wav_file.reset(new WavWriter(input_name.str(),
andrew@webrtc.orga3ed7132014-10-31 21:51:03 +0000359 input_sample_rate,
360 num_input_channels));
aluebsf03a8d42016-06-17 09:41:41 -0700361 std::stringstream output_name;
oprypin6e09d872017-08-31 03:21:39 -0700362 output_name << FLAG_output_file << frame_count << ".wav";
aluebsf03a8d42016-06-17 09:41:41 -0700363 output_wav_file.reset(new WavWriter(output_name.str(),
andrew@webrtc.orga3ed7132014-10-31 21:51:03 +0000364 output_sample_rate,
365 num_output_channels));
Sam Zackrissonf61475d2018-05-11 11:34:49 +0200366
367 std::stringstream callorder_name;
368 callorder_name << FLAG_callorder_file << frame_count << ".char";
369 callorder_char_file = OpenFile(callorder_name.str(), "wb");
aluebs@webrtc.org841f58f2014-09-02 07:51:51 +0000370 }
andrew@webrtc.orgcb181212011-10-26 00:27:17 +0000371 }
372 }
373
374 return 0;
375}
andrew@webrtc.orga8b97372014-03-10 22:26:12 +0000376
377} // namespace webrtc
378
379int main(int argc, char* argv[]) {
380 return webrtc::do_main(argc, argv);
381}