nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #include "modules/congestion_controller/include/send_side_congestion_controller.h" |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 12 | |
| 13 | #include <algorithm> |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 14 | #include <cstdio> |
Mirko Bonadei | e32bb50 | 2018-04-11 14:59:08 +0200 | [diff] [blame] | 15 | #include <iterator> |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 16 | #include <memory> |
| 17 | #include <vector> |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 18 | |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 19 | #include "absl/memory/memory.h" |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 20 | #include "modules/bitrate_controller/include/bitrate_controller.h" |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 21 | #include "modules/congestion_controller/congestion_window_pushback_controller.h" |
Sebastian Jansson | 172fd85 | 2018-05-24 14:17:06 +0200 | [diff] [blame] | 22 | #include "modules/congestion_controller/goog_cc/acknowledged_bitrate_estimator.h" |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 23 | #include "modules/congestion_controller/goog_cc/probe_controller.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 24 | #include "modules/remote_bitrate_estimator/include/bwe_defines.h" |
| 25 | #include "rtc_base/checks.h" |
| 26 | #include "rtc_base/format_macros.h" |
| 27 | #include "rtc_base/logging.h" |
Oleh Prypin | a40f824 | 2017-12-21 13:32:23 +0100 | [diff] [blame] | 28 | #include "rtc_base/numerics/safe_conversions.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 29 | #include "rtc_base/rate_limiter.h" |
| 30 | #include "rtc_base/socket.h" |
| 31 | #include "rtc_base/timeutils.h" |
| 32 | #include "system_wrappers/include/field_trial.h" |
Ilya Nikolaevskiy | 2ffe3e8 | 2018-01-17 19:57:24 +0000 | [diff] [blame] | 33 | #include "system_wrappers/include/runtime_enabled_features.h" |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 34 | |
| 35 | namespace webrtc { |
| 36 | namespace { |
| 37 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 38 | const char kCwndExperiment[] = "WebRTC-CwndExperiment"; |
| 39 | const char kPacerPushbackExperiment[] = "WebRTC-PacerPushbackExperiment"; |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 40 | |
| 41 | // When CongestionWindowPushback is enabled, the pacer is oblivious to |
| 42 | // the congestion window. The relation between outstanding data and |
| 43 | // the congestion window affects encoder allocations directly. |
| 44 | const char kCongestionPushbackExperiment[] = "WebRTC-CongestionWindowPushback"; |
| 45 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 46 | const int64_t kDefaultAcceptedQueueMs = 250; |
| 47 | |
| 48 | bool CwndExperimentEnabled() { |
| 49 | std::string experiment_string = |
| 50 | webrtc::field_trial::FindFullName(kCwndExperiment); |
| 51 | // The experiment is enabled iff the field trial string begins with "Enabled". |
| 52 | return experiment_string.find("Enabled") == 0; |
| 53 | } |
| 54 | |
| 55 | bool ReadCwndExperimentParameter(int64_t* accepted_queue_ms) { |
| 56 | RTC_DCHECK(accepted_queue_ms); |
| 57 | std::string experiment_string = |
| 58 | webrtc::field_trial::FindFullName(kCwndExperiment); |
| 59 | int parsed_values = |
| 60 | sscanf(experiment_string.c_str(), "Enabled-%" PRId64, accepted_queue_ms); |
| 61 | if (parsed_values == 1) { |
| 62 | RTC_CHECK_GE(*accepted_queue_ms, 0) |
| 63 | << "Accepted must be greater than or equal to 0."; |
| 64 | return true; |
| 65 | } |
| 66 | return false; |
| 67 | } |
| 68 | |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 69 | bool IsCongestionWindowPushbackExperimentEnabled() { |
| 70 | return webrtc::field_trial::IsEnabled(kCongestionPushbackExperiment) && |
| 71 | webrtc::field_trial::IsEnabled(kCwndExperiment); |
| 72 | } |
| 73 | |
| 74 | std::unique_ptr<CongestionWindowPushbackController> |
| 75 | MaybeCreateCongestionWindowPushbackController() { |
| 76 | return IsCongestionWindowPushbackExperimentEnabled() |
| 77 | ? absl::make_unique<CongestionWindowPushbackController>() |
| 78 | : nullptr; |
| 79 | } |
| 80 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 81 | static const int64_t kRetransmitWindowSizeMs = 500; |
| 82 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 83 | // Makes sure that the bitrate and the min, max values are in valid range. |
| 84 | static void ClampBitrates(int* bitrate_bps, |
| 85 | int* min_bitrate_bps, |
| 86 | int* max_bitrate_bps) { |
| 87 | // TODO(holmer): We should make sure the default bitrates are set to 10 kbps, |
| 88 | // and that we don't try to set the min bitrate to 0 from any applications. |
| 89 | // The congestion controller should allow a min bitrate of 0. |
| 90 | if (*min_bitrate_bps < congestion_controller::GetMinBitrateBps()) |
| 91 | *min_bitrate_bps = congestion_controller::GetMinBitrateBps(); |
| 92 | if (*max_bitrate_bps > 0) |
| 93 | *max_bitrate_bps = std::max(*min_bitrate_bps, *max_bitrate_bps); |
| 94 | if (*bitrate_bps > 0) |
| 95 | *bitrate_bps = std::max(*min_bitrate_bps, *bitrate_bps); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 98 | std::vector<webrtc::PacketFeedback> ReceivedPacketFeedbackVector( |
| 99 | const std::vector<webrtc::PacketFeedback>& input) { |
| 100 | std::vector<PacketFeedback> received_packet_feedback_vector; |
| 101 | auto is_received = [](const webrtc::PacketFeedback& packet_feedback) { |
| 102 | return packet_feedback.arrival_time_ms != |
| 103 | webrtc::PacketFeedback::kNotReceived; |
| 104 | }; |
| 105 | std::copy_if(input.begin(), input.end(), |
| 106 | std::back_inserter(received_packet_feedback_vector), |
| 107 | is_received); |
| 108 | return received_packet_feedback_vector; |
tschumim | 3fae628 | 2017-06-11 23:57:17 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 111 | void SortPacketFeedbackVector( |
| 112 | std::vector<webrtc::PacketFeedback>* const input) { |
| 113 | RTC_DCHECK(input); |
tschumim | 3fae628 | 2017-06-11 23:57:17 -0700 | [diff] [blame] | 114 | std::sort(input->begin(), input->end(), PacketFeedbackComparator()); |
| 115 | } |
| 116 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 117 | bool IsPacerPushbackExperimentEnabled() { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 118 | return webrtc::field_trial::IsEnabled(kPacerPushbackExperiment) || |
| 119 | (!webrtc::field_trial::IsDisabled(kPacerPushbackExperiment) && |
| 120 | webrtc::runtime_enabled_features::IsFeatureEnabled( |
| 121 | webrtc::runtime_enabled_features::kDualStreamModeFeatureName)); |
Ilya Nikolaevskiy | 2ffe3e8 | 2018-01-17 19:57:24 +0000 | [diff] [blame] | 122 | } |
| 123 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 124 | } // namespace |
| 125 | |
| 126 | SendSideCongestionController::SendSideCongestionController( |
| 127 | const Clock* clock, |
| 128 | Observer* observer, |
| 129 | RtcEventLog* event_log, |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 130 | PacedSender* pacer) |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 131 | : clock_(clock), |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 132 | observer_(observer), |
| 133 | event_log_(event_log), |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 134 | pacer_(pacer), |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 135 | bitrate_controller_( |
| 136 | BitrateController::CreateBitrateController(clock_, event_log)), |
| 137 | acknowledged_bitrate_estimator_( |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 138 | absl::make_unique<AcknowledgedBitrateEstimator>()), |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 139 | probe_controller_(new ProbeController()), |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 140 | retransmission_rate_limiter_( |
| 141 | new RateLimiter(clock, kRetransmitWindowSizeMs)), |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 142 | transport_feedback_adapter_(clock_), |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 143 | last_reported_bitrate_bps_(0), |
| 144 | last_reported_fraction_loss_(0), |
| 145 | last_reported_rtt_(0), |
| 146 | network_state_(kNetworkUp), |
| 147 | pause_pacer_(false), |
| 148 | pacer_paused_(false), |
| 149 | min_bitrate_bps_(congestion_controller::GetMinBitrateBps()), |
Sebastian Jansson | 04b18cb | 2018-07-02 09:25:25 +0200 | [diff] [blame] | 150 | delay_based_bwe_(new DelayBasedBwe(event_log_)), |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 151 | in_cwnd_experiment_(CwndExperimentEnabled()), |
| 152 | accepted_queue_ms_(kDefaultAcceptedQueueMs), |
| 153 | was_in_alr_(false), |
Stefan Holmer | 4dbc7e4 | 2018-01-26 15:09:41 +0100 | [diff] [blame] | 154 | send_side_bwe_with_overhead_( |
| 155 | webrtc::field_trial::IsEnabled("WebRTC-SendSideBwe-WithOverhead")), |
| 156 | transport_overhead_bytes_per_packet_(0), |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 157 | pacer_pushback_experiment_(IsPacerPushbackExperimentEnabled()), |
| 158 | congestion_window_pushback_controller_( |
| 159 | MaybeCreateCongestionWindowPushbackController()) { |
Per Kjellander | dd3eae5 | 2018-05-18 07:12:15 +0000 | [diff] [blame] | 160 | delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 161 | if (in_cwnd_experiment_ && |
| 162 | !ReadCwndExperimentParameter(&accepted_queue_ms_)) { |
| 163 | RTC_LOG(LS_WARNING) << "Failed to parse parameters for CwndExperiment " |
| 164 | "from field trial string. Experiment disabled."; |
| 165 | in_cwnd_experiment_ = false; |
| 166 | } |
Sebastian Jansson | 65792c5 | 2018-02-14 16:50:17 +0000 | [diff] [blame] | 167 | } |
Danil Chapovalov | 4e849f6 | 2018-02-14 08:28:02 +0000 | [diff] [blame] | 168 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 169 | SendSideCongestionController::~SendSideCongestionController() {} |
| 170 | |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 171 | void SendSideCongestionController::RegisterPacketFeedbackObserver( |
| 172 | PacketFeedbackObserver* observer) { |
| 173 | transport_feedback_adapter_.RegisterPacketFeedbackObserver(observer); |
| 174 | } |
| 175 | |
| 176 | void SendSideCongestionController::DeRegisterPacketFeedbackObserver( |
| 177 | PacketFeedbackObserver* observer) { |
| 178 | transport_feedback_adapter_.DeRegisterPacketFeedbackObserver(observer); |
| 179 | } |
| 180 | |
nisse | 23425f9 | 2017-04-03 04:54:25 -0700 | [diff] [blame] | 181 | void SendSideCongestionController::RegisterNetworkObserver(Observer* observer) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 182 | rtc::CritScope cs(&observer_lock_); |
| 183 | RTC_DCHECK(observer_ == nullptr); |
| 184 | observer_ = observer; |
nisse | 23425f9 | 2017-04-03 04:54:25 -0700 | [diff] [blame] | 185 | } |
| 186 | |
| 187 | void SendSideCongestionController::DeRegisterNetworkObserver( |
| 188 | Observer* observer) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 189 | rtc::CritScope cs(&observer_lock_); |
| 190 | RTC_DCHECK_EQ(observer_, observer); |
| 191 | observer_ = nullptr; |
nisse | 23425f9 | 2017-04-03 04:54:25 -0700 | [diff] [blame] | 192 | } |
| 193 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 194 | void SendSideCongestionController::SetBweBitrates(int min_bitrate_bps, |
| 195 | int start_bitrate_bps, |
| 196 | int max_bitrate_bps) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 197 | ClampBitrates(&start_bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 198 | bitrate_controller_->SetBitrates(start_bitrate_bps, min_bitrate_bps, |
| 199 | max_bitrate_bps); |
| 200 | |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 201 | { |
| 202 | rtc::CritScope cs(&probe_lock_); |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 203 | SendProbes(probe_controller_->SetBitrates( |
| 204 | min_bitrate_bps, start_bitrate_bps, max_bitrate_bps, |
| 205 | clock_->TimeInMilliseconds())); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 206 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 207 | |
| 208 | { |
| 209 | rtc::CritScope cs(&bwe_lock_); |
| 210 | if (start_bitrate_bps > 0) |
| 211 | delay_based_bwe_->SetStartBitrate(start_bitrate_bps); |
| 212 | min_bitrate_bps_ = min_bitrate_bps; |
Per Kjellander | dd3eae5 | 2018-05-18 07:12:15 +0000 | [diff] [blame] | 213 | delay_based_bwe_->SetMinBitrate(min_bitrate_bps_); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 214 | } |
| 215 | MaybeTriggerOnNetworkChanged(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Sebastian Jansson | 68ee465 | 2018-03-13 11:40:34 +0100 | [diff] [blame] | 218 | void SendSideCongestionController::SetAllocatedSendBitrateLimits( |
| 219 | int64_t min_send_bitrate_bps, |
| 220 | int64_t max_padding_bitrate_bps, |
| 221 | int64_t max_total_bitrate_bps) { |
| 222 | pacer_->SetSendBitrateLimits(min_send_bitrate_bps, max_padding_bitrate_bps); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 223 | |
| 224 | rtc::CritScope cs(&probe_lock_); |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 225 | SendProbes(probe_controller_->OnMaxTotalAllocatedBitrate( |
| 226 | max_total_bitrate_bps, clock_->TimeInMilliseconds())); |
philipel | db4fa4b | 2018-03-06 18:29:22 +0100 | [diff] [blame] | 227 | } |
| 228 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 229 | // TODO(holmer): Split this up and use SetBweBitrates in combination with |
| 230 | // OnNetworkRouteChanged. |
| 231 | void SendSideCongestionController::OnNetworkRouteChanged( |
| 232 | const rtc::NetworkRoute& network_route, |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 233 | int bitrate_bps, |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 234 | int min_bitrate_bps, |
| 235 | int max_bitrate_bps) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 236 | ClampBitrates(&bitrate_bps, &min_bitrate_bps, &max_bitrate_bps); |
| 237 | // TODO(honghaiz): Recreate this object once the bitrate controller is |
| 238 | // no longer exposed outside SendSideCongestionController. |
| 239 | bitrate_controller_->ResetBitrates(bitrate_bps, min_bitrate_bps, |
| 240 | max_bitrate_bps); |
| 241 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 242 | transport_feedback_adapter_.SetNetworkIds(network_route.local_network_id, |
| 243 | network_route.remote_network_id); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 244 | { |
| 245 | rtc::CritScope cs(&bwe_lock_); |
Sebastian Jansson | 3c24ea8 | 2018-02-23 18:30:26 +0100 | [diff] [blame] | 246 | transport_overhead_bytes_per_packet_ = network_route.packet_overhead; |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 247 | min_bitrate_bps_ = min_bitrate_bps; |
Sebastian Jansson | 04b18cb | 2018-07-02 09:25:25 +0200 | [diff] [blame] | 248 | delay_based_bwe_.reset(new DelayBasedBwe(event_log_)); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 249 | acknowledged_bitrate_estimator_.reset(new AcknowledgedBitrateEstimator()); |
| 250 | delay_based_bwe_->SetStartBitrate(bitrate_bps); |
Per Kjellander | dd3eae5 | 2018-05-18 07:12:15 +0000 | [diff] [blame] | 251 | delay_based_bwe_->SetMinBitrate(min_bitrate_bps); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 252 | } |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 253 | { |
| 254 | rtc::CritScope cs(&probe_lock_); |
| 255 | probe_controller_->Reset(clock_->TimeInMilliseconds()); |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 256 | SendProbes(probe_controller_->SetBitrates(min_bitrate_bps, bitrate_bps, |
| 257 | max_bitrate_bps, |
| 258 | clock_->TimeInMilliseconds())); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 259 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 260 | |
| 261 | MaybeTriggerOnNetworkChanged(); |
| 262 | } |
| 263 | |
| 264 | BitrateController* SendSideCongestionController::GetBitrateController() const { |
| 265 | return bitrate_controller_.get(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 266 | } |
| 267 | |
srte | a6092a9 | 2017-11-22 19:37:43 +0100 | [diff] [blame] | 268 | bool SendSideCongestionController::AvailableBandwidth( |
| 269 | uint32_t* bandwidth) const { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 270 | return bitrate_controller_->AvailableBandwidth(bandwidth); |
srte | a6092a9 | 2017-11-22 19:37:43 +0100 | [diff] [blame] | 271 | } |
| 272 | |
Sebastian Jansson | 98e0111 | 2018-02-28 16:47:29 +0100 | [diff] [blame] | 273 | RtcpBandwidthObserver* SendSideCongestionController::GetBandwidthObserver() { |
| 274 | return bitrate_controller_.get(); |
| 275 | } |
| 276 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 277 | RtcpBandwidthObserver* SendSideCongestionController::GetBandwidthObserver() |
| 278 | const { |
| 279 | return bitrate_controller_.get(); |
Sebastian Jansson | 8d9c540 | 2017-11-15 17:22:16 +0100 | [diff] [blame] | 280 | } |
| 281 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 282 | RateLimiter* SendSideCongestionController::GetRetransmissionRateLimiter() { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 283 | return retransmission_rate_limiter_.get(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 284 | } |
| 285 | |
Sebastian Jansson | 1d430f7 | 2018-03-21 12:47:10 +0100 | [diff] [blame] | 286 | void SendSideCongestionController::SetPerPacketFeedbackAvailable( |
| 287 | bool available) {} |
| 288 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 289 | void SendSideCongestionController::EnablePeriodicAlrProbing(bool enable) { |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 290 | rtc::CritScope cs(&probe_lock_); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 291 | probe_controller_->EnablePeriodicAlrProbing(enable); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 292 | } |
| 293 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 294 | int64_t SendSideCongestionController::GetPacerQueuingDelayMs() const { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 295 | return IsNetworkDown() ? 0 : pacer_->QueueInMs(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 296 | } |
| 297 | |
asapersson | fc5e81c | 2017-04-19 23:28:53 -0700 | [diff] [blame] | 298 | int64_t SendSideCongestionController::GetFirstPacketTimeMs() const { |
| 299 | return pacer_->FirstSentPacketTimeMs(); |
| 300 | } |
| 301 | |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 302 | TransportFeedbackObserver* |
| 303 | SendSideCongestionController::GetTransportFeedbackObserver() { |
| 304 | return this; |
| 305 | } |
| 306 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 307 | void SendSideCongestionController::SignalNetworkState(NetworkState state) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 308 | RTC_LOG(LS_INFO) << "SignalNetworkState " |
| 309 | << (state == kNetworkUp ? "Up" : "Down"); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 310 | { |
| 311 | rtc::CritScope cs(&network_state_lock_); |
| 312 | pause_pacer_ = state == kNetworkDown; |
| 313 | network_state_ = state; |
| 314 | } |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 315 | |
| 316 | { |
| 317 | rtc::CritScope cs(&probe_lock_); |
| 318 | NetworkAvailability msg; |
| 319 | msg.at_time = Timestamp::ms(clock_->TimeInMilliseconds()); |
| 320 | msg.network_available = state == kNetworkUp; |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 321 | SendProbes(probe_controller_->OnNetworkAvailability(msg)); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 322 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 323 | MaybeTriggerOnNetworkChanged(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 324 | } |
| 325 | |
| 326 | void SendSideCongestionController::SetTransportOverhead( |
| 327 | size_t transport_overhead_bytes_per_packet) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 328 | rtc::CritScope cs(&bwe_lock_); |
Stefan Holmer | 4dbc7e4 | 2018-01-26 15:09:41 +0100 | [diff] [blame] | 329 | transport_overhead_bytes_per_packet_ = transport_overhead_bytes_per_packet; |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | void SendSideCongestionController::OnSentPacket( |
| 333 | const rtc::SentPacket& sent_packet) { |
| 334 | // We're not interested in packets without an id, which may be stun packets, |
| 335 | // etc, sent on the same transport. |
| 336 | if (sent_packet.packet_id == -1) |
| 337 | return; |
| 338 | transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id, |
| 339 | sent_packet.send_time_ms); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 340 | if (in_cwnd_experiment_) |
| 341 | LimitOutstandingBytes(transport_feedback_adapter_.GetOutstandingBytes()); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | void SendSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms, |
| 345 | int64_t max_rtt_ms) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 346 | rtc::CritScope cs(&bwe_lock_); |
Sebastian Jansson | 04b18cb | 2018-07-02 09:25:25 +0200 | [diff] [blame] | 347 | delay_based_bwe_->OnRttUpdate(avg_rtt_ms); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | int64_t SendSideCongestionController::TimeUntilNextProcess() { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 351 | return bitrate_controller_->TimeUntilNextProcess(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 352 | } |
| 353 | |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 354 | void SendSideCongestionController::SendProbes( |
| 355 | std::vector<ProbeClusterConfig> probe_configs) { |
| 356 | for (auto probe_config : probe_configs) { |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 357 | pacer_->CreateProbeCluster(probe_config.target_data_rate.bps()); |
| 358 | } |
| 359 | } |
| 360 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 361 | void SendSideCongestionController::Process() { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 362 | bool pause_pacer; |
| 363 | // TODO(holmer): Once this class is running on a task queue we should |
| 364 | // replace this with a task instead. |
stefan | 9e117c5e1 | 2017-08-16 08:16:25 -0700 | [diff] [blame] | 365 | { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 366 | rtc::CritScope lock(&network_state_lock_); |
| 367 | pause_pacer = pause_pacer_; |
stefan | 9e117c5e1 | 2017-08-16 08:16:25 -0700 | [diff] [blame] | 368 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 369 | if (pause_pacer && !pacer_paused_) { |
| 370 | pacer_->Pause(); |
| 371 | pacer_paused_ = true; |
| 372 | } else if (!pause_pacer && pacer_paused_) { |
| 373 | pacer_->Resume(); |
| 374 | pacer_paused_ = false; |
stefan | 9e117c5e1 | 2017-08-16 08:16:25 -0700 | [diff] [blame] | 375 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 376 | bitrate_controller_->Process(); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 377 | |
| 378 | { |
| 379 | rtc::CritScope cs(&probe_lock_); |
| 380 | probe_controller_->SetAlrStartTimeMs( |
| 381 | pacer_->GetApplicationLimitedRegionStartTime()); |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 382 | SendProbes(probe_controller_->Process(clock_->TimeInMilliseconds())); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 383 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 384 | MaybeTriggerOnNetworkChanged(); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | void SendSideCongestionController::AddPacket( |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 388 | uint32_t ssrc, |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 389 | uint16_t sequence_number, |
| 390 | size_t length, |
| 391 | const PacedPacketInfo& pacing_info) { |
Stefan Holmer | 4dbc7e4 | 2018-01-26 15:09:41 +0100 | [diff] [blame] | 392 | if (send_side_bwe_with_overhead_) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 393 | rtc::CritScope cs(&bwe_lock_); |
Stefan Holmer | 4dbc7e4 | 2018-01-26 15:09:41 +0100 | [diff] [blame] | 394 | length += transport_overhead_bytes_per_packet_; |
| 395 | } |
elad.alon | d12a8e1 | 2017-03-23 11:04:48 -0700 | [diff] [blame] | 396 | transport_feedback_adapter_.AddPacket(ssrc, sequence_number, length, |
| 397 | pacing_info); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | void SendSideCongestionController::OnTransportFeedback( |
| 401 | const rtcp::TransportFeedback& feedback) { |
erikvarga | bf5a2fc | 2017-06-16 05:02:05 -0700 | [diff] [blame] | 402 | RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 403 | transport_feedback_adapter_.OnTransportFeedback(feedback); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 404 | std::vector<PacketFeedback> feedback_vector = ReceivedPacketFeedbackVector( |
| 405 | transport_feedback_adapter_.GetTransportFeedbackVector()); |
tschumim | 3fae628 | 2017-06-11 23:57:17 -0700 | [diff] [blame] | 406 | SortPacketFeedbackVector(&feedback_vector); |
tschumim | 9d11764 | 2017-07-17 01:41:41 -0700 | [diff] [blame] | 407 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 408 | bool currently_in_alr = |
| 409 | pacer_->GetApplicationLimitedRegionStartTime().has_value(); |
| 410 | if (was_in_alr_ && !currently_in_alr) { |
| 411 | int64_t now_ms = rtc::TimeMillis(); |
| 412 | acknowledged_bitrate_estimator_->SetAlrEndedTimeMs(now_ms); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 413 | rtc::CritScope cs(&probe_lock_); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 414 | probe_controller_->SetAlrEndedTimeMs(now_ms); |
tschumim | 9d11764 | 2017-07-17 01:41:41 -0700 | [diff] [blame] | 415 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 416 | was_in_alr_ = currently_in_alr; |
| 417 | |
| 418 | acknowledged_bitrate_estimator_->IncomingPacketFeedbackVector( |
| 419 | feedback_vector); |
| 420 | DelayBasedBwe::Result result; |
| 421 | { |
| 422 | rtc::CritScope cs(&bwe_lock_); |
| 423 | result = delay_based_bwe_->IncomingPacketFeedbackVector( |
Sebastian Jansson | 04b18cb | 2018-07-02 09:25:25 +0200 | [diff] [blame] | 424 | feedback_vector, acknowledged_bitrate_estimator_->bitrate_bps(), |
| 425 | clock_->TimeInMilliseconds()); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 426 | } |
| 427 | if (result.updated) { |
| 428 | bitrate_controller_->OnDelayBasedBweResult(result); |
| 429 | // Update the estimate in the ProbeController, in case we want to probe. |
| 430 | MaybeTriggerOnNetworkChanged(); |
| 431 | } |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 432 | if (result.recovered_from_overuse) { |
| 433 | rtc::CritScope cs(&probe_lock_); |
| 434 | probe_controller_->SetAlrStartTimeMs( |
| 435 | pacer_->GetApplicationLimitedRegionStartTime()); |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 436 | SendProbes(probe_controller_->RequestProbe(clock_->TimeInMilliseconds())); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 437 | } |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 438 | if (in_cwnd_experiment_) { |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 439 | LimitOutstandingBytes(transport_feedback_adapter_.GetOutstandingBytes()); |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 440 | } |
stefan | 9e117c5e1 | 2017-08-16 08:16:25 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 443 | void SendSideCongestionController::LimitOutstandingBytes( |
| 444 | size_t num_outstanding_bytes) { |
| 445 | RTC_DCHECK(in_cwnd_experiment_); |
| 446 | rtc::CritScope lock(&network_state_lock_); |
Danil Chapovalov | 0040b66 | 2018-06-18 10:48:16 +0200 | [diff] [blame] | 447 | absl::optional<int64_t> min_rtt_ms = |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 448 | transport_feedback_adapter_.GetMinFeedbackLoopRtt(); |
| 449 | // No valid RTT. Could be because send-side BWE isn't used, in which case |
| 450 | // we don't try to limit the outstanding packets. |
| 451 | if (!min_rtt_ms) |
| 452 | return; |
| 453 | const size_t kMinCwndBytes = 2 * 1500; |
| 454 | size_t max_outstanding_bytes = |
| 455 | std::max<size_t>((*min_rtt_ms + accepted_queue_ms_) * |
| 456 | last_reported_bitrate_bps_ / 1000 / 8, |
| 457 | kMinCwndBytes); |
| 458 | RTC_LOG(LS_INFO) << clock_->TimeInMilliseconds() |
| 459 | << " Outstanding bytes: " << num_outstanding_bytes |
| 460 | << " pacer queue: " << pacer_->QueueInMs() |
| 461 | << " max outstanding: " << max_outstanding_bytes; |
| 462 | RTC_LOG(LS_INFO) << "Feedback rtt: " << *min_rtt_ms |
| 463 | << " Bitrate: " << last_reported_bitrate_bps_; |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 464 | if (congestion_window_pushback_controller_) { |
| 465 | congestion_window_pushback_controller_->UpdateOutstandingData( |
| 466 | num_outstanding_bytes); |
| 467 | congestion_window_pushback_controller_->UpdateMaxOutstandingData( |
| 468 | max_outstanding_bytes); |
| 469 | } else { |
| 470 | pause_pacer_ = num_outstanding_bytes > max_outstanding_bytes; |
| 471 | } |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 472 | } |
| 473 | |
| 474 | std::vector<PacketFeedback> |
| 475 | SendSideCongestionController::GetTransportFeedbackVector() const { |
erikvarga | bf5a2fc | 2017-06-16 05:02:05 -0700 | [diff] [blame] | 476 | RTC_DCHECK_RUNS_SERIALIZED(&worker_race_); |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 477 | return transport_feedback_adapter_.GetTransportFeedbackVector(); |
| 478 | } |
| 479 | |
Sebastian Jansson | 68ee465 | 2018-03-13 11:40:34 +0100 | [diff] [blame] | 480 | void SendSideCongestionController::SetPacingFactor(float pacing_factor) { |
| 481 | pacer_->SetPacingFactor(pacing_factor); |
| 482 | } |
| 483 | |
Alex Narest | bcf9180 | 2018-06-25 16:08:36 +0200 | [diff] [blame] | 484 | void SendSideCongestionController::SetAllocatedBitrateWithoutFeedback( |
| 485 | uint32_t bitrate_bps) { |
| 486 | acknowledged_bitrate_estimator_->SetAllocatedBitrateWithoutFeedback( |
| 487 | bitrate_bps); |
| 488 | } |
| 489 | |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 490 | void SendSideCongestionController::MaybeTriggerOnNetworkChanged() { |
| 491 | uint32_t bitrate_bps; |
| 492 | uint8_t fraction_loss; |
| 493 | int64_t rtt; |
| 494 | bool estimate_changed = bitrate_controller_->GetNetworkParameters( |
| 495 | &bitrate_bps, &fraction_loss, &rtt); |
| 496 | if (estimate_changed) { |
| 497 | pacer_->SetEstimatedBitrate(bitrate_bps); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 498 | { |
| 499 | rtc::CritScope cs(&probe_lock_); |
Sebastian Jansson | da2ec40 | 2018-08-02 16:27:28 +0200 | [diff] [blame] | 500 | SendProbes(probe_controller_->SetEstimatedBitrate( |
| 501 | bitrate_bps, clock_->TimeInMilliseconds())); |
Sebastian Jansson | b2ecc3d | 2018-07-13 17:22:01 +0200 | [diff] [blame] | 502 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 503 | retransmission_rate_limiter_->SetMaxRate(bitrate_bps); |
Danil Chapovalov | 4e849f6 | 2018-02-14 08:28:02 +0000 | [diff] [blame] | 504 | } |
| 505 | |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 506 | if (IsNetworkDown()) { |
| 507 | bitrate_bps = 0; |
| 508 | } else if (congestion_window_pushback_controller_) { |
| 509 | rtc::CritScope lock(&network_state_lock_); |
| 510 | bitrate_bps = congestion_window_pushback_controller_->UpdateTargetBitrate( |
| 511 | bitrate_bps); |
| 512 | } else if (!pacer_pushback_experiment_) { |
| 513 | bitrate_bps = IsSendQueueFull() ? 0 : bitrate_bps; |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 514 | } else { |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 515 | int64_t queue_length_ms = pacer_->ExpectedQueueTimeMs(); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 516 | |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 517 | if (queue_length_ms == 0) { |
| 518 | encoding_rate_ = 1.0; |
| 519 | } else if (queue_length_ms > 50) { |
| 520 | float encoding_rate = 1.0 - queue_length_ms / 1000.0; |
| 521 | encoding_rate_ = std::min(encoding_rate_, encoding_rate); |
| 522 | encoding_rate_ = std::max(encoding_rate_, 0.0f); |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 523 | } |
Ying Wang | e1d7b23 | 2018-07-17 16:01:25 +0200 | [diff] [blame] | 524 | |
| 525 | bitrate_bps *= encoding_rate_; |
| 526 | bitrate_bps = bitrate_bps < 50000 ? 0 : bitrate_bps; |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | if (HasNetworkParametersToReportChanged(bitrate_bps, fraction_loss, rtt)) { |
| 530 | int64_t probing_interval_ms; |
| 531 | { |
| 532 | rtc::CritScope cs(&bwe_lock_); |
| 533 | probing_interval_ms = delay_based_bwe_->GetExpectedBwePeriodMs(); |
| 534 | } |
| 535 | { |
| 536 | rtc::CritScope cs(&observer_lock_); |
| 537 | if (observer_) { |
| 538 | observer_->OnNetworkChanged(bitrate_bps, fraction_loss, rtt, |
| 539 | probing_interval_ms); |
| 540 | } |
| 541 | } |
| 542 | } |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 543 | } |
Sebastian Jansson | ea86bb7 | 2018-02-14 16:53:38 +0000 | [diff] [blame] | 544 | |
| 545 | bool SendSideCongestionController::HasNetworkParametersToReportChanged( |
| 546 | uint32_t bitrate_bps, |
| 547 | uint8_t fraction_loss, |
| 548 | int64_t rtt) { |
| 549 | rtc::CritScope cs(&network_state_lock_); |
| 550 | bool changed = |
| 551 | last_reported_bitrate_bps_ != bitrate_bps || |
| 552 | (bitrate_bps > 0 && (last_reported_fraction_loss_ != fraction_loss || |
| 553 | last_reported_rtt_ != rtt)); |
| 554 | if (changed && (last_reported_bitrate_bps_ == 0 || bitrate_bps == 0)) { |
| 555 | RTC_LOG(LS_INFO) << "Bitrate estimate state changed, BWE: " << bitrate_bps |
| 556 | << " bps."; |
| 557 | } |
| 558 | last_reported_bitrate_bps_ = bitrate_bps; |
| 559 | last_reported_fraction_loss_ = fraction_loss; |
| 560 | last_reported_rtt_ = rtt; |
| 561 | return changed; |
| 562 | } |
| 563 | |
| 564 | bool SendSideCongestionController::IsSendQueueFull() const { |
| 565 | return pacer_->ExpectedQueueTimeMs() > PacedSender::kMaxQueueLengthMs; |
| 566 | } |
| 567 | |
| 568 | bool SendSideCongestionController::IsNetworkDown() const { |
| 569 | rtc::CritScope cs(&network_state_lock_); |
| 570 | return network_state_ == kNetworkDown; |
| 571 | } |
| 572 | |
nisse | 559af38 | 2017-03-21 06:41:12 -0700 | [diff] [blame] | 573 | } // namespace webrtc |