Move parsing of trusted rate controller to RateControlSettings

Bug: webrtc:10223
Change-Id: Iadf46e278e0f994ed95ff1a240c1f39a0421ab7c
Reviewed-on: https://webrtc-review.googlesource.com/c/119261
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26371}
This commit is contained in:
Erik Språng 2019-01-23 12:48:13 +01:00 committed by Commit Bot
parent 470a5eae93
commit 4b4266f00f
5 changed files with 39 additions and 11 deletions

View File

@ -427,6 +427,7 @@ rtc_static_library("webrtc_vp8") {
"../../rtc_base:rtc_numerics",
"../../rtc_base/experiments:cpu_speed_experiment",
"../../rtc_base/experiments:field_trial_parser",
"../../rtc_base/experiments:rate_control_settings",
"../../system_wrappers",
"../../system_wrappers:field_trial",
"../../system_wrappers:metrics",
@ -531,6 +532,7 @@ rtc_static_library("webrtc_vp9") {
"../../media:rtc_vp9_profile",
"../../rtc_base:checks",
"../../rtc_base:rtc_base",
"../../rtc_base/experiments:rate_control_settings",
"../../system_wrappers",
"../../system_wrappers:field_trial",
"../rtp_rtcp:rtp_rtcp_format",

View File

@ -31,6 +31,7 @@
#include "modules/video_coding/utility/simulcast_utility.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/field_trial_parser.h"
#include "rtc_base/experiments/rate_control_settings.h"
#include "rtc_base/scoped_ref_ptr.h"
#include "rtc_base/trace_event.h"
#include "system_wrappers/include/field_trial.h"
@ -39,8 +40,6 @@
namespace webrtc {
namespace {
const char kVp8TrustedRateControllerFieldTrial[] =
"WebRTC-LibvpxVp8TrustedRateController";
#if defined(WEBRTC_IOS)
const char kVP8IosMaxNumberOfThreadFieldTrial[] =
"WebRTC-VP8IosMaxNumberOfThread";
@ -162,8 +161,8 @@ LibvpxVp8Encoder::LibvpxVp8Encoder()
LibvpxVp8Encoder::LibvpxVp8Encoder(std::unique_ptr<LibvpxInterface> interface)
: libvpx_(std::move(interface)),
experimental_cpu_speed_config_arm_(CpuSpeedExperiment::GetConfigs()),
trusted_rate_controller_(
field_trial::IsEnabled(kVp8TrustedRateControllerFieldTrial)),
trusted_rate_controller_(RateControlSettings::ParseFromFieldTrials()
.LibvpxVp8TrustedRateController()),
encoded_complete_callback_(nullptr),
inited_(false),
timestamp_(0),

View File

@ -30,6 +30,7 @@
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "modules/video_coding/codecs/vp9/svc_rate_allocator.h"
#include "rtc_base/checks.h"
#include "rtc_base/experiments/rate_control_settings.h"
#include "rtc_base/keep_ref_until_done.h"
#include "rtc_base/logging.h"
#include "rtc_base/time_utils.h"
@ -39,9 +40,6 @@
namespace webrtc {
namespace {
const char kVp9TrustedRateControllerFieldTrial[] =
"WebRTC-LibvpxVp9TrustedRateController";
// Maps from gof_idx to encoder internal reference frame buffer index. These
// maps work for 1,2 and 3 temporal layers with GOF length of 1,2 and 4 frames.
uint8_t kRefBufIdx[4] = {0, 0, 0, 1};
@ -170,8 +168,8 @@ VP9EncoderImpl::VP9EncoderImpl(const cricket::VideoCodec& codec)
is_svc_(false),
inter_layer_pred_(InterLayerPredMode::kOn),
external_ref_control_(false), // Set in InitEncode because of tests.
trusted_rate_controller_(
field_trial::IsEnabled(kVp9TrustedRateControllerFieldTrial)),
trusted_rate_controller_(RateControlSettings::ParseFromFieldTrials()
.LibvpxVp9TrustedRateController()),
full_superframe_drop_(true),
first_frame_in_picture_(true),
ss_info_needed_(false),

View File

@ -30,6 +30,11 @@ const char* kCongestionWindowPushbackFieldTrialName =
"WebRTC-CongestionWindowPushback";
const int kDefaultMinPushbackTargetBitrateBps = 30000;
const char kVp8TrustedRateControllerFieldTrialName[] =
"WebRTC-LibvpxVp8TrustedRateController";
const char kVp9TrustedRateControllerFieldTrialName[] =
"WebRTC-LibvpxVp9TrustedRateController";
absl::optional<int> MaybeReadCwndExperimentParameter(
const WebRtcKeyValueConfig* const key_value_config) {
int64_t accepted_queue_ms;
@ -64,6 +69,11 @@ absl::optional<int> MaybeReadCongestionWindowPushbackExperimentParameter(
return absl::nullopt;
}
bool IsEnabled(const WebRtcKeyValueConfig* const key_value_config,
absl::string_view key) {
return key_value_config->Lookup(key).find("Enabled") == 0;
}
} // namespace
RateControlSettings::RateControlSettings(
@ -75,9 +85,15 @@ RateControlSettings::RateControlSettings(
MaybeReadCongestionWindowPushbackExperimentParameter(
key_value_config)),
pacing_factor_("pacing_factor"),
alr_probing_("alr_probing", false) {
alr_probing_("alr_probing", false),
trust_vp8_(
"trust_vp8",
IsEnabled(key_value_config, kVp8TrustedRateControllerFieldTrialName)),
trust_vp9_("trust_vp9",
IsEnabled(key_value_config,
kVp9TrustedRateControllerFieldTrialName)) {
ParseFieldTrial({&congestion_window_, &congestion_window_pushback_,
&pacing_factor_, &alr_probing_},
&pacing_factor_, &alr_probing_, &trust_vp8_, &trust_vp9_},
key_value_config->Lookup("WebRTC-VideoRateControl"));
}
@ -122,4 +138,12 @@ bool RateControlSettings::UseAlrProbing() const {
return alr_probing_.Get();
}
bool RateControlSettings::LibvpxVp8TrustedRateController() const {
return trust_vp8_.Get();
}
bool RateControlSettings::LibvpxVp9TrustedRateController() const {
return trust_vp9_.Get();
}
} // namespace webrtc

View File

@ -38,6 +38,9 @@ class RateControlSettings final {
absl::optional<double> GetPacingFactor() const;
bool UseAlrProbing() const;
bool LibvpxVp8TrustedRateController() const;
bool LibvpxVp9TrustedRateController() const;
private:
explicit RateControlSettings(
const WebRtcKeyValueConfig* const key_value_config);
@ -46,6 +49,8 @@ class RateControlSettings final {
FieldTrialOptional<int> congestion_window_pushback_;
FieldTrialOptional<double> pacing_factor_;
FieldTrialParameter<bool> alr_probing_;
FieldTrialParameter<bool> trust_vp8_;
FieldTrialParameter<bool> trust_vp9_;
};
} // namespace webrtc