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}
diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc
index 0fb1bf0..d3cb227 100644
--- a/call/bitrate_allocator.cc
+++ b/call/bitrate_allocator.cc
@@ -55,6 +55,7 @@
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 @@
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 @@
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 @@
// 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();
}