Reset loss based BWE on route change.

The change is under field trial use_in_start_phase.

Bug: webrtc:12707
Change-Id: I2ba8245c5d126b3c8a2e54b826853d98aad6e4f9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/325184
Commit-Queue: Diep Bui <diepbp@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41047}
This commit is contained in:
Diep Bui 2023-10-30 13:55:26 +00:00 committed by WebRTC LUCI CQ
parent e920073a68
commit 9682f4be7d
4 changed files with 27 additions and 14 deletions

View File

@ -149,6 +149,10 @@ bool LossBasedBweV2::ReadyToUseInStartPhase() const {
return IsReady() && config_->use_in_start_phase;
}
bool LossBasedBweV2::UseInStartPhase() const {
return config_->use_in_start_phase;
}
LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult() const {
if (!IsReady()) {
if (!IsEnabled()) {

View File

@ -62,6 +62,9 @@ class LossBasedBweV2 {
// Returns true if loss based BWE is ready to be used in the start phase.
bool ReadyToUseInStartPhase() const;
// Returns true if loss based BWE can be used in the start phase.
bool UseInStartPhase() const;
// Returns `DataRate::PlusInfinity` if no BWE can be calculated.
Result GetLossBasedResult() const;

View File

@ -203,9 +203,9 @@ TimeDelta RttBasedBackoff::CorrectedRtt() const {
RttBasedBackoff::~RttBasedBackoff() = default;
SendSideBandwidthEstimation::SendSideBandwidthEstimation(
const FieldTrialsView* key_value_config,
RtcEventLog* event_log)
: rtt_backoff_(key_value_config),
const FieldTrialsView* key_value_config, RtcEventLog* event_log)
: key_value_config_(key_value_config),
rtt_backoff_(key_value_config),
lost_packets_since_last_loss_update_(0),
expected_packets_since_last_loss_update_(0),
current_target_(DataRate::Zero()),
@ -234,7 +234,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(
high_loss_threshold_(kDefaultHighLossThreshold),
bitrate_threshold_(kDefaultBitrateThreshold),
loss_based_bandwidth_estimator_v1_(key_value_config),
loss_based_bandwidth_estimator_v2_(key_value_config),
loss_based_bandwidth_estimator_v2_(new LossBasedBweV2(key_value_config)),
loss_based_state_(LossBasedState::kDelayBasedEstimate),
disable_receiver_limit_caps_only_("Disabled") {
RTC_DCHECK(event_log);
@ -252,7 +252,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation(
ParseFieldTrial({&disable_receiver_limit_caps_only_},
key_value_config->Lookup("WebRTC-Bwe-ReceiverLimitCapsOnly"));
if (LossBasedBandwidthEstimatorV2Enabled()) {
loss_based_bandwidth_estimator_v2_.SetMinMaxBitrate(
loss_based_bandwidth_estimator_v2_->SetMinMaxBitrate(
min_bitrate_configured_, max_bitrate_configured_);
}
}
@ -281,6 +281,10 @@ void SendSideBandwidthEstimation::OnRouteChange() {
uma_update_state_ = kNoUpdate;
uma_rtt_state_ = kNoUpdate;
last_rtc_event_log_ = Timestamp::MinusInfinity();
if (loss_based_bandwidth_estimator_v2_->UseInStartPhase()) {
loss_based_bandwidth_estimator_v2_.reset(
new LossBasedBweV2(key_value_config_));
}
}
void SendSideBandwidthEstimation::SetBitrates(
@ -315,8 +319,8 @@ void SendSideBandwidthEstimation::SetMinMaxBitrate(DataRate min_bitrate,
} else {
max_bitrate_configured_ = kDefaultMaxBitrate;
}
loss_based_bandwidth_estimator_v2_.SetMinMaxBitrate(min_bitrate_configured_,
max_bitrate_configured_);
loss_based_bandwidth_estimator_v2_->SetMinMaxBitrate(min_bitrate_configured_,
max_bitrate_configured_);
}
int SendSideBandwidthEstimation::GetMinBitrate() const {
@ -371,7 +375,7 @@ void SendSideBandwidthEstimation::SetAcknowledgedRate(
*acknowledged_rate, at_time);
}
if (LossBasedBandwidthEstimatorV2Enabled()) {
loss_based_bandwidth_estimator_v2_.SetAcknowledgedBitrate(
loss_based_bandwidth_estimator_v2_->SetAcknowledgedBitrate(
*acknowledged_rate);
}
}
@ -386,7 +390,7 @@ void SendSideBandwidthEstimation::UpdateLossBasedEstimator(
report.packet_feedbacks, report.feedback_time);
}
if (LossBasedBandwidthEstimatorV2Enabled()) {
loss_based_bandwidth_estimator_v2_.UpdateBandwidthEstimate(
loss_based_bandwidth_estimator_v2_->UpdateBandwidthEstimate(
report.packet_feedbacks, delay_based_limit_, in_alr);
UpdateEstimate(report.feedback_time);
}
@ -492,7 +496,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
// We trust the REMB and/or delay-based estimate during the first 2 seconds if
// we haven't had any packet loss reported, to allow startup bitrate probing.
if (last_fraction_loss_ == 0 && IsInStartPhase(at_time) &&
!loss_based_bandwidth_estimator_v2_.ReadyToUseInStartPhase()) {
!loss_based_bandwidth_estimator_v2_->ReadyToUseInStartPhase()) {
DataRate new_bitrate = current_target_;
// TODO(srte): We should not allow the new_bitrate to be larger than the
// receiver limit here.
@ -534,7 +538,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
if (LossBasedBandwidthEstimatorV2ReadyForUse()) {
LossBasedBweV2::Result result =
loss_based_bandwidth_estimator_v2_.GetLossBasedResult();
loss_based_bandwidth_estimator_v2_->GetLossBasedResult();
loss_based_state_ = result.state;
UpdateTargetBitrate(result.bandwidth_estimate, at_time);
return;
@ -690,13 +694,13 @@ bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV1ReadyForUse()
}
bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2Enabled() const {
return loss_based_bandwidth_estimator_v2_.IsEnabled();
return loss_based_bandwidth_estimator_v2_->IsEnabled();
}
bool SendSideBandwidthEstimation::LossBasedBandwidthEstimatorV2ReadyForUse()
const {
return LossBasedBandwidthEstimatorV2Enabled() &&
loss_based_bandwidth_estimator_v2_.IsReady();
loss_based_bandwidth_estimator_v2_->IsReady();
}
} // namespace webrtc

View File

@ -16,6 +16,7 @@
#include <stdint.h>
#include <deque>
#include <memory>
#include <utility>
#include <vector>
@ -167,6 +168,7 @@ class SendSideBandwidthEstimation {
bool LossBasedBandwidthEstimatorV1ReadyForUse() const;
bool LossBasedBandwidthEstimatorV2ReadyForUse() const;
const FieldTrialsView* key_value_config_;
RttBasedBackoff rtt_backoff_;
LinkCapacityTracker link_capacity_;
@ -208,7 +210,7 @@ class SendSideBandwidthEstimation {
float high_loss_threshold_;
DataRate bitrate_threshold_;
LossBasedBandwidthEstimation loss_based_bandwidth_estimator_v1_;
LossBasedBweV2 loss_based_bandwidth_estimator_v2_;
std::unique_ptr<LossBasedBweV2> loss_based_bandwidth_estimator_v2_;
LossBasedState loss_based_state_;
FieldTrialFlag disable_receiver_limit_caps_only_;
};