Migrate WebRTC test infra to ABSL_FLAG.
This is the last CL required to migrate WebRTC to ABSL_FLAG, rtc::Flag
will be removed soon after this one lands.
Bug: webrtc:10616
Change-Id: I2807cec39e28a2737d2c49e2dc23f2a6f98d08f0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/145727
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28606}
diff --git a/modules/audio_coding/neteq/neteq_unittest.cc b/modules/audio_coding/neteq/neteq_unittest.cc
index 9f7d04d..7835096 100644
--- a/modules/audio_coding/neteq/neteq_unittest.cc
+++ b/modules/audio_coding/neteq/neteq_unittest.cc
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include "absl/flags/flag.h"
#include "api/audio/audio_frame.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "modules/audio_coding/codecs/pcm16b/pcm16b.h"
@@ -40,9 +41,6 @@
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
-// This must come after test/gtest.h
-#include "rtc_base/flags.h" // NOLINT(build/include)
-
#ifdef WEBRTC_NETEQ_UNITTEST_BITEXACT
RTC_PUSH_IGNORING_WUNDEF()
#ifdef WEBRTC_ANDROID_PLATFORM_BUILD
@@ -53,7 +51,7 @@
RTC_POP_IGNORING_WUNDEF()
#endif
-WEBRTC_DEFINE_bool(gen_ref, false, "Generate reference files.");
+ABSL_FLAG(bool, gen_ref, false, "Generate reference files.");
namespace webrtc {
@@ -470,7 +468,7 @@
"3689c9f0ab9e50cefab3e44c37c3d7aa0de82ca4");
DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
- FLAG_gen_ref);
+ absl::GetFlag(FLAGS_gen_ref));
}
#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
@@ -499,7 +497,7 @@
"0b3d34baffaf651812ffaf06ea1b5ce45ea1c47a");
DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
- FLAG_gen_ref);
+ absl::GetFlag(FLAGS_gen_ref));
}
#if !defined(WEBRTC_IOS) && defined(WEBRTC_NETEQ_UNITTEST_BITEXACT) && \
@@ -523,7 +521,7 @@
"bab58dc587d956f326056d7340c96eb9d2d3cc21";
DecodeAndCompare(input_rtp_file, output_checksum, network_stats_checksum,
- FLAG_gen_ref);
+ absl::GetFlag(FLAGS_gen_ref));
}
// Use fax mode to avoid time-scaling. This is to simplify the testing of
diff --git a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc
index 5d2df77..1004141 100644
--- a/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_ilbc_quality_test.cc
@@ -10,13 +10,15 @@
#include <memory>
+#include "absl/flags/flag.h"
#include "modules/audio_coding/codecs/ilbc/audio_encoder_ilbc.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "test/testsupport/file_utils.h"
+ABSL_FLAG(int, frame_size_ms, 20, "Codec frame size (milliseconds).");
+
using ::testing::InitGoogleTest;
namespace webrtc {
@@ -24,28 +26,27 @@
namespace {
static const int kInputSampleRateKhz = 8;
static const int kOutputSampleRateKhz = 8;
-
-WEBRTC_DEFINE_int(frame_size_ms, 20, "Codec frame size (milliseconds).");
-
} // namespace
class NetEqIlbcQualityTest : public NetEqQualityTest {
protected:
NetEqIlbcQualityTest()
- : NetEqQualityTest(FLAG_frame_size_ms,
+ : NetEqQualityTest(absl::GetFlag(FLAGS_frame_size_ms),
kInputSampleRateKhz,
kOutputSampleRateKhz,
SdpAudioFormat("ilbc", 8000, 1)) {
// Flag validation
- RTC_CHECK(FLAG_frame_size_ms == 20 || FLAG_frame_size_ms == 30 ||
- FLAG_frame_size_ms == 40 || FLAG_frame_size_ms == 60)
+ RTC_CHECK(absl::GetFlag(FLAGS_frame_size_ms) == 20 ||
+ absl::GetFlag(FLAGS_frame_size_ms) == 30 ||
+ absl::GetFlag(FLAGS_frame_size_ms) == 40 ||
+ absl::GetFlag(FLAGS_frame_size_ms) == 60)
<< "Invalid frame size, should be 20, 30, 40, or 60 ms.";
}
void SetUp() override {
ASSERT_EQ(1u, channels_) << "iLBC supports only mono audio.";
AudioEncoderIlbcConfig config;
- config.frame_size_ms = FLAG_frame_size_ms;
+ config.frame_size_ms = absl::GetFlag(FLAGS_frame_size_ms);
encoder_.reset(new AudioEncoderIlbcImpl(config, 102));
NetEqQualityTest::SetUp();
}
diff --git a/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc b/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc
index 94a5a86..6a096c3 100644
--- a/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_isac_quality_test.cc
@@ -8,9 +8,11 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "absl/flags/flag.h"
#include "modules/audio_coding/codecs/isac/fix/include/isacfix.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
-#include "rtc_base/flags.h"
+
+ABSL_FLAG(int, bit_rate_kbps, 32, "Target bit rate (kbps).");
using ::testing::InitGoogleTest;
@@ -20,9 +22,6 @@
static const int kIsacBlockDurationMs = 30;
static const int kIsacInputSamplingKhz = 16;
static const int kIsacOutputSamplingKhz = 16;
-
-WEBRTC_DEFINE_int(bit_rate_kbps, 32, "Target bit rate (kbps).");
-
} // namespace
class NetEqIsacQualityTest : public NetEqQualityTest {
@@ -46,9 +45,10 @@
kIsacOutputSamplingKhz,
SdpAudioFormat("isac", 16000, 1)),
isac_encoder_(NULL),
- bit_rate_kbps_(FLAG_bit_rate_kbps) {
+ bit_rate_kbps_(absl::GetFlag(FLAGS_bit_rate_kbps)) {
// Flag validation
- RTC_CHECK(FLAG_bit_rate_kbps >= 10 && FLAG_bit_rate_kbps <= 32)
+ RTC_CHECK(absl::GetFlag(FLAGS_bit_rate_kbps) >= 10 &&
+ absl::GetFlag(FLAGS_bit_rate_kbps) <= 32)
<< "Invalid bit rate, should be between 10 and 32 kbps.";
}
diff --git a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
index 6a6b665..eb7c2c1 100644
--- a/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_opus_quality_test.cc
@@ -8,10 +8,30 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "absl/flags/flag.h"
#include "modules/audio_coding/codecs/opus/opus_inst.h"
#include "modules/audio_coding/codecs/opus/opus_interface.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
-#include "rtc_base/flags.h"
+
+ABSL_FLAG(int, bit_rate_kbps, 32, "Target bit rate (kbps).");
+
+ABSL_FLAG(int,
+ complexity,
+ 10,
+ "Complexity: 0 ~ 10 -- defined as in Opus"
+ "specification.");
+
+ABSL_FLAG(int, maxplaybackrate, 48000, "Maximum playback rate (Hz).");
+
+ABSL_FLAG(int, application, 0, "Application mode: 0 -- VOIP, 1 -- Audio.");
+
+ABSL_FLAG(int, reported_loss_rate, 10, "Reported percentile of packet loss.");
+
+ABSL_FLAG(bool, fec, false, "Enable FEC for encoding (-nofec to disable).");
+
+ABSL_FLAG(bool, dtx, false, "Enable DTX for encoding (-nodtx to disable).");
+
+ABSL_FLAG(int, sub_packets, 1, "Number of sub packets to repacketize.");
using ::testing::InitGoogleTest;
@@ -21,28 +41,6 @@
static const int kOpusBlockDurationMs = 20;
static const int kOpusSamplingKhz = 48;
-
-WEBRTC_DEFINE_int(bit_rate_kbps, 32, "Target bit rate (kbps).");
-
-WEBRTC_DEFINE_int(complexity,
- 10,
- "Complexity: 0 ~ 10 -- defined as in Opus"
- "specification.");
-
-WEBRTC_DEFINE_int(maxplaybackrate, 48000, "Maximum playback rate (Hz).");
-
-WEBRTC_DEFINE_int(application, 0, "Application mode: 0 -- VOIP, 1 -- Audio.");
-
-WEBRTC_DEFINE_int(reported_loss_rate,
- 10,
- "Reported percentile of packet loss.");
-
-WEBRTC_DEFINE_bool(fec, false, "Enable FEC for encoding (-nofec to disable).");
-
-WEBRTC_DEFINE_bool(dtx, false, "Enable DTX for encoding (-nodtx to disable).");
-
-WEBRTC_DEFINE_int(sub_packets, 1, "Number of sub packets to repacketize.");
-
} // namespace
class NetEqOpusQualityTest : public NetEqQualityTest {
@@ -70,7 +68,7 @@
};
NetEqOpusQualityTest::NetEqOpusQualityTest()
- : NetEqQualityTest(kOpusBlockDurationMs * FLAG_sub_packets,
+ : NetEqQualityTest(kOpusBlockDurationMs * absl::GetFlag(FLAGS_sub_packets),
kOpusSamplingKhz,
kOpusSamplingKhz,
SdpAudioFormat("opus", 48000, 2)),
@@ -78,27 +76,32 @@
repacketizer_(NULL),
sub_block_size_samples_(
static_cast<size_t>(kOpusBlockDurationMs * kOpusSamplingKhz)),
- bit_rate_kbps_(FLAG_bit_rate_kbps),
- fec_(FLAG_fec),
- dtx_(FLAG_dtx),
- complexity_(FLAG_complexity),
- maxplaybackrate_(FLAG_maxplaybackrate),
- target_loss_rate_(FLAG_reported_loss_rate),
- sub_packets_(FLAG_sub_packets) {
+ bit_rate_kbps_(absl::GetFlag(FLAGS_bit_rate_kbps)),
+ fec_(absl::GetFlag(FLAGS_fec)),
+ dtx_(absl::GetFlag(FLAGS_dtx)),
+ complexity_(absl::GetFlag(FLAGS_complexity)),
+ maxplaybackrate_(absl::GetFlag(FLAGS_maxplaybackrate)),
+ target_loss_rate_(absl::GetFlag(FLAGS_reported_loss_rate)),
+ sub_packets_(absl::GetFlag(FLAGS_sub_packets)) {
// Flag validation
- RTC_CHECK(FLAG_bit_rate_kbps >= 6 && FLAG_bit_rate_kbps <= 510)
+ RTC_CHECK(absl::GetFlag(FLAGS_bit_rate_kbps) >= 6 &&
+ absl::GetFlag(FLAGS_bit_rate_kbps) <= 510)
<< "Invalid bit rate, should be between 6 and 510 kbps.";
- RTC_CHECK(FLAG_complexity >= -1 && FLAG_complexity <= 10)
+ RTC_CHECK(absl::GetFlag(FLAGS_complexity) >= -1 &&
+ absl::GetFlag(FLAGS_complexity) <= 10)
<< "Invalid complexity setting, should be between 0 and 10.";
- RTC_CHECK(FLAG_application == 0 || FLAG_application == 1)
+ RTC_CHECK(absl::GetFlag(FLAGS_application) == 0 ||
+ absl::GetFlag(FLAGS_application) == 1)
<< "Invalid application mode, should be 0 or 1.";
- RTC_CHECK(FLAG_reported_loss_rate >= 0 && FLAG_reported_loss_rate <= 100)
+ RTC_CHECK(absl::GetFlag(FLAGS_reported_loss_rate) >= 0 &&
+ absl::GetFlag(FLAGS_reported_loss_rate) <= 100)
<< "Invalid packet loss percentile, should be between 0 and 100.";
- RTC_CHECK(FLAG_sub_packets >= 1 && FLAG_sub_packets <= 3)
+ RTC_CHECK(absl::GetFlag(FLAGS_sub_packets) >= 1 &&
+ absl::GetFlag(FLAGS_sub_packets) <= 3)
<< "Invalid number of sub packets, should be between 1 and 3.";
// Redefine decoder type if input is stereo.
@@ -106,7 +109,7 @@
audio_format_ = SdpAudioFormat(
"opus", 48000, 2, std::map<std::string, std::string>{{"stereo", "1"}});
}
- application_ = FLAG_application;
+ application_ = absl::GetFlag(FLAGS_application);
}
void NetEqOpusQualityTest::SetUp() {
diff --git a/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc b/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc
index 9ec9d44..c3e160c 100644
--- a/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_pcm16b_quality_test.cc
@@ -10,13 +10,15 @@
#include <memory>
+#include "absl/flags/flag.h"
#include "modules/audio_coding/codecs/pcm16b/audio_encoder_pcm16b.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "test/testsupport/file_utils.h"
+ABSL_FLAG(int, frame_size_ms, 20, "Codec frame size (milliseconds).");
+
using ::testing::InitGoogleTest;
namespace webrtc {
@@ -24,27 +26,25 @@
namespace {
static const int kInputSampleRateKhz = 48;
static const int kOutputSampleRateKhz = 48;
-
-WEBRTC_DEFINE_int(frame_size_ms, 20, "Codec frame size (milliseconds).");
-
} // namespace
class NetEqPcm16bQualityTest : public NetEqQualityTest {
protected:
NetEqPcm16bQualityTest()
- : NetEqQualityTest(FLAG_frame_size_ms,
+ : NetEqQualityTest(absl::GetFlag(FLAGS_frame_size_ms),
kInputSampleRateKhz,
kOutputSampleRateKhz,
SdpAudioFormat("l16", 48000, 1)) {
// Flag validation
- RTC_CHECK(FLAG_frame_size_ms >= 10 && FLAG_frame_size_ms <= 60 &&
- (FLAG_frame_size_ms % 10) == 0)
+ RTC_CHECK(absl::GetFlag(FLAGS_frame_size_ms) >= 10 &&
+ absl::GetFlag(FLAGS_frame_size_ms) <= 60 &&
+ (absl::GetFlag(FLAGS_frame_size_ms) % 10) == 0)
<< "Invalid frame size, should be 10, 20, ..., 60 ms.";
}
void SetUp() override {
AudioEncoderPcm16B::Config config;
- config.frame_size_ms = FLAG_frame_size_ms;
+ config.frame_size_ms = absl::GetFlag(FLAGS_frame_size_ms);
config.sample_rate_hz = 48000;
config.num_channels = channels_;
encoder_.reset(new AudioEncoderPcm16B(config));
diff --git a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc
index 62a184e..d22170c 100644
--- a/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_pcmu_quality_test.cc
@@ -10,13 +10,15 @@
#include <memory>
+#include "absl/flags/flag.h"
#include "modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/numerics/safe_conversions.h"
#include "test/testsupport/file_utils.h"
+ABSL_FLAG(int, frame_size_ms, 20, "Codec frame size (milliseconds).");
+
using ::testing::InitGoogleTest;
namespace webrtc {
@@ -24,28 +26,26 @@
namespace {
static const int kInputSampleRateKhz = 8;
static const int kOutputSampleRateKhz = 8;
-
-WEBRTC_DEFINE_int(frame_size_ms, 20, "Codec frame size (milliseconds).");
-
} // namespace
class NetEqPcmuQualityTest : public NetEqQualityTest {
protected:
NetEqPcmuQualityTest()
- : NetEqQualityTest(FLAG_frame_size_ms,
+ : NetEqQualityTest(absl::GetFlag(FLAGS_frame_size_ms),
kInputSampleRateKhz,
kOutputSampleRateKhz,
SdpAudioFormat("pcmu", 8000, 1)) {
// Flag validation
- RTC_CHECK(FLAG_frame_size_ms >= 10 && FLAG_frame_size_ms <= 60 &&
- (FLAG_frame_size_ms % 10) == 0)
+ RTC_CHECK(absl::GetFlag(FLAGS_frame_size_ms) >= 10 &&
+ absl::GetFlag(FLAGS_frame_size_ms) <= 60 &&
+ (absl::GetFlag(FLAGS_frame_size_ms) % 10) == 0)
<< "Invalid frame size, should be 10, 20, ..., 60 ms.";
}
void SetUp() override {
ASSERT_EQ(1u, channels_) << "PCMu supports only mono audio.";
AudioEncoderPcmU::Config config;
- config.frame_size_ms = FLAG_frame_size_ms;
+ config.frame_size_ms = absl::GetFlag(FLAGS_frame_size_ms);
encoder_.reset(new AudioEncoderPcmU(config));
NetEqQualityTest::SetUp();
}
diff --git a/modules/audio_coding/neteq/test/neteq_speed_test.cc b/modules/audio_coding/neteq/test/neteq_speed_test.cc
index 70777a2..a72b200 100644
--- a/modules/audio_coding/neteq/test/neteq_speed_test.cc
+++ b/modules/audio_coding/neteq/test/neteq_speed_test.cc
@@ -11,18 +11,21 @@
#include <stdio.h>
#include <iostream>
+#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "modules/audio_coding/neteq/tools/neteq_performance_test.h"
-#include "rtc_base/flags.h"
+#include "rtc_base/checks.h"
// Define command line flags.
-WEBRTC_DEFINE_int(runtime_ms, 10000, "Simulated runtime in ms.");
-WEBRTC_DEFINE_int(lossrate, 10, "Packet lossrate; drop every N packets.");
-WEBRTC_DEFINE_float(drift, 0.1f, "Clockdrift factor.");
-WEBRTC_DEFINE_bool(help, false, "Print this message.");
+ABSL_FLAG(int, runtime_ms, 10000, "Simulated runtime in ms.");
+ABSL_FLAG(int, lossrate, 10, "Packet lossrate; drop every N packets.");
+ABSL_FLAG(float, drift, 0.1f, "Clockdrift factor.");
int main(int argc, char* argv[]) {
- std::string program_name = argv[0];
+ std::vector<char*> args = absl::ParseCommandLine(argc, argv);
+ std::string program_name = args[0];
std::string usage =
"Tool for measuring the speed of NetEq.\n"
"Usage: " +
@@ -32,21 +35,18 @@
" --lossrate=N drop every N packets; default is 10\n"
" --drift=F clockdrift factor between 0.0 and 1.0; "
"default is 0.1\n";
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
- argc != 1) {
+ if (args.size() != 1) {
printf("%s", usage.c_str());
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
return 1;
}
- RTC_CHECK_GT(FLAG_runtime_ms, 0);
- RTC_CHECK_GE(FLAG_lossrate, 0);
- RTC_CHECK(FLAG_drift >= 0.0 && FLAG_drift < 1.0);
+ RTC_CHECK_GT(absl::GetFlag(FLAGS_runtime_ms), 0);
+ RTC_CHECK_GE(absl::GetFlag(FLAGS_lossrate), 0);
+ RTC_CHECK(absl::GetFlag(FLAGS_drift) >= 0.0 &&
+ absl::GetFlag(FLAGS_drift) < 1.0);
int64_t result = webrtc::test::NetEqPerformanceTest::Run(
- FLAG_runtime_ms, FLAG_lossrate, FLAG_drift);
+ absl::GetFlag(FLAGS_runtime_ms), absl::GetFlag(FLAGS_lossrate),
+ absl::GetFlag(FLAGS_drift));
if (result <= 0) {
std::cout << "There was an error" << std::endl;
return -1;
diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.cc b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
index 01d2a2d..0adc21d 100644
--- a/modules/audio_coding/neteq/tools/neteq_quality_test.cc
+++ b/modules/audio_coding/neteq/tools/neteq_quality_test.cc
@@ -14,12 +14,75 @@
#include <cmath>
+#include "absl/flags/flag.h"
+#include "modules/audio_coding/neteq/tools/neteq_quality_test.h"
#include "modules/audio_coding/neteq/tools/output_audio_file.h"
#include "modules/audio_coding/neteq/tools/output_wav_file.h"
#include "modules/audio_coding/neteq/tools/resample_input_audio_file.h"
#include "rtc_base/checks.h"
#include "test/testsupport/file_utils.h"
+const std::string& DefaultInFilename() {
+ static const std::string path =
+ ::webrtc::test::ResourcePath("audio_coding/speech_mono_16kHz", "pcm");
+ return path;
+}
+
+const std::string& DefaultOutFilename() {
+ static const std::string path =
+ ::webrtc::test::OutputPath() + "neteq_quality_test_out.pcm";
+ return path;
+}
+
+ABSL_FLAG(
+ std::string,
+ in_filename,
+ DefaultInFilename(),
+ "Filename for input audio (specify sample rate with --input_sample_rate, "
+ "and channels with --channels).");
+
+ABSL_FLAG(int, input_sample_rate, 16000, "Sample rate of input file in Hz.");
+
+ABSL_FLAG(int, channels, 1, "Number of channels in input audio.");
+
+ABSL_FLAG(std::string,
+ out_filename,
+ DefaultOutFilename(),
+ "Name of output audio file.");
+
+ABSL_FLAG(
+ int,
+ runtime_ms,
+ 10000,
+ "Simulated runtime (milliseconds). -1 will consume the complete file.");
+
+ABSL_FLAG(int, packet_loss_rate, 10, "Percentile of packet loss.");
+
+ABSL_FLAG(int,
+ random_loss_mode,
+ ::webrtc::test::kUniformLoss,
+ "Random loss mode: 0--no loss, 1--uniform loss, 2--Gilbert Elliot "
+ "loss, 3--fixed loss.");
+
+ABSL_FLAG(int,
+ burst_length,
+ 30,
+ "Burst length in milliseconds, only valid for Gilbert Elliot loss.");
+
+ABSL_FLAG(float, drift_factor, 0.0, "Time drift factor.");
+
+ABSL_FLAG(int,
+ preload_packets,
+ 1,
+ "Preload the buffer with this many packets.");
+
+ABSL_FLAG(std::string,
+ loss_events,
+ "",
+ "List of loss events time and duration separated by comma: "
+ "<first_event_time> <first_event_duration>, <second_event_time> "
+ "<second_event_duration>, ...");
+
namespace webrtc {
namespace test {
@@ -28,17 +91,6 @@
const int kInitSeed = 0x12345678;
const int kPacketLossTimeUnitMs = 10;
-const std::string& DefaultInFilename() {
- static const std::string path =
- ResourcePath("audio_coding/speech_mono_16kHz", "pcm");
- return path;
-}
-
-const std::string& DefaultOutFilename() {
- static const std::string path = OutputPath() + "neteq_quality_test_out.pcm";
- return path;
-}
-
// Common validator for file names.
static bool ValidateFilename(const std::string& value, bool is_output) {
if (!is_output) {
@@ -53,51 +105,6 @@
return true;
}
-WEBRTC_DEFINE_string(
- in_filename,
- DefaultInFilename().c_str(),
- "Filename for input audio (specify sample rate with --input_sample_rate, "
- "and channels with --channels).");
-
-WEBRTC_DEFINE_int(input_sample_rate, 16000, "Sample rate of input file in Hz.");
-
-WEBRTC_DEFINE_int(channels, 1, "Number of channels in input audio.");
-
-WEBRTC_DEFINE_string(out_filename,
- DefaultOutFilename().c_str(),
- "Name of output audio file.");
-
-WEBRTC_DEFINE_int(
- runtime_ms,
- 10000,
- "Simulated runtime (milliseconds). -1 will consume the complete file.");
-
-WEBRTC_DEFINE_int(packet_loss_rate, 10, "Percentile of packet loss.");
-
-WEBRTC_DEFINE_int(
- random_loss_mode,
- kUniformLoss,
- "Random loss mode: 0--no loss, 1--uniform loss, 2--Gilbert Elliot "
- "loss, 3--fixed loss.");
-
-WEBRTC_DEFINE_int(
- burst_length,
- 30,
- "Burst length in milliseconds, only valid for Gilbert Elliot loss.");
-
-WEBRTC_DEFINE_float(drift_factor, 0.0, "Time drift factor.");
-
-WEBRTC_DEFINE_int(preload_packets,
- 1,
- "Preload the buffer with this many packets.");
-
-WEBRTC_DEFINE_string(
- loss_events,
- "",
- "List of loss events time and duration separated by comma: "
- "<first_event_time> <first_event_duration>, <second_event_time> "
- "<second_event_duration>, ...");
-
// ProbTrans00Solver() is to calculate the transition probability from no-loss
// state to itself in a modified Gilbert Elliot packet loss model. The result is
// to achieve the target packet loss rate |loss_rate|, when a packet is not
@@ -148,11 +155,11 @@
const SdpAudioFormat& format,
const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory)
: audio_format_(format),
- channels_(static_cast<size_t>(FLAG_channels)),
+ channels_(absl::GetFlag(FLAGS_channels)),
decoded_time_ms_(0),
decodable_time_ms_(0),
- drift_factor_(FLAG_drift_factor),
- packet_loss_rate_(FLAG_packet_loss_rate),
+ drift_factor_(absl::GetFlag(FLAGS_drift_factor)),
+ packet_loss_rate_(absl::GetFlag(FLAGS_packet_loss_rate)),
block_duration_ms_(block_duration_ms),
in_sampling_khz_(in_sampling_khz),
out_sampling_khz_(out_sampling_khz),
@@ -160,45 +167,50 @@
static_cast<size_t>(in_sampling_khz_ * block_duration_ms_)),
payload_size_bytes_(0),
max_payload_bytes_(0),
- in_file_(new ResampleInputAudioFile(FLAG_in_filename,
- FLAG_input_sample_rate,
- in_sampling_khz * 1000,
- FLAG_runtime_ms > 0)),
+ in_file_(
+ new ResampleInputAudioFile(absl::GetFlag(FLAGS_in_filename),
+ absl::GetFlag(FLAGS_input_sample_rate),
+ in_sampling_khz * 1000,
+ absl::GetFlag(FLAGS_runtime_ms) > 0)),
rtp_generator_(
new RtpGenerator(in_sampling_khz_, 0, 0, decodable_time_ms_)),
total_payload_size_bytes_(0) {
// Flag validation
- RTC_CHECK(ValidateFilename(FLAG_in_filename, false))
+ RTC_CHECK(ValidateFilename(absl::GetFlag(FLAGS_in_filename), false))
<< "Invalid input filename.";
- RTC_CHECK(FLAG_input_sample_rate == 8000 || FLAG_input_sample_rate == 16000 ||
- FLAG_input_sample_rate == 32000 || FLAG_input_sample_rate == 48000)
+ RTC_CHECK(absl::GetFlag(FLAGS_input_sample_rate) == 8000 ||
+ absl::GetFlag(FLAGS_input_sample_rate) == 16000 ||
+ absl::GetFlag(FLAGS_input_sample_rate) == 32000 ||
+ absl::GetFlag(FLAGS_input_sample_rate) == 48000)
<< "Invalid sample rate should be 8000, 16000, 32000 or 48000 Hz.";
- RTC_CHECK_EQ(FLAG_channels, 1)
+ RTC_CHECK_EQ(absl::GetFlag(FLAGS_channels), 1)
<< "Invalid number of channels, current support only 1.";
- RTC_CHECK(ValidateFilename(FLAG_out_filename, true))
+ RTC_CHECK(ValidateFilename(absl::GetFlag(FLAGS_out_filename), true))
<< "Invalid output filename.";
- RTC_CHECK(FLAG_packet_loss_rate >= 0 && FLAG_packet_loss_rate <= 100)
+ RTC_CHECK(absl::GetFlag(FLAGS_packet_loss_rate) >= 0 &&
+ absl::GetFlag(FLAGS_packet_loss_rate) <= 100)
<< "Invalid packet loss percentile, should be between 0 and 100.";
- RTC_CHECK(FLAG_random_loss_mode >= 0 && FLAG_random_loss_mode < kLastLossMode)
+ RTC_CHECK(absl::GetFlag(FLAGS_random_loss_mode) >= 0 &&
+ absl::GetFlag(FLAGS_random_loss_mode) < kLastLossMode)
<< "Invalid random packet loss mode, should be between 0 and "
<< kLastLossMode - 1 << ".";
- RTC_CHECK_GE(FLAG_burst_length, kPacketLossTimeUnitMs)
+ RTC_CHECK_GE(absl::GetFlag(FLAGS_burst_length), kPacketLossTimeUnitMs)
<< "Invalid burst length, should be greater than or equal to "
<< kPacketLossTimeUnitMs << " ms.";
- RTC_CHECK_GT(FLAG_drift_factor, -0.1)
+ RTC_CHECK_GT(absl::GetFlag(FLAGS_drift_factor), -0.1)
<< "Invalid drift factor, should be greater than -0.1.";
- RTC_CHECK_GE(FLAG_preload_packets, 0)
+ RTC_CHECK_GE(absl::GetFlag(FLAGS_preload_packets), 0)
<< "Invalid number of packets to preload; must be non-negative.";
- const std::string out_filename = FLAG_out_filename;
+ const std::string out_filename = absl::GetFlag(FLAGS_out_filename);
const std::string log_filename = out_filename + ".log";
log_file_.open(log_filename.c_str(), std::ofstream::out);
RTC_CHECK(log_file_.is_open());
@@ -283,7 +295,7 @@
rtp_generator_->set_drift_factor(drift_factor_);
int units = block_duration_ms_ / kPacketLossTimeUnitMs;
- switch (FLAG_random_loss_mode) {
+ switch (absl::GetFlag(FLAGS_random_loss_mode)) {
case kUniformLoss: {
// |unit_loss_rate| is the packet loss rate for each unit time interval
// (kPacketLossTimeUnitMs). Since a packet loss event is generated if any
@@ -297,8 +309,8 @@
break;
}
case kGilbertElliotLoss: {
- // |FLAG_burst_length| should be integer times of kPacketLossTimeUnitMs.
- ASSERT_EQ(0, FLAG_burst_length % kPacketLossTimeUnitMs);
+ // |FLAGS_burst_length| should be integer times of kPacketLossTimeUnitMs.
+ ASSERT_EQ(0, absl::GetFlag(FLAGS_burst_length) % kPacketLossTimeUnitMs);
// We do not allow 100 percent packet loss in Gilbert Elliot model, which
// makes no sense.
@@ -316,14 +328,15 @@
// prob_trans_00 ^ (units - 1) = (loss_rate - 1) / prob_trans_10 *
// prob_trans_00 + (1 - loss_rate) * (1 + 1 / prob_trans_10).
double loss_rate = 0.01f * packet_loss_rate_;
- double prob_trans_10 = 1.0f * kPacketLossTimeUnitMs / FLAG_burst_length;
+ double prob_trans_10 =
+ 1.0f * kPacketLossTimeUnitMs / absl::GetFlag(FLAGS_burst_length);
double prob_trans_00 = ProbTrans00Solver(units, loss_rate, prob_trans_10);
loss_model_.reset(
new GilbertElliotLoss(1.0f - prob_trans_10, 1.0f - prob_trans_00));
break;
}
case kFixedLoss: {
- std::istringstream loss_events_stream(FLAG_loss_events);
+ std::istringstream loss_events_stream(absl::GetFlag(FLAGS_loss_events));
std::string loss_event_string;
std::set<FixedLossEvent, FixedLossEventCmp> loss_events;
while (std::getline(loss_events_stream, loss_event_string, ',')) {
@@ -415,15 +428,18 @@
void NetEqQualityTest::Simulate() {
int audio_size_samples;
bool end_of_input = false;
- int runtime_ms = FLAG_runtime_ms >= 0 ? FLAG_runtime_ms : INT_MAX;
+ int runtime_ms = absl::GetFlag(FLAGS_runtime_ms) >= 0
+ ? absl::GetFlag(FLAGS_runtime_ms)
+ : INT_MAX;
while (!end_of_input && decoded_time_ms_ < runtime_ms) {
// Preload the buffer if needed.
- while (decodable_time_ms_ - FLAG_preload_packets * block_duration_ms_ <
+ while (decodable_time_ms_ -
+ absl::GetFlag(FLAGS_preload_packets) * block_duration_ms_ <
decoded_time_ms_) {
if (!in_file_->Read(in_size_samples_ * channels_, &in_data_[0])) {
end_of_input = true;
- ASSERT_TRUE(end_of_input && FLAG_runtime_ms < 0);
+ ASSERT_TRUE(end_of_input && absl::GetFlag(FLAGS_runtime_ms) < 0);
break;
}
payload_.Clear();
@@ -438,8 +454,8 @@
}
}
Log() << "Average bit rate was "
- << 8.0f * total_payload_size_bytes_ / FLAG_runtime_ms << " kbps"
- << std::endl;
+ << 8.0f * total_payload_size_bytes_ / absl::GetFlag(FLAGS_runtime_ms)
+ << " kbps" << std::endl;
}
} // namespace test
diff --git a/modules/audio_coding/neteq/tools/neteq_quality_test.h b/modules/audio_coding/neteq/tools/neteq_quality_test.h
index e9c6dab..a8243c1 100644
--- a/modules/audio_coding/neteq/tools/neteq_quality_test.h
+++ b/modules/audio_coding/neteq/tools/neteq_quality_test.h
@@ -19,7 +19,6 @@
#include "modules/audio_coding/neteq/tools/audio_sink.h"
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
#include "modules/audio_coding/neteq/tools/rtp_generator.h"
-#include "rtc_base/flags.h"
#include "test/gtest.h"
namespace webrtc {
diff --git a/modules/audio_coding/neteq/tools/neteq_test_factory.cc b/modules/audio_coding/neteq/tools/neteq_test_factory.cc
index a7061eb..8147142 100644
--- a/modules/audio_coding/neteq/tools/neteq_test_factory.cc
+++ b/modules/audio_coding/neteq/tools/neteq_test_factory.cc
@@ -39,7 +39,6 @@
#include "modules/audio_coding/neteq/tools/output_wav_file.h"
#include "modules/audio_coding/neteq/tools/rtp_file_source.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/ref_counted_object.h"
#include "test/function_audio_decoder_factory.h"
#include "test/testsupport/file_utils.h"
diff --git a/modules/audio_coding/neteq/tools/rtp_analyze.cc b/modules/audio_coding/neteq/tools/rtp_analyze.cc
index e71aee0..dad3750 100644
--- a/modules/audio_coding/neteq/tools/rtp_analyze.cc
+++ b/modules/audio_coding/neteq/tools/rtp_analyze.cc
@@ -18,7 +18,6 @@
#include "absl/flags/parse.h"
#include "modules/audio_coding/neteq/tools/packet.h"
#include "modules/audio_coding/neteq/tools/rtp_file_source.h"
-#include "rtc_base/flags.h"
ABSL_FLAG(int, red, 117, "RTP payload type for RED");
ABSL_FLAG(int,
diff --git a/modules/audio_coding/neteq/tools/rtp_encode.cc b/modules/audio_coding/neteq/tools/rtp_encode.cc
index 0379d21..f65679d 100644
--- a/modules/audio_coding/neteq/tools/rtp_encode.cc
+++ b/modules/audio_coding/neteq/tools/rtp_encode.cc
@@ -35,7 +35,6 @@
#include "modules/audio_coding/codecs/cng/audio_encoder_cng.h"
#include "modules/audio_coding/include/audio_coding_module.h"
#include "modules/audio_coding/neteq/tools/input_audio_file.h"
-#include "rtc_base/flags.h"
#include "rtc_base/numerics/safe_conversions.h"
ABSL_FLAG(bool, list_codecs, false, "Enumerate all codecs");