| 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 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" | 11 #include "webrtc/modules/congestion_controller/include/congestion_controller.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "webrtc/base/checks.h" | 17 #include "webrtc/base/checks.h" |
| 18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
| 19 #include "webrtc/base/logging.h" | 19 #include "webrtc/base/logging.h" |
| 20 #include "webrtc/base/socket.h" | 20 #include "webrtc/base/socket.h" |
| 21 #include "webrtc/base/thread_annotations.h" | 21 #include "webrtc/base/thread_annotations.h" |
| 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 22 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 23 #include "webrtc/modules/congestion_controller/delay_based_bandwidth_estimator.h
" |
| 23 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" |
| 24 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" | |
| 25 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" | 25 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_singl
e_stream.h" |
| 26 #include "webrtc/modules/utility/include/process_thread.h" | 26 #include "webrtc/modules/utility/include/process_thread.h" |
| 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 28 #include "webrtc/video/payload_router.h" | 28 #include "webrtc/video/payload_router.h" |
| 29 | 29 |
| 30 namespace webrtc { | 30 namespace webrtc { |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 static const uint32_t kTimeOffsetSwitchThreshold = 30; | 33 static const uint32_t kTimeOffsetSwitchThreshold = 30; |
| 34 | 34 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 using_absolute_send_time_ = false; | 108 using_absolute_send_time_ = false; |
| 109 PickEstimator(); | 109 PickEstimator(); |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 // Instantiate RBE for Time Offset or Absolute Send Time extensions. | 115 // Instantiate RBE for Time Offset or Absolute Send Time extensions. |
| 116 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { | 116 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { |
| 117 if (using_absolute_send_time_) { | 117 if (using_absolute_send_time_) { |
| 118 rbe_.reset(new RemoteBitrateEstimatorAbsSendTime(observer_)); | 118 rbe_.reset(new DelayBasedBwe(observer_)); |
| 119 } else { | 119 } else { |
| 120 rbe_.reset(new RemoteBitrateEstimatorSingleStream(observer_, clock_)); | 120 rbe_.reset(new RemoteBitrateEstimatorSingleStream(observer_, clock_)); |
| 121 } | 121 } |
| 122 rbe_->SetMinBitrate(min_bitrate_bps_); | 122 rbe_->SetMinBitrate(min_bitrate_bps_); |
| 123 } | 123 } |
| 124 | 124 |
| 125 RemoteBitrateObserver* observer_; | 125 RemoteBitrateObserver* observer_; |
| 126 Clock* const clock_; | 126 Clock* const clock_; |
| 127 std::unique_ptr<CriticalSectionWrapper> crit_sect_; | 127 std::unique_ptr<CriticalSectionWrapper> crit_sect_; |
| 128 std::unique_ptr<RemoteBitrateEstimator> rbe_; | 128 std::unique_ptr<RemoteBitrateEstimator> rbe_; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 last_reported_fraction_loss_(0), | 200 last_reported_fraction_loss_(0), |
| 201 last_reported_rtt_(0), | 201 last_reported_rtt_(0), |
| 202 network_state_(kNetworkUp) { | 202 network_state_(kNetworkUp) { |
| 203 Init(); | 203 Init(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 CongestionController::~CongestionController() {} | 206 CongestionController::~CongestionController() {} |
| 207 | 207 |
| 208 void CongestionController::Init() { | 208 void CongestionController::Init() { |
| 209 transport_feedback_adapter_.SetBitrateEstimator( | 209 transport_feedback_adapter_.SetBitrateEstimator( |
| 210 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_)); | 210 new DelayBasedBwe(&transport_feedback_adapter_)); |
| 211 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( | 211 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( |
| 212 min_bitrate_bps_); | 212 min_bitrate_bps_); |
| 213 } | 213 } |
| 214 | 214 |
| 215 | 215 |
| 216 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 216 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| 217 int start_bitrate_bps, | 217 int start_bitrate_bps, |
| 218 int max_bitrate_bps) { | 218 int max_bitrate_bps) { |
| 219 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, | 219 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
| 220 // and that we don't try to set the min bitrate to 0 from any applications. | 220 // and that we don't try to set the min bitrate to 0 from any applications. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 bool CongestionController::IsSendQueueFull() const { | 339 bool CongestionController::IsSendQueueFull() const { |
| 340 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 340 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 341 } | 341 } |
| 342 | 342 |
| 343 bool CongestionController::IsNetworkDown() const { | 343 bool CongestionController::IsNetworkDown() const { |
| 344 rtc::CritScope cs(&critsect_); | 344 rtc::CritScope cs(&critsect_); |
| 345 return network_state_ == kNetworkDown; | 345 return network_state_ == kNetworkDown; |
| 346 } | 346 } |
| 347 | 347 |
| 348 } // namespace webrtc | 348 } // namespace webrtc |
| OLD | NEW |