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 int32_t BitrateControllerImpl::Process() { | 165 void BitrateControllerImpl::Process() { |
166 if (TimeUntilNextProcess() > 0) | 166 if (TimeUntilNextProcess() > 0) |
167 return 0; | 167 return; |
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; | |
175 } | 174 } |
176 | 175 |
177 void BitrateControllerImpl::OnReceivedRtcpReceiverReport( | 176 void BitrateControllerImpl::OnReceivedRtcpReceiverReport( |
178 uint8_t fraction_loss, | 177 uint8_t fraction_loss, |
179 int64_t rtt, | 178 int64_t rtt, |
180 int number_of_packets, | 179 int number_of_packets, |
181 int64_t now_ms) { | 180 int64_t now_ms) { |
182 { | 181 { |
183 rtc::CritScope cs(&critsect_); | 182 rtc::CritScope cs(&critsect_); |
184 bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt, | 183 bandwidth_estimation_.UpdateReceiverBlock(fraction_loss, rtt, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 226 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
228 if (bitrate > 0) { | 227 if (bitrate > 0) { |
229 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 228 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
230 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 229 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
231 *bandwidth = bitrate; | 230 *bandwidth = bitrate; |
232 return true; | 231 return true; |
233 } | 232 } |
234 return false; | 233 return false; |
235 } | 234 } |
236 } // namespace webrtc | 235 } // namespace webrtc |
OLD | NEW |