Move simulcast hysteresis factor parsing to RateControlSettings

Bug: webrtc:10223
Change-Id: I962ca959afbcd8c27a0f79533c6e3c97369c697e
Reviewed-on: https://webrtc-review.googlesource.com/c/119262
Commit-Queue: Erik Språng <sprang@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26374}
This commit is contained in:
Erik Språng
2019-01-23 16:53:18 +01:00
committed by Commit Bot
parent 83d5e86163
commit 2c58ba1f24
4 changed files with 55 additions and 32 deletions

View File

@ -20,6 +20,7 @@
#include "common_types.h" // NOLINT(build/include)
#include "rtc_base/checks.h"
#include "rtc_base/experiments/rate_control_settings.h"
#include "system_wrappers/include/field_trial.h"
namespace webrtc {
@ -40,33 +41,6 @@ static const float kBaseHeavy3TlRateAllocation[kMaxTemporalStreams] = {
const uint32_t kLegacyScreenshareTl0BitrateKbps = 200;
const uint32_t kLegacyScreenshareTl1BitrateKbps = 1000;
double GetHysteresisFactor(const VideoCodec& codec) {
double factor = 1.0;
std::string field_trial_name;
switch (codec.mode) {
case VideoCodecMode::kRealtimeVideo:
field_trial_name = "WebRTC-SimulcastUpswitchHysteresisPercent";
// Default to no hysteresis for simulcast video.
factor = 1.0;
break;
case VideoCodecMode::kScreensharing:
field_trial_name = "WebRTC-SimulcastScreenshareUpswitchHysteresisPercent";
// Default to 35% hysteresis for simulcast screenshare.
factor = 1.35;
break;
}
std::string group_name = webrtc::field_trial::FindFullName(field_trial_name);
int percent = 0;
if (!group_name.empty() && sscanf(group_name.c_str(), "%d", &percent) == 1 &&
percent >= 0) {
factor = 1.0 + (percent / 100.0);
}
return factor;
}
} // namespace
float SimulcastRateAllocator::GetTemporalRateAllocation(int num_layers,
@ -83,7 +57,12 @@ float SimulcastRateAllocator::GetTemporalRateAllocation(int num_layers,
}
SimulcastRateAllocator::SimulcastRateAllocator(const VideoCodec& codec)
: codec_(codec), hysteresis_factor_(GetHysteresisFactor(codec)) {}
: codec_(codec),
hysteresis_factor_(codec.mode == VideoCodecMode::kScreensharing
? RateControlSettings::ParseFromFieldTrials()
.GetSimulcastScreenshareHysteresisFactor()
: RateControlSettings::ParseFromFieldTrials()
.GetSimulcastVideoHysteresisFactor()) {}
SimulcastRateAllocator::~SimulcastRateAllocator() = default;