OLD | NEW |
---|---|
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 Loading... | |
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 | 67 |
68 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} | 68 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} |
69 | 69 |
70 void SendSideBandwidthEstimation::SetSendBitrate(int bitrate) { | 70 void SendSideBandwidthEstimation::SetSendBitrate(int bitrate) { |
71 RTC_DCHECK_GT(bitrate, 0); | 71 RTC_DCHECK_GT(bitrate, 0); |
72 bitrate_ = bitrate; | 72 bitrate_ = bitrate; |
73 | 73 |
74 // Clear last sent bitrate history so the new value can be used directly | 74 // Clear last sent bitrate history so the new value can be used directly |
75 // and not capped. | 75 // and not capped. |
76 min_bitrate_history_.clear(); | 76 min_bitrate_history_.clear(); |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 // If instead one would do: bitrate_ *= 1.08^(delta time), it would | 212 // 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. | 213 // take over one second since the lower packet loss to achieve 108kbps. |
214 bitrate_ = static_cast<uint32_t>( | 214 bitrate_ = static_cast<uint32_t>( |
215 min_bitrate_history_.front().second * 1.08 + 0.5); | 215 min_bitrate_history_.front().second * 1.08 + 0.5); |
216 | 216 |
217 // Add 1 kbps extra, just to make sure that we do not get stuck | 217 // 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 | 218 // (gives a little extra increase at low rates, negligible at higher |
219 // rates). | 219 // rates). |
220 bitrate_ += 1000; | 220 bitrate_ += 1000; |
221 | 221 |
222 if (event_log_) { | 222 if (event_log_) { |
stefan-webrtc
2016/03/11 10:11:53
I guess we can remove these ifs now that we always
ivoc
2016/03/16 17:00:32
I guess that makes sense, I can add a DCHECK in th
| |
223 event_log_->LogBwePacketLossEvent( | 223 event_log_->LogBwePacketLossEvent( |
224 bitrate_, last_fraction_loss_, | 224 bitrate_, last_fraction_loss_, |
225 expected_packets_since_last_loss_update_); | 225 expected_packets_since_last_loss_update_); |
226 } | 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_ && |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 |
OLD | NEW |