From ec6e550a8f1e473182935e188477c1f9068715d1 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Fri, 4 May 2018 17:07:16 +0200 Subject: [PATCH] Removes usage of uninitialized units in network control code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This removes places where the units types are implicitly left uninitialized in network_types.h and adds rtc::Optional where needed. Also removing the change indicator in the NetworkEstimate struct as it is not used in practice. Bug: webrtc:9155 Change-Id: I7e30e338effba96bd466ae91e380e6a8e90f66e1 Reviewed-on: https://webrtc-review.googlesource.com/73369 Commit-Queue: Sebastian Jansson Reviewed-by: Björn Terelius Cr-Commit-Position: refs/heads/master@{#23126} --- .../bbr/bbr_network_controller.cc | 15 +-- .../bbr/bbr_network_controller_unittest.cc | 4 +- .../goog_cc/goog_cc_network_control.cc | 31 +++---- .../goog_cc/goog_cc_network_control.h | 4 +- .../network_control/include/network_control.h | 2 +- .../network_control/include/network_types.h | 92 +++++++++---------- .../network_control/network_types.cc | 9 ++ .../test/network_control_tester.cc | 6 +- .../test/network_control_tester.h | 2 +- .../network_control/units/data_rate.h | 10 ++ .../rtp/pacer_controller.cc | 10 +- .../rtp/pacer_controller.h | 4 +- .../rtp/send_side_congestion_controller.cc | 27 +++--- 13 files changed, 110 insertions(+), 106 deletions(-) diff --git a/modules/congestion_controller/bbr/bbr_network_controller.cc b/modules/congestion_controller/bbr/bbr_network_controller.cc index 033b13a868..05bc049008 100644 --- a/modules/congestion_controller/bbr/bbr_network_controller.cc +++ b/modules/congestion_controller/bbr/bbr_network_controller.cc @@ -214,8 +214,10 @@ NetworkControlUpdate BbrNetworkController::CreateRateUpdate(Timestamp at_time) { target_rate = std::min(target_rate, pacing_rate); if (constraints_) { - target_rate = std::min(target_rate, constraints_->max_data_rate); - target_rate = std::max(target_rate, constraints_->min_data_rate); + if (constraints_->max_data_rate) + target_rate = std::min(target_rate, *constraints_->max_data_rate); + if (constraints_->min_data_rate) + target_rate = std::max(target_rate, *constraints_->min_data_rate); } bool probing_for_bandwidth = IsProbingForMoreBandwidth(); if (last_update_state_.mode == mode_ && @@ -260,9 +262,7 @@ NetworkControlUpdate BbrNetworkController::CreateRateUpdate(Timestamp at_time) { pacer_config.at_time = at_time; update.pacer_config = pacer_config; - CongestionWindow congestion_window; - congestion_window.data_window = GetCongestionWindow(); - update.congestion_window = congestion_window; + update.congestion_window = GetCongestionWindow(); return update; } @@ -277,8 +277,9 @@ NetworkControlUpdate BbrNetworkController::OnNetworkRouteChange( NetworkRouteChange msg) { constraints_ = msg.constraints; Reset(); - if (msg.starting_rate.IsFinite()) - default_bandwidth_ = msg.starting_rate; + if (msg.starting_rate) + default_bandwidth_ = *msg.starting_rate; + rtt_stats_.OnConnectionMigration(); return CreateRateUpdate(msg.at_time); } diff --git a/modules/congestion_controller/bbr/bbr_network_controller_unittest.cc b/modules/congestion_controller/bbr/bbr_network_controller_unittest.cc index df596eb67a..4ee63b6b27 100644 --- a/modules/congestion_controller/bbr/bbr_network_controller_unittest.cc +++ b/modules/congestion_controller/bbr/bbr_network_controller_unittest.cc @@ -92,9 +92,7 @@ TEST_F(BbrNetworkControllerTest, SendsConfigurationOnFirstProcess) { EXPECT_THAT(*update.target_rate, TargetRateCloseTo(kInitialBitrate)); EXPECT_THAT(*update.pacer_config, Property(&PacerConfig::data_rate, Ge(kInitialBitrate))); - EXPECT_THAT(*update.congestion_window, - Field(&CongestionWindow::data_window, - Property(&DataSize::IsFinite, true))); + EXPECT_THAT(*update.congestion_window, Property(&DataSize::IsFinite, true)); } TEST_F(BbrNetworkControllerTest, SendsConfigurationOnNetworkRouteChanged) { diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index 89aa88a976..04121b8514 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -117,6 +117,7 @@ GoogCcNetworkController::GoogCcNetworkController(RtcEventLog* event_log, pacing_factor_(kDefaultPaceMultiplier), min_pacing_rate_(DataRate::Zero()), max_padding_rate_(DataRate::Zero()), + max_total_allocated_bitrate_(DataRate::Zero()), in_cwnd_experiment_(CwndExperimentEnabled()), accepted_queue_ms_(kDefaultAcceptedQueueMs) { delay_based_bwe_->SetMinBitrate(congestion_controller::GetMinBitrateBps()); @@ -140,9 +141,9 @@ NetworkControlUpdate GoogCcNetworkController::OnNetworkAvailability( NetworkControlUpdate GoogCcNetworkController::OnNetworkRouteChange( NetworkRouteChange msg) { - int64_t min_bitrate_bps = msg.constraints.min_data_rate.bps_or(-1); - int64_t max_bitrate_bps = msg.constraints.max_data_rate.bps_or(-1); - int64_t start_bitrate_bps = msg.starting_rate.bps_or(-1); + int64_t min_bitrate_bps = GetBpsOrDefault(msg.constraints.min_data_rate, -1); + int64_t max_bitrate_bps = GetBpsOrDefault(msg.constraints.max_data_rate, -1); + int64_t start_bitrate_bps = GetBpsOrDefault(msg.starting_rate, -1); ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); @@ -234,17 +235,16 @@ NetworkControlUpdate GoogCcNetworkController::OnStreamsConfig( NetworkControlUpdate GoogCcNetworkController::OnTargetRateConstraints( TargetRateConstraints constraints) { - NetworkControlUpdate update; - UpdateBitrateConstraints(constraints, DataRate()); + UpdateBitrateConstraints(constraints, rtc::nullopt); return MaybeTriggerOnNetworkChanged(constraints.at_time); } void GoogCcNetworkController::UpdateBitrateConstraints( TargetRateConstraints constraints, - DataRate starting_rate) { - int64_t min_bitrate_bps = constraints.min_data_rate.bps_or(0); - int64_t max_bitrate_bps = constraints.max_data_rate.bps_or(-1); - int64_t start_bitrate_bps = starting_rate.bps_or(-1); + rtc::Optional starting_rate) { + int64_t min_bitrate_bps = GetBpsOrDefault(constraints.min_data_rate, 0); + int64_t max_bitrate_bps = GetBpsOrDefault(constraints.max_data_rate, -1); + int64_t start_bitrate_bps = GetBpsOrDefault(starting_rate, -1); ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); @@ -327,8 +327,7 @@ NetworkControlUpdate GoogCcNetworkController::OnTransportPacketsFeedback( return update; } -rtc::Optional -GoogCcNetworkController::MaybeUpdateCongestionWindow() { +rtc::Optional GoogCcNetworkController::MaybeUpdateCongestionWindow() { if (!in_cwnd_experiment_) return rtc::nullopt; // No valid RTT. Could be because send-side BWE isn't used, in which case @@ -340,12 +339,10 @@ GoogCcNetworkController::MaybeUpdateCongestionWindow() { TimeDelta time_window = TimeDelta::ms(*min_feedback_rtt_ms_ + accepted_queue_ms_); DataSize data_window = last_bandwidth_ * time_window; - CongestionWindow msg; - msg.enabled = true; - msg.data_window = std::max(kMinCwnd, data_window); + data_window = std::max(kMinCwnd, data_window); RTC_LOG(LS_INFO) << "Feedback rtt: " << *min_feedback_rtt_ms_ << " Bitrate: " << last_bandwidth_.bps(); - return msg; + return data_window; } NetworkControlUpdate GoogCcNetworkController::MaybeTriggerOnNetworkChanged( @@ -366,7 +363,6 @@ NetworkControlUpdate GoogCcNetworkController::MaybeTriggerOnNetworkChanged( new_estimate.bandwidth = DataRate::bps(estimated_bitrate_bps); new_estimate.loss_rate_ratio = fraction_loss / 255.0f; new_estimate.bwe_period = bwe_period; - new_estimate.changed = true; last_bandwidth_ = new_estimate.bandwidth; return OnNetworkEstimate(new_estimate); } @@ -405,9 +401,6 @@ bool GoogCcNetworkController::GetNetworkParameters( NetworkControlUpdate GoogCcNetworkController::OnNetworkEstimate( NetworkEstimate estimate) { NetworkControlUpdate update; - if (!estimate.changed) - return update; - update.pacer_config = UpdatePacingRates(estimate.at_time); alr_detector_->SetEstimatedBitrate(estimate.bandwidth.bps()); probe_controller_->SetEstimatedBitrate(estimate.bandwidth.bps(), diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.h b/modules/congestion_controller/goog_cc/goog_cc_network_control.h index ab13d2080e..498edc359b 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -51,8 +51,8 @@ class GoogCcNetworkController : public NetworkControllerInterface { private: void UpdateBitrateConstraints(TargetRateConstraints constraints, - DataRate starting_rate); - rtc::Optional MaybeUpdateCongestionWindow(); + rtc::Optional starting_rate); + rtc::Optional MaybeUpdateCongestionWindow(); NetworkControlUpdate MaybeTriggerOnNetworkChanged(Timestamp at_time); bool GetNetworkParameters(int32_t* estimated_bitrate_bps, uint8_t* fraction_loss, diff --git a/modules/congestion_controller/network_control/include/network_control.h b/modules/congestion_controller/network_control/include/network_control.h index cf598c3d0e..8a54706ced 100644 --- a/modules/congestion_controller/network_control/include/network_control.h +++ b/modules/congestion_controller/network_control/include/network_control.h @@ -37,7 +37,7 @@ struct NetworkControllerConfig { // The initial bandwidth estimate to base target rate on. This should be used // as the basis for initial OnTargetTransferRate and OnPacerConfig callbacks. // Note that starting rate is only provided on construction. - DataRate starting_bandwidth; + DataRate starting_bandwidth = DataRate::Infinity(); }; // NetworkControllerInterface is implemented by network controllers. A network diff --git a/modules/congestion_controller/network_control/include/network_types.h b/modules/congestion_controller/network_control/include/network_types.h index 84698982b2..59e9d5f8a9 100644 --- a/modules/congestion_controller/network_control/include/network_types.h +++ b/modules/congestion_controller/network_control/include/network_types.h @@ -32,7 +32,7 @@ struct StreamsConfig { StreamsConfig(); StreamsConfig(const StreamsConfig&); ~StreamsConfig(); - Timestamp at_time; + Timestamp at_time = Timestamp::Infinity(); bool requests_alr_probing = false; rtc::Optional pacing_factor; rtc::Optional min_pacing_rate; @@ -41,62 +41,59 @@ struct StreamsConfig { }; struct TargetRateConstraints { - Timestamp at_time; - DataRate min_data_rate; - DataRate max_data_rate; + TargetRateConstraints(); + TargetRateConstraints(const TargetRateConstraints&); + ~TargetRateConstraints(); + Timestamp at_time = Timestamp::Infinity(); + rtc::Optional min_data_rate; + rtc::Optional max_data_rate; }; // Send side information struct NetworkAvailability { - Timestamp at_time; + Timestamp at_time = Timestamp::Infinity(); bool network_available = false; }; struct NetworkRouteChange { - Timestamp at_time; + NetworkRouteChange(); + NetworkRouteChange(const NetworkRouteChange&); + ~NetworkRouteChange(); + Timestamp at_time = Timestamp::Infinity(); // The TargetRateConstraints are set here so they can be changed synchronously // when network route changes. TargetRateConstraints constraints; - DataRate starting_rate; + rtc::Optional starting_rate; }; struct SentPacket { - Timestamp send_time; - DataSize size; + Timestamp send_time = Timestamp::Infinity(); + DataSize size = DataSize::Zero(); PacedPacketInfo pacing_info; }; -struct PacerQueueUpdate { - Timestamp at_time; - TimeDelta expected_queue_time; -}; - // Transport level feedback struct RemoteBitrateReport { - Timestamp receive_time; - DataRate bandwidth; + Timestamp receive_time = Timestamp::Infinity(); + DataRate bandwidth = DataRate::Infinity(); }; struct RoundTripTimeUpdate { - Timestamp receive_time; - TimeDelta round_trip_time; + Timestamp receive_time = Timestamp::Infinity(); + TimeDelta round_trip_time = TimeDelta::PlusInfinity(); bool smoothed = false; }; struct TransportLossReport { - Timestamp receive_time; - Timestamp start_time; - Timestamp end_time; + Timestamp receive_time = Timestamp::Infinity(); + Timestamp start_time = Timestamp::Infinity(); + Timestamp end_time = Timestamp::Infinity(); uint64_t packets_lost_delta = 0; uint64_t packets_received_delta = 0; }; -struct OutstandingData { - DataSize in_flight_data; -}; - // Packet level feedback struct PacketResult { @@ -105,7 +102,7 @@ struct PacketResult { ~PacketResult(); rtc::Optional sent_packet; - Timestamp receive_time; + Timestamp receive_time = Timestamp::Infinity(); }; struct TransportPacketsFeedback { @@ -113,9 +110,9 @@ struct TransportPacketsFeedback { TransportPacketsFeedback(const TransportPacketsFeedback& other); ~TransportPacketsFeedback(); - Timestamp feedback_time; - DataSize data_in_flight; - DataSize prior_in_flight; + Timestamp feedback_time = Timestamp::Infinity(); + DataSize data_in_flight = DataSize::Zero(); + DataSize prior_in_flight = DataSize::Zero(); std::vector packet_feedbacks; std::vector ReceivedWithSendInfo() const; @@ -126,44 +123,39 @@ struct TransportPacketsFeedback { // Network estimation struct NetworkEstimate { - Timestamp at_time; - DataRate bandwidth; - TimeDelta round_trip_time; - TimeDelta bwe_period; + Timestamp at_time = Timestamp::Infinity(); + DataRate bandwidth = DataRate::Infinity(); + TimeDelta round_trip_time = TimeDelta::PlusInfinity(); + TimeDelta bwe_period = TimeDelta::PlusInfinity(); float loss_rate_ratio = 0; - bool changed = true; }; // Network control -struct CongestionWindow { - bool enabled = true; - DataSize data_window; -}; struct PacerConfig { - Timestamp at_time; + Timestamp at_time = Timestamp::Infinity(); // Pacer should send at most data_window data over time_window duration. - DataSize data_window; - TimeDelta time_window; + DataSize data_window = DataSize::Infinity(); + TimeDelta time_window = TimeDelta::PlusInfinity(); // Pacer should send at least pad_window data over time_window duration. - DataSize pad_window; + DataSize pad_window = DataSize::Zero(); DataRate data_rate() const { return data_window / time_window; } DataRate pad_rate() const { return pad_window / time_window; } }; struct ProbeClusterConfig { - Timestamp at_time; - DataRate target_data_rate; - TimeDelta target_duration; - uint32_t target_probe_count; + Timestamp at_time = Timestamp::Infinity(); + DataRate target_data_rate = DataRate::Zero(); + TimeDelta target_duration = TimeDelta::Zero(); + int32_t target_probe_count = 0; }; struct TargetTransferRate { - Timestamp at_time; - DataRate target_rate; + Timestamp at_time = Timestamp::Infinity(); // The estimate on which the target rate is based on. NetworkEstimate network_estimate; + DataRate target_rate = DataRate::Zero(); }; // Contains updates of network controller comand state. Using optionals to @@ -173,7 +165,7 @@ struct NetworkControlUpdate { NetworkControlUpdate(); NetworkControlUpdate(const NetworkControlUpdate&); ~NetworkControlUpdate(); - rtc::Optional congestion_window; + rtc::Optional congestion_window; rtc::Optional pacer_config; std::vector probe_cluster_configs; rtc::Optional target_rate; @@ -181,7 +173,7 @@ struct NetworkControlUpdate { // Process control struct ProcessInterval { - Timestamp at_time; + Timestamp at_time = Timestamp::Infinity(); }; } // namespace webrtc diff --git a/modules/congestion_controller/network_control/network_types.cc b/modules/congestion_controller/network_control/network_types.cc index a786f613dc..f354bf321e 100644 --- a/modules/congestion_controller/network_control/network_types.cc +++ b/modules/congestion_controller/network_control/network_types.cc @@ -16,6 +16,15 @@ StreamsConfig::StreamsConfig() = default; StreamsConfig::StreamsConfig(const StreamsConfig&) = default; StreamsConfig::~StreamsConfig() = default; +TargetRateConstraints::TargetRateConstraints() = default; +TargetRateConstraints::TargetRateConstraints(const TargetRateConstraints&) = + default; +TargetRateConstraints::~TargetRateConstraints() = default; + +NetworkRouteChange::NetworkRouteChange() = default; +NetworkRouteChange::NetworkRouteChange(const NetworkRouteChange&) = default; +NetworkRouteChange::~NetworkRouteChange() = default; + PacketResult::PacketResult() = default; PacketResult::PacketResult(const PacketResult& other) = default; PacketResult::~PacketResult() = default; diff --git a/modules/congestion_controller/network_control/test/network_control_tester.cc b/modules/congestion_controller/network_control/test/network_control_tester.cc index d6cce8876f..29b6211808 100644 --- a/modules/congestion_controller/network_control/test/network_control_tester.cc +++ b/modules/congestion_controller/network_control/test/network_control_tester.cc @@ -21,7 +21,7 @@ namespace { void Update(NetworkControlUpdate* target, const NetworkControlUpdate& update) { if (update.congestion_window) { RTC_LOG(LS_INFO) << "Received window=" - << ToString(update.congestion_window->data_window) << "\n"; + << ToString(*update.congestion_window) << "\n"; target->congestion_window = update.congestion_window; } if (update.pacer_config) { @@ -98,11 +98,11 @@ void NetworkControllerTester::RunSimulation(TimeDelta duration, Timestamp last_process_time = current_time_; while (current_time_ - start_time < duration) { bool send_packet = true; - if (state_.congestion_window && state_.congestion_window->enabled) { + if (state_.congestion_window && state_.congestion_window->IsFinite()) { DataSize data_in_flight = DataSize::Zero(); for (PacketResult& packet : outstanding_packets_) data_in_flight += packet.sent_packet->size; - if (data_in_flight > state_.congestion_window->data_window) + if (data_in_flight > *state_.congestion_window) send_packet = false; } diff --git a/modules/congestion_controller/network_control/test/network_control_tester.h b/modules/congestion_controller/network_control/test/network_control_tester.h index 857e0c5d8f..f91f016bfd 100644 --- a/modules/congestion_controller/network_control/test/network_control_tester.h +++ b/modules/congestion_controller/network_control/test/network_control_tester.h @@ -64,7 +64,7 @@ class NetworkControllerTester { TimeDelta propagation_delay, DataRate actual_bandwidth); std::unique_ptr controller_; - TimeDelta process_interval_; + TimeDelta process_interval_ = TimeDelta::PlusInfinity(); Timestamp current_time_; TimeDelta accumulated_delay_; std::deque outstanding_packets_; diff --git a/modules/congestion_controller/network_control/units/data_rate.h b/modules/congestion_controller/network_control/units/data_rate.h index e3834944d4..5bc66e10ef 100644 --- a/modules/congestion_controller/network_control/units/data_rate.h +++ b/modules/congestion_controller/network_control/units/data_rate.h @@ -16,6 +16,7 @@ #include #include +#include "api/optional.h" #include "rtc_base/checks.h" #include "modules/congestion_controller/network_control/units/data_size.h" @@ -134,6 +135,15 @@ inline DataSize operator*(const TimeDelta& duration, const DataRate& rate) { return rate * duration; } +inline int64_t GetBpsOrDefault(const rtc::Optional& rate, + int64_t fallback_bps) { + if (rate && rate->IsFinite()) { + return rate->bps(); + } else { + return fallback_bps; + } +} + std::string ToString(const DataRate& value); } // namespace webrtc diff --git a/modules/congestion_controller/rtp/pacer_controller.cc b/modules/congestion_controller/rtp/pacer_controller.cc index 446ed9769b..6444ea5960 100644 --- a/modules/congestion_controller/rtp/pacer_controller.cc +++ b/modules/congestion_controller/rtp/pacer_controller.cc @@ -22,10 +22,10 @@ PacerController::PacerController(PacedSender* pacer) : pacer_(pacer) { PacerController::~PacerController() = default; -void PacerController::OnCongestionWindow(CongestionWindow congestion_window) { +void PacerController::OnCongestionWindow(DataSize congestion_window) { RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); - if (congestion_window.enabled) - pacer_->SetCongestionWindow(congestion_window.data_window.bytes()); + if (congestion_window.IsFinite()) + pacer_->SetCongestionWindow(congestion_window.bytes()); else pacer_->SetCongestionWindow(PacedSender::kNoCongestionWindow); } @@ -55,9 +55,9 @@ void PacerController::OnProbeClusterConfig(ProbeClusterConfig config) { pacer_->CreateProbeCluster(bitrate_bps); } -void PacerController::OnOutstandingData(OutstandingData msg) { +void PacerController::OnOutstandingData(DataSize in_flight_data) { RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); - pacer_->UpdateOutstandingData(msg.in_flight_data.bytes()); + pacer_->UpdateOutstandingData(in_flight_data.bytes()); } void PacerController::SetPacerState(bool paused) { diff --git a/modules/congestion_controller/rtp/pacer_controller.h b/modules/congestion_controller/rtp/pacer_controller.h index 6aa029ca71..278fa613dc 100644 --- a/modules/congestion_controller/rtp/pacer_controller.h +++ b/modules/congestion_controller/rtp/pacer_controller.h @@ -30,10 +30,10 @@ class PacerController { public: explicit PacerController(PacedSender* pacer); ~PacerController(); - void OnCongestionWindow(CongestionWindow msg); + void OnCongestionWindow(DataSize msg); void OnNetworkAvailability(NetworkAvailability msg); void OnNetworkRouteChange(NetworkRouteChange msg); - void OnOutstandingData(OutstandingData msg); + void OnOutstandingData(DataSize in_flight_data); void OnPacerConfig(PacerConfig msg); void OnProbeClusterConfig(ProbeClusterConfig msg); diff --git a/modules/congestion_controller/rtp/send_side_congestion_controller.cc b/modules/congestion_controller/rtp/send_side_congestion_controller.cc index 7a905d1bd9..38d23f84b4 100644 --- a/modules/congestion_controller/rtp/send_side_congestion_controller.cc +++ b/modules/congestion_controller/rtp/send_side_congestion_controller.cc @@ -166,7 +166,7 @@ class ControlHandler { void PostUpdates(NetworkControlUpdate update); void OnNetworkAvailability(NetworkAvailability msg); - void OnPacerQueueUpdate(PacerQueueUpdate msg); + void OnPacerQueueUpdate(TimeDelta expected_queue_time); rtc::Optional last_transfer_rate(); @@ -227,9 +227,9 @@ void ControlHandler::OnNetworkAvailability(NetworkAvailability msg) { OnNetworkInvalidation(); } -void ControlHandler::OnPacerQueueUpdate(PacerQueueUpdate msg) { +void ControlHandler::OnPacerQueueUpdate(TimeDelta expected_queue_time) { RTC_DCHECK_CALLED_SEQUENTIALLY(&sequenced_checker_); - pacer_expected_queue_ms_ = msg.expected_queue_time.ms(); + pacer_expected_queue_ms_ = expected_queue_time.ms(); OnNetworkInvalidation(); } @@ -318,6 +318,7 @@ SendSideCongestionController::SendSideCongestionController( rtc::MakeUnique(event_log)), pacer_controller_(MakeUnique(pacer_)), process_interval_(controller_factory_fallback_->GetProcessInterval()), + last_report_block_time_(Timestamp::ms(clock_->TimeInMilliseconds())), observer_(nullptr), send_side_bwe_with_overhead_( webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), @@ -456,14 +457,15 @@ void SendSideCongestionController::OnNetworkRouteChanged( msg.at_time = Timestamp::ms(clock_->TimeInMilliseconds()); msg.constraints = ConvertConstraints(min_bitrate_bps, max_bitrate_bps, clock_); - msg.starting_rate = - start_bitrate_bps > 0 ? DataRate::bps(start_bitrate_bps) : DataRate(); + if (start_bitrate_bps > 0) + msg.starting_rate = DataRate::bps(start_bitrate_bps); task_queue_->PostTask([this, msg]() { RTC_DCHECK_RUN_ON(task_queue_ptr_); if (controller_) { control_handler_->PostUpdates(controller_->OnNetworkRouteChange(msg)); } else { - initial_config_.starting_bandwidth = msg.starting_rate; + if (msg.starting_rate) + initial_config_.starting_bandwidth = *msg.starting_rate; initial_config_.constraints = msg.constraints; } pacer_controller_->OnNetworkRouteChange(msg); @@ -626,9 +628,9 @@ void SendSideCongestionController::UpdateControllerWithTimeInterval() { void SendSideCongestionController::UpdatePacerQueue() { if (control_handler_) { - PacerQueueUpdate msg; - msg.expected_queue_time = TimeDelta::ms(pacer_->ExpectedQueueTimeMs()); - control_handler_->OnPacerQueueUpdate(msg); + TimeDelta expected_queue_time = + TimeDelta::ms(pacer_->ExpectedQueueTimeMs()); + control_handler_->OnPacerQueueUpdate(expected_queue_time); } } @@ -675,12 +677,11 @@ void SendSideCongestionController::OnTransportFeedback( } void SendSideCongestionController::MaybeUpdateOutstandingData() { - OutstandingData msg; - msg.in_flight_data = + DataSize in_flight_data = DataSize::bytes(transport_feedback_adapter_.GetOutstandingBytes()); - task_queue_->PostTask([this, msg]() { + task_queue_->PostTask([this, in_flight_data]() { RTC_DCHECK_RUN_ON(task_queue_ptr_); - pacer_controller_->OnOutstandingData(msg); + pacer_controller_->OnOutstandingData(in_flight_data); }); }