diff --git a/api/transport/network_control.h b/api/transport/network_control.h index 9086260427..e68e209cb8 100644 --- a/api/transport/network_control.h +++ b/api/transport/network_control.h @@ -23,6 +23,9 @@ class TargetTransferRateObserver { // Called to indicate target transfer rate as well as giving information about // the current estimate of network parameters. virtual void OnTargetTransferRate(TargetTransferRate) = 0; + // Called to provide updates to the expected target rate in case it changes + // before the first call to OnTargetTransferRate. + virtual void OnStartRateUpdate(DataRate) {} }; // Configuration sent to factory create function. The parameters here are diff --git a/call/bitrate_allocator.cc b/call/bitrate_allocator.cc index a8b600f59d..e23fa89db3 100644 --- a/call/bitrate_allocator.cc +++ b/call/bitrate_allocator.cc @@ -77,6 +77,11 @@ BitrateAllocator::~BitrateAllocator() { num_pause_events_); } +void BitrateAllocator::UpdateStartRate(uint32_t start_rate_bps) { + RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); + last_non_zero_bitrate_bps_ = start_rate_bps; +} + // static uint8_t BitrateAllocator::GetTransmissionMaxBitrateMultiplier() { uint64_t multiplier = strtoul(webrtc::field_trial::FindFullName( diff --git a/call/bitrate_allocator.h b/call/bitrate_allocator.h index 059f77b967..56d8bd566d 100644 --- a/call/bitrate_allocator.h +++ b/call/bitrate_allocator.h @@ -100,6 +100,8 @@ class BitrateAllocator : public BitrateAllocatorInterface { explicit BitrateAllocator(LimitObserver* limit_observer); ~BitrateAllocator() override; + void UpdateStartRate(uint32_t start_rate_bps); + // Allocate target_bitrate across the registered BitrateAllocatorObservers. void OnNetworkChanged(uint32_t target_bitrate_bps, uint32_t link_capacity_bps, diff --git a/call/call.cc b/call/call.cc index 95f64e9249..5811f5ccf4 100644 --- a/call/call.cc +++ b/call/call.cc @@ -215,6 +215,7 @@ class Call final : public webrtc::Call, // Implements TargetTransferRateObserver, void OnTargetTransferRate(TargetTransferRate msg) override; + void OnStartRateUpdate(DataRate start_rate) override; // Implements BitrateAllocator::LimitObserver. void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps, @@ -1091,6 +1092,15 @@ void Call::OnSentPacket(const rtc::SentPacket& sent_packet) { transport_send_ptr_->OnSentPacket(sent_packet); } +void Call::OnStartRateUpdate(DataRate start_rate) { + if (!transport_send_ptr_->GetWorkerQueue()->IsCurrent()) { + transport_send_ptr_->GetWorkerQueue()->PostTask( + [this, start_rate] { this->OnStartRateUpdate(start_rate); }); + return; + } + bitrate_allocator_->UpdateStartRate(start_rate.bps()); +} + void Call::OnTargetTransferRate(TargetTransferRate msg) { // TODO(bugs.webrtc.org/9719) // Call::OnTargetTransferRate requires that on target transfer rate is invoked diff --git a/call/rtp_transport_controller_send.cc b/call/rtp_transport_controller_send.cc index cb28ecaebf..fc3e5ce1e3 100644 --- a/call/rtp_transport_controller_send.cc +++ b/call/rtp_transport_controller_send.cc @@ -271,6 +271,7 @@ void RtpTransportControllerSend::RegisterTargetTransferRateObserver( RTC_DCHECK_RUN_ON(&task_queue_); RTC_DCHECK(observer_ == nullptr); observer_ = observer; + observer_->OnStartRateUpdate(*initial_config_.constraints.starting_rate); MaybeCreateControllers(); }); }