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 BitrateController* BitrateController::CreateBitrateController(Clock* clock) { | 87 BitrateController* BitrateController::CreateBitrateController( |
87 return new BitrateControllerImpl(clock, nullptr); | 88 Clock* clock, |
| 89 RtcEventLog* event_log) { |
| 90 return CreateBitrateController(clock, nullptr, event_log); |
88 } | 91 } |
89 | 92 |
90 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, | 93 BitrateControllerImpl::BitrateControllerImpl(Clock* clock, |
91 BitrateObserver* observer) | 94 BitrateObserver* observer, |
| 95 RtcEventLog* event_log) |
92 : clock_(clock), | 96 : clock_(clock), |
93 observer_(observer), | 97 observer_(observer), |
94 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), | 98 last_bitrate_update_ms_(clock_->TimeInMilliseconds()), |
95 bandwidth_estimation_(), | 99 event_log_(event_log), |
| 100 bandwidth_estimation_(event_log), |
96 reserved_bitrate_bps_(0), | 101 reserved_bitrate_bps_(0), |
97 last_bitrate_bps_(0), | 102 last_bitrate_bps_(0), |
98 last_fraction_loss_(0), | 103 last_fraction_loss_(0), |
99 last_rtt_ms_(0), | 104 last_rtt_ms_(0), |
100 last_reserved_bitrate_bps_(0) { | 105 last_reserved_bitrate_bps_(0) { |
101 // This calls the observer_ if set, which means that the observer provided by | 106 // This calls the observer_ if set, which means that the observer provided by |
102 // the user must be ready to accept a bitrate update when it constructs the | 107 // the user must be ready to accept a bitrate update when it constructs the |
103 // controller. We do this to avoid having to keep synchronized initial values | 108 // controller. We do this to avoid having to keep synchronized initial values |
104 // in both the controller and the allocator. | 109 // in both the controller and the allocator. |
105 MaybeTriggerOnNetworkChanged(); | 110 MaybeTriggerOnNetworkChanged(); |
(...skipping 30 matching lines...) Expand all Loading... |
136 max_bitrate_bps); | 141 max_bitrate_bps); |
137 } | 142 } |
138 MaybeTriggerOnNetworkChanged(); | 143 MaybeTriggerOnNetworkChanged(); |
139 } | 144 } |
140 | 145 |
141 void BitrateControllerImpl::ResetBitrates(int bitrate_bps, | 146 void BitrateControllerImpl::ResetBitrates(int bitrate_bps, |
142 int min_bitrate_bps, | 147 int min_bitrate_bps, |
143 int max_bitrate_bps) { | 148 int max_bitrate_bps) { |
144 { | 149 { |
145 rtc::CritScope cs(&critsect_); | 150 rtc::CritScope cs(&critsect_); |
146 bandwidth_estimation_ = SendSideBandwidthEstimation(); | 151 bandwidth_estimation_ = SendSideBandwidthEstimation(event_log_); |
147 bandwidth_estimation_.SetBitrates(bitrate_bps, min_bitrate_bps, | 152 bandwidth_estimation_.SetBitrates(bitrate_bps, min_bitrate_bps, |
148 max_bitrate_bps); | 153 max_bitrate_bps); |
149 } | 154 } |
150 MaybeTriggerOnNetworkChanged(); | 155 MaybeTriggerOnNetworkChanged(); |
151 } | 156 } |
152 | 157 |
153 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { | 158 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { |
154 { | 159 { |
155 rtc::CritScope cs(&critsect_); | 160 rtc::CritScope cs(&critsect_); |
156 reserved_bitrate_bps_ = reserved_bitrate_bps; | 161 reserved_bitrate_bps_ = reserved_bitrate_bps; |
157 } | 162 } |
158 MaybeTriggerOnNetworkChanged(); | 163 MaybeTriggerOnNetworkChanged(); |
159 } | 164 } |
160 | 165 |
161 void BitrateControllerImpl::SetEventLog(RtcEventLog* event_log) { | |
162 rtc::CritScope cs(&critsect_); | |
163 bandwidth_estimation_.SetEventLog(event_log); | |
164 } | |
165 | |
166 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { | 166 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { |
167 { | 167 { |
168 rtc::CritScope cs(&critsect_); | 168 rtc::CritScope cs(&critsect_); |
169 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), | 169 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), |
170 bitrate); | 170 bitrate); |
171 } | 171 } |
172 MaybeTriggerOnNetworkChanged(); | 172 MaybeTriggerOnNetworkChanged(); |
173 } | 173 } |
174 | 174 |
175 void BitrateControllerImpl::UpdateDelayBasedEstimate(uint32_t bitrate_bps) { | 175 void BitrateControllerImpl::UpdateDelayBasedEstimate(uint32_t bitrate_bps) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 258 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
259 if (bitrate > 0) { | 259 if (bitrate > 0) { |
260 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 260 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
261 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 261 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
262 *bandwidth = bitrate; | 262 *bandwidth = bitrate; |
263 return true; | 263 return true; |
264 } | 264 } |
265 return false; | 265 return false; |
266 } | 266 } |
267 } // namespace webrtc | 267 } // namespace webrtc |
OLD | NEW |