Test field trial group with startswith rather than equals.

BUG=webrtc:7266

Review-Url: https://codereview.webrtc.org/2717973005
Cr-Commit-Position: refs/heads/master@{#16915}
This commit is contained in:
sprang 2017-02-28 08:50:47 -08:00 committed by Commit bot
parent f8ee65ead6
commit c1b57a15bf
23 changed files with 42 additions and 46 deletions

View File

@ -290,7 +290,7 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec,
observer.PrintResults();
// In quick test synchronization may not be achieved in time.
if (field_trial::FindFullName("WebRTC-QuickPerfTest") != "Enabled") {
if (field_trial::IsEnabled("WebRTC-QuickPerfTest")) {
EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.AVSyncOffsetInMs"));
}
}

View File

@ -24,7 +24,7 @@ namespace {
const char kFlexfecFieldTrialName[] = "WebRTC-FlexFEC-03";
bool IsFlexfecFieldTrialEnabled() {
return webrtc::field_trial::FindFullName(kFlexfecFieldTrialName) == "Enabled";
return webrtc::field_trial::IsEnabled(kFlexfecFieldTrialName);
}
} // namespace

View File

@ -299,8 +299,7 @@ bool ScreenshareLayerConfig::FromFieldTrialGroup(
}
bool UseSimulcastScreenshare() {
return webrtc::field_trial::FindFullName(
kSimulcastScreenshareFieldTrialName) == "Enabled";
return webrtc::field_trial::IsEnabled(kSimulcastScreenshareFieldTrialName);
}
} // namespace cricket

View File

@ -230,12 +230,8 @@ void WebRtcVideoCapturer::OnSinkWantsChanged(const rtc::VideoSinkWants& wants) {
// calls, can't take lock.
RTC_DCHECK(module_);
const std::string group_name =
webrtc::field_trial::FindFullName("WebRTC-CVO");
if (group_name == "Disabled") {
if (webrtc::field_trial::FindFullName("WebRTC-CVO").find("Disabled") == 0)
return;
}
VideoCapturer::OnSinkWantsChanged(wants);
bool result = module_->SetApplyRotation(wants.rotation_applied);

View File

@ -50,7 +50,7 @@ namespace {
const char kFlexfecFieldTrialName[] = "WebRTC-FlexFEC-03";
bool IsFlexfecFieldTrialEnabled() {
return webrtc::field_trial::FindFullName(kFlexfecFieldTrialName) == "Enabled";
return webrtc::field_trial::IsEnabled(kFlexfecFieldTrialName);
}
// Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory.

View File

@ -982,8 +982,7 @@ RtpCapabilities WebRtcVoiceEngine::GetCapabilities() const {
capabilities.header_extensions.push_back(
webrtc::RtpExtension(webrtc::RtpExtension::kAudioLevelUri,
webrtc::RtpExtension::kAudioLevelDefaultId));
if (webrtc::field_trial::FindFullName("WebRTC-Audio-SendSideBwe") ==
"Enabled") {
if (webrtc::field_trial::IsEnabled("WebRTC-Audio-SendSideBwe")) {
capabilities.header_extensions.push_back(webrtc::RtpExtension(
webrtc::RtpExtension::kTransportSequenceNumberUri,
webrtc::RtpExtension::kTransportSequenceNumberDefaultId));
@ -1194,8 +1193,8 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
: voe_audio_transport_(voe_audio_transport),
call_(call),
config_(send_transport),
send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName(
"WebRTC-SendSideBwe-WithOverhead") == "Enabled"),
send_side_bwe_with_overhead_(
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
max_send_bitrate_bps_(max_send_bitrate_bps),
rtp_parameters_(CreateRtpParametersWithOneEncoding()) {
RTC_DCHECK_GE(ch, 0);
@ -1422,8 +1421,7 @@ class WebRtcVoiceMediaChannel::WebRtcAudioSendStream
stream_ = nullptr;
}
RTC_DCHECK(!stream_);
if (webrtc::field_trial::FindFullName("WebRTC-Audio-SendSideBwe") ==
"Enabled") {
if (webrtc::field_trial::IsEnabled("WebRTC-Audio-SendSideBwe")) {
config_.min_bitrate_bps = kOpusMinBitrateBps;
config_.max_bitrate_bps = kOpusBitrateFbBps;
// TODO(mflodman): Keep testing this and set proper values.

View File

@ -51,8 +51,8 @@ void BitrateController::MakeDecision(
// Current implementation of BitrateController can only work when
// |metrics.target_audio_bitrate_bps| includes overhead is enabled. This is
// currently governed by the following field trial.
RTC_DCHECK_EQ("Enabled", webrtc::field_trial::FindFullName(
"WebRTC-SendSideBwe-WithOverhead"));
RTC_DCHECK(
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead"));
if (config->frame_length_ms)
frame_length_ms_ = *config->frame_length_ms;
int overhead_rate_bps =

View File

@ -183,8 +183,8 @@ AudioEncoderOpus::AudioEncoderOpus(
const Config& config,
AudioNetworkAdaptorCreator&& audio_network_adaptor_creator,
std::unique_ptr<SmoothingFilter> bitrate_smoother)
: send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName(
"WebRTC-SendSideBwe-WithOverhead") == "Enabled"),
: send_side_bwe_with_overhead_(webrtc::field_trial::IsEnabled(
"WebRTC-SendSideBwe-WithOverhead")),
packet_loss_rate_(0.0),
inst_(nullptr),
packet_loss_fraction_smoother_(new PacketLossFractionSmoother(

View File

@ -22,7 +22,7 @@ TEST(NetEqPerformanceTest, Run) {
const int kLossPeriod = 10; // Drop every 10th packet.
const double kDriftFactor = 0.1;
int64_t runtime = webrtc::test::NetEqPerformanceTest::Run(
webrtc::field_trial::FindFullName("WebRTC-QuickPerfTest") == "Enabled"
webrtc::field_trial::IsEnabled("WebRTC-QuickPerfTest")
? kQuickSimulationTimeMs
: kSimulationTimeMs,
kLossPeriod, kDriftFactor);
@ -40,7 +40,7 @@ TEST(NetEqPerformanceTest, RunClean) {
const int kLossPeriod = 0; // No losses.
const double kDriftFactor = 0.0; // No clock drift.
int64_t runtime = webrtc::test::NetEqPerformanceTest::Run(
webrtc::field_trial::FindFullName("WebRTC-QuickPerfTest") == "Enabled"
webrtc::field_trial::IsEnabled("WebRTC-QuickPerfTest")
? kQuickSimulationTimeMs
: kSimulationTimeMs,
kLossPeriod, kDriftFactor);

View File

@ -73,8 +73,8 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
rampup_uma_stats_updated_(kNumUmaRampupMetrics, false),
event_log_(event_log),
last_rtc_event_log_ms_(-1),
in_timeout_experiment_(webrtc::field_trial::FindFullName(
"WebRTC-FeedbackTimeout") == "Enabled") {
in_timeout_experiment_(
webrtc::field_trial::IsEnabled("WebRTC-FeedbackTimeout")) {
RTC_DCHECK(event_log);
}

View File

@ -57,8 +57,7 @@ const char kBweTrendlineFilterExperiment[] = "WebRTC-BweTrendlineFilter";
const char kBweMedianSlopeFilterExperiment[] = "WebRTC-BweMedianSlopeFilter";
bool BitrateEstimateExperimentIsEnabled() {
return webrtc::field_trial::FindFullName(kBitrateEstimateExperiment) ==
"Enabled";
return webrtc::field_trial::IsEnabled(kBitrateEstimateExperiment);
}
bool TrendlineFilterExperimentIsEnabled() {

View File

@ -45,9 +45,8 @@ TransportFeedbackAdapter::TransportFeedbackAdapter(
RtcEventLog* event_log,
Clock* clock,
BitrateController* bitrate_controller)
: send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName(
"WebRTC-SendSideBwe-WithOverhead") ==
"Enabled"),
: send_side_bwe_with_overhead_(
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
transport_overhead_bytes_per_packet_(0),
send_time_history_(clock, kSendTimeHistoryWindowMs),
event_log_(event_log),

View File

@ -18,8 +18,7 @@ namespace congestion_controller {
int GetMinBitrateBps() {
constexpr int kAudioMinBitrateBps = 5000;
constexpr int kMinBitrateBps = 10000;
if (webrtc::field_trial::FindFullName("WebRTC-Audio-SendSideBwe") ==
"Enabled") {
if (webrtc::field_trial::IsEnabled("WebRTC-Audio-SendSideBwe")) {
return kAudioMinBitrateBps;
}
return kMinBitrateBps;

View File

@ -167,7 +167,7 @@ void BweTest::RunFor(int64_t time_ms) {
// TODO(holmer): Support different feedback intervals for different flows.
// For quick perf tests ignore passed timeout
if (field_trial::FindFullName("WebRTC-QuickPerfTest") == "Enabled") {
if (field_trial::IsEnabled("WebRTC-QuickPerfTest")) {
time_ms = kQuickTestTimeoutMs;
}
if (!uplink_.senders().empty()) {
@ -380,7 +380,7 @@ void BweTest::RunFairnessTest(BandwidthEstimatorType bwe_type,
PrintResults(capacity_kbps, total_utilization.GetBitrateStats(),
flow_delay_ms, flow_throughput_kbps);
if (field_trial::FindFullName("WebRTC-QuickPerfTest") != "Enabled") {
if (field_trial::IsEnabled("WebRTC-QuickPerfTest")) {
for (int i : all_flow_ids) {
metric_recorders[i]->PlotThroughputHistogram(
title, flow_name, static_cast<int>(num_media_flows), 0);

View File

@ -124,8 +124,7 @@ RTPSender::RTPSender(
retransmission_rate_limiter_(retransmission_rate_limiter),
overhead_observer_(overhead_observer),
send_side_bwe_with_overhead_(
webrtc::field_trial::FindFullName(
"WebRTC-SendSideBwe-WithOverhead") == "Enabled") {
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")) {
// This random initialization is not intended to be cryptographic strong.
timestamp_offset_ = random_.Rand<uint32_t>();
// Random start, 16 bits. Can't be 0.

View File

@ -2510,8 +2510,8 @@ bool PeerConnection::InitializePortAllocator_n(
// by experiment.
if (configuration.disable_ipv6) {
portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6);
} else if (webrtc::field_trial::FindFullName("WebRTC-IPv6Default") ==
"Disabled") {
} else if (webrtc::field_trial::FindFullName("WebRTC-IPv6Default")
.find("Disabled") == 0) {
portallocator_flags &= ~(cricket::PORTALLOCATOR_ENABLE_IPV6);
}

View File

@ -1298,11 +1298,11 @@ webrtc::VideoEncoder* MediaCodecVideoEncoderFactory::CreateVideoEncoder(
const std::vector<cricket::VideoCodec>&
MediaCodecVideoEncoderFactory::supported_codecs() const {
if (webrtc::field_trial::FindFullName(kH264HighProfileFieldTrial) ==
"Enabled")
if (webrtc::field_trial::IsEnabled(kH264HighProfileFieldTrial)) {
return supported_codecs_with_h264_hp_;
else
} else {
return supported_codecs_;
}
}
void MediaCodecVideoEncoderFactory::DestroyVideoEncoder(

View File

@ -22,7 +22,7 @@ namespace {
const char kHighProfileExperiment[] = "WebRTC-H264HighProfile";
bool IsHighProfileEnabled() {
return field_trial::FindFullName(kHighProfileExperiment) == "Enabled";
return field_trial::IsEnabled(kHighProfileExperiment);
}
}

View File

@ -62,6 +62,10 @@ namespace field_trial {
// Note: To keep things tidy append all the trial names with WebRTC.
std::string FindFullName(const std::string& name);
// Convenience method, returns true iff FindFullName(name) return a string that
// starts with "Enabled".
bool IsEnabled(const char* name);
} // namespace field_trial
} // namespace webrtc

View File

@ -53,6 +53,10 @@ std::string FindFullName(const std::string& name) {
return std::string();
}
bool IsEnabled(const char* name) {
return FindFullName(name).find("Enabled") == 0;
}
// Optionally initialize field trial from a string.
void InitFieldTrialsFromString(const char* trials_string) {
trials_init_string = trials_string;

View File

@ -43,7 +43,7 @@ class RtpRtcpObserver {
virtual ~RtpRtcpObserver() {}
virtual bool Wait() {
if (field_trial::FindFullName("WebRTC-QuickPerfTest") == "Enabled") {
if (field_trial::IsEnabled("WebRTC-QuickPerfTest")) {
observation_complete_.Wait(kShortTimeoutMs);
return true;
}

View File

@ -1441,8 +1441,7 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) {
// abort.
VideoStream& selected_stream = params_.ss.streams[params_.ss.selected_stream];
bool is_quick_test_enabled =
field_trial::FindFullName("WebRTC-QuickPerfTest") == "Enabled";
bool is_quick_test_enabled = field_trial::IsEnabled("WebRTC-QuickPerfTest");
VideoAnalyzer analyzer(
&send_transport, params_.analyzer.test_label,

View File

@ -757,8 +757,8 @@ VideoSendStreamImpl::VideoSendStreamImpl(
const VideoSendStream::Config* config,
int initial_encoder_max_bitrate,
std::map<uint32_t, RtpState> suspended_ssrcs)
: send_side_bwe_with_overhead_(webrtc::field_trial::FindFullName(
"WebRTC-SendSideBwe-WithOverhead") == "Enabled"),
: send_side_bwe_with_overhead_(
webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")),
stats_proxy_(stats_proxy),
config_(config),
suspended_ssrcs_(std::move(suspended_ssrcs)),