OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 double avg_packet_size_bits = bits_per_frame / packets_per_frame; | 129 double avg_packet_size_bits = bits_per_frame / packets_per_frame; |
130 | 130 |
131 // Approximate the over-use estimator delay to 100 ms. | 131 // Approximate the over-use estimator delay to 100 ms. |
132 const int64_t response_time = in_experiment_ ? (rtt_ + 100) * 2 : rtt_ + 100; | 132 const int64_t response_time = in_experiment_ ? (rtt_ + 100) * 2 : rtt_ + 100; |
133 constexpr double kMinIncreaseRateBps = 4000; | 133 constexpr double kMinIncreaseRateBps = 4000; |
134 return static_cast<int>(std::max( | 134 return static_cast<int>(std::max( |
135 kMinIncreaseRateBps, (avg_packet_size_bits * 1000) / response_time)); | 135 kMinIncreaseRateBps, (avg_packet_size_bits * 1000) / response_time)); |
136 } | 136 } |
137 | 137 |
138 int AimdRateControl::GetExpectedBandwidthPeriodMs() const { | 138 int AimdRateControl::GetExpectedBandwidthPeriodMs() const { |
139 constexpr int kMinIntervalMs = 2000; | 139 constexpr int kMinPeriodMs = 2000; |
140 constexpr int kDefaultIntervalMs = 3000; | 140 constexpr int kDefaultPeriodMs = 3000; |
141 constexpr int kMaxIntervalMs = 50000; | 141 constexpr int kMaxPeriodMs = 50000; |
142 | 142 |
143 int increase_rate = GetNearMaxIncreaseRateBps(); | 143 int increase_rate = GetNearMaxIncreaseRateBps(); |
144 if (!last_decrease_) | 144 if (!last_decrease_) |
145 return kDefaultIntervalMs; | 145 return kDefaultPeriodMs; |
146 | 146 |
147 return std::min(kMaxIntervalMs, | 147 return std::min(kMaxPeriodMs, |
148 std::max<int>(1000 * static_cast<int64_t>(*last_decrease_) / | 148 std::max<int>(1000 * static_cast<int64_t>(*last_decrease_) / |
149 increase_rate, | 149 increase_rate, |
150 kMinIntervalMs)); | 150 kMinPeriodMs)); |
151 } | 151 } |
152 | 152 |
153 uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, | 153 uint32_t AimdRateControl::ChangeBitrate(uint32_t new_bitrate_bps, |
154 const RateControlInput& input, | 154 const RateControlInput& input, |
155 int64_t now_ms) { | 155 int64_t now_ms) { |
156 uint32_t incoming_bitrate_bps = | 156 uint32_t incoming_bitrate_bps = |
157 input.incoming_bitrate.value_or(current_bitrate_bps_); | 157 input.incoming_bitrate.value_or(current_bitrate_bps_); |
158 | 158 |
159 // An over-use should always trigger us to reduce the bitrate, even though | 159 // An over-use should always trigger us to reduce the bitrate, even though |
160 // we have not yet established our first estimate. By acting on the over-use, | 160 // we have not yet established our first estimate. By acting on the over-use, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 default: | 310 default: |
311 assert(false); | 311 assert(false); |
312 } | 312 } |
313 } | 313 } |
314 | 314 |
315 void AimdRateControl::ChangeRegion(RateControlRegion region) { | 315 void AimdRateControl::ChangeRegion(RateControlRegion region) { |
316 rate_control_region_ = region; | 316 rate_control_region_ = region; |
317 } | 317 } |
318 | 318 |
319 } // namespace webrtc | 319 } // namespace webrtc |
OLD | NEW |