Cleanup expired field trial WebRTC-Video-QualityRampupSettings
Bug: webrtc:42221607 Change-Id: I72f271a2063ed543cd45b771991ce73208ed45c2 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/349721 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Cr-Commit-Position: refs/heads/main@{#42225}
This commit is contained in:
parent
5ed460aa31
commit
8b7d89a85f
@ -847,9 +847,6 @@ POLICY_EXEMPT_FIELD_TRIALS: FrozenSet[FieldTrial] = frozenset([
|
||||
FieldTrial('WebRTC-Video-PreferTemporalSupportOnBaseLayer',
|
||||
42221417,
|
||||
INDEFINITE),
|
||||
FieldTrial('WebRTC-Video-QualityRampupSettings',
|
||||
NO_BUG,
|
||||
date(2024, 4, 1)),
|
||||
FieldTrial('WebRTC-Video-QualityScalerSettings',
|
||||
NO_BUG,
|
||||
INDEFINITE),
|
||||
@ -887,7 +884,7 @@ POLICY_EXEMPT_FIELD_TRIALS: FrozenSet[FieldTrial] = frozenset([
|
||||
]) # yapf: disable
|
||||
|
||||
POLICY_EXEMPT_FIELD_TRIALS_DIGEST: str = \
|
||||
'230533dd083ddb73124412b928105b4c2ef3c1e9'
|
||||
'a84804e20ae8a5f63996e59560ca97d724665c20'
|
||||
|
||||
REGISTERED_FIELD_TRIALS: FrozenSet[FieldTrial] = ACTIVE_FIELD_TRIALS.union(
|
||||
POLICY_EXEMPT_FIELD_TRIALS)
|
||||
|
||||
@ -50,21 +50,6 @@ rtc_library("field_trial_parser") {
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("quality_rampup_experiment") {
|
||||
sources = [
|
||||
"quality_rampup_experiment.cc",
|
||||
"quality_rampup_experiment.h",
|
||||
]
|
||||
deps = [
|
||||
":field_trial_parser",
|
||||
"..:logging",
|
||||
"../../api:field_trials_view",
|
||||
"../../api/transport:field_trial_based_config",
|
||||
"../../system_wrappers:field_trial",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
}
|
||||
|
||||
rtc_library("quality_scaler_settings") {
|
||||
sources = [
|
||||
"quality_scaler_settings.cc",
|
||||
@ -216,7 +201,6 @@ if (rtc_include_tests && !build_with_chromium) {
|
||||
"keyframe_interval_settings_unittest.cc",
|
||||
"min_video_bitrate_experiment_unittest.cc",
|
||||
"normalize_simulcast_size_experiment_unittest.cc",
|
||||
"quality_rampup_experiment_unittest.cc",
|
||||
"quality_scaler_settings_unittest.cc",
|
||||
"quality_scaling_experiment_unittest.cc",
|
||||
"rate_control_settings_unittest.cc",
|
||||
@ -230,7 +214,6 @@ if (rtc_include_tests && !build_with_chromium) {
|
||||
":keyframe_interval_settings_experiment",
|
||||
":min_video_bitrate_experiment",
|
||||
":normalize_simulcast_size_experiment",
|
||||
":quality_rampup_experiment",
|
||||
":quality_scaler_settings",
|
||||
":quality_scaling_experiment",
|
||||
":rate_control_settings",
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "rtc_base/experiments/quality_rampup_experiment.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "api/transport/field_trial_based_config.h"
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
QualityRampupExperiment::QualityRampupExperiment(
|
||||
const FieldTrialsView* const key_value_config)
|
||||
: min_pixels_("min_pixels"),
|
||||
min_duration_ms_("min_duration_ms"),
|
||||
max_bitrate_factor_("max_bitrate_factor") {
|
||||
ParseFieldTrial(
|
||||
{&min_pixels_, &min_duration_ms_, &max_bitrate_factor_},
|
||||
key_value_config->Lookup("WebRTC-Video-QualityRampupSettings"));
|
||||
}
|
||||
|
||||
QualityRampupExperiment QualityRampupExperiment::ParseSettings() {
|
||||
FieldTrialBasedConfig field_trial_config;
|
||||
return QualityRampupExperiment(&field_trial_config);
|
||||
}
|
||||
|
||||
absl::optional<int> QualityRampupExperiment::MinPixels() const {
|
||||
return min_pixels_.GetOptional();
|
||||
}
|
||||
|
||||
absl::optional<int> QualityRampupExperiment::MinDurationMs() const {
|
||||
return min_duration_ms_.GetOptional();
|
||||
}
|
||||
|
||||
absl::optional<double> QualityRampupExperiment::MaxBitrateFactor() const {
|
||||
return max_bitrate_factor_.GetOptional();
|
||||
}
|
||||
|
||||
void QualityRampupExperiment::SetMaxBitrate(int pixels,
|
||||
uint32_t max_bitrate_kbps) {
|
||||
if (!min_pixels_ || pixels < min_pixels_.Value() || max_bitrate_kbps == 0) {
|
||||
return;
|
||||
}
|
||||
max_bitrate_kbps_ = std::max(max_bitrate_kbps_.value_or(0), max_bitrate_kbps);
|
||||
}
|
||||
|
||||
bool QualityRampupExperiment::BwHigh(int64_t now_ms,
|
||||
uint32_t available_bw_kbps) {
|
||||
if (!min_pixels_ || !min_duration_ms_ || !max_bitrate_kbps_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (available_bw_kbps <
|
||||
max_bitrate_kbps_.value() * MaxBitrateFactor().value_or(1)) {
|
||||
start_ms_.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!start_ms_)
|
||||
start_ms_ = now_ms;
|
||||
|
||||
return (now_ms - *start_ms_) >= min_duration_ms_.Value();
|
||||
}
|
||||
|
||||
void QualityRampupExperiment::Reset() {
|
||||
start_ms_.reset();
|
||||
max_bitrate_kbps_.reset();
|
||||
}
|
||||
|
||||
bool QualityRampupExperiment::Enabled() const {
|
||||
return min_pixels_ && min_duration_ms_;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_
|
||||
#define RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/experiments/field_trial_parser.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class QualityRampupExperiment final {
|
||||
public:
|
||||
static QualityRampupExperiment ParseSettings();
|
||||
|
||||
absl::optional<int> MinPixels() const;
|
||||
absl::optional<int> MinDurationMs() const;
|
||||
absl::optional<double> MaxBitrateFactor() const;
|
||||
|
||||
// Sets the max bitrate and the frame size.
|
||||
// The call has no effect if the frame size is less than `min_pixels_`.
|
||||
void SetMaxBitrate(int pixels, uint32_t max_bitrate_kbps);
|
||||
|
||||
// Returns true if the available bandwidth is a certain percentage
|
||||
// (max_bitrate_factor_) above `max_bitrate_kbps_` for `min_duration_ms_`.
|
||||
bool BwHigh(int64_t now_ms, uint32_t available_bw_kbps);
|
||||
|
||||
void Reset();
|
||||
bool Enabled() const;
|
||||
|
||||
private:
|
||||
explicit QualityRampupExperiment(
|
||||
const FieldTrialsView* const key_value_config);
|
||||
|
||||
FieldTrialOptional<int> min_pixels_;
|
||||
FieldTrialOptional<int> min_duration_ms_;
|
||||
FieldTrialOptional<double> max_bitrate_factor_;
|
||||
|
||||
absl::optional<int64_t> start_ms_;
|
||||
absl::optional<uint32_t> max_bitrate_kbps_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // RTC_BASE_EXPERIMENTS_QUALITY_RAMPUP_EXPERIMENT_H_
|
||||
@ -1,139 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "rtc_base/experiments/quality_rampup_experiment.h"
|
||||
|
||||
#include "test/field_trial.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
||||
class QualityRampupExperimentTest : public ::testing::Test {
|
||||
protected:
|
||||
int64_t NowMs() const { return current_ms_; }
|
||||
int64_t AdvanceMs(int64_t delta_ms) {
|
||||
current_ms_ += delta_ms;
|
||||
return current_ms_;
|
||||
}
|
||||
int64_t current_ms_ = 2345;
|
||||
};
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ValuesNotSetByDefault) {
|
||||
const auto settings = QualityRampupExperiment::ParseSettings();
|
||||
EXPECT_FALSE(settings.MinPixels());
|
||||
EXPECT_FALSE(settings.MinDurationMs());
|
||||
EXPECT_FALSE(settings.MaxBitrateFactor());
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ParseMinPixels) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/min_pixels:10000/");
|
||||
EXPECT_EQ(10000, QualityRampupExperiment::ParseSettings().MinPixels());
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ParseMinDuration) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/min_duration_ms:987/");
|
||||
EXPECT_EQ(987, QualityRampupExperiment::ParseSettings().MinDurationMs());
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ParseMaxBitrateFactor) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/max_bitrate_factor:1.23/");
|
||||
EXPECT_EQ(1.23, QualityRampupExperiment::ParseSettings().MaxBitrateFactor());
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ReportsBwHighWhenDurationPassed) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/"
|
||||
"min_pixels:10000,min_duration_ms:2000/");
|
||||
auto exp = QualityRampupExperiment::ParseSettings();
|
||||
EXPECT_EQ(10000, exp.MinPixels());
|
||||
EXPECT_EQ(2000, exp.MinDurationMs());
|
||||
|
||||
const uint32_t kMaxKbps = 800;
|
||||
exp.SetMaxBitrate(/*pixels*/ 10000, kMaxKbps);
|
||||
|
||||
const uint32_t kAvailableKbps = kMaxKbps;
|
||||
EXPECT_FALSE(exp.BwHigh(NowMs(), kAvailableKbps));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(2000 - 1), kAvailableKbps));
|
||||
EXPECT_TRUE(exp.BwHigh(AdvanceMs(1), kAvailableKbps));
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, UsesMaxSetBitrate) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/"
|
||||
"min_pixels:10000,min_duration_ms:2000/");
|
||||
auto exp = QualityRampupExperiment::ParseSettings();
|
||||
|
||||
const uint32_t kMaxKbps = 800;
|
||||
exp.SetMaxBitrate(/*pixels*/ 10000, kMaxKbps);
|
||||
exp.SetMaxBitrate(/*pixels*/ 10000, kMaxKbps - 1);
|
||||
|
||||
EXPECT_FALSE(exp.BwHigh(NowMs(), kMaxKbps - 1));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(2000), kMaxKbps - 1));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(1), kMaxKbps));
|
||||
EXPECT_TRUE(exp.BwHigh(AdvanceMs(2000), kMaxKbps));
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, DoesNotReportBwHighIfBelowMinPixels) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/"
|
||||
"min_pixels:10000,min_duration_ms:2000/");
|
||||
auto exp = QualityRampupExperiment::ParseSettings();
|
||||
|
||||
const uint32_t kMaxKbps = 800;
|
||||
exp.SetMaxBitrate(/*pixels*/ 9999, kMaxKbps);
|
||||
|
||||
const uint32_t kAvailableKbps = kMaxKbps;
|
||||
EXPECT_FALSE(exp.BwHigh(NowMs(), kAvailableKbps));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(2000), kAvailableKbps));
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ReportsBwHighWithMaxBitrateFactor) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/"
|
||||
"min_pixels:10000,min_duration_ms:2000,max_bitrate_factor:1.5/");
|
||||
auto exp = QualityRampupExperiment::ParseSettings();
|
||||
EXPECT_EQ(10000, exp.MinPixels());
|
||||
EXPECT_EQ(2000, exp.MinDurationMs());
|
||||
EXPECT_EQ(1.5, exp.MaxBitrateFactor());
|
||||
|
||||
const uint32_t kMaxKbps = 800;
|
||||
exp.SetMaxBitrate(/*pixels*/ 10000, kMaxKbps);
|
||||
|
||||
const uint32_t kAvailableKbps = kMaxKbps * 1.5;
|
||||
EXPECT_FALSE(exp.BwHigh(NowMs(), kAvailableKbps - 1));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(2000), kAvailableKbps - 1));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(1), kAvailableKbps));
|
||||
EXPECT_TRUE(exp.BwHigh(AdvanceMs(2000), kAvailableKbps));
|
||||
}
|
||||
|
||||
TEST_F(QualityRampupExperimentTest, ReportsBwHigh) {
|
||||
test::ScopedFieldTrials field_trials(
|
||||
"WebRTC-Video-QualityRampupSettings/"
|
||||
"min_pixels:10000,min_duration_ms:2000/");
|
||||
auto exp = QualityRampupExperiment::ParseSettings();
|
||||
|
||||
const uint32_t kMaxKbps = 800;
|
||||
exp.SetMaxBitrate(/*pixels*/ 10000, kMaxKbps);
|
||||
|
||||
const uint32_t kAvailableKbps = kMaxKbps;
|
||||
EXPECT_FALSE(exp.BwHigh(NowMs(), kAvailableKbps));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(2000 - 1), kAvailableKbps));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(1), kAvailableKbps - 1)); // Below, reset.
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(1), kAvailableKbps));
|
||||
EXPECT_FALSE(exp.BwHigh(AdvanceMs(2000 - 1), kAvailableKbps));
|
||||
EXPECT_TRUE(exp.BwHigh(AdvanceMs(1), kAvailableKbps));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace webrtc
|
||||
@ -457,7 +457,6 @@ rtc_library("video_stream_encoder_impl") {
|
||||
"../rtc_base/experiments:balanced_degradation_settings",
|
||||
"../rtc_base/experiments:encoder_info_settings",
|
||||
"../rtc_base/experiments:field_trial_parser",
|
||||
"../rtc_base/experiments:quality_rampup_experiment",
|
||||
"../rtc_base/experiments:quality_scaler_settings",
|
||||
"../rtc_base/experiments:quality_scaling_experiment",
|
||||
"../rtc_base/experiments:rate_control_settings",
|
||||
|
||||
@ -22,8 +22,6 @@ rtc_library("video_adaptation") {
|
||||
"overuse_frame_detector.h",
|
||||
"pixel_limit_resource.cc",
|
||||
"pixel_limit_resource.h",
|
||||
"quality_rampup_experiment_helper.cc",
|
||||
"quality_rampup_experiment_helper.h",
|
||||
"quality_scaler_resource.cc",
|
||||
"quality_scaler_resource.h",
|
||||
"video_stream_encoder_resource.cc",
|
||||
@ -61,7 +59,6 @@ rtc_library("video_adaptation") {
|
||||
"../../rtc_base:timeutils",
|
||||
"../../rtc_base/experiments:balanced_degradation_settings",
|
||||
"../../rtc_base/experiments:field_trial_parser",
|
||||
"../../rtc_base/experiments:quality_rampup_experiment",
|
||||
"../../rtc_base/experiments:quality_scaler_settings",
|
||||
"../../rtc_base/synchronization:mutex",
|
||||
"../../rtc_base/system:no_unique_address",
|
||||
|
||||
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "video/adaptation/quality_rampup_experiment_helper.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "rtc_base/logging.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
QualityRampUpExperimentHelper::QualityRampUpExperimentHelper(
|
||||
QualityRampUpExperimentListener* experiment_listener,
|
||||
Clock* clock,
|
||||
QualityRampupExperiment experiment)
|
||||
: experiment_listener_(experiment_listener),
|
||||
clock_(clock),
|
||||
quality_rampup_experiment_(std::move(experiment)),
|
||||
cpu_adapted_(false),
|
||||
qp_resolution_adaptations_(0) {
|
||||
RTC_DCHECK(experiment_listener_);
|
||||
RTC_DCHECK(clock_);
|
||||
}
|
||||
|
||||
std::unique_ptr<QualityRampUpExperimentHelper>
|
||||
QualityRampUpExperimentHelper::CreateIfEnabled(
|
||||
QualityRampUpExperimentListener* experiment_listener,
|
||||
Clock* clock) {
|
||||
QualityRampupExperiment experiment = QualityRampupExperiment::ParseSettings();
|
||||
if (experiment.Enabled()) {
|
||||
return std::unique_ptr<QualityRampUpExperimentHelper>(
|
||||
new QualityRampUpExperimentHelper(experiment_listener, clock,
|
||||
experiment));
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void QualityRampUpExperimentHelper::ConfigureQualityRampupExperiment(
|
||||
bool reset,
|
||||
absl::optional<uint32_t> pixels,
|
||||
absl::optional<DataRate> max_bitrate) {
|
||||
if (reset)
|
||||
quality_rampup_experiment_.Reset();
|
||||
if (pixels && max_bitrate)
|
||||
quality_rampup_experiment_.SetMaxBitrate(*pixels, max_bitrate->kbps());
|
||||
}
|
||||
|
||||
void QualityRampUpExperimentHelper::PerformQualityRampupExperiment(
|
||||
rtc::scoped_refptr<QualityScalerResource> quality_scaler_resource,
|
||||
DataRate bandwidth,
|
||||
DataRate encoder_target_bitrate,
|
||||
absl::optional<DataRate> max_bitrate) {
|
||||
if (!quality_scaler_resource->is_started() || !max_bitrate)
|
||||
return;
|
||||
|
||||
int64_t now_ms = clock_->TimeInMilliseconds();
|
||||
|
||||
bool try_quality_rampup = false;
|
||||
if (quality_rampup_experiment_.BwHigh(now_ms, bandwidth.kbps())) {
|
||||
// Verify that encoder is at max bitrate and the QP is low.
|
||||
if (encoder_target_bitrate == *max_bitrate &&
|
||||
quality_scaler_resource->QpFastFilterLow()) {
|
||||
try_quality_rampup = true;
|
||||
}
|
||||
}
|
||||
if (try_quality_rampup && qp_resolution_adaptations_ > 0 && !cpu_adapted_) {
|
||||
experiment_listener_->OnQualityRampUp();
|
||||
}
|
||||
}
|
||||
|
||||
void QualityRampUpExperimentHelper::cpu_adapted(bool cpu_adapted) {
|
||||
cpu_adapted_ = cpu_adapted;
|
||||
}
|
||||
|
||||
void QualityRampUpExperimentHelper::qp_resolution_adaptations(
|
||||
int qp_resolution_adaptations) {
|
||||
qp_resolution_adaptations_ = qp_resolution_adaptations;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2020 The WebRTC Project Authors. All rights reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#ifndef VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_
|
||||
#define VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/scoped_refptr.h"
|
||||
#include "api/units/data_rate.h"
|
||||
#include "rtc_base/experiments/quality_rampup_experiment.h"
|
||||
#include "system_wrappers/include/clock.h"
|
||||
#include "video/adaptation/quality_scaler_resource.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class QualityRampUpExperimentListener {
|
||||
public:
|
||||
virtual ~QualityRampUpExperimentListener() = default;
|
||||
virtual void OnQualityRampUp() = 0;
|
||||
};
|
||||
|
||||
// Helper class for orchestrating the WebRTC-Video-QualityRampupSettings
|
||||
// experiment.
|
||||
class QualityRampUpExperimentHelper {
|
||||
public:
|
||||
// Returns a QualityRampUpExperimentHelper if the experiment is enabled,
|
||||
// an nullptr otherwise.
|
||||
static std::unique_ptr<QualityRampUpExperimentHelper> CreateIfEnabled(
|
||||
QualityRampUpExperimentListener* experiment_listener,
|
||||
Clock* clock);
|
||||
|
||||
QualityRampUpExperimentHelper(const QualityRampUpExperimentHelper&) = delete;
|
||||
QualityRampUpExperimentHelper& operator=(
|
||||
const QualityRampUpExperimentHelper&) = delete;
|
||||
|
||||
void cpu_adapted(bool cpu_adapted);
|
||||
void qp_resolution_adaptations(int qp_adaptations);
|
||||
|
||||
void ConfigureQualityRampupExperiment(bool reset,
|
||||
absl::optional<uint32_t> pixels,
|
||||
absl::optional<DataRate> max_bitrate);
|
||||
|
||||
void PerformQualityRampupExperiment(
|
||||
rtc::scoped_refptr<QualityScalerResource> quality_scaler_resource,
|
||||
DataRate bandwidth,
|
||||
DataRate encoder_target_bitrate,
|
||||
absl::optional<DataRate> max_bitrate);
|
||||
|
||||
private:
|
||||
QualityRampUpExperimentHelper(
|
||||
QualityRampUpExperimentListener* experiment_listener,
|
||||
Clock* clock,
|
||||
QualityRampupExperiment experiment);
|
||||
QualityRampUpExperimentListener* const experiment_listener_;
|
||||
Clock* clock_;
|
||||
QualityRampupExperiment quality_rampup_experiment_;
|
||||
bool cpu_adapted_;
|
||||
int qp_resolution_adaptations_;
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // VIDEO_ADAPTATION_QUALITY_RAMPUP_EXPERIMENT_HELPER_H_
|
||||
@ -88,30 +88,6 @@ bool EqualFlags(const std::vector<bool>& a, const std::vector<bool>& b) {
|
||||
return std::equal(a.begin(), a.end(), b.begin());
|
||||
}
|
||||
|
||||
absl::optional<DataRate> GetSingleActiveLayerMaxBitrate(
|
||||
const VideoCodec& codec) {
|
||||
int num_active = 0;
|
||||
absl::optional<DataRate> max_bitrate;
|
||||
if (codec.codecType == VideoCodecType::kVideoCodecVP9) {
|
||||
for (int i = 0; i < codec.VP9().numberOfSpatialLayers; ++i) {
|
||||
if (codec.spatialLayers[i].active) {
|
||||
++num_active;
|
||||
max_bitrate =
|
||||
DataRate::KilobitsPerSec(codec.spatialLayers[i].maxBitrate);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < codec.numberOfSimulcastStreams; ++i) {
|
||||
if (codec.simulcastStream[i].active) {
|
||||
++num_active;
|
||||
max_bitrate =
|
||||
DataRate::KilobitsPerSec(codec.simulcastStream[i].maxBitrate);
|
||||
}
|
||||
}
|
||||
}
|
||||
return (num_active > 1) ? absl::nullopt : max_bitrate;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
class VideoStreamEncoderResourceManager::InitialFrameDropper {
|
||||
@ -298,8 +274,6 @@ VideoStreamEncoderResourceManager::VideoStreamEncoderResourceManager(
|
||||
pixel_limit_resource_experiment_enabled_(
|
||||
field_trials.IsEnabled(kPixelLimitResourceFieldTrialName)),
|
||||
encoder_target_bitrate_bps_(absl::nullopt),
|
||||
quality_rampup_experiment_(
|
||||
QualityRampUpExperimentHelper::CreateIfEnabled(this, clock_)),
|
||||
encoder_settings_(absl::nullopt) {
|
||||
TRACE_EVENT0(
|
||||
"webrtc",
|
||||
@ -442,12 +416,6 @@ void VideoStreamEncoderResourceManager::SetEncoderSettings(
|
||||
initial_frame_dropper_->OnEncoderSettingsUpdated(
|
||||
encoder_settings_->video_codec(), current_adaptation_counters_);
|
||||
MaybeUpdateTargetFrameRate();
|
||||
if (quality_rampup_experiment_) {
|
||||
quality_rampup_experiment_->ConfigureQualityRampupExperiment(
|
||||
initial_frame_dropper_->last_stream_configuration_changed(),
|
||||
initial_frame_dropper_->single_active_stream_pixels(),
|
||||
GetSingleActiveLayerMaxBitrate(encoder_settings_->video_codec()));
|
||||
}
|
||||
}
|
||||
|
||||
void VideoStreamEncoderResourceManager::SetStartBitrate(
|
||||
@ -547,15 +515,6 @@ VideoStreamEncoderResourceManager::UseBandwidthAllocationBps() const {
|
||||
void VideoStreamEncoderResourceManager::OnMaybeEncodeFrame() {
|
||||
RTC_DCHECK_RUN_ON(encoder_queue_);
|
||||
initial_frame_dropper_->Disable();
|
||||
if (quality_rampup_experiment_ && quality_scaler_resource_->is_started()) {
|
||||
DataRate bandwidth = encoder_rates_.has_value()
|
||||
? encoder_rates_->bandwidth_allocation
|
||||
: DataRate::Zero();
|
||||
quality_rampup_experiment_->PerformQualityRampupExperiment(
|
||||
quality_scaler_resource_, bandwidth,
|
||||
DataRate::BitsPerSec(encoder_target_bitrate_bps_.value_or(0)),
|
||||
GetSingleActiveLayerMaxBitrate(encoder_settings_->video_codec()));
|
||||
}
|
||||
}
|
||||
|
||||
void VideoStreamEncoderResourceManager::UpdateQualityScalerSettings(
|
||||
@ -744,15 +703,6 @@ void VideoStreamEncoderResourceManager::OnResourceLimitationChanged(
|
||||
adaptation_reason, limitations[VideoAdaptationReason::kCpu],
|
||||
limitations[VideoAdaptationReason::kQuality]);
|
||||
|
||||
if (quality_rampup_experiment_) {
|
||||
bool cpu_limited = limitations.at(VideoAdaptationReason::kCpu).Total() > 0;
|
||||
auto qp_resolution_adaptations =
|
||||
limitations.at(VideoAdaptationReason::kQuality).resolution_adaptations;
|
||||
quality_rampup_experiment_->cpu_adapted(cpu_limited);
|
||||
quality_rampup_experiment_->qp_resolution_adaptations(
|
||||
qp_resolution_adaptations);
|
||||
}
|
||||
|
||||
RTC_LOG(LS_INFO) << ActiveCountsToString(limitations);
|
||||
}
|
||||
|
||||
@ -813,12 +763,6 @@ std::string VideoStreamEncoderResourceManager::ActiveCountsToString(
|
||||
return ss.Release();
|
||||
}
|
||||
|
||||
void VideoStreamEncoderResourceManager::OnQualityRampUp() {
|
||||
RTC_DCHECK_RUN_ON(encoder_queue_);
|
||||
stream_adapter_->ClearRestrictions();
|
||||
quality_rampup_experiment_.reset();
|
||||
}
|
||||
|
||||
bool VideoStreamEncoderResourceManager::IsSimulcastOrMultipleSpatialLayers(
|
||||
const VideoEncoderConfig& encoder_config,
|
||||
const VideoCodec& video_codec) {
|
||||
|
||||
@ -46,7 +46,6 @@
|
||||
#include "video/adaptation/encode_usage_resource.h"
|
||||
#include "video/adaptation/overuse_frame_detector.h"
|
||||
#include "video/adaptation/pixel_limit_resource.h"
|
||||
#include "video/adaptation/quality_rampup_experiment_helper.h"
|
||||
#include "video/adaptation/quality_scaler_resource.h"
|
||||
#include "video/adaptation/video_stream_encoder_resource.h"
|
||||
#include "video/config/video_encoder_config.h"
|
||||
@ -70,8 +69,7 @@ extern const int kDefaultInputPixelsHeight;
|
||||
// ResourceAdaptationProcessor code such as the initial frame dropping.
|
||||
class VideoStreamEncoderResourceManager
|
||||
: public VideoSourceRestrictionsListener,
|
||||
public ResourceLimitationsListener,
|
||||
public QualityRampUpExperimentListener {
|
||||
public ResourceLimitationsListener {
|
||||
public:
|
||||
VideoStreamEncoderResourceManager(
|
||||
VideoStreamInputStateProvider* input_state_provider,
|
||||
@ -149,9 +147,6 @@ class VideoStreamEncoderResourceManager
|
||||
const std::map<rtc::scoped_refptr<Resource>, VideoAdaptationCounters>&
|
||||
resource_limitations) override;
|
||||
|
||||
// QualityRampUpExperimentListener implementation.
|
||||
void OnQualityRampUp() override;
|
||||
|
||||
static bool IsSimulcastOrMultipleSpatialLayers(
|
||||
const VideoEncoderConfig& encoder_config,
|
||||
const VideoCodec& video_codec);
|
||||
@ -223,8 +218,6 @@ class VideoStreamEncoderResourceManager
|
||||
RTC_GUARDED_BY(encoder_queue_);
|
||||
absl::optional<VideoEncoder::RateControlParameters> encoder_rates_
|
||||
RTC_GUARDED_BY(encoder_queue_);
|
||||
std::unique_ptr<QualityRampUpExperimentHelper> quality_rampup_experiment_
|
||||
RTC_GUARDED_BY(encoder_queue_);
|
||||
absl::optional<EncoderSettings> encoder_settings_
|
||||
RTC_GUARDED_BY(encoder_queue_);
|
||||
|
||||
|
||||
@ -6328,82 +6328,6 @@ TEST_F(VideoStreamEncoderTest,
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
|
||||
TEST_F(VideoStreamEncoderTest, RampsUpInQualityWhenBwIsHigh) {
|
||||
webrtc::test::ScopedKeyValueConfig field_trials(
|
||||
field_trials_,
|
||||
"WebRTC-Video-QualityRampupSettings/"
|
||||
"min_pixels:921600,min_duration_ms:2000/");
|
||||
|
||||
const int kWidth = 1280;
|
||||
const int kHeight = 720;
|
||||
const int kFps = 10;
|
||||
max_framerate_ = kFps;
|
||||
|
||||
// Reset encoder for field trials to take effect.
|
||||
VideoEncoderConfig config = video_encoder_config_.Copy();
|
||||
config.max_bitrate_bps = kTargetBitrate.bps();
|
||||
DataRate max_bitrate = DataRate::BitsPerSec(config.max_bitrate_bps);
|
||||
ConfigureEncoder(std::move(config));
|
||||
fake_encoder_.SetQp(kQpLow);
|
||||
|
||||
// Enable MAINTAIN_FRAMERATE preference.
|
||||
AdaptingFrameForwarder source(&time_controller_);
|
||||
source.set_adaptation_enabled(true);
|
||||
video_stream_encoder_->SetSource(&source,
|
||||
DegradationPreference::MAINTAIN_FRAMERATE);
|
||||
|
||||
// Start at low bitrate.
|
||||
const DataRate kLowBitrate = DataRate::KilobitsPerSec(200);
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
kLowBitrate, kLowBitrate, kLowBitrate, 0, 0, 0);
|
||||
|
||||
// Expect first frame to be dropped and resolution to be limited.
|
||||
const int64_t kFrameIntervalMs = 1000 / kFps;
|
||||
int64_t timestamp_ms = kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
ExpectDroppedFrame();
|
||||
EXPECT_TRUE_WAIT(source.sink_wants().max_pixel_count < kWidth * kHeight,
|
||||
5000);
|
||||
|
||||
// Increase bitrate to encoder max.
|
||||
video_stream_encoder_->OnBitrateUpdatedAndWaitForManagedResources(
|
||||
max_bitrate, max_bitrate, max_bitrate, 0, 0, 0);
|
||||
|
||||
// Insert frames and advance `min_duration_ms`.
|
||||
const int64_t start_bw_high_ms = CurrentTimeMs();
|
||||
for (size_t i = 1; i <= 10; i++) {
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
}
|
||||
|
||||
// Advance to `min_duration_ms` - 1, frame should not trigger high BW.
|
||||
int64_t elapsed_bw_high_ms = CurrentTimeMs() - start_bw_high_ms;
|
||||
AdvanceTime(TimeDelta::Millis(2000 - elapsed_bw_high_ms - 1));
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
EXPECT_TRUE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
EXPECT_LT(source.sink_wants().max_pixel_count, kWidth * kHeight);
|
||||
|
||||
// Frame should trigger high BW and release quality limitation.
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(timestamp_ms);
|
||||
// The ramp-up code involves the adaptation queue, give it time to execute.
|
||||
// TODO(hbos): Can we await an appropriate event instead?
|
||||
video_stream_encoder_->WaitUntilTaskQueueIsIdle();
|
||||
EXPECT_THAT(source.sink_wants(), UnlimitedSinkWants());
|
||||
|
||||
// Frame should not be adapted.
|
||||
timestamp_ms += kFrameIntervalMs;
|
||||
source.IncomingCapturedFrame(CreateFrame(timestamp_ms, kWidth, kHeight));
|
||||
WaitForEncodedFrame(kWidth, kHeight);
|
||||
EXPECT_FALSE(stats_proxy_->GetStats().bw_limited_resolution);
|
||||
|
||||
video_stream_encoder_->Stop();
|
||||
}
|
||||
|
||||
TEST_F(VideoStreamEncoderTest,
|
||||
QualityScalerAdaptationsRemovedWhenQualityScalingDisabled) {
|
||||
webrtc::test::ScopedKeyValueConfig field_trials(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user