Scope field trials to PeerConnectionE2EQualityTest::Run.

Having ScopedFieldTrials at class scope might introduce some hard
to understand lifetime patterns. Keeping them in scope only for the
Run method simplifies that, reducing the risk of problems.

Bug: b/197053062
Change-Id: I1c1239757387443552a7b5f83f68014ee56e4248
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229920
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34836}
This commit is contained in:
Mirko Bonadei
2021-08-24 10:47:31 +02:00
committed by WebRTC LUCI CQ
parent b2db9890c5
commit 623d92c1ce
2 changed files with 11 additions and 16 deletions

View File

@ -30,6 +30,7 @@
#include "rtc_base/strings/string_builder.h"
#include "system_wrappers/include/cpu_info.h"
#include "system_wrappers/include/field_trial.h"
#include "test/field_trial.h"
#include "test/pc/e2e/analyzer/audio/default_audio_quality_analyzer.h"
#include "test/pc/e2e/analyzer/video/default_video_quality_analyzer.h"
#include "test/pc/e2e/analyzer/video/video_quality_metrics_reporter.h"
@ -180,7 +181,7 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) {
<< "Only simulcast stream from first peer is supported";
}
SetupRequiredFieldTrials(run_params);
test::ScopedFieldTrials field_trials(GetFieldTrials(run_params));
// Print test summary
RTC_LOG(INFO) << "Media quality test: " << *alice_configurer->params()->name
@ -387,22 +388,19 @@ void PeerConnectionE2EQualityTest::Run(RunParams run_params) {
RTC_CHECK(bob_video_sources_.empty());
}
void PeerConnectionE2EQualityTest::SetupRequiredFieldTrials(
std::string PeerConnectionE2EQualityTest::GetFieldTrials(
const RunParams& run_params) {
std::vector<absl::string_view> default_field_trials = {
kUseStandardsBytesStats};
if (run_params.use_flex_fec) {
default_field_trials.push_back(kFlexFecEnabledFieldTrials);
}
if (!default_field_trials.empty()) {
rtc::StringBuilder sb;
sb << field_trial::GetFieldTrialString();
for (const absl::string_view& field_trial : default_field_trials) {
sb << field_trial;
}
override_field_trials_ =
std::make_unique<test::ScopedFieldTrials>(sb.Release());
rtc::StringBuilder sb;
sb << field_trial::GetFieldTrialString();
for (const absl::string_view& field_trial : default_field_trials) {
sb << field_trial;
}
return sb.Release();
}
void PeerConnectionE2EQualityTest::OnTrackCallback(

View File

@ -27,7 +27,6 @@
#include "rtc_base/thread.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/clock.h"
#include "test/field_trial.h"
#include "test/pc/e2e/analyzer/video/single_process_encoded_image_data_injector.h"
#include "test/pc/e2e/analyzer/video/video_quality_analyzer_injection_helper.h"
#include "test/pc/e2e/analyzer_helper.h"
@ -81,9 +80,9 @@ class PeerConnectionE2EQualityTest
}
private:
// For some functionality some field trials have to be enabled, so we will
// enable them here.
void SetupRequiredFieldTrials(const RunParams& run_params);
// For some functionality some field trials have to be enabled, they will be
// enabled in Run().
std::string GetFieldTrials(const RunParams& run_params);
void OnTrackCallback(absl::string_view peer_name,
rtc::scoped_refptr<RtpTransceiverInterface> transceiver,
std::vector<VideoConfig> remote_video_configs);
@ -116,8 +115,6 @@ class PeerConnectionE2EQualityTest
std::vector<std::unique_ptr<PeerConfigurerImpl>> peer_configurations_;
std::unique_ptr<test::ScopedFieldTrials> override_field_trials_ = nullptr;
std::unique_ptr<TestPeer> alice_;
std::unique_ptr<TestPeer> bob_;
std::vector<std::unique_ptr<QualityMetricsReporter>>