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

Side by Side Diff: webrtc/modules/congestion_controller/delay_based_bwe.cc

Issue 2407143002: Remove GetFeedbackInterval in sender side BWE. (Closed)
Patch Set: Respond to comments Created 3 years, 8 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) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000); 146 return rtc::Optional<uint32_t>(bitrate_estimate_ * 1000);
147 } 147 }
148 148
149 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, const Clock* clock) 149 DelayBasedBwe::DelayBasedBwe(RtcEventLog* event_log, const Clock* clock)
150 : event_log_(event_log), 150 : event_log_(event_log),
151 clock_(clock), 151 clock_(clock),
152 inter_arrival_(), 152 inter_arrival_(),
153 trendline_estimator_(), 153 trendline_estimator_(),
154 detector_(), 154 detector_(),
155 receiver_incoming_bitrate_(), 155 receiver_incoming_bitrate_(),
156 last_update_ms_(-1),
157 last_seen_packet_ms_(-1), 156 last_seen_packet_ms_(-1),
158 uma_recorded_(false), 157 uma_recorded_(false),
159 probe_bitrate_estimator_(event_log), 158 probe_bitrate_estimator_(event_log),
160 trendline_window_size_(kDefaultTrendlineWindowSize), 159 trendline_window_size_(kDefaultTrendlineWindowSize),
161 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff), 160 trendline_smoothing_coeff_(kDefaultTrendlineSmoothingCoeff),
162 trendline_threshold_gain_(kDefaultTrendlineThresholdGain), 161 trendline_threshold_gain_(kDefaultTrendlineThresholdGain),
163 consecutive_delayed_feedbacks_(0), 162 consecutive_delayed_feedbacks_(0),
164 last_logged_bitrate_(0), 163 last_logged_bitrate_(0),
165 last_logged_state_(BandwidthUsage::kBwNormal) { 164 last_logged_state_(BandwidthUsage::kBwNormal) {
166 LOG(LS_INFO) << "Using Trendline filter for delay change estimation."; 165 LOG(LS_INFO) << "Using Trendline filter for delay change estimation.";
(...skipping 15 matching lines...) Expand all
182 LOG(LS_WARNING) << "Very late feedback received."; 181 LOG(LS_WARNING) << "Very late feedback received.";
183 return DelayBasedBwe::Result(); 182 return DelayBasedBwe::Result();
184 } 183 }
185 184
186 if (!uma_recorded_) { 185 if (!uma_recorded_) {
187 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram, 186 RTC_HISTOGRAM_ENUMERATION(kBweTypeHistogram,
188 BweNames::kSendSideTransportSeqNum, 187 BweNames::kSendSideTransportSeqNum,
189 BweNames::kBweNamesMax); 188 BweNames::kBweNamesMax);
190 uma_recorded_ = true; 189 uma_recorded_ = true;
191 } 190 }
192 Result aggregated_result; 191 bool overusing = false;
193 bool delayed_feedback = true; 192 bool delayed_feedback = true;
194 for (const auto& packet_feedback : sorted_packet_feedback_vector) { 193 for (const auto& packet_feedback : sorted_packet_feedback_vector) {
195 if (packet_feedback.send_time_ms < 0) 194 if (packet_feedback.send_time_ms < 0)
196 continue; 195 continue;
197 delayed_feedback = false; 196 delayed_feedback = false;
198 Result result = IncomingPacketFeedback(packet_feedback); 197 IncomingPacketFeedback(packet_feedback);
199 if (result.updated) 198 overusing |= detector_.State() == BandwidthUsage::kBwOverusing;
200 aggregated_result = result;
201 } 199 }
202 if (delayed_feedback) { 200 if (delayed_feedback) {
203 ++consecutive_delayed_feedbacks_; 201 ++consecutive_delayed_feedbacks_;
202 if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) {
203 consecutive_delayed_feedbacks_ = 0;
204 return OnLongFeedbackDelay(
205 sorted_packet_feedback_vector.back().arrival_time_ms);
206 }
204 } else { 207 } else {
205 consecutive_delayed_feedbacks_ = 0; 208 consecutive_delayed_feedbacks_ = 0;
209 return MaybeUpdateEstimate(overusing);
206 } 210 }
207 if (consecutive_delayed_feedbacks_ >= kMaxConsecutiveFailedLookups) { 211 return Result();
208 aggregated_result = OnLongFeedbackDelay(
209 sorted_packet_feedback_vector.back().arrival_time_ms);
210 consecutive_delayed_feedbacks_ = 0;
211 }
212 return aggregated_result;
213 } 212 }
214 213
215 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay( 214 DelayBasedBwe::Result DelayBasedBwe::OnLongFeedbackDelay(
216 int64_t arrival_time_ms) { 215 int64_t arrival_time_ms) {
217 // Estimate should always be valid since a start bitrate always is set in the 216 // Estimate should always be valid since a start bitrate always is set in the
218 // Call constructor. An alternative would be to return an empty Result here, 217 // Call constructor. An alternative would be to return an empty Result here,
219 // or to estimate the throughput based on the feedback we received. 218 // or to estimate the throughput based on the feedback we received.
220 RTC_DCHECK(rate_control_.ValidEstimate()); 219 RTC_DCHECK(rate_control_.ValidEstimate());
221 rate_control_.SetEstimate(rate_control_.LatestEstimate() / 2, 220 rate_control_.SetEstimate(rate_control_.LatestEstimate() / 2,
222 arrival_time_ms); 221 arrival_time_ms);
223 Result result; 222 Result result;
224 result.updated = true; 223 result.updated = true;
225 result.probe = false; 224 result.probe = false;
226 result.target_bitrate_bps = rate_control_.LatestEstimate(); 225 result.target_bitrate_bps = rate_control_.LatestEstimate();
227 LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to " 226 LOG(LS_WARNING) << "Long feedback delay detected, reducing BWE to "
228 << result.target_bitrate_bps; 227 << result.target_bitrate_bps;
229 return result; 228 return result;
230 } 229 }
231 230
232 DelayBasedBwe::Result DelayBasedBwe::IncomingPacketFeedback( 231 void DelayBasedBwe::IncomingPacketFeedback(
233 const PacketFeedback& packet_feedback) { 232 const PacketFeedback& packet_feedback) {
234 int64_t now_ms = clock_->TimeInMilliseconds(); 233 int64_t now_ms = clock_->TimeInMilliseconds();
235 234
236 receiver_incoming_bitrate_.Update(packet_feedback.arrival_time_ms, 235 receiver_incoming_bitrate_.Update(packet_feedback.arrival_time_ms,
237 packet_feedback.payload_size); 236 packet_feedback.payload_size);
238 Result result; 237 Result result;
239 // Reset if the stream has timed out. 238 // Reset if the stream has timed out.
240 if (last_seen_packet_ms_ == -1 || 239 if (last_seen_packet_ms_ == -1 ||
241 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) { 240 now_ms - last_seen_packet_ms_ > kStreamTimeOutMs) {
242 inter_arrival_.reset( 241 inter_arrival_.reset(
(...skipping 22 matching lines...) Expand all
265 if (inter_arrival_->ComputeDeltas(timestamp, packet_feedback.arrival_time_ms, 264 if (inter_arrival_->ComputeDeltas(timestamp, packet_feedback.arrival_time_ms,
266 now_ms, packet_feedback.payload_size, 265 now_ms, packet_feedback.payload_size,
267 &ts_delta, &t_delta, &size_delta)) { 266 &ts_delta, &t_delta, &size_delta)) {
268 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift); 267 double ts_delta_ms = (1000.0 * ts_delta) / (1 << kInterArrivalShift);
269 trendline_estimator_->Update(t_delta, ts_delta_ms, 268 trendline_estimator_->Update(t_delta, ts_delta_ms,
270 packet_feedback.arrival_time_ms); 269 packet_feedback.arrival_time_ms);
271 detector_.Detect(trendline_estimator_->trendline_slope(), ts_delta_ms, 270 detector_.Detect(trendline_estimator_->trendline_slope(), ts_delta_ms,
272 trendline_estimator_->num_of_deltas(), 271 trendline_estimator_->num_of_deltas(),
273 packet_feedback.arrival_time_ms); 272 packet_feedback.arrival_time_ms);
274 } 273 }
275
276 int probing_bps = 0;
277 if (packet_feedback.pacing_info.probe_cluster_id != 274 if (packet_feedback.pacing_info.probe_cluster_id !=
278 PacedPacketInfo::kNotAProbe) { 275 PacedPacketInfo::kNotAProbe) {
279 probing_bps = 276 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback);
280 probe_bitrate_estimator_.HandleProbeAndEstimateBitrate(packet_feedback);
281 } 277 }
278 }
279
280 DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate(bool overusing) {
281 Result result;
282 int64_t now_ms = clock_->TimeInMilliseconds();
283
282 rtc::Optional<uint32_t> acked_bitrate_bps = 284 rtc::Optional<uint32_t> acked_bitrate_bps =
283 receiver_incoming_bitrate_.bitrate_bps(); 285 receiver_incoming_bitrate_.bitrate_bps();
286 rtc::Optional<int> probe_bitrate_bps =
287 probe_bitrate_estimator_.FetchAndResetLastEstimatedBitrateBps();
284 // Currently overusing the bandwidth. 288 // Currently overusing the bandwidth.
285 if (detector_.State() == BandwidthUsage::kBwOverusing) { 289 if (overusing) {
286 if (acked_bitrate_bps && 290 if (acked_bitrate_bps &&
287 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) { 291 rate_control_.TimeToReduceFurther(now_ms, *acked_bitrate_bps)) {
288 result.updated = 292 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing,
289 UpdateEstimate(packet_feedback.arrival_time_ms, now_ms, 293 &result.target_bitrate_bps);
290 acked_bitrate_bps, &result.target_bitrate_bps);
291 } 294 }
292 } else if (probing_bps > 0) { 295 } else {
293 // No overuse, but probing measured a bitrate. 296 if (probe_bitrate_bps) {
294 rate_control_.SetEstimate(probing_bps, packet_feedback.arrival_time_ms); 297 rate_control_.SetEstimate(*probe_bitrate_bps, now_ms);
295 result.probe = true; 298 result.probe = true;
296 result.updated = 299 }
297 UpdateEstimate(packet_feedback.arrival_time_ms, now_ms, 300 result.updated = UpdateEstimate(now_ms, acked_bitrate_bps, overusing,
298 acked_bitrate_bps, &result.target_bitrate_bps); 301 &result.target_bitrate_bps);
299 }
300 if (!result.updated &&
301 (last_update_ms_ == -1 ||
302 now_ms - last_update_ms_ > rate_control_.GetFeedbackInterval())) {
303 result.updated =
304 UpdateEstimate(packet_feedback.arrival_time_ms, now_ms,
305 acked_bitrate_bps, &result.target_bitrate_bps);
306 } 302 }
307 if (result.updated) { 303 if (result.updated) {
308 last_update_ms_ = now_ms;
309 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms, 304 BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", now_ms,
310 result.target_bitrate_bps); 305 result.target_bitrate_bps);
311 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ || 306 if (event_log_ && (result.target_bitrate_bps != last_logged_bitrate_ ||
312 detector_.State() != last_logged_state_)) { 307 detector_.State() != last_logged_state_)) {
313 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps, 308 event_log_->LogDelayBasedBweUpdate(result.target_bitrate_bps,
314 detector_.State()); 309 detector_.State());
315 last_logged_bitrate_ = result.target_bitrate_bps; 310 last_logged_bitrate_ = result.target_bitrate_bps;
316 last_logged_state_ = detector_.State(); 311 last_logged_state_ = detector_.State();
317 } 312 }
318 } 313 }
319
320 return result; 314 return result;
321 } 315 }
322 316
323 bool DelayBasedBwe::UpdateEstimate(int64_t arrival_time_ms, 317 bool DelayBasedBwe::UpdateEstimate(int64_t now_ms,
324 int64_t now_ms,
325 rtc::Optional<uint32_t> acked_bitrate_bps, 318 rtc::Optional<uint32_t> acked_bitrate_bps,
319 bool overusing,
326 uint32_t* target_bitrate_bps) { 320 uint32_t* target_bitrate_bps) {
327 // TODO(terelius): RateControlInput::noise_var is deprecated and will be 321 // TODO(terelius): RateControlInput::noise_var is deprecated and will be
328 // removed. In the meantime, we set it to zero. 322 // removed. In the meantime, we set it to zero.
329 const RateControlInput input(detector_.State(), acked_bitrate_bps, 0); 323 const RateControlInput input(
324 overusing ? BandwidthUsage::kBwOverusing : detector_.State(),
325 acked_bitrate_bps, 0);
330 *target_bitrate_bps = rate_control_.Update(&input, now_ms); 326 *target_bitrate_bps = rate_control_.Update(&input, now_ms);
331 return rate_control_.ValidEstimate(); 327 return rate_control_.ValidEstimate();
332 } 328 }
333 329
334 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 330 void DelayBasedBwe::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
335 rate_control_.SetRtt(avg_rtt_ms); 331 rate_control_.SetRtt(avg_rtt_ms);
336 } 332 }
337 333
338 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs, 334 bool DelayBasedBwe::LatestEstimate(std::vector<uint32_t>* ssrcs,
339 uint32_t* bitrate_bps) const { 335 uint32_t* bitrate_bps) const {
(...skipping 19 matching lines...) Expand all
359 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) { 355 void DelayBasedBwe::SetMinBitrate(int min_bitrate_bps) {
360 // Called from both the configuration thread and the network thread. Shouldn't 356 // Called from both the configuration thread and the network thread. Shouldn't
361 // be called from the network thread in the future. 357 // be called from the network thread in the future.
362 rate_control_.SetMinBitrate(min_bitrate_bps); 358 rate_control_.SetMinBitrate(min_bitrate_bps);
363 } 359 }
364 360
365 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const { 361 int64_t DelayBasedBwe::GetExpectedBwePeriodMs() const {
366 return rate_control_.GetExpectedBandwidthPeriodMs(); 362 return rate_control_.GetExpectedBandwidthPeriodMs();
367 } 363 }
368 } // namespace webrtc 364 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698