Chromium Code Reviews| 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/modules/rtp_rtcp/source/rtp_header_extensions.h" | |
| 27 #include "webrtc/modules/rtp_rtcp/source/rtp_packet_received.h" | |
| 26 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 28 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
| 27 | 29 |
| 28 namespace webrtc { | 30 namespace webrtc { |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 static const uint32_t kTimeOffsetSwitchThreshold = 30; | 33 static const uint32_t kTimeOffsetSwitchThreshold = 30; |
| 32 static const int64_t kRetransmitWindowSizeMs = 500; | 34 static const int64_t kRetransmitWindowSizeMs = 500; |
| 33 | 35 |
| 34 // Makes sure that the bitrate and the min, max values are in valid range. | 36 // Makes sure that the bitrate and the min, max values are in valid range. |
| 35 static void ClampBitrates(int* bitrate_bps, | 37 static void ClampBitrates(int* bitrate_bps, |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 190 last_reported_bitrate_bps_(0), | 192 last_reported_bitrate_bps_(0), |
| 191 last_reported_fraction_loss_(0), | 193 last_reported_fraction_loss_(0), |
| 192 last_reported_rtt_(0), | 194 last_reported_rtt_(0), |
| 193 network_state_(kNetworkUp) { | 195 network_state_(kNetworkUp) { |
| 194 transport_feedback_adapter_.InitBwe(); | 196 transport_feedback_adapter_.InitBwe(); |
| 195 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); | 197 transport_feedback_adapter_.SetMinBitrate(min_bitrate_bps_); |
| 196 } | 198 } |
| 197 | 199 |
| 198 CongestionController::~CongestionController() {} | 200 CongestionController::~CongestionController() {} |
| 199 | 201 |
| 202 void CongestionController::NotifyBweOfReceivedPacket( | |
|
stefan-webrtc
2016/12/19 14:03:31
Call this method "OnReceivedPacket"
brandtr
2016/12/19 14:26:53
Done. Alternatively, it could also be called "Inco
stefan-webrtc
2016/12/19 15:50:30
Agree, but now it resembles OnSentPacket below, wh
| |
| 203 const RtpPacketReceived& packet) { | |
| 204 const bool transport_wide = packet.HasExtension<TransportSequenceNumber>(); | |
| 205 const bool abs_send_time = packet.HasExtension<AbsoluteSendTime>(); | |
| 206 const bool t_offset = packet.HasExtension<TransmissionOffset>(); | |
|
stefan-webrtc
2016/12/19 14:03:31
One more tiny request...
Could we move out the rt
brandtr
2016/12/19 14:26:53
Done.
| |
| 207 | |
| 208 // At least one of the header extensions is needed for the BWE. | |
| 209 if (!transport_wide && !abs_send_time && !t_offset) | |
| 210 return; | |
| 211 | |
| 212 RTPHeader header; | |
| 213 packet.GetHeader(&header); | |
| 214 | |
| 215 // Send-side BWE. | |
| 216 if (transport_wide) { | |
| 217 remote_estimator_proxy_.IncomingPacket(packet.arrival_time_ms(), | |
| 218 packet.payload_size(), header); | |
| 219 return; | |
| 220 } | |
| 221 | |
| 222 // Receive-side BWE. | |
| 223 if (remote_bitrate_estimator_) { | |
| 224 remote_bitrate_estimator_->IncomingPacket(packet.arrival_time_ms(), | |
| 225 packet.payload_size(), header); | |
| 226 } | |
| 227 } | |
| 228 | |
| 200 void CongestionController::SetBweBitrates(int min_bitrate_bps, | 229 void CongestionController::SetBweBitrates(int min_bitrate_bps, |
| 201 int start_bitrate_bps, | 230 int start_bitrate_bps, |
| 202 int max_bitrate_bps) { | 231 int max_bitrate_bps) { |
| 203 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); | 232 ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 204 bitrate_controller_->SetBitrates(start_bitrate_bps, | 233 bitrate_controller_->SetBitrates(start_bitrate_bps, |
| 205 min_bitrate_bps, | 234 min_bitrate_bps, |
| 206 max_bitrate_bps); | 235 max_bitrate_bps); |
| 207 | 236 |
| 208 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, | 237 probe_controller_->SetBitrates(min_bitrate_bps, start_bitrate_bps, |
| 209 max_bitrate_bps); | 238 max_bitrate_bps); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 364 bool CongestionController::IsSendQueueFull() const { | 393 bool CongestionController::IsSendQueueFull() const { |
| 365 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; | 394 return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 366 } | 395 } |
| 367 | 396 |
| 368 bool CongestionController::IsNetworkDown() const { | 397 bool CongestionController::IsNetworkDown() const { |
| 369 rtc::CritScope cs(&critsect_); | 398 rtc::CritScope cs(&critsect_); |
| 370 return network_state_ == kNetworkDown; | 399 return network_state_ == kNetworkDown; |
| 371 } | 400 } |
| 372 | 401 |
| 373 } // namespace webrtc | 402 } // namespace webrtc |
| OLD | NEW |