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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 }; | 168 }; |
169 | 169 |
170 class IntervalBudget { | 170 class IntervalBudget { |
171 public: | 171 public: |
172 explicit IntervalBudget(int initial_target_rate_kbps) | 172 explicit IntervalBudget(int initial_target_rate_kbps) |
173 : target_rate_kbps_(initial_target_rate_kbps), | 173 : target_rate_kbps_(initial_target_rate_kbps), |
174 bytes_remaining_(0) {} | 174 bytes_remaining_(0) {} |
175 | 175 |
176 void set_target_rate_kbps(int target_rate_kbps) { | 176 void set_target_rate_kbps(int target_rate_kbps) { |
177 target_rate_kbps_ = target_rate_kbps; | 177 target_rate_kbps_ = target_rate_kbps; |
178 bytes_remaining_ = std::max(-500 * target_rate_kbps_ / 8, bytes_remaining_); | |
pbos-webrtc
2015/07/06 10:01:40
Named constants please.
stefan-webrtc
2015/07/06 10:54:25
Done.
| |
178 } | 179 } |
179 | 180 |
180 void IncreaseBudget(int64_t delta_time_ms) { | 181 void IncreaseBudget(int64_t delta_time_ms) { |
181 int64_t bytes = target_rate_kbps_ * delta_time_ms / 8; | 182 int64_t bytes = target_rate_kbps_ * delta_time_ms / 8; |
182 if (bytes_remaining_ < 0) { | 183 if (bytes_remaining_ < 0) { |
183 // We overused last interval, compensate this interval. | 184 // We overused last interval, compensate this interval. |
184 bytes_remaining_ = bytes_remaining_ + bytes; | 185 bytes_remaining_ = bytes_remaining_ + bytes; |
185 } else { | 186 } else { |
186 // If we underused last interval we can't use it this interval. | 187 // If we underused last interval we can't use it this interval. |
187 bytes_remaining_ = bytes; | 188 bytes_remaining_ = bytes; |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
402 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { | 403 void PacedSender::UpdateBytesPerInterval(int64_t delta_time_ms) { |
403 media_budget_->IncreaseBudget(delta_time_ms); | 404 media_budget_->IncreaseBudget(delta_time_ms); |
404 padding_budget_->IncreaseBudget(delta_time_ms); | 405 padding_budget_->IncreaseBudget(delta_time_ms); |
405 } | 406 } |
406 | 407 |
407 bool PacedSender::ProbingExperimentIsEnabled() const { | 408 bool PacedSender::ProbingExperimentIsEnabled() const { |
408 return webrtc::field_trial::FindFullName("WebRTC-BitrateProbing") == | 409 return webrtc::field_trial::FindFullName("WebRTC-BitrateProbing") == |
409 "Enabled"; | 410 "Enabled"; |
410 } | 411 } |
411 } // namespace webrtc | 412 } // namespace webrtc |
OLD | NEW |