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}
This commit is contained in:
committed by
Commit Bot
parent
63741c7fa1
commit
2ab97f6f8e
@ -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 test {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -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 @@ namespace {
|
||||
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 @@ NetEqIsacQualityTest::NetEqIsacQualityTest()
|
||||
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.";
|
||||
}
|
||||
|
||||
|
||||
@ -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 @@ namespace {
|
||||
|
||||
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 @@ class NetEqOpusQualityTest : public NetEqQualityTest {
|
||||
};
|
||||
|
||||
NetEqOpusQualityTest::NetEqOpusQualityTest()
|
||||
: NetEqQualityTest(kOpusBlockDurationMs * FLAG_sub_packets,
|
||||
: NetEqQualityTest(kOpusBlockDurationMs * absl::GetFlag(FLAGS_sub_packets),
|
||||
kOpusSamplingKhz,
|
||||
kOpusSamplingKhz,
|
||||
SdpAudioFormat("opus", 48000, 2)),
|
||||
@ -78,27 +76,32 @@ NetEqOpusQualityTest::NetEqOpusQualityTest()
|
||||
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 @@ NetEqOpusQualityTest::NetEqOpusQualityTest()
|
||||
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() {
|
||||
|
||||
@ -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 test {
|
||||
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));
|
||||
|
||||
@ -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 test {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -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 @@ int main(int argc, char* argv[]) {
|
||||
" --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;
|
||||
|
||||
Reference in New Issue
Block a user