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/BUILD.gn b/BUILD.gn
index 4a04def..95d02f7 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -83,6 +83,13 @@
}
}
+# Abseil Flags by default doesn't register command line flags on mobile
+# platforms, WebRTC tests requires them (e.g. on simualtors) so this
+# config will be applied to testonly targets globally (see webrtc.gni).
+config("absl_flags_configs") {
+ defines = [ "ABSL_FLAGS_STRIP_NAMES=0" ]
+}
+
config("library_impl_config") {
# Build targets that contain WebRTC implementation need this macro to
# be defined in order to correctly export symbols when is_component_build
diff --git a/api/BUILD.gn b/api/BUILD.gn
index 645daee..ca2b5cb 100644
--- a/api/BUILD.gn
+++ b/api/BUILD.gn
@@ -573,7 +573,8 @@
":neteq_simulator_api",
"../modules/audio_coding:neteq_test_factory",
"../rtc_base:checks",
- "../rtc_base:rtc_base_approved",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
]
diff --git a/api/test/neteq_simulator_factory.cc b/api/test/neteq_simulator_factory.cc
index 64e9c5b..8bb0625 100644
--- a/api/test/neteq_simulator_factory.cc
+++ b/api/test/neteq_simulator_factory.cc
@@ -11,21 +11,25 @@
#include "api/test/neteq_simulator_factory.h"
#include <string>
+#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "modules/audio_coding/neteq/tools/neteq_test_factory.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
namespace {
-WEBRTC_DEFINE_string(replacement_audio_file,
- "",
- "A PCM file that will be used to populate dummy"
- " RTP packets");
-WEBRTC_DEFINE_int(max_nr_packets_in_buffer,
- 50,
- "Maximum allowed number of packets in the buffer");
+ABSL_FLAG(std::string,
+ replacement_audio_file,
+ "",
+ "A PCM file that will be used to populate dummy"
+ " RTP packets");
+ABSL_FLAG(int,
+ max_nr_packets_in_buffer,
+ 50,
+ "Maximum allowed number of packets in the buffer");
} // namespace
@@ -40,17 +44,17 @@
std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulator(
int argc,
char* argv[]) {
- RTC_CHECK(!rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true))
- << "Error while parsing command-line flags";
- RTC_CHECK_EQ(argc, 3) << "Wrong number of input arguments. Expected 3, got "
- << argc;
+ std::vector<char*> args = absl::ParseCommandLine(argc, argv);
+ RTC_CHECK_EQ(args.size(), 3)
+ << "Wrong number of input arguments. Expected 3, got " << args.size();
// TODO(ivoc) Stop (ab)using command-line flags in this function.
- const std::string output_audio_filename(argv[2]);
+ const std::string output_audio_filename(args[2]);
NetEqTestFactory::Config config;
- config.replacement_audio_file = FLAG_replacement_audio_file;
- config.max_nr_packets_in_buffer = FLAG_max_nr_packets_in_buffer;
+ config.replacement_audio_file = absl::GetFlag(FLAGS_replacement_audio_file);
+ config.max_nr_packets_in_buffer =
+ absl::GetFlag(FLAGS_max_nr_packets_in_buffer);
config.output_audio_filename = output_audio_filename;
- return factory_->InitializeTestFromFile(argv[1], config);
+ return factory_->InitializeTestFromFile(args[1], config);
}
std::unique_ptr<NetEqSimulator> NetEqSimulatorFactory::CreateSimulatorFromFile(
diff --git a/audio/BUILD.gn b/audio/BUILD.gn
index 0e78a68..cf8af3d 100644
--- a/audio/BUILD.gn
+++ b/audio/BUILD.gn
@@ -190,7 +190,6 @@
"../api:simulated_network_api",
"../call:simulated_network",
"../common_audio",
- "../rtc_base:rtc_base_approved",
"../system_wrappers",
"../test:fileutils",
"../test:perf_test",
@@ -199,7 +198,8 @@
"../test:test_support",
"../test/pc/e2e:network_quality_metrics_reporter",
"//testing/gtest",
- "//third_party/abseil-cpp/absl/memory:memory",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/memory",
]
if (is_android) {
deps += [ "//testing/android/native_test:native_test_native_code" ]
diff --git a/audio/test/low_bandwidth_audio_test.cc b/audio/test/low_bandwidth_audio_test.cc
index db1ff2c..049b5e5 100644
--- a/audio/test/low_bandwidth_audio_test.cc
+++ b/audio/test/low_bandwidth_audio_test.cc
@@ -8,21 +8,21 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "absl/flags/flag.h"
#include "api/test/simulated_network.h"
#include "audio/test/audio_end_to_end_test.h"
-#include "rtc_base/flags.h"
#include "system_wrappers/include/sleep.h"
#include "test/testsupport/file_utils.h"
-WEBRTC_DECLARE_int(sample_rate_hz);
-WEBRTC_DECLARE_bool(quick);
+ABSL_DECLARE_FLAG(int, sample_rate_hz);
+ABSL_DECLARE_FLAG(bool, quick);
namespace webrtc {
namespace test {
namespace {
std::string FileSampleRateSuffix() {
- return std::to_string(FLAG_sample_rate_hz / 1000);
+ return std::to_string(absl::GetFlag(FLAGS_sample_rate_hz) / 1000);
}
class AudioQualityTest : public AudioEndToEndTest {
@@ -48,11 +48,11 @@
std::unique_ptr<TestAudioDeviceModule::Renderer> CreateRenderer() override {
return TestAudioDeviceModule::CreateBoundedWavFileWriter(
- AudioOutputFile(), FLAG_sample_rate_hz);
+ AudioOutputFile(), absl::GetFlag(FLAGS_sample_rate_hz));
}
void PerformTest() override {
- if (FLAG_quick) {
+ if (absl::GetFlag(FLAGS_quick)) {
// Let the recording run for a small amount of time to check if it works.
SleepMs(1000);
} else {
diff --git a/audio/test/low_bandwidth_audio_test_flags.cc b/audio/test/low_bandwidth_audio_test_flags.cc
index a0f12c5..9d93790 100644
--- a/audio/test/low_bandwidth_audio_test_flags.cc
+++ b/audio/test/low_bandwidth_audio_test_flags.cc
@@ -10,18 +10,19 @@
// #ifndef AUDIO_TEST_LOW_BANDWIDTH_AUDIO_TEST_FLAGS_H_
// #define AUDIO_TEST_LOW_BANDWIDTH_AUDIO_TEST_FLAGS_H_
-#include "rtc_base/flags.h"
+#include "absl/flags/flag.h"
-WEBRTC_DEFINE_int(sample_rate_hz,
- 16000,
- "Sample rate (Hz) of the produced audio files.");
+ABSL_FLAG(int,
+ sample_rate_hz,
+ 16000,
+ "Sample rate (Hz) of the produced audio files.");
-WEBRTC_DEFINE_bool(
- quick,
- false,
- "Don't do the full audio recording. "
- "Used to quickly check that the test runs without crashing.");
+ABSL_FLAG(bool,
+ quick,
+ false,
+ "Don't do the full audio recording. "
+ "Used to quickly check that the test runs without crashing.");
-WEBRTC_DEFINE_string(test_case_prefix, "", "Test case prefix.");
+ABSL_FLAG(std::string, test_case_prefix, "", "Test case prefix.");
// #endif // AUDIO_TEST_LOW_BANDWIDTH_AUDIO_TEST_FLAGS_H_
diff --git a/audio/test/pc_low_bandwidth_audio_test.cc b/audio/test/pc_low_bandwidth_audio_test.cc
index 85ca04e..f2de6c9 100644
--- a/audio/test/pc_low_bandwidth_audio_test.cc
+++ b/audio/test/pc_low_bandwidth_audio_test.cc
@@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
+#include "absl/flags/flag.h"
#include "absl/memory/memory.h"
#include "api/test/create_network_emulation_manager.h"
#include "api/test/create_peerconnection_quality_test_fixture.h"
@@ -15,15 +16,14 @@
#include "api/test/peerconnection_quality_test_fixture.h"
#include "api/test/simulated_network.h"
#include "call/simulated_network.h"
-#include "rtc_base/flags.h"
#include "test/gtest.h"
#include "test/pc/e2e/network_quality_metrics_reporter.h"
#include "test/testsupport/file_utils.h"
#include "test/testsupport/perf_test.h"
-WEBRTC_DECLARE_string(test_case_prefix);
-WEBRTC_DECLARE_int(sample_rate_hz);
-WEBRTC_DECLARE_bool(quick);
+ABSL_DECLARE_FLAG(std::string, test_case_prefix);
+ABSL_DECLARE_FLAG(int, sample_rate_hz);
+ABSL_DECLARE_FLAG(bool, quick);
namespace webrtc {
namespace test {
@@ -42,11 +42,11 @@
std::string GetMetricTestCaseName() {
const ::testing::TestInfo* const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
- std::string test_case_prefix(FLAG_test_case_prefix);
+ std::string test_case_prefix(absl::GetFlag(FLAGS_test_case_prefix));
if (test_case_prefix.empty()) {
return test_info->name();
}
- return std::string(FLAG_test_case_prefix) + "_" + test_info->name();
+ return test_case_prefix + "_" + test_info->name();
}
std::pair<EmulatedNetworkManagerInterface*, EmulatedNetworkManagerInterface*>
@@ -87,7 +87,7 @@
}
std::string FileSampleRateSuffix() {
- return std::to_string(FLAG_sample_rate_hz / 1000);
+ return std::to_string(absl::GetFlag(FLAGS_sample_rate_hz) / 1000);
}
std::string AudioInputFile() {
@@ -135,12 +135,12 @@
audio.mode = AudioConfig::Mode::kFile;
audio.input_file_name = AudioInputFile();
audio.output_dump_file_name = AudioOutputFile();
- audio.sampling_frequency_in_hz = FLAG_sample_rate_hz;
+ audio.sampling_frequency_in_hz = absl::GetFlag(FLAGS_sample_rate_hz);
alice->SetAudioConfig(std::move(audio));
},
[](PeerConfigurer* bob) {});
- fixture->Run(RunParams(TimeDelta::seconds(FLAG_quick ? kQuickTestDurationSec
- : kTestDurationSec)));
+ fixture->Run(RunParams(TimeDelta::seconds(
+ absl::GetFlag(FLAGS_quick) ? kQuickTestDurationSec : kTestDurationSec)));
LogTestResults();
}
@@ -160,12 +160,12 @@
audio.mode = AudioConfig::Mode::kFile;
audio.input_file_name = AudioInputFile();
audio.output_dump_file_name = AudioOutputFile();
- audio.sampling_frequency_in_hz = FLAG_sample_rate_hz;
+ audio.sampling_frequency_in_hz = absl::GetFlag(FLAGS_sample_rate_hz);
alice->SetAudioConfig(std::move(audio));
},
[](PeerConfigurer* bob) {});
- fixture->Run(RunParams(TimeDelta::seconds(FLAG_quick ? kQuickTestDurationSec
- : kTestDurationSec)));
+ fixture->Run(RunParams(TimeDelta::seconds(
+ absl::GetFlag(FLAGS_quick) ? kQuickTestDurationSec : kTestDurationSec)));
LogTestResults();
}
diff --git a/call/BUILD.gn b/call/BUILD.gn
index b8c9d23..8c2f455 100644
--- a/call/BUILD.gn
+++ b/call/BUILD.gn
@@ -454,6 +454,7 @@
"../test:video_test_common",
"../video",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/memory",
]
}
diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc
index 914160e..0fc3627 100644
--- a/call/rampup_tests.cc
+++ b/call/rampup_tests.cc
@@ -12,6 +12,7 @@
#include <memory>
+#include "absl/flags/flag.h"
#include "absl/memory/memory.h"
#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/rtc_event_log_output_file.h"
@@ -19,7 +20,6 @@
#include "api/task_queue/task_queue_factory.h"
#include "call/fake_network_pipe.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/platform_thread.h"
#include "rtc_base/string_encode.h"
@@ -28,6 +28,11 @@
#include "test/gtest.h"
#include "test/testsupport/perf_test.h"
+ABSL_FLAG(std::string,
+ ramp_dump_name,
+ "",
+ "Filename for dumped received RTP stream.");
+
namespace webrtc {
namespace {
@@ -47,10 +52,6 @@
}
} // namespace
-WEBRTC_DEFINE_string(ramp_dump_name,
- "",
- "Filename for dumped received RTP stream.");
-
RampUpTester::RampUpTester(size_t num_video_streams,
size_t num_audio_streams,
size_t num_flexfec_streams,
@@ -583,7 +584,7 @@
RampUpTest()
: task_queue_factory_(CreateDefaultTaskQueueFactory()),
rtc_event_log_factory_(task_queue_factory_.get()) {
- std::string dump_name(FLAG_ramp_dump_name);
+ std::string dump_name(absl::GetFlag(FLAGS_ramp_dump_name));
if (!dump_name.empty()) {
send_event_log_ = rtc_event_log_factory_.CreateRtcEventLog(
RtcEventLog::EncodingType::Legacy);
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn
index 75ba75b..6cc9dc5 100644
--- a/modules/audio_coding/BUILD.gn
+++ b/modules/audio_coding/BUILD.gn
@@ -1593,10 +1593,10 @@
":neteq_test_tools",
"../../api/audio_codecs:builtin_audio_decoder_factory",
"../../rtc_base:checks",
- "../../rtc_base:rtc_base_approved",
"../../test:fileutils",
"../../test:test_support",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
]
}
@@ -1617,7 +1617,7 @@
"../../api/audio_codecs/ilbc:audio_encoder_ilbc",
"../../api/audio_codecs/isac:audio_encoder_isac",
"../../api/audio_codecs/opus:audio_encoder_opus",
- "../../rtc_base:rtc_base_approved",
+ "../../rtc_base:safe_conversions",
]
sources = [
@@ -1669,7 +1669,6 @@
":neteq",
":neteq_test_tools",
":pcm16b",
- "../../rtc_base:rtc_base_approved",
"//testing/gtest",
"//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/flags:parse",
@@ -1691,6 +1690,7 @@
"../../rtc_base:rtc_base_approved",
"../../test:test_main",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
]
}
@@ -1704,8 +1704,10 @@
deps = [
":neteq",
":neteq_test_support",
- "../../rtc_base:rtc_base_approved",
+ "../../rtc_base:checks",
"../../test:test_support",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
]
}
@@ -1726,6 +1728,7 @@
"../../test:fileutils",
"../../test:test_main",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
]
}
@@ -1743,6 +1746,7 @@
"../../rtc_base:rtc_base_approved",
"../../test:test_main",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
]
}
@@ -1762,6 +1766,7 @@
"../../test:fileutils",
"../../test:test_main",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
]
}
@@ -1781,6 +1786,7 @@
"../../test:fileutils",
"../../test:test_main",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
]
}
@@ -2047,6 +2053,7 @@
"codecs/opus/test",
"codecs/opus/test:test_unittest",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
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");
diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn
index 7354447..9e8fab4 100644
--- a/modules/audio_mixer/BUILD.gn
+++ b/modules/audio_mixer/BUILD.gn
@@ -130,7 +130,9 @@
":audio_mixer_impl",
"../../api/audio:audio_mixer_api",
"../../common_audio",
- "../../rtc_base:rtc_base_approved",
+ "../../rtc_base:stringutils",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
]
}
}
diff --git a/modules/audio_mixer/audio_mixer_test.cc b/modules/audio_mixer/audio_mixer_test.cc
index a8e1c23..816d229 100644
--- a/modules/audio_mixer/audio_mixer_test.cc
+++ b/modules/audio_mixer/audio_mixer_test.cc
@@ -14,31 +14,32 @@
#include <iostream>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "common_audio/wav_file.h"
#include "modules/audio_mixer/audio_mixer_impl.h"
#include "modules/audio_mixer/default_output_rate_calculator.h"
-#include "rtc_base/flags.h"
#include "rtc_base/strings/string_builder.h"
-WEBRTC_DEFINE_bool(help, false, "Prints this message");
-WEBRTC_DEFINE_int(
- sampling_rate,
- 16000,
- "Rate at which to mix (all input streams must have this rate)");
+ABSL_FLAG(int,
+ sampling_rate,
+ 16000,
+ "Rate at which to mix (all input streams must have this rate)");
-WEBRTC_DEFINE_bool(
- stereo,
- false,
- "Enable stereo (interleaved). Inputs need not be as this parameter.");
+ABSL_FLAG(bool,
+ stereo,
+ false,
+ "Enable stereo (interleaved). Inputs need not be as this parameter.");
-WEBRTC_DEFINE_bool(limiter, true, "Enable limiter.");
-WEBRTC_DEFINE_string(output_file,
- "mixed_file.wav",
- "File in which to store the mixed result.");
-WEBRTC_DEFINE_string(input_file_1, "", "First input. Default none.");
-WEBRTC_DEFINE_string(input_file_2, "", "Second input. Default none.");
-WEBRTC_DEFINE_string(input_file_3, "", "Third input. Default none.");
-WEBRTC_DEFINE_string(input_file_4, "", "Fourth input. Default none.");
+ABSL_FLAG(bool, limiter, true, "Enable limiter.");
+ABSL_FLAG(std::string,
+ output_file,
+ "mixed_file.wav",
+ "File in which to store the mixed result.");
+ABSL_FLAG(std::string, input_file_1, "", "First input. Default none.");
+ABSL_FLAG(std::string, input_file_2, "", "Second input. Default none.");
+ABSL_FLAG(std::string, input_file_3, "", "Third input. Default none.");
+ABSL_FLAG(std::string, input_file_4, "", "Fourth input. Default none.");
namespace webrtc {
namespace test {
@@ -97,9 +98,10 @@
const std::vector<std::string> parse_input_files() {
std::vector<std::string> result;
- for (auto* x : {FLAG_input_file_1, FLAG_input_file_2, FLAG_input_file_3,
- FLAG_input_file_4}) {
- if (strcmp(x, "") != 0) {
+ for (auto& x :
+ {absl::GetFlag(FLAGS_input_file_1), absl::GetFlag(FLAGS_input_file_2),
+ absl::GetFlag(FLAGS_input_file_3), absl::GetFlag(FLAGS_input_file_4)}) {
+ if (!x.empty()) {
result.push_back(x);
}
}
@@ -108,21 +110,17 @@
} // namespace
int main(int argc, char* argv[]) {
- rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, false);
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
+ absl::ParseCommandLine(argc, argv);
rtc::scoped_refptr<webrtc::AudioMixerImpl> mixer(
webrtc::AudioMixerImpl::Create(
std::unique_ptr<webrtc::OutputRateCalculator>(
new webrtc::DefaultOutputRateCalculator()),
- FLAG_limiter));
+ absl::GetFlag(FLAGS_limiter)));
const std::vector<std::string> input_files = parse_input_files();
std::vector<webrtc::test::FilePlayingSource> sources;
- const int num_channels = FLAG_stereo ? 2 : 1;
+ const int num_channels = absl::GetFlag(FLAGS_stereo) ? 2 : 1;
sources.reserve(input_files.size());
for (const auto& input_file : input_files) {
sources.emplace_back(input_file);
@@ -135,7 +133,6 @@
if (sources.empty()) {
std::cout << "Need at least one source!\n";
- rtc::FlagList::Print(nullptr, false);
return 1;
}
@@ -145,7 +142,8 @@
}
// Print stats.
- std::cout << "Limiting is: " << (FLAG_limiter ? "on" : "off") << "\n"
+ std::cout << "Limiting is: " << (absl::GetFlag(FLAGS_limiter) ? "on" : "off")
+ << "\n"
<< "Channels: " << num_channels << "\n"
<< "Rate: " << sample_rate << "\n"
<< "Number of input streams: " << input_files.size() << "\n";
@@ -154,7 +152,8 @@
}
std::cout << "Now mixing\n...\n";
- webrtc::WavWriter wav_writer(FLAG_output_file, sample_rate, num_channels);
+ webrtc::WavWriter wav_writer(absl::GetFlag(FLAGS_output_file), sample_rate,
+ num_channels);
webrtc::AudioFrame frame;
diff --git a/modules/audio_processing/BUILD.gn b/modules/audio_processing/BUILD.gn
index 488099a..4b1b46d 100644
--- a/modules/audio_processing/BUILD.gn
+++ b/modules/audio_processing/BUILD.gn
@@ -641,6 +641,8 @@
"aec_dump",
"aec_dump:aec_dump_impl",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional",
@@ -713,6 +715,8 @@
"../../test:test_support",
"agc:level_estimation",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
]
}
diff --git a/modules/audio_processing/test/audioproc_float_impl.cc b/modules/audio_processing/test/audioproc_float_impl.cc
index 6b94a07..3764282 100644
--- a/modules/audio_processing/test/audioproc_float_impl.cc
+++ b/modules/audio_processing/test/audioproc_float_impl.cc
@@ -18,21 +18,253 @@
#include <utility>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/strings/string_view.h"
#include "modules/audio_processing/include/audio_processing.h"
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
#include "modules/audio_processing/test/audio_processing_simulator.h"
#include "modules/audio_processing/test/wav_based_simulator.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/strings/string_builder.h"
+constexpr int kParameterNotSpecifiedValue = -10000;
+
+ABSL_FLAG(std::string, dump_input, "", "Aec dump input filename");
+ABSL_FLAG(std::string, dump_output, "", "Aec dump output filename");
+ABSL_FLAG(std::string, i, "", "Forward stream input wav filename");
+ABSL_FLAG(std::string, o, "", "Forward stream output wav filename");
+ABSL_FLAG(std::string, ri, "", "Reverse stream input wav filename");
+ABSL_FLAG(std::string, ro, "", "Reverse stream output wav filename");
+ABSL_FLAG(std::string,
+ artificial_nearend,
+ "",
+ "Artificial nearend wav filename");
+ABSL_FLAG(int,
+ output_num_channels,
+ kParameterNotSpecifiedValue,
+ "Number of forward stream output channels");
+ABSL_FLAG(int,
+ reverse_output_num_channels,
+ kParameterNotSpecifiedValue,
+ "Number of Reverse stream output channels");
+ABSL_FLAG(int,
+ output_sample_rate_hz,
+ kParameterNotSpecifiedValue,
+ "Forward stream output sample rate in Hz");
+ABSL_FLAG(int,
+ reverse_output_sample_rate_hz,
+ kParameterNotSpecifiedValue,
+ "Reverse stream output sample rate in Hz");
+ABSL_FLAG(bool,
+ fixed_interface,
+ false,
+ "Use the fixed interface when operating on wav files");
+ABSL_FLAG(int,
+ aec,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the echo canceller");
+ABSL_FLAG(int,
+ aecm,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the mobile echo controller");
+ABSL_FLAG(int,
+ ed,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate (0) the residual echo detector");
+ABSL_FLAG(std::string,
+ ed_graph,
+ "",
+ "Output filename for graph of echo likelihood");
+ABSL_FLAG(int,
+ agc,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the AGC");
+ABSL_FLAG(int,
+ agc2,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the AGC2");
+ABSL_FLAG(int,
+ pre_amplifier,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the pre amplifier");
+ABSL_FLAG(int,
+ hpf,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the high-pass filter");
+ABSL_FLAG(int,
+ ns,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the noise suppressor");
+ABSL_FLAG(int,
+ ts,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the transient suppressor");
+ABSL_FLAG(int,
+ vad,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the voice activity detector");
+ABSL_FLAG(int,
+ le,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the level estimator");
+ABSL_FLAG(bool,
+ all_default,
+ false,
+ "Activate all of the default components (will be overridden by any "
+ "other settings)");
+ABSL_FLAG(int,
+ aec_suppression_level,
+ kParameterNotSpecifiedValue,
+ "Set the aec suppression level (0-2)");
+ABSL_FLAG(int,
+ delay_agnostic,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the AEC delay agnostic mode");
+ABSL_FLAG(int,
+ extended_filter,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the AEC extended filter mode");
+ABSL_FLAG(int,
+ use_legacy_aec,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the legacy AEC");
+ABSL_FLAG(int,
+ experimental_agc,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the experimental AGC");
+ABSL_FLAG(int,
+ experimental_agc_disable_digital_adaptive,
+ kParameterNotSpecifiedValue,
+ "Force-deactivate (1) digital adaptation in "
+ "experimental AGC. Digital adaptation is active by default (0).");
+ABSL_FLAG(int,
+ experimental_agc_analyze_before_aec,
+ kParameterNotSpecifiedValue,
+ "Make level estimation happen before AEC"
+ " in the experimental AGC. After AEC is the default (0)");
+ABSL_FLAG(int,
+ experimental_agc_agc2_level_estimator,
+ kParameterNotSpecifiedValue,
+ "AGC2 level estimation"
+ " in the experimental AGC. AGC1 level estimation is the default (0)");
+ABSL_FLAG(
+ int,
+ refined_adaptive_filter,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the refined adaptive filter functionality");
+ABSL_FLAG(int,
+ agc_mode,
+ kParameterNotSpecifiedValue,
+ "Specify the AGC mode (0-2)");
+ABSL_FLAG(int,
+ agc_target_level,
+ kParameterNotSpecifiedValue,
+ "Specify the AGC target level (0-31)");
+ABSL_FLAG(int,
+ agc_limiter,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the level estimator");
+ABSL_FLAG(int,
+ agc_compression_gain,
+ kParameterNotSpecifiedValue,
+ "Specify the AGC compression gain (0-90)");
+ABSL_FLAG(int,
+ agc2_enable_adaptive_gain,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) the AGC2 adaptive gain");
+ABSL_FLAG(float,
+ agc2_fixed_gain_db,
+ kParameterNotSpecifiedValue,
+ "AGC2 fixed gain (dB) to apply");
+ABSL_FLAG(std::string,
+ agc2_adaptive_level_estimator,
+ "RMS",
+ "AGC2 adaptive digital level estimator to use [RMS, peak]");
+ABSL_FLAG(float,
+ pre_amplifier_gain_factor,
+ kParameterNotSpecifiedValue,
+ "Pre-amplifier gain factor (linear) to apply");
+ABSL_FLAG(int,
+ vad_likelihood,
+ kParameterNotSpecifiedValue,
+ "Specify the VAD likelihood (0-3)");
+ABSL_FLAG(int,
+ ns_level,
+ kParameterNotSpecifiedValue,
+ "Specify the NS level (0-3)");
+ABSL_FLAG(int,
+ stream_delay,
+ kParameterNotSpecifiedValue,
+ "Specify the stream delay in ms to use");
+ABSL_FLAG(int,
+ use_stream_delay,
+ kParameterNotSpecifiedValue,
+ "Activate (1) or deactivate(0) reporting the stream delay");
+ABSL_FLAG(int,
+ stream_drift_samples,
+ kParameterNotSpecifiedValue,
+ "Specify the number of stream drift samples to use");
+ABSL_FLAG(int, initial_mic_level, 100, "Initial mic level (0-255)");
+ABSL_FLAG(int,
+ simulate_mic_gain,
+ 0,
+ "Activate (1) or deactivate(0) the analog mic gain simulation");
+ABSL_FLAG(int,
+ simulated_mic_kind,
+ kParameterNotSpecifiedValue,
+ "Specify which microphone kind to use for microphone simulation");
+ABSL_FLAG(bool, performance_report, false, "Report the APM performance ");
+ABSL_FLAG(std::string,
+ performance_report_output_file,
+ "",
+ "Generate a CSV file with the API call durations");
+ABSL_FLAG(bool, verbose, false, "Produce verbose output");
+ABSL_FLAG(bool,
+ quiet,
+ false,
+ "Avoid producing information about the progress.");
+ABSL_FLAG(bool,
+ bitexactness_report,
+ false,
+ "Report bitexactness for aec dump result reproduction");
+ABSL_FLAG(bool,
+ discard_settings_in_aecdump,
+ false,
+ "Discard any config settings specified in the aec dump");
+ABSL_FLAG(bool,
+ store_intermediate_output,
+ false,
+ "Creates new output files after each init");
+ABSL_FLAG(std::string,
+ custom_call_order_file,
+ "",
+ "Custom process API call order file");
+ABSL_FLAG(std::string,
+ output_custom_call_order_file,
+ "",
+ "Generate custom process API call order file from AEC dump");
+ABSL_FLAG(bool,
+ print_aec_parameter_values,
+ false,
+ "Print parameter values used in AEC in JSON-format");
+ABSL_FLAG(std::string,
+ aec_settings,
+ "",
+ "File in JSON-format with custom AEC settings");
+ABSL_FLAG(bool,
+ dump_data,
+ false,
+ "Dump internal data during the call (requires build flag)");
+ABSL_FLAG(std::string,
+ dump_data_output_dir,
+ "",
+ "Internal data dump output directory");
+
namespace webrtc {
namespace test {
namespace {
-const int kParameterNotSpecifiedValue = -10000;
-
const char kUsageDescription[] =
"Usage: audioproc_f [options] -i <input.wav>\n"
" or\n"
@@ -42,194 +274,9 @@
"processing module, either based on wav files or "
"protobuf debug dump recordings.\n";
-WEBRTC_DEFINE_string(dump_input, "", "Aec dump input filename");
-WEBRTC_DEFINE_string(dump_output, "", "Aec dump output filename");
-WEBRTC_DEFINE_string(i, "", "Forward stream input wav filename");
-WEBRTC_DEFINE_string(o, "", "Forward stream output wav filename");
-WEBRTC_DEFINE_string(ri, "", "Reverse stream input wav filename");
-WEBRTC_DEFINE_string(ro, "", "Reverse stream output wav filename");
-WEBRTC_DEFINE_string(artificial_nearend, "", "Artificial nearend wav filename");
-WEBRTC_DEFINE_int(output_num_channels,
- kParameterNotSpecifiedValue,
- "Number of forward stream output channels");
-WEBRTC_DEFINE_int(reverse_output_num_channels,
- kParameterNotSpecifiedValue,
- "Number of Reverse stream output channels");
-WEBRTC_DEFINE_int(output_sample_rate_hz,
- kParameterNotSpecifiedValue,
- "Forward stream output sample rate in Hz");
-WEBRTC_DEFINE_int(reverse_output_sample_rate_hz,
- kParameterNotSpecifiedValue,
- "Reverse stream output sample rate in Hz");
-WEBRTC_DEFINE_bool(fixed_interface,
- false,
- "Use the fixed interface when operating on wav files");
-WEBRTC_DEFINE_int(aec,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the echo canceller");
-WEBRTC_DEFINE_int(aecm,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the mobile echo controller");
-WEBRTC_DEFINE_int(ed,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate (0) the residual echo detector");
-WEBRTC_DEFINE_string(ed_graph,
- "",
- "Output filename for graph of echo likelihood");
-WEBRTC_DEFINE_int(agc,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the AGC");
-WEBRTC_DEFINE_int(agc2,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the AGC2");
-WEBRTC_DEFINE_int(pre_amplifier,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the pre amplifier");
-WEBRTC_DEFINE_int(hpf,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the high-pass filter");
-WEBRTC_DEFINE_int(ns,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the noise suppressor");
-WEBRTC_DEFINE_int(ts,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the transient suppressor");
-WEBRTC_DEFINE_int(vad,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the voice activity detector");
-WEBRTC_DEFINE_int(le,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the level estimator");
-WEBRTC_DEFINE_bool(
- all_default,
- false,
- "Activate all of the default components (will be overridden by any "
- "other settings)");
-WEBRTC_DEFINE_int(aec_suppression_level,
- kParameterNotSpecifiedValue,
- "Set the aec suppression level (0-2)");
-WEBRTC_DEFINE_int(delay_agnostic,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the AEC delay agnostic mode");
-WEBRTC_DEFINE_int(extended_filter,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the AEC extended filter mode");
-WEBRTC_DEFINE_int(use_legacy_aec,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the legacy AEC");
-WEBRTC_DEFINE_int(experimental_agc,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the experimental AGC");
-WEBRTC_DEFINE_int(
- experimental_agc_disable_digital_adaptive,
- kParameterNotSpecifiedValue,
- "Force-deactivate (1) digital adaptation in "
- "experimental AGC. Digital adaptation is active by default (0).");
-WEBRTC_DEFINE_int(experimental_agc_analyze_before_aec,
- kParameterNotSpecifiedValue,
- "Make level estimation happen before AEC"
- " in the experimental AGC. After AEC is the default (0)");
-WEBRTC_DEFINE_int(
- experimental_agc_agc2_level_estimator,
- kParameterNotSpecifiedValue,
- "AGC2 level estimation"
- " in the experimental AGC. AGC1 level estimation is the default (0)");
-WEBRTC_DEFINE_int(
- refined_adaptive_filter,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the refined adaptive filter functionality");
-WEBRTC_DEFINE_int(agc_mode,
- kParameterNotSpecifiedValue,
- "Specify the AGC mode (0-2)");
-WEBRTC_DEFINE_int(agc_target_level,
- kParameterNotSpecifiedValue,
- "Specify the AGC target level (0-31)");
-WEBRTC_DEFINE_int(agc_limiter,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the level estimator");
-WEBRTC_DEFINE_int(agc_compression_gain,
- kParameterNotSpecifiedValue,
- "Specify the AGC compression gain (0-90)");
-WEBRTC_DEFINE_int(agc2_enable_adaptive_gain,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) the AGC2 adaptive gain");
-WEBRTC_DEFINE_float(agc2_fixed_gain_db,
- kParameterNotSpecifiedValue,
- "AGC2 fixed gain (dB) to apply");
-
std::vector<std::string> GetAgc2AdaptiveLevelEstimatorNames() {
return {"RMS", "peak"};
}
-WEBRTC_DEFINE_string(
- agc2_adaptive_level_estimator,
- "RMS",
- "AGC2 adaptive digital level estimator to use [RMS, peak]");
-
-WEBRTC_DEFINE_float(pre_amplifier_gain_factor,
- kParameterNotSpecifiedValue,
- "Pre-amplifier gain factor (linear) to apply");
-WEBRTC_DEFINE_int(vad_likelihood,
- kParameterNotSpecifiedValue,
- "Specify the VAD likelihood (0-3)");
-WEBRTC_DEFINE_int(ns_level,
- kParameterNotSpecifiedValue,
- "Specify the NS level (0-3)");
-WEBRTC_DEFINE_int(stream_delay,
- kParameterNotSpecifiedValue,
- "Specify the stream delay in ms to use");
-WEBRTC_DEFINE_int(use_stream_delay,
- kParameterNotSpecifiedValue,
- "Activate (1) or deactivate(0) reporting the stream delay");
-WEBRTC_DEFINE_int(stream_drift_samples,
- kParameterNotSpecifiedValue,
- "Specify the number of stream drift samples to use");
-WEBRTC_DEFINE_int(initial_mic_level, 100, "Initial mic level (0-255)");
-WEBRTC_DEFINE_int(
- simulate_mic_gain,
- 0,
- "Activate (1) or deactivate(0) the analog mic gain simulation");
-WEBRTC_DEFINE_int(
- simulated_mic_kind,
- kParameterNotSpecifiedValue,
- "Specify which microphone kind to use for microphone simulation");
-WEBRTC_DEFINE_bool(performance_report, false, "Report the APM performance ");
-WEBRTC_DEFINE_string(performance_report_output_file,
- "",
- "Generate a CSV file with the API call durations");
-
-WEBRTC_DEFINE_bool(verbose, false, "Produce verbose output");
-WEBRTC_DEFINE_bool(quiet,
- false,
- "Avoid producing information about the progress.");
-WEBRTC_DEFINE_bool(bitexactness_report,
- false,
- "Report bitexactness for aec dump result reproduction");
-WEBRTC_DEFINE_bool(discard_settings_in_aecdump,
- false,
- "Discard any config settings specified in the aec dump");
-WEBRTC_DEFINE_bool(store_intermediate_output,
- false,
- "Creates new output files after each init");
-WEBRTC_DEFINE_string(custom_call_order_file,
- "",
- "Custom process API call order file");
-WEBRTC_DEFINE_string(
- output_custom_call_order_file,
- "",
- "Generate custom process API call order file from AEC dump");
-WEBRTC_DEFINE_bool(print_aec_parameter_values,
- false,
- "Print parameter values used in AEC in JSON-format");
-WEBRTC_DEFINE_string(aec_settings,
- "",
- "File in JSON-format with custom AEC settings");
-WEBRTC_DEFINE_bool(dump_data,
- false,
- "Dump internal data during the call (requires build flag)");
-WEBRTC_DEFINE_string(dump_data_output_dir,
- "",
- "Internal data dump output directory");
-WEBRTC_DEFINE_bool(help, false, "Print this message");
void SetSettingIfSpecified(const std::string& value,
absl::optional<std::string>* parameter) {
@@ -283,7 +330,7 @@
SimulationSettings CreateSettings() {
SimulationSettings settings;
- if (FLAG_all_default) {
+ if (absl::GetFlag(FLAGS_all_default)) {
settings.use_le = true;
settings.use_vad = true;
settings.use_ie = false;
@@ -297,87 +344,110 @@
settings.use_aecm = false;
settings.use_ed = false;
}
- SetSettingIfSpecified(FLAG_dump_input, &settings.aec_dump_input_filename);
- SetSettingIfSpecified(FLAG_dump_output, &settings.aec_dump_output_filename);
- SetSettingIfSpecified(FLAG_i, &settings.input_filename);
- SetSettingIfSpecified(FLAG_o, &settings.output_filename);
- SetSettingIfSpecified(FLAG_ri, &settings.reverse_input_filename);
- SetSettingIfSpecified(FLAG_ro, &settings.reverse_output_filename);
- SetSettingIfSpecified(FLAG_artificial_nearend,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_input),
+ &settings.aec_dump_input_filename);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_output),
+ &settings.aec_dump_output_filename);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_i), &settings.input_filename);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_o), &settings.output_filename);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_ri),
+ &settings.reverse_input_filename);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_ro),
+ &settings.reverse_output_filename);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_artificial_nearend),
&settings.artificial_nearend_filename);
- SetSettingIfSpecified(FLAG_output_num_channels,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_output_num_channels),
&settings.output_num_channels);
- SetSettingIfSpecified(FLAG_reverse_output_num_channels,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_reverse_output_num_channels),
&settings.reverse_output_num_channels);
- SetSettingIfSpecified(FLAG_output_sample_rate_hz,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_output_sample_rate_hz),
&settings.output_sample_rate_hz);
- SetSettingIfSpecified(FLAG_reverse_output_sample_rate_hz,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_reverse_output_sample_rate_hz),
&settings.reverse_output_sample_rate_hz);
- SetSettingIfFlagSet(FLAG_aec, &settings.use_aec);
- SetSettingIfFlagSet(FLAG_aecm, &settings.use_aecm);
- SetSettingIfFlagSet(FLAG_ed, &settings.use_ed);
- SetSettingIfSpecified(FLAG_ed_graph, &settings.ed_graph_output_filename);
- SetSettingIfFlagSet(FLAG_agc, &settings.use_agc);
- SetSettingIfFlagSet(FLAG_agc2, &settings.use_agc2);
- SetSettingIfFlagSet(FLAG_pre_amplifier, &settings.use_pre_amplifier);
- SetSettingIfFlagSet(FLAG_hpf, &settings.use_hpf);
- SetSettingIfFlagSet(FLAG_ns, &settings.use_ns);
- SetSettingIfFlagSet(FLAG_ts, &settings.use_ts);
- SetSettingIfFlagSet(FLAG_vad, &settings.use_vad);
- SetSettingIfFlagSet(FLAG_le, &settings.use_le);
- SetSettingIfSpecified(FLAG_aec_suppression_level,
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_aec), &settings.use_aec);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_aecm), &settings.use_aecm);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_ed), &settings.use_ed);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_ed_graph),
+ &settings.ed_graph_output_filename);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc), &settings.use_agc);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc2), &settings.use_agc2);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_pre_amplifier),
+ &settings.use_pre_amplifier);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_hpf), &settings.use_hpf);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_ns), &settings.use_ns);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_ts), &settings.use_ts);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_vad), &settings.use_vad);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_le), &settings.use_le);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_aec_suppression_level),
&settings.aec_suppression_level);
- SetSettingIfFlagSet(FLAG_delay_agnostic, &settings.use_delay_agnostic);
- SetSettingIfFlagSet(FLAG_extended_filter, &settings.use_extended_filter);
- SetSettingIfFlagSet(FLAG_refined_adaptive_filter,
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_delay_agnostic),
+ &settings.use_delay_agnostic);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_extended_filter),
+ &settings.use_extended_filter);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_refined_adaptive_filter),
&settings.use_refined_adaptive_filter);
- SetSettingIfFlagSet(FLAG_use_legacy_aec, &settings.use_legacy_aec);
- SetSettingIfFlagSet(FLAG_experimental_agc, &settings.use_experimental_agc);
- SetSettingIfFlagSet(FLAG_experimental_agc_disable_digital_adaptive,
- &settings.experimental_agc_disable_digital_adaptive);
- SetSettingIfFlagSet(FLAG_experimental_agc_analyze_before_aec,
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_use_legacy_aec),
+ &settings.use_legacy_aec);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_agc),
+ &settings.use_experimental_agc);
+ SetSettingIfFlagSet(
+ absl::GetFlag(FLAGS_experimental_agc_disable_digital_adaptive),
+ &settings.experimental_agc_disable_digital_adaptive);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_experimental_agc_analyze_before_aec),
&settings.experimental_agc_analyze_before_aec);
- SetSettingIfFlagSet(FLAG_experimental_agc_agc2_level_estimator,
- &settings.use_experimental_agc_agc2_level_estimator);
- SetSettingIfSpecified(FLAG_agc_mode, &settings.agc_mode);
- SetSettingIfSpecified(FLAG_agc_target_level, &settings.agc_target_level);
- SetSettingIfFlagSet(FLAG_agc_limiter, &settings.use_agc_limiter);
- SetSettingIfSpecified(FLAG_agc_compression_gain,
+ SetSettingIfFlagSet(
+ absl::GetFlag(FLAGS_experimental_agc_agc2_level_estimator),
+ &settings.use_experimental_agc_agc2_level_estimator);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_mode), &settings.agc_mode);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_target_level),
+ &settings.agc_target_level);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc_limiter),
+ &settings.use_agc_limiter);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_agc_compression_gain),
&settings.agc_compression_gain);
- SetSettingIfFlagSet(FLAG_agc2_enable_adaptive_gain,
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_agc2_enable_adaptive_gain),
&settings.agc2_use_adaptive_gain);
- SetSettingIfSpecified(FLAG_agc2_fixed_gain_db, &settings.agc2_fixed_gain_db);
- settings.agc2_adaptive_level_estimator =
- MapAgc2AdaptiveLevelEstimator(FLAG_agc2_adaptive_level_estimator);
- SetSettingIfSpecified(FLAG_pre_amplifier_gain_factor,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_agc2_fixed_gain_db),
+ &settings.agc2_fixed_gain_db);
+ settings.agc2_adaptive_level_estimator = MapAgc2AdaptiveLevelEstimator(
+ absl::GetFlag(FLAGS_agc2_adaptive_level_estimator));
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_pre_amplifier_gain_factor),
&settings.pre_amplifier_gain_factor);
- SetSettingIfSpecified(FLAG_vad_likelihood, &settings.vad_likelihood);
- SetSettingIfSpecified(FLAG_ns_level, &settings.ns_level);
- SetSettingIfSpecified(FLAG_stream_delay, &settings.stream_delay);
- SetSettingIfFlagSet(FLAG_use_stream_delay, &settings.use_stream_delay);
- SetSettingIfSpecified(FLAG_stream_drift_samples,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_vad_likelihood),
+ &settings.vad_likelihood);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_ns_level), &settings.ns_level);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_stream_delay),
+ &settings.stream_delay);
+ SetSettingIfFlagSet(absl::GetFlag(FLAGS_use_stream_delay),
+ &settings.use_stream_delay);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_stream_drift_samples),
&settings.stream_drift_samples);
- SetSettingIfSpecified(FLAG_custom_call_order_file,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_custom_call_order_file),
&settings.call_order_input_filename);
- SetSettingIfSpecified(FLAG_output_custom_call_order_file,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_output_custom_call_order_file),
&settings.call_order_output_filename);
- SetSettingIfSpecified(FLAG_aec_settings, &settings.aec_settings_filename);
- settings.initial_mic_level = FLAG_initial_mic_level;
- settings.simulate_mic_gain = FLAG_simulate_mic_gain;
- SetSettingIfSpecified(FLAG_simulated_mic_kind, &settings.simulated_mic_kind);
- settings.report_performance = FLAG_performance_report;
- SetSettingIfSpecified(FLAG_performance_report_output_file,
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_aec_settings),
+ &settings.aec_settings_filename);
+ settings.initial_mic_level = absl::GetFlag(FLAGS_initial_mic_level);
+ settings.simulate_mic_gain = absl::GetFlag(FLAGS_simulate_mic_gain);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_simulated_mic_kind),
+ &settings.simulated_mic_kind);
+ settings.report_performance = absl::GetFlag(FLAGS_performance_report);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_performance_report_output_file),
&settings.performance_report_output_filename);
- settings.use_verbose_logging = FLAG_verbose;
- settings.use_quiet_output = FLAG_quiet;
- settings.report_bitexactness = FLAG_bitexactness_report;
- settings.discard_all_settings_in_aecdump = FLAG_discard_settings_in_aecdump;
- settings.fixed_interface = FLAG_fixed_interface;
- settings.store_intermediate_output = FLAG_store_intermediate_output;
- settings.print_aec_parameter_values = FLAG_print_aec_parameter_values;
- settings.dump_internal_data = FLAG_dump_data;
- SetSettingIfSpecified(FLAG_dump_data_output_dir,
+ settings.use_verbose_logging = absl::GetFlag(FLAGS_verbose);
+ settings.use_quiet_output = absl::GetFlag(FLAGS_quiet);
+ settings.report_bitexactness = absl::GetFlag(FLAGS_bitexactness_report);
+ settings.discard_all_settings_in_aecdump =
+ absl::GetFlag(FLAGS_discard_settings_in_aecdump);
+ settings.fixed_interface = absl::GetFlag(FLAGS_fixed_interface);
+ settings.store_intermediate_output =
+ absl::GetFlag(FLAGS_store_intermediate_output);
+ settings.print_aec_parameter_values =
+ absl::GetFlag(FLAGS_print_aec_parameter_values);
+ settings.dump_internal_data = absl::GetFlag(FLAGS_dump_data);
+ SetSettingIfSpecified(absl::GetFlag(FLAGS_dump_data_output_dir),
&settings.dump_internal_data_output_dir);
return settings;
@@ -555,13 +625,9 @@
int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder,
int argc,
char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
- argc != 1) {
+ std::vector<char*> args = absl::ParseCommandLine(argc, argv);
+ if (args.size() != 1) {
printf("%s", kUsageDescription);
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
return 1;
}
diff --git a/modules/audio_processing/test/conversational_speech/BUILD.gn b/modules/audio_processing/test/conversational_speech/BUILD.gn
index 282591b..7a278a3 100644
--- a/modules/audio_processing/test/conversational_speech/BUILD.gn
+++ b/modules/audio_processing/test/conversational_speech/BUILD.gn
@@ -22,9 +22,10 @@
]
deps = [
":lib",
- "../../../../rtc_base:rtc_base_approved",
"../../../../test:fileutils",
"../../../../test:test_support",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
]
}
diff --git a/modules/audio_processing/test/conversational_speech/generator.cc b/modules/audio_processing/test/conversational_speech/generator.cc
index 04c0678..abbea8c 100644
--- a/modules/audio_processing/test/conversational_speech/generator.cc
+++ b/modules/audio_processing/test/conversational_speech/generator.cc
@@ -9,16 +9,22 @@
*/
#include <iostream>
+#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "modules/audio_processing/test/conversational_speech/config.h"
#include "modules/audio_processing/test/conversational_speech/multiend_call.h"
#include "modules/audio_processing/test/conversational_speech/simulator.h"
#include "modules/audio_processing/test/conversational_speech/timing.h"
#include "modules/audio_processing/test/conversational_speech/wavreader_factory.h"
-#include "rtc_base/flags.h"
#include "test/testsupport/file_utils.h"
+ABSL_FLAG(std::string, i, "", "Directory containing the speech turn wav files");
+ABSL_FLAG(std::string, t, "", "Path to the timing text file");
+ABSL_FLAG(std::string, o, "", "Output wav files destination path");
+
namespace webrtc {
namespace test {
namespace {
@@ -32,28 +38,20 @@
"Command-line tool to generate multiple-end audio tracks to simulate "
"conversational speech with two or more participants.\n";
-WEBRTC_DEFINE_string(i, "", "Directory containing the speech turn wav files");
-WEBRTC_DEFINE_string(t, "", "Path to the timing text file");
-WEBRTC_DEFINE_string(o, "", "Output wav files destination path");
-WEBRTC_DEFINE_bool(help, false, "Prints this message");
-
} // namespace
int main(int argc, char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
- argc != 1) {
+ std::vector<char*> args = absl::ParseCommandLine(argc, argv);
+ if (args.size() != 1) {
printf("%s", kUsageDescription);
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
return 1;
}
- RTC_CHECK(DirExists(FLAG_i));
- RTC_CHECK(FileExists(FLAG_t));
- RTC_CHECK(DirExists(FLAG_o));
+ RTC_CHECK(DirExists(absl::GetFlag(FLAGS_i)));
+ RTC_CHECK(FileExists(absl::GetFlag(FLAGS_t)));
+ RTC_CHECK(DirExists(absl::GetFlag(FLAGS_o)));
- conversational_speech::Config config(FLAG_i, FLAG_t, FLAG_o);
+ conversational_speech::Config config(
+ absl::GetFlag(FLAGS_i), absl::GetFlag(FLAGS_t), absl::GetFlag(FLAGS_o));
// Load timing.
std::vector<conversational_speech::Turn> timing =
diff --git a/modules/audio_processing/transient/transient_suppression_test.cc b/modules/audio_processing/transient/transient_suppression_test.cc
index 85db391..7a2f6a3 100644
--- a/modules/audio_processing/transient/transient_suppression_test.cc
+++ b/modules/audio_processing/transient/transient_suppression_test.cc
@@ -14,36 +14,41 @@
#include <memory>
#include <string>
+#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "common_audio/include/audio_util.h"
#include "modules/audio_processing/agc/agc.h"
#include "modules/audio_processing/transient/transient_suppressor.h"
-#include "rtc_base/flags.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
-WEBRTC_DEFINE_string(in_file_name, "", "PCM file that contains the signal.");
-WEBRTC_DEFINE_string(detection_file_name,
- "",
- "PCM file that contains the detection signal.");
-WEBRTC_DEFINE_string(reference_file_name,
- "",
- "PCM file that contains the reference signal.");
+ABSL_FLAG(std::string, in_file_name, "", "PCM file that contains the signal.");
+ABSL_FLAG(std::string,
+ detection_file_name,
+ "",
+ "PCM file that contains the detection signal.");
+ABSL_FLAG(std::string,
+ reference_file_name,
+ "",
+ "PCM file that contains the reference signal.");
-WEBRTC_DEFINE_int(chunk_size_ms,
- 10,
- "Time between each chunk of samples in milliseconds.");
+ABSL_FLAG(int,
+ chunk_size_ms,
+ 10,
+ "Time between each chunk of samples in milliseconds.");
-WEBRTC_DEFINE_int(sample_rate_hz,
- 16000,
- "Sampling frequency of the signal in Hertz.");
-WEBRTC_DEFINE_int(detection_rate_hz,
- 0,
- "Sampling frequency of the detection signal in Hertz.");
+ABSL_FLAG(int,
+ sample_rate_hz,
+ 16000,
+ "Sampling frequency of the signal in Hertz.");
+ABSL_FLAG(int,
+ detection_rate_hz,
+ 0,
+ "Sampling frequency of the detection signal in Hertz.");
-WEBRTC_DEFINE_int(num_channels, 1, "Number of channels.");
-
-WEBRTC_DEFINE_bool(help, false, "Print this message.");
+ABSL_FLAG(int, num_channels, 1, "Number of channels.");
namespace webrtc {
@@ -131,19 +136,21 @@
void void_main() {
// TODO(aluebs): Remove all FileWrappers.
// Prepare the input file.
- FILE* in_file = fopen(FLAG_in_file_name, "rb");
+ FILE* in_file = fopen(absl::GetFlag(FLAGS_in_file_name).c_str(), "rb");
ASSERT_TRUE(in_file != NULL);
// Prepare the detection file.
FILE* detection_file = NULL;
- if (strlen(FLAG_detection_file_name) > 0) {
- detection_file = fopen(FLAG_detection_file_name, "rb");
+ if (!absl::GetFlag(FLAGS_detection_file_name).empty()) {
+ detection_file =
+ fopen(absl::GetFlag(FLAGS_detection_file_name).c_str(), "rb");
}
// Prepare the reference file.
FILE* reference_file = NULL;
- if (strlen(FLAG_reference_file_name) > 0) {
- reference_file = fopen(FLAG_reference_file_name, "rb");
+ if (!absl::GetFlag(FLAGS_reference_file_name).empty()) {
+ reference_file =
+ fopen(absl::GetFlag(FLAGS_reference_file_name).c_str(), "rb");
}
// Prepare the output file.
@@ -151,27 +158,27 @@
FILE* out_file = fopen(out_file_name.c_str(), "wb");
ASSERT_TRUE(out_file != NULL);
- int detection_rate_hz = FLAG_detection_rate_hz;
+ int detection_rate_hz = absl::GetFlag(FLAGS_detection_rate_hz);
if (detection_rate_hz == 0) {
- detection_rate_hz = FLAG_sample_rate_hz;
+ detection_rate_hz = absl::GetFlag(FLAGS_sample_rate_hz);
}
Agc agc;
TransientSuppressor suppressor;
- suppressor.Initialize(FLAG_sample_rate_hz, detection_rate_hz,
- FLAG_num_channels);
+ suppressor.Initialize(absl::GetFlag(FLAGS_sample_rate_hz), detection_rate_hz,
+ absl::GetFlag(FLAGS_num_channels));
- const size_t audio_buffer_size =
- FLAG_chunk_size_ms * FLAG_sample_rate_hz / 1000;
+ const size_t audio_buffer_size = absl::GetFlag(FLAGS_chunk_size_ms) *
+ absl::GetFlag(FLAGS_sample_rate_hz) / 1000;
const size_t detection_buffer_size =
- FLAG_chunk_size_ms * detection_rate_hz / 1000;
+ absl::GetFlag(FLAGS_chunk_size_ms) * detection_rate_hz / 1000;
// int16 and float variants of the same data.
std::unique_ptr<int16_t[]> audio_buffer_i(
- new int16_t[FLAG_num_channels * audio_buffer_size]);
+ new int16_t[absl::GetFlag(FLAGS_num_channels) * audio_buffer_size]);
std::unique_ptr<float[]> audio_buffer_f(
- new float[FLAG_num_channels * audio_buffer_size]);
+ new float[absl::GetFlag(FLAGS_num_channels) * audio_buffer_size]);
std::unique_ptr<float[]> detection_buffer, reference_buffer;
@@ -180,26 +187,27 @@
if (reference_file)
reference_buffer.reset(new float[audio_buffer_size]);
- while (ReadBuffers(in_file, audio_buffer_size, FLAG_num_channels,
- audio_buffer_i.get(), detection_file,
- detection_buffer_size, detection_buffer.get(),
- reference_file, reference_buffer.get())) {
+ while (ReadBuffers(
+ in_file, audio_buffer_size, absl::GetFlag(FLAGS_num_channels),
+ audio_buffer_i.get(), detection_file, detection_buffer_size,
+ detection_buffer.get(), reference_file, reference_buffer.get())) {
agc.Process(audio_buffer_i.get(), static_cast<int>(audio_buffer_size),
- FLAG_sample_rate_hz);
+ absl::GetFlag(FLAGS_sample_rate_hz));
- for (size_t i = 0; i < FLAG_num_channels * audio_buffer_size; ++i) {
+ for (size_t i = 0;
+ i < absl::GetFlag(FLAGS_num_channels) * audio_buffer_size; ++i) {
audio_buffer_f[i] = audio_buffer_i[i];
}
- ASSERT_EQ(0, suppressor.Suppress(audio_buffer_f.get(), audio_buffer_size,
- FLAG_num_channels, detection_buffer.get(),
- detection_buffer_size,
- reference_buffer.get(), audio_buffer_size,
- agc.voice_probability(), true))
+ ASSERT_EQ(0, suppressor.Suppress(
+ audio_buffer_f.get(), audio_buffer_size,
+ absl::GetFlag(FLAGS_num_channels), detection_buffer.get(),
+ detection_buffer_size, reference_buffer.get(),
+ audio_buffer_size, agc.voice_probability(), true))
<< "The transient suppressor could not suppress the frame";
// Write result to out file.
- WritePCM(out_file, audio_buffer_size, FLAG_num_channels,
+ WritePCM(out_file, audio_buffer_size, absl::GetFlag(FLAGS_num_channels),
audio_buffer_f.get());
}
@@ -216,18 +224,14 @@
} // namespace webrtc
int main(int argc, char* argv[]) {
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) || FLAG_help ||
- argc != 1) {
+ std::vector<char*> args = absl::ParseCommandLine(argc, argv);
+ if (args.size() != 1) {
printf("%s", webrtc::kUsage);
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
return 1;
}
- RTC_CHECK_GT(FLAG_chunk_size_ms, 0);
- RTC_CHECK_GT(FLAG_sample_rate_hz, 0);
- RTC_CHECK_GT(FLAG_num_channels, 0);
+ RTC_CHECK_GT(absl::GetFlag(FLAGS_chunk_size_ms), 0);
+ RTC_CHECK_GT(absl::GetFlag(FLAGS_sample_rate_hz), 0);
+ RTC_CHECK_GT(absl::GetFlag(FLAGS_num_channels), 0);
webrtc::void_main();
return 0;
diff --git a/pc/datagram_dtls_adaptor.cc b/pc/datagram_dtls_adaptor.cc
index b48a9e4..e1added 100644
--- a/pc/datagram_dtls_adaptor.cc
+++ b/pc/datagram_dtls_adaptor.cc
@@ -29,7 +29,6 @@
#include "rtc_base/buffer.h"
#include "rtc_base/checks.h"
#include "rtc_base/dscp.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/message_queue.h"
#include "rtc_base/rtc_certificate.h"
diff --git a/rtc_tools/unpack_aecdump/unpack.cc b/rtc_tools/unpack_aecdump/unpack.cc
index f326b4c..c9da63a 100644
--- a/rtc_tools/unpack_aecdump/unpack.cc
+++ b/rtc_tools/unpack_aecdump/unpack.cc
@@ -28,7 +28,6 @@
#include "common_audio/wav_file.h"
#include "modules/audio_processing/test/protobuf_utils.h"
#include "modules/audio_processing/test/test_utils.h"
-#include "rtc_base/flags.h"
#include "rtc_base/format_macros.h"
#include "rtc_base/ignore_wundef.h"
#include "rtc_base/strings/string_builder.h"
diff --git a/test/BUILD.gn b/test/BUILD.gn
index 2ffd973..2020521 100644
--- a/test/BUILD.gn
+++ b/test/BUILD.gn
@@ -256,6 +256,8 @@
"../system_wrappers:field_trial",
"../system_wrappers:metrics",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
# TODO(bugs.webrtc.org/9792): This is needed for downstream projects on
@@ -331,6 +333,8 @@
":fileutils",
"../rtc_base:rtc_base_approved",
"../rtc_base/system:file_wrapper",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
]
}
@@ -389,6 +393,7 @@
"time_controller:time_controller_unittests",
"//testing/gmock",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings",
]
diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn
index eac3ba8..5f3aec8 100644
--- a/test/scenario/BUILD.gn
+++ b/test/scenario/BUILD.gn
@@ -140,6 +140,8 @@
"../logging:log_writer",
"../network:emulated_network",
"../time_controller",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
diff --git a/test/scenario/scenario.cc b/test/scenario/scenario.cc
index 9626030..e4551db 100644
--- a/test/scenario/scenario.cc
+++ b/test/scenario/scenario.cc
@@ -11,10 +11,11 @@
#include <algorithm>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
-#include "rtc_base/flags.h"
#include "rtc_base/socket_address.h"
#include "test/logging/file_log_writer.h"
#include "test/network/network_emulation.h"
@@ -22,10 +23,11 @@
#include "test/time_controller/real_time_controller.h"
#include "test/time_controller/simulated_time_controller.h"
-WEBRTC_DEFINE_bool(scenario_logs, false, "Save logs from scenario framework.");
-WEBRTC_DEFINE_string(scenario_logs_root,
- "",
- "Output root path, based on project root if unset.");
+ABSL_FLAG(bool, scenario_logs, false, "Save logs from scenario framework.");
+ABSL_FLAG(std::string,
+ scenario_logs_root,
+ "",
+ "Output root path, based on project root if unset.");
namespace webrtc {
namespace test {
@@ -34,8 +36,8 @@
std::unique_ptr<FileLogWriterFactory> GetScenarioLogManager(
std::string file_name) {
- if (FLAG_scenario_logs && !file_name.empty()) {
- std::string output_root = FLAG_scenario_logs_root;
+ if (absl::GetFlag(FLAGS_scenario_logs) && !file_name.empty()) {
+ std::string output_root = absl::GetFlag(FLAGS_scenario_logs_root);
if (output_root.empty())
output_root = OutputPath() + "output_data/";
diff --git a/test/test_main_lib.cc b/test/test_main_lib.cc
index 52939af..02e0703 100644
--- a/test/test_main_lib.cc
+++ b/test/test_main_lib.cc
@@ -13,9 +13,10 @@
#include <fstream>
#include <string>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/ssl_stream_adapter.h"
@@ -35,13 +36,16 @@
#if defined(WEBRTC_IOS)
#include "test/ios/test_support.h"
-WEBRTC_DEFINE_string(NSTreatUnknownArgumentsAsOpen,
- "",
- "Intentionally ignored flag intended for iOS simulator.");
-WEBRTC_DEFINE_string(ApplePersistenceIgnoreState,
- "",
- "Intentionally ignored flag intended for iOS simulator.");
-WEBRTC_DEFINE_bool(
+ABSL_FLAG(std::string,
+ NSTreatUnknownArgumentsAsOpen,
+ "",
+ "Intentionally ignored flag intended for iOS simulator.");
+ABSL_FLAG(std::string,
+ ApplePersistenceIgnoreState,
+ "",
+ "Intentionally ignored flag intended for iOS simulator.");
+ABSL_FLAG(
+ bool,
save_chartjson_result,
false,
"Store the perf results in Documents/perf_result.json in the format "
@@ -51,12 +55,13 @@
#else
-WEBRTC_DEFINE_string(
- isolated_script_test_output,
- "",
- "Path to output an empty JSON file which Chromium infra requires.");
+ABSL_FLAG(std::string,
+ isolated_script_test_output,
+ "",
+ "Path to output an empty JSON file which Chromium infra requires.");
-WEBRTC_DEFINE_string(
+ABSL_FLAG(
+ std::string,
isolated_script_test_perf_output,
"",
"Path where the perf results should be stored in the JSON format described "
@@ -66,17 +71,15 @@
#endif
-WEBRTC_DEFINE_bool(logs, true, "print logs to stderr");
-WEBRTC_DEFINE_bool(verbose, false, "verbose logs to stderr");
+ABSL_FLAG(bool, logs, true, "print logs to stderr");
+ABSL_FLAG(bool, verbose, false, "verbose logs to stderr");
-WEBRTC_DEFINE_string(
- force_fieldtrials,
- "",
- "Field trials control experimental feature code which can be forced. "
- "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
- " will assign the group Enable to field trial WebRTC-FooFeature.");
-
-WEBRTC_DEFINE_bool(help, false, "Print this message.");
+ABSL_FLAG(std::string,
+ force_fieldtrials,
+ "",
+ "Field trials control experimental feature code which can be forced. "
+ "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
+ " will assign the group Enable to field trial WebRTC-FooFeature.");
namespace webrtc {
@@ -86,24 +89,18 @@
public:
int Init(int* argc, char* argv[]) override {
::testing::InitGoogleMock(argc, argv);
+ absl::ParseCommandLine(*argc, argv);
// Default to LS_INFO, even for release builds to provide better test
// logging.
if (rtc::LogMessage::GetLogToDebug() > rtc::LS_INFO)
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
- if (rtc::FlagList::SetFlagsFromCommandLine(argc, argv, false)) {
- return 1;
- }
- if (FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
-
- if (FLAG_verbose)
+ if (absl::GetFlag(FLAGS_verbose))
rtc::LogMessage::LogToDebug(rtc::LS_VERBOSE);
- rtc::LogMessage::SetLogToStderr(FLAG_logs || FLAG_verbose);
+ rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs) ||
+ absl::GetFlag(FLAGS_verbose));
// TODO(bugs.webrtc.org/9792): we need to reference something from
// fileutils.h so that our downstream hack where we replace fileutils.cc
@@ -114,7 +111,8 @@
// InitFieldTrialsFromString stores the char*, so the char array must
// outlive the application.
- webrtc::field_trial::InitFieldTrialsFromString(FLAG_force_fieldtrials);
+ field_trials_ = absl::GetFlag(FLAGS_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(field_trials_.c_str());
webrtc::metrics::Enable();
#if defined(WEBRTC_WIN)
@@ -139,18 +137,20 @@
int Run(int argc, char* argv[]) override {
#if defined(WEBRTC_IOS)
rtc::test::InitTestSuite(RUN_ALL_TESTS, argc, argv,
- FLAG_save_chartjson_result);
+ absl::GetFlag(FLAGS_save_chartjson_result));
rtc::test::RunTestsFromIOSApp();
return 0;
#else
int exit_code = RUN_ALL_TESTS();
- std::string chartjson_result_file = FLAG_isolated_script_test_perf_output;
+ std::string chartjson_result_file =
+ absl::GetFlag(FLAGS_isolated_script_test_perf_output);
if (!chartjson_result_file.empty()) {
webrtc::test::WritePerfResults(chartjson_result_file);
}
- std::string result_filename = FLAG_isolated_script_test_output;
+ std::string result_filename =
+ absl::GetFlag(FLAGS_isolated_script_test_output);
if (!result_filename.empty()) {
std::ofstream result_file(result_filename);
result_file << "{\"version\": 3}";
diff --git a/test/test_main_lib.h b/test/test_main_lib.h
index 44dd764..bdb0afb 100644
--- a/test/test_main_lib.h
+++ b/test/test_main_lib.h
@@ -11,6 +11,7 @@
#define TEST_TEST_MAIN_LIB_H_
#include <memory>
+#include <string>
namespace webrtc {
@@ -31,6 +32,8 @@
protected:
TestMain() = default;
+
+ std::string field_trials_;
};
} // namespace webrtc
diff --git a/test/testsupport/test_artifacts.cc b/test/testsupport/test_artifacts.cc
index b417745..6f062e5 100644
--- a/test/testsupport/test_artifacts.cc
+++ b/test/testsupport/test_artifacts.cc
@@ -12,7 +12,8 @@
#include <string.h>
-#include "rtc_base/flags.h"
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "rtc_base/logging.h"
#include "rtc_base/system/file_wrapper.h"
#include "test/testsupport/file_utils.h"
@@ -24,26 +25,27 @@
}
} // namespace
-WEBRTC_DEFINE_string(test_artifacts_dir,
- DefaultArtifactPath().c_str(),
- "The output folder where test output should be saved.");
+ABSL_FLAG(std::string,
+ test_artifacts_dir,
+ DefaultArtifactPath().c_str(),
+ "The output folder where test output should be saved.");
namespace webrtc {
namespace test {
bool GetTestArtifactsDir(std::string* out_dir) {
- if (strlen(FLAG_test_artifacts_dir) == 0) {
+ if (absl::GetFlag(FLAGS_test_artifacts_dir).empty()) {
RTC_LOG(LS_WARNING) << "No test_out_dir defined.";
return false;
}
- *out_dir = FLAG_test_artifacts_dir;
+ *out_dir = absl::GetFlag(FLAGS_test_artifacts_dir);
return true;
}
bool WriteToTestArtifactsDir(const char* filename,
const uint8_t* buffer,
size_t length) {
- if (strlen(FLAG_test_artifacts_dir) == 0) {
+ if (absl::GetFlag(FLAGS_test_artifacts_dir).empty()) {
RTC_LOG(LS_WARNING) << "No test_out_dir defined.";
return false;
}
@@ -54,7 +56,7 @@
}
FileWrapper output = FileWrapper::OpenWriteOnly(
- JoinFilename(FLAG_test_artifacts_dir, filename));
+ JoinFilename(absl::GetFlag(FLAGS_test_artifacts_dir), filename));
return output.is_open() && output.Write(buffer, length);
}
diff --git a/test/testsupport/test_artifacts_unittest.cc b/test/testsupport/test_artifacts_unittest.cc
index cb8c77c..98de9e4 100644
--- a/test/testsupport/test_artifacts_unittest.cc
+++ b/test/testsupport/test_artifacts_unittest.cc
@@ -14,21 +14,21 @@
#include <string>
-#include "rtc_base/flags.h"
+#include "absl/flags/flag.h"
#include "rtc_base/system/file_wrapper.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
-WEBRTC_DECLARE_string(test_artifacts_dir);
+ABSL_DECLARE_FLAG(std::string, test_artifacts_dir);
namespace webrtc {
namespace test {
TEST(IsolatedOutputTest, ShouldRejectInvalidIsolatedOutDir) {
- const char* backup = FLAG_test_artifacts_dir;
- FLAG_test_artifacts_dir = "";
+ const std::string backup = absl::GetFlag(FLAGS_test_artifacts_dir);
+ absl::SetFlag(&FLAGS_test_artifacts_dir, "");
ASSERT_FALSE(WriteToTestArtifactsDir("a-file", "some-contents"));
- FLAG_test_artifacts_dir = backup;
+ absl::SetFlag(&FLAGS_test_artifacts_dir, backup);
}
TEST(IsolatedOutputTest, ShouldRejectInvalidFileName) {
@@ -41,7 +41,8 @@
const char* filename = "a-file";
const char* content = "some-contents";
if (WriteToTestArtifactsDir(filename, content)) {
- std::string out_file = JoinFilename(FLAG_test_artifacts_dir, filename);
+ std::string out_file =
+ JoinFilename(absl::GetFlag(FLAGS_test_artifacts_dir), filename);
FileWrapper input = FileWrapper::OpenReadOnly(out_file);
EXPECT_TRUE(input.is_open());
EXPECT_TRUE(input.Rewind());
diff --git a/tools_webrtc/gtest-parallel-wrapper.py b/tools_webrtc/gtest-parallel-wrapper.py
index 7be4b2b..b4b6675 100755
--- a/tools_webrtc/gtest-parallel-wrapper.py
+++ b/tools_webrtc/gtest-parallel-wrapper.py
@@ -157,7 +157,20 @@
options, unrecognized_args = parser.parse_known_args(argv)
- executable_args = options.executable_args + unrecognized_args
+ webrtc_flags_to_change = {
+ '--isolated-script-test-perf-output': '--isolated_script_test_perf_output',
+ '--isolated-script-test-output': '--isolated_script_test_output',
+ }
+ args_to_pass = []
+ for arg in unrecognized_args:
+ if any(arg.startswith(k) for k in webrtc_flags_to_change.keys()):
+ arg_split = arg.split('=')
+ args_to_pass.append(
+ webrtc_flags_to_change[arg_split[0]] + '=' + arg_split[1])
+ else:
+ args_to_pass.append(arg)
+
+ executable_args = options.executable_args + args_to_pass
if options.store_test_artifacts:
assert options.output_dir, (
diff --git a/tools_webrtc/gtest_parallel_wrapper_test.py b/tools_webrtc/gtest_parallel_wrapper_test.py
index e5447e3..5d436aa 100755
--- a/tools_webrtc/gtest_parallel_wrapper_test.py
+++ b/tools_webrtc/gtest_parallel_wrapper_test.py
@@ -148,7 +148,7 @@
'--output_dir=' + output_dir, '--dump_json_test_results=SOME_DIR',
'some_test', '--', '--test_artifacts_dir=' + expected_artifacts_dir,
'--some_flag=some_value', '--another_flag',
- '--isolated-script-test-perf-output=SOME_OTHER_DIR', '--foo=bar',
+ '--isolated_script_test_perf_output=SOME_OTHER_DIR', '--foo=bar',
'--baz'
])
self.assertEqual(result.gtest_parallel_args, expected)
diff --git a/video/BUILD.gn b/video/BUILD.gn
index 89c1f32..7d83ffe 100644
--- a/video/BUILD.gn
+++ b/video/BUILD.gn
@@ -299,6 +299,8 @@
"../test:video_test_common",
"../test:video_test_support",
"//third_party/abseil-cpp/absl/algorithm:container",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
]
@@ -322,7 +324,6 @@
"../media:rtc_vp9_profile",
"../modules/pacing",
"../modules/video_coding:webrtc_vp9",
- "../rtc_base:rtc_base_approved",
"../rtc_base/experiments:alr_experiment",
"../system_wrappers:field_trial",
"../test:field_trial",
@@ -330,6 +331,8 @@
"../test:test_common",
"../test:test_support",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
]
}
@@ -372,7 +375,6 @@
"../api/video_codecs:video_codecs_api",
"../rtc_base:checks",
"../rtc_base:logging",
- "../rtc_base:rtc_base_approved",
"../system_wrappers:field_trial",
"../test:field_trial",
"../test:run_test",
@@ -381,6 +383,8 @@
"../test:test_renderer",
"../test:test_support",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
]
}
@@ -422,7 +426,7 @@
"../api/video_codecs:video_codecs_api",
"../rtc_base:checks",
"../rtc_base:logging",
- "../rtc_base:rtc_base_approved",
+ "../rtc_base:stringutils",
"../system_wrappers:field_trial",
"../test:field_trial",
"../test:run_test",
@@ -430,6 +434,8 @@
"../test:test_common",
"../test:test_renderer",
"../test:test_support",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional",
]
@@ -448,7 +454,7 @@
"../api/video_codecs:video_codecs_api",
"../rtc_base:checks",
"../rtc_base:logging",
- "../rtc_base:rtc_base_approved",
+ "../rtc_base:stringutils",
"../system_wrappers:field_trial",
"../test:field_trial",
"../test:run_test",
@@ -457,6 +463,8 @@
"../test:test_renderer",
"../test:test_support",
"//testing/gtest",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
]
}
@@ -475,8 +483,9 @@
"../media:rtc_internal_video_codecs",
"../modules/rtp_rtcp",
"../rtc_base:checks",
- "../rtc_base:rtc_base_approved",
"../rtc_base:rtc_json",
+ "../rtc_base:stringutils",
+ "../rtc_base:timeutils",
"../system_wrappers",
"../test:call_config_utils",
"../test:encoder_settings",
@@ -490,6 +499,8 @@
"../test:test_support",
"../test:video_test_common",
"../test:video_test_support",
+ "//third_party/abseil-cpp/absl/flags:flag",
+ "//third_party/abseil-cpp/absl/flags:parse",
"//third_party/abseil-cpp/absl/memory",
]
}
diff --git a/video/full_stack_tests.cc b/video/full_stack_tests.cc
index 6fae630..07d1510 100644
--- a/video/full_stack_tests.cc
+++ b/video/full_stack_tests.cc
@@ -12,6 +12,8 @@
#include <utility>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "api/test/simulated_network.h"
@@ -22,39 +24,26 @@
#include "api/video_codecs/video_encoder_config.h"
#include "media/base/vp9_profile.h"
#include "modules/video_coding/codecs/vp9/include/vp9.h"
-#include "rtc_base/flags.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
#include "video/video_quality_test.h"
-namespace webrtc {
-namespace flags {
-
-WEBRTC_DEFINE_string(rtc_event_log_name,
- "",
- "Filename for rtc event log. Two files "
- "with \"_send\" and \"_recv\" suffixes will be created.");
-std::string RtcEventLogName() {
- return static_cast<std::string>(FLAG_rtc_event_log_name);
-}
-WEBRTC_DEFINE_string(rtp_dump_name,
- "",
- "Filename for dumped received RTP stream.");
-std::string RtpDumpName() {
- return static_cast<std::string>(FLAG_rtp_dump_name);
-}
-WEBRTC_DEFINE_string(
- encoded_frame_path,
- "",
- "The base path for encoded frame logs. Created files will have "
- "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
-std::string EncodedFramePath() {
- return static_cast<std::string>(FLAG_encoded_frame_path);
-}
-} // namespace flags
-} // namespace webrtc
+ABSL_FLAG(std::string,
+ rtc_event_log_name,
+ "",
+ "Filename for rtc event log. Two files "
+ "with \"_send\" and \"_recv\" suffixes will be created.");
+ABSL_FLAG(std::string,
+ rtp_dump_name,
+ "",
+ "Filename for dumped received RTP stream.");
+ABSL_FLAG(std::string,
+ encoded_frame_path,
+ "",
+ "The base path for encoded frame logs. Created files will have "
+ "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
namespace webrtc {
@@ -67,8 +56,9 @@
public:
ParamsWithLogging() {
// Use these logging flags by default, for everything.
- logging = {flags::RtcEventLogName(), flags::RtpDumpName(),
- flags::EncodedFramePath()};
+ logging = {absl::GetFlag(FLAGS_rtc_event_log_name),
+ absl::GetFlag(FLAGS_rtp_dump_name),
+ absl::GetFlag(FLAGS_encoded_frame_path)};
this->config = BuiltInNetworkBehaviorConfig();
}
};
diff --git a/video/screenshare_loopback.cc b/video/screenshare_loopback.cc
index fc10fc3..ed14b30 100644
--- a/video/screenshare_loopback.cc
+++ b/video/screenshare_loopback.cc
@@ -14,6 +14,8 @@
#include <string>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "api/bitrate_constraints.h"
@@ -21,7 +23,6 @@
#include "api/test/video_quality_test_fixture.h"
#include "api/video_codecs/video_codec.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/string_encode.h"
#include "system_wrappers/include/field_trial.h"
@@ -30,225 +31,234 @@
#include "test/run_test.h"
#include "video/video_quality_test.h"
-namespace webrtc {
-namespace flags {
+using ::webrtc::BitrateConstraints;
+using ::webrtc::BuiltInNetworkBehaviorConfig;
+using ::webrtc::InterLayerPredMode;
+using ::webrtc::SdpVideoFormat;
+using ::webrtc::VideoQualityTest;
// Flags common with video loopback, with different default values.
-WEBRTC_DEFINE_int(width, 1850, "Video width (crops source).");
+ABSL_FLAG(int, width, 1850, "Video width (crops source).");
size_t Width() {
- return static_cast<size_t>(FLAG_width);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_width));
}
-WEBRTC_DEFINE_int(height, 1110, "Video height (crops source).");
+ABSL_FLAG(int, height, 1110, "Video height (crops source).");
size_t Height() {
- return static_cast<size_t>(FLAG_height);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_height));
}
-WEBRTC_DEFINE_int(fps, 5, "Frames per second.");
+ABSL_FLAG(int, fps, 5, "Frames per second.");
int Fps() {
- return static_cast<int>(FLAG_fps);
+ return absl::GetFlag(FLAGS_fps);
}
-WEBRTC_DEFINE_int(min_bitrate, 50, "Call and stream min bitrate in kbps.");
+ABSL_FLAG(int, min_bitrate, 50, "Call and stream min bitrate in kbps.");
int MinBitrateKbps() {
- return static_cast<int>(FLAG_min_bitrate);
+ return absl::GetFlag(FLAGS_min_bitrate);
}
-WEBRTC_DEFINE_int(start_bitrate, 300, "Call start bitrate in kbps.");
+ABSL_FLAG(int, start_bitrate, 300, "Call start bitrate in kbps.");
int StartBitrateKbps() {
- return static_cast<int>(FLAG_start_bitrate);
+ return absl::GetFlag(FLAGS_start_bitrate);
}
-WEBRTC_DEFINE_int(target_bitrate, 200, "Stream target bitrate in kbps.");
+ABSL_FLAG(int, target_bitrate, 200, "Stream target bitrate in kbps.");
int TargetBitrateKbps() {
- return static_cast<int>(FLAG_target_bitrate);
+ return absl::GetFlag(FLAGS_target_bitrate);
}
-WEBRTC_DEFINE_int(max_bitrate, 1000, "Call and stream max bitrate in kbps.");
+ABSL_FLAG(int, max_bitrate, 1000, "Call and stream max bitrate in kbps.");
int MaxBitrateKbps() {
- return static_cast<int>(FLAG_max_bitrate);
+ return absl::GetFlag(FLAGS_max_bitrate);
}
-WEBRTC_DEFINE_int(num_temporal_layers, 2, "Number of temporal layers to use.");
+ABSL_FLAG(int, num_temporal_layers, 2, "Number of temporal layers to use.");
int NumTemporalLayers() {
- return static_cast<int>(FLAG_num_temporal_layers);
+ return absl::GetFlag(FLAGS_num_temporal_layers);
}
// Flags common with video loopback, with equal default values.
-WEBRTC_DEFINE_string(codec, "VP8", "Video codec to use.");
+ABSL_FLAG(std::string, codec, "VP8", "Video codec to use.");
std::string Codec() {
- return static_cast<std::string>(FLAG_codec);
+ return absl::GetFlag(FLAGS_codec);
}
-WEBRTC_DEFINE_string(rtc_event_log_name,
- "",
- "Filename for rtc event log. Two files "
- "with \"_send\" and \"_recv\" suffixes will be created.");
+ABSL_FLAG(std::string,
+ rtc_event_log_name,
+ "",
+ "Filename for rtc event log. Two files "
+ "with \"_send\" and \"_recv\" suffixes will be created.");
std::string RtcEventLogName() {
- return static_cast<std::string>(FLAG_rtc_event_log_name);
+ return absl::GetFlag(FLAGS_rtc_event_log_name);
}
-WEBRTC_DEFINE_string(rtp_dump_name,
- "",
- "Filename for dumped received RTP stream.");
+ABSL_FLAG(std::string,
+ rtp_dump_name,
+ "",
+ "Filename for dumped received RTP stream.");
std::string RtpDumpName() {
- return static_cast<std::string>(FLAG_rtp_dump_name);
+ return absl::GetFlag(FLAGS_rtp_dump_name);
}
-WEBRTC_DEFINE_int(
- selected_tl,
- -1,
- "Temporal layer to show or analyze. -1 to disable filtering.");
+ABSL_FLAG(int,
+ selected_tl,
+ -1,
+ "Temporal layer to show or analyze. -1 to disable filtering.");
int SelectedTL() {
- return static_cast<int>(FLAG_selected_tl);
+ return absl::GetFlag(FLAGS_selected_tl);
}
-WEBRTC_DEFINE_int(
+ABSL_FLAG(
+ int,
duration,
0,
"Duration of the test in seconds. If 0, rendered will be shown instead.");
int DurationSecs() {
- return static_cast<int>(FLAG_duration);
+ return absl::GetFlag(FLAGS_duration);
}
-WEBRTC_DEFINE_string(output_filename, "", "Target graph data filename.");
+ABSL_FLAG(std::string, output_filename, "", "Target graph data filename.");
std::string OutputFilename() {
- return static_cast<std::string>(FLAG_output_filename);
+ return absl::GetFlag(FLAGS_output_filename);
}
-WEBRTC_DEFINE_string(graph_title,
- "",
- "If empty, title will be generated automatically.");
+ABSL_FLAG(std::string,
+ graph_title,
+ "",
+ "If empty, title will be generated automatically.");
std::string GraphTitle() {
- return static_cast<std::string>(FLAG_graph_title);
+ return absl::GetFlag(FLAGS_graph_title);
}
-WEBRTC_DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
+ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost.");
int LossPercent() {
- return static_cast<int>(FLAG_loss_percent);
+ return absl::GetFlag(FLAGS_loss_percent);
}
-WEBRTC_DEFINE_int(link_capacity,
- 0,
- "Capacity (kbps) of the fake link. 0 means infinite.");
+ABSL_FLAG(int,
+ link_capacity,
+ 0,
+ "Capacity (kbps) of the fake link. 0 means infinite.");
int LinkCapacityKbps() {
- return static_cast<int>(FLAG_link_capacity);
+ return absl::GetFlag(FLAGS_link_capacity);
}
-WEBRTC_DEFINE_int(queue_size,
- 0,
- "Size of the bottleneck link queue in packets.");
+ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets.");
int QueueSize() {
- return static_cast<int>(FLAG_queue_size);
+ return absl::GetFlag(FLAGS_queue_size);
}
-WEBRTC_DEFINE_int(avg_propagation_delay_ms,
- 0,
- "Average link propagation delay in ms.");
+ABSL_FLAG(int,
+ avg_propagation_delay_ms,
+ 0,
+ "Average link propagation delay in ms.");
int AvgPropagationDelayMs() {
- return static_cast<int>(FLAG_avg_propagation_delay_ms);
+ return absl::GetFlag(FLAGS_avg_propagation_delay_ms);
}
-WEBRTC_DEFINE_int(std_propagation_delay_ms,
- 0,
- "Link propagation delay standard deviation in ms.");
+ABSL_FLAG(int,
+ std_propagation_delay_ms,
+ 0,
+ "Link propagation delay standard deviation in ms.");
int StdPropagationDelayMs() {
- return static_cast<int>(FLAG_std_propagation_delay_ms);
+ return absl::GetFlag(FLAGS_std_propagation_delay_ms);
}
-WEBRTC_DEFINE_int(num_streams, 0, "Number of streams to show or analyze.");
+ABSL_FLAG(int, num_streams, 0, "Number of streams to show or analyze.");
int NumStreams() {
- return static_cast<int>(FLAG_num_streams);
+ return absl::GetFlag(FLAGS_num_streams);
}
-WEBRTC_DEFINE_int(selected_stream,
- 0,
- "ID of the stream to show or analyze. "
- "Set to the number of streams to show them all.");
+ABSL_FLAG(int,
+ selected_stream,
+ 0,
+ "ID of the stream to show or analyze. "
+ "Set to the number of streams to show them all.");
int SelectedStream() {
- return static_cast<int>(FLAG_selected_stream);
+ return absl::GetFlag(FLAGS_selected_stream);
}
-WEBRTC_DEFINE_int(num_spatial_layers, 1, "Number of spatial layers to use.");
+ABSL_FLAG(int, num_spatial_layers, 1, "Number of spatial layers to use.");
int NumSpatialLayers() {
- return static_cast<int>(FLAG_num_spatial_layers);
+ return absl::GetFlag(FLAGS_num_spatial_layers);
}
-WEBRTC_DEFINE_int(
- inter_layer_pred,
- 0,
- "Inter-layer prediction mode. "
- "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
+ABSL_FLAG(int,
+ inter_layer_pred,
+ 0,
+ "Inter-layer prediction mode. "
+ "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
InterLayerPredMode InterLayerPred() {
- if (FLAG_inter_layer_pred == 0) {
- return InterLayerPredMode::kOn;
- } else if (FLAG_inter_layer_pred == 1) {
- return InterLayerPredMode::kOff;
+ if (absl::GetFlag(FLAGS_inter_layer_pred) == 0) {
+ return webrtc::InterLayerPredMode::kOn;
+ } else if (absl::GetFlag(FLAGS_inter_layer_pred) == 1) {
+ return webrtc::InterLayerPredMode::kOff;
} else {
- RTC_DCHECK_EQ(FLAG_inter_layer_pred, 2);
- return InterLayerPredMode::kOnKeyPic;
+ RTC_DCHECK_EQ(absl::GetFlag(FLAGS_inter_layer_pred), 2);
+ return webrtc::InterLayerPredMode::kOnKeyPic;
}
}
-WEBRTC_DEFINE_int(selected_sl,
- -1,
- "Spatial layer to show or analyze. -1 to disable filtering.");
+ABSL_FLAG(int,
+ selected_sl,
+ -1,
+ "Spatial layer to show or analyze. -1 to disable filtering.");
int SelectedSL() {
- return static_cast<int>(FLAG_selected_sl);
+ return absl::GetFlag(FLAGS_selected_sl);
}
-WEBRTC_DEFINE_string(
- stream0,
- "",
- "Comma separated values describing VideoStream for stream #0.");
+ABSL_FLAG(std::string,
+ stream0,
+ "",
+ "Comma separated values describing VideoStream for stream #0.");
std::string Stream0() {
- return static_cast<std::string>(FLAG_stream0);
+ return absl::GetFlag(FLAGS_stream0);
}
-WEBRTC_DEFINE_string(
- stream1,
- "",
- "Comma separated values describing VideoStream for stream #1.");
+ABSL_FLAG(std::string,
+ stream1,
+ "",
+ "Comma separated values describing VideoStream for stream #1.");
std::string Stream1() {
- return static_cast<std::string>(FLAG_stream1);
+ return absl::GetFlag(FLAGS_stream1);
}
-WEBRTC_DEFINE_string(
- sl0,
- "",
- "Comma separated values describing SpatialLayer for layer #0.");
+ABSL_FLAG(std::string,
+ sl0,
+ "",
+ "Comma separated values describing SpatialLayer for layer #0.");
std::string SL0() {
- return static_cast<std::string>(FLAG_sl0);
+ return absl::GetFlag(FLAGS_sl0);
}
-WEBRTC_DEFINE_string(
- sl1,
- "",
- "Comma separated values describing SpatialLayer for layer #1.");
+ABSL_FLAG(std::string,
+ sl1,
+ "",
+ "Comma separated values describing SpatialLayer for layer #1.");
std::string SL1() {
- return static_cast<std::string>(FLAG_sl1);
+ return absl::GetFlag(FLAGS_sl1);
}
-WEBRTC_DEFINE_string(
- encoded_frame_path,
- "",
- "The base path for encoded frame logs. Created files will have "
- "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
+ABSL_FLAG(std::string,
+ encoded_frame_path,
+ "",
+ "The base path for encoded frame logs. Created files will have "
+ "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
std::string EncodedFramePath() {
- return static_cast<std::string>(FLAG_encoded_frame_path);
+ return absl::GetFlag(FLAGS_encoded_frame_path);
}
-WEBRTC_DEFINE_bool(logs, false, "print logs to stderr");
+ABSL_FLAG(bool, logs, false, "print logs to stderr");
-WEBRTC_DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
+ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation");
-WEBRTC_DEFINE_bool(generic_descriptor,
- false,
- "Use the generic frame descriptor.");
+ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor.");
-WEBRTC_DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
+ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur");
-WEBRTC_DEFINE_string(
+ABSL_FLAG(
+ std::string,
force_fieldtrials,
"",
"Field trials control experimental feature code which can be forced. "
@@ -257,139 +267,125 @@
"trials are separated by \"/\"");
// Screenshare-specific flags.
-WEBRTC_DEFINE_int(min_transmit_bitrate,
- 400,
- "Min transmit bitrate incl. padding.");
+ABSL_FLAG(int,
+ min_transmit_bitrate,
+ 400,
+ "Min transmit bitrate incl. padding.");
int MinTransmitBitrateKbps() {
- return FLAG_min_transmit_bitrate;
+ return absl::GetFlag(FLAGS_min_transmit_bitrate);
}
-WEBRTC_DEFINE_bool(
- generate_slides,
- false,
- "Whether to use randomly generated slides or read them from files.");
+ABSL_FLAG(bool,
+ generate_slides,
+ false,
+ "Whether to use randomly generated slides or read them from files.");
bool GenerateSlides() {
- return static_cast<int>(FLAG_generate_slides);
+ return absl::GetFlag(FLAGS_generate_slides);
}
-WEBRTC_DEFINE_int(slide_change_interval,
- 10,
- "Interval (in seconds) between simulated slide changes.");
+ABSL_FLAG(int,
+ slide_change_interval,
+ 10,
+ "Interval (in seconds) between simulated slide changes.");
int SlideChangeInterval() {
- return static_cast<int>(FLAG_slide_change_interval);
+ return absl::GetFlag(FLAGS_slide_change_interval);
}
-WEBRTC_DEFINE_int(
+ABSL_FLAG(
+ int,
scroll_duration,
0,
"Duration (in seconds) during which a slide will be scrolled into place.");
int ScrollDuration() {
- return static_cast<int>(FLAG_scroll_duration);
+ return absl::GetFlag(FLAGS_scroll_duration);
}
-WEBRTC_DEFINE_string(
- slides,
- "",
- "Comma-separated list of *.yuv files to display as slides.");
+ABSL_FLAG(std::string,
+ slides,
+ "",
+ "Comma-separated list of *.yuv files to display as slides.");
std::vector<std::string> Slides() {
std::vector<std::string> slides;
- std::string slides_list = FLAG_slides;
+ std::string slides_list = absl::GetFlag(FLAGS_slides);
rtc::tokenize(slides_list, ',', &slides);
return slides;
}
-WEBRTC_DEFINE_bool(help, false, "prints this message");
-
-} // namespace flags
-
void Loopback() {
BuiltInNetworkBehaviorConfig pipe_config;
- pipe_config.loss_percent = flags::LossPercent();
- pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
- pipe_config.queue_length_packets = flags::QueueSize();
- pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
- pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
- pipe_config.allow_reordering = flags::FLAG_allow_reordering;
+ pipe_config.loss_percent = LossPercent();
+ pipe_config.link_capacity_kbps = LinkCapacityKbps();
+ pipe_config.queue_length_packets = QueueSize();
+ pipe_config.queue_delay_ms = AvgPropagationDelayMs();
+ pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs();
+ pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering);
BitrateConstraints call_bitrate_config;
- call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
- call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
+ call_bitrate_config.min_bitrate_bps = MinBitrateKbps() * 1000;
+ call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000;
call_bitrate_config.max_bitrate_bps = -1; // Don't cap bandwidth estimate.
VideoQualityTest::Params params;
- params.call = {flags::FLAG_send_side_bwe, flags::FLAG_generic_descriptor,
- call_bitrate_config};
+ params.call = {absl::GetFlag(FLAGS_send_side_bwe),
+ absl::GetFlag(FLAGS_generic_descriptor), call_bitrate_config};
params.video[0] = {true,
- flags::Width(),
- flags::Height(),
- flags::Fps(),
- flags::MinBitrateKbps() * 1000,
- flags::TargetBitrateKbps() * 1000,
- flags::MaxBitrateKbps() * 1000,
+ Width(),
+ Height(),
+ Fps(),
+ MinBitrateKbps() * 1000,
+ TargetBitrateKbps() * 1000,
+ MaxBitrateKbps() * 1000,
false,
- flags::Codec(),
- flags::NumTemporalLayers(),
- flags::SelectedTL(),
- flags::MinTransmitBitrateKbps() * 1000,
+ Codec(),
+ NumTemporalLayers(),
+ SelectedTL(),
+ MinTransmitBitrateKbps() * 1000,
false, // ULPFEC disabled.
false, // FlexFEC disabled.
false, // Automatic scaling disabled.
"",
0, // capture_device_index.
SdpVideoFormat::Parameters()};
- params.screenshare[0] = {true, flags::GenerateSlides(),
- flags::SlideChangeInterval(),
- flags::ScrollDuration(), flags::Slides()};
- params.analyzer = {"screenshare",
- 0.0,
- 0.0,
- flags::DurationSecs(),
- flags::OutputFilename(),
- flags::GraphTitle()};
+ params.screenshare[0] = {true, GenerateSlides(), SlideChangeInterval(),
+ ScrollDuration(), Slides()};
+ params.analyzer = {"screenshare", 0.0, 0.0, DurationSecs(),
+ OutputFilename(), GraphTitle()};
params.config = pipe_config;
- params.logging = {flags::RtcEventLogName(), flags::RtpDumpName(),
- flags::EncodedFramePath()};
+ params.logging = {RtcEventLogName(), RtpDumpName(), EncodedFramePath()};
- if (flags::NumStreams() > 1 && flags::Stream0().empty() &&
- flags::Stream1().empty()) {
+ if (NumStreams() > 1 && Stream0().empty() && Stream1().empty()) {
params.ss[0].infer_streams = true;
}
std::vector<std::string> stream_descriptors;
- stream_descriptors.push_back(flags::Stream0());
- stream_descriptors.push_back(flags::Stream1());
+ stream_descriptors.push_back(Stream0());
+ stream_descriptors.push_back(Stream1());
std::vector<std::string> SL_descriptors;
- SL_descriptors.push_back(flags::SL0());
- SL_descriptors.push_back(flags::SL1());
+ SL_descriptors.push_back(SL0());
+ SL_descriptors.push_back(SL1());
VideoQualityTest::FillScalabilitySettings(
- ¶ms, 0, stream_descriptors, flags::NumStreams(),
- flags::SelectedStream(), flags::NumSpatialLayers(), flags::SelectedSL(),
- flags::InterLayerPred(), SL_descriptors);
+ ¶ms, 0, stream_descriptors, NumStreams(), SelectedStream(),
+ NumSpatialLayers(), SelectedSL(), InterLayerPred(), SL_descriptors);
auto fixture = absl::make_unique<VideoQualityTest>(nullptr);
- if (flags::DurationSecs()) {
+ if (DurationSecs()) {
fixture->RunWithAnalyzer(params);
} else {
fixture->RunWithRenderers(params);
}
}
-} // namespace webrtc
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
- rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
- if (webrtc::flags::FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
+ absl::ParseCommandLine(argc, argv);
- rtc::LogMessage::SetLogToStderr(webrtc::flags::FLAG_logs);
+ rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs));
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
- webrtc::field_trial::InitFieldTrialsFromString(
- webrtc::flags::FLAG_force_fieldtrials);
+ const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
- webrtc::test::RunTest(webrtc::Loopback);
+ webrtc::test::RunTest(Loopback);
return 0;
}
diff --git a/video/sv_loopback.cc b/video/sv_loopback.cc
index 248708e..d27e0cc 100644
--- a/video/sv_loopback.cc
+++ b/video/sv_loopback.cc
@@ -14,6 +14,8 @@
#include <string>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "api/bitrate_constraints.h"
@@ -21,7 +23,6 @@
#include "api/test/video_quality_test_fixture.h"
#include "api/video_codecs/video_codec.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "rtc_base/string_encode.h"
#include "system_wrappers/include/field_trial.h"
@@ -30,8 +31,305 @@
#include "test/run_test.h"
#include "video/video_quality_test.h"
+// Flags for video.
+ABSL_FLAG(int, vwidth, 640, "Video width.");
+
+ABSL_FLAG(int, vheight, 480, "Video height.");
+
+ABSL_FLAG(int, vfps, 30, "Video frames per second.");
+
+ABSL_FLAG(int,
+ capture_device_index,
+ 0,
+ "Capture device to select for video stream");
+
+ABSL_FLAG(int, vtarget_bitrate, 400, "Video stream target bitrate in kbps.");
+
+ABSL_FLAG(int, vmin_bitrate, 100, "Video stream min bitrate in kbps.");
+
+ABSL_FLAG(int, vmax_bitrate, 2000, "Video stream max bitrate in kbps.");
+
+ABSL_FLAG(bool,
+ suspend_below_min_bitrate,
+ false,
+ "Suspends video below the configured min bitrate.");
+
+ABSL_FLAG(int,
+ vnum_temporal_layers,
+ 1,
+ "Number of temporal layers for video. Set to 1-4 to override.");
+
+ABSL_FLAG(int, vnum_streams, 0, "Number of video streams to show or analyze.");
+
+ABSL_FLAG(int,
+ vnum_spatial_layers,
+ 1,
+ "Number of video spatial layers to use.");
+
+ABSL_FLAG(int,
+ vinter_layer_pred,
+ 2,
+ "Video inter-layer prediction mode. "
+ "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
+
+ABSL_FLAG(std::string,
+ vstream0,
+ "",
+ "Comma separated values describing VideoStream for video stream #0.");
+
+ABSL_FLAG(std::string,
+ vstream1,
+ "",
+ "Comma separated values describing VideoStream for video stream #1.");
+
+ABSL_FLAG(std::string,
+ vsl0,
+ "",
+ "Comma separated values describing SpatialLayer for video layer #0.");
+
+ABSL_FLAG(std::string,
+ vsl1,
+ "",
+ "Comma separated values describing SpatialLayer for video layer #1.");
+
+ABSL_FLAG(int,
+ vselected_tl,
+ -1,
+ "Temporal layer to show or analyze for screenshare. -1 to disable "
+ "filtering.");
+
+ABSL_FLAG(int,
+ vselected_stream,
+ 0,
+ "ID of the stream to show or analyze for screenshare."
+ "Set to the number of streams to show them all.");
+
+ABSL_FLAG(int,
+ vselected_sl,
+ -1,
+ "Spatial layer to show or analyze for screenshare. -1 to disable "
+ "filtering.");
+
+// Flags for screenshare.
+ABSL_FLAG(int,
+ min_transmit_bitrate,
+ 400,
+ "Min transmit bitrate incl. padding for screenshare.");
+
+ABSL_FLAG(int, swidth, 1850, "Screenshare width (crops source).");
+
+ABSL_FLAG(int, sheight, 1110, "Screenshare height (crops source).");
+
+ABSL_FLAG(int, sfps, 5, "Frames per second for screenshare.");
+
+ABSL_FLAG(int,
+ starget_bitrate,
+ 100,
+ "Screenshare stream target bitrate in kbps.");
+
+ABSL_FLAG(int, smin_bitrate, 100, "Screenshare stream min bitrate in kbps.");
+
+ABSL_FLAG(int, smax_bitrate, 2000, "Screenshare stream max bitrate in kbps.");
+
+ABSL_FLAG(int,
+ snum_temporal_layers,
+ 2,
+ "Number of temporal layers to use in screenshare.");
+
+ABSL_FLAG(int,
+ snum_streams,
+ 0,
+ "Number of screenshare streams to show or analyze.");
+
+ABSL_FLAG(int,
+ snum_spatial_layers,
+ 1,
+ "Number of screenshare spatial layers to use.");
+
+ABSL_FLAG(int,
+ sinter_layer_pred,
+ 0,
+ "Screenshare inter-layer prediction mode. "
+ "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
+
+ABSL_FLAG(
+ std::string,
+ sstream0,
+ "",
+ "Comma separated values describing VideoStream for screenshare stream #0.");
+
+ABSL_FLAG(
+ std::string,
+ sstream1,
+ "",
+ "Comma separated values describing VideoStream for screenshare stream #1.");
+
+ABSL_FLAG(
+ std::string,
+ ssl0,
+ "",
+ "Comma separated values describing SpatialLayer for screenshare layer #0.");
+
+ABSL_FLAG(
+ std::string,
+ ssl1,
+ "",
+ "Comma separated values describing SpatialLayer for screenshare layer #1.");
+
+ABSL_FLAG(int,
+ sselected_tl,
+ -1,
+ "Temporal layer to show or analyze for screenshare. -1 to disable "
+ "filtering.");
+
+ABSL_FLAG(int,
+ sselected_stream,
+ 0,
+ "ID of the stream to show or analyze for screenshare."
+ "Set to the number of streams to show them all.");
+
+ABSL_FLAG(int,
+ sselected_sl,
+ -1,
+ "Spatial layer to show or analyze for screenshare. -1 to disable "
+ "filtering.");
+
+ABSL_FLAG(bool,
+ generate_slides,
+ false,
+ "Whether to use randomly generated slides or read them from files.");
+
+ABSL_FLAG(int,
+ slide_change_interval,
+ 10,
+ "Interval (in seconds) between simulated slide changes.");
+
+ABSL_FLAG(
+ int,
+ scroll_duration,
+ 0,
+ "Duration (in seconds) during which a slide will be scrolled into place.");
+
+ABSL_FLAG(std::string,
+ slides,
+ "",
+ "Comma-separated list of *.yuv files to display as slides.");
+
+// Flags common with screenshare and video loopback, with equal default values.
+ABSL_FLAG(int, start_bitrate, 600, "Call start bitrate in kbps.");
+
+ABSL_FLAG(std::string, codec, "VP8", "Video codec to use.");
+
+ABSL_FLAG(bool,
+ analyze_video,
+ false,
+ "Analyze video stream (if --duration is present)");
+
+ABSL_FLAG(bool,
+ analyze_screenshare,
+ false,
+ "Analyze screenshare stream (if --duration is present)");
+
+ABSL_FLAG(
+ int,
+ duration,
+ 0,
+ "Duration of the test in seconds. If 0, rendered will be shown instead.");
+
+ABSL_FLAG(std::string, output_filename, "", "Target graph data filename.");
+
+ABSL_FLAG(std::string,
+ graph_title,
+ "",
+ "If empty, title will be generated automatically.");
+
+ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost.");
+
+ABSL_FLAG(int,
+ avg_burst_loss_length,
+ -1,
+ "Average burst length of lost packets.");
+
+ABSL_FLAG(int,
+ link_capacity,
+ 0,
+ "Capacity (kbps) of the fake link. 0 means infinite.");
+
+ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets.");
+
+ABSL_FLAG(int,
+ avg_propagation_delay_ms,
+ 0,
+ "Average link propagation delay in ms.");
+
+ABSL_FLAG(std::string,
+ rtc_event_log_name,
+ "",
+ "Filename for rtc event log. Two files "
+ "with \"_send\" and \"_recv\" suffixes will be created. "
+ "Works only when --duration is set.");
+
+ABSL_FLAG(std::string,
+ rtp_dump_name,
+ "",
+ "Filename for dumped received RTP stream.");
+
+ABSL_FLAG(int,
+ std_propagation_delay_ms,
+ 0,
+ "Link propagation delay standard deviation in ms.");
+
+ABSL_FLAG(std::string,
+ encoded_frame_path,
+ "",
+ "The base path for encoded frame logs. Created files will have "
+ "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
+
+ABSL_FLAG(bool, logs, false, "print logs to stderr");
+
+ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation");
+
+ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor.");
+
+ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur");
+
+ABSL_FLAG(bool, use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
+
+ABSL_FLAG(bool, use_flexfec, false, "Use FlexFEC forward error correction.");
+
+ABSL_FLAG(bool, audio, false, "Add audio stream");
+
+ABSL_FLAG(bool,
+ audio_video_sync,
+ false,
+ "Sync audio and video stream (no effect if"
+ " audio is false)");
+
+ABSL_FLAG(bool,
+ audio_dtx,
+ false,
+ "Enable audio DTX (no effect if audio is false)");
+
+ABSL_FLAG(bool, video, true, "Add video stream");
+
+ABSL_FLAG(
+ std::string,
+ force_fieldtrials,
+ "",
+ "Field trials control experimental feature code which can be forced. "
+ "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
+ " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
+ "trials are separated by \"/\"");
+
+// Video-specific flags.
+ABSL_FLAG(std::string,
+ vclip,
+ "",
+ "Name of the clip to show. If empty, the camera is used. Use "
+ "\"Generator\" for chroma generator.");
+
namespace webrtc {
-namespace flags {
+namespace {
InterLayerPredMode IntToInterLayerPredMode(int inter_layer_pred) {
if (inter_layer_pred == 0) {
@@ -44,471 +342,247 @@
}
}
-// Flags for video.
-WEBRTC_DEFINE_int(vwidth, 640, "Video width.");
size_t VideoWidth() {
- return static_cast<size_t>(FLAG_vwidth);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_vwidth));
}
-WEBRTC_DEFINE_int(vheight, 480, "Video height.");
size_t VideoHeight() {
- return static_cast<size_t>(FLAG_vheight);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_vheight));
}
-WEBRTC_DEFINE_int(vfps, 30, "Video frames per second.");
int VideoFps() {
- return static_cast<int>(FLAG_vfps);
+ return absl::GetFlag(FLAGS_vfps);
}
-WEBRTC_DEFINE_int(capture_device_index,
- 0,
- "Capture device to select for video stream");
size_t GetCaptureDevice() {
- return static_cast<size_t>(FLAG_capture_device_index);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_capture_device_index));
}
-WEBRTC_DEFINE_int(vtarget_bitrate, 400, "Video stream target bitrate in kbps.");
int VideoTargetBitrateKbps() {
- return static_cast<int>(FLAG_vtarget_bitrate);
+ return absl::GetFlag(FLAGS_vtarget_bitrate);
}
-WEBRTC_DEFINE_int(vmin_bitrate, 100, "Video stream min bitrate in kbps.");
int VideoMinBitrateKbps() {
- return static_cast<int>(FLAG_vmin_bitrate);
+ return absl::GetFlag(FLAGS_vmin_bitrate);
}
-WEBRTC_DEFINE_int(vmax_bitrate, 2000, "Video stream max bitrate in kbps.");
int VideoMaxBitrateKbps() {
- return static_cast<int>(FLAG_vmax_bitrate);
+ return absl::GetFlag(FLAGS_vmax_bitrate);
}
-WEBRTC_DEFINE_bool(suspend_below_min_bitrate,
- false,
- "Suspends video below the configured min bitrate.");
-
-WEBRTC_DEFINE_int(
- vnum_temporal_layers,
- 1,
- "Number of temporal layers for video. Set to 1-4 to override.");
int VideoNumTemporalLayers() {
- return static_cast<int>(FLAG_vnum_temporal_layers);
+ return absl::GetFlag(FLAGS_vnum_temporal_layers);
}
-WEBRTC_DEFINE_int(vnum_streams,
- 0,
- "Number of video streams to show or analyze.");
int VideoNumStreams() {
- return static_cast<int>(FLAG_vnum_streams);
+ return absl::GetFlag(FLAGS_vnum_streams);
}
-WEBRTC_DEFINE_int(vnum_spatial_layers,
- 1,
- "Number of video spatial layers to use.");
int VideoNumSpatialLayers() {
- return static_cast<int>(FLAG_vnum_spatial_layers);
+ return absl::GetFlag(FLAGS_vnum_spatial_layers);
}
-WEBRTC_DEFINE_int(
- vinter_layer_pred,
- 2,
- "Video inter-layer prediction mode. "
- "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
InterLayerPredMode VideoInterLayerPred() {
- return IntToInterLayerPredMode(FLAG_vinter_layer_pred);
+ return IntToInterLayerPredMode(absl::GetFlag(FLAGS_vinter_layer_pred));
}
-WEBRTC_DEFINE_string(
- vstream0,
- "",
- "Comma separated values describing VideoStream for video stream #0.");
std::string VideoStream0() {
- return static_cast<std::string>(FLAG_vstream0);
+ return absl::GetFlag(FLAGS_vstream0);
}
-WEBRTC_DEFINE_string(
- vstream1,
- "",
- "Comma separated values describing VideoStream for video stream #1.");
std::string VideoStream1() {
- return static_cast<std::string>(FLAG_vstream1);
+ return absl::GetFlag(FLAGS_vstream1);
}
-WEBRTC_DEFINE_string(
- vsl0,
- "",
- "Comma separated values describing SpatialLayer for video layer #0.");
std::string VideoSL0() {
- return static_cast<std::string>(FLAG_vsl0);
+ return absl::GetFlag(FLAGS_vsl0);
}
-WEBRTC_DEFINE_string(
- vsl1,
- "",
- "Comma separated values describing SpatialLayer for video layer #1.");
std::string VideoSL1() {
- return static_cast<std::string>(FLAG_vsl1);
+ return absl::GetFlag(FLAGS_vsl1);
}
-WEBRTC_DEFINE_int(
- vselected_tl,
- -1,
- "Temporal layer to show or analyze for screenshare. -1 to disable "
- "filtering.");
int VideoSelectedTL() {
- return static_cast<int>(FLAG_vselected_tl);
+ return absl::GetFlag(FLAGS_vselected_tl);
}
-WEBRTC_DEFINE_int(vselected_stream,
- 0,
- "ID of the stream to show or analyze for screenshare."
- "Set to the number of streams to show them all.");
int VideoSelectedStream() {
- return static_cast<int>(FLAG_vselected_stream);
+ return absl::GetFlag(FLAGS_vselected_stream);
}
-WEBRTC_DEFINE_int(
- vselected_sl,
- -1,
- "Spatial layer to show or analyze for screenshare. -1 to disable "
- "filtering.");
int VideoSelectedSL() {
- return static_cast<int>(FLAG_vselected_sl);
+ return absl::GetFlag(FLAGS_vselected_sl);
}
-// Flags for screenshare.
-WEBRTC_DEFINE_int(min_transmit_bitrate,
- 400,
- "Min transmit bitrate incl. padding for screenshare.");
int ScreenshareMinTransmitBitrateKbps() {
- return FLAG_min_transmit_bitrate;
+ return absl::GetFlag(FLAGS_min_transmit_bitrate);
}
-WEBRTC_DEFINE_int(swidth, 1850, "Screenshare width (crops source).");
size_t ScreenshareWidth() {
- return static_cast<size_t>(FLAG_swidth);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_swidth));
}
-WEBRTC_DEFINE_int(sheight, 1110, "Screenshare height (crops source).");
size_t ScreenshareHeight() {
- return static_cast<size_t>(FLAG_sheight);
+ return static_cast<size_t>(absl::GetFlag(FLAGS_sheight));
}
-WEBRTC_DEFINE_int(sfps, 5, "Frames per second for screenshare.");
int ScreenshareFps() {
- return static_cast<int>(FLAG_sfps);
+ return absl::GetFlag(FLAGS_sfps);
}
-WEBRTC_DEFINE_int(starget_bitrate,
- 100,
- "Screenshare stream target bitrate in kbps.");
int ScreenshareTargetBitrateKbps() {
- return static_cast<int>(FLAG_starget_bitrate);
+ return absl::GetFlag(FLAGS_starget_bitrate);
}
-WEBRTC_DEFINE_int(smin_bitrate, 100, "Screenshare stream min bitrate in kbps.");
int ScreenshareMinBitrateKbps() {
- return static_cast<int>(FLAG_smin_bitrate);
+ return absl::GetFlag(FLAGS_smin_bitrate);
}
-WEBRTC_DEFINE_int(smax_bitrate,
- 2000,
- "Screenshare stream max bitrate in kbps.");
int ScreenshareMaxBitrateKbps() {
- return static_cast<int>(FLAG_smax_bitrate);
+ return absl::GetFlag(FLAGS_smax_bitrate);
}
-WEBRTC_DEFINE_int(snum_temporal_layers,
- 2,
- "Number of temporal layers to use in screenshare.");
int ScreenshareNumTemporalLayers() {
- return static_cast<int>(FLAG_snum_temporal_layers);
+ return absl::GetFlag(FLAGS_snum_temporal_layers);
}
-WEBRTC_DEFINE_int(snum_streams,
- 0,
- "Number of screenshare streams to show or analyze.");
int ScreenshareNumStreams() {
- return static_cast<int>(FLAG_snum_streams);
+ return absl::GetFlag(FLAGS_snum_streams);
}
-WEBRTC_DEFINE_int(snum_spatial_layers,
- 1,
- "Number of screenshare spatial layers to use.");
int ScreenshareNumSpatialLayers() {
- return static_cast<int>(FLAG_snum_spatial_layers);
+ return absl::GetFlag(FLAGS_snum_spatial_layers);
}
-WEBRTC_DEFINE_int(
- sinter_layer_pred,
- 0,
- "Screenshare inter-layer prediction mode. "
- "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
InterLayerPredMode ScreenshareInterLayerPred() {
- return IntToInterLayerPredMode(FLAG_sinter_layer_pred);
+ return IntToInterLayerPredMode(absl::GetFlag(FLAGS_sinter_layer_pred));
}
-WEBRTC_DEFINE_string(
- sstream0,
- "",
- "Comma separated values describing VideoStream for screenshare stream #0.");
std::string ScreenshareStream0() {
- return static_cast<std::string>(FLAG_sstream0);
+ return absl::GetFlag(FLAGS_sstream0);
}
-WEBRTC_DEFINE_string(
- sstream1,
- "",
- "Comma separated values describing VideoStream for screenshare stream #1.");
std::string ScreenshareStream1() {
- return static_cast<std::string>(FLAG_sstream1);
+ return absl::GetFlag(FLAGS_sstream1);
}
-WEBRTC_DEFINE_string(
- ssl0,
- "",
- "Comma separated values describing SpatialLayer for screenshare layer #0.");
std::string ScreenshareSL0() {
- return static_cast<std::string>(FLAG_ssl0);
+ return absl::GetFlag(FLAGS_ssl0);
}
-WEBRTC_DEFINE_string(
- ssl1,
- "",
- "Comma separated values describing SpatialLayer for screenshare layer #1.");
std::string ScreenshareSL1() {
- return static_cast<std::string>(FLAG_ssl1);
+ return absl::GetFlag(FLAGS_ssl1);
}
-WEBRTC_DEFINE_int(
- sselected_tl,
- -1,
- "Temporal layer to show or analyze for screenshare. -1 to disable "
- "filtering.");
int ScreenshareSelectedTL() {
- return static_cast<int>(FLAG_sselected_tl);
+ return absl::GetFlag(FLAGS_sselected_tl);
}
-WEBRTC_DEFINE_int(sselected_stream,
- 0,
- "ID of the stream to show or analyze for screenshare."
- "Set to the number of streams to show them all.");
int ScreenshareSelectedStream() {
- return static_cast<int>(FLAG_sselected_stream);
+ return absl::GetFlag(FLAGS_sselected_stream);
}
-WEBRTC_DEFINE_int(
- sselected_sl,
- -1,
- "Spatial layer to show or analyze for screenshare. -1 to disable "
- "filtering.");
int ScreenshareSelectedSL() {
- return static_cast<int>(FLAG_sselected_sl);
+ return absl::GetFlag(FLAGS_sselected_sl);
}
-WEBRTC_DEFINE_bool(
- generate_slides,
- false,
- "Whether to use randomly generated slides or read them from files.");
bool GenerateSlides() {
- return static_cast<int>(FLAG_generate_slides);
+ return absl::GetFlag(FLAGS_generate_slides);
}
-WEBRTC_DEFINE_int(slide_change_interval,
- 10,
- "Interval (in seconds) between simulated slide changes.");
int SlideChangeInterval() {
- return static_cast<int>(FLAG_slide_change_interval);
+ return absl::GetFlag(FLAGS_slide_change_interval);
}
-WEBRTC_DEFINE_int(
- scroll_duration,
- 0,
- "Duration (in seconds) during which a slide will be scrolled into place.");
int ScrollDuration() {
- return static_cast<int>(FLAG_scroll_duration);
+ return absl::GetFlag(FLAGS_scroll_duration);
}
-WEBRTC_DEFINE_string(
- slides,
- "",
- "Comma-separated list of *.yuv files to display as slides.");
std::vector<std::string> Slides() {
std::vector<std::string> slides;
- std::string slides_list = FLAG_slides;
+ std::string slides_list = absl::GetFlag(FLAGS_slides);
rtc::tokenize(slides_list, ',', &slides);
return slides;
}
-// Flags common with screenshare and video loopback, with equal default values.
-WEBRTC_DEFINE_int(start_bitrate, 600, "Call start bitrate in kbps.");
int StartBitrateKbps() {
- return static_cast<int>(FLAG_start_bitrate);
+ return absl::GetFlag(FLAGS_start_bitrate);
}
-WEBRTC_DEFINE_string(codec, "VP8", "Video codec to use.");
std::string Codec() {
- return static_cast<std::string>(FLAG_codec);
+ return absl::GetFlag(FLAGS_codec);
}
-WEBRTC_DEFINE_bool(analyze_video,
- false,
- "Analyze video stream (if --duration is present)");
bool AnalyzeVideo() {
- return static_cast<bool>(FLAG_analyze_video);
+ return absl::GetFlag(FLAGS_analyze_video);
}
-WEBRTC_DEFINE_bool(analyze_screenshare,
- false,
- "Analyze screenshare stream (if --duration is present)");
bool AnalyzeScreenshare() {
- return static_cast<bool>(FLAG_analyze_screenshare);
+ return absl::GetFlag(FLAGS_analyze_screenshare);
}
-WEBRTC_DEFINE_int(
- duration,
- 0,
- "Duration of the test in seconds. If 0, rendered will be shown instead.");
int DurationSecs() {
- return static_cast<int>(FLAG_duration);
+ return absl::GetFlag(FLAGS_duration);
}
-WEBRTC_DEFINE_string(output_filename, "", "Target graph data filename.");
std::string OutputFilename() {
- return static_cast<std::string>(FLAG_output_filename);
+ return absl::GetFlag(FLAGS_output_filename);
}
-WEBRTC_DEFINE_string(graph_title,
- "",
- "If empty, title will be generated automatically.");
std::string GraphTitle() {
- return static_cast<std::string>(FLAG_graph_title);
+ return absl::GetFlag(FLAGS_graph_title);
}
-WEBRTC_DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
int LossPercent() {
- return static_cast<int>(FLAG_loss_percent);
+ return absl::GetFlag(FLAGS_loss_percent);
}
-WEBRTC_DEFINE_int(avg_burst_loss_length,
- -1,
- "Average burst length of lost packets.");
int AvgBurstLossLength() {
- return static_cast<int>(FLAG_avg_burst_loss_length);
+ return absl::GetFlag(FLAGS_avg_burst_loss_length);
}
-WEBRTC_DEFINE_int(link_capacity,
- 0,
- "Capacity (kbps) of the fake link. 0 means infinite.");
int LinkCapacityKbps() {
- return static_cast<int>(FLAG_link_capacity);
+ return absl::GetFlag(FLAGS_link_capacity);
}
-WEBRTC_DEFINE_int(queue_size,
- 0,
- "Size of the bottleneck link queue in packets.");
int QueueSize() {
- return static_cast<int>(FLAG_queue_size);
+ return absl::GetFlag(FLAGS_queue_size);
}
-WEBRTC_DEFINE_int(avg_propagation_delay_ms,
- 0,
- "Average link propagation delay in ms.");
int AvgPropagationDelayMs() {
- return static_cast<int>(FLAG_avg_propagation_delay_ms);
+ return absl::GetFlag(FLAGS_avg_propagation_delay_ms);
}
-WEBRTC_DEFINE_string(rtc_event_log_name,
- "",
- "Filename for rtc event log. Two files "
- "with \"_send\" and \"_recv\" suffixes will be created. "
- "Works only when --duration is set.");
std::string RtcEventLogName() {
- return static_cast<std::string>(FLAG_rtc_event_log_name);
+ return absl::GetFlag(FLAGS_rtc_event_log_name);
}
-WEBRTC_DEFINE_string(rtp_dump_name,
- "",
- "Filename for dumped received RTP stream.");
std::string RtpDumpName() {
- return static_cast<std::string>(FLAG_rtp_dump_name);
+ return absl::GetFlag(FLAGS_rtp_dump_name);
}
-WEBRTC_DEFINE_int(std_propagation_delay_ms,
- 0,
- "Link propagation delay standard deviation in ms.");
int StdPropagationDelayMs() {
- return static_cast<int>(FLAG_std_propagation_delay_ms);
+ return absl::GetFlag(FLAGS_std_propagation_delay_ms);
}
-WEBRTC_DEFINE_string(
- encoded_frame_path,
- "",
- "The base path for encoded frame logs. Created files will have "
- "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
std::string EncodedFramePath() {
- return static_cast<std::string>(FLAG_encoded_frame_path);
+ return absl::GetFlag(FLAGS_encoded_frame_path);
}
-WEBRTC_DEFINE_bool(logs, false, "print logs to stderr");
-
-WEBRTC_DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
-
-WEBRTC_DEFINE_bool(generic_descriptor,
- false,
- "Use the generic frame descriptor.");
-
-WEBRTC_DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
-
-WEBRTC_DEFINE_bool(use_ulpfec,
- false,
- "Use RED+ULPFEC forward error correction.");
-
-WEBRTC_DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction.");
-
-WEBRTC_DEFINE_bool(audio, false, "Add audio stream");
-
-WEBRTC_DEFINE_bool(audio_video_sync,
- false,
- "Sync audio and video stream (no effect if"
- " audio is false)");
-
-WEBRTC_DEFINE_bool(audio_dtx,
- false,
- "Enable audio DTX (no effect if audio is false)");
-
-WEBRTC_DEFINE_bool(video, true, "Add video stream");
-
-WEBRTC_DEFINE_string(
- force_fieldtrials,
- "",
- "Field trials control experimental feature code which can be forced. "
- "E.g. running with --force_fieldtrials=WebRTC-FooFeature/Enable/"
- " will assign the group Enable to field trial WebRTC-FooFeature. Multiple "
- "trials are separated by \"/\"");
-
-// Video-specific flags.
-WEBRTC_DEFINE_string(
- vclip,
- "",
- "Name of the clip to show. If empty, the camera is used. Use "
- "\"Generator\" for chroma generator.");
std::string VideoClip() {
- return static_cast<std::string>(FLAG_vclip);
+ return absl::GetFlag(FLAGS_vclip);
}
-WEBRTC_DEFINE_bool(help, false, "prints this message");
-
-} // namespace flags
+} // namespace
void Loopback() {
int camera_idx, screenshare_idx;
- RTC_CHECK(!(flags::AnalyzeScreenshare() && flags::AnalyzeVideo()))
+ RTC_CHECK(!(AnalyzeScreenshare() && AnalyzeVideo()))
<< "Select only one of video or screenshare.";
- RTC_CHECK(!flags::DurationSecs() || flags::AnalyzeScreenshare() ||
- flags::AnalyzeVideo())
+ RTC_CHECK(!DurationSecs() || AnalyzeScreenshare() || AnalyzeVideo())
<< "If duration is set, exactly one of analyze_* flags should be set.";
// Default: camera feed first, if nothing selected.
- if (flags::AnalyzeVideo() || !flags::AnalyzeScreenshare()) {
+ if (AnalyzeVideo() || !AnalyzeScreenshare()) {
camera_idx = 0;
screenshare_idx = 1;
} else {
@@ -517,114 +591,106 @@
}
BuiltInNetworkBehaviorConfig pipe_config;
- pipe_config.loss_percent = flags::LossPercent();
- pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
- pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
- pipe_config.queue_length_packets = flags::QueueSize();
- pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
- pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
- pipe_config.allow_reordering = flags::FLAG_allow_reordering;
+ pipe_config.loss_percent = LossPercent();
+ pipe_config.avg_burst_loss_length = AvgBurstLossLength();
+ pipe_config.link_capacity_kbps = LinkCapacityKbps();
+ pipe_config.queue_length_packets = QueueSize();
+ pipe_config.queue_delay_ms = AvgPropagationDelayMs();
+ pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs();
+ pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering);
BitrateConstraints call_bitrate_config;
call_bitrate_config.min_bitrate_bps =
- (flags::ScreenshareMinBitrateKbps() + flags::VideoMinBitrateKbps()) *
- 1000;
- call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
+ (ScreenshareMinBitrateKbps() + VideoMinBitrateKbps()) * 1000;
+ call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000;
call_bitrate_config.max_bitrate_bps =
- (flags::ScreenshareMaxBitrateKbps() + flags::VideoMaxBitrateKbps()) *
- 1000;
+ (ScreenshareMaxBitrateKbps() + VideoMaxBitrateKbps()) * 1000;
VideoQualityTest::Params params, camera_params, screenshare_params;
- params.call = {flags::FLAG_send_side_bwe, flags::FLAG_generic_descriptor,
- call_bitrate_config, 0};
+ params.call = {absl::GetFlag(FLAGS_send_side_bwe),
+ absl::GetFlag(FLAGS_generic_descriptor), call_bitrate_config,
+ 0};
params.call.dual_video = true;
- params.video[screenshare_idx] = {
- true,
- flags::ScreenshareWidth(),
- flags::ScreenshareHeight(),
- flags::ScreenshareFps(),
- flags::ScreenshareMinBitrateKbps() * 1000,
- flags::ScreenshareTargetBitrateKbps() * 1000,
- flags::ScreenshareMaxBitrateKbps() * 1000,
- false,
- flags::Codec(),
- flags::ScreenshareNumTemporalLayers(),
- flags::ScreenshareSelectedTL(),
- flags::ScreenshareMinTransmitBitrateKbps() * 1000,
- false, // ULPFEC disabled.
- false, // FlexFEC disabled.
- false, // Automatic scaling disabled
- ""};
- params.video[camera_idx] = {flags::FLAG_video,
- flags::VideoWidth(),
- flags::VideoHeight(),
- flags::VideoFps(),
- flags::VideoMinBitrateKbps() * 1000,
- flags::VideoTargetBitrateKbps() * 1000,
- flags::VideoMaxBitrateKbps() * 1000,
- flags::FLAG_suspend_below_min_bitrate,
- flags::Codec(),
- flags::VideoNumTemporalLayers(),
- flags::VideoSelectedTL(),
+ params.video[screenshare_idx] = {true,
+ ScreenshareWidth(),
+ ScreenshareHeight(),
+ ScreenshareFps(),
+ ScreenshareMinBitrateKbps() * 1000,
+ ScreenshareTargetBitrateKbps() * 1000,
+ ScreenshareMaxBitrateKbps() * 1000,
+ false,
+ Codec(),
+ ScreenshareNumTemporalLayers(),
+ ScreenshareSelectedTL(),
+ ScreenshareMinTransmitBitrateKbps() * 1000,
+ false, // ULPFEC disabled.
+ false, // FlexFEC disabled.
+ false, // Automatic scaling disabled
+ ""};
+ params.video[camera_idx] = {absl::GetFlag(FLAGS_video),
+ VideoWidth(),
+ VideoHeight(),
+ VideoFps(),
+ VideoMinBitrateKbps() * 1000,
+ VideoTargetBitrateKbps() * 1000,
+ VideoMaxBitrateKbps() * 1000,
+ absl::GetFlag(FLAGS_suspend_below_min_bitrate),
+ Codec(),
+ VideoNumTemporalLayers(),
+ VideoSelectedTL(),
0, // No min transmit bitrate.
- flags::FLAG_use_ulpfec,
- flags::FLAG_use_flexfec,
+ absl::GetFlag(FLAGS_use_ulpfec),
+ absl::GetFlag(FLAGS_use_flexfec),
false,
- flags::VideoClip(),
- flags::GetCaptureDevice()};
- params.audio = {flags::FLAG_audio, flags::FLAG_audio_video_sync,
- flags::FLAG_audio_dtx};
- params.logging = {flags::FLAG_rtc_event_log_name, flags::FLAG_rtp_dump_name,
- flags::FLAG_encoded_frame_path};
- params.analyzer = {"dual_streams",
- 0.0,
- 0.0,
- flags::DurationSecs(),
- flags::OutputFilename(),
- flags::GraphTitle()};
+ VideoClip(),
+ GetCaptureDevice()};
+ params.audio = {absl::GetFlag(FLAGS_audio),
+ absl::GetFlag(FLAGS_audio_video_sync),
+ absl::GetFlag(FLAGS_audio_dtx)};
+ params.logging = {RtcEventLogName(), RtpDumpName(), EncodedFramePath()};
+ params.analyzer = {"dual_streams", 0.0, 0.0, DurationSecs(),
+ OutputFilename(), GraphTitle()};
params.config = pipe_config;
params.screenshare[camera_idx].enabled = false;
- params.screenshare[screenshare_idx] = {
- true, flags::GenerateSlides(), flags::SlideChangeInterval(),
- flags::ScrollDuration(), flags::Slides()};
+ params.screenshare[screenshare_idx] = {true, GenerateSlides(),
+ SlideChangeInterval(),
+ ScrollDuration(), Slides()};
- if (flags::VideoNumStreams() > 1 && flags::VideoStream0().empty() &&
- flags::VideoStream1().empty()) {
+ if (VideoNumStreams() > 1 && VideoStream0().empty() &&
+ VideoStream1().empty()) {
params.ss[camera_idx].infer_streams = true;
}
- if (flags::ScreenshareNumStreams() > 1 &&
- flags::ScreenshareStream0().empty() &&
- flags::ScreenshareStream1().empty()) {
+ if (ScreenshareNumStreams() > 1 && ScreenshareStream0().empty() &&
+ ScreenshareStream1().empty()) {
params.ss[screenshare_idx].infer_streams = true;
}
std::vector<std::string> stream_descriptors;
- stream_descriptors.push_back(flags::ScreenshareStream0());
- stream_descriptors.push_back(flags::ScreenshareStream1());
+ stream_descriptors.push_back(ScreenshareStream0());
+ stream_descriptors.push_back(ScreenshareStream1());
std::vector<std::string> SL_descriptors;
- SL_descriptors.push_back(flags::ScreenshareSL0());
- SL_descriptors.push_back(flags::ScreenshareSL1());
+ SL_descriptors.push_back(ScreenshareSL0());
+ SL_descriptors.push_back(ScreenshareSL1());
VideoQualityTest::FillScalabilitySettings(
- ¶ms, screenshare_idx, stream_descriptors,
- flags::ScreenshareNumStreams(), flags::ScreenshareSelectedStream(),
- flags::ScreenshareNumSpatialLayers(), flags::ScreenshareSelectedSL(),
- flags::ScreenshareInterLayerPred(), SL_descriptors);
+ ¶ms, screenshare_idx, stream_descriptors, ScreenshareNumStreams(),
+ ScreenshareSelectedStream(), ScreenshareNumSpatialLayers(),
+ ScreenshareSelectedSL(), ScreenshareInterLayerPred(), SL_descriptors);
stream_descriptors.clear();
- stream_descriptors.push_back(flags::VideoStream0());
- stream_descriptors.push_back(flags::VideoStream1());
+ stream_descriptors.push_back(VideoStream0());
+ stream_descriptors.push_back(VideoStream1());
SL_descriptors.clear();
- SL_descriptors.push_back(flags::VideoSL0());
- SL_descriptors.push_back(flags::VideoSL1());
+ SL_descriptors.push_back(VideoSL0());
+ SL_descriptors.push_back(VideoSL1());
VideoQualityTest::FillScalabilitySettings(
- ¶ms, camera_idx, stream_descriptors, flags::VideoNumStreams(),
- flags::VideoSelectedStream(), flags::VideoNumSpatialLayers(),
- flags::VideoSelectedSL(), flags::VideoInterLayerPred(), SL_descriptors);
+ ¶ms, camera_idx, stream_descriptors, VideoNumStreams(),
+ VideoSelectedStream(), VideoNumSpatialLayers(), VideoSelectedSL(),
+ VideoInterLayerPred(), SL_descriptors);
auto fixture = absl::make_unique<VideoQualityTest>(nullptr);
- if (flags::DurationSecs()) {
+ if (DurationSecs()) {
fixture->RunWithAnalyzer(params);
} else {
fixture->RunWithRenderers(params);
@@ -634,21 +700,14 @@
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true) != 0) {
- // Fail on unrecognized flags.
- return 1;
- }
- if (webrtc::flags::FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
+ absl::ParseCommandLine(argc, argv);
- rtc::LogMessage::SetLogToStderr(webrtc::flags::FLAG_logs);
+ rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs));
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
- webrtc::field_trial::InitFieldTrialsFromString(
- webrtc::flags::FLAG_force_fieldtrials);
+ const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
webrtc::test::RunTest(webrtc::Loopback);
return 0;
diff --git a/video/video_analyzer.cc b/video/video_analyzer.cc
index 7efbaf3..fa18d00 100644
--- a/video/video_analyzer.cc
+++ b/video/video_analyzer.cc
@@ -13,11 +13,12 @@
#include <utility>
#include "absl/algorithm/container.h"
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "common_video/libyuv/include/webrtc_libyuv.h"
#include "modules/rtp_rtcp/source/rtp_format.h"
#include "modules/rtp_rtcp/source/rtp_utility.h"
#include "rtc_base/cpu_time.h"
-#include "rtc_base/flags.h"
#include "rtc_base/format_macros.h"
#include "rtc_base/memory_usage.h"
#include "system_wrappers/include/cpu_info.h"
@@ -27,11 +28,11 @@
#include "test/testsupport/perf_test.h"
#include "test/testsupport/test_artifacts.h"
-WEBRTC_DEFINE_bool(
- save_worst_frame,
- false,
- "Enable saving a frame with the lowest PSNR to a jpeg file in the "
- "test_artifacts_dir");
+ABSL_FLAG(bool,
+ save_worst_frame,
+ false,
+ "Enable saving a frame with the lowest PSNR to a jpeg file in the "
+ "test_artifacts_dir");
namespace webrtc {
namespace {
@@ -718,7 +719,7 @@
// Saving only the worst frame for manual analysis. Intention here is to
// only detect video corruptions and not to track picture quality. Thus,
// jpeg is used here.
- if (FLAG_save_worst_frame && worst_frame_) {
+ if (absl::GetFlag(FLAGS_save_worst_frame) && worst_frame_) {
std::string output_dir;
test::GetTestArtifactsDir(&output_dir);
std::string output_path =
diff --git a/video/video_loopback.cc b/video/video_loopback.cc
index f4b2bfa..4270ba9 100644
--- a/video/video_loopback.cc
+++ b/video/video_loopback.cc
@@ -15,6 +15,8 @@
#include <string>
#include <vector>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "absl/types/optional.h"
#include "api/bitrate_constraints.h"
@@ -22,7 +24,6 @@
#include "api/test/video_quality_test_fixture.h"
#include "api/video_codecs/video_codec.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
@@ -30,275 +31,175 @@
#include "test/run_test.h"
#include "video/video_quality_test.h"
-namespace webrtc {
-namespace flags {
-
// Flags common with screenshare loopback, with different default values.
-WEBRTC_DEFINE_int(width, 640, "Video width.");
-size_t Width() {
- return static_cast<size_t>(FLAG_width);
-}
+ABSL_FLAG(int, width, 640, "Video width.");
-WEBRTC_DEFINE_int(height, 480, "Video height.");
-size_t Height() {
- return static_cast<size_t>(FLAG_height);
-}
+ABSL_FLAG(int, height, 480, "Video height.");
-WEBRTC_DEFINE_int(fps, 30, "Frames per second.");
-int Fps() {
- return static_cast<int>(FLAG_fps);
-}
+ABSL_FLAG(int, fps, 30, "Frames per second.");
-WEBRTC_DEFINE_int(capture_device_index, 0, "Capture device to select");
-size_t GetCaptureDevice() {
- return static_cast<size_t>(FLAG_capture_device_index);
-}
+ABSL_FLAG(int, capture_device_index, 0, "Capture device to select");
-WEBRTC_DEFINE_int(min_bitrate, 50, "Call and stream min bitrate in kbps.");
-int MinBitrateKbps() {
- return static_cast<int>(FLAG_min_bitrate);
-}
+ABSL_FLAG(int, min_bitrate, 50, "Call and stream min bitrate in kbps.");
-WEBRTC_DEFINE_int(start_bitrate, 300, "Call start bitrate in kbps.");
-int StartBitrateKbps() {
- return static_cast<int>(FLAG_start_bitrate);
-}
+ABSL_FLAG(int, start_bitrate, 300, "Call start bitrate in kbps.");
-WEBRTC_DEFINE_int(target_bitrate, 800, "Stream target bitrate in kbps.");
-int TargetBitrateKbps() {
- return static_cast<int>(FLAG_target_bitrate);
-}
+ABSL_FLAG(int, target_bitrate, 800, "Stream target bitrate in kbps.");
-WEBRTC_DEFINE_int(max_bitrate, 800, "Call and stream max bitrate in kbps.");
-int MaxBitrateKbps() {
- return static_cast<int>(FLAG_max_bitrate);
-}
+ABSL_FLAG(int, max_bitrate, 800, "Call and stream max bitrate in kbps.");
-WEBRTC_DEFINE_bool(suspend_below_min_bitrate,
- false,
- "Suspends video below the configured min bitrate.");
+ABSL_FLAG(bool,
+ suspend_below_min_bitrate,
+ false,
+ "Suspends video below the configured min bitrate.");
-WEBRTC_DEFINE_int(num_temporal_layers,
- 1,
- "Number of temporal layers. Set to 1-4 to override.");
-int NumTemporalLayers() {
- return static_cast<int>(FLAG_num_temporal_layers);
-}
+ABSL_FLAG(int,
+ num_temporal_layers,
+ 1,
+ "Number of temporal layers. Set to 1-4 to override.");
-WEBRTC_DEFINE_int(
- inter_layer_pred,
- 2,
- "Inter-layer prediction mode. "
- "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
-InterLayerPredMode InterLayerPred() {
- if (FLAG_inter_layer_pred == 0) {
- return InterLayerPredMode::kOn;
- } else if (FLAG_inter_layer_pred == 1) {
- return InterLayerPredMode::kOff;
- } else {
- RTC_DCHECK_EQ(FLAG_inter_layer_pred, 2);
- return InterLayerPredMode::kOnKeyPic;
- }
-}
+ABSL_FLAG(int,
+ inter_layer_pred,
+ 2,
+ "Inter-layer prediction mode. "
+ "0 - enabled, 1 - disabled, 2 - enabled only for key pictures.");
// Flags common with screenshare loopback, with equal default values.
-WEBRTC_DEFINE_string(codec, "VP8", "Video codec to use.");
-std::string Codec() {
- return static_cast<std::string>(FLAG_codec);
-}
+ABSL_FLAG(std::string, codec, "VP8", "Video codec to use.");
-WEBRTC_DEFINE_int(
- selected_tl,
- -1,
- "Temporal layer to show or analyze. -1 to disable filtering.");
-int SelectedTL() {
- return static_cast<int>(FLAG_selected_tl);
-}
+ABSL_FLAG(int,
+ selected_tl,
+ -1,
+ "Temporal layer to show or analyze. -1 to disable filtering.");
-WEBRTC_DEFINE_int(
+ABSL_FLAG(
+ int,
duration,
0,
"Duration of the test in seconds. If 0, rendered will be shown instead.");
-int DurationSecs() {
- return static_cast<int>(FLAG_duration);
-}
-WEBRTC_DEFINE_string(output_filename, "", "Target graph data filename.");
-std::string OutputFilename() {
- return static_cast<std::string>(FLAG_output_filename);
-}
+ABSL_FLAG(std::string, output_filename, "", "Target graph data filename.");
-WEBRTC_DEFINE_string(graph_title,
- "",
- "If empty, title will be generated automatically.");
-std::string GraphTitle() {
- return static_cast<std::string>(FLAG_graph_title);
-}
+ABSL_FLAG(std::string,
+ graph_title,
+ "",
+ "If empty, title will be generated automatically.");
-WEBRTC_DEFINE_int(loss_percent, 0, "Percentage of packets randomly lost.");
-int LossPercent() {
- return static_cast<int>(FLAG_loss_percent);
-}
+ABSL_FLAG(int, loss_percent, 0, "Percentage of packets randomly lost.");
-WEBRTC_DEFINE_int(avg_burst_loss_length,
- -1,
- "Average burst length of lost packets.");
-int AvgBurstLossLength() {
- return static_cast<int>(FLAG_avg_burst_loss_length);
-}
+ABSL_FLAG(int,
+ avg_burst_loss_length,
+ -1,
+ "Average burst length of lost packets.");
-WEBRTC_DEFINE_int(link_capacity,
- 0,
- "Capacity (kbps) of the fake link. 0 means infinite.");
-int LinkCapacityKbps() {
- return static_cast<int>(FLAG_link_capacity);
-}
+ABSL_FLAG(int,
+ link_capacity,
+ 0,
+ "Capacity (kbps) of the fake link. 0 means infinite.");
-WEBRTC_DEFINE_int(queue_size,
- 0,
- "Size of the bottleneck link queue in packets.");
-int QueueSize() {
- return static_cast<int>(FLAG_queue_size);
-}
+ABSL_FLAG(int, queue_size, 0, "Size of the bottleneck link queue in packets.");
-WEBRTC_DEFINE_int(avg_propagation_delay_ms,
- 0,
- "Average link propagation delay in ms.");
-int AvgPropagationDelayMs() {
- return static_cast<int>(FLAG_avg_propagation_delay_ms);
-}
+ABSL_FLAG(int,
+ avg_propagation_delay_ms,
+ 0,
+ "Average link propagation delay in ms.");
-WEBRTC_DEFINE_string(rtc_event_log_name,
- "",
- "Filename for rtc event log. Two files "
- "with \"_send\" and \"_recv\" suffixes will be created.");
-std::string RtcEventLogName() {
- return static_cast<std::string>(FLAG_rtc_event_log_name);
-}
+ABSL_FLAG(std::string,
+ rtc_event_log_name,
+ "",
+ "Filename for rtc event log. Two files "
+ "with \"_send\" and \"_recv\" suffixes will be created.");
-WEBRTC_DEFINE_string(rtp_dump_name,
- "",
- "Filename for dumped received RTP stream.");
-std::string RtpDumpName() {
- return static_cast<std::string>(FLAG_rtp_dump_name);
-}
+ABSL_FLAG(std::string,
+ rtp_dump_name,
+ "",
+ "Filename for dumped received RTP stream.");
-WEBRTC_DEFINE_int(std_propagation_delay_ms,
- 0,
- "Link propagation delay standard deviation in ms.");
-int StdPropagationDelayMs() {
- return static_cast<int>(FLAG_std_propagation_delay_ms);
-}
+ABSL_FLAG(int,
+ std_propagation_delay_ms,
+ 0,
+ "Link propagation delay standard deviation in ms.");
-WEBRTC_DEFINE_int(num_streams, 0, "Number of streams to show or analyze.");
-int NumStreams() {
- return static_cast<int>(FLAG_num_streams);
-}
+ABSL_FLAG(int, num_streams, 0, "Number of streams to show or analyze.");
-WEBRTC_DEFINE_int(selected_stream,
- 0,
- "ID of the stream to show or analyze. "
- "Set to the number of streams to show them all.");
-int SelectedStream() {
- return static_cast<int>(FLAG_selected_stream);
-}
+ABSL_FLAG(int,
+ selected_stream,
+ 0,
+ "ID of the stream to show or analyze. "
+ "Set to the number of streams to show them all.");
-WEBRTC_DEFINE_int(num_spatial_layers, 1, "Number of spatial layers to use.");
-int NumSpatialLayers() {
- return static_cast<int>(FLAG_num_spatial_layers);
-}
+ABSL_FLAG(int, num_spatial_layers, 1, "Number of spatial layers to use.");
-WEBRTC_DEFINE_int(selected_sl,
- -1,
- "Spatial layer to show or analyze. -1 to disable filtering.");
-int SelectedSL() {
- return static_cast<int>(FLAG_selected_sl);
-}
+ABSL_FLAG(int,
+ selected_sl,
+ -1,
+ "Spatial layer to show or analyze. -1 to disable filtering.");
-WEBRTC_DEFINE_string(
- stream0,
- "",
- "Comma separated values describing VideoStream for stream #0.");
-std::string Stream0() {
- return static_cast<std::string>(FLAG_stream0);
-}
+ABSL_FLAG(std::string,
+ stream0,
+ "",
+ "Comma separated values describing VideoStream for stream #0.");
-WEBRTC_DEFINE_string(
- stream1,
- "",
- "Comma separated values describing VideoStream for stream #1.");
-std::string Stream1() {
- return static_cast<std::string>(FLAG_stream1);
-}
+ABSL_FLAG(std::string,
+ stream1,
+ "",
+ "Comma separated values describing VideoStream for stream #1.");
-WEBRTC_DEFINE_string(
- sl0,
- "",
- "Comma separated values describing SpatialLayer for layer #0.");
-std::string SL0() {
- return static_cast<std::string>(FLAG_sl0);
-}
+ABSL_FLAG(std::string,
+ sl0,
+ "",
+ "Comma separated values describing SpatialLayer for layer #0.");
-WEBRTC_DEFINE_string(
- sl1,
- "",
- "Comma separated values describing SpatialLayer for layer #1.");
-std::string SL1() {
- return static_cast<std::string>(FLAG_sl1);
-}
+ABSL_FLAG(std::string,
+ sl1,
+ "",
+ "Comma separated values describing SpatialLayer for layer #1.");
-WEBRTC_DEFINE_string(
- sl2,
- "",
- "Comma separated values describing SpatialLayer for layer #2.");
-std::string SL2() {
- return static_cast<std::string>(FLAG_sl2);
-}
+ABSL_FLAG(std::string,
+ sl2,
+ "",
+ "Comma separated values describing SpatialLayer for layer #2.");
-WEBRTC_DEFINE_string(
- encoded_frame_path,
- "",
- "The base path for encoded frame logs. Created files will have "
- "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
-std::string EncodedFramePath() {
- return static_cast<std::string>(FLAG_encoded_frame_path);
-}
+ABSL_FLAG(std::string,
+ encoded_frame_path,
+ "",
+ "The base path for encoded frame logs. Created files will have "
+ "the form <encoded_frame_path>.<n>.(recv|send.<m>).ivf");
-WEBRTC_DEFINE_bool(logs, false, "print logs to stderr");
+ABSL_FLAG(bool, logs, false, "print logs to stderr");
-WEBRTC_DEFINE_bool(send_side_bwe, true, "Use send-side bandwidth estimation");
+ABSL_FLAG(bool, send_side_bwe, true, "Use send-side bandwidth estimation");
-WEBRTC_DEFINE_bool(generic_descriptor,
- false,
- "Use the generic frame descriptor.");
+ABSL_FLAG(bool, generic_descriptor, false, "Use the generic frame descriptor.");
-WEBRTC_DEFINE_bool(allow_reordering, false, "Allow packet reordering to occur");
+ABSL_FLAG(bool, allow_reordering, false, "Allow packet reordering to occur");
-WEBRTC_DEFINE_bool(use_ulpfec,
- false,
- "Use RED+ULPFEC forward error correction.");
+ABSL_FLAG(bool, use_ulpfec, false, "Use RED+ULPFEC forward error correction.");
-WEBRTC_DEFINE_bool(use_flexfec, false, "Use FlexFEC forward error correction.");
+ABSL_FLAG(bool, use_flexfec, false, "Use FlexFEC forward error correction.");
-WEBRTC_DEFINE_bool(audio, false, "Add audio stream");
+ABSL_FLAG(bool, audio, false, "Add audio stream");
-WEBRTC_DEFINE_bool(
- use_real_adm,
- false,
- "Use real ADM instead of fake (no effect if audio is false)");
+ABSL_FLAG(bool,
+ use_real_adm,
+ false,
+ "Use real ADM instead of fake (no effect if audio is false)");
-WEBRTC_DEFINE_bool(audio_video_sync,
- false,
- "Sync audio and video stream (no effect if"
- " audio is false)");
+ABSL_FLAG(bool,
+ audio_video_sync,
+ false,
+ "Sync audio and video stream (no effect if"
+ " audio is false)");
-WEBRTC_DEFINE_bool(audio_dtx,
- false,
- "Enable audio DTX (no effect if audio is false)");
+ABSL_FLAG(bool,
+ audio_dtx,
+ false,
+ "Enable audio DTX (no effect if audio is false)");
-WEBRTC_DEFINE_bool(video, true, "Add video stream");
+ABSL_FLAG(bool, video, true, "Add video stream");
-WEBRTC_DEFINE_string(
+ABSL_FLAG(
+ std::string,
force_fieldtrials,
"",
"Field trials control experimental feature code which can be forced. "
@@ -307,85 +208,221 @@
"trials are separated by \"/\"");
// Video-specific flags.
-WEBRTC_DEFINE_string(
- clip,
- "",
- "Name of the clip to show. If empty, using chroma generator.");
-std::string Clip() {
- return static_cast<std::string>(FLAG_clip);
+ABSL_FLAG(std::string,
+ clip,
+ "",
+ "Name of the clip to show. If empty, using chroma generator.");
+
+namespace webrtc {
+namespace {
+
+size_t Width() {
+ return static_cast<size_t>(absl::GetFlag(FLAGS_width));
}
-WEBRTC_DEFINE_bool(help, false, "prints this message");
+size_t Height() {
+ return static_cast<size_t>(absl::GetFlag(FLAGS_height));
+}
-} // namespace flags
+int Fps() {
+ return absl::GetFlag(FLAGS_fps);
+}
+
+size_t GetCaptureDevice() {
+ return static_cast<size_t>(absl::GetFlag(FLAGS_capture_device_index));
+}
+
+int MinBitrateKbps() {
+ return absl::GetFlag(FLAGS_min_bitrate);
+}
+
+int StartBitrateKbps() {
+ return absl::GetFlag(FLAGS_start_bitrate);
+}
+
+int TargetBitrateKbps() {
+ return absl::GetFlag(FLAGS_target_bitrate);
+}
+
+int MaxBitrateKbps() {
+ return absl::GetFlag(FLAGS_max_bitrate);
+}
+
+int NumTemporalLayers() {
+ return absl::GetFlag(FLAGS_num_temporal_layers);
+}
+
+InterLayerPredMode InterLayerPred() {
+ if (absl::GetFlag(FLAGS_inter_layer_pred) == 0) {
+ return InterLayerPredMode::kOn;
+ } else if (absl::GetFlag(FLAGS_inter_layer_pred) == 1) {
+ return InterLayerPredMode::kOff;
+ } else {
+ RTC_DCHECK_EQ(absl::GetFlag(FLAGS_inter_layer_pred), 2);
+ return InterLayerPredMode::kOnKeyPic;
+ }
+}
+
+std::string Codec() {
+ return absl::GetFlag(FLAGS_codec);
+}
+
+int SelectedTL() {
+ return absl::GetFlag(FLAGS_selected_tl);
+}
+
+int DurationSecs() {
+ return absl::GetFlag(FLAGS_duration);
+}
+
+std::string OutputFilename() {
+ return absl::GetFlag(FLAGS_output_filename);
+}
+
+std::string GraphTitle() {
+ return absl::GetFlag(FLAGS_graph_title);
+}
+
+int LossPercent() {
+ return static_cast<int>(absl::GetFlag(FLAGS_loss_percent));
+}
+
+int AvgBurstLossLength() {
+ return static_cast<int>(absl::GetFlag(FLAGS_avg_burst_loss_length));
+}
+
+int LinkCapacityKbps() {
+ return static_cast<int>(absl::GetFlag(FLAGS_link_capacity));
+}
+
+int QueueSize() {
+ return static_cast<int>(absl::GetFlag(FLAGS_queue_size));
+}
+
+int AvgPropagationDelayMs() {
+ return static_cast<int>(absl::GetFlag(FLAGS_avg_propagation_delay_ms));
+}
+
+std::string RtcEventLogName() {
+ return absl::GetFlag(FLAGS_rtc_event_log_name);
+}
+
+std::string RtpDumpName() {
+ return absl::GetFlag(FLAGS_rtp_dump_name);
+}
+
+int StdPropagationDelayMs() {
+ return absl::GetFlag(FLAGS_std_propagation_delay_ms);
+}
+
+int NumStreams() {
+ return absl::GetFlag(FLAGS_num_streams);
+}
+
+int SelectedStream() {
+ return absl::GetFlag(FLAGS_selected_stream);
+}
+
+int NumSpatialLayers() {
+ return absl::GetFlag(FLAGS_num_spatial_layers);
+}
+
+int SelectedSL() {
+ return absl::GetFlag(FLAGS_selected_sl);
+}
+
+std::string Stream0() {
+ return absl::GetFlag(FLAGS_stream0);
+}
+
+std::string Stream1() {
+ return absl::GetFlag(FLAGS_stream1);
+}
+
+std::string SL0() {
+ return absl::GetFlag(FLAGS_sl0);
+}
+
+std::string SL1() {
+ return absl::GetFlag(FLAGS_sl1);
+}
+
+std::string SL2() {
+ return absl::GetFlag(FLAGS_sl2);
+}
+
+std::string EncodedFramePath() {
+ return absl::GetFlag(FLAGS_encoded_frame_path);
+}
+
+std::string Clip() {
+ return absl::GetFlag(FLAGS_clip);
+}
+
+} // namespace
void Loopback() {
BuiltInNetworkBehaviorConfig pipe_config;
- pipe_config.loss_percent = flags::LossPercent();
- pipe_config.avg_burst_loss_length = flags::AvgBurstLossLength();
- pipe_config.link_capacity_kbps = flags::LinkCapacityKbps();
- pipe_config.queue_length_packets = flags::QueueSize();
- pipe_config.queue_delay_ms = flags::AvgPropagationDelayMs();
- pipe_config.delay_standard_deviation_ms = flags::StdPropagationDelayMs();
- pipe_config.allow_reordering = flags::FLAG_allow_reordering;
+ pipe_config.loss_percent = LossPercent();
+ pipe_config.avg_burst_loss_length = AvgBurstLossLength();
+ pipe_config.link_capacity_kbps = LinkCapacityKbps();
+ pipe_config.queue_length_packets = QueueSize();
+ pipe_config.queue_delay_ms = AvgPropagationDelayMs();
+ pipe_config.delay_standard_deviation_ms = StdPropagationDelayMs();
+ pipe_config.allow_reordering = absl::GetFlag(FLAGS_allow_reordering);
BitrateConstraints call_bitrate_config;
- call_bitrate_config.min_bitrate_bps = flags::MinBitrateKbps() * 1000;
- call_bitrate_config.start_bitrate_bps = flags::StartBitrateKbps() * 1000;
+ call_bitrate_config.min_bitrate_bps = MinBitrateKbps() * 1000;
+ call_bitrate_config.start_bitrate_bps = StartBitrateKbps() * 1000;
call_bitrate_config.max_bitrate_bps = -1; // Don't cap bandwidth estimate.
VideoQualityTest::Params params;
- params.call = {flags::FLAG_send_side_bwe, flags::FLAG_generic_descriptor,
- call_bitrate_config, 0};
- params.video[0] = {flags::FLAG_video,
- flags::Width(),
- flags::Height(),
- flags::Fps(),
- flags::MinBitrateKbps() * 1000,
- flags::TargetBitrateKbps() * 1000,
- flags::MaxBitrateKbps() * 1000,
- flags::FLAG_suspend_below_min_bitrate,
- flags::Codec(),
- flags::NumTemporalLayers(),
- flags::SelectedTL(),
+ params.call = {absl::GetFlag(FLAGS_send_side_bwe),
+ absl::GetFlag(FLAGS_generic_descriptor), call_bitrate_config,
+ 0};
+ params.video[0] = {absl::GetFlag(FLAGS_video),
+ Width(),
+ Height(),
+ Fps(),
+ MinBitrateKbps() * 1000,
+ TargetBitrateKbps() * 1000,
+ MaxBitrateKbps() * 1000,
+ absl::GetFlag(FLAGS_suspend_below_min_bitrate),
+ Codec(),
+ NumTemporalLayers(),
+ SelectedTL(),
0, // No min transmit bitrate.
- flags::FLAG_use_ulpfec,
- flags::FLAG_use_flexfec,
- flags::NumStreams() < 2, // Automatic quality scaling.
- flags::Clip(),
- flags::GetCaptureDevice()};
- params.audio = {flags::FLAG_audio, flags::FLAG_audio_video_sync,
- flags::FLAG_audio_dtx, flags::FLAG_use_real_adm};
- params.logging = {flags::FLAG_rtc_event_log_name, flags::FLAG_rtp_dump_name,
- flags::FLAG_encoded_frame_path};
+ absl::GetFlag(FLAGS_use_ulpfec),
+ absl::GetFlag(FLAGS_use_flexfec),
+ NumStreams() < 2, // Automatic quality scaling.
+ Clip(),
+ GetCaptureDevice()};
+ params.audio = {
+ absl::GetFlag(FLAGS_audio), absl::GetFlag(FLAGS_audio_video_sync),
+ absl::GetFlag(FLAGS_audio_dtx), absl::GetFlag(FLAGS_use_real_adm)};
+ params.logging = {RtcEventLogName(), RtpDumpName(), EncodedFramePath()};
params.screenshare[0].enabled = false;
- params.analyzer = {"video",
- 0.0,
- 0.0,
- flags::DurationSecs(),
- flags::OutputFilename(),
- flags::GraphTitle()};
+ params.analyzer = {"video", 0.0, 0.0, DurationSecs(),
+ OutputFilename(), GraphTitle()};
params.config = pipe_config;
- if (flags::NumStreams() > 1 && flags::Stream0().empty() &&
- flags::Stream1().empty()) {
+ if (NumStreams() > 1 && Stream0().empty() && Stream1().empty()) {
params.ss[0].infer_streams = true;
}
std::vector<std::string> stream_descriptors;
- stream_descriptors.push_back(flags::Stream0());
- stream_descriptors.push_back(flags::Stream1());
+ stream_descriptors.push_back(Stream0());
+ stream_descriptors.push_back(Stream1());
std::vector<std::string> SL_descriptors;
- SL_descriptors.push_back(flags::SL0());
- SL_descriptors.push_back(flags::SL1());
- SL_descriptors.push_back(flags::SL2());
+ SL_descriptors.push_back(SL0());
+ SL_descriptors.push_back(SL1());
+ SL_descriptors.push_back(SL2());
VideoQualityTest::FillScalabilitySettings(
- ¶ms, 0, stream_descriptors, flags::NumStreams(),
- flags::SelectedStream(), flags::NumSpatialLayers(), flags::SelectedSL(),
- flags::InterLayerPred(), SL_descriptors);
+ ¶ms, 0, stream_descriptors, NumStreams(), SelectedStream(),
+ NumSpatialLayers(), SelectedSL(), InterLayerPred(), SL_descriptors);
auto fixture = absl::make_unique<VideoQualityTest>(nullptr);
- if (flags::DurationSecs()) {
+ if (DurationSecs()) {
fixture->RunWithAnalyzer(params);
} else {
fixture->RunWithRenderers(params);
@@ -394,18 +431,14 @@
int RunLoopbackTest(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
- rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true);
- if (webrtc::flags::FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
+ absl::ParseCommandLine(argc, argv);
- rtc::LogMessage::SetLogToStderr(webrtc::flags::FLAG_logs);
+ rtc::LogMessage::SetLogToStderr(absl::GetFlag(FLAGS_logs));
// InitFieldTrialsFromString stores the char*, so the char array must outlive
// the application.
- webrtc::field_trial::InitFieldTrialsFromString(
- webrtc::flags::FLAG_force_fieldtrials);
+ const std::string field_trials = absl::GetFlag(FLAGS_force_fieldtrials);
+ webrtc::field_trial::InitFieldTrialsFromString(field_trials.c_str());
webrtc::test::RunTest(webrtc::Loopback);
return 0;
diff --git a/video/video_replay.cc b/video/video_replay.cc
index b007145..98b1196 100644
--- a/video/video_replay.cc
+++ b/video/video_replay.cc
@@ -14,6 +14,8 @@
#include <map>
#include <memory>
+#include "absl/flags/flag.h"
+#include "absl/flags/parse.h"
#include "absl/memory/memory.h"
#include "api/test/video/function_video_decoder_factory.h"
#include "api/video_codecs/video_decoder.h"
@@ -23,7 +25,6 @@
#include "media/engine/internal_decoder_factory.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "rtc_base/checks.h"
-#include "rtc_base/flags.h"
#include "rtc_base/string_to_number.h"
#include "rtc_base/strings/json.h"
#include "rtc_base/time_utils.h"
@@ -42,6 +43,77 @@
#include "test/testsupport/frame_writer.h"
#include "test/video_renderer.h"
+// Flag for payload type.
+ABSL_FLAG(int,
+ media_payload_type,
+ webrtc::test::CallTest::kPayloadTypeVP8,
+ "Media payload type");
+
+// Flag for RED payload type.
+ABSL_FLAG(int,
+ red_payload_type,
+ webrtc::test::CallTest::kRedPayloadType,
+ "RED payload type");
+
+// Flag for ULPFEC payload type.
+ABSL_FLAG(int,
+ ulpfec_payload_type,
+ webrtc::test::CallTest::kUlpfecPayloadType,
+ "ULPFEC payload type");
+
+ABSL_FLAG(int,
+ media_payload_type_rtx,
+ webrtc::test::CallTest::kSendRtxPayloadType,
+ "Media over RTX payload type");
+
+ABSL_FLAG(int,
+ red_payload_type_rtx,
+ webrtc::test::CallTest::kRtxRedPayloadType,
+ "RED over RTX payload type");
+
+// Flag for SSRC.
+const std::string& DefaultSsrc() {
+ static const std::string ssrc =
+ std::to_string(webrtc::test::CallTest::kVideoSendSsrcs[0]);
+ return ssrc;
+}
+ABSL_FLAG(std::string, ssrc, DefaultSsrc().c_str(), "Incoming SSRC");
+
+const std::string& DefaultSsrcRtx() {
+ static const std::string ssrc_rtx =
+ std::to_string(webrtc::test::CallTest::kSendRtxSsrcs[0]);
+ return ssrc_rtx;
+}
+ABSL_FLAG(std::string, ssrc_rtx, DefaultSsrcRtx().c_str(), "Incoming RTX SSRC");
+
+// Flag for abs-send-time id.
+ABSL_FLAG(int, abs_send_time_id, -1, "RTP extension ID for abs-send-time");
+
+// Flag for transmission-offset id.
+ABSL_FLAG(int,
+ transmission_offset_id,
+ -1,
+ "RTP extension ID for transmission-offset");
+
+// Flag for rtpdump input file.
+ABSL_FLAG(std::string, input_file, "", "input file");
+
+ABSL_FLAG(std::string, config_file, "", "config file");
+
+// Flag for raw output files.
+ABSL_FLAG(std::string,
+ out_base,
+ "",
+ "Basename (excluding .jpg) for raw output");
+
+ABSL_FLAG(std::string,
+ decoder_bitstream_filename,
+ "",
+ "Decoder bitstream output file");
+
+// Flag for video codec.
+ABSL_FLAG(std::string, codec, "VP8", "Video codec");
+
namespace {
static bool ValidatePayloadType(int32_t payload_type) {
@@ -64,118 +136,65 @@
return !string.empty();
}
+static int MediaPayloadType() {
+ return absl::GetFlag(FLAGS_media_payload_type);
+}
+
+static int RedPayloadType() {
+ return absl::GetFlag(FLAGS_red_payload_type);
+}
+
+static int UlpfecPayloadType() {
+ return absl::GetFlag(FLAGS_ulpfec_payload_type);
+}
+
+static int MediaPayloadTypeRtx() {
+ return absl::GetFlag(FLAGS_media_payload_type_rtx);
+}
+
+static int RedPayloadTypeRtx() {
+ return absl::GetFlag(FLAGS_red_payload_type_rtx);
+}
+
+static uint32_t Ssrc() {
+ return rtc::StringToNumber<uint32_t>(absl::GetFlag(FLAGS_ssrc)).value();
+}
+
+static uint32_t SsrcRtx() {
+ return rtc::StringToNumber<uint32_t>(absl::GetFlag(FLAGS_ssrc_rtx)).value();
+}
+
+static int AbsSendTimeId() {
+ return absl::GetFlag(FLAGS_abs_send_time_id);
+}
+
+static int TransmissionOffsetId() {
+ return absl::GetFlag(FLAGS_transmission_offset_id);
+}
+
+static std::string InputFile() {
+ return absl::GetFlag(FLAGS_input_file);
+}
+
+static std::string ConfigFile() {
+ return absl::GetFlag(FLAGS_config_file);
+}
+
+static std::string OutBase() {
+ return absl::GetFlag(FLAGS_out_base);
+}
+
+static std::string DecoderBitstreamFilename() {
+ return absl::GetFlag(FLAGS_decoder_bitstream_filename);
+}
+
+static std::string Codec() {
+ return absl::GetFlag(FLAGS_codec);
+}
+
} // namespace
namespace webrtc {
-namespace flags {
-
-// TODO(pbos): Multiple receivers.
-
-// Flag for payload type.
-WEBRTC_DEFINE_int(media_payload_type,
- test::CallTest::kPayloadTypeVP8,
- "Media payload type");
-static int MediaPayloadType() {
- return static_cast<int>(FLAG_media_payload_type);
-}
-
-// Flag for RED payload type.
-WEBRTC_DEFINE_int(red_payload_type,
- test::CallTest::kRedPayloadType,
- "RED payload type");
-static int RedPayloadType() {
- return static_cast<int>(FLAG_red_payload_type);
-}
-
-// Flag for ULPFEC payload type.
-WEBRTC_DEFINE_int(ulpfec_payload_type,
- test::CallTest::kUlpfecPayloadType,
- "ULPFEC payload type");
-static int UlpfecPayloadType() {
- return static_cast<int>(FLAG_ulpfec_payload_type);
-}
-
-WEBRTC_DEFINE_int(media_payload_type_rtx,
- test::CallTest::kSendRtxPayloadType,
- "Media over RTX payload type");
-static int MediaPayloadTypeRtx() {
- return static_cast<int>(FLAG_media_payload_type_rtx);
-}
-
-WEBRTC_DEFINE_int(red_payload_type_rtx,
- test::CallTest::kRtxRedPayloadType,
- "RED over RTX payload type");
-static int RedPayloadTypeRtx() {
- return static_cast<int>(FLAG_red_payload_type_rtx);
-}
-
-// Flag for SSRC.
-const std::string& DefaultSsrc() {
- static const std::string ssrc =
- std::to_string(test::CallTest::kVideoSendSsrcs[0]);
- return ssrc;
-}
-WEBRTC_DEFINE_string(ssrc, DefaultSsrc().c_str(), "Incoming SSRC");
-static uint32_t Ssrc() {
- return rtc::StringToNumber<uint32_t>(FLAG_ssrc).value();
-}
-
-const std::string& DefaultSsrcRtx() {
- static const std::string ssrc_rtx =
- std::to_string(test::CallTest::kSendRtxSsrcs[0]);
- return ssrc_rtx;
-}
-WEBRTC_DEFINE_string(ssrc_rtx, DefaultSsrcRtx().c_str(), "Incoming RTX SSRC");
-static uint32_t SsrcRtx() {
- return rtc::StringToNumber<uint32_t>(FLAG_ssrc_rtx).value();
-}
-
-// Flag for abs-send-time id.
-WEBRTC_DEFINE_int(abs_send_time_id, -1, "RTP extension ID for abs-send-time");
-static int AbsSendTimeId() {
- return static_cast<int>(FLAG_abs_send_time_id);
-}
-
-// Flag for transmission-offset id.
-WEBRTC_DEFINE_int(transmission_offset_id,
- -1,
- "RTP extension ID for transmission-offset");
-static int TransmissionOffsetId() {
- return static_cast<int>(FLAG_transmission_offset_id);
-}
-
-// Flag for rtpdump input file.
-WEBRTC_DEFINE_string(input_file, "", "input file");
-static std::string InputFile() {
- return static_cast<std::string>(FLAG_input_file);
-}
-
-WEBRTC_DEFINE_string(config_file, "", "config file");
-static std::string ConfigFile() {
- return static_cast<std::string>(FLAG_config_file);
-}
-
-// Flag for raw output files.
-WEBRTC_DEFINE_string(out_base, "", "Basename (excluding .jpg) for raw output");
-static std::string OutBase() {
- return static_cast<std::string>(FLAG_out_base);
-}
-
-WEBRTC_DEFINE_string(decoder_bitstream_filename,
- "",
- "Decoder bitstream output file");
-static std::string DecoderBitstreamFilename() {
- return static_cast<std::string>(FLAG_decoder_bitstream_filename);
-}
-
-// Flag for video codec.
-WEBRTC_DEFINE_string(codec, "VP8", "Video codec");
-static std::string Codec() {
- return static_cast<std::string>(FLAG_codec);
-}
-
-WEBRTC_DEFINE_bool(help, false, "Print this message.");
-} // namespace flags
static const uint32_t kReceiverLocalSsrc = 0x123456;
@@ -338,38 +357,35 @@
std::unique_ptr<test::VideoRenderer> playback_video(
test::VideoRenderer::Create(window_title.str().c_str(), 640, 480));
auto file_passthrough = absl::make_unique<FileRenderPassthrough>(
- flags::OutBase(), playback_video.get());
+ OutBase(), playback_video.get());
stream_state->sinks.push_back(std::move(playback_video));
stream_state->sinks.push_back(std::move(file_passthrough));
// Setup the configuration from the flags.
VideoReceiveStream::Config receive_config(&(stream_state->transport));
- receive_config.rtp.remote_ssrc = flags::Ssrc();
+ receive_config.rtp.remote_ssrc = Ssrc();
receive_config.rtp.local_ssrc = kReceiverLocalSsrc;
- receive_config.rtp.rtx_ssrc = flags::SsrcRtx();
- receive_config.rtp
- .rtx_associated_payload_types[flags::MediaPayloadTypeRtx()] =
- flags::MediaPayloadType();
- receive_config.rtp
- .rtx_associated_payload_types[flags::RedPayloadTypeRtx()] =
- flags::RedPayloadType();
- receive_config.rtp.ulpfec_payload_type = flags::UlpfecPayloadType();
- receive_config.rtp.red_payload_type = flags::RedPayloadType();
+ receive_config.rtp.rtx_ssrc = SsrcRtx();
+ receive_config.rtp.rtx_associated_payload_types[MediaPayloadTypeRtx()] =
+ MediaPayloadType();
+ receive_config.rtp.rtx_associated_payload_types[RedPayloadTypeRtx()] =
+ RedPayloadType();
+ receive_config.rtp.ulpfec_payload_type = UlpfecPayloadType();
+ receive_config.rtp.red_payload_type = RedPayloadType();
receive_config.rtp.nack.rtp_history_ms = 1000;
- if (flags::TransmissionOffsetId() != -1) {
+ if (TransmissionOffsetId() != -1) {
receive_config.rtp.extensions.push_back(RtpExtension(
- RtpExtension::kTimestampOffsetUri, flags::TransmissionOffsetId()));
+ RtpExtension::kTimestampOffsetUri, TransmissionOffsetId()));
}
- if (flags::AbsSendTimeId() != -1) {
+ if (AbsSendTimeId() != -1) {
receive_config.rtp.extensions.push_back(
- RtpExtension(RtpExtension::kAbsSendTimeUri, flags::AbsSendTimeId()));
+ RtpExtension(RtpExtension::kAbsSendTimeUri, AbsSendTimeId()));
}
receive_config.renderer = stream_state->sinks.back().get();
// Setup the receiving stream
VideoReceiveStream::Decoder decoder;
- decoder =
- test::CreateMatchingDecoder(flags::MediaPayloadType(), flags::Codec());
- if (flags::DecoderBitstreamFilename().empty()) {
+ decoder = test::CreateMatchingDecoder(MediaPayloadType(), Codec());
+ if (DecoderBitstreamFilename().empty()) {
stream_state->decoder_factory =
absl::make_unique<InternalDecoderFactory>();
} else {
@@ -378,7 +394,7 @@
stream_state->decoder_factory =
absl::make_unique<test::FunctionVideoDecoderFactory>([]() {
return absl::make_unique<DecoderBitstreamFileWriter>(
- flags::DecoderBitstreamFilename().c_str());
+ DecoderBitstreamFilename().c_str());
});
}
decoder.decoder_factory = stream_state->decoder_factory.get();
@@ -474,34 +490,29 @@
}; // class RtpReplayer
void RtpReplay() {
- RtpReplayer::Replay(flags::ConfigFile(), flags::InputFile());
+ RtpReplayer::Replay(ConfigFile(), InputFile());
}
} // namespace webrtc
int main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
- if (rtc::FlagList::SetFlagsFromCommandLine(&argc, argv, true)) {
- return 1;
- }
- if (webrtc::flags::FLAG_help) {
- rtc::FlagList::Print(nullptr, false);
- return 0;
- }
+ absl::ParseCommandLine(argc, argv);
- RTC_CHECK(ValidatePayloadType(webrtc::flags::FLAG_media_payload_type));
- RTC_CHECK(ValidatePayloadType(webrtc::flags::FLAG_media_payload_type_rtx));
- RTC_CHECK(ValidateOptionalPayloadType(webrtc::flags::FLAG_red_payload_type));
+ RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_media_payload_type)));
+ RTC_CHECK(ValidatePayloadType(absl::GetFlag(FLAGS_media_payload_type_rtx)));
+ RTC_CHECK(ValidateOptionalPayloadType(absl::GetFlag(FLAGS_red_payload_type)));
RTC_CHECK(
- ValidateOptionalPayloadType(webrtc::flags::FLAG_red_payload_type_rtx));
+ ValidateOptionalPayloadType(absl::GetFlag(FLAGS_red_payload_type_rtx)));
RTC_CHECK(
- ValidateOptionalPayloadType(webrtc::flags::FLAG_ulpfec_payload_type));
- RTC_CHECK(ValidateSsrc(webrtc::flags::FLAG_ssrc));
- RTC_CHECK(ValidateSsrc(webrtc::flags::FLAG_ssrc_rtx));
- RTC_CHECK(ValidateRtpHeaderExtensionId(webrtc::flags::FLAG_abs_send_time_id));
+ ValidateOptionalPayloadType(absl::GetFlag(FLAGS_ulpfec_payload_type)));
+ RTC_CHECK(ValidateSsrc(absl::GetFlag(FLAGS_ssrc).c_str()));
+ RTC_CHECK(ValidateSsrc(absl::GetFlag(FLAGS_ssrc_rtx).c_str()));
RTC_CHECK(
- ValidateRtpHeaderExtensionId(webrtc::flags::FLAG_transmission_offset_id));
- RTC_CHECK(ValidateInputFilenameNotEmpty(webrtc::flags::FLAG_input_file));
+ ValidateRtpHeaderExtensionId(absl::GetFlag(FLAGS_abs_send_time_id)));
+ RTC_CHECK(ValidateRtpHeaderExtensionId(
+ absl::GetFlag(FLAGS_transmission_offset_id)));
+ RTC_CHECK(ValidateInputFilenameNotEmpty(absl::GetFlag(FLAGS_input_file)));
webrtc::test::RunTest(webrtc::RtpReplay);
return 0;
diff --git a/webrtc.gni b/webrtc.gni
index e27a84a..dece36e 100644
--- a/webrtc.gni
+++ b/webrtc.gni
@@ -376,6 +376,10 @@
absl_include_config = "//third_party/abseil-cpp:absl_include_config"
absl_define_config = "//third_party/abseil-cpp:absl_define_config"
+# Abseil Flags are testonly, so this config will only be applied to WebRTC targets
+# that are testonly.
+absl_flags_config = webrtc_root + ":absl_flags_configs"
+
template("rtc_test") {
test(target_name) {
forward_variables_from(invoker,
@@ -398,6 +402,7 @@
rtc_common_inherited_config,
absl_include_config,
absl_define_config,
+ absl_flags_config,
]
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
@@ -476,6 +481,9 @@
absl_include_config,
absl_define_config,
]
+ if (defined(testonly) && testonly) {
+ public_configs += [ absl_flags_config ]
+ }
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
@@ -507,6 +515,9 @@
absl_include_config,
absl_define_config,
]
+ if (defined(testonly) && testonly) {
+ public_configs += [ absl_flags_config ]
+ }
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
@@ -585,6 +596,9 @@
absl_include_config,
absl_define_config,
]
+ if (defined(testonly) && testonly) {
+ public_configs += [ absl_flags_config ]
+ }
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}
@@ -652,6 +666,9 @@
absl_include_config,
absl_define_config,
]
+ if (defined(testonly) && testonly) {
+ public_configs += [ absl_flags_config ]
+ }
if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}