Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(503)

Unified Diff: webrtc/modules/pacing/bitrate_prober.cc

Issue 2681733004: Fix bug in BitrateProber where an old probe added at a high bitrate will stay active indefinit… (Closed)
Patch Set: Add unittest. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/modules/pacing/bitrate_prober.h ('k') | webrtc/modules/pacing/bitrate_prober_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/pacing/bitrate_prober.cc
diff --git a/webrtc/modules/pacing/bitrate_prober.cc b/webrtc/modules/pacing/bitrate_prober.cc
index 749aa69ff8586deff5f0a2d12b8cdd81ce23b573..39fe0f4fd286031bcf828d929c05c2741fdff6e9 100644
--- a/webrtc/modules/pacing/bitrate_prober.cc
+++ b/webrtc/modules/pacing/bitrate_prober.cc
@@ -41,6 +41,8 @@ constexpr int kMaxRetryAttempts = 3;
// we have a min probe packet size of 200 bytes.
constexpr size_t kMinProbePacketSize = 200;
+constexpr int64_t kProbeClusterTimeoutMs = 5000;
+
} // namespace
BitrateProber::BitrateProber()
@@ -78,12 +80,18 @@ void BitrateProber::OnIncomingPacket(size_t packet_size) {
}
}
-void BitrateProber::CreateProbeCluster(int bitrate_bps) {
+void BitrateProber::CreateProbeCluster(int bitrate_bps, int64_t now_ms) {
RTC_DCHECK(probing_state_ != ProbingState::kDisabled);
+ while (!clusters_.empty() &&
+ now_ms - clusters_.front().time_created_ms > kProbeClusterTimeoutMs) {
+ clusters_.pop();
+ }
+
ProbeCluster cluster;
cluster.min_probes = kMinProbePacketsSent;
cluster.min_bytes = bitrate_bps * kMinProbeDurationMs / 8000;
cluster.bitrate_bps = bitrate_bps;
+ cluster.time_created_ms = now_ms;
cluster.id = next_cluster_id_++;
clusters_.push(cluster);
@@ -96,7 +104,7 @@ void BitrateProber::CreateProbeCluster(int bitrate_bps) {
probing_state_ = ProbingState::kInactive;
}
-void BitrateProber::ResetState() {
+void BitrateProber::ResetState(int64_t now_ms) {
RTC_DCHECK(probing_state_ == ProbingState::kActive);
// Recreate all probing clusters.
@@ -104,7 +112,7 @@ void BitrateProber::ResetState() {
clusters.swap(clusters_);
while (!clusters.empty()) {
if (clusters.front().retries < kMaxRetryAttempts) {
- CreateProbeCluster(clusters.front().bitrate_bps);
+ CreateProbeCluster(clusters.front().bitrate_bps, now_ms);
clusters_.back().retries = clusters.front().retries + 1;
}
clusters.pop();
@@ -122,7 +130,7 @@ int BitrateProber::TimeUntilNextProbe(int64_t now_ms) {
if (next_probe_time_ms_ >= 0) {
time_until_probe_ms = next_probe_time_ms_ - now_ms;
if (time_until_probe_ms < -kMaxProbeDelayMs) {
- ResetState();
+ ResetState(now_ms);
return -1;
}
}
« no previous file with comments | « webrtc/modules/pacing/bitrate_prober.h ('k') | webrtc/modules/pacing/bitrate_prober_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698