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 |
11 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" | 11 #include "webrtc/modules/bitrate_controller/send_side_bandwidth_estimation.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <cmath> | 14 #include <cmath> |
15 | 15 |
16 #include "webrtc/base/checks.h" | 16 #include "webrtc/base/checks.h" |
17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 18 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| 19 #include "webrtc/modules/congestion_controller/include/defines.h" |
19 #include "webrtc/system_wrappers/include/field_trial.h" | 20 #include "webrtc/system_wrappers/include/field_trial.h" |
20 #include "webrtc/system_wrappers/include/metrics.h" | 21 #include "webrtc/system_wrappers/include/metrics.h" |
21 | 22 |
22 namespace webrtc { | 23 namespace webrtc { |
23 namespace { | 24 namespace { |
24 const int64_t kBweIncreaseIntervalMs = 1000; | 25 const int64_t kBweIncreaseIntervalMs = 1000; |
25 const int64_t kBweDecreaseIntervalMs = 300; | 26 const int64_t kBweDecreaseIntervalMs = 300; |
26 const int64_t kStartPhaseMs = 2000; | 27 const int64_t kStartPhaseMs = 2000; |
27 const int64_t kBweConverganceTimeMs = 20000; | 28 const int64_t kBweConverganceTimeMs = 20000; |
28 const int kLimitNumPackets = 20; | 29 const int kLimitNumPackets = 20; |
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 const int64_t kRtcEventLogPeriodMs = 5000; |
33 // Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals. | 33 // Expecting that RTCP feedback is sent uniformly within [0.5, 1.5]s intervals. |
34 const int64_t kFeedbackIntervalMs = 1500; | 34 const int64_t kFeedbackIntervalMs = 1500; |
35 const int64_t kFeedbackTimeoutIntervals = 3; | 35 const int64_t kFeedbackTimeoutIntervals = 3; |
36 const int64_t kTimeoutIntervalMs = 1000; | 36 const int64_t kTimeoutIntervalMs = 1000; |
37 | 37 |
38 struct UmaRampUpMetric { | 38 struct UmaRampUpMetric { |
39 const char* metric_name; | 39 const char* metric_name; |
40 int bitrate_kbps; | 40 int bitrate_kbps; |
41 }; | 41 }; |
42 | 42 |
43 const UmaRampUpMetric kUmaRampupMetrics[] = { | 43 const UmaRampUpMetric kUmaRampupMetrics[] = { |
44 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, | 44 {"WebRTC.BWE.RampUpTimeTo500kbpsInMs", 500}, |
45 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, | 45 {"WebRTC.BWE.RampUpTimeTo1000kbpsInMs", 1000}, |
46 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; | 46 {"WebRTC.BWE.RampUpTimeTo2000kbpsInMs", 2000}}; |
47 const size_t kNumUmaRampupMetrics = | 47 const size_t kNumUmaRampupMetrics = |
48 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]); | 48 sizeof(kUmaRampupMetrics) / sizeof(kUmaRampupMetrics[0]); |
49 | 49 |
50 } // namespace | 50 } // namespace |
51 | 51 |
52 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) | 52 SendSideBandwidthEstimation::SendSideBandwidthEstimation(RtcEventLog* event_log) |
53 : lost_packets_since_last_loss_update_Q8_(0), | 53 : lost_packets_since_last_loss_update_Q8_(0), |
54 expected_packets_since_last_loss_update_(0), | 54 expected_packets_since_last_loss_update_(0), |
55 bitrate_(0), | 55 bitrate_(0), |
56 min_bitrate_configured_(kDefaultMinBitrateBps), | 56 min_bitrate_configured_(congestion_controller::kMinBitrateBps), |
57 max_bitrate_configured_(kDefaultMaxBitrateBps), | 57 max_bitrate_configured_(kDefaultMaxBitrateBps), |
58 last_low_bitrate_log_ms_(-1), | 58 last_low_bitrate_log_ms_(-1), |
59 has_decreased_since_last_fraction_loss_(false), | 59 has_decreased_since_last_fraction_loss_(false), |
60 last_feedback_ms_(-1), | 60 last_feedback_ms_(-1), |
61 last_packet_report_ms_(-1), | 61 last_packet_report_ms_(-1), |
62 last_timeout_ms_(-1), | 62 last_timeout_ms_(-1), |
63 last_fraction_loss_(0), | 63 last_fraction_loss_(0), |
64 last_logged_fraction_loss_(0), | 64 last_logged_fraction_loss_(0), |
65 last_round_trip_time_ms_(0), | 65 last_round_trip_time_ms_(0), |
66 bwe_incoming_(0), | 66 bwe_incoming_(0), |
(...skipping 26 matching lines...) Expand all Loading... |
93 bitrate_ = bitrate; | 93 bitrate_ = bitrate; |
94 | 94 |
95 // Clear last sent bitrate history so the new value can be used directly | 95 // Clear last sent bitrate history so the new value can be used directly |
96 // and not capped. | 96 // and not capped. |
97 min_bitrate_history_.clear(); | 97 min_bitrate_history_.clear(); |
98 } | 98 } |
99 | 99 |
100 void SendSideBandwidthEstimation::SetMinMaxBitrate(int min_bitrate, | 100 void SendSideBandwidthEstimation::SetMinMaxBitrate(int min_bitrate, |
101 int max_bitrate) { | 101 int max_bitrate) { |
102 RTC_DCHECK_GE(min_bitrate, 0); | 102 RTC_DCHECK_GE(min_bitrate, 0); |
103 min_bitrate_configured_ = std::max(min_bitrate, kDefaultMinBitrateBps); | 103 min_bitrate_configured_ = |
| 104 std::max(min_bitrate, congestion_controller::kMinBitrateBps); |
104 if (max_bitrate > 0) { | 105 if (max_bitrate > 0) { |
105 max_bitrate_configured_ = | 106 max_bitrate_configured_ = |
106 std::max<uint32_t>(min_bitrate_configured_, max_bitrate); | 107 std::max<uint32_t>(min_bitrate_configured_, max_bitrate); |
107 } else { | 108 } else { |
108 max_bitrate_configured_ = kDefaultMaxBitrateBps; | 109 max_bitrate_configured_ = kDefaultMaxBitrateBps; |
109 } | 110 } |
110 } | 111 } |
111 | 112 |
112 int SendSideBandwidthEstimation::GetMinBitrate() const { | 113 int SendSideBandwidthEstimation::GetMinBitrate() const { |
113 return min_bitrate_configured_; | 114 return min_bitrate_configured_; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 | 336 LOG(LS_WARNING) << "Estimated available bandwidth " << bitrate / 1000 |
336 << " kbps is below configured min bitrate " | 337 << " kbps is below configured min bitrate " |
337 << min_bitrate_configured_ / 1000 << " kbps."; | 338 << min_bitrate_configured_ / 1000 << " kbps."; |
338 last_low_bitrate_log_ms_ = now_ms; | 339 last_low_bitrate_log_ms_ = now_ms; |
339 } | 340 } |
340 bitrate = min_bitrate_configured_; | 341 bitrate = min_bitrate_configured_; |
341 } | 342 } |
342 return bitrate; | 343 return bitrate; |
343 } | 344 } |
344 } // namespace webrtc | 345 } // namespace webrtc |
OLD | NEW |