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

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

Issue 2861673006: Don't initiate perodic probing if we don't have a bandwidth estimate. (Closed)
Patch Set: Feedback Created 3 years, 7 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
« no previous file with comments | « webrtc/modules/congestion_controller/probe_controller_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 packet_size >= 79 packet_size >=
80 std::min<size_t>(RecommendedMinProbeSize(), kMinProbePacketSize)) { 80 std::min<size_t>(RecommendedMinProbeSize(), kMinProbePacketSize)) {
81 // Send next probe right away. 81 // Send next probe right away.
82 next_probe_time_ms_ = -1; 82 next_probe_time_ms_ = -1;
83 probing_state_ = ProbingState::kActive; 83 probing_state_ = ProbingState::kActive;
84 } 84 }
85 } 85 }
86 86
87 void BitrateProber::CreateProbeCluster(int bitrate_bps, int64_t now_ms) { 87 void BitrateProber::CreateProbeCluster(int bitrate_bps, int64_t now_ms) {
88 RTC_DCHECK(probing_state_ != ProbingState::kDisabled); 88 RTC_DCHECK(probing_state_ != ProbingState::kDisabled);
89 RTC_DCHECK_GT(bitrate_bps, 0);
89 while (!clusters_.empty() && 90 while (!clusters_.empty() &&
90 now_ms - clusters_.front().time_created_ms > kProbeClusterTimeoutMs) { 91 now_ms - clusters_.front().time_created_ms > kProbeClusterTimeoutMs) {
91 clusters_.pop(); 92 clusters_.pop();
92 } 93 }
93 94
94 ProbeCluster cluster; 95 ProbeCluster cluster;
95 cluster.time_created_ms = now_ms; 96 cluster.time_created_ms = now_ms;
96 cluster.pace_info.probe_cluster_min_probes = kMinProbePacketsSent; 97 cluster.pace_info.probe_cluster_min_probes = kMinProbePacketsSent;
97 cluster.pace_info.probe_cluster_min_bytes = 98 cluster.pace_info.probe_cluster_min_bytes =
98 bitrate_bps * kMinProbeDurationMs / 8000; 99 bitrate_bps * kMinProbeDurationMs / 8000;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 ResetState(now_ms); 145 ResetState(now_ms);
145 return -1; 146 return -1;
146 } 147 }
147 } 148 }
148 149
149 return std::max(time_until_probe_ms, 0); 150 return std::max(time_until_probe_ms, 0);
150 } 151 }
151 152
152 PacedPacketInfo BitrateProber::CurrentCluster() const { 153 PacedPacketInfo BitrateProber::CurrentCluster() const {
153 RTC_DCHECK(!clusters_.empty()); 154 RTC_DCHECK(!clusters_.empty());
154 RTC_DCHECK(ProbingState::kActive == probing_state_); 155 RTC_DCHECK(probing_state_ == ProbingState::kActive);
155 return clusters_.front().pace_info; 156 return clusters_.front().pace_info;
156 } 157 }
157 158
158 // Probe size is recommended based on the probe bitrate required. We choose 159 // Probe size is recommended based on the probe bitrate required. We choose
159 // a minimum of twice |kMinProbeDeltaMs| interval to allow scheduling to be 160 // a minimum of twice |kMinProbeDeltaMs| interval to allow scheduling to be
160 // feasible. 161 // feasible.
161 size_t BitrateProber::RecommendedMinProbeSize() const { 162 size_t BitrateProber::RecommendedMinProbeSize() const {
162 RTC_DCHECK(!clusters_.empty()); 163 RTC_DCHECK(!clusters_.empty());
163 return clusters_.front().pace_info.send_bitrate_bps * 2 * kMinProbeDeltaMs / 164 return clusters_.front().pace_info.send_bitrate_bps * 2 * kMinProbeDeltaMs /
164 (8 * 1000); 165 (8 * 1000);
165 } 166 }
166 167
167 void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) { 168 void BitrateProber::ProbeSent(int64_t now_ms, size_t bytes) {
168 RTC_DCHECK(probing_state_ == ProbingState::kActive); 169 RTC_DCHECK(probing_state_ == ProbingState::kActive);
169 RTC_DCHECK_GT(bytes, 0); 170 RTC_DCHECK_GT(bytes, 0);
170 171
171 if (!clusters_.empty()) { 172 if (!clusters_.empty()) {
172 ProbeCluster* cluster = &clusters_.front(); 173 ProbeCluster* cluster = &clusters_.front();
173 if (cluster->sent_probes == 0) { 174 if (cluster->sent_probes == 0) {
174 RTC_DCHECK_EQ(cluster->time_started_ms, -1); 175 RTC_DCHECK_EQ(cluster->time_started_ms, -1);
175 cluster->time_started_ms = now_ms; 176 cluster->time_started_ms = now_ms;
176 } 177 }
177 cluster->sent_bytes += static_cast<int>(bytes); 178 cluster->sent_bytes += static_cast<int>(bytes);
178 cluster->sent_probes += 1; 179 cluster->sent_probes += 1;
179 next_probe_time_ms_ = GetNextProbeTime(clusters_.front()); 180 next_probe_time_ms_ = GetNextProbeTime(*cluster);
180 if (cluster->sent_bytes >= cluster->pace_info.probe_cluster_min_bytes && 181 if (cluster->sent_bytes >= cluster->pace_info.probe_cluster_min_bytes &&
181 cluster->sent_probes >= cluster->pace_info.probe_cluster_min_probes) { 182 cluster->sent_probes >= cluster->pace_info.probe_cluster_min_probes) {
182 clusters_.pop(); 183 clusters_.pop();
183 } 184 }
184 if (clusters_.empty()) 185 if (clusters_.empty())
185 probing_state_ = ProbingState::kSuspended; 186 probing_state_ = ProbingState::kSuspended;
186 } 187 }
187 } 188 }
188 189
189 int64_t BitrateProber::GetNextProbeTime(const ProbeCluster& cluster) { 190 int64_t BitrateProber::GetNextProbeTime(const ProbeCluster& cluster) {
190 RTC_CHECK_GT(cluster.pace_info.send_bitrate_bps, 0); 191 RTC_CHECK_GT(cluster.pace_info.send_bitrate_bps, 0);
191 RTC_CHECK_GE(cluster.time_started_ms, 0); 192 RTC_CHECK_GE(cluster.time_started_ms, 0);
192 193
193 // Compute the time delta from the cluster start to ensure probe bitrate stays 194 // Compute the time delta from the cluster start to ensure probe bitrate stays
194 // close to the target bitrate. Result is in milliseconds. 195 // close to the target bitrate. Result is in milliseconds.
195 int64_t delta_ms = 196 int64_t delta_ms =
196 (8000ll * cluster.sent_bytes + cluster.pace_info.send_bitrate_bps / 2) / 197 (8000ll * cluster.sent_bytes + cluster.pace_info.send_bitrate_bps / 2) /
197 cluster.pace_info.send_bitrate_bps; 198 cluster.pace_info.send_bitrate_bps;
198 return cluster.time_started_ms + delta_ms; 199 return cluster.time_started_ms + delta_ms;
199 } 200 }
200 201
201 202
202 } // namespace webrtc 203 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/congestion_controller/probe_controller_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698