Clean up loss based bwe v2: store delay based estimate locally.

This is to avoid passing delay based estimate value twice from send side  bwe.

Bug: webrtc:12707
Change-Id: Idc77cf7c2f4ecc60ae1dcfead325320532e7a7ca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282864
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Commit-Queue: Diep Bui <diepbp@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38600}
This commit is contained in:
Diep Bui 2022-11-09 16:09:11 +00:00 committed by WebRTC LUCI CQ
parent 0dbee62eb9
commit 3d7771cc08
4 changed files with 122 additions and 187 deletions

View file

@ -138,8 +138,7 @@ bool LossBasedBweV2::IsReady() const {
num_observations_ > 0;
}
LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult(
DataRate delay_based_limit) const {
LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult() const {
Result result;
result.state = current_state_;
if (!IsReady()) {
@ -156,16 +155,16 @@ LossBasedBweV2::Result LossBasedBweV2::GetLossBasedResult(
"statistics before it can be used.";
}
}
result.bandwidth_estimate = IsValid(delay_based_limit)
? delay_based_limit
result.bandwidth_estimate = IsValid(delay_based_estimate_)
? delay_based_estimate_
: DataRate::PlusInfinity();
return result;
}
if (IsValid(delay_based_limit)) {
if (IsValid(delay_based_estimate_)) {
result.bandwidth_estimate =
std::min({current_estimate_.loss_limited_bandwidth,
GetInstantUpperBound(), delay_based_limit});
GetInstantUpperBound(), delay_based_estimate_});
} else {
result.bandwidth_estimate = std::min(
current_estimate_.loss_limited_bandwidth, GetInstantUpperBound());
@ -221,6 +220,7 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
DataRate delay_based_estimate,
BandwidthUsage delay_detector_state,
absl::optional<DataRate> probe_bitrate) {
delay_based_estimate_ = delay_based_estimate;
if (!IsEnabled()) {
RTC_LOG(LS_WARNING)
<< "The estimator must be enabled before it can be used.";
@ -245,7 +245,7 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
ChannelParameters best_candidate = current_estimate_;
double objective_max = std::numeric_limits<double>::lowest();
for (ChannelParameters candidate : GetCandidates(delay_based_estimate)) {
for (ChannelParameters candidate : GetCandidates()) {
NewtonsMethodUpdate(candidate);
const double candidate_objective = GetObjective(candidate);
@ -309,11 +309,11 @@ void LossBasedBweV2::UpdateBandwidthEstimate(
if (IsEstimateIncreasingWhenLossLimited(best_candidate)) {
current_state_ = LossBasedState::kIncreasing;
} else if (IsValid(delay_based_estimate) &&
best_candidate.loss_limited_bandwidth < delay_based_estimate) {
} else if (IsValid(delay_based_estimate_) &&
best_candidate.loss_limited_bandwidth < delay_based_estimate_) {
current_state_ = LossBasedState::kDecreasing;
} else if (IsValid(delay_based_estimate) &&
best_candidate.loss_limited_bandwidth == delay_based_estimate) {
} else if (IsValid(delay_based_estimate_) &&
best_candidate.loss_limited_bandwidth == delay_based_estimate_) {
current_state_ = LossBasedState::kDelayBasedEstimate;
}
current_estimate_ = best_candidate;
@ -716,8 +716,7 @@ double LossBasedBweV2::GetAverageReportedLossRatio() const {
return num_lost_packets / num_packets;
}
DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound(
DataRate delay_based_estimate) const {
DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound() const {
DataRate candidate_bandwidth_upper_bound = max_bitrate_;
if (IsBandwidthLimitedDueToLoss() &&
IsValid(bandwidth_limit_in_current_window_)) {
@ -727,9 +726,9 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound(
if (config_->trendline_integration_enabled) {
candidate_bandwidth_upper_bound =
std::min(GetInstantUpperBound(), candidate_bandwidth_upper_bound);
if (IsValid(delay_based_estimate)) {
if (IsValid(delay_based_estimate_)) {
candidate_bandwidth_upper_bound =
std::min(delay_based_estimate, candidate_bandwidth_upper_bound);
std::min(delay_based_estimate_, candidate_bandwidth_upper_bound);
}
}
@ -751,8 +750,8 @@ DataRate LossBasedBweV2::GetCandidateBandwidthUpperBound(
return candidate_bandwidth_upper_bound;
}
std::vector<LossBasedBweV2::ChannelParameters> LossBasedBweV2::GetCandidates(
DataRate delay_based_estimate) const {
std::vector<LossBasedBweV2::ChannelParameters> LossBasedBweV2::GetCandidates()
const {
std::vector<DataRate> bandwidths;
bool can_increase_bitrate = TrendlineEsimateAllowBitrateIncrease();
for (double candidate_factor : config_->candidate_factors) {
@ -770,16 +769,16 @@ std::vector<LossBasedBweV2::ChannelParameters> LossBasedBweV2::GetCandidates(
config_->bandwidth_backoff_lower_bound_factor);
}
if (IsValid(delay_based_estimate) &&
if (IsValid(delay_based_estimate_) &&
config_->append_delay_based_estimate_candidate) {
if (can_increase_bitrate &&
delay_based_estimate > current_estimate_.loss_limited_bandwidth) {
bandwidths.push_back(delay_based_estimate);
delay_based_estimate_ > current_estimate_.loss_limited_bandwidth) {
bandwidths.push_back(delay_based_estimate_);
}
}
const DataRate candidate_bandwidth_upper_bound =
GetCandidateBandwidthUpperBound(delay_based_estimate);
GetCandidateBandwidthUpperBound();
std::vector<ChannelParameters> candidates;
candidates.resize(bandwidths.size());

View file

@ -57,7 +57,7 @@ class LossBasedBweV2 {
bool IsReady() const;
// Returns `DataRate::PlusInfinity` if no BWE can be calculated.
Result GetLossBasedResult(DataRate delay_based_limit) const;
Result GetLossBasedResult() const;
void SetAcknowledgedBitrate(DataRate acknowledged_bitrate);
void SetBandwidthEstimate(DataRate bandwidth_estimate);
@ -139,9 +139,8 @@ class LossBasedBweV2 {
// Returns `0.0` if not enough loss statistics have been received.
double GetAverageReportedLossRatio() const;
std::vector<ChannelParameters> GetCandidates(
DataRate delay_based_estimate) const;
DataRate GetCandidateBandwidthUpperBound(DataRate delay_based_estimate) const;
std::vector<ChannelParameters> GetCandidates() const;
DataRate GetCandidateBandwidthUpperBound() const;
Derivatives GetDerivatives(const ChannelParameters& channel_parameters) const;
double GetFeasibleInherentLoss(
const ChannelParameters& channel_parameters) const;
@ -193,6 +192,7 @@ class LossBasedBweV2 {
DataRate max_bitrate_ = DataRate::PlusInfinity();
LossBasedState current_state_ = LossBasedState::kDelayBasedEstimate;
DataRate probe_bitrate_ = DataRate::PlusInfinity();
DataRate delay_based_estimate_ = DataRate::PlusInfinity();
};
} // namespace webrtc

View file

@ -201,11 +201,13 @@ TEST_P(LossBasedBweV2Test, ReturnsDelayBasedEstimateWhenDisabled) {
Config(/*enabled=*/false, /*valid=*/true,
/*trendline_integration_enabled=*/GetParam()));
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100))
.bandwidth_estimate,
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
/*packet_results=*/{},
/*delay_based_estimate=*/DataRate::KilobitsPerSec(100),
BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(100));
}
@ -215,11 +217,13 @@ TEST_P(LossBasedBweV2Test,
Config(/*enabled=*/true, /*valid=*/false,
/*trendline_integration_enabled=*/GetParam()));
LossBasedBweV2 loss_based_bandwidth_estimator(&key_value_config);
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::KilobitsPerSec(100))
.bandwidth_estimate,
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
/*packet_results=*/{},
/*delay_based_estimate=*/DataRate::KilobitsPerSec(100),
BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(100));
}
@ -241,9 +245,7 @@ TEST_P(LossBasedBweV2Test,
/*probe_estimate=*/absl::nullopt);
EXPECT_TRUE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult()
.bandwidth_estimate.IsFinite());
}
@ -261,9 +263,7 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNoInitialization) {
/*probe_estimate=*/absl::nullopt);
EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult()
.bandwidth_estimate.IsPlusInfinity());
}
@ -290,9 +290,7 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) {
DataRate::KilobitsPerSec(600));
EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult()
.bandwidth_estimate.IsPlusInfinity());
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
@ -300,9 +298,7 @@ TEST_P(LossBasedBweV2Test, NoBandwidthEstimateGivenNotEnoughFeedback) {
/*probe_estimate=*/absl::nullopt);
EXPECT_FALSE(loss_based_bandwidth_estimator.IsReady());
EXPECT_TRUE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_limit=*/DataRate::PlusInfinity())
EXPECT_TRUE(loss_based_bandwidth_estimator.GetLossBasedResult()
.bandwidth_estimate.IsPlusInfinity());
}
@ -327,29 +323,23 @@ TEST_P(LossBasedBweV2Test,
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_NE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_NE(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.SetBandwidthEstimate(
DataRate::KilobitsPerSec(600));
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_NE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_NE(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
}
@ -380,19 +370,15 @@ TEST_P(LossBasedBweV2Test,
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_EQ(loss_based_bandwidth_estimator_1
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(
loss_based_bandwidth_estimator_1.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(660));
loss_based_bandwidth_estimator_1.SetAcknowledgedBitrate(
DataRate::KilobitsPerSec(900));
EXPECT_EQ(loss_based_bandwidth_estimator_1
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(
loss_based_bandwidth_estimator_1.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(660));
loss_based_bandwidth_estimator_1.UpdateBandwidthEstimate(
@ -402,14 +388,9 @@ TEST_P(LossBasedBweV2Test,
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_NE(loss_based_bandwidth_estimator_1
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
loss_based_bandwidth_estimator_2
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate);
EXPECT_NE(
loss_based_bandwidth_estimator_1.GetLossBasedResult().bandwidth_estimate,
loss_based_bandwidth_estimator_2.GetLossBasedResult().bandwidth_estimate);
}
TEST_P(LossBasedBweV2Test,
@ -429,10 +410,8 @@ TEST_P(LossBasedBweV2Test,
enough_feedback_no_received_packets, DataRate::PlusInfinity(),
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(100));
}
@ -459,18 +438,14 @@ TEST_P(LossBasedBweV2Test, BandwidthEstimateNotIncreaseWhenNetworkUnderusing) {
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(),
BandwidthUsage::kBwUnderusing, /*probe_estimate=*/absl::nullopt);
EXPECT_LE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_LE(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_LE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_LE(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
}
@ -499,20 +474,17 @@ TEST_P(LossBasedBweV2Test,
/*probe_estimate=*/absl::nullopt);
// If the delay based estimate is infinity, then loss based estimate increases
// and not bounded by delay based estimate.
EXPECT_GT(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_GT(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
enough_feedback_2, /*delay_based_estimate=*/DataRate::KilobitsPerSec(500),
BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
// If the delay based estimate is not infinity, then loss based estimate is
// bounded by delay based estimate.
EXPECT_EQ(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::KilobitsPerSec(500))
.bandwidth_estimate,
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(500));
}
@ -548,10 +520,8 @@ TEST_P(LossBasedBweV2Test, UseAckedBitrateForEmegencyBackOff) {
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing,
/*probe_estimate=*/absl::nullopt);
// The estimate bitrate now is backed off based on acked bitrate.
EXPECT_LE(loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate,
EXPECT_LE(
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
acked_bitrate);
}
@ -573,19 +543,15 @@ TEST_P(LossBasedBweV2Test, NoBweChangeIfObservationDurationUnchanged) {
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_1 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
// Use the same feedback and check if the estimate is unchanged.
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
EXPECT_EQ(estimate_2, estimate_1);
}
@ -610,18 +576,14 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_1 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
EXPECT_EQ(estimate_2, estimate_1);
}
@ -646,18 +608,14 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_1 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(),
BandwidthUsage::kBwUnderusing, /*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
EXPECT_LE(estimate_2, estimate_1);
}
@ -689,18 +647,14 @@ TEST_P(LossBasedBweV2Test,
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_1, DataRate::PlusInfinity(), BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_1 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_1 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, DataRate::PlusInfinity(), BandwidthUsage::kBwOverusing,
/*probe_estimate=*/absl::nullopt);
DataRate estimate_2 = loss_based_bandwidth_estimator
.GetLossBasedResult(
/*delay_based_limit=*/DataRate::PlusInfinity())
.bandwidth_estimate;
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
EXPECT_LT(estimate_2, estimate_1);
}
@ -725,15 +679,13 @@ TEST_P(LossBasedBweV2Test,
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
delay_based_estimate);
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_2, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
delay_based_estimate);
}
@ -761,7 +713,7 @@ TEST_P(LossBasedBweV2Test,
enough_feedback_1, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
LossBasedBweV2::Result result_at_loss =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate);
loss_based_bandwidth_estimator.GetLossBasedResult();
// Network recovers after loss.
std::vector<PacketResult> enough_feedback_2 =
@ -775,7 +727,7 @@ TEST_P(LossBasedBweV2Test,
/*probe_estimate=*/absl::nullopt);
LossBasedBweV2::Result result_after_recovery =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate);
loss_based_bandwidth_estimator.GetLossBasedResult();
EXPECT_EQ(result_after_recovery.bandwidth_estimate,
result_at_loss.bandwidth_estimate * 1.5);
}
@ -815,8 +767,7 @@ TEST_P(LossBasedBweV2Test,
// The estimate is capped by acked_bitrate * BwRampupUpperBoundFactor.
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate;
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
EXPECT_EQ(estimate_2, acked_bitrate * 1.2);
}
@ -859,8 +810,7 @@ TEST_P(LossBasedBweV2Test,
// The estimate is capped by current_estimate * kMaxIncreaseFactor because
// it recently backed off.
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate;
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal,
@ -868,8 +818,7 @@ TEST_P(LossBasedBweV2Test,
// The latest estimate is the same as the previous estimate since the sent
// packets were sent within the DelayedIncreaseWindow.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
estimate_2);
}
@ -910,16 +859,14 @@ TEST_P(LossBasedBweV2Test, KeepIncreasingEstimateAfterDelayedIncreaseWindow) {
// The estimate is capped by current_estimate * kMaxIncreaseFactor because it
// recently backed off.
DataRate estimate_2 =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate;
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate;
loss_based_bandwidth_estimator.UpdateBandwidthEstimate(
enough_feedback_3, delay_based_estimate, BandwidthUsage::kBwNormal,
/*probe_estimate=*/absl::nullopt);
// The estimate can continue increasing after the DelayedIncreaseWindow.
EXPECT_GE(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
estimate_2);
}
@ -954,8 +901,7 @@ TEST_P(LossBasedBweV2Test, NotIncreaseIfInherentLossLessThanAverageLoss) {
// Do not increase the bitrate because inherent loss is less than average loss
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
}
@ -993,8 +939,7 @@ TEST_P(LossBasedBweV2Test,
// Because LossThresholdOfHighBandwidthPreference is 20%, the average loss is
// 10%, bandwidth estimate should increase.
EXPECT_GT(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
}
@ -1032,8 +977,7 @@ TEST_P(LossBasedBweV2Test,
// Because LossThresholdOfHighBandwidthPreference is 5%, the average loss is
// 10%, bandwidth estimate should decrease.
EXPECT_LT(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(600));
}
@ -1071,7 +1015,7 @@ TEST_P(LossBasedBweV2Test, UseProbeResultWhenRecoveringFromLoss) {
probe_estimate);
LossBasedBweV2::Result result_after_recovery =
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate);
loss_based_bandwidth_estimator.GetLossBasedResult();
EXPECT_EQ(result_after_recovery.bandwidth_estimate, probe_estimate);
}
@ -1111,8 +1055,7 @@ TEST_P(LossBasedBweV2Test,
// At 10% loss rate and high loss rate threshold to be 10%, cap the estimate
// to be 500 * 1000-0.1 = 400kbps.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(400));
}
@ -1152,8 +1095,7 @@ TEST_P(LossBasedBweV2Test,
// At 50% loss rate and high loss rate threshold to be 30%, cap the estimate
// to be the min bitrate.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(10));
}
@ -1193,8 +1135,7 @@ TEST_P(LossBasedBweV2Test,
// At 100% loss rate and high loss rate threshold to be 30%, cap the estimate
// to be the min bitrate.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(10));
}
@ -1225,8 +1166,7 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) {
// Make sure that the estimate is set to min bitrate because of 100% loss
// rate.
EXPECT_EQ(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(10));
// Create some feedbacks with 0 loss rate to simulate network recovering.
@ -1248,8 +1188,7 @@ TEST_P(LossBasedBweV2Test, EstimateRecoversAfterHighLoss) {
// The estimate increases as network recovers.
EXPECT_GT(
loss_based_bandwidth_estimator.GetLossBasedResult(delay_based_estimate)
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(10));
}
@ -1271,9 +1210,7 @@ TEST_P(LossBasedBweV2Test, EstimateIsNotHigherThanMaxBitrate) {
BandwidthUsage::kBwNormal, /*probe_estimate=*/absl::nullopt);
EXPECT_LE(
loss_based_bandwidth_estimator
.GetLossBasedResult(/*delay_based_estimate=*/DataRate::PlusInfinity())
.bandwidth_estimate,
loss_based_bandwidth_estimator.GetLossBasedResult().bandwidth_estimate,
DataRate::KilobitsPerSec(1000));
}

View file

@ -526,8 +526,7 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
if (LossBasedBandwidthEstimatorV2ReadyForUse()) {
LossBasedBweV2::Result result =
loss_based_bandwidth_estimator_v2_.GetLossBasedResult(
delay_based_limit_);
loss_based_bandwidth_estimator_v2_.GetLossBasedResult();
loss_based_state_ = result.state;
UpdateTargetBitrate(result.bandwidth_estimate, at_time);
return;