| 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/pacing/paced_sender.h" | |
| 24 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" | 23 #include "webrtc/modules/remote_bitrate_estimator/include/send_time_history.h" |
| 25 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" | 24 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" |
| 26 #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" |
| 27 #include "webrtc/modules/utility/include/process_thread.h" | 26 #include "webrtc/modules/utility/include/process_thread.h" |
| 28 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 27 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 29 #include "webrtc/video/payload_router.h" | 28 #include "webrtc/video/payload_router.h" |
| 30 | 29 |
| 31 namespace webrtc { | 30 namespace webrtc { |
| 32 namespace { | 31 namespace { |
| 33 | 32 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 }; | 134 }; |
| 136 | 135 |
| 137 } // namespace | 136 } // namespace |
| 138 | 137 |
| 139 CongestionController::CongestionController( | 138 CongestionController::CongestionController( |
| 140 Clock* clock, | 139 Clock* clock, |
| 141 BitrateObserver* bitrate_observer, | 140 BitrateObserver* bitrate_observer, |
| 142 RemoteBitrateObserver* remote_bitrate_observer) | 141 RemoteBitrateObserver* remote_bitrate_observer) |
| 143 : clock_(clock), | 142 : clock_(clock), |
| 144 pacer_(new PacedSender(clock_, | 143 pacer_(new PacedSender(clock_, |
| 145 &packet_router_, | 144 &packet_router_, |
| 146 BitrateController::kDefaultStartBitrateKbps, | 145 BitrateController::kDefaultStartBitratebps)), |
| 147 PacedSender::kDefaultPaceMultiplier * | |
| 148 BitrateController::kDefaultStartBitrateKbps, | |
| 149 0)), | |
| 150 remote_bitrate_estimator_( | 146 remote_bitrate_estimator_( |
| 151 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), | 147 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
| 152 // Constructed last as this object calls the provided callback on | 148 // Constructed last as this object calls the provided callback on |
| 153 // construction. | 149 // construction. |
| 154 bitrate_controller_( | 150 bitrate_controller_( |
| 155 BitrateController::CreateBitrateController(clock_, bitrate_observer)), | 151 BitrateController::CreateBitrateController(clock_, |
| 152 bitrate_observer, |
| 153 pacer_.get())), |
| 156 remote_estimator_proxy_(clock_, &packet_router_), | 154 remote_estimator_proxy_(clock_, &packet_router_), |
| 157 transport_feedback_adapter_(bitrate_controller_.get(), clock_), | 155 transport_feedback_adapter_(bitrate_controller_.get(), clock_), |
| 158 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) { | 156 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps) { |
| 159 transport_feedback_adapter_.SetBitrateEstimator( | 157 transport_feedback_adapter_.SetBitrateEstimator( |
| 160 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_)); | 158 new RemoteBitrateEstimatorAbsSendTime(&transport_feedback_adapter_)); |
| 161 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( | 159 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( |
| 162 min_bitrate_bps_); | 160 min_bitrate_bps_); |
| 163 } | 161 } |
| 164 | 162 |
| 165 CongestionController::~CongestionController() { | 163 CongestionController::~CongestionController() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 } else { | 198 } else { |
| 201 return remote_bitrate_estimator_.get(); | 199 return remote_bitrate_estimator_.get(); |
| 202 } | 200 } |
| 203 } | 201 } |
| 204 | 202 |
| 205 TransportFeedbackObserver* | 203 TransportFeedbackObserver* |
| 206 CongestionController::GetTransportFeedbackObserver() { | 204 CongestionController::GetTransportFeedbackObserver() { |
| 207 return &transport_feedback_adapter_; | 205 return &transport_feedback_adapter_; |
| 208 } | 206 } |
| 209 | 207 |
| 210 void CongestionController::UpdatePacerBitrate(int bitrate_kbps, | 208 void CongestionController::UpdatePaddingBitrate(int bitrate_bps) { |
| 211 int max_bitrate_kbps, | 209 pacer_->SetPaddingBitrate(bitrate_bps); |
| 212 int min_bitrate_kbps) { | 210 } |
| 213 pacer_->UpdateBitrate(bitrate_kbps, max_bitrate_kbps, min_bitrate_kbps); | 211 |
| 212 void CongestionController::SetMinimumSendBitrate(int bitrate_bps) { |
| 213 pacer_->SetMinimumSendBitrate(bitrate_bps); |
| 214 } | 214 } |
| 215 | 215 |
| 216 int64_t CongestionController::GetPacerQueuingDelayMs() const { | 216 int64_t CongestionController::GetPacerQueuingDelayMs() const { |
| 217 return pacer_->QueueInMs(); | 217 return pacer_->QueueInMs(); |
| 218 } | 218 } |
| 219 | 219 |
| 220 void CongestionController::SignalNetworkState(NetworkState state) { | 220 void CongestionController::SignalNetworkState(NetworkState state) { |
| 221 if (state == kNetworkUp) { | 221 if (state == kNetworkUp) { |
| 222 pacer_->Resume(); | 222 pacer_->Resume(); |
| 223 } else { | 223 } else { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 239 return std::min(bitrate_controller_->TimeUntilNextProcess(), | 239 return std::min(bitrate_controller_->TimeUntilNextProcess(), |
| 240 remote_bitrate_estimator_->TimeUntilNextProcess()); | 240 remote_bitrate_estimator_->TimeUntilNextProcess()); |
| 241 } | 241 } |
| 242 | 242 |
| 243 void CongestionController::Process() { | 243 void CongestionController::Process() { |
| 244 bitrate_controller_->Process(); | 244 bitrate_controller_->Process(); |
| 245 remote_bitrate_estimator_->Process(); | 245 remote_bitrate_estimator_->Process(); |
| 246 } | 246 } |
| 247 | 247 |
| 248 } // namespace webrtc | 248 } // namespace webrtc |
| OLD | NEW |