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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 | 155 |
156 int64_t BitrateControllerImpl::TimeUntilNextProcess() { | 156 int64_t BitrateControllerImpl::TimeUntilNextProcess() { |
157 const int64_t kBitrateControllerUpdateIntervalMs = 25; | 157 const int64_t kBitrateControllerUpdateIntervalMs = 25; |
158 rtc::CritScope cs(&critsect_); | 158 rtc::CritScope cs(&critsect_); |
159 int64_t time_since_update_ms = | 159 int64_t time_since_update_ms = |
160 clock_->TimeInMilliseconds() - last_bitrate_update_ms_; | 160 clock_->TimeInMilliseconds() - last_bitrate_update_ms_; |
161 return std::max<int64_t>( | 161 return std::max<int64_t>( |
162 kBitrateControllerUpdateIntervalMs - time_since_update_ms, 0); | 162 kBitrateControllerUpdateIntervalMs - time_since_update_ms, 0); |
163 } | 163 } |
164 | 164 |
165 void BitrateControllerImpl::Process() { | 165 int32_t BitrateControllerImpl::Process() { |
166 if (TimeUntilNextProcess() > 0) | 166 if (TimeUntilNextProcess() > 0) |
167 return; | 167 return 0; |
168 { | 168 { |
169 rtc::CritScope cs(&critsect_); | 169 rtc::CritScope cs(&critsect_); |
170 bandwidth_estimation_.UpdateEstimate(clock_->TimeInMilliseconds()); | 170 bandwidth_estimation_.UpdateEstimate(clock_->TimeInMilliseconds()); |
171 } | 171 } |
172 MaybeTriggerOnNetworkChanged(); | 172 MaybeTriggerOnNetworkChanged(); |
173 last_bitrate_update_ms_ = clock_->TimeInMilliseconds(); | 173 last_bitrate_update_ms_ = clock_->TimeInMilliseconds(); |
| 174 return 0; |
174 } | 175 } |
175 | 176 |
176 void BitrateControllerImpl::OnReceivedRtcpReceiverReport( | 177 void BitrateControllerImpl::OnReceivedRtcpReceiverReport( |
177 uint8_t fraction_loss, | 178 uint8_t fraction_loss, |
178 int64_t rtt, | 179 int64_t rtt, |
179 int number_of_packets, | 180 int number_of_packets, |
180 int64_t now_ms) { | 181 int64_t now_ms) { |
181 { | 182 { |
182 rtc::CritScope cs(&critsect_); | 183 rtc::CritScope cs(&critsect_); |
183 bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt, | 184 bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 227 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
227 if (bitrate > 0) { | 228 if (bitrate > 0) { |
228 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 229 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
229 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 230 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
230 *bandwidth = bitrate; | 231 *bandwidth = bitrate; |
231 return true; | 232 return true; |
232 } | 233 } |
233 return false; | 234 return false; |
234 } | 235 } |
235 } // namespace webrtc | 236 } // namespace webrtc |
OLD | NEW |