OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... | |
33 DEFINE_string(level_file, "level.int32", "The name of the level file."); | 33 DEFINE_string(level_file, "level.int32", "The name of the level file."); |
34 DEFINE_string(keypress_file, "keypress.bool", "The name of the keypress file."); | 34 DEFINE_string(keypress_file, "keypress.bool", "The name of the keypress file."); |
35 DEFINE_string(settings_file, "settings.txt", "The name of the settings file."); | 35 DEFINE_string(settings_file, "settings.txt", "The name of the settings file."); |
36 DEFINE_bool(full, false, | 36 DEFINE_bool(full, false, |
37 "Unpack the full set of files (normally not needed)."); | 37 "Unpack the full set of files (normally not needed)."); |
38 DEFINE_bool(raw, false, "Write raw data instead of a WAV file."); | 38 DEFINE_bool(raw, false, "Write raw data instead of a WAV file."); |
39 DEFINE_bool(text, | 39 DEFINE_bool(text, |
40 false, | 40 false, |
41 "Write non-audio files as text files instead of binary files."); | 41 "Write non-audio files as text files instead of binary files."); |
42 | 42 |
43 #define PRINT_CONFIG(field_name, descriptor) \ | |
44 if (msg.has_##field_name()) { \ | |
45 fprintf(settings_file, " " descriptor ": %d\n", msg.field_name()); \ | |
46 } | |
47 | |
43 namespace webrtc { | 48 namespace webrtc { |
44 | 49 |
45 using audioproc::Event; | 50 using audioproc::Event; |
46 using audioproc::ReverseStream; | 51 using audioproc::ReverseStream; |
47 using audioproc::Stream; | 52 using audioproc::Stream; |
48 using audioproc::Init; | 53 using audioproc::Init; |
49 | 54 |
50 void WriteData(const void* data, size_t size, FILE* file, | 55 void WriteData(const void* data, size_t size, FILE* file, |
51 const std::string& filename) { | 56 const std::string& filename) { |
52 if (fwrite(data, size, 1, file) != 1) { | 57 if (fwrite(data, size, 1, file) != 1) { |
(...skipping 23 matching lines...) Expand all Loading... | |
76 int output_samples_per_channel = 0; | 81 int output_samples_per_channel = 0; |
77 int num_reverse_channels = 0; | 82 int num_reverse_channels = 0; |
78 int num_input_channels = 0; | 83 int num_input_channels = 0; |
79 int num_output_channels = 0; | 84 int num_output_channels = 0; |
80 rtc::scoped_ptr<WavWriter> reverse_wav_file; | 85 rtc::scoped_ptr<WavWriter> reverse_wav_file; |
81 rtc::scoped_ptr<WavWriter> input_wav_file; | 86 rtc::scoped_ptr<WavWriter> input_wav_file; |
82 rtc::scoped_ptr<WavWriter> output_wav_file; | 87 rtc::scoped_ptr<WavWriter> output_wav_file; |
83 rtc::scoped_ptr<RawFile> reverse_raw_file; | 88 rtc::scoped_ptr<RawFile> reverse_raw_file; |
84 rtc::scoped_ptr<RawFile> input_raw_file; | 89 rtc::scoped_ptr<RawFile> input_raw_file; |
85 rtc::scoped_ptr<RawFile> output_raw_file; | 90 rtc::scoped_ptr<RawFile> output_raw_file; |
91 | |
92 FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); | |
93 | |
86 while (ReadMessageFromFile(debug_file, &event_msg)) { | 94 while (ReadMessageFromFile(debug_file, &event_msg)) { |
87 if (event_msg.type() == Event::REVERSE_STREAM) { | 95 if (event_msg.type() == Event::REVERSE_STREAM) { |
88 if (!event_msg.has_reverse_stream()) { | 96 if (!event_msg.has_reverse_stream()) { |
89 printf("Corrupt input file: ReverseStream missing.\n"); | 97 printf("Corrupt input file: ReverseStream missing.\n"); |
90 return 1; | 98 return 1; |
91 } | 99 } |
92 | 100 |
93 const ReverseStream msg = event_msg.reverse_stream(); | 101 const ReverseStream msg = event_msg.reverse_stream(); |
94 if (msg.has_data()) { | 102 if (msg.has_data()) { |
95 if (FLAGS_raw && !reverse_raw_file) { | 103 if (FLAGS_raw && !reverse_raw_file) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
210 static FILE* keypress_file = OpenFile(FLAGS_keypress_file, "wb"); | 218 static FILE* keypress_file = OpenFile(FLAGS_keypress_file, "wb"); |
211 bool keypress = msg.keypress(); | 219 bool keypress = msg.keypress(); |
212 if (FLAGS_text) { | 220 if (FLAGS_text) { |
213 fprintf(keypress_file, "%d\n", keypress); | 221 fprintf(keypress_file, "%d\n", keypress); |
214 } else { | 222 } else { |
215 WriteData(&keypress, sizeof(keypress), keypress_file, | 223 WriteData(&keypress, sizeof(keypress), keypress_file, |
216 FLAGS_keypress_file); | 224 FLAGS_keypress_file); |
217 } | 225 } |
218 } | 226 } |
219 } | 227 } |
228 } else if (event_msg.type() == Event::CONFIG) { | |
229 if (!event_msg.has_config()) { | |
230 printf("Corrupt input file: Config missing.\n"); | |
231 return 1; | |
232 } | |
233 const audioproc::Config msg = event_msg.config(); | |
234 | |
235 fprintf(settings_file, "APM re-config at frame: %d\n", frame_count); | |
236 // AEC. | |
237 PRINT_CONFIG(aec_enabled, "AEC enabled"); | |
Andrew MacDonald
2015/10/01 06:33:28
I wouldn't add the second string parameter here. T
minyue-webrtc
2015/10/01 20:18:26
Ok. I think it is better to use inline function th
Andrew MacDonald
2015/10/02 00:37:20
Why not just have the macro "stringify" the single
minyue-webrtc
2015/10/02 05:29:01
Because I think the variable name is not sufficien
Andrew MacDonald
2015/10/02 06:07:39
I'm more concerned about the code being clear than
| |
238 PRINT_CONFIG(aec_delay_agnostic, "AEC delay agnostic enabled"); | |
239 PRINT_CONFIG(aec_drift_compensation, "AEC drift compensation enabled"); | |
240 PRINT_CONFIG(aec_extended_filter, "AEC extended filter enabled"); | |
241 PRINT_CONFIG(aec_suppression_level, "AEC suppression level"); | |
242 // AECM. | |
243 PRINT_CONFIG(aecm_enabled, "AECM enabled"); | |
244 PRINT_CONFIG(aecm_comfort_noise, "AECM comfort noise enabled"); | |
245 PRINT_CONFIG(aecm_routing_mode, "AECM routing mode"); | |
246 // AGC. | |
247 PRINT_CONFIG(agc_enabled, "AGC enabled"); | |
248 PRINT_CONFIG(agc_experiment, "AGC experiment enabled"); | |
249 PRINT_CONFIG(agc_mode, "AGC mode"); | |
250 PRINT_CONFIG(agc_limiter, "AGC limiter enabled"); | |
251 // HPF. | |
252 PRINT_CONFIG(hpf_enabled, "HPF enabled"); | |
253 // NS. | |
254 PRINT_CONFIG(ns_enabled, "NS enabled"); | |
255 PRINT_CONFIG(ns_experiment, "NS experiment enabled"); | |
256 PRINT_CONFIG(ns_level, "NS Level"); | |
220 } else if (event_msg.type() == Event::INIT) { | 257 } else if (event_msg.type() == Event::INIT) { |
221 if (!event_msg.has_init()) { | 258 if (!event_msg.has_init()) { |
222 printf("Corrupt input file: Init missing.\n"); | 259 printf("Corrupt input file: Init missing.\n"); |
223 return 1; | 260 return 1; |
224 } | 261 } |
225 | 262 |
226 static FILE* settings_file = OpenFile(FLAGS_settings_file, "wb"); | |
227 const Init msg = event_msg.init(); | 263 const Init msg = event_msg.init(); |
228 // These should print out zeros if they're missing. | 264 // These should print out zeros if they're missing. |
229 fprintf(settings_file, "Init at frame: %d\n", frame_count); | 265 fprintf(settings_file, "Init at frame: %d\n", frame_count); |
230 int input_sample_rate = msg.sample_rate(); | 266 int input_sample_rate = msg.sample_rate(); |
231 fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate); | 267 fprintf(settings_file, " Input sample rate: %d\n", input_sample_rate); |
232 int output_sample_rate = msg.output_sample_rate(); | 268 int output_sample_rate = msg.output_sample_rate(); |
233 fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); | 269 fprintf(settings_file, " Output sample rate: %d\n", output_sample_rate); |
234 int reverse_sample_rate = msg.reverse_sample_rate(); | 270 int reverse_sample_rate = msg.reverse_sample_rate(); |
235 fprintf(settings_file, | 271 fprintf(settings_file, |
236 " Reverse sample rate: %d\n", | 272 " Reverse sample rate: %d\n", |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
272 } | 308 } |
273 | 309 |
274 return 0; | 310 return 0; |
275 } | 311 } |
276 | 312 |
277 } // namespace webrtc | 313 } // namespace webrtc |
278 | 314 |
279 int main(int argc, char* argv[]) { | 315 int main(int argc, char* argv[]) { |
280 return webrtc::do_main(argc, argv); | 316 return webrtc::do_main(argc, argv); |
281 } | 317 } |
OLD | NEW |