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

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: Undid unneccessary changes to rtp_rtcp module. Created 4 years, 9 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::SetSendBitrate(int bitrate) { 72 void SendSideBandwidthEstimation::SetSendBitrate(int bitrate) {
71 RTC_DCHECK_GT(bitrate, 0); 73 RTC_DCHECK_GT(bitrate, 0);
72 bitrate_ = bitrate; 74 bitrate_ = bitrate;
73 75
74 // Clear last sent bitrate history so the new value can be used directly 76 // Clear last sent bitrate history so the new value can be used directly
75 // and not capped. 77 // and not capped.
76 min_bitrate_history_.clear(); 78 min_bitrate_history_.clear();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // If instead one would do: bitrate_ *= 1.08^(delta time), it would 214 // If instead one would do: bitrate_ *= 1.08^(delta time), it would
213 // take over one second since the lower packet loss to achieve 108kbps. 215 // take over one second since the lower packet loss to achieve 108kbps.
214 bitrate_ = static_cast<uint32_t>( 216 bitrate_ = static_cast<uint32_t>(
215 min_bitrate_history_.front().second * 1.08 + 0.5); 217 min_bitrate_history_.front().second * 1.08 + 0.5);
216 218
217 // Add 1 kbps extra, just to make sure that we do not get stuck 219 // Add 1 kbps extra, just to make sure that we do not get stuck
218 // (gives a little extra increase at low rates, negligible at higher 220 // (gives a little extra increase at low rates, negligible at higher
219 // rates). 221 // rates).
220 bitrate_ += 1000; 222 bitrate_ += 1000;
221 223
222 if (event_log_) { 224 event_log_->LogBwePacketLossEvent(
223 event_log_->LogBwePacketLossEvent( 225 bitrate_, last_fraction_loss_,
224 bitrate_, last_fraction_loss_, 226 expected_packets_since_last_loss_update_);
225 expected_packets_since_last_loss_update_);
226 }
227 } else if (last_fraction_loss_ <= 26) { 227 } else if (last_fraction_loss_ <= 26) {
228 // Loss between 2% - 10%: Do nothing. 228 // Loss between 2% - 10%: Do nothing.
229 } else { 229 } else {
230 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + 230 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs +
231 // rtt. 231 // rtt.
232 if (!has_decreased_since_last_fraction_loss_ && 232 if (!has_decreased_since_last_fraction_loss_ &&
233 (now_ms - time_last_decrease_ms_) >= 233 (now_ms - time_last_decrease_ms_) >=
234 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { 234 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) {
235 time_last_decrease_ms_ = now_ms; 235 time_last_decrease_ms_ = now_ms;
236 236
237 // Reduce rate: 237 // Reduce rate:
238 // newRate = rate * (1 - 0.5*lossRate); 238 // newRate = rate * (1 - 0.5*lossRate);
239 // where packetLoss = 256*lossRate; 239 // where packetLoss = 256*lossRate;
240 bitrate_ = static_cast<uint32_t>( 240 bitrate_ = static_cast<uint32_t>(
241 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) / 241 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) /
242 512.0); 242 512.0);
243 has_decreased_since_last_fraction_loss_ = true; 243 has_decreased_since_last_fraction_loss_ = true;
244 } 244 }
245 if (event_log_) { 245 if (event_log_) {
stefan-webrtc 2016/03/21 13:25:48 Remove
ivoc 2016/03/22 13:44:55 Good catch, done.
246 event_log_->LogBwePacketLossEvent( 246 event_log_->LogBwePacketLossEvent(
247 bitrate_, last_fraction_loss_, 247 bitrate_, last_fraction_loss_,
248 expected_packets_since_last_loss_update_); 248 expected_packets_since_last_loss_update_);
249 } 249 }
250 } 250 }
251 } 251 }
252 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); 252 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_);
253 } 253 }
254 254
255 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { 255 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) { 293 now_ms - last_low_bitrate_log_ms_ > kLowBitrateLogPeriodMs) {
294 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 294 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000
295 << " kbps is below configured min bitrate " 295 << " kbps is below configured min bitrate "
296 << min_bitrate_configured_ / 1000 << " kbps."; 296 << min_bitrate_configured_ / 1000 << " kbps.";
297 last_low_bitrate_log_ms_ = now_ms; 297 last_low_bitrate_log_ms_ = now_ms;
298 } 298 }
299 bitrate = min_bitrate_configured_; 299 bitrate = min_bitrate_configured_;
300 } 300 }
301 return bitrate; 301 return bitrate;
302 } 302 }
303
304 void SendSideBandwidthEstimation::SetEventLog(RtcEventLog* event_log) {
305 event_log_ = event_log;
306 }
307
308 } // namespace webrtc 303 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698