diff --git a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc index a7e9ce1712..f29fee92f4 100644 --- a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc +++ b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.cc @@ -68,6 +68,10 @@ absl::optional AcknowledgedBitrateEstimator::bitrate_bps() const { } } +absl::optional AcknowledgedBitrateEstimator::PeekBps() const { + return bitrate_estimator_->PeekBps(); +} + void AcknowledgedBitrateEstimator::SetAlrEndedTimeMs( int64_t alr_ended_time_ms) { alr_ended_time_ms_.emplace(alr_ended_time_ms); diff --git a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h index 31e44102a4..15ee370395 100644 --- a/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h +++ b/modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h @@ -32,6 +32,7 @@ class AcknowledgedBitrateEstimator { void IncomingPacketFeedbackVector( const std::vector& packet_feedback_vector); absl::optional bitrate_bps() const; + absl::optional PeekBps() const; void SetAlrEndedTimeMs(int64_t alr_ended_time_ms); void SetAllocatedBitrateWithoutFeedback(uint32_t bitrate_bps); diff --git a/modules/congestion_controller/goog_cc/bitrate_estimator.cc b/modules/congestion_controller/goog_cc/bitrate_estimator.cc index 985107496a..0a40392742 100644 --- a/modules/congestion_controller/goog_cc/bitrate_estimator.cc +++ b/modules/congestion_controller/goog_cc/bitrate_estimator.cc @@ -132,6 +132,12 @@ absl::optional BitrateEstimator::bitrate_bps() const { return bitrate_estimate_ * 1000; } +absl::optional BitrateEstimator::PeekBps() const { + if (current_window_ms_ > 0) + return sum_ * 8000 / current_window_ms_; + return absl::nullopt; +} + void BitrateEstimator::ExpectFastRateChange() { // By setting the bitrate-estimate variance to a higher value we allow the // bitrate to change fast for the next few samples. diff --git a/modules/congestion_controller/goog_cc/bitrate_estimator.h b/modules/congestion_controller/goog_cc/bitrate_estimator.h index dd1e51bc28..d3df2b5104 100644 --- a/modules/congestion_controller/goog_cc/bitrate_estimator.h +++ b/modules/congestion_controller/goog_cc/bitrate_estimator.h @@ -29,6 +29,7 @@ class BitrateEstimator { virtual void Update(int64_t now_ms, int bytes); virtual absl::optional bitrate_bps() const; + absl::optional PeekBps() const; virtual void ExpectFastRateChange(); 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 2a9723e2a9..00880180a6 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -132,8 +132,8 @@ GoogCcNetworkController::GoogCcNetworkController(RtcEventLog* event_log, bool feedback_only) : event_log_(event_log), packet_feedback_only_(feedback_only), - safe_reset_on_route_change_( - field_trial::IsEnabled("WebRTC-Bwe-SafeResetOnRouteChange")), + safe_reset_on_route_change_("Enabled"), + safe_reset_acknowledged_rate_("ack"), probe_controller_(new ProbeController()), congestion_window_pushback_controller_( MaybeInitalizeCongestionWindowPushbackController()), @@ -155,6 +155,10 @@ GoogCcNetworkController::GoogCcNetworkController(RtcEventLog* event_log, in_cwnd_experiment_(CwndExperimentEnabled()), accepted_queue_ms_(kDefaultAcceptedQueueMs) { RTC_DCHECK(config.constraints.at_time.IsFinite()); + ParseFieldTrial( + {&safe_reset_on_route_change_, &safe_reset_acknowledged_rate_}, + field_trial::FindFullName("WebRTC-Bwe-SafeResetOnRouteChange")); + delay_based_bwe_->SetMinBitrate(congestion_controller::GetMinBitrateBps()); if (in_cwnd_experiment_ && !ReadCwndExperimentParameter(&accepted_queue_ms_)) { @@ -183,14 +187,22 @@ NetworkControlUpdate GoogCcNetworkController::OnNetworkRouteChange( ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); if (safe_reset_on_route_change_) { - int32_t estimated_bitrate_bps; - uint8_t fraction_loss; - int64_t rtt_ms; - bandwidth_estimation_->CurrentEstimate(&estimated_bitrate_bps, - &fraction_loss, &rtt_ms); - if (!msg.constraints.starting_rate || - estimated_bitrate_bps <= start_bitrate_bps) { - start_bitrate_bps = estimated_bitrate_bps; + absl::optional estimated_bitrate_bps; + if (safe_reset_acknowledged_rate_) { + estimated_bitrate_bps = acknowledged_bitrate_estimator_->bitrate_bps(); + if (!estimated_bitrate_bps) + estimated_bitrate_bps = acknowledged_bitrate_estimator_->PeekBps(); + } else { + int32_t target_bitrate_bps; + uint8_t fraction_loss; + int64_t rtt_ms; + bandwidth_estimation_->CurrentEstimate(&target_bitrate_bps, + &fraction_loss, &rtt_ms); + estimated_bitrate_bps = target_bitrate_bps; + } + if (estimated_bitrate_bps && (!msg.constraints.starting_rate || + estimated_bitrate_bps < start_bitrate_bps)) { + start_bitrate_bps = *estimated_bitrate_bps; if (msg.constraints.starting_rate) { msg.constraints.starting_rate = DataRate::bps(start_bitrate_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 1ec073ff90..60a75ad8e4 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.h +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.h @@ -64,7 +64,8 @@ class GoogCcNetworkController : public NetworkControllerInterface { RtcEventLog* const event_log_; const bool packet_feedback_only_; - const bool safe_reset_on_route_change_; + FieldTrialFlag safe_reset_on_route_change_; + FieldTrialFlag safe_reset_acknowledged_rate_; const std::unique_ptr probe_controller_; const std::unique_ptr