Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #include "pc/rtp_transceiver.h" |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 12 | |
Harald Alvestrand | c24a218 | 2022-02-23 13:44:59 +0000 | [diff] [blame] | 13 | #include <algorithm> |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 14 | #include <iterator> |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 15 | #include <string> |
Markus Handell | 0357b3e | 2020-03-16 13:40:51 +0100 | [diff] [blame] | 16 | #include <utility> |
Markus Handell | 5932fe1 | 2020-12-17 22:19:40 +0100 | [diff] [blame] | 17 | #include <vector> |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 18 | |
Steve Anton | 64b626b | 2019-01-28 17:25:26 -0800 | [diff] [blame] | 19 | #include "absl/algorithm/container.h" |
Markus Handell | 0357b3e | 2020-03-16 13:40:51 +0100 | [diff] [blame] | 20 | #include "api/rtp_parameters.h" |
Artem Titov | d15a575 | 2021-02-10 14:31:24 +0100 | [diff] [blame] | 21 | #include "api/sequence_checker.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 22 | #include "media/base/codec.h" |
| 23 | #include "media/base/media_constants.h" |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 24 | #include "pc/channel_manager.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 25 | #include "pc/rtp_media_utils.h" |
Markus Handell | 5932fe1 | 2020-12-17 22:19:40 +0100 | [diff] [blame] | 26 | #include "pc/session_description.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 27 | #include "rtc_base/checks.h" |
Harald Alvestrand | c24a218 | 2022-02-23 13:44:59 +0000 | [diff] [blame] | 28 | #include "rtc_base/location.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 29 | #include "rtc_base/logging.h" |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 30 | #include "rtc_base/task_utils/to_queued_task.h" |
Harald Alvestrand | 5761e7b | 2021-01-29 14:45:08 +0000 | [diff] [blame] | 31 | #include "rtc_base/thread.h" |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 32 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 33 | namespace webrtc { |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 34 | namespace { |
| 35 | template <class T> |
| 36 | RTCError VerifyCodecPreferences(const std::vector<RtpCodecCapability>& codecs, |
| 37 | const std::vector<T>& send_codecs, |
| 38 | const std::vector<T>& recv_codecs) { |
| 39 | // If the intersection between codecs and |
| 40 | // RTCRtpSender.getCapabilities(kind).codecs or the intersection between |
| 41 | // codecs and RTCRtpReceiver.getCapabilities(kind).codecs only contains RTX, |
| 42 | // RED or FEC codecs or is an empty set, throw InvalidModificationError. |
| 43 | // This ensures that we always have something to offer, regardless of |
| 44 | // transceiver.direction. |
| 45 | |
| 46 | if (!absl::c_any_of(codecs, [&recv_codecs](const RtpCodecCapability& codec) { |
| 47 | return codec.name != cricket::kRtxCodecName && |
| 48 | codec.name != cricket::kRedCodecName && |
| 49 | codec.name != cricket::kFlexfecCodecName && |
| 50 | absl::c_any_of(recv_codecs, [&codec](const T& recv_codec) { |
| 51 | return recv_codec.MatchesCapability(codec); |
| 52 | }); |
| 53 | })) { |
| 54 | return RTCError(RTCErrorType::INVALID_MODIFICATION, |
| 55 | "Invalid codec preferences: Missing codec from recv " |
| 56 | "codec capabilities."); |
| 57 | } |
| 58 | |
| 59 | if (!absl::c_any_of(codecs, [&send_codecs](const RtpCodecCapability& codec) { |
| 60 | return codec.name != cricket::kRtxCodecName && |
| 61 | codec.name != cricket::kRedCodecName && |
| 62 | codec.name != cricket::kFlexfecCodecName && |
| 63 | absl::c_any_of(send_codecs, [&codec](const T& send_codec) { |
| 64 | return send_codec.MatchesCapability(codec); |
| 65 | }); |
| 66 | })) { |
| 67 | return RTCError(RTCErrorType::INVALID_MODIFICATION, |
| 68 | "Invalid codec preferences: Missing codec from send " |
| 69 | "codec capabilities."); |
| 70 | } |
| 71 | |
| 72 | // Let codecCapabilities be the union of |
| 73 | // RTCRtpSender.getCapabilities(kind).codecs and |
| 74 | // RTCRtpReceiver.getCapabilities(kind).codecs. For each codec in codecs, If |
| 75 | // codec is not in codecCapabilities, throw InvalidModificationError. |
| 76 | for (const auto& codec_preference : codecs) { |
| 77 | bool is_recv_codec = |
| 78 | absl::c_any_of(recv_codecs, [&codec_preference](const T& codec) { |
| 79 | return codec.MatchesCapability(codec_preference); |
| 80 | }); |
| 81 | |
| 82 | bool is_send_codec = |
| 83 | absl::c_any_of(send_codecs, [&codec_preference](const T& codec) { |
| 84 | return codec.MatchesCapability(codec_preference); |
| 85 | }); |
| 86 | |
| 87 | if (!is_recv_codec && !is_send_codec) { |
| 88 | return RTCError( |
| 89 | RTCErrorType::INVALID_MODIFICATION, |
| 90 | std::string("Invalid codec preferences: invalid codec with name \"") + |
| 91 | codec_preference.name + "\"."); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | // Check we have a real codec (not just rtx, red or fec) |
| 96 | if (absl::c_all_of(codecs, [](const RtpCodecCapability& codec) { |
| 97 | return codec.name == cricket::kRtxCodecName || |
| 98 | codec.name == cricket::kRedCodecName || |
| 99 | codec.name == cricket::kUlpfecCodecName; |
| 100 | })) { |
| 101 | return RTCError(RTCErrorType::INVALID_MODIFICATION, |
| 102 | "Invalid codec preferences: codec list must have a non " |
| 103 | "RTX, RED or FEC entry."); |
| 104 | } |
| 105 | |
| 106 | return RTCError::OK(); |
| 107 | } |
| 108 | |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 109 | TaskQueueBase* GetCurrentTaskQueueOrThread() { |
| 110 | TaskQueueBase* current = TaskQueueBase::Current(); |
| 111 | if (!current) |
| 112 | current = rtc::ThreadManager::Instance()->CurrentThread(); |
| 113 | return current; |
| 114 | } |
| 115 | |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 116 | } // namespace |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 117 | |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 118 | RtpTransceiver::RtpTransceiver( |
| 119 | cricket::MediaType media_type, |
| 120 | cricket::ChannelManager* channel_manager /* = nullptr*/) |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 121 | : thread_(GetCurrentTaskQueueOrThread()), |
| 122 | unified_plan_(false), |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 123 | media_type_(media_type), |
| 124 | channel_manager_(channel_manager) { |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 125 | RTC_DCHECK(media_type == cricket::MEDIA_TYPE_AUDIO || |
| 126 | media_type == cricket::MEDIA_TYPE_VIDEO); |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 127 | RTC_DCHECK(channel_manager_); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 128 | } |
| 129 | |
Steve Anton | 79e7960 | 2017-11-20 10:25:56 -0800 | [diff] [blame] | 130 | RtpTransceiver::RtpTransceiver( |
| 131 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender, |
| 132 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 133 | receiver, |
Markus Handell | 0357b3e | 2020-03-16 13:40:51 +0100 | [diff] [blame] | 134 | cricket::ChannelManager* channel_manager, |
Harald Alvestrand | 280054f | 2020-11-10 13:12:53 +0000 | [diff] [blame] | 135 | std::vector<RtpHeaderExtensionCapability> header_extensions_offered, |
| 136 | std::function<void()> on_negotiation_needed) |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 137 | : thread_(GetCurrentTaskQueueOrThread()), |
| 138 | unified_plan_(true), |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 139 | media_type_(sender->media_type()), |
Markus Handell | 0357b3e | 2020-03-16 13:40:51 +0100 | [diff] [blame] | 140 | channel_manager_(channel_manager), |
Harald Alvestrand | 280054f | 2020-11-10 13:12:53 +0000 | [diff] [blame] | 141 | header_extensions_to_offer_(std::move(header_extensions_offered)), |
| 142 | on_negotiation_needed_(std::move(on_negotiation_needed)) { |
Steve Anton | 79e7960 | 2017-11-20 10:25:56 -0800 | [diff] [blame] | 143 | RTC_DCHECK(media_type_ == cricket::MEDIA_TYPE_AUDIO || |
| 144 | media_type_ == cricket::MEDIA_TYPE_VIDEO); |
| 145 | RTC_DCHECK_EQ(sender->media_type(), receiver->media_type()); |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 146 | RTC_DCHECK(channel_manager_); |
Steve Anton | 79e7960 | 2017-11-20 10:25:56 -0800 | [diff] [blame] | 147 | senders_.push_back(sender); |
| 148 | receivers_.push_back(receiver); |
| 149 | } |
| 150 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 151 | RtpTransceiver::~RtpTransceiver() { |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 152 | // TODO(tommi): On Android, when running PeerConnectionClientTest (e.g. |
| 153 | // PeerConnectionClientTest#testCameraSwitch), the instance doesn't get |
| 154 | // deleted on `thread_`. See if we can fix that. |
Harald Alvestrand | 8546666 | 2021-04-19 21:21:36 +0000 | [diff] [blame] | 155 | if (!stopped_) { |
| 156 | RTC_DCHECK_RUN_ON(thread_); |
| 157 | StopInternal(); |
| 158 | } |
Tomas Gunnarsson | 16de216 | 2022-01-26 10:21:57 +0100 | [diff] [blame] | 159 | |
| 160 | RTC_CHECK(!channel_) << "Missing call to SetChannel(nullptr)?"; |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 161 | } |
| 162 | |
Tomas Gunnarsson | 4f8a58c | 2022-01-19 11:36:23 +0100 | [diff] [blame] | 163 | void RtpTransceiver::SetChannel( |
| 164 | cricket::ChannelInterface* channel, |
| 165 | std::function<RtpTransportInternal*(const std::string&)> transport_lookup) { |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 166 | RTC_DCHECK_RUN_ON(thread_); |
Harald Alvestrand | 19ebabc | 2022-04-28 13:31:17 +0000 | [diff] [blame^] | 167 | RTC_DCHECK(channel); // Use ClearChannel() if clearing. |
| 168 | RTC_DCHECK(transport_lookup); |
| 169 | // Cannot set a channel on a stopped transceiver. |
| 170 | if (stopped_ || channel == channel_) { |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 171 | return; |
| 172 | } |
| 173 | |
Tommi | fe04164 | 2021-04-07 10:08:28 +0200 | [diff] [blame] | 174 | RTC_LOG_THREAD_BLOCK_COUNT(); |
| 175 | |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 176 | if (channel_) { |
| 177 | signaling_thread_safety_->SetNotAlive(); |
| 178 | signaling_thread_safety_ = nullptr; |
| 179 | } |
| 180 | |
Harald Alvestrand | 19ebabc | 2022-04-28 13:31:17 +0000 | [diff] [blame^] | 181 | RTC_DCHECK_EQ(media_type(), channel->media_type()); |
| 182 | signaling_thread_safety_ = PendingTaskSafetyFlag::Create(); |
Steve Anton | 6077675 | 2018-01-10 11:51:34 -0800 | [diff] [blame] | 183 | |
Tomas Gunnarsson | 16de216 | 2022-01-26 10:21:57 +0100 | [diff] [blame] | 184 | cricket::ChannelInterface* channel_to_delete = nullptr; |
| 185 | |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 186 | // An alternative to this, could be to require SetChannel to be called |
| 187 | // on the network thread. The channel object operates for the most part |
| 188 | // on the network thread, as part of its initialization being on the network |
| 189 | // thread is required, so setting a channel object as part of the construction |
| 190 | // (without thread hopping) might be the more efficient thing to do than |
| 191 | // how SetChannel works today. |
| 192 | // Similarly, if the channel() accessor is limited to the network thread, that |
| 193 | // helps with keeping the channel implementation requirements being met and |
| 194 | // avoids synchronization for accessing the pointer or network related state. |
| 195 | channel_manager_->network_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { |
| 196 | if (channel_) { |
| 197 | channel_->SetFirstPacketReceivedCallback(nullptr); |
Tomas Gunnarsson | 4f8a58c | 2022-01-19 11:36:23 +0100 | [diff] [blame] | 198 | channel_->SetRtpTransport(nullptr); |
Tomas Gunnarsson | 16de216 | 2022-01-26 10:21:57 +0100 | [diff] [blame] | 199 | channel_to_delete = channel_; |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 200 | } |
Steve Anton | 6077675 | 2018-01-10 11:51:34 -0800 | [diff] [blame] | 201 | |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 202 | channel_ = channel; |
Steve Anton | 6077675 | 2018-01-10 11:51:34 -0800 | [diff] [blame] | 203 | |
Harald Alvestrand | 19ebabc | 2022-04-28 13:31:17 +0000 | [diff] [blame^] | 204 | channel_->SetRtpTransport(transport_lookup(channel_->mid())); |
| 205 | channel_->SetFirstPacketReceivedCallback( |
| 206 | [thread = thread_, flag = signaling_thread_safety_, this]() mutable { |
| 207 | thread->PostTask(ToQueuedTask(std::move(flag), |
| 208 | [this]() { OnFirstPacketReceived(); })); |
| 209 | }); |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 210 | }); |
Steve Anton | 6077675 | 2018-01-10 11:51:34 -0800 | [diff] [blame] | 211 | |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 212 | RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1); |
Tommi | fe04164 | 2021-04-07 10:08:28 +0200 | [diff] [blame] | 213 | |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 214 | if (channel_to_delete || !senders_.empty() || !receivers_.empty()) { |
Harald Alvestrand | 19ebabc | 2022-04-28 13:31:17 +0000 | [diff] [blame^] | 215 | DeleteChannel(channel_to_delete); |
Tomas Gunnarsson | 16de216 | 2022-01-26 10:21:57 +0100 | [diff] [blame] | 216 | } |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 217 | |
| 218 | RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(2); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 219 | } |
| 220 | |
Harald Alvestrand | 19ebabc | 2022-04-28 13:31:17 +0000 | [diff] [blame^] | 221 | void RtpTransceiver::ClearChannel() { |
| 222 | RTC_DCHECK_RUN_ON(thread_); |
| 223 | |
| 224 | if (!channel_) { |
| 225 | return; |
| 226 | } |
| 227 | |
| 228 | RTC_LOG_THREAD_BLOCK_COUNT(); |
| 229 | |
| 230 | if (channel_) { |
| 231 | signaling_thread_safety_->SetNotAlive(); |
| 232 | signaling_thread_safety_ = nullptr; |
| 233 | } |
| 234 | cricket::ChannelInterface* channel_to_delete = nullptr; |
| 235 | |
| 236 | channel_manager_->network_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { |
| 237 | if (channel_) { |
| 238 | channel_->SetFirstPacketReceivedCallback(nullptr); |
| 239 | channel_->SetRtpTransport(nullptr); |
| 240 | channel_to_delete = channel_; |
| 241 | } |
| 242 | |
| 243 | channel_ = nullptr; |
| 244 | }); |
| 245 | |
| 246 | RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(1); |
| 247 | |
| 248 | if (channel_to_delete || !senders_.empty() || !receivers_.empty()) { |
| 249 | DeleteChannel(channel_to_delete); |
| 250 | } |
| 251 | |
| 252 | RTC_DCHECK_BLOCK_COUNT_NO_MORE_THAN(2); |
| 253 | } |
| 254 | |
| 255 | void RtpTransceiver::DeleteChannel( |
| 256 | cricket::ChannelInterface* channel_to_delete) { |
| 257 | channel_manager_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { |
| 258 | auto* media_channel = channel_ ? channel_->media_channel() : nullptr; |
| 259 | for (const auto& sender : senders_) { |
| 260 | sender->internal()->SetMediaChannel(media_channel); |
| 261 | } |
| 262 | |
| 263 | for (const auto& receiver : receivers_) { |
| 264 | receiver->internal()->SetMediaChannel(media_channel); |
| 265 | } |
| 266 | |
| 267 | // Destroy the channel, if we had one, now _after_ updating the receivers |
| 268 | // who might have had references to the previous channel. |
| 269 | if (channel_to_delete) { |
| 270 | channel_manager_->DestroyChannel(channel_to_delete); |
| 271 | } |
| 272 | }); |
| 273 | } |
| 274 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 275 | void RtpTransceiver::AddSender( |
| 276 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender) { |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 277 | RTC_DCHECK_RUN_ON(thread_); |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 278 | RTC_DCHECK(!stopped_); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 279 | RTC_DCHECK(!unified_plan_); |
| 280 | RTC_DCHECK(sender); |
Steve Anton | 6947025 | 2018-02-09 11:43:08 -0800 | [diff] [blame] | 281 | RTC_DCHECK_EQ(media_type(), sender->media_type()); |
Steve Anton | 64b626b | 2019-01-28 17:25:26 -0800 | [diff] [blame] | 282 | RTC_DCHECK(!absl::c_linear_search(senders_, sender)); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 283 | senders_.push_back(sender); |
| 284 | } |
| 285 | |
| 286 | bool RtpTransceiver::RemoveSender(RtpSenderInterface* sender) { |
| 287 | RTC_DCHECK(!unified_plan_); |
| 288 | if (sender) { |
| 289 | RTC_DCHECK_EQ(media_type(), sender->media_type()); |
| 290 | } |
Steve Anton | 64b626b | 2019-01-28 17:25:26 -0800 | [diff] [blame] | 291 | auto it = absl::c_find(senders_, sender); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 292 | if (it == senders_.end()) { |
| 293 | return false; |
| 294 | } |
| 295 | (*it)->internal()->Stop(); |
| 296 | senders_.erase(it); |
| 297 | return true; |
| 298 | } |
| 299 | |
| 300 | void RtpTransceiver::AddReceiver( |
| 301 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
| 302 | receiver) { |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 303 | RTC_DCHECK_RUN_ON(thread_); |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 304 | RTC_DCHECK(!stopped_); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 305 | RTC_DCHECK(!unified_plan_); |
| 306 | RTC_DCHECK(receiver); |
Steve Anton | 6947025 | 2018-02-09 11:43:08 -0800 | [diff] [blame] | 307 | RTC_DCHECK_EQ(media_type(), receiver->media_type()); |
Steve Anton | 64b626b | 2019-01-28 17:25:26 -0800 | [diff] [blame] | 308 | RTC_DCHECK(!absl::c_linear_search(receivers_, receiver)); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 309 | receivers_.push_back(receiver); |
| 310 | } |
| 311 | |
| 312 | bool RtpTransceiver::RemoveReceiver(RtpReceiverInterface* receiver) { |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 313 | RTC_DCHECK_RUN_ON(thread_); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 314 | RTC_DCHECK(!unified_plan_); |
| 315 | if (receiver) { |
| 316 | RTC_DCHECK_EQ(media_type(), receiver->media_type()); |
| 317 | } |
Steve Anton | 64b626b | 2019-01-28 17:25:26 -0800 | [diff] [blame] | 318 | auto it = absl::c_find(receivers_, receiver); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 319 | if (it == receivers_.end()) { |
| 320 | return false; |
| 321 | } |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 322 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 323 | (*it)->internal()->Stop(); |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 324 | channel_manager_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { |
| 325 | // `Stop()` will clear the receiver's pointer to the media channel. |
| 326 | (*it)->internal()->SetMediaChannel(nullptr); |
| 327 | }); |
| 328 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 329 | receivers_.erase(it); |
| 330 | return true; |
| 331 | } |
| 332 | |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 333 | rtc::scoped_refptr<RtpSenderInternal> RtpTransceiver::sender_internal() const { |
| 334 | RTC_DCHECK(unified_plan_); |
| 335 | RTC_CHECK_EQ(1u, senders_.size()); |
Niels Möller | e7cc883 | 2022-01-04 15:20:03 +0100 | [diff] [blame] | 336 | return rtc::scoped_refptr<RtpSenderInternal>(senders_[0]->internal()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 337 | } |
| 338 | |
| 339 | rtc::scoped_refptr<RtpReceiverInternal> RtpTransceiver::receiver_internal() |
| 340 | const { |
| 341 | RTC_DCHECK(unified_plan_); |
| 342 | RTC_CHECK_EQ(1u, receivers_.size()); |
Niels Möller | e7cc883 | 2022-01-04 15:20:03 +0100 | [diff] [blame] | 343 | return rtc::scoped_refptr<RtpReceiverInternal>(receivers_[0]->internal()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 344 | } |
| 345 | |
Steve Anton | 6947025 | 2018-02-09 11:43:08 -0800 | [diff] [blame] | 346 | cricket::MediaType RtpTransceiver::media_type() const { |
| 347 | return media_type_; |
| 348 | } |
| 349 | |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 350 | absl::optional<std::string> RtpTransceiver::mid() const { |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 351 | return mid_; |
| 352 | } |
| 353 | |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 354 | void RtpTransceiver::OnFirstPacketReceived() { |
Mirko Bonadei | 739baf0 | 2019-01-27 17:29:42 +0100 | [diff] [blame] | 355 | for (const auto& receiver : receivers_) { |
Steve Anton | 6077675 | 2018-01-10 11:51:34 -0800 | [diff] [blame] | 356 | receiver->internal()->NotifyFirstPacketReceived(); |
| 357 | } |
| 358 | } |
| 359 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 360 | rtc::scoped_refptr<RtpSenderInterface> RtpTransceiver::sender() const { |
| 361 | RTC_DCHECK(unified_plan_); |
| 362 | RTC_CHECK_EQ(1u, senders_.size()); |
| 363 | return senders_[0]; |
| 364 | } |
| 365 | |
| 366 | rtc::scoped_refptr<RtpReceiverInterface> RtpTransceiver::receiver() const { |
| 367 | RTC_DCHECK(unified_plan_); |
| 368 | RTC_CHECK_EQ(1u, receivers_.size()); |
| 369 | return receivers_[0]; |
| 370 | } |
| 371 | |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 372 | void RtpTransceiver::set_current_direction(RtpTransceiverDirection direction) { |
Steve Anton | 3d954a6 | 2018-04-02 11:27:23 -0700 | [diff] [blame] | 373 | RTC_LOG(LS_INFO) << "Changing transceiver (MID=" << mid_.value_or("<not set>") |
| 374 | << ") current direction from " |
| 375 | << (current_direction_ ? RtpTransceiverDirectionToString( |
| 376 | *current_direction_) |
| 377 | : "<not set>") |
| 378 | << " to " << RtpTransceiverDirectionToString(direction) |
| 379 | << "."; |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 380 | current_direction_ = direction; |
| 381 | if (RtpTransceiverDirectionHasSend(*current_direction_)) { |
| 382 | has_ever_been_used_to_send_ = true; |
| 383 | } |
| 384 | } |
| 385 | |
Steve Anton | 0f5400a | 2018-07-17 14:25:36 -0700 | [diff] [blame] | 386 | void RtpTransceiver::set_fired_direction(RtpTransceiverDirection direction) { |
| 387 | fired_direction_ = direction; |
| 388 | } |
| 389 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 390 | bool RtpTransceiver::stopped() const { |
Tommi | 99c8a80 | 2021-04-27 15:00:00 +0200 | [diff] [blame] | 391 | RTC_DCHECK_RUN_ON(thread_); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 392 | return stopped_; |
| 393 | } |
| 394 | |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 395 | bool RtpTransceiver::stopping() const { |
| 396 | RTC_DCHECK_RUN_ON(thread_); |
| 397 | return stopping_; |
| 398 | } |
| 399 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 400 | RtpTransceiverDirection RtpTransceiver::direction() const { |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 401 | if (unified_plan_ && stopping()) |
| 402 | return webrtc::RtpTransceiverDirection::kStopped; |
| 403 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 404 | return direction_; |
| 405 | } |
| 406 | |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 407 | RTCError RtpTransceiver::SetDirectionWithError( |
| 408 | RtpTransceiverDirection new_direction) { |
| 409 | if (unified_plan_ && stopping()) { |
| 410 | LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_STATE, |
| 411 | "Cannot set direction on a stopping transceiver."); |
Steve Anton | 52d8677 | 2018-02-20 15:48:12 -0800 | [diff] [blame] | 412 | } |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 413 | if (new_direction == direction_) |
| 414 | return RTCError::OK(); |
| 415 | |
| 416 | if (new_direction == RtpTransceiverDirection::kStopped) { |
| 417 | LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER, |
| 418 | "The set direction 'stopped' is invalid."); |
Steve Anton | 52d8677 | 2018-02-20 15:48:12 -0800 | [diff] [blame] | 419 | } |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 420 | |
Steve Anton | 52d8677 | 2018-02-20 15:48:12 -0800 | [diff] [blame] | 421 | direction_ = new_direction; |
Harald Alvestrand | 280054f | 2020-11-10 13:12:53 +0000 | [diff] [blame] | 422 | on_negotiation_needed_(); |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 423 | |
| 424 | return RTCError::OK(); |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 425 | } |
| 426 | |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 427 | absl::optional<RtpTransceiverDirection> RtpTransceiver::current_direction() |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 428 | const { |
Harald Alvestrand | c75c428 | 2020-08-26 12:17:54 +0000 | [diff] [blame] | 429 | if (unified_plan_ && stopped()) |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 430 | return webrtc::RtpTransceiverDirection::kStopped; |
| 431 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 432 | return current_direction_; |
| 433 | } |
| 434 | |
Steve Anton | 0f5400a | 2018-07-17 14:25:36 -0700 | [diff] [blame] | 435 | absl::optional<RtpTransceiverDirection> RtpTransceiver::fired_direction() |
| 436 | const { |
| 437 | return fired_direction_; |
| 438 | } |
| 439 | |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 440 | void RtpTransceiver::StopSendingAndReceiving() { |
| 441 | // 1. Let sender be transceiver.[[Sender]]. |
| 442 | // 2. Let receiver be transceiver.[[Receiver]]. |
| 443 | // |
| 444 | // 3. Stop sending media with sender. |
| 445 | // |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 446 | RTC_DCHECK_RUN_ON(thread_); |
| 447 | |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 448 | // 4. Send an RTCP BYE for each RTP stream that was being sent by sender, as |
| 449 | // specified in [RFC3550]. |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 450 | for (const auto& sender : senders_) |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 451 | sender->internal()->Stop(); |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 452 | |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 453 | // Signal to receiver sources that we're stopping. |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 454 | for (const auto& receiver : receivers_) |
Tommi | 6589def | 2022-02-17 23:36:47 +0100 | [diff] [blame] | 455 | receiver->internal()->Stop(); |
| 456 | |
| 457 | channel_manager_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [&]() { |
| 458 | // 5 Stop receiving media with receiver. |
| 459 | for (const auto& receiver : receivers_) |
| 460 | receiver->internal()->SetMediaChannel(nullptr); |
| 461 | }); |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 462 | |
| 463 | stopping_ = true; |
| 464 | direction_ = webrtc::RtpTransceiverDirection::kInactive; |
| 465 | } |
| 466 | |
| 467 | RTCError RtpTransceiver::StopStandard() { |
| 468 | RTC_DCHECK_RUN_ON(thread_); |
Harald Alvestrand | c75c428 | 2020-08-26 12:17:54 +0000 | [diff] [blame] | 469 | // If we're on Plan B, do what Stop() used to do there. |
| 470 | if (!unified_plan_) { |
| 471 | StopInternal(); |
| 472 | return RTCError::OK(); |
| 473 | } |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 474 | // 1. Let transceiver be the RTCRtpTransceiver object on which the method is |
| 475 | // invoked. |
| 476 | // |
| 477 | // 2. Let connection be the RTCPeerConnection object associated with |
| 478 | // transceiver. |
| 479 | // |
| 480 | // 3. If connection.[[IsClosed]] is true, throw an InvalidStateError. |
| 481 | if (is_pc_closed_) { |
| 482 | LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_STATE, |
| 483 | "PeerConnection is closed."); |
Harald Alvestrand | a88c977 | 2020-08-10 18:06:09 +0000 | [diff] [blame] | 484 | } |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 485 | |
| 486 | // 4. If transceiver.[[Stopping]] is true, abort these steps. |
| 487 | if (stopping_) |
| 488 | return RTCError::OK(); |
| 489 | |
| 490 | // 5. Stop sending and receiving given transceiver, and update the |
| 491 | // negotiation-needed flag for connection. |
| 492 | StopSendingAndReceiving(); |
Harald Alvestrand | 280054f | 2020-11-10 13:12:53 +0000 | [diff] [blame] | 493 | on_negotiation_needed_(); |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 494 | |
| 495 | return RTCError::OK(); |
| 496 | } |
| 497 | |
| 498 | void RtpTransceiver::StopInternal() { |
Harald Alvestrand | 8546666 | 2021-04-19 21:21:36 +0000 | [diff] [blame] | 499 | RTC_DCHECK_RUN_ON(thread_); |
Harald Alvestrand | c75c428 | 2020-08-26 12:17:54 +0000 | [diff] [blame] | 500 | StopTransceiverProcedure(); |
| 501 | } |
| 502 | |
| 503 | void RtpTransceiver::StopTransceiverProcedure() { |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 504 | RTC_DCHECK_RUN_ON(thread_); |
Harald Alvestrand | c75c428 | 2020-08-26 12:17:54 +0000 | [diff] [blame] | 505 | // As specified in the "Stop the RTCRtpTransceiver" procedure |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 506 | // 1. If transceiver.[[Stopping]] is false, stop sending and receiving given |
| 507 | // transceiver. |
| 508 | if (!stopping_) |
| 509 | StopSendingAndReceiving(); |
| 510 | |
| 511 | // 2. Set transceiver.[[Stopped]] to true. |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 512 | stopped_ = true; |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 513 | |
| 514 | // Signal the updated change to the senders. |
| 515 | for (const auto& sender : senders_) |
| 516 | sender->internal()->SetTransceiverAsStopped(); |
| 517 | |
| 518 | // 3. Set transceiver.[[Receptive]] to false. |
| 519 | // 4. Set transceiver.[[CurrentDirection]] to null. |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 520 | current_direction_ = absl::nullopt; |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 521 | } |
| 522 | |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 523 | RTCError RtpTransceiver::SetCodecPreferences( |
| 524 | rtc::ArrayView<RtpCodecCapability> codec_capabilities) { |
| 525 | RTC_DCHECK(unified_plan_); |
| 526 | |
| 527 | // 3. If codecs is an empty list, set transceiver's [[PreferredCodecs]] slot |
| 528 | // to codecs and abort these steps. |
| 529 | if (codec_capabilities.empty()) { |
| 530 | codec_preferences_.clear(); |
| 531 | return RTCError::OK(); |
| 532 | } |
| 533 | |
| 534 | // 4. Remove any duplicate values in codecs. |
| 535 | std::vector<RtpCodecCapability> codecs; |
| 536 | absl::c_remove_copy_if(codec_capabilities, std::back_inserter(codecs), |
| 537 | [&codecs](const RtpCodecCapability& codec) { |
| 538 | return absl::c_linear_search(codecs, codec); |
| 539 | }); |
| 540 | |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 541 | // 6. to 8. |
| 542 | RTCError result; |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 543 | if (media_type_ == cricket::MEDIA_TYPE_AUDIO) { |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 544 | std::vector<cricket::AudioCodec> recv_codecs, send_codecs; |
| 545 | channel_manager_->GetSupportedAudioReceiveCodecs(&recv_codecs); |
| 546 | channel_manager_->GetSupportedAudioSendCodecs(&send_codecs); |
| 547 | |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 548 | result = VerifyCodecPreferences(codecs, send_codecs, recv_codecs); |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 549 | } else if (media_type_ == cricket::MEDIA_TYPE_VIDEO) { |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 550 | std::vector<cricket::VideoCodec> recv_codecs, send_codecs; |
| 551 | channel_manager_->GetSupportedVideoReceiveCodecs(&recv_codecs); |
| 552 | channel_manager_->GetSupportedVideoSendCodecs(&send_codecs); |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 553 | |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 554 | result = VerifyCodecPreferences(codecs, send_codecs, recv_codecs); |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 555 | } |
| 556 | |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 557 | if (result.ok()) { |
| 558 | codec_preferences_ = codecs; |
Florent Castelli | 2d9d82e | 2019-04-23 19:25:51 +0200 | [diff] [blame] | 559 | } |
| 560 | |
Johannes Kron | 3e98368 | 2020-03-29 22:17:00 +0200 | [diff] [blame] | 561 | return result; |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 562 | } |
| 563 | |
Markus Handell | 0357b3e | 2020-03-16 13:40:51 +0100 | [diff] [blame] | 564 | std::vector<RtpHeaderExtensionCapability> |
| 565 | RtpTransceiver::HeaderExtensionsToOffer() const { |
Markus Handell | 755c65d | 2020-06-24 01:06:10 +0200 | [diff] [blame] | 566 | return header_extensions_to_offer_; |
| 567 | } |
| 568 | |
Markus Handell | 5932fe1 | 2020-12-17 22:19:40 +0100 | [diff] [blame] | 569 | std::vector<RtpHeaderExtensionCapability> |
| 570 | RtpTransceiver::HeaderExtensionsNegotiated() const { |
Tommi | cc7a368 | 2021-05-04 14:59:38 +0200 | [diff] [blame] | 571 | RTC_DCHECK_RUN_ON(thread_); |
Markus Handell | 5932fe1 | 2020-12-17 22:19:40 +0100 | [diff] [blame] | 572 | std::vector<RtpHeaderExtensionCapability> result; |
Tommi | cc7a368 | 2021-05-04 14:59:38 +0200 | [diff] [blame] | 573 | for (const auto& ext : negotiated_header_extensions_) { |
Markus Handell | 5932fe1 | 2020-12-17 22:19:40 +0100 | [diff] [blame] | 574 | result.emplace_back(ext.uri, ext.id, RtpTransceiverDirection::kSendRecv); |
| 575 | } |
| 576 | return result; |
| 577 | } |
| 578 | |
Markus Handell | 755c65d | 2020-06-24 01:06:10 +0200 | [diff] [blame] | 579 | RTCError RtpTransceiver::SetOfferedRtpHeaderExtensions( |
| 580 | rtc::ArrayView<const RtpHeaderExtensionCapability> |
| 581 | header_extensions_to_offer) { |
| 582 | for (const auto& entry : header_extensions_to_offer) { |
| 583 | // Handle unsupported requests for mandatory extensions as per |
| 584 | // https://w3c.github.io/webrtc-extensions/#rtcrtptransceiver-interface. |
| 585 | // Note: |
| 586 | // - We do not handle setOfferedRtpHeaderExtensions algorithm step 2.1, |
| 587 | // this has to be checked on a higher level. We naturally error out |
| 588 | // in the handling of Step 2.2 if an unset URI is encountered. |
| 589 | |
| 590 | // Step 2.2. |
| 591 | // Handle unknown extensions. |
| 592 | auto it = std::find_if( |
| 593 | header_extensions_to_offer_.begin(), header_extensions_to_offer_.end(), |
| 594 | [&entry](const auto& offered) { return entry.uri == offered.uri; }); |
| 595 | if (it == header_extensions_to_offer_.end()) { |
Markus Handell | c17bca7 | 2021-01-14 17:08:01 +0100 | [diff] [blame] | 596 | return RTCError(RTCErrorType::UNSUPPORTED_PARAMETER, |
Markus Handell | 755c65d | 2020-06-24 01:06:10 +0200 | [diff] [blame] | 597 | "Attempted to modify an unoffered extension."); |
| 598 | } |
| 599 | |
| 600 | // Step 2.4-2.5. |
| 601 | // - Use of the transceiver interface indicates unified plan is in effect, |
| 602 | // hence the MID extension needs to be enabled. |
| 603 | // - Also handle the mandatory video orientation extensions. |
| 604 | if ((entry.uri == RtpExtension::kMidUri || |
| 605 | entry.uri == RtpExtension::kVideoRotationUri) && |
| 606 | entry.direction != RtpTransceiverDirection::kSendRecv) { |
| 607 | return RTCError(RTCErrorType::INVALID_MODIFICATION, |
| 608 | "Attempted to stop a mandatory extension."); |
| 609 | } |
| 610 | } |
| 611 | |
| 612 | // Apply mutation after error checking. |
| 613 | for (const auto& entry : header_extensions_to_offer) { |
| 614 | auto it = std::find_if( |
| 615 | header_extensions_to_offer_.begin(), header_extensions_to_offer_.end(), |
| 616 | [&entry](const auto& offered) { return entry.uri == offered.uri; }); |
| 617 | it->direction = entry.direction; |
| 618 | } |
| 619 | |
| 620 | return RTCError::OK(); |
Markus Handell | 0357b3e | 2020-03-16 13:40:51 +0100 | [diff] [blame] | 621 | } |
| 622 | |
Tommi | cc7a368 | 2021-05-04 14:59:38 +0200 | [diff] [blame] | 623 | void RtpTransceiver::OnNegotiationUpdate( |
| 624 | SdpType sdp_type, |
| 625 | const cricket::MediaContentDescription* content) { |
| 626 | RTC_DCHECK_RUN_ON(thread_); |
| 627 | RTC_DCHECK(content); |
| 628 | if (sdp_type == SdpType::kAnswer) |
| 629 | negotiated_header_extensions_ = content->rtp_header_extensions(); |
| 630 | } |
| 631 | |
Harald Alvestrand | 6060df5 | 2020-08-11 09:54:02 +0200 | [diff] [blame] | 632 | void RtpTransceiver::SetPeerConnectionClosed() { |
| 633 | is_pc_closed_ = true; |
| 634 | } |
| 635 | |
Steve Anton | 6e634bf | 2017-11-13 10:44:53 -0800 | [diff] [blame] | 636 | } // namespace webrtc |