| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 total_number_of_packets, now_ms); | 72 total_number_of_packets, now_ms); |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 std::map<uint32_t, uint32_t> ssrc_to_last_received_extended_high_seq_num_; | 76 std::map<uint32_t, uint32_t> ssrc_to_last_received_extended_high_seq_num_; |
| 77 BitrateControllerImpl* owner_; | 77 BitrateControllerImpl* owner_; |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 BitrateController* BitrateController::CreateBitrateController( | 80 BitrateController* BitrateController::CreateBitrateController( |
| 81 Clock* clock, | 81 Clock* clock, |
| 82 BitrateObserver* observer) { | 82 BitrateObserver* observer, |
| 83 return new BitrateControllerImpl(clock, observer); | 83 RtcEventLog* event_log) { |
| 84 return new BitrateControllerImpl(clock, observer, event_log); |
| 84 } | 85 } |
| 85 | 86 |
| 86 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, | 87 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, |
| 87 BitrateObserver* observer) | 88 BitrateObserver* observer, |
| 89 RtcEventLog* event_log) |
| 88 : clock_(clock), | 90 : clock_(clock), |
| 89 observer_(observer), | 91 observer_(observer), |
| 90 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), | 92 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), |
| 91 bandwidth_estimation_(), | 93 bandwidth_estimation_(event_log), |
| 92 reserved_bitrate_bps_(0), | 94 reserved_bitrate_bps_(0), |
| 93 last_bitrate_bps_(0), | 95 last_bitrate_bps_(0), |
| 94 last_fraction_loss_(0), | 96 last_fraction_loss_(0), |
| 95 last_rtt_ms_(0), | 97 last_rtt_ms_(0), |
| 96 last_reserved_bitrate_bps_(0) { | 98 last_reserved_bitrate_bps_(0) { |
| 97 // This calls the observer_, which means that the observer provided by the | 99 // This calls the observer_, which means that the observer provided by the |
| 98 // user must be ready to accept a bitrate update when it constructs the | 100 // user must be ready to accept a bitrate update when it constructs the |
| 99 // controller. We do this to avoid having to keep synchronized initial values | 101 // controller. We do this to avoid having to keep synchronized initial values |
| 100 // in both the controller and the allocator. | 102 // in both the controller and the allocator. |
| 101 MaybeTriggerOnNetworkChanged(); | 103 MaybeTriggerOnNetworkChanged(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 123 } | 125 } |
| 124 | 126 |
| 125 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { | 127 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { |
| 126 { | 128 { |
| 127 rtc::CritScope cs(&critsect_); | 129 rtc::CritScope cs(&critsect_); |
| 128 reserved_bitrate_bps_ = reserved_bitrate_bps; | 130 reserved_bitrate_bps_ = reserved_bitrate_bps; |
| 129 } | 131 } |
| 130 MaybeTriggerOnNetworkChanged(); | 132 MaybeTriggerOnNetworkChanged(); |
| 131 } | 133 } |
| 132 | 134 |
| 133 void BitrateControllerImpl::SetEventLog(RtcEventLog* event_log) { | |
| 134 rtc::CritScope cs(&critsect_); | |
| 135 bandwidth_estimation_.SetEventLog(event_log); | |
| 136 } | |
| 137 | |
| 138 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { | 135 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { |
| 139 { | 136 { |
| 140 rtc::CritScope cs(&critsect_); | 137 rtc::CritScope cs(&critsect_); |
| 141 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), | 138 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), |
| 142 bitrate); | 139 bitrate); |
| 143 } | 140 } |
| 144 MaybeTriggerOnNetworkChanged(); | 141 MaybeTriggerOnNetworkChanged(); |
| 145 } | 142 } |
| 146 | 143 |
| 147 void BitrateControllerImpl::UpdateDelayBasedEstimate(uint32_t bitrate_bps) { | 144 void BitrateControllerImpl::UpdateDelayBasedEstimate(uint32_t bitrate_bps) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 223 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
| 227 if (bitrate > 0) { | 224 if (bitrate > 0) { |
| 228 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 225 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
| 229 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 226 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
| 230 *bandwidth = bitrate; | 227 *bandwidth = bitrate; |
| 231 return true; | 228 return true; |
| 232 } | 229 } |
| 233 return false; | 230 return false; |
| 234 } | 231 } |
| 235 } // namespace webrtc | 232 } // namespace webrtc |
| OLD | NEW |