Remove option to parse RateControlSettings from the global field trial string

Bug: webrtc:42220378
Change-Id: Iff016f0f53f427ff59df816d8d87dc4a8119db65
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350921
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42348}
This commit is contained in:
Danil Chapovalov 2024-05-17 16:31:00 +02:00 committed by WebRTC LUCI CQ
parent 819cfb0608
commit f317f7106a
7 changed files with 65 additions and 122 deletions

View File

@ -58,12 +58,6 @@ float SimulcastRateAllocator::GetTemporalRateAllocation(
return kLayerRateAllocation[num_layers - 1][temporal_id]; return kLayerRateAllocation[num_layers - 1][temporal_id];
} }
SimulcastRateAllocator::SimulcastRateAllocator(const VideoCodec& codec)
: codec_(codec),
stable_rate_settings_(StableTargetRateExperiment::ParseFromFieldTrials()),
rate_control_settings_(RateControlSettings::ParseFromFieldTrials()),
legacy_conference_mode_(false) {}
SimulcastRateAllocator::SimulcastRateAllocator(const Environment& env, SimulcastRateAllocator::SimulcastRateAllocator(const Environment& env,
const VideoCodec& codec) const VideoCodec& codec)
: codec_(codec), : codec_(codec),

View File

@ -27,7 +27,6 @@ namespace webrtc {
class SimulcastRateAllocator : public VideoBitrateAllocator { class SimulcastRateAllocator : public VideoBitrateAllocator {
public: public:
[[deprecated]] explicit SimulcastRateAllocator(const VideoCodec& codec);
SimulcastRateAllocator(const Environment& env, const VideoCodec& codec); SimulcastRateAllocator(const Environment& env, const VideoCodec& codec);
~SimulcastRateAllocator() override; ~SimulcastRateAllocator() override;

View File

@ -134,10 +134,8 @@ rtc_library("rate_control_settings") {
"..:logging", "..:logging",
"..:safe_conversions", "..:safe_conversions",
"../../api:field_trials_view", "../../api:field_trials_view",
"../../api/transport:field_trial_based_config",
"../../api/units:data_size", "../../api/units:data_size",
"../../api/video_codecs:video_codecs_api", "../../api/video_codecs:video_codecs_api",
"../../system_wrappers:field_trial",
"../../video/config:encoder_config", "../../video/config:encoder_config",
] ]
absl_deps = [ absl_deps = [

View File

@ -16,7 +16,6 @@
#include <string> #include <string>
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "api/transport/field_trial_based_config.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/numerics/safe_conversions.h" #include "rtc_base/numerics/safe_conversions.h"
@ -87,10 +86,6 @@ RateControlSettings::RateControlSettings(
RateControlSettings::~RateControlSettings() = default; RateControlSettings::~RateControlSettings() = default;
RateControlSettings::RateControlSettings(RateControlSettings&&) = default; RateControlSettings::RateControlSettings(RateControlSettings&&) = default;
RateControlSettings RateControlSettings::ParseFromFieldTrials() {
return RateControlSettings(FieldTrialBasedConfig());
}
bool RateControlSettings::UseCongestionWindow() const { bool RateControlSettings::UseCongestionWindow() const {
return static_cast<bool>(congestion_window_config_.queue_size_ms); return static_cast<bool>(congestion_window_config_.queue_size_ms);
} }

View File

@ -52,8 +52,6 @@ class RateControlSettings final {
RateControlSettings(RateControlSettings&&); RateControlSettings(RateControlSettings&&);
~RateControlSettings(); ~RateControlSettings();
static RateControlSettings ParseFromFieldTrials();
// When CongestionWindowPushback is enabled, the pacer is oblivious to // When CongestionWindowPushback is enabled, the pacer is oblivious to
// the congestion window. The relation between outstanding data and // the congestion window. The relation between outstanding data and
// the congestion window affects encoder allocations directly. // the congestion window affects encoder allocations directly.

View File

@ -11,7 +11,8 @@
#include "rtc_base/experiments/rate_control_settings.h" #include "rtc_base/experiments/rate_control_settings.h"
#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_codec.h"
#include "test/field_trial.h" #include "test/explicit_key_value_config.h"
#include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
#include "video/config/video_encoder_config.h" #include "video/config/video_encoder_config.h"
@ -19,172 +20,131 @@ namespace webrtc {
namespace { namespace {
TEST(RateControlSettingsTest, CongestionWindow) { using test::ExplicitKeyValueConfig;
EXPECT_TRUE( using ::testing::DoubleEq;
RateControlSettings::ParseFromFieldTrials().UseCongestionWindow()); using ::testing::Optional;
test::ScopedFieldTrials field_trials( RateControlSettings ParseFrom(absl::string_view field_trials) {
"WebRTC-CongestionWindow/QueueSize:100/"); return RateControlSettings(ExplicitKeyValueConfig(field_trials));
const RateControlSettings settings_after = }
RateControlSettings::ParseFromFieldTrials();
EXPECT_TRUE(settings_after.UseCongestionWindow()); TEST(RateControlSettingsTest, CongestionWindow) {
EXPECT_EQ(settings_after.GetCongestionWindowAdditionalTimeMs(), 100); EXPECT_TRUE(ParseFrom("").UseCongestionWindow());
const RateControlSettings settings =
ParseFrom("WebRTC-CongestionWindow/QueueSize:100/");
EXPECT_TRUE(settings.UseCongestionWindow());
EXPECT_EQ(settings.GetCongestionWindowAdditionalTimeMs(), 100);
} }
TEST(RateControlSettingsTest, CongestionWindowPushback) { TEST(RateControlSettingsTest, CongestionWindowPushback) {
EXPECT_TRUE(RateControlSettings::ParseFromFieldTrials() EXPECT_TRUE(ParseFrom("").UseCongestionWindowPushback());
.UseCongestionWindowPushback());
test::ScopedFieldTrials field_trials( const RateControlSettings settings =
"WebRTC-CongestionWindow/QueueSize:100,MinBitrate:100000/"); ParseFrom("WebRTC-CongestionWindow/QueueSize:100,MinBitrate:100000/");
const RateControlSettings settings_after = EXPECT_TRUE(settings.UseCongestionWindowPushback());
RateControlSettings::ParseFromFieldTrials(); EXPECT_EQ(settings.CongestionWindowMinPushbackTargetBitrateBps(), 100000u);
EXPECT_TRUE(settings_after.UseCongestionWindowPushback());
EXPECT_EQ(settings_after.CongestionWindowMinPushbackTargetBitrateBps(),
100000u);
} }
TEST(RateControlSettingsTest, CongestionWindowPushbackDropframe) { TEST(RateControlSettingsTest, CongestionWindowPushbackDropframe) {
EXPECT_TRUE(RateControlSettings::ParseFromFieldTrials() EXPECT_TRUE(ParseFrom("").UseCongestionWindowPushback());
.UseCongestionWindowPushback());
test::ScopedFieldTrials field_trials( const RateControlSettings settings = ParseFrom(
"WebRTC-CongestionWindow/" "WebRTC-CongestionWindow/"
"QueueSize:100,MinBitrate:100000,DropFrame:true/"); "QueueSize:100,MinBitrate:100000,DropFrame:true/");
const RateControlSettings settings_after = EXPECT_TRUE(settings.UseCongestionWindowPushback());
RateControlSettings::ParseFromFieldTrials(); EXPECT_EQ(settings.CongestionWindowMinPushbackTargetBitrateBps(), 100000u);
EXPECT_TRUE(settings_after.UseCongestionWindowPushback()); EXPECT_TRUE(settings.UseCongestionWindowDropFrameOnly());
EXPECT_EQ(settings_after.CongestionWindowMinPushbackTargetBitrateBps(),
100000u);
EXPECT_TRUE(settings_after.UseCongestionWindowDropFrameOnly());
} }
TEST(RateControlSettingsTest, CongestionWindowPushbackDefaultConfig) { TEST(RateControlSettingsTest, CongestionWindowPushbackDefaultConfig) {
const RateControlSettings settings = const RateControlSettings settings = ParseFrom("");
RateControlSettings::ParseFromFieldTrials();
EXPECT_TRUE(settings.UseCongestionWindowPushback()); EXPECT_TRUE(settings.UseCongestionWindowPushback());
EXPECT_EQ(settings.CongestionWindowMinPushbackTargetBitrateBps(), 30000u); EXPECT_EQ(settings.CongestionWindowMinPushbackTargetBitrateBps(), 30000u);
EXPECT_TRUE(settings.UseCongestionWindowDropFrameOnly()); EXPECT_TRUE(settings.UseCongestionWindowDropFrameOnly());
} }
TEST(RateControlSettingsTest, PacingFactor) { TEST(RateControlSettingsTest, PacingFactor) {
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials().GetPacingFactor()); EXPECT_FALSE(ParseFrom("").GetPacingFactor());
test::ScopedFieldTrials field_trials( EXPECT_THAT(
"WebRTC-VideoRateControl/pacing_factor:1.2/"); ParseFrom("WebRTC-VideoRateControl/pacing_factor:1.2/").GetPacingFactor(),
const RateControlSettings settings_after = Optional(DoubleEq(1.2)));
RateControlSettings::ParseFromFieldTrials();
// Need to explicitly dereference the absl::optional
// for the EXPECT_DOUBLE_EQ to compile.
ASSERT_TRUE(settings_after.GetPacingFactor());
EXPECT_DOUBLE_EQ(*settings_after.GetPacingFactor(), 1.2);
} }
TEST(RateControlSettingsTest, AlrProbing) { TEST(RateControlSettingsTest, AlrProbing) {
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials().UseAlrProbing()); EXPECT_FALSE(ParseFrom("").UseAlrProbing());
test::ScopedFieldTrials field_trials( EXPECT_TRUE(
"WebRTC-VideoRateControl/alr_probing:1/"); ParseFrom("WebRTC-VideoRateControl/alr_probing:1/").UseAlrProbing());
EXPECT_TRUE(RateControlSettings::ParseFromFieldTrials().UseAlrProbing());
} }
TEST(RateControlSettingsTest, LibvpxVp8QpMax) { TEST(RateControlSettingsTest, LibvpxVp8QpMax) {
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials().LibvpxVp8QpMax()); EXPECT_FALSE(ParseFrom("").LibvpxVp8QpMax());
test::ScopedFieldTrials field_trials( EXPECT_EQ(
"WebRTC-VideoRateControl/vp8_qp_max:50/"); ParseFrom("WebRTC-VideoRateControl/vp8_qp_max:50/").LibvpxVp8QpMax(), 50);
EXPECT_EQ(RateControlSettings::ParseFromFieldTrials().LibvpxVp8QpMax(), 50);
} }
TEST(RateControlSettingsTest, DoesNotGetTooLargeLibvpxVp8QpMaxValue) { TEST(RateControlSettingsTest, DoesNotGetTooLargeLibvpxVp8QpMaxValue) {
test::ScopedFieldTrials field_trials( EXPECT_FALSE(
"WebRTC-VideoRateControl/vp8_qp_max:70/"); ParseFrom("WebRTC-VideoRateControl/vp8_qp_max:70/").LibvpxVp8QpMax());
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials().LibvpxVp8QpMax());
} }
TEST(RateControlSettingsTest, LibvpxVp8MinPixels) { TEST(RateControlSettingsTest, LibvpxVp8MinPixels) {
EXPECT_FALSE( EXPECT_FALSE(ParseFrom("").LibvpxVp8MinPixels());
RateControlSettings::ParseFromFieldTrials().LibvpxVp8MinPixels());
test::ScopedFieldTrials field_trials( EXPECT_EQ(ParseFrom("WebRTC-VideoRateControl/vp8_min_pixels:50000/")
"WebRTC-VideoRateControl/vp8_min_pixels:50000/"); .LibvpxVp8MinPixels(),
EXPECT_EQ(RateControlSettings::ParseFromFieldTrials().LibvpxVp8MinPixels(),
50000); 50000);
} }
TEST(RateControlSettingsTest, DoesNotGetTooSmallLibvpxVp8MinPixelValue) { TEST(RateControlSettingsTest, DoesNotGetTooSmallLibvpxVp8MinPixelValue) {
test::ScopedFieldTrials field_trials( EXPECT_FALSE(ParseFrom("WebRTC-VideoRateControl/vp8_min_pixels:0/")
"WebRTC-VideoRateControl/vp8_min_pixels:0/"); .LibvpxVp8MinPixels());
EXPECT_FALSE(
RateControlSettings::ParseFromFieldTrials().LibvpxVp8MinPixels());
} }
TEST(RateControlSettingsTest, LibvpxTrustedRateController) { TEST(RateControlSettingsTest, LibvpxTrustedRateController) {
const RateControlSettings settings_before = const RateControlSettings default_settings = ParseFrom("");
RateControlSettings::ParseFromFieldTrials(); EXPECT_TRUE(default_settings.LibvpxVp8TrustedRateController());
EXPECT_TRUE(settings_before.LibvpxVp8TrustedRateController()); EXPECT_TRUE(default_settings.LibvpxVp9TrustedRateController());
EXPECT_TRUE(settings_before.LibvpxVp9TrustedRateController());
test::ScopedFieldTrials field_trials( const RateControlSettings settings =
"WebRTC-VideoRateControl/trust_vp8:0,trust_vp9:0/"); ParseFrom("WebRTC-VideoRateControl/trust_vp8:0,trust_vp9:0/");
const RateControlSettings settings_after = EXPECT_FALSE(settings.LibvpxVp8TrustedRateController());
RateControlSettings::ParseFromFieldTrials(); EXPECT_FALSE(settings.LibvpxVp9TrustedRateController());
EXPECT_FALSE(settings_after.LibvpxVp8TrustedRateController());
EXPECT_FALSE(settings_after.LibvpxVp9TrustedRateController());
} }
TEST(RateControlSettingsTest, Vp8BaseHeavyTl3RateAllocationLegacyKey) { TEST(RateControlSettingsTest, Vp8BaseHeavyTl3RateAllocationLegacyKey) {
const RateControlSettings settings_before = EXPECT_FALSE(ParseFrom("").Vp8BaseHeavyTl3RateAllocation());
RateControlSettings::ParseFromFieldTrials();
EXPECT_FALSE(settings_before.Vp8BaseHeavyTl3RateAllocation());
test::ScopedFieldTrials field_trials( EXPECT_TRUE(ParseFrom("WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/")
"WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/"); .Vp8BaseHeavyTl3RateAllocation());
const RateControlSettings settings_after =
RateControlSettings::ParseFromFieldTrials();
EXPECT_TRUE(settings_after.Vp8BaseHeavyTl3RateAllocation());
} }
TEST(RateControlSettingsTest, TEST(RateControlSettingsTest,
Vp8BaseHeavyTl3RateAllocationVideoRateControlKey) { Vp8BaseHeavyTl3RateAllocationVideoRateControlKey) {
const RateControlSettings settings_before = EXPECT_FALSE(ParseFrom("").Vp8BaseHeavyTl3RateAllocation());
RateControlSettings::ParseFromFieldTrials();
EXPECT_FALSE(settings_before.Vp8BaseHeavyTl3RateAllocation());
test::ScopedFieldTrials field_trials( EXPECT_TRUE(ParseFrom("WebRTC-VideoRateControl/vp8_base_heavy_tl3_alloc:1/")
"WebRTC-VideoRateControl/vp8_base_heavy_tl3_alloc:1/"); .Vp8BaseHeavyTl3RateAllocation());
const RateControlSettings settings_after =
RateControlSettings::ParseFromFieldTrials();
EXPECT_TRUE(settings_after.Vp8BaseHeavyTl3RateAllocation());
} }
TEST(RateControlSettingsTest, TEST(RateControlSettingsTest,
Vp8BaseHeavyTl3RateAllocationVideoRateControlKeyOverridesLegacyKey) { Vp8BaseHeavyTl3RateAllocationVideoRateControlKeyOverridesLegacyKey) {
const RateControlSettings settings_before = EXPECT_FALSE(ParseFrom("").Vp8BaseHeavyTl3RateAllocation());
RateControlSettings::ParseFromFieldTrials();
EXPECT_FALSE(settings_before.Vp8BaseHeavyTl3RateAllocation());
test::ScopedFieldTrials field_trials( EXPECT_FALSE(ParseFrom("WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/"
"WebRTC-UseBaseHeavyVP8TL3RateAllocation/Enabled/WebRTC-VideoRateControl/" "WebRTC-VideoRateControl/vp8_base_heavy_tl3_alloc:0/")
"vp8_base_heavy_tl3_alloc:0/"); .Vp8BaseHeavyTl3RateAllocation());
const RateControlSettings settings_after =
RateControlSettings::ParseFromFieldTrials();
EXPECT_FALSE(settings_after.Vp8BaseHeavyTl3RateAllocation());
} }
TEST(RateControlSettingsTest, UseEncoderBitrateAdjuster) { TEST(RateControlSettingsTest, UseEncoderBitrateAdjuster) {
// Should be on by default. EXPECT_TRUE(ParseFrom("").UseEncoderBitrateAdjuster());
EXPECT_TRUE(
RateControlSettings::ParseFromFieldTrials().UseEncoderBitrateAdjuster());
{ EXPECT_FALSE(ParseFrom("WebRTC-VideoRateControl/bitrate_adjuster:false/")
// Can be turned off via field trial.
test::ScopedFieldTrials field_trials(
"WebRTC-VideoRateControl/bitrate_adjuster:false/");
EXPECT_FALSE(RateControlSettings::ParseFromFieldTrials()
.UseEncoderBitrateAdjuster()); .UseEncoderBitrateAdjuster());
} }
}
} // namespace } // namespace

View File

@ -7300,8 +7300,7 @@ TEST_F(VideoStreamEncoderTest, DropsFramesWhenEncoderOvershoots) {
// of video, verify number of drops. Rate needs to be slightly changed in // of video, verify number of drops. Rate needs to be slightly changed in
// order to force the rate to be reconfigured. // order to force the rate to be reconfigured.
double overshoot_factor = 2.0; double overshoot_factor = 2.0;
const RateControlSettings trials = const RateControlSettings trials(env_.field_trials());
RateControlSettings::ParseFromFieldTrials();
if (trials.UseEncoderBitrateAdjuster()) { if (trials.UseEncoderBitrateAdjuster()) {
// With bitrate adjuster, when need to overshoot even more to trigger // With bitrate adjuster, when need to overshoot even more to trigger
// frame dropping since the adjuter will try to just lower the target // frame dropping since the adjuter will try to just lower the target