| 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 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 observer_(observer), | 162 observer_(observer), |
| 163 packet_router_(new PacketRouter()), | 163 packet_router_(new PacketRouter()), |
| 164 pacer_(new PacedSender(clock_, packet_router_.get())), | 164 pacer_(new PacedSender(clock_, packet_router_.get())), |
| 165 remote_bitrate_estimator_( | 165 remote_bitrate_estimator_( |
| 166 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), | 166 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
| 167 bitrate_controller_( | 167 bitrate_controller_( |
| 168 BitrateController::CreateBitrateController(clock_, event_log)), | 168 BitrateController::CreateBitrateController(clock_, event_log)), |
| 169 retransmission_rate_limiter_( | 169 retransmission_rate_limiter_( |
| 170 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 170 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
| 171 remote_estimator_proxy_(clock_, packet_router_.get()), | 171 remote_estimator_proxy_(clock_, packet_router_.get()), |
| 172 transport_feedback_adapter_(bitrate_controller_.get(), clock_), | 172 transport_feedback_adapter_(clock_), |
| 173 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), | 173 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), |
| 174 last_reported_bitrate_bps_(0), | 174 last_reported_bitrate_bps_(0), |
| 175 last_reported_fraction_loss_(0), | 175 last_reported_fraction_loss_(0), |
| 176 last_reported_rtt_(0), | 176 last_reported_rtt_(0), |
| 177 network_state_(kNetworkUp) { | 177 network_state_(kNetworkUp) { |
| 178 Init(); | 178 Init(); |
| 179 } | 179 } |
| 180 | 180 |
| 181 CongestionController::CongestionController( | 181 CongestionController::CongestionController( |
| 182 Clock* clock, | 182 Clock* clock, |
| 183 Observer* observer, | 183 Observer* observer, |
| 184 RemoteBitrateObserver* remote_bitrate_observer, | 184 RemoteBitrateObserver* remote_bitrate_observer, |
| 185 RtcEventLog* event_log, | 185 RtcEventLog* event_log, |
| 186 std::unique_ptr<PacketRouter> packet_router, | 186 std::unique_ptr<PacketRouter> packet_router, |
| 187 std::unique_ptr<PacedSender> pacer) | 187 std::unique_ptr<PacedSender> pacer) |
| 188 : clock_(clock), | 188 : clock_(clock), |
| 189 observer_(observer), | 189 observer_(observer), |
| 190 packet_router_(std::move(packet_router)), | 190 packet_router_(std::move(packet_router)), |
| 191 pacer_(std::move(pacer)), | 191 pacer_(std::move(pacer)), |
| 192 remote_bitrate_estimator_( | 192 remote_bitrate_estimator_( |
| 193 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), | 193 new WrappingBitrateEstimator(remote_bitrate_observer, clock_)), |
| 194 // Constructed last as this object calls the provided callback on | 194 // Constructed last as this object calls the provided callback on |
| 195 // construction. | 195 // construction. |
| 196 bitrate_controller_( | 196 bitrate_controller_( |
| 197 BitrateController::CreateBitrateController(clock_, event_log)), | 197 BitrateController::CreateBitrateController(clock_, event_log)), |
| 198 retransmission_rate_limiter_( | 198 retransmission_rate_limiter_( |
| 199 new RateLimiter(clock, kRetransmitWindowSizeMs)), | 199 new RateLimiter(clock, kRetransmitWindowSizeMs)), |
| 200 remote_estimator_proxy_(clock_, packet_router_.get()), | 200 remote_estimator_proxy_(clock_, packet_router_.get()), |
| 201 transport_feedback_adapter_(bitrate_controller_.get(), clock_), | 201 transport_feedback_adapter_(clock_), |
| 202 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), | 202 min_bitrate_bps_(RemoteBitrateEstimator::kDefaultMinBitrateBps), |
| 203 last_reported_bitrate_bps_(0), | 203 last_reported_bitrate_bps_(0), |
| 204 last_reported_fraction_loss_(0), | 204 last_reported_fraction_loss_(0), |
| 205 last_reported_rtt_(0), | 205 last_reported_rtt_(0), |
| 206 network_state_(kNetworkUp) { | 206 network_state_(kNetworkUp) { |
| 207 Init(); | 207 Init(); |
| 208 } | 208 } |
| 209 | 209 |
| 210 CongestionController::~CongestionController() {} | 210 CongestionController::~CongestionController() {} |
| 211 | 211 |
| 212 void CongestionController::Init() { | 212 void CongestionController::Init() { |
| 213 transport_feedback_adapter_.SetBitrateEstimator( | 213 transport_feedback_adapter_.SetBitrateEstimator( |
| 214 new DelayBasedBwe(&transport_feedback_adapter_, clock_)); | 214 new DelayBasedBwe(this, clock_)); |
| 215 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( | 215 transport_feedback_adapter_.GetBitrateEstimator()->SetMinBitrate( |
| 216 min_bitrate_bps_); | 216 min_bitrate_bps_); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 219 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| 220 int start_bitrate_bps, | 220 int start_bitrate_bps, |
| 221 int max_bitrate_bps) { | 221 int max_bitrate_bps) { |
| 222 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | 222 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 223 bitrate_controller_->SetBitrates(start_bitrate_bps, | 223 bitrate_controller_->SetBitrates(start_bitrate_bps, |
| 224 min_bitrate_bps, | 224 min_bitrate_bps, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 239 // TODO(honghaiz): Recreate this object once the bitrate controller is | 239 // TODO(honghaiz): Recreate this object once the bitrate controller is |
| 240 // no longer exposed outside CongestionController. | 240 // no longer exposed outside CongestionController. |
| 241 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, | 241 bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, |
| 242 max_bitrate_bps); | 242 max_bitrate_bps); |
| 243 min_bitrate_bps_ = min_bitrate_bps; | 243 min_bitrate_bps_ = min_bitrate_bps; |
| 244 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is | 244 // TODO(honghaiz): Recreate this object once the remote bitrate estimator is |
| 245 // no longer exposed outside CongestionController. | 245 // no longer exposed outside CongestionController. |
| 246 if (remote_bitrate_estimator_) | 246 if (remote_bitrate_estimator_) |
| 247 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); | 247 remote_bitrate_estimator_->SetMinBitrate(min_bitrate_bps); |
| 248 | 248 |
| 249 RemoteBitrateEstimator* rbe = new DelayBasedBwe( | 249 RemoteBitrateEstimator* rbe = new DelayBasedBwe(this, clock_); |
| 250 &transport_feedback_adapter_, clock_); | |
| 251 transport_feedback_adapter_.SetBitrateEstimator(rbe); | 250 transport_feedback_adapter_.SetBitrateEstimator(rbe); |
| 252 rbe->SetMinBitrate(min_bitrate_bps); | 251 rbe->SetMinBitrate(min_bitrate_bps); |
| 253 // TODO(holmer): Trigger a new probe once mid-call probing is implemented. | 252 // TODO(holmer): Trigger a new probe once mid-call probing is implemented. |
| 254 MaybeTriggerOnNetworkChanged(); | 253 MaybeTriggerOnNetworkChanged(); |
| 255 } | 254 } |
| 256 | 255 |
| 257 BitrateController* CongestionController::GetBitrateController() const { | 256 BitrateController* CongestionController::GetBitrateController() const { |
| 258 return bitrate_controller_.get(); | 257 return bitrate_controller_.get(); |
| 259 } | 258 } |
| 260 | 259 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 network_state_ = state; | 298 network_state_ = state; |
| 300 } | 299 } |
| 301 MaybeTriggerOnNetworkChanged(); | 300 MaybeTriggerOnNetworkChanged(); |
| 302 } | 301 } |
| 303 | 302 |
| 304 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { | 303 void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) { |
| 305 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, | 304 transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, |
| 306 sent_packet.send_time_ms); | 305 sent_packet.send_time_ms); |
| 307 } | 306 } |
| 308 | 307 |
| 308 void CongestionController::OnDelayBasedBweChanged(int bitrate_bps) { |
| 309 bitrate_controller_->UpdateDelayBasedEstimate(bitrate_bps); |
| 310 } |
| 311 |
| 312 void CongestionController::OnProbingBitrateMeasured(int bitrate_bps) { |
| 313 pacer_->OnProbingBitrateMeasured(bitrate_bps); |
| 314 } |
| 315 |
| 316 PacedSender::State CongestionController::SenderState() { |
| 317 return pacer_->PacingState(); |
| 318 } |
| 319 |
| 309 void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { | 320 void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { |
| 310 remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 321 remote_bitrate_estimator_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| 311 transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); | 322 transport_feedback_adapter_.OnRttUpdate(avg_rtt_ms, max_rtt_ms); |
| 312 } | 323 } |
| 313 | 324 |
| 314 int64_t CongestionController::TimeUntilNextProcess() { | 325 int64_t CongestionController::TimeUntilNextProcess() { |
| 315 return std::min(bitrate_controller_->TimeUntilNextProcess(), | 326 return std::min(bitrate_controller_->TimeUntilNextProcess(), |
| 316 remote_bitrate_estimator_->TimeUntilNextProcess()); | 327 remote_bitrate_estimator_->TimeUntilNextProcess()); |
| 317 } | 328 } |
| 318 | 329 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 bool CongestionController::IsSendQueueFull() const { | 378 bool CongestionController::IsSendQueueFull() const { |
| 368 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 379 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 369 } | 380 } |
| 370 | 381 |
| 371 bool CongestionController::IsNetworkDown() const { | 382 bool CongestionController::IsNetworkDown() const { |
| 372 rtc::CritScope cs(&critsect_); | 383 rtc::CritScope cs(&critsect_); |
| 373 return network_state_ == kNetworkDown; | 384 return network_state_ == kNetworkDown; |
| 374 } | 385 } |
| 375 | 386 |
| 376 } // namespace webrtc | 387 } // namespace webrtc |
| OLD | NEW |