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 13 matching lines...) Expand all Loading... |
24 class BitrateControllerImpl::RtcpBandwidthObserverImpl | 24 class BitrateControllerImpl::RtcpBandwidthObserverImpl |
25 : public RtcpBandwidthObserver { | 25 : public RtcpBandwidthObserver { |
26 public: | 26 public: |
27 explicit RtcpBandwidthObserverImpl(BitrateControllerImpl* owner) | 27 explicit RtcpBandwidthObserverImpl(BitrateControllerImpl* owner) |
28 : owner_(owner) { | 28 : owner_(owner) { |
29 } | 29 } |
30 virtual ~RtcpBandwidthObserverImpl() { | 30 virtual ~RtcpBandwidthObserverImpl() { |
31 } | 31 } |
32 // Received RTCP REMB or TMMBR. | 32 // Received RTCP REMB or TMMBR. |
33 void OnReceivedEstimatedBitrate(uint32_t bitrate) override { | 33 void OnReceivedEstimatedBitrate(uint32_t bitrate) override { |
34 owner_->OnReceivedEstimatedBitrate(bitrate); | 34 owner_->OnReceiverEstimatedBitrate(bitrate); |
35 } | 35 } |
36 // Received RTCP receiver block. | 36 // Received RTCP receiver block. |
37 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks, | 37 void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks, |
38 int64_t rtt, | 38 int64_t rtt, |
39 int64_t now_ms) override { | 39 int64_t now_ms) override { |
40 if (report_blocks.empty()) | 40 if (report_blocks.empty()) |
41 return; | 41 return; |
42 | 42 |
43 int fraction_lost_aggregate = 0; | 43 int fraction_lost_aggregate = 0; |
44 int total_number_of_packets = 0; | 44 int total_number_of_packets = 0; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 166 } |
167 | 167 |
168 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { | 168 void BitrateControllerImpl::SetReservedBitrate(uint32_t reserved_bitrate_bps) { |
169 { | 169 { |
170 rtc::CritScope cs(&critsect_); | 170 rtc::CritScope cs(&critsect_); |
171 reserved_bitrate_bps_ = reserved_bitrate_bps; | 171 reserved_bitrate_bps_ = reserved_bitrate_bps; |
172 } | 172 } |
173 MaybeTriggerOnNetworkChanged(); | 173 MaybeTriggerOnNetworkChanged(); |
174 } | 174 } |
175 | 175 |
176 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { | 176 // This is called upon reception of REMB or TMMBR. |
| 177 void BitrateControllerImpl::OnReceiverEstimatedBitrate(uint32_t bitrate) { |
177 { | 178 { |
178 rtc::CritScope cs(&critsect_); | 179 rtc::CritScope cs(&critsect_); |
179 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), | 180 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), |
180 bitrate); | 181 bitrate); |
181 } | 182 } |
182 MaybeTriggerOnNetworkChanged(); | 183 MaybeTriggerOnNetworkChanged(); |
183 } | 184 } |
184 | 185 |
185 void BitrateControllerImpl::UpdateProbeBitrate(uint32_t bitrate_bps) { | 186 void BitrateControllerImpl::OnProbeBitrate(uint32_t bitrate_bps) { |
186 { | 187 { |
187 rtc::CritScope cs(&critsect_); | 188 rtc::CritScope cs(&critsect_); |
188 bandwidth_estimation_.SetSendBitrate(bitrate_bps); | 189 bandwidth_estimation_.SetSendBitrate(bitrate_bps); |
189 } | 190 } |
190 MaybeTriggerOnNetworkChanged(); | 191 MaybeTriggerOnNetworkChanged(); |
191 } | 192 } |
192 | 193 |
193 void BitrateControllerImpl::UpdateDelayBasedEstimate(uint32_t bitrate_bps) { | 194 // TODO(isheriff): Perhaps need new interface for invocation from DelayBasedBwe. |
| 195 void BitrateControllerImpl::OnReceiveBitrateChanged( |
| 196 const std::vector<uint32_t>& ssrcs, |
| 197 uint32_t bitrate_bps) { |
194 { | 198 { |
195 rtc::CritScope cs(&critsect_); | 199 rtc::CritScope cs(&critsect_); |
196 bandwidth_estimation_.UpdateDelayBasedEstimate(clock_->TimeInMilliseconds(), | 200 bandwidth_estimation_.UpdateDelayBasedEstimate(clock_->TimeInMilliseconds(), |
197 bitrate_bps); | 201 bitrate_bps); |
198 } | 202 } |
199 MaybeTriggerOnNetworkChanged(); | 203 MaybeTriggerOnNetworkChanged(); |
200 } | 204 } |
201 | 205 |
202 int64_t BitrateControllerImpl::TimeUntilNextProcess() { | 206 int64_t BitrateControllerImpl::TimeUntilNextProcess() { |
203 const int64_t kBitrateControllerUpdateIntervalMs = 25; | 207 const int64_t kBitrateControllerUpdateIntervalMs = 25; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 280 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
277 if (bitrate > 0) { | 281 if (bitrate > 0) { |
278 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 282 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
279 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 283 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
280 *bandwidth = bitrate; | 284 *bandwidth = bitrate; |
281 return true; | 285 return true; |
282 } | 286 } |
283 return false; | 287 return false; |
284 } | 288 } |
285 } // namespace webrtc | 289 } // namespace webrtc |
OLD | NEW |