[fix] fix timestamp in congestion control feedback

This commit is contained in:
dijunkun
2025-02-08 17:59:30 +08:00
parent 8d7068aa32
commit 61ac3a9971
10 changed files with 38 additions and 71 deletions

View File

@@ -163,7 +163,7 @@ SendSideBandwidthEstimation::SendSideBandwidthEstimation()
low_loss_threshold_(kDefaultLowLossThreshold),
high_loss_threshold_(kDefaultHighLossThreshold),
bitrate_threshold_(kDefaultBitrateThreshold),
disable_receiver_limit_caps_only_("Disabled") {
disable_receiver_limit_caps_only_(false) {
// rtt_backoff_ =
}
@@ -204,7 +204,6 @@ void SendSideBandwidthEstimation::SetBitrates(
void SendSideBandwidthEstimation::SetSendBitrate(DataRate bitrate,
Timestamp at_time) {
LOG_ERROR("3");
// Reset to avoid being capped by the estimate.
delay_based_limit_ = DataRate::PlusInfinity();
UpdateTargetBitrate(bitrate, at_time);
@@ -245,7 +244,6 @@ DataRate SendSideBandwidthEstimation::GetEstimatedLinkCapacity() const {
void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time,
DataRate bandwidth) {
LOG_ERROR("6");
// TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no
// limitation.
receiver_limit_ = bandwidth.IsZero() ? DataRate::PlusInfinity() : bandwidth;
@@ -254,7 +252,6 @@ void SendSideBandwidthEstimation::UpdateReceiverEstimate(Timestamp at_time,
void SendSideBandwidthEstimation::UpdateDelayBasedEstimate(Timestamp at_time,
DataRate bitrate) {
LOG_ERROR("7");
link_capacity_.UpdateDelayBasedEstimate(at_time, bitrate);
// TODO(srte): Ensure caller passes PlusInfinity, not zero, to represent no
// limitation.
@@ -345,9 +342,7 @@ void SendSideBandwidthEstimation::UpdateRtt(TimeDelta rtt, Timestamp at_time) {
}
void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
LOG_ERROR("1");
if (rtt_backoff_.IsRttAboveLimit()) {
LOG_ERROR("11");
if (at_time - time_last_decrease_ >= rtt_backoff_.drop_interval_ &&
current_target_ > rtt_backoff_.bandwidth_floor_) {
time_last_decrease_ = at_time;
@@ -362,7 +357,6 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
ApplyTargetLimits(at_time);
return;
}
LOG_ERROR("111");
// 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)) {
@@ -381,28 +375,23 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
return;
}
}
LOG_ERROR("112");
UpdateMinHistory(at_time);
if (last_loss_packet_report_.IsInfinite()) {
// No feedback received.
// TODO(srte): This is likely redundant in most cases.
LOG_ERROR("113");
ApplyTargetLimits(at_time);
return;
}
TimeDelta time_since_loss_packet_report = at_time - last_loss_packet_report_;
if (time_since_loss_packet_report < 1.2 * kMaxRtcpFeedbackInterval) {
LOG_ERROR("114");
// We only care about loss above a given bitrate threshold.
float loss = last_fraction_loss_ / 256.0f;
LOG_ERROR("current_target_ = [{}], loss = [{}]", ToString(current_target_),
loss);
// We only make decisions based on loss when the bitrate is above a
// threshold. This is a crude way of handling loss which is uncorrelated
// to congestion.
LOG_WARN("loss: [{}]", loss);
if (current_target_ < bitrate_threshold_ || loss <= low_loss_threshold_) {
LOG_ERROR("115");
// Loss < 2%: Increase rate by 8% of the min bitrate in the last
// kBweIncreaseInterval.
// Note that by remembering the bitrate over the last second one can
@@ -420,21 +409,18 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
// (gives a little extra increase at low rates, negligible at higher
// rates).
new_bitrate += DataRate::BitsPerSec(1000);
LOG_WARN("1 new_bitrate: [{}]", ToString(new_bitrate).c_str());
UpdateTargetBitrate(new_bitrate, at_time);
return;
} else if (current_target_ > bitrate_threshold_) {
LOG_ERROR("116");
if (loss <= high_loss_threshold_) {
LOG_ERROR("117");
// Loss between 2% - 10%: Do nothing.
} else {
LOG_ERROR("118");
// Loss > 10%: Limit the rate decreases to once a kBweDecreaseInterval
// + rtt.
if (!has_decreased_since_last_fraction_loss_ &&
(at_time - time_last_decrease_) >=
(kBweDecreaseInterval + last_round_trip_time_)) {
LOG_ERROR("119");
time_last_decrease_ = at_time;
// Reduce rate:
@@ -445,13 +431,13 @@ void SendSideBandwidthEstimation::UpdateEstimate(Timestamp at_time) {
static_cast<double>(512 - last_fraction_loss_)) /
512.0);
has_decreased_since_last_fraction_loss_ = true;
LOG_WARN("2 new_bitrate: [{}]", ToString(new_bitrate).c_str());
UpdateTargetBitrate(new_bitrate, at_time);
return;
}
}
}
}
LOG_ERROR("120");
// TODO(srte): This is likely redundant in most cases.
ApplyTargetLimits(at_time);
}
@@ -494,8 +480,9 @@ void SendSideBandwidthEstimation::UpdateMinHistory(Timestamp at_time) {
DataRate SendSideBandwidthEstimation::GetUpperLimit() const {
DataRate upper_limit = delay_based_limit_;
if (disable_receiver_limit_caps_only_)
if (disable_receiver_limit_caps_only_) {
upper_limit = std::min(upper_limit, receiver_limit_);
}
return std::min(upper_limit, max_bitrate_configured_);
}
@@ -512,7 +499,6 @@ void SendSideBandwidthEstimation::MaybeLogLowBitrateWarning(DataRate bitrate,
void SendSideBandwidthEstimation::UpdateTargetBitrate(DataRate new_bitrate,
Timestamp at_time) {
new_bitrate = std::min(new_bitrate, GetUpperLimit());
LOG_WARN("new_bitrate: [{}]", ToString(new_bitrate).c_str());
if (new_bitrate < min_bitrate_configured_) {
MaybeLogLowBitrateWarning(new_bitrate, at_time);
new_bitrate = min_bitrate_configured_;
@@ -522,7 +508,6 @@ void SendSideBandwidthEstimation::UpdateTargetBitrate(DataRate new_bitrate,
}
void SendSideBandwidthEstimation::ApplyTargetLimits(Timestamp at_time) {
LOG_ERROR("2");
UpdateTargetBitrate(current_target_, at_time);
}