Index: webrtc/modules/audio_coding/test/delay_test.cc |
diff --git a/webrtc/modules/audio_coding/test/delay_test.cc b/webrtc/modules/audio_coding/test/delay_test.cc |
index ce244932c82bd1040553a8739710c69c31c686bd..0ce7fd226aec1291e3f9193d6c61fc0b4361d9a4 100644 |
--- a/webrtc/modules/audio_coding/test/delay_test.cc |
+++ b/webrtc/modules/audio_coding/test/delay_test.cc |
@@ -10,11 +10,11 @@ |
#include <assert.h> |
#include <math.h> |
+#include <string.h> |
#include <iostream> |
#include <memory> |
-#include "gflags/gflags.h" |
#include "webrtc/common_types.h" |
#include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" |
#include "webrtc/modules/audio_coding/include/audio_coding_module.h" |
@@ -22,19 +22,21 @@ |
#include "webrtc/modules/audio_coding/test/Channel.h" |
#include "webrtc/modules/audio_coding/test/PCMFile.h" |
#include "webrtc/modules/audio_coding/test/utility.h" |
+#include "webrtc/rtc_base/flags.h" |
#include "webrtc/system_wrappers/include/event_wrapper.h" |
#include "webrtc/test/gtest.h" |
#include "webrtc/test/testsupport/fileutils.h" |
#include "webrtc/typedefs.h" |
DEFINE_string(codec, "isac", "Codec Name"); |
-DEFINE_int32(sample_rate_hz, 16000, "Sampling rate in Hertz."); |
-DEFINE_int32(num_channels, 1, "Number of Channels."); |
+DEFINE_int(sample_rate_hz, 16000, "Sampling rate in Hertz."); |
+DEFINE_int(num_channels, 1, "Number of Channels."); |
DEFINE_string(input_file, "", "Input file, PCM16 32 kHz, optional."); |
-DEFINE_int32(delay, 0, "Delay in millisecond."); |
+DEFINE_int(delay, 0, "Delay in millisecond."); |
DEFINE_bool(dtx, false, "Enable DTX at the sender side."); |
DEFINE_bool(packet_loss, false, "Apply packet loss, c.f. Channel{.cc, .h}."); |
DEFINE_bool(fec, false, "Use Forward Error Correction (FEC)."); |
+DEFINE_bool(help, false, "Print this message."); |
namespace webrtc { |
@@ -80,16 +82,16 @@ class DelayTest { |
test_cntr_ = 0; |
std::string file_name = webrtc::test::ResourcePath( |
"audio_coding/testfile32kHz", "pcm"); |
- if (FLAGS_input_file.size() > 0) |
- file_name = FLAGS_input_file; |
+ if (strlen(FLAG_input_file) > 0) |
+ file_name = FLAG_input_file; |
in_file_a_.Open(file_name, 32000, "rb"); |
ASSERT_EQ(0, acm_a_->InitializeReceiver()) << |
"Couldn't initialize receiver.\n"; |
ASSERT_EQ(0, acm_b_->InitializeReceiver()) << |
"Couldn't initialize receiver.\n"; |
- if (FLAGS_delay > 0) { |
- ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAGS_delay)) << |
+ if (FLAG_delay > 0) { |
+ ASSERT_EQ(0, acm_b_->SetMinimumPlayoutDelay(FLAG_delay)) << |
"Failed to set minimum delay.\n"; |
} |
@@ -166,8 +168,8 @@ class DelayTest { |
void OpenOutFile(const char* output_id) { |
std::stringstream file_stream; |
- file_stream << "delay_test_" << FLAGS_codec << "_" << FLAGS_sample_rate_hz |
- << "Hz" << "_" << FLAGS_delay << "ms.pcm"; |
+ file_stream << "delay_test_" << FLAG_codec << "_" << FLAG_sample_rate_hz |
+ << "Hz" << "_" << FLAG_delay << "ms.pcm"; |
std::cout << "Output file: " << file_stream.str() << std::endl << std::endl; |
std::string file_name = webrtc::test::OutputPath() + file_stream.str(); |
out_file_b_.Open(file_name.c_str(), 32000, "wb"); |
@@ -240,26 +242,33 @@ class DelayTest { |
} // namespace webrtc |
int main(int argc, char* argv[]) { |
- google::ParseCommandLineFlags(&argc, &argv, true); |
+ if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) { |
+ return 1; |
+ } |
+ if (FLAG_help) { |
+ rtc::FlagList::Print(nullptr, false); |
+ return 0; |
+ } |
+ |
webrtc::TestSettings test_setting; |
- strcpy(test_setting.codec.name, FLAGS_codec.c_str()); |
+ strcpy(test_setting.codec.name, FLAG_codec); |
- if (FLAGS_sample_rate_hz != 8000 && |
- FLAGS_sample_rate_hz != 16000 && |
- FLAGS_sample_rate_hz != 32000 && |
- FLAGS_sample_rate_hz != 48000) { |
+ if (FLAG_sample_rate_hz != 8000 && |
+ FLAG_sample_rate_hz != 16000 && |
+ FLAG_sample_rate_hz != 32000 && |
+ FLAG_sample_rate_hz != 48000) { |
std::cout << "Invalid sampling rate.\n"; |
return 1; |
} |
- test_setting.codec.sample_rate_hz = FLAGS_sample_rate_hz; |
- if (FLAGS_num_channels < 1 || FLAGS_num_channels > 2) { |
+ test_setting.codec.sample_rate_hz = FLAG_sample_rate_hz; |
+ if (FLAG_num_channels < 1 || FLAG_num_channels > 2) { |
std::cout << "Only mono and stereo are supported.\n"; |
return 1; |
} |
- test_setting.codec.num_channels = FLAGS_num_channels; |
- test_setting.acm.dtx = FLAGS_dtx; |
- test_setting.acm.fec = FLAGS_fec; |
- test_setting.packet_loss = FLAGS_packet_loss; |
+ test_setting.codec.num_channels = FLAG_num_channels; |
+ test_setting.acm.dtx = FLAG_dtx; |
+ test_setting.acm.fec = FLAG_fec; |
+ test_setting.packet_loss = FLAG_packet_loss; |
webrtc::DelayTest delay_test; |
delay_test.Initialize(); |