Using unit classes in BitrateAllocationUpdate struct.

This prepares for moving BitrateAllocationUpdate to API.

Bug: webrtc:9718
Change-Id: Ib2bcedb6b68fde33b6a2466f40829e86438aa973
Reviewed-on: https://webrtc-review.googlesource.com/c/111507
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25737}
This commit is contained in:
Sebastian Jansson
2018-11-21 19:13:07 +01:00
committed by Commit Bot
parent e4cccae299
commit 13e5903626
8 changed files with 65 additions and 45 deletions

View File

@ -55,6 +55,7 @@ BitrateAllocator::BitrateAllocator(LimitObserver* limit_observer)
last_non_zero_bitrate_bps_(kDefaultBitrateBps),
last_fraction_loss_(0),
last_rtt_(0),
last_bwe_period_ms_(1000),
num_pause_events_(0),
clock_(Clock::GetRealTimeClock()),
last_bwe_log_time_(0),
@ -115,10 +116,13 @@ void BitrateAllocator::OnNetworkChanged(uint32_t target_bitrate_bps,
for (auto& config : bitrate_observer_configs_) {
uint32_t allocated_bitrate = allocation[config.observer];
uint32_t allocated_bandwidth = bandwidth_allocation[config.observer];
uint32_t protection_bitrate =
config.observer->OnBitrateUpdated(BitrateAllocationUpdate{
allocated_bitrate, allocated_bandwidth, last_fraction_loss_,
last_rtt_, last_bwe_period_ms_});
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(allocated_bitrate);
update.link_capacity = DataRate::bps(allocated_bandwidth);
update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::ms(last_rtt_);
update.bwe_period = TimeDelta::ms(last_bwe_period_ms_);
uint32_t protection_bitrate = config.observer->OnBitrateUpdated(update);
if (allocated_bitrate == 0 && config.allocated_bitrate_bps > 0) {
if (target_bitrate_bps > 0)
@ -179,10 +183,13 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
for (auto& config : bitrate_observer_configs_) {
uint32_t allocated_bitrate = allocation[config.observer];
uint32_t bandwidth = bandwidth_allocation[config.observer];
uint32_t protection_bitrate =
config.observer->OnBitrateUpdated(BitrateAllocationUpdate{
allocated_bitrate, bandwidth, last_fraction_loss_, last_rtt_,
last_bwe_period_ms_});
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::bps(allocated_bitrate);
update.link_capacity = DataRate::bps(bandwidth);
update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::ms(last_rtt_);
update.bwe_period = TimeDelta::ms(last_bwe_period_ms_);
uint32_t protection_bitrate = config.observer->OnBitrateUpdated(update);
config.allocated_bitrate_bps = allocated_bitrate;
if (allocated_bitrate > 0)
config.media_ratio = MediaRatio(allocated_bitrate, protection_bitrate);
@ -191,8 +198,14 @@ void BitrateAllocator::AddObserver(BitrateAllocatorObserver* observer,
// Currently, an encoder is not allowed to produce frames.
// But we still have to return the initial config bitrate + let the
// observer know that it can not produce frames.
observer->OnBitrateUpdated(BitrateAllocationUpdate{
0, 0, last_fraction_loss_, last_rtt_, last_bwe_period_ms_});
BitrateAllocationUpdate update;
update.target_bitrate = DataRate::Zero();
update.link_capacity = DataRate::Zero();
update.packet_loss_ratio = last_fraction_loss_ / 256.0;
update.round_trip_time = TimeDelta::ms(last_rtt_);
update.bwe_period = TimeDelta::ms(last_bwe_period_ms_);
observer->OnBitrateUpdated(update);
}
UpdateAllocationLimits();
}