Chromium Code Reviews| 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 11 matching lines...) Expand all Loading... | |
| 22 namespace webrtc { | 22 namespace webrtc { |
| 23 namespace { | 23 namespace { |
| 24 const int64_t kBweIncreaseIntervalMs = 1000; | 24 const int64_t kBweIncreaseIntervalMs = 1000; |
| 25 const int64_t kBweDecreaseIntervalMs = 300; | 25 const int64_t kBweDecreaseIntervalMs = 300; |
| 26 const int64_t kStartPhaseMs = 2000; | 26 const int64_t kStartPhaseMs = 2000; |
| 27 const int64_t kBweConverganceTimeMs = 20000; | 27 const int64_t kBweConverganceTimeMs = 20000; |
| 28 const int kLimitNumPackets = 20; | 28 const int kLimitNumPackets = 20; |
| 29 const int kDefaultMinBitrateBps = 10000; | 29 const int kDefaultMinBitrateBps = 10000; |
| 30 const int kDefaultMaxBitrateBps = 1000000000; | 30 const int kDefaultMaxBitrateBps = 1000000000; |
| 31 const int64_t kLowBitrateLogPeriodMs = 10000; | 31 const int64_t kLowBitrateLogPeriodMs = 10000; |
| 32 const int64_t kRtcEventLogPeriodMs = 5000; | |
| 32 | 33 |
| 33 struct UmaRampUpMetric { | 34 struct UmaRampUpMetric { |
| 34 const char* metric_name; | 35 const char* metric_name; |
| 35 int bitrate_kbps; | 36 int bitrate_kbps; |
| 36 }; | 37 }; |
| 37 | 38 |
| 38 const UmaRampUpMetric kUmaRampupMetrics[] = { | 39 const UmaRampUpMetric kUmaRampupMetrics[] = { |
| 39 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, | 40 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, |
| 40 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, | 41 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, |
| 41 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; | 42 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 56 last_fraction_loss_(0), | 57 last_fraction_loss_(0), |
| 57 last_round_trip_time_ms_(0), | 58 last_round_trip_time_ms_(0), |
| 58 bwe_incoming_(0), | 59 bwe_incoming_(0), |
| 59 delay_based_bitrate_bps_(0), | 60 delay_based_bitrate_bps_(0), |
| 60 time_last_decrease_ms_(0), | 61 time_last_decrease_ms_(0), |
| 61 first_report_time_ms_(-1), | 62 first_report_time_ms_(-1), |
| 62 initially_lost_packets_(0), | 63 initially_lost_packets_(0), |
| 63 bitrate_at_2_seconds_kbps_(0), | 64 bitrate_at_2_seconds_kbps_(0), |
| 64 uma_update_state_(kNoUpdate), | 65 uma_update_state_(kNoUpdate), |
| 65 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), | 66 rampup_uma_stats_updated_(kNumUmaRampupMetrics, false), |
| 66 event_log_(event_log) { | 67 event_log_(event_log), |
| 68 last_rtc_event_log_ms_(-1) { | |
| 67 RTC_DCHECK(event_log); | 69 RTC_DCHECK(event_log); |
| 68 } | 70 } |
| 69 | 71 |
| 70 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} | 72 SendSideBandwidthEstimation::~SendSideBandwidthEstimation() {} |
| 71 | 73 |
| 72 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate, | 74 void SendSideBandwidthEstimation::SetBitrates(int send_bitrate, |
| 73 int min_bitrate, | 75 int min_bitrate, |
| 74 int max_bitrate) { | 76 int max_bitrate) { |
| 75 if (send_bitrate > 0) | 77 if (send_bitrate > 0) |
| 76 SetSendBitrate(send_bitrate); | 78 SetSendBitrate(send_bitrate); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 // whenever a receiver report is received with lower packet loss. | 223 // whenever a receiver report is received with lower packet loss. |
| 222 // If instead one would do: bitrate_ *= 1.08^(delta time), it would | 224 // If instead one would do: bitrate_ *= 1.08^(delta time), it would |
| 223 // take over one second since the lower packet loss to achieve 108kbps. | 225 // take over one second since the lower packet loss to achieve 108kbps. |
| 224 bitrate_ = static_cast<uint32_t>( | 226 bitrate_ = static_cast<uint32_t>( |
| 225 min_bitrate_history_.front().second * 1.08 + 0.5); | 227 min_bitrate_history_.front().second * 1.08 + 0.5); |
| 226 | 228 |
| 227 // Add 1 kbps extra, just to make sure that we do not get stuck | 229 // Add 1 kbps extra, just to make sure that we do not get stuck |
| 228 // (gives a little extra increase at low rates, negligible at higher | 230 // (gives a little extra increase at low rates, negligible at higher |
| 229 // rates). | 231 // rates). |
| 230 bitrate_ += 1000; | 232 bitrate_ += 1000; |
| 231 | |
| 232 event_log_->LogBwePacketLossEvent( | |
| 233 bitrate_, last_fraction_loss_, | |
| 234 expected_packets_since_last_loss_update_); | |
| 235 } else if (last_fraction_loss_ <= 26) { | 233 } else if (last_fraction_loss_ <= 26) { |
| 236 // Loss between 2% - 10%: Do nothing. | 234 // Loss between 2% - 10%: Do nothing. |
| 237 } else { | 235 } else { |
| 238 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + | 236 // Loss > 10%: Limit the rate decreases to once a kBweDecreaseIntervalMs + |
| 239 // rtt. | 237 // rtt. |
| 240 if (!has_decreased_since_last_fraction_loss_ && | 238 if (!has_decreased_since_last_fraction_loss_ && |
| 241 (now_ms - time_last_decrease_ms_) >= | 239 (now_ms - time_last_decrease_ms_) >= |
| 242 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { | 240 (kBweDecreaseIntervalMs + last_round_trip_time_ms_)) { |
| 243 time_last_decrease_ms_ = now_ms; | 241 time_last_decrease_ms_ = now_ms; |
| 244 | 242 |
| 245 // Reduce rate: | 243 // Reduce rate: |
| 246 // newRate = rate * (1 - 0.5*lossRate); | 244 // newRate = rate * (1 - 0.5*lossRate); |
| 247 // where packetLoss = 256*lossRate; | 245 // where packetLoss = 256*lossRate; |
| 248 bitrate_ = static_cast<uint32_t>( | 246 bitrate_ = static_cast<uint32_t>( |
| 249 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) / | 247 (bitrate_ * static_cast<double>(512 - last_fraction_loss_)) / |
| 250 512.0); | 248 512.0); |
| 251 has_decreased_since_last_fraction_loss_ = true; | 249 has_decreased_since_last_fraction_loss_ = true; |
| 252 } | 250 } |
| 253 event_log_->LogBwePacketLossEvent( | |
| 254 bitrate_, last_fraction_loss_, | |
| 255 expected_packets_since_last_loss_update_); | |
| 256 } | 251 } |
| 257 } | 252 } |
| 258 bitrate_ = CapBitrateToThresholds(now_ms, bitrate_); | 253 uint32_t capped_bitrate = CapBitrateToThresholds(now_ms, bitrate_); |
| 254 if (capped_bitrate != bitrate_ || last_fraction_loss_ > 0 || | |
|
philipel
2016/09/02 11:26:07
Maybe add the same type of logic to fraction loss,
stefan-webrtc
2016/09/02 13:13:17
Done.
| |
| 255 last_rtc_event_log_ms_ == -1 || | |
| 256 now_ms - last_rtc_event_log_ms_ > kRtcEventLogPeriodMs) { | |
| 257 event_log_->LogBwePacketLossEvent(capped_bitrate, last_fraction_loss_, | |
| 258 expected_packets_since_last_loss_update_); | |
| 259 last_rtc_event_log_ms_ = now_ms; | |
| 260 } | |
| 261 bitrate_ = capped_bitrate; | |
| 259 } | 262 } |
| 260 | 263 |
| 261 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { | 264 bool SendSideBandwidthEstimation::IsInStartPhase(int64_t now_ms) const { |
| 262 return first_report_time_ms_ == -1 || | 265 return first_report_time_ms_ == -1 || |
| 263 now_ms - first_report_time_ms_ < kStartPhaseMs; | 266 now_ms - first_report_time_ms_ < kStartPhaseMs; |
| 264 } | 267 } |
| 265 | 268 |
| 266 void SendSideBandwidthEstimation::UpdateMinHistory(int64_t now_ms) { | 269 void SendSideBandwidthEstimation::UpdateMinHistory(int64_t now_ms) { |
| 267 // Remove old data points from history. | 270 // Remove old data points from history. |
| 268 // Since history precision is in ms, add one so it is able to increase | 271 // Since history precision is in ms, add one so it is able to increase |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 | 303 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 |
| 301 << " kbps is below configured min bitrate " | 304 << " kbps is below configured min bitrate " |
| 302 << min_bitrate_configured_ / 1000 << " kbps."; | 305 << min_bitrate_configured_ / 1000 << " kbps."; |
| 303 last_low_bitrate_log_ms_ = now_ms; | 306 last_low_bitrate_log_ms_ = now_ms; |
| 304 } | 307 } |
| 305 bitrate = min_bitrate_configured_; | 308 bitrate = min_bitrate_configured_; |
| 306 } | 309 } |
| 307 return bitrate; | 310 return bitrate; |
| 308 } | 311 } |
| 309 } // namespace webrtc | 312 } // namespace webrtc |
| OLD | NEW |