nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 | */ |
Sebastian Jansson | 91bb667 | 2018-02-21 13:02:51 +0100 | [diff] [blame] | 10 | #include <utility> |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 11 | #include <vector> |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 12 | |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 13 | #include "absl/memory/memory.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "call/rtp_transport_controller_send.h" |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 15 | #include "modules/congestion_controller/include/send_side_congestion_controller.h" |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 16 | #include "modules/congestion_controller/rtp/include/send_side_congestion_controller.h" |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 17 | #include "rtc_base/location.h" |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 18 | #include "rtc_base/logging.h" |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 19 | #include "rtc_base/rate_limiter.h" |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 20 | #include "system_wrappers/include/field_trial.h" |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 21 | |
| 22 | namespace webrtc { |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 23 | namespace { |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 24 | static const int64_t kRetransmitWindowSizeMs = 500; |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 25 | static const size_t kMaxOverheadBytes = 500; |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 26 | const char kTaskQueueExperiment[] = "WebRTC-TaskQueueCongestionControl"; |
| 27 | using TaskQueueController = webrtc::webrtc_cc::SendSideCongestionController; |
| 28 | |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 29 | std::unique_ptr<SendSideCongestionControllerInterface> CreateController( |
| 30 | Clock* clock, |
Sebastian Jansson | bd9fe09 | 2018-05-07 16:33:50 +0200 | [diff] [blame] | 31 | rtc::TaskQueue* task_queue, |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 32 | webrtc::RtcEventLog* event_log, |
| 33 | PacedSender* pacer, |
| 34 | const BitrateConstraints& bitrate_config, |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 35 | bool task_queue_controller, |
| 36 | NetworkControllerFactoryInterface* controller_factory) { |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 37 | if (task_queue_controller) { |
Sebastian Jansson | 4e140da | 2018-04-13 13:25:19 +0200 | [diff] [blame] | 38 | RTC_LOG(LS_INFO) << "Using TaskQueue based SSCC"; |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 39 | return absl::make_unique<webrtc::webrtc_cc::SendSideCongestionController>( |
Sebastian Jansson | bd9fe09 | 2018-05-07 16:33:50 +0200 | [diff] [blame] | 40 | clock, task_queue, event_log, pacer, bitrate_config.start_bitrate_bps, |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 41 | bitrate_config.min_bitrate_bps, bitrate_config.max_bitrate_bps, |
| 42 | controller_factory); |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 43 | } |
Sebastian Jansson | 4e140da | 2018-04-13 13:25:19 +0200 | [diff] [blame] | 44 | RTC_LOG(LS_INFO) << "Using Legacy SSCC"; |
Karl Wiberg | 918f50c | 2018-07-05 11:40:33 +0200 | [diff] [blame] | 45 | auto cc = absl::make_unique<webrtc::SendSideCongestionController>( |
Sebastian Jansson | 19bea51 | 2018-03-13 19:07:46 +0100 | [diff] [blame] | 46 | clock, nullptr /* observer */, event_log, pacer); |
| 47 | cc->SignalNetworkState(kNetworkDown); |
| 48 | cc->SetBweBitrates(bitrate_config.min_bitrate_bps, |
| 49 | bitrate_config.start_bitrate_bps, |
| 50 | bitrate_config.max_bitrate_bps); |
| 51 | return std::move(cc); |
| 52 | } |
| 53 | } // namespace |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 54 | |
| 55 | RtpTransportControllerSend::RtpTransportControllerSend( |
| 56 | Clock* clock, |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 57 | webrtc::RtcEventLog* event_log, |
Sebastian Jansson | dfce03a | 2018-05-18 18:05:10 +0200 | [diff] [blame] | 58 | NetworkControllerFactoryInterface* controller_factory, |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 59 | const BitrateConstraints& bitrate_config) |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 60 | : clock_(clock), |
| 61 | pacer_(clock, &packet_router_, event_log), |
Sebastian Jansson | 317a522 | 2018-03-16 15:36:37 +0100 | [diff] [blame] | 62 | bitrate_configurator_(bitrate_config), |
| 63 | process_thread_(ProcessThread::Create("SendControllerThread")), |
| 64 | observer_(nullptr), |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 65 | retransmission_rate_limiter_(clock, kRetransmitWindowSizeMs), |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 66 | task_queue_("rtp_send_controller") { |
Sebastian Jansson | bd9fe09 | 2018-05-07 16:33:50 +0200 | [diff] [blame] | 67 | // Created after task_queue to be able to post to the task queue internally. |
Sebastian Jansson | 4ff7214 | 2018-10-08 11:15:04 +0200 | [diff] [blame] | 68 | send_side_cc_ = CreateController( |
| 69 | clock, &task_queue_, event_log, &pacer_, bitrate_config, |
| 70 | !field_trial::IsDisabled(kTaskQueueExperiment), controller_factory); |
Sebastian Jansson | bd9fe09 | 2018-05-07 16:33:50 +0200 | [diff] [blame] | 71 | |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 72 | process_thread_->RegisterModule(&pacer_, RTC_FROM_HERE); |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 73 | process_thread_->RegisterModule(send_side_cc_.get(), RTC_FROM_HERE); |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 74 | process_thread_->Start(); |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 75 | } |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 76 | |
| 77 | RtpTransportControllerSend::~RtpTransportControllerSend() { |
| 78 | process_thread_->Stop(); |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 79 | process_thread_->DeRegisterModule(send_side_cc_.get()); |
Sebastian Jansson | c33c0fc | 2018-02-22 11:10:18 +0100 | [diff] [blame] | 80 | process_thread_->DeRegisterModule(&pacer_); |
| 81 | } |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 82 | |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 83 | RtpVideoSenderInterface* RtpTransportControllerSend::CreateRtpVideoSender( |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 84 | const std::vector<uint32_t>& ssrcs, |
| 85 | std::map<uint32_t, RtpState> suspended_ssrcs, |
| 86 | const std::map<uint32_t, RtpPayloadState>& states, |
| 87 | const RtpConfig& rtp_config, |
| 88 | const RtcpConfig& rtcp_config, |
| 89 | Transport* send_transport, |
| 90 | const RtpSenderObservers& observers, |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 91 | RtcEventLog* event_log, |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame] | 92 | std::unique_ptr<FecController> fec_controller, |
| 93 | const RtpSenderFrameEncryptionConfig& frame_encryption_config) { |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 94 | video_rtp_senders_.push_back(absl::make_unique<RtpVideoSender>( |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 95 | ssrcs, suspended_ssrcs, states, rtp_config, rtcp_config, send_transport, |
| 96 | observers, |
| 97 | // TODO(holmer): Remove this circular dependency by injecting |
| 98 | // the parts of RtpTransportControllerSendInterface that are really used. |
Benjamin Wright | 192eeec | 2018-10-17 17:27:25 -0700 | [diff] [blame] | 99 | this, event_log, &retransmission_rate_limiter_, std::move(fec_controller), |
| 100 | frame_encryption_config.frame_encryptor, |
| 101 | frame_encryption_config.crypto_options)); |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 102 | return video_rtp_senders_.back().get(); |
| 103 | } |
| 104 | |
Stefan Holmer | 9416ef8 | 2018-07-19 10:34:38 +0200 | [diff] [blame] | 105 | void RtpTransportControllerSend::DestroyRtpVideoSender( |
| 106 | RtpVideoSenderInterface* rtp_video_sender) { |
| 107 | std::vector<std::unique_ptr<RtpVideoSenderInterface>>::iterator it = |
Stefan Holmer | 5ed25af | 2018-07-18 15:17:14 +0200 | [diff] [blame] | 108 | video_rtp_senders_.end(); |
| 109 | for (it = video_rtp_senders_.begin(); it != video_rtp_senders_.end(); ++it) { |
| 110 | if (it->get() == rtp_video_sender) { |
| 111 | break; |
| 112 | } |
| 113 | } |
| 114 | RTC_DCHECK(it != video_rtp_senders_.end()); |
| 115 | video_rtp_senders_.erase(it); |
| 116 | } |
| 117 | |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 118 | void RtpTransportControllerSend::OnNetworkChanged(uint32_t bitrate_bps, |
| 119 | uint8_t fraction_loss, |
| 120 | int64_t rtt_ms, |
| 121 | int64_t probing_interval_ms) { |
| 122 | // TODO(srte): Skip this step when old SendSideCongestionController is |
| 123 | // deprecated. |
| 124 | TargetTransferRate msg; |
| 125 | msg.at_time = Timestamp::ms(clock_->TimeInMilliseconds()); |
| 126 | msg.target_rate = DataRate::bps(bitrate_bps); |
| 127 | msg.network_estimate.at_time = msg.at_time; |
| 128 | msg.network_estimate.bwe_period = TimeDelta::ms(probing_interval_ms); |
| 129 | uint32_t bandwidth_bps; |
Sebastian Jansson | bd9fe09 | 2018-05-07 16:33:50 +0200 | [diff] [blame] | 130 | if (send_side_cc_->AvailableBandwidth(&bandwidth_bps)) |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 131 | msg.network_estimate.bandwidth = DataRate::bps(bandwidth_bps); |
| 132 | msg.network_estimate.loss_rate_ratio = fraction_loss / 255.0; |
| 133 | msg.network_estimate.round_trip_time = TimeDelta::ms(rtt_ms); |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 134 | |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 135 | retransmission_rate_limiter_.SetMaxRate(bandwidth_bps); |
| 136 | |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 137 | if (!task_queue_.IsCurrent()) { |
| 138 | task_queue_.PostTask([this, msg] { |
| 139 | rtc::CritScope cs(&observer_crit_); |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 140 | // We won't register as observer until we have an observers. |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 141 | RTC_DCHECK(observer_ != nullptr); |
| 142 | observer_->OnTargetTransferRate(msg); |
| 143 | }); |
| 144 | } else { |
| 145 | rtc::CritScope cs(&observer_crit_); |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 146 | // We won't register as observer until we have an observers. |
Sebastian Jansson | e625605 | 2018-05-04 14:08:15 +0200 | [diff] [blame] | 147 | RTC_DCHECK(observer_ != nullptr); |
| 148 | observer_->OnTargetTransferRate(msg); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | rtc::TaskQueue* RtpTransportControllerSend::GetWorkerQueue() { |
| 153 | return &task_queue_; |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 154 | } |
| 155 | |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 156 | PacketRouter* RtpTransportControllerSend::packet_router() { |
| 157 | return &packet_router_; |
| 158 | } |
| 159 | |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 160 | TransportFeedbackObserver* |
| 161 | RtpTransportControllerSend::transport_feedback_observer() { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 162 | return send_side_cc_.get(); |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | RtpPacketSender* RtpTransportControllerSend::packet_sender() { |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 166 | return &pacer_; |
nisse | 76e62b0 | 2017-05-31 02:24:52 -0700 | [diff] [blame] | 167 | } |
| 168 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 169 | const RtpKeepAliveConfig& RtpTransportControllerSend::keepalive_config() const { |
| 170 | return keepalive_; |
| 171 | } |
| 172 | |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 173 | void RtpTransportControllerSend::SetAllocatedSendBitrateLimits( |
| 174 | int min_send_bitrate_bps, |
philipel | 832b1c8 | 2018-02-28 17:04:18 +0100 | [diff] [blame] | 175 | int max_padding_bitrate_bps, |
philipel | db4fa4b | 2018-03-06 18:29:22 +0100 | [diff] [blame] | 176 | int max_total_bitrate_bps) { |
Sebastian Jansson | 68ee465 | 2018-03-13 11:40:34 +0100 | [diff] [blame] | 177 | send_side_cc_->SetAllocatedSendBitrateLimits( |
| 178 | min_send_bitrate_bps, max_padding_bitrate_bps, max_total_bitrate_bps); |
Stefan Holmer | 5c8942a | 2017-08-22 16:16:44 +0200 | [diff] [blame] | 179 | } |
| 180 | |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 181 | void RtpTransportControllerSend::SetKeepAliveConfig( |
| 182 | const RtpKeepAliveConfig& config) { |
| 183 | keepalive_ = config; |
| 184 | } |
Sebastian Jansson | 4c1ffb8 | 2018-02-15 16:51:58 +0100 | [diff] [blame] | 185 | void RtpTransportControllerSend::SetPacingFactor(float pacing_factor) { |
Sebastian Jansson | 68ee465 | 2018-03-13 11:40:34 +0100 | [diff] [blame] | 186 | send_side_cc_->SetPacingFactor(pacing_factor); |
Sebastian Jansson | 4c1ffb8 | 2018-02-15 16:51:58 +0100 | [diff] [blame] | 187 | } |
| 188 | void RtpTransportControllerSend::SetQueueTimeLimit(int limit_ms) { |
| 189 | pacer_.SetQueueTimeLimit(limit_ms); |
| 190 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 191 | CallStatsObserver* RtpTransportControllerSend::GetCallStatsObserver() { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 192 | return send_side_cc_.get(); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 193 | } |
| 194 | void RtpTransportControllerSend::RegisterPacketFeedbackObserver( |
| 195 | PacketFeedbackObserver* observer) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 196 | send_side_cc_->RegisterPacketFeedbackObserver(observer); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 197 | } |
| 198 | void RtpTransportControllerSend::DeRegisterPacketFeedbackObserver( |
| 199 | PacketFeedbackObserver* observer) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 200 | send_side_cc_->DeRegisterPacketFeedbackObserver(observer); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 201 | } |
Sebastian Jansson | 19704ec | 2018-03-12 15:59:12 +0100 | [diff] [blame] | 202 | |
| 203 | void RtpTransportControllerSend::RegisterTargetTransferRateObserver( |
| 204 | TargetTransferRateObserver* observer) { |
| 205 | { |
| 206 | rtc::CritScope cs(&observer_crit_); |
| 207 | RTC_DCHECK(observer_ == nullptr); |
| 208 | observer_ = observer; |
| 209 | } |
| 210 | send_side_cc_->RegisterNetworkObserver(this); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 211 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 212 | void RtpTransportControllerSend::OnNetworkRouteChanged( |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 213 | const std::string& transport_name, |
| 214 | const rtc::NetworkRoute& network_route) { |
Sebastian Jansson | 91bb667 | 2018-02-21 13:02:51 +0100 | [diff] [blame] | 215 | // Check if the network route is connected. |
| 216 | if (!network_route.connected) { |
| 217 | RTC_LOG(LS_INFO) << "Transport " << transport_name << " is disconnected"; |
| 218 | // TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and |
| 219 | // consider merging these two methods. |
| 220 | return; |
| 221 | } |
| 222 | |
| 223 | // Check whether the network route has changed on each transport. |
| 224 | auto result = |
| 225 | network_routes_.insert(std::make_pair(transport_name, network_route)); |
| 226 | auto kv = result.first; |
| 227 | bool inserted = result.second; |
| 228 | if (inserted) { |
| 229 | // No need to reset BWE if this is the first time the network connects. |
| 230 | return; |
| 231 | } |
| 232 | if (kv->second != network_route) { |
| 233 | kv->second = network_route; |
| 234 | BitrateConstraints bitrate_config = bitrate_configurator_.GetConfig(); |
| 235 | RTC_LOG(LS_INFO) << "Network route changed on transport " << transport_name |
| 236 | << ": new local network id " |
| 237 | << network_route.local_network_id |
| 238 | << " new remote network id " |
| 239 | << network_route.remote_network_id |
| 240 | << " Reset bitrates to min: " |
| 241 | << bitrate_config.min_bitrate_bps |
| 242 | << " bps, start: " << bitrate_config.start_bitrate_bps |
| 243 | << " bps, max: " << bitrate_config.max_bitrate_bps |
| 244 | << " bps."; |
| 245 | RTC_DCHECK_GT(bitrate_config.start_bitrate_bps, 0); |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 246 | send_side_cc_->OnNetworkRouteChanged( |
Sebastian Jansson | 91bb667 | 2018-02-21 13:02:51 +0100 | [diff] [blame] | 247 | network_route, bitrate_config.start_bitrate_bps, |
| 248 | bitrate_config.min_bitrate_bps, bitrate_config.max_bitrate_bps); |
| 249 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 250 | } |
| 251 | void RtpTransportControllerSend::OnNetworkAvailability(bool network_available) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 252 | send_side_cc_->SignalNetworkState(network_available ? kNetworkUp |
| 253 | : kNetworkDown); |
Stefan Holmer | dbdb3a0 | 2018-07-17 16:03:46 +0200 | [diff] [blame] | 254 | for (auto& rtp_sender : video_rtp_senders_) { |
| 255 | rtp_sender->OnNetworkAvailability(network_available); |
| 256 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 257 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 258 | RtcpBandwidthObserver* RtpTransportControllerSend::GetBandwidthObserver() { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 259 | return send_side_cc_->GetBandwidthObserver(); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 260 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 261 | int64_t RtpTransportControllerSend::GetPacerQueuingDelayMs() const { |
Sebastian Jansson | a06e919 | 2018-03-07 18:49:55 +0100 | [diff] [blame] | 262 | return pacer_.QueueInMs(); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 263 | } |
| 264 | int64_t RtpTransportControllerSend::GetFirstPacketTimeMs() const { |
Sebastian Jansson | a06e919 | 2018-03-07 18:49:55 +0100 | [diff] [blame] | 265 | return pacer_.FirstSentPacketTimeMs(); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 266 | } |
Sebastian Jansson | 12130bb | 2018-03-21 12:48:43 +0100 | [diff] [blame] | 267 | void RtpTransportControllerSend::SetPerPacketFeedbackAvailable(bool available) { |
| 268 | send_side_cc_->SetPerPacketFeedbackAvailable(available); |
| 269 | } |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 270 | void RtpTransportControllerSend::EnablePeriodicAlrProbing(bool enable) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 271 | send_side_cc_->EnablePeriodicAlrProbing(enable); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 272 | } |
| 273 | void RtpTransportControllerSend::OnSentPacket( |
| 274 | const rtc::SentPacket& sent_packet) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 275 | send_side_cc_->OnSentPacket(sent_packet); |
Sebastian Jansson | e4be6da | 2018-02-15 16:51:41 +0100 | [diff] [blame] | 276 | } |
sprang | db2a9fc | 2017-08-09 06:42:32 -0700 | [diff] [blame] | 277 | |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 278 | void RtpTransportControllerSend::SetSdpBitrateParameters( |
| 279 | const BitrateConstraints& constraints) { |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 280 | absl::optional<BitrateConstraints> updated = |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 281 | bitrate_configurator_.UpdateWithSdpParameters(constraints); |
| 282 | if (updated.has_value()) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 283 | send_side_cc_->SetBweBitrates(updated->min_bitrate_bps, |
| 284 | updated->start_bitrate_bps, |
| 285 | updated->max_bitrate_bps); |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 286 | } else { |
| 287 | RTC_LOG(LS_VERBOSE) |
Sebastian Jansson | 8f83b42 | 2018-02-21 13:07:13 +0100 | [diff] [blame] | 288 | << "WebRTC.RtpTransportControllerSend.SetSdpBitrateParameters: " |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 289 | << "nothing to update"; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | void RtpTransportControllerSend::SetClientBitratePreferences( |
Niels Möller | 0c4f7be | 2018-05-07 14:01:37 +0200 | [diff] [blame] | 294 | const BitrateSettings& preferences) { |
Danil Chapovalov | b9b146c | 2018-06-15 12:28:07 +0200 | [diff] [blame] | 295 | absl::optional<BitrateConstraints> updated = |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 296 | bitrate_configurator_.UpdateWithClientPreferences(preferences); |
| 297 | if (updated.has_value()) { |
Sebastian Jansson | 10211e9 | 2018-02-28 16:48:26 +0100 | [diff] [blame] | 298 | send_side_cc_->SetBweBitrates(updated->min_bitrate_bps, |
| 299 | updated->start_bitrate_bps, |
| 300 | updated->max_bitrate_bps); |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 301 | } else { |
| 302 | RTC_LOG(LS_VERBOSE) |
Sebastian Jansson | 8f83b42 | 2018-02-21 13:07:13 +0100 | [diff] [blame] | 303 | << "WebRTC.RtpTransportControllerSend.SetClientBitratePreferences: " |
Sebastian Jansson | 97f61ea | 2018-02-21 13:01:55 +0100 | [diff] [blame] | 304 | << "nothing to update"; |
| 305 | } |
| 306 | } |
Alex Narest | bcf9180 | 2018-06-25 16:08:36 +0200 | [diff] [blame] | 307 | |
| 308 | void RtpTransportControllerSend::SetAllocatedBitrateWithoutFeedback( |
| 309 | uint32_t bitrate_bps) { |
Sebastian Jansson | 35fa280 | 2018-10-01 09:16:12 +0200 | [diff] [blame] | 310 | // Audio transport feedback will not be reported in this mode, instead update |
| 311 | // acknowledged bitrate estimator with the bitrate allocated for audio. |
| 312 | if (field_trial::IsEnabled("WebRTC-Audio-ABWENoTWCC")) { |
| 313 | // TODO(srte): Make sure it's safe to always report this and remove the |
| 314 | // field trial check. |
| 315 | send_side_cc_->SetAllocatedBitrateWithoutFeedback(bitrate_bps); |
| 316 | } |
Alex Narest | bcf9180 | 2018-06-25 16:08:36 +0200 | [diff] [blame] | 317 | } |
Stefan Holmer | 64be7fa | 2018-10-04 15:21:55 +0200 | [diff] [blame] | 318 | |
| 319 | void RtpTransportControllerSend::OnTransportOverheadChanged( |
| 320 | size_t transport_overhead_bytes_per_packet) { |
| 321 | if (transport_overhead_bytes_per_packet >= kMaxOverheadBytes) { |
| 322 | RTC_LOG(LS_ERROR) << "Transport overhead exceeds " << kMaxOverheadBytes; |
| 323 | return; |
| 324 | } |
| 325 | |
| 326 | // TODO(holmer): Call AudioRtpSenders when they have been moved to |
| 327 | // RtpTransportControllerSend. |
| 328 | for (auto& rtp_video_sender : video_rtp_senders_) { |
| 329 | rtp_video_sender->OnTransportOverheadChanged( |
| 330 | transport_overhead_bytes_per_packet); |
| 331 | } |
| 332 | } |
nisse | cae45d0 | 2017-04-24 05:53:20 -0700 | [diff] [blame] | 333 | } // namespace webrtc |