| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 |
| 11 #include <stdio.h> | 11 #include <stdio.h> |
| 12 #include <iostream> | 12 #include <iostream> |
| 13 #include <sstream> | 13 #include <sstream> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 | 16 |
| 17 #include "gflags/gflags.h" | 17 #include "gflags/gflags.h" |
| 18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
| 19 #include "webrtc/base/format_macros.h" |
| 19 #include "webrtc/base/scoped_ptr.h" | 20 #include "webrtc/base/scoped_ptr.h" |
| 20 #include "webrtc/common_audio/channel_buffer.h" | 21 #include "webrtc/common_audio/channel_buffer.h" |
| 21 #include "webrtc/common_audio/wav_file.h" | 22 #include "webrtc/common_audio/wav_file.h" |
| 22 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 23 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 23 #include "webrtc/modules/audio_processing/test/audio_file_processor.h" | 24 #include "webrtc/modules/audio_processing/test/audio_file_processor.h" |
| 24 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 25 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
| 25 #include "webrtc/modules/audio_processing/test/test_utils.h" | 26 #include "webrtc/modules/audio_processing/test/test_utils.h" |
| 26 #include "webrtc/system_wrappers/include/tick_util.h" | 27 #include "webrtc/system_wrappers/include/tick_util.h" |
| 27 #include "webrtc/test/testsupport/trace_to_stderr.h" | 28 #include "webrtc/test/testsupport/trace_to_stderr.h" |
| 28 | 29 |
| 30 namespace { |
| 31 |
| 32 bool ValidateOutChannels(const char* flagname, int32_t value) { |
| 33 return value >= 0; |
| 34 } |
| 35 |
| 36 } // namespace |
| 37 |
| 29 DEFINE_string(dump, "", "Name of the aecdump debug file to read from."); | 38 DEFINE_string(dump, "", "Name of the aecdump debug file to read from."); |
| 30 DEFINE_string(i, "", "Name of the capture input stream file to read from."); | 39 DEFINE_string(i, "", "Name of the capture input stream file to read from."); |
| 31 DEFINE_string( | 40 DEFINE_string( |
| 32 o, | 41 o, |
| 33 "out.wav", | 42 "out.wav", |
| 34 "Name of the output file to write the processed capture stream to."); | 43 "Name of the output file to write the processed capture stream to."); |
| 35 DEFINE_int32(out_channels, 1, "Number of output channels."); | 44 DEFINE_int32(out_channels, 1, "Number of output channels."); |
| 45 const bool out_channels_dummy = |
| 46 google::RegisterFlagValidator(&FLAGS_out_channels, &ValidateOutChannels); |
| 36 DEFINE_int32(out_sample_rate, 48000, "Output sample rate in Hz."); | 47 DEFINE_int32(out_sample_rate, 48000, "Output sample rate in Hz."); |
| 37 DEFINE_string(mic_positions, "", | 48 DEFINE_string(mic_positions, "", |
| 38 "Space delimited cartesian coordinates of microphones in meters. " | 49 "Space delimited cartesian coordinates of microphones in meters. " |
| 39 "The coordinates of each point are contiguous. " | 50 "The coordinates of each point are contiguous. " |
| 40 "For a two element array: \"x1 y1 z1 x2 y2 z2\""); | 51 "For a two element array: \"x1 y1 z1 x2 y2 z2\""); |
| 41 DEFINE_double( | 52 DEFINE_double( |
| 42 target_angle_degrees, | 53 target_angle_degrees, |
| 43 90, | 54 90, |
| 44 "The azimuth of the target in degrees. Only applies to beamforming."); | 55 "The azimuth of the target in degrees. Only applies to beamforming."); |
| 45 | 56 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 RTC_CHECK_EQ(kNoErr, ap->high_pass_filter()->Enable(FLAGS_hpf || FLAGS_all)); | 121 RTC_CHECK_EQ(kNoErr, ap->high_pass_filter()->Enable(FLAGS_hpf || FLAGS_all)); |
| 111 RTC_CHECK_EQ(kNoErr, ap->noise_suppression()->Enable(FLAGS_ns || FLAGS_all)); | 122 RTC_CHECK_EQ(kNoErr, ap->noise_suppression()->Enable(FLAGS_ns || FLAGS_all)); |
| 112 if (FLAGS_ns_level != -1) { | 123 if (FLAGS_ns_level != -1) { |
| 113 RTC_CHECK_EQ(kNoErr, | 124 RTC_CHECK_EQ(kNoErr, |
| 114 ap->noise_suppression()->set_level( | 125 ap->noise_suppression()->set_level( |
| 115 static_cast<NoiseSuppression::Level>(FLAGS_ns_level))); | 126 static_cast<NoiseSuppression::Level>(FLAGS_ns_level))); |
| 116 } | 127 } |
| 117 ap->set_stream_key_pressed(FLAGS_ts); | 128 ap->set_stream_key_pressed(FLAGS_ts); |
| 118 | 129 |
| 119 rtc::scoped_ptr<AudioFileProcessor> processor; | 130 rtc::scoped_ptr<AudioFileProcessor> processor; |
| 120 auto out_file = rtc_make_scoped_ptr( | 131 auto out_file = rtc_make_scoped_ptr(new WavWriter( |
| 121 new WavWriter(FLAGS_o, FLAGS_out_sample_rate, FLAGS_out_channels)); | 132 FLAGS_o, FLAGS_out_sample_rate, static_cast<size_t>(FLAGS_out_channels))); |
| 122 std::cout << FLAGS_o << ": " << out_file->FormatAsString() << std::endl; | 133 std::cout << FLAGS_o << ": " << out_file->FormatAsString() << std::endl; |
| 123 if (FLAGS_dump.empty()) { | 134 if (FLAGS_dump.empty()) { |
| 124 auto in_file = rtc_make_scoped_ptr(new WavReader(FLAGS_i)); | 135 auto in_file = rtc_make_scoped_ptr(new WavReader(FLAGS_i)); |
| 125 std::cout << FLAGS_i << ": " << in_file->FormatAsString() << std::endl; | 136 std::cout << FLAGS_i << ": " << in_file->FormatAsString() << std::endl; |
| 126 processor.reset(new WavFileProcessor(std::move(ap), std::move(in_file), | 137 processor.reset(new WavFileProcessor(std::move(ap), std::move(in_file), |
| 127 std::move(out_file))); | 138 std::move(out_file))); |
| 128 | 139 |
| 129 } else { | 140 } else { |
| 130 processor.reset(new AecDumpFileProcessor( | 141 processor.reset(new AecDumpFileProcessor( |
| 131 std::move(ap), fopen(FLAGS_dump.c_str(), "rb"), std::move(out_file))); | 142 std::move(ap), fopen(FLAGS_dump.c_str(), "rb"), std::move(out_file))); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 149 } | 160 } |
| 150 | 161 |
| 151 return 0; | 162 return 0; |
| 152 } | 163 } |
| 153 | 164 |
| 154 } // namespace webrtc | 165 } // namespace webrtc |
| 155 | 166 |
| 156 int main(int argc, char* argv[]) { | 167 int main(int argc, char* argv[]) { |
| 157 return webrtc::main(argc, argv); | 168 return webrtc::main(argc, argv); |
| 158 } | 169 } |
| OLD | NEW |