| 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/logging.h" | 18 #include "webrtc/base/logging.h" |
| 19 #include "webrtc/base/rate_limiter.h" | 19 #include "webrtc/base/rate_limiter.h" |
| 20 #include "webrtc/base/socket.h" | 20 #include "webrtc/base/socket.h" |
| 21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 21 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
| 22 #include "webrtc/modules/congestion_controller/probe_controller.h" | 22 #include "webrtc/modules/congestion_controller/probe_controller.h" |
| 23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 23 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 24 #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" |
| 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/system_wrappers/include/critical_section_wrapper.h" | |
| 27 | 26 |
| 28 namespace webrtc { | 27 namespace webrtc { |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 static const uint32_t kTimeOffsetSwitchThreshold = 30; | 30 static const uint32_t kTimeOffsetSwitchThreshold = 30; |
| 32 static const int64_t kRetransmitWindowSizeMs = 500; | 31 static const int64_t kRetransmitWindowSizeMs = 500; |
| 33 | 32 |
| 34 // Makes sure that the bitrate and the min, max values are in valid range. | 33 // Makes sure that the bitrate and the min, max values are in valid range. |
| 35 static void ClampBitrates(int* bitrate_bps, | 34 static void ClampBitrates(int* bitrate_bps, |
| 36 int* min_bitrate_bps, | 35 int* min_bitrate_bps, |
| 37 int* max_bitrate_bps) { | 36 int* max_bitrate_bps) { |
| 38 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, | 37 // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
| 39 // and that we don't try to set the min bitrate to 0 from any applications. | 38 // and that we don't try to set the min bitrate to 0 from any applications. |
| 40 // The congestion controller should allow a min bitrate of 0. | 39 // The congestion controller should allow a min bitrate of 0. |
| 41 if (*min_bitrate_bps < congestion_controller::GetMinBitrateBps()) | 40 if (*min_bitrate_bps < congestion_controller::GetMinBitrateBps()) |
| 42 *min_bitrate_bps = congestion_controller::GetMinBitrateBps(); | 41 *min_bitrate_bps = congestion_controller::GetMinBitrateBps(); |
| 43 if (*max_bitrate_bps > 0) | 42 if (*max_bitrate_bps > 0) |
| 44 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); | 43 *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); |
| 45 if (*bitrate_bps > 0) | 44 if (*bitrate_bps > 0) |
| 46 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); | 45 *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); |
| 47 } | 46 } |
| 48 | 47 |
| 49 class WrappingBitrateEstimator : public RemoteBitrateEstimator { | 48 } // namespace |
| 50 public: | |
| 51 WrappingBitrateEstimator(RemoteBitrateObserver* observer, Clock* clock) | |
| 52 : observer_(observer), | |
| 53 clock_(clock), | |
| 54 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | |
| 55 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)), | |
| 56 using_absolute_send_time_(false), | |
| 57 packets_since_absolute_send_time_(0), | |
| 58 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()) {} | |
| 59 | 49 |
| 60 virtual ~WrappingBitrateEstimator() {} | 50 CongestionController::WrappingBitrateEstimator::WrappingBitrateEstimator( |
| 51 RemoteBitrateObserver* observer, Clock* clock) |
| 52 : observer_(observer), |
| 53 clock_(clock), |
| 54 rbe_(new RemoteBitrateEstimatorSingleStream(observer_, clock_)), |
| 55 using_absolute_send_time_(false), |
| 56 packets_since_absolute_send_time_(0), |
| 57 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()) {} |
| 61 | 58 |
| 62 void IncomingPacket(int64_t arrival_time_ms, | 59 void CongestionController::WrappingBitrateEstimator::IncomingPacket( |
| 63 size_t payload_size, | 60 int64_t arrival_time_ms, |
| 64 const RTPHeader& header) override { | 61 size_t payload_size, |
| 65 CriticalSectionScoped cs(crit_sect_.get()); | 62 const RTPHeader& header) { |
| 66 PickEstimatorFromHeader(header); | 63 rtc::CritScope cs(&crit_sect_); |
| 67 rbe_->IncomingPacket(arrival_time_ms, payload_size, header); | 64 PickEstimatorFromHeader(header); |
| 68 } | 65 rbe_->IncomingPacket(arrival_time_ms, payload_size, header); |
| 66 } |
| 69 | 67 |
| 70 void Process() override { | 68 void CongestionController::WrappingBitrateEstimator::Process() { |
| 71 CriticalSectionScoped cs(crit_sect_.get()); | 69 rtc::CritScope cs(&crit_sect_); |
| 72 rbe_->Process(); | 70 rbe_->Process(); |
| 73 } | 71 } |
| 74 | 72 |
| 75 int64_t TimeUntilNextProcess() override { | 73 int64_t CongestionController::WrappingBitrateEstimator::TimeUntilNextProcess() { |
| 76 CriticalSectionScoped cs(crit_sect_.get()); | 74 rtc::CritScope cs(&crit_sect_); |
| 77 return rbe_->TimeUntilNextProcess(); | 75 return rbe_->TimeUntilNextProcess(); |
| 78 } | 76 } |
| 79 | 77 |
| 80 void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override { | 78 void CongestionController::WrappingBitrateEstimator::OnRttUpdate( |
| 81 CriticalSectionScoped cs(crit_sect_.get()); | 79 int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 82 rbe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 80 rtc::CritScope cs(&crit_sect_); |
| 83 } | 81 rbe_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| 82 } |
| 84 | 83 |
| 85 void RemoveStream(unsigned int ssrc) override { | 84 void CongestionController::WrappingBitrateEstimator::RemoveStream( |
| 86 CriticalSectionScoped cs(crit_sect_.get()); | 85 unsigned int ssrc) { |
| 87 rbe_->RemoveStream(ssrc); | 86 rtc::CritScope cs(&crit_sect_); |
| 88 } | 87 rbe_->RemoveStream(ssrc); |
| 88 } |
| 89 | 89 |
| 90 bool LatestEstimate(std::vector<unsigned int>* ssrcs, | 90 bool CongestionController::WrappingBitrateEstimator::LatestEstimate( |
| 91 unsigned int* bitrate_bps) const override { | 91 std::vector<unsigned int>* ssrcs, |
| 92 CriticalSectionScoped cs(crit_sect_.get()); | 92 unsigned int* bitrate_bps) const { |
| 93 return rbe_->LatestEstimate(ssrcs, bitrate_bps); | 93 rtc::CritScope cs(&crit_sect_); |
| 94 } | 94 return rbe_->LatestEstimate(ssrcs, bitrate_bps); |
| 95 } |
| 95 | 96 |
| 96 void SetMinBitrate(int min_bitrate_bps) override { | 97 void CongestionController::WrappingBitrateEstimator::SetMinBitrate( |
| 97 CriticalSectionScoped cs(crit_sect_.get()); | 98 int min_bitrate_bps) { |
| 98 rbe_->SetMinBitrate(min_bitrate_bps); | 99 rtc::CritScope cs(&crit_sect_); |
| 99 min_bitrate_bps_ = min_bitrate_bps; | 100 rbe_->SetMinBitrate(min_bitrate_bps); |
| 100 } | 101 min_bitrate_bps_ = min_bitrate_bps; |
| 102 } |
| 101 | 103 |
| 102 private: | 104 void CongestionController::WrappingBitrateEstimator::PickEstimatorFromHeader( |
| 103 void PickEstimatorFromHeader(const RTPHeader& header) | 105 const RTPHeader& header) { |
| 104 EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { | 106 if (header.extension.hasAbsoluteSendTime) { |
| 105 if (header.extension.hasAbsoluteSendTime) { | 107 // If we see AST in header, switch RBE strategy immediately. |
| 106 // If we see AST in header, switch RBE strategy immediately. | 108 if (!using_absolute_send_time_) { |
| 107 if (!using_absolute_send_time_) { | 109 LOG(LS_INFO) << |
| 108 LOG(LS_INFO) << | 110 "WrappingBitrateEstimator: Switching to absolute send time RBE."; |
| 109 "WrappingBitrateEstimator: Switching to absolute send time RBE."; | 111 using_absolute_send_time_ = true; |
| 110 using_absolute_send_time_ = true; | 112 PickEstimator(); |
| 113 } |
| 114 packets_since_absolute_send_time_ = 0; |
| 115 } else { |
| 116 // When we don't see AST, wait for a few packets before going back to TOF. |
| 117 if (using_absolute_send_time_) { |
| 118 ++packets_since_absolute_send_time_; |
| 119 if (packets_since_absolute_send_time_ >= kTimeOffsetSwitchThreshold) { |
| 120 LOG(LS_INFO) << "WrappingBitrateEstimator: Switching to transmission " |
| 121 << "time offset RBE."; |
| 122 using_absolute_send_time_ = false; |
| 111 PickEstimator(); | 123 PickEstimator(); |
| 112 } | 124 } |
| 113 packets_since_absolute_send_time_ = 0; | |
| 114 } else { | |
| 115 // When we don't see AST, wait for a few packets before going back to TOF. | |
| 116 if (using_absolute_send_time_) { | |
| 117 ++packets_since_absolute_send_time_; | |
| 118 if (packets_since_absolute_send_time_ >= kTimeOffsetSwitchThreshold) { | |
| 119 LOG(LS_INFO) << "WrappingBitrateEstimator: Switching to transmission " | |
| 120 << "time offset RBE."; | |
| 121 using_absolute_send_time_ = false; | |
| 122 PickEstimator(); | |
| 123 } | |
| 124 } | |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 } |
| 127 | 128 |
| 128 // Instantiate RBE for Time Offset or Absolute Send Time extensions. | 129 // Instantiate RBE for Time Offset or Absolute Send Time extensions. |
| 129 void PickEstimator() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_.get()) { | 130 void CongestionController::WrappingBitrateEstimator::PickEstimator() { |
| 130 if (using_absolute_send_time_) { | 131 if (using_absolute_send_time_) { |
| 131 rbe_.reset(new RemoteBitrateEstimatorAbsSendTime(observer_, clock_)); | 132 rbe_.reset(new RemoteBitrateEstimatorAbsSendTime(observer_, clock_)); |
| 132 } else { | 133 } else { |
| 133 rbe_.reset(new RemoteBitrateEstimatorSingleStream(observer_, clock_)); | 134 rbe_.reset(new RemoteBitrateEstimatorSingleStream(observer_, clock_)); |
| 134 } | |
| 135 rbe_->SetMinBitrate(min_bitrate_bps_); | |
| 136 } | 135 } |
| 137 | 136 rbe_->SetMinBitrate(min_bitrate_bps_); |
| 138 RemoteBitrateObserver* observer_; | 137 } |
| 139 Clock* const clock_; | |
| 140 std::unique_ptr<CriticalSectionWrapper> crit_sect_; | |
| 141 std::unique_ptr<RemoteBitrateEstimator> rbe_; | |
| 142 bool using_absolute_send_time_; | |
| 143 uint32_t packets_since_absolute_send_time_; | |
| 144 int min_bitrate_bps_; | |
| 145 | |
| 146 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(WrappingBitrateEstimator); | |
| 147 }; | |
| 148 | |
| 149 } // namespace | |
| 150 | 138 |
| 151 CongestionController::CongestionController( | 139 CongestionController::CongestionController( |
| 152 Clock* clock, | 140 Clock* clock, |
| 153 Observer* observer, | 141 Observer* observer, |
| 154 RemoteBitrateObserver* remote_bitrate_observer, | 142 RemoteBitrateObserver* remote_bitrate_observer, |
| 155 RtcEventLog* event_log, | 143 RtcEventLog* event_log, |
| 156 PacketRouter* packet_router) | 144 PacketRouter* packet_router) |
| 157 : CongestionController( | 145 : CongestionController( |
| 158 clock, | 146 clock, |
| 159 observer, | 147 observer, |
| 160 remote_bitrate_observer, | 148 remote_bitrate_observer, |
| 161 event_log, | 149 event_log, |
| 162 packet_router, | 150 packet_router, |
| 163 std::unique_ptr<PacedSender>(new PacedSender(clock, packet_router))) { | 151 std::unique_ptr<PacedSender>(new PacedSender(clock, packet_router))) { |
| 164 } | 152 } |
| 165 | 153 |
| 166 CongestionController::CongestionController( | 154 CongestionController::CongestionController( |
| 167 Clock* clock, | 155 Clock* clock, |
| 168 Observer* observer, | 156 Observer* observer, |
| 169 RemoteBitrateObserver* remote_bitrate_observer, | 157 RemoteBitrateObserver* remote_bitrate_observer, |
| 170 RtcEventLog* event_log, | 158 RtcEventLog* event_log, |
| 171 PacketRouter* packet_router, | 159 PacketRouter* packet_router, |
| 172 std::unique_ptr<PacedSender> pacer) | 160 std::unique_ptr<PacedSender> pacer) |
| 173 : clock_(clock), | 161 : clock_(clock), |
| 174 observer_(observer), | 162 observer_(observer), |
| 175 packet_router_(packet_router), | 163 packet_router_(packet_router), |
| 176 pacer_(std::move(pacer)), | 164 pacer_(std::move(pacer)), |
| 177 remote_bitrate_estimator_( | |
| 178 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), | |
| 179 // Constructed last as this object calls the provided callback on | |
| 180 // construction. | |
| 181 bitrate_controller_( | 165 bitrate_controller_( |
| 182 BitrateController::CreateBitrateController(clock_, event_log)), | 166 BitrateController::CreateBitrateController(clock_, event_log)), |
| 183 probe_controller_(new ProbeController(pacer_.get(), clock_)), | 167 probe_controller_(new ProbeController(pacer_.get(), clock_)), |
| 184 retransmission_rate_limiter_( | 168 retransmission_rate_limiter_( |
| 185 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 169 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
| 170 remote_bitrate_estimator_(remote_bitrate_observer, clock_), |
| 186 remote_estimator_proxy_(clock_, packet_router_), | 171 remote_estimator_proxy_(clock_, packet_router_), |
| 187 transport_feedback_adapter_(clock_, bitrate_controller_.get()), | 172 transport_feedback_adapter_(clock_, bitrate_controller_.get()), |
| 188 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), | 173 min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
| 189 max_bitrate_bps_(0), | 174 max_bitrate_bps_(0), |
| 190 last_reported_bitrate_bps_(0), | 175 last_reported_bitrate_bps_(0), |
| 191 last_reported_fraction_loss_(0), | 176 last_reported_fraction_loss_(0), |
| 192 last_reported_rtt_(0), | 177 last_reported_rtt_(0), |
| 193 network_state_(kNetworkUp) { | 178 network_state_(kNetworkUp) { |
| 194 transport_feedback_adapter_.InitBwe(); | 179 transport_feedback_adapter_.InitBwe(); |
| 195 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); | 180 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); |
| 196 } | 181 } |
| 197 | 182 |
| 198 CongestionController::~CongestionController() {} | 183 CongestionController::~CongestionController() {} |
| 199 | 184 |
| 200 void CongestionController::OnReceivedPacket(int64_t arrival_time_ms, | 185 void CongestionController::OnReceivedPacket(int64_t arrival_time_ms, |
| 201 size_t payload_size, | 186 size_t payload_size, |
| 202 const RTPHeader& header) { | 187 const RTPHeader& header) { |
| 203 // Send-side BWE. | 188 // Send-side BWE. |
| 204 if (header.extension.hasTransportSequenceNumber) { | 189 if (header.extension.hasTransportSequenceNumber) { |
| 205 remote_estimator_proxy_.IncomingPacket(arrival_time_ms, payload_size, | 190 remote_estimator_proxy_.IncomingPacket(arrival_time_ms, payload_size, |
| 206 header); | 191 header); |
| 207 return; | 192 } else { |
| 208 } | 193 // Receive-side BWE. |
| 209 | 194 remote_bitrate_estimator_.IncomingPacket(arrival_time_ms, payload_size, |
| 210 // Receive-side BWE. | |
| 211 if (remote_bitrate_estimator_) { | |
| 212 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_size, | |
| 213 header); | 195 header); |
| 214 } | 196 } |
| 215 } | 197 } |
| 216 | 198 |
| 217 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 199 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| 218 int start_bitrate_bps, | 200 int start_bitrate_bps, |
| 219 int max_bitrate_bps) { | 201 int max_bitrate_bps) { |
| 220 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | 202 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 221 bitrate_controller_->SetBitrates(start_bitrate_bps, | 203 bitrate_controller_->SetBitrates(start_bitrate_bps, |
| 222 min_bitrate_bps, | 204 min_bitrate_bps, |
| 223 max_bitrate_bps); | 205 max_bitrate_bps); |
| 224 | 206 |
| 225 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, | 207 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, |
| 226 max_bitrate_bps); | 208 max_bitrate_bps); |
| 227 max_bitrate_bps_ = max_bitrate_bps; | 209 max_bitrate_bps_ = max_bitrate_bps; |
| 228 | 210 |
| 229 if (remote_bitrate_estimator_) | 211 remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps); |
| 230 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | |
| 231 min_bitrate_bps_ = min_bitrate_bps; | 212 min_bitrate_bps_ = min_bitrate_bps; |
| 232 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); | 213 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); |
| 233 MaybeTriggerOnNetworkChanged(); | 214 MaybeTriggerOnNetworkChanged(); |
| 234 } | 215 } |
| 235 | 216 |
| 236 void CongestionController::ResetBweAndBitrates(int bitrate_bps, | 217 void CongestionController::ResetBweAndBitrates(int bitrate_bps, |
| 237 int min_bitrate_bps, | 218 int min_bitrate_bps, |
| 238 int max_bitrate_bps) { | 219 int max_bitrate_bps) { |
| 239 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | 220 ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 240 // TODO(honghaiz): Recreate this object once the bitrate controller is | 221 // TODO(honghaiz): Recreate this object once the bitrate controller is |
| 241 // no longer exposed outside CongestionController. | 222 // no longer exposed outside CongestionController. |
| 242 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, | 223 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, |
| 243 max_bitrate_bps); | 224 max_bitrate_bps); |
| 244 min_bitrate_bps_ = min_bitrate_bps; | 225 min_bitrate_bps_ = min_bitrate_bps; |
| 245 max_bitrate_bps_ = max_bitrate_bps; | 226 max_bitrate_bps_ = max_bitrate_bps; |
| 246 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is | 227 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is |
| 247 // no longer exposed outside CongestionController. | 228 // no longer exposed outside CongestionController. |
| 248 if (remote_bitrate_estimator_) | 229 remote_bitrate_estimator_.SetMinBitrate(min_bitrate_bps); |
| 249 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | |
| 250 | 230 |
| 251 transport_feedback_adapter_.InitBwe(); | 231 transport_feedback_adapter_.InitBwe(); |
| 252 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps); | 232 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps); |
| 253 // TODO(holmer): Trigger a new probe once mid-call probing is implemented. | 233 // TODO(holmer): Trigger a new probe once mid-call probing is implemented. |
| 254 MaybeTriggerOnNetworkChanged(); | 234 MaybeTriggerOnNetworkChanged(); |
| 255 } | 235 } |
| 256 | 236 |
| 257 BitrateController* CongestionController::GetBitrateController() const { | 237 BitrateController* CongestionController::GetBitrateController() const { |
| 258 return bitrate_controller_.get(); | 238 return bitrate_controller_.get(); |
| 259 } | 239 } |
| 260 | 240 |
| 261 RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator( | 241 RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator( |
| 262 bool send_side_bwe) { | 242 bool send_side_bwe) { |
| 263 if (send_side_bwe) { | 243 if (send_side_bwe) { |
| 264 return &remote_estimator_proxy_; | 244 return &remote_estimator_proxy_; |
| 265 } else { | 245 } else { |
| 266 return remote_bitrate_estimator_.get(); | 246 return &remote_bitrate_estimator_; |
| 267 } | 247 } |
| 268 } | 248 } |
| 269 | 249 |
| 270 TransportFeedbackObserver* | 250 TransportFeedbackObserver* |
| 271 CongestionController::GetTransportFeedbackObserver() { | 251 CongestionController::GetTransportFeedbackObserver() { |
| 272 return &transport_feedback_adapter_; | 252 return &transport_feedback_adapter_; |
| 273 } | 253 } |
| 274 | 254 |
| 275 RateLimiter* CongestionController::GetRetransmissionRateLimiter() { | 255 RateLimiter* CongestionController::GetRetransmissionRateLimiter() { |
| 276 return retransmission_rate_limiter_.get(); | 256 return retransmission_rate_limiter_.get(); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { | 295 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { |
| 316 // We're not interested in packets without an id, which may be stun packets, | 296 // We're not interested in packets without an id, which may be stun packets, |
| 317 // etc, sent on the same transport. | 297 // etc, sent on the same transport. |
| 318 if (sent_packet.packet_id == -1) | 298 if (sent_packet.packet_id == -1) |
| 319 return; | 299 return; |
| 320 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, | 300 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, |
| 321 sent_packet.send_time_ms); | 301 sent_packet.send_time_ms); |
| 322 } | 302 } |
| 323 | 303 |
| 324 void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 304 void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 325 remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 305 remote_bitrate_estimator_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| 326 transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 306 transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| 327 } | 307 } |
| 328 | 308 |
| 329 int64_t CongestionController::TimeUntilNextProcess() { | 309 int64_t CongestionController::TimeUntilNextProcess() { |
| 330 return std::min(bitrate_controller_->TimeUntilNextProcess(), | 310 return std::min(bitrate_controller_->TimeUntilNextProcess(), |
| 331 remote_bitrate_estimator_->TimeUntilNextProcess()); | 311 remote_bitrate_estimator_.TimeUntilNextProcess()); |
| 332 } | 312 } |
| 333 | 313 |
| 334 void CongestionController::Process() { | 314 void CongestionController::Process() { |
| 335 bitrate_controller_->Process(); | 315 bitrate_controller_->Process(); |
| 336 remote_bitrate_estimator_->Process(); | 316 remote_bitrate_estimator_.Process(); |
| 337 probe_controller_->Process(); | 317 probe_controller_->Process(); |
| 338 MaybeTriggerOnNetworkChanged(); | 318 MaybeTriggerOnNetworkChanged(); |
| 339 } | 319 } |
| 340 | 320 |
| 341 void CongestionController::MaybeTriggerOnNetworkChanged() { | 321 void CongestionController::MaybeTriggerOnNetworkChanged() { |
| 342 // TODO(perkj): |observer_| can be nullptr if the ctor that accepts a | 322 // TODO(perkj): |observer_| can be nullptr if the ctor that accepts a |
| 343 // BitrateObserver is used. Remove this check once the ctor is removed. | 323 // BitrateObserver is used. Remove this check once the ctor is removed. |
| 344 if (!observer_) | 324 if (!observer_) |
| 345 return; | 325 return; |
| 346 | 326 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 bool CongestionController::IsSendQueueFull() const { | 367 bool CongestionController::IsSendQueueFull() const { |
| 388 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 368 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 389 } | 369 } |
| 390 | 370 |
| 391 bool CongestionController::IsNetworkDown() const { | 371 bool CongestionController::IsNetworkDown() const { |
| 392 rtc::CritScope cs(&critsect_); | 372 rtc::CritScope cs(&critsect_); |
| 393 return network_state_ == kNetworkDown; | 373 return network_state_ == kNetworkDown; |
| 394 } | 374 } |
| 395 | 375 |
| 396 } // namespace webrtc | 376 } // namespace webrtc |
| OLD | NEW |