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

Side by Side Diff: webrtc/modules/pacing/bitrate_prober.cc

Issue 1221943002: Improve probing by ignoring small packets which otherwise break the mechanism. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix test. Created 5 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 11 matching lines...) Expand all
22 namespace { 22 namespace {
23 int ComputeDeltaFromBitrate(size_t packet_size, int bitrate_bps) { 23 int ComputeDeltaFromBitrate(size_t packet_size, int bitrate_bps) {
24 assert(bitrate_bps > 0); 24 assert(bitrate_bps > 0);
25 // Compute the time delta needed to send packet_size bytes at bitrate_bps 25 // Compute the time delta needed to send packet_size bytes at bitrate_bps
26 // bps. Result is in milliseconds. 26 // bps. Result is in milliseconds.
27 return static_cast<int>(1000ll * static_cast<int64_t>(packet_size) * 8ll / 27 return static_cast<int>(1000ll * static_cast<int64_t>(packet_size) * 8ll /
28 bitrate_bps); 28 bitrate_bps);
29 } 29 }
30 } // namespace 30 } // namespace
31 31
32 const size_t BitrateProber::kMinProbePacketSize = 200;
33
32 BitrateProber::BitrateProber() 34 BitrateProber::BitrateProber()
33 : probing_state_(kDisabled), 35 : probing_state_(kDisabled),
34 packet_size_last_send_(0), 36 packet_size_last_send_(0),
35 time_last_send_ms_(-1) { 37 time_last_send_ms_(-1) {
36 } 38 }
37 39
38 void BitrateProber::SetEnabled(bool enable) { 40 void BitrateProber::SetEnabled(bool enable) {
39 if (enable) { 41 if (enable) {
40 if (probing_state_ == kDisabled) { 42 if (probing_state_ == kDisabled) {
41 probing_state_ = kAllowedToProbe; 43 probing_state_ = kAllowedToProbe;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 probing_state_ = kWait; 83 probing_state_ = kWait;
82 } 84 }
83 if (probe_bitrates_.empty()) { 85 if (probe_bitrates_.empty()) {
84 // No probe started, or waiting for next probe. 86 // No probe started, or waiting for next probe.
85 return -1; 87 return -1;
86 } 88 }
87 int64_t elapsed_time_ms = now_ms - time_last_send_ms_; 89 int64_t elapsed_time_ms = now_ms - time_last_send_ms_;
88 // We will send the first probe packet immediately if no packet has been 90 // We will send the first probe packet immediately if no packet has been
89 // sent before. 91 // sent before.
90 int time_until_probe_ms = 0; 92 int time_until_probe_ms = 0;
91 if (packet_size_last_send_ > 0 && probing_state_ == kProbing) { 93 if (packet_size_last_send_ > kMinProbePacketSize &&
94 probing_state_ == kProbing) {
92 int next_delta_ms = ComputeDeltaFromBitrate(packet_size_last_send_, 95 int next_delta_ms = ComputeDeltaFromBitrate(packet_size_last_send_,
93 probe_bitrates_.front()); 96 probe_bitrates_.front());
94 time_until_probe_ms = next_delta_ms - elapsed_time_ms; 97 time_until_probe_ms = next_delta_ms - elapsed_time_ms;
95 // There is no point in trying to probe with less than 1 ms between packets 98 // There is no point in trying to probe with less than 1 ms between packets
96 // as it essentially means trying to probe at infinite bandwidth. 99 // as it essentially means trying to probe at infinite bandwidth.
97 const int kMinProbeDeltaMs = 1; 100 const int kMinProbeDeltaMs = 1;
98 // If we have waited more than 3 ms for a new packet to probe with we will 101 // If we have waited more than 3 ms for a new packet to probe with we will
99 // consider this probing session over. 102 // consider this probing session over.
100 const int kMaxProbeDelayMs = 3; 103 const int kMaxProbeDelayMs = 3;
101 if (next_delta_ms < kMinProbeDeltaMs || 104 if (next_delta_ms < kMinProbeDeltaMs ||
(...skipping 16 matching lines...) Expand all
118 void BitrateProber::PacketSent(int64_t now_ms, size_t packet_size) { 121 void BitrateProber::PacketSent(int64_t now_ms, size_t packet_size) {
119 assert(packet_size > 0); 122 assert(packet_size > 0);
120 packet_size_last_send_ = packet_size; 123 packet_size_last_send_ = packet_size;
121 time_last_send_ms_ = now_ms; 124 time_last_send_ms_ = now_ms;
122 if (probing_state_ != kProbing) 125 if (probing_state_ != kProbing)
123 return; 126 return;
124 if (!probe_bitrates_.empty()) 127 if (!probe_bitrates_.empty())
125 probe_bitrates_.pop_front(); 128 probe_bitrates_.pop_front();
126 } 129 }
127 } // namespace webrtc 130 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698