mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-12 21:30:45 +01:00
Use propagated field trials for WebRTC-NormalizeSimulcastResolution experiment
Bug: webrtc:10335 Change-Id: I2db0ac9fc305e033c26cb8401db38317fbc71014 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/343761 Reviewed-by: Åsa Persson <asapersson@webrtc.org> Commit-Queue: Åsa Persson <asapersson@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#41934}
This commit is contained in:
parent
d7e0981281
commit
8aaf85a687
7 changed files with 49 additions and 27 deletions
|
@ -117,7 +117,7 @@ rtc_library("normalize_simulcast_size_experiment") {
|
|||
]
|
||||
deps = [
|
||||
"..:logging",
|
||||
"../../system_wrappers:field_trial",
|
||||
"../../api:field_trials_view",
|
||||
]
|
||||
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
|
||||
}
|
||||
|
@ -287,6 +287,7 @@ if (rtc_include_tests && !build_with_chromium) {
|
|||
"../../api/video:video_frame",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../system_wrappers:field_trial",
|
||||
"../../test:explicit_key_value_config",
|
||||
"../../test:field_trial",
|
||||
"../../test:scoped_key_value_config",
|
||||
"../../test:test_main",
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include "api/field_trials_view.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "system_wrappers/include/field_trial.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace {
|
||||
|
@ -24,11 +24,12 @@ constexpr int kMinSetting = 0;
|
|||
constexpr int kMaxSetting = 5;
|
||||
} // namespace
|
||||
|
||||
absl::optional<int> NormalizeSimulcastSizeExperiment::GetBase2Exponent() {
|
||||
if (!webrtc::field_trial::IsEnabled(kFieldTrial))
|
||||
absl::optional<int> NormalizeSimulcastSizeExperiment::GetBase2Exponent(
|
||||
const FieldTrialsView& field_trials) {
|
||||
if (!field_trials.IsEnabled(kFieldTrial))
|
||||
return absl::nullopt;
|
||||
|
||||
const std::string group = webrtc::field_trial::FindFullName(kFieldTrial);
|
||||
const std::string group = field_trials.Lookup(kFieldTrial);
|
||||
if (group.empty())
|
||||
return absl::nullopt;
|
||||
|
||||
|
|
|
@ -12,12 +12,14 @@
|
|||
#define RTC_BASE_EXPERIMENTS_NORMALIZE_SIMULCAST_SIZE_EXPERIMENT_H_
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/field_trials_view.h"
|
||||
|
||||
namespace webrtc {
|
||||
class NormalizeSimulcastSizeExperiment {
|
||||
public:
|
||||
// Returns the base two exponent from field trial.
|
||||
static absl::optional<int> GetBase2Exponent();
|
||||
static absl::optional<int> GetBase2Exponent(
|
||||
const FieldTrialsView& field_trials);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -10,50 +10,58 @@
|
|||
|
||||
#include "rtc_base/experiments/normalize_simulcast_size_experiment.h"
|
||||
|
||||
#include "test/field_trial.h"
|
||||
#include "test/explicit_key_value_config.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
using test::ExplicitKeyValueConfig;
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest, GetExponent) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
ExplicitKeyValueConfig field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-2/");
|
||||
EXPECT_EQ(2, NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
EXPECT_EQ(2,
|
||||
NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials));
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest, GetExponentWithTwoParameters) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
ExplicitKeyValueConfig field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-3-4/");
|
||||
EXPECT_EQ(3, NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
EXPECT_EQ(3,
|
||||
NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials));
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest, GetExponentFailsIfNotEnabled) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
ExplicitKeyValueConfig field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Disabled/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
EXPECT_FALSE(
|
||||
NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials));
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest,
|
||||
GetExponentFailsForInvalidFieldTrial) {
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
ExplicitKeyValueConfig field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-invalid/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
EXPECT_FALSE(
|
||||
NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials));
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest,
|
||||
GetExponentFailsForNegativeOutOfBoundValue) {
|
||||
// Supported range: [0, 5].
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
ExplicitKeyValueConfig field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled--1/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
EXPECT_FALSE(
|
||||
NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials));
|
||||
}
|
||||
|
||||
TEST(NormalizeSimulcastSizeExperimentTest,
|
||||
GetExponentFailsForPositiveOutOfBoundValue) {
|
||||
// Supported range: [0, 5].
|
||||
webrtc::test::ScopedFieldTrials field_trials(
|
||||
ExplicitKeyValueConfig field_trials(
|
||||
"WebRTC-NormalizeSimulcastResolution/Enabled-6/");
|
||||
EXPECT_FALSE(NormalizeSimulcastSizeExperiment::GetBase2Exponent());
|
||||
EXPECT_FALSE(
|
||||
NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials));
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
|
|
@ -340,16 +340,19 @@ EncoderStreamFactory::CreateSimulcastOrConferenceModeScreenshareStreams(
|
|||
default_scale_factors_used = IsScaleFactorsPowerOfTwo(encoder_config);
|
||||
}
|
||||
const bool norm_size_configured =
|
||||
webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent().has_value();
|
||||
webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent(trials_)
|
||||
.has_value();
|
||||
const int normalized_width =
|
||||
(default_scale_factors_used || norm_size_configured) &&
|
||||
(width >= kMinLayerSize)
|
||||
? NormalizeSimulcastSize(width, encoder_config.number_of_streams)
|
||||
? NormalizeSimulcastSize(trials_, width,
|
||||
encoder_config.number_of_streams)
|
||||
: width;
|
||||
const int normalized_height =
|
||||
(default_scale_factors_used || norm_size_configured) &&
|
||||
(height >= kMinLayerSize)
|
||||
? NormalizeSimulcastSize(height, encoder_config.number_of_streams)
|
||||
? NormalizeSimulcastSize(trials_, height,
|
||||
encoder_config.number_of_streams)
|
||||
: height;
|
||||
for (size_t i = 0; i < layers.size(); ++i) {
|
||||
layers[i].active = encoder_config.simulcast_layers[i].active;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "absl/strings/match.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/field_trials_view.h"
|
||||
#include "api/video/video_codec_constants.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "modules/video_coding/utility/simulcast_rate_allocator.h"
|
||||
|
@ -33,6 +34,8 @@ namespace cricket {
|
|||
|
||||
namespace {
|
||||
|
||||
using ::webrtc::FieldTrialsView;
|
||||
|
||||
constexpr char kUseLegacySimulcastLayerLimitFieldTrial[] =
|
||||
"WebRTC-LegacySimulcastLayerLimit";
|
||||
|
||||
|
@ -218,10 +221,12 @@ int FindSimulcastFormatIndex(int width,
|
|||
// Round size to nearest simulcast-friendly size.
|
||||
// Simulcast stream width and height must both be dividable by
|
||||
// |2 ^ (simulcast_layers - 1)|.
|
||||
int NormalizeSimulcastSize(int size, size_t simulcast_layers) {
|
||||
int NormalizeSimulcastSize(const FieldTrialsView& field_trials,
|
||||
int size,
|
||||
size_t simulcast_layers) {
|
||||
int base2_exponent = static_cast<int>(simulcast_layers) - 1;
|
||||
const absl::optional<int> experimental_base2_exponent =
|
||||
webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent();
|
||||
webrtc::NormalizeSimulcastSizeExperiment::GetBase2Exponent(field_trials);
|
||||
if (experimental_base2_exponent &&
|
||||
(size > (1 << *experimental_base2_exponent))) {
|
||||
base2_exponent = *experimental_base2_exponent;
|
||||
|
@ -411,8 +416,8 @@ std::vector<webrtc::VideoStream> GetNormalSimulcastLayers(
|
|||
const int num_temporal_layers = DefaultNumberOfTemporalLayers(trials);
|
||||
// Format width and height has to be divisible by |2 ^ num_simulcast_layers -
|
||||
// 1|.
|
||||
width = NormalizeSimulcastSize(width, layer_count);
|
||||
height = NormalizeSimulcastSize(height, layer_count);
|
||||
width = NormalizeSimulcastSize(trials, width, layer_count);
|
||||
height = NormalizeSimulcastSize(trials, height, layer_count);
|
||||
// Add simulcast streams, from highest resolution (`s` = num_simulcast_layers
|
||||
// -1) to lowest resolution at `s` = 0.
|
||||
for (size_t s = layer_count - 1;; --s) {
|
||||
|
|
|
@ -31,7 +31,9 @@ void BoostMaxSimulcastLayer(webrtc::DataRate max_bitrate,
|
|||
std::vector<webrtc::VideoStream>* layers);
|
||||
|
||||
// Round size to nearest simulcast-friendly size
|
||||
int NormalizeSimulcastSize(int size, size_t simulcast_layers);
|
||||
int NormalizeSimulcastSize(const webrtc::FieldTrialsView& field_trials,
|
||||
int size,
|
||||
size_t simulcast_layers);
|
||||
|
||||
// Gets simulcast settings.
|
||||
std::vector<webrtc::VideoStream> GetSimulcastConfig(
|
||||
|
|
Loading…
Reference in a new issue