Chromium Code Reviews| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 | 70 |
| 71 owner_->OnReceivedRtcpReceiverReport(fraction_lost_aggregate, rtt, | 71 owner_->OnReceivedRtcpReceiverReport(fraction_lost_aggregate, rtt, |
| 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( |
|
the sun
2016/03/21 13:03:08
Can you ditch this Create method and just have the
ivoc
2016/03/22 13:44:55
Stefan suggested that I should mark this one as de
| |
| 81 Clock* clock, | 81 Clock* clock, |
| 82 BitrateObserver* observer) { | 82 BitrateObserver* observer) { |
| 83 return new BitrateControllerImpl(clock, observer); | 83 return CreateBitrateController(clock, observer, nullptr); |
| 84 } | |
| 85 | |
| 86 BitrateController* BitrateController::CreateBitrateController( | |
| 87 Clock* clock, | |
| 88 BitrateObserver* observer, | |
| 89 RtcEventLog* event_log) { | |
| 90 return new BitrateControllerImpl(clock, observer, event_log); | |
| 84 } | 91 } |
| 85 | 92 |
| 86 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, | 93 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, |
| 87 BitrateObserver* observer) | 94 BitrateObserver* observer, |
| 95 RtcEventLog* event_log) | |
| 88 : clock_(clock), | 96 : clock_(clock), |
| 89 observer_(observer), | 97 observer_(observer), |
| 90 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), | 98 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), |
| 91 bandwidth_estimation_(), | 99 bandwidth_estimation_(event_log), |
| 92 reserved_bitrate_bps_(0), | 100 reserved_bitrate_bps_(0), |
| 93 last_bitrate_bps_(0), | 101 last_bitrate_bps_(0), |
| 94 last_fraction_loss_(0), | 102 last_fraction_loss_(0), |
| 95 last_rtt_ms_(0), | 103 last_rtt_ms_(0), |
| 96 last_reserved_bitrate_bps_(0) { | 104 last_reserved_bitrate_bps_(0) { |
| 97 // This calls the observer_, which means that the observer provided by the | 105 // 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 | 106 // 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 | 107 // controller. We do this to avoid having to keep synchronized initial values |
| 100 // in both the controller and the allocator. | 108 // in both the controller and the allocator. |
| 101 MaybeTriggerOnNetworkChanged(); | 109 MaybeTriggerOnNetworkChanged(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 123 } | 131 } |
| 124 | 132 |
| 125 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { | 133 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { |
| 126 { | 134 { |
| 127 rtc::CritScope cs(&critsect_); | 135 rtc::CritScope cs(&critsect_); |
| 128 reserved_bitrate_bps_ = reserved_bitrate_bps; | 136 reserved_bitrate_bps_ = reserved_bitrate_bps; |
| 129 } | 137 } |
| 130 MaybeTriggerOnNetworkChanged(); | 138 MaybeTriggerOnNetworkChanged(); |
| 131 } | 139 } |
| 132 | 140 |
| 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) { | 141 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { |
| 139 { | 142 { |
| 140 rtc::CritScope cs(&critsect_); | 143 rtc::CritScope cs(&critsect_); |
| 141 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), | 144 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), |
| 142 bitrate); | 145 bitrate); |
| 143 } | 146 } |
| 144 MaybeTriggerOnNetworkChanged(); | 147 MaybeTriggerOnNetworkChanged(); |
| 145 } | 148 } |
| 146 | 149 |
| 147 void BitrateControllerImpl::UpdateDelayBasedEstimate(uint32_t bitrate_bps) { | 150 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); | 229 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
| 227 if (bitrate > 0) { | 230 if (bitrate > 0) { |
| 228 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 231 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
| 229 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 232 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
| 230 *bandwidth = bitrate; | 233 *bandwidth = bitrate; |
| 231 return true; | 234 return true; |
| 232 } | 235 } |
| 233 return false; | 236 return false; |
| 234 } | 237 } |
| 235 } // namespace webrtc | 238 } // namespace webrtc |
| OLD | NEW |