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