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 */ |
11 | 11 |
12 #include "webrtc/modules/bitrate_controller/bitrate_controller_impl.h" | 12 #include "webrtc/modules/bitrate_controller/bitrate_controller_impl.h" |
13 | 13 |
14 #include <algorithm> | 14 #include <algorithm> |
15 #include <map> | 15 #include <map> |
16 #include <utility> | 16 #include <utility> |
17 | 17 |
18 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 20 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
21 | 21 |
| 22 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
| 23 |
22 namespace webrtc { | 24 namespace webrtc { |
23 | 25 |
24 class BitrateControllerImpl::RtcpBandwidthObserverImpl | 26 class BitrateControllerImpl::RtcpBandwidthObserverImpl |
25 : public RtcpBandwidthObserver { | 27 : public RtcpBandwidthObserver { |
26 public: | 28 public: |
27 explicit RtcpBandwidthObserverImpl(BitrateControllerImpl* owner) | 29 explicit RtcpBandwidthObserverImpl(BitrateControllerImpl* owner) |
28 : owner_(owner) { | 30 : owner_(owner) { |
29 } | 31 } |
30 virtual ~RtcpBandwidthObserverImpl() { | 32 virtual ~RtcpBandwidthObserverImpl() { |
31 } | 33 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 reserved_bitrate_bps_ = reserved_bitrate_bps; | 173 reserved_bitrate_bps_ = reserved_bitrate_bps; |
172 } | 174 } |
173 MaybeTriggerOnNetworkChanged(); | 175 MaybeTriggerOnNetworkChanged(); |
174 } | 176 } |
175 | 177 |
176 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { | 178 void BitrateControllerImpl::OnReceivedEstimatedBitrate(uint32_t bitrate) { |
177 { | 179 { |
178 rtc::CritScope cs(&critsect_); | 180 rtc::CritScope cs(&critsect_); |
179 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), | 181 bandwidth_estimation_.UpdateReceiverEstimate(clock_->TimeInMilliseconds(), |
180 bitrate); | 182 bitrate); |
| 183 BWE_TEST_LOGGING_PLOT(1, "REMB[kbps]", clock_->TimeInMilliseconds(), \ |
| 184 bitrate/1000); |
181 } | 185 } |
182 MaybeTriggerOnNetworkChanged(); | 186 MaybeTriggerOnNetworkChanged(); |
183 } | 187 } |
184 | 188 |
185 void BitrateControllerImpl::UpdateProbeBitrate(uint32_t bitrate_bps) { | 189 void BitrateControllerImpl::UpdateProbeBitrate(uint32_t bitrate_bps) { |
186 { | 190 { |
187 rtc::CritScope cs(&critsect_); | 191 rtc::CritScope cs(&critsect_); |
188 bandwidth_estimation_.SetSendBitrate(bitrate_bps); | 192 bandwidth_estimation_.SetSendBitrate(bitrate_bps); |
189 } | 193 } |
190 MaybeTriggerOnNetworkChanged(); | 194 MaybeTriggerOnNetworkChanged(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 bool new_bitrate = false; | 262 bool new_bitrate = false; |
259 if (*bitrate != last_bitrate_bps_ || *fraction_loss != last_fraction_loss_ || | 263 if (*bitrate != last_bitrate_bps_ || *fraction_loss != last_fraction_loss_ || |
260 *rtt != last_rtt_ms_ || | 264 *rtt != last_rtt_ms_ || |
261 last_reserved_bitrate_bps_ != reserved_bitrate_bps_) { | 265 last_reserved_bitrate_bps_ != reserved_bitrate_bps_) { |
262 last_bitrate_bps_ = *bitrate; | 266 last_bitrate_bps_ = *bitrate; |
263 last_fraction_loss_ = *fraction_loss; | 267 last_fraction_loss_ = *fraction_loss; |
264 last_rtt_ms_ = *rtt; | 268 last_rtt_ms_ = *rtt; |
265 last_reserved_bitrate_bps_ = reserved_bitrate_bps_; | 269 last_reserved_bitrate_bps_ = reserved_bitrate_bps_; |
266 new_bitrate = true; | 270 new_bitrate = true; |
267 } | 271 } |
| 272 |
| 273 BWE_TEST_LOGGING_PLOT(1, "fraction_loss_[%%]", \ |
| 274 clock_->TimeInMilliseconds(), (last_fraction_loss_*100)/256); |
| 275 BWE_TEST_LOGGING_PLOT(1, "rtt[ms]", clock_->TimeInMilliseconds(), \ |
| 276 last_rtt_ms_); |
| 277 BWE_TEST_LOGGING_PLOT(1, "Target_bitrate[kbps]", \ |
| 278 clock_->TimeInMilliseconds(), last_bitrate_bps_/1000); |
| 279 |
268 return new_bitrate; | 280 return new_bitrate; |
269 } | 281 } |
270 | 282 |
271 bool BitrateControllerImpl::AvailableBandwidth(uint32_t* bandwidth) const { | 283 bool BitrateControllerImpl::AvailableBandwidth(uint32_t* bandwidth) const { |
272 rtc::CritScope cs(&critsect_); | 284 rtc::CritScope cs(&critsect_); |
273 int bitrate; | 285 int bitrate; |
274 uint8_t fraction_loss; | 286 uint8_t fraction_loss; |
275 int64_t rtt; | 287 int64_t rtt; |
276 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); | 288 bandwidth_estimation_.CurrentEstimate(&bitrate, &fraction_loss, &rtt); |
277 if (bitrate > 0) { | 289 if (bitrate > 0) { |
278 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); | 290 bitrate = bitrate - std::min<int>(bitrate, reserved_bitrate_bps_); |
279 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); | 291 bitrate = std::max(bitrate, bandwidth_estimation_.GetMinBitrate()); |
280 *bandwidth = bitrate; | 292 *bandwidth = bitrate; |
281 return true; | 293 return true; |
282 } | 294 } |
283 return false; | 295 return false; |
284 } | 296 } |
285 } // namespace webrtc | 297 } // namespace webrtc |
OLD | NEW |