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

Side by Side Diff: webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.cc

Issue 1748403002: Move RtcEventLog object from inside VoiceEngine to Call. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Another rebase and accompanying changes. Created 4 years, 5 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 26 matching lines...) Expand all
37 37
38 const UmaRampUpMetric kUmaRampupMetrics[] = { 38 const UmaRampUpMetric kUmaRampupMetrics[] = {
39 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, 39 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500},
40 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, 40 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000},
41 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; 41 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}};
42 const size_t kNumUmaRampupMetrics = 42 const size_t kNumUmaRampupMetrics =
43 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]); 43 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]);
44 44
45 } // namespace 45 } // namespace
46 46
47 SendSideBandwidthEstimation::SendSideBandwidthEstimation() 47 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log)
48 : lost_packets_since_last_loss_update_Q8_(0), 48 : lost_packets_since_last_loss_update_Q8_(0),
49 expected_packets_since_last_loss_update_(0), 49 expected_packets_since_last_loss_update_(0),
50 bitrate_(0), 50 bitrate_(0),
51 min_bitrate_configured_(kDefaultMinBitrateBps), 51 min_bitrate_configured_(kDefaultMinBitrateBps),
52 max_bitrate_configured_(kDefaultMaxBitrateBps), 52 max_bitrate_configured_(kDefaultMaxBitrateBps),
53 last_low_bitrate_log_ms_(-1), 53 last_low_bitrate_log_ms_(-1),
54 has_decreased_since_last_fraction_loss_(false), 54 has_decreased_since_last_fraction_loss_(false),
55 time_last_receiver_block_ms_(-1), 55 time_last_receiver_block_ms_(-1),
56 last_fraction_loss_(0), 56 last_fraction_loss_(0),
57 last_round_trip_time_ms_(0), 57 last_round_trip_time_ms_(0),
58 bwe_incoming_(0), 58 bwe_incoming_(0),
59 delay_based_bitrate_bps_(0), 59 delay_based_bitrate_bps_(0),
60 time_last_decrease_ms_(0), 60 time_last_decrease_ms_(0),
61 first_report_time_ms_(-1), 61 first_report_time_ms_(-1),
62 initially_lost_packets_(0), 62 initially_lost_packets_(0),
63 bitrate_at_2_seconds_kbps_(0), 63 bitrate_at_2_seconds_kbps_(0),
64 uma_update_state_(kNoUpdate), 64 uma_update_state_(kNoUpdate),
65 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), 65 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false),
66 event_log_(nullptr) {} 66 event_log_(event_log) {
67 RTC_DCHECK(event_log);
68 }
67 69
68 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} 70 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {}
69 71
70 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate, 72 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate,
71 int min_bitrate, 73 int min_bitrate,
72 int max_bitrate) { 74 int max_bitrate) {
73 if (send_bitrate > 0) 75 if (send_bitrate > 0)
74 SetSendBitrate(send_bitrate); 76 SetSendBitrate(send_bitrate);
75 SetMinMaxBitrate(min_bitrate, max_bitrate); 77 SetMinMaxBitrate(min_bitrate, max_bitrate);
76 } 78 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // If instead one would do: bitrate_ *= 1.08^(delta time), it would 222 // If instead one would do: bitrate_ *= 1.08^(delta time), it would
221 // take over one second since the lower packet loss to achieve 108kbps. 223 // take over one second since the lower packet loss to achieve 108kbps.
222 bitrate_ = static_cast<uint32_t>( 224 bitrate_ = static_cast<uint32_t>(
223 min_bitrate_history_.front().second * 1.08 + 0.5); 225 min_bitrate_history_.front().second * 1.08 + 0.5);
224 226
225 // Add 1 kbps extra, just to make sure that we do not get stuck 227 // Add 1 kbps extra, just to make sure that we do not get stuck
226 // (gives a little extra increase at low rates, negligible at higher 228 // (gives a little extra increase at low rates, negligible at higher
227 // rates). 229 // rates).
228 bitrate_ += 1000; 230 bitrate_ += 1000;
229 231
230 if (event_log_) { 232 event_log_->LogBwePacketLossEvent(
231 event_log_->LogBwePacketLossEvent( 233 bitrate_, last_fraction_loss_,
232 bitrate_, last_fraction_loss_, 234 expected_packets_since_last_loss_update_);
233 expected_packets_since_last_loss_update_);
234 }
235 } else if (last_fraction_loss_ <= 26) { 235 } else if (last_fraction_loss_ <= 26) {
236 // Loss between 2% - 10%: Do nothing. 236 // Loss between 2% - 10%: Do nothing.
237 } else { 237 } else {
238 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + 238 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs +
239 // rtt. 239 // rtt.
240 if (!has_decreased_since_last_fraction_loss_ && 240 if (!has_decreased_since_last_fraction_loss_ &&
241 (now_ms - time_last_decrease_ms_) >= 241 (now_ms - time_last_decrease_ms_) >=
242 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { 242 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) {
243 time_last_decrease_ms_ = now_ms; 243 time_last_decrease_ms_ = now_ms;
244 244
245 // Reduce rate: 245 // Reduce rate:
246 // newRate = rate * (1 - 0.5*lossRate); 246 // newRate = rate * (1 - 0.5*lossRate);
247 // where packetLoss = 256*lossRate; 247 // where packetLoss = 256*lossRate;
248 bitrate_ = static_cast<uint32_t>( 248 bitrate_ = static_cast<uint32_t>(
249 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) / 249 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) /
250 512.0); 250 512.0);
251 has_decreased_since_last_fraction_loss_ = true; 251 has_decreased_since_last_fraction_loss_ = true;
252 } 252 }
253 if (event_log_) { 253 event_log_->LogBwePacketLossEvent(
254 event_log_->LogBwePacketLossEvent( 254 bitrate_, last_fraction_loss_,
255 bitrate_, last_fraction_loss_, 255 expected_packets_since_last_loss_update_);
256 expected_packets_since_last_loss_update_);
257 }
258 } 256 }
259 } 257 }
260 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); 258 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_);
261 } 259 }
262 260
263 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { 261 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const {
264 return first_report_time_ms_ == -1 || 262 return first_report_time_ms_ == -1 ||
265 now_ms - first_report_time_ms_ < kStartPhaseMs; 263 now_ms - first_report_time_ms_ < kStartPhaseMs;
266 } 264 }
267 265
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) { 299 now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) {
302 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 300 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000
303 << " kbps is below configured min bitrate " 301 << " kbps is below configured min bitrate "
304 << min_bitrate_configured_ / 1000 << " kbps."; 302 << min_bitrate_configured_ / 1000 << " kbps.";
305 last_low_bitrate_log_ms_ = now_ms; 303 last_low_bitrate_log_ms_ = now_ms;
306 } 304 }
307 bitrate = min_bitrate_configured_; 305 bitrate = min_bitrate_configured_;
308 } 306 }
309 return bitrate; 307 return bitrate;
310 } 308 }
311
312 void SendSideBandwidthEstimation::SetEventLog(RtcEventLog* event_log) {
313 event_log_ = event_log;
314 }
315
316 } // namespace webrtc 309 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698