blob: 658e8e7b72615af47a3d11b8406479564507c925 [file] [log] [blame]
Zhi Huange818b6e2018-02-22 15:26:27 -08001/*
2 * Copyright 2018 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 Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_JSEP_TRANSPORT_H_
12#define PC_JSEP_TRANSPORT_H_
Zhi Huange818b6e2018-02-22 15:26:27 -080013
14#include <map>
15#include <memory>
16#include <string>
17#include <vector>
18
Danil Chapovalov66cadcc2018-06-19 16:47:43 +020019#include "absl/types/optional.h"
Zhi Huange818b6e2018-02-22 15:26:27 -080020#include "api/candidate.h"
Qingsi Wang25ec8882019-11-15 12:33:05 -080021#include "api/ice_transport_interface.h"
Zhi Huange818b6e2018-02-22 15:26:27 -080022#include "api/jsep.h"
Niels Möller65f17ca2019-09-12 13:59:36 +020023#include "api/transport/datagram_transport_interface.h"
24#include "api/transport/media/media_transport_interface.h"
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -070025#include "media/sctp/sctp_transport_internal.h"
Steve Anton10542f22019-01-11 09:11:00 -080026#include "p2p/base/dtls_transport.h"
27#include "p2p/base/p2p_constants.h"
28#include "p2p/base/transport_info.h"
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -070029#include "pc/composite_data_channel_transport.h"
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -070030#include "pc/composite_rtp_transport.h"
Steve Anton10542f22019-01-11 09:11:00 -080031#include "pc/dtls_srtp_transport.h"
32#include "pc/dtls_transport.h"
33#include "pc/rtcp_mux_filter.h"
34#include "pc/rtp_transport.h"
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -070035#include "pc/sctp_transport.h"
Steve Anton10542f22019-01-11 09:11:00 -080036#include "pc/session_description.h"
37#include "pc/srtp_filter.h"
38#include "pc/srtp_transport.h"
39#include "pc/transport_stats.h"
40#include "rtc_base/constructor_magic.h"
41#include "rtc_base/message_queue.h"
42#include "rtc_base/rtc_certificate.h"
43#include "rtc_base/ssl_stream_adapter.h"
Artem Titove41c4332018-07-25 15:04:28 +020044#include "rtc_base/third_party/sigslot/sigslot.h"
Harald Alvestrand78a5e962019-04-03 10:42:39 +020045#include "rtc_base/thread_checker.h"
Zhi Huange818b6e2018-02-22 15:26:27 -080046
47namespace cricket {
48
49class DtlsTransportInternal;
50
51struct JsepTransportDescription {
52 public:
53 JsepTransportDescription();
54 JsepTransportDescription(
55 bool rtcp_mux_enabled,
56 const std::vector<CryptoParams>& cryptos,
57 const std::vector<int>& encrypted_header_extension_ids,
Zhi Huange830e682018-03-30 10:48:35 -070058 int rtp_abs_sendtime_extn_id,
Bjorn A Mellem8e1343a2019-09-30 15:12:47 -070059 const TransportDescription& transport_description,
60 absl::optional<std::string> media_alt_protocol,
61 absl::optional<std::string> data_alt_protocol);
Zhi Huange818b6e2018-02-22 15:26:27 -080062 JsepTransportDescription(const JsepTransportDescription& from);
63 ~JsepTransportDescription();
64
65 JsepTransportDescription& operator=(const JsepTransportDescription& from);
66
67 bool rtcp_mux_enabled = true;
68 std::vector<CryptoParams> cryptos;
69 std::vector<int> encrypted_header_extension_ids;
Zhi Huange830e682018-03-30 10:48:35 -070070 int rtp_abs_sendtime_extn_id = -1;
Zhi Huange818b6e2018-02-22 15:26:27 -080071 // TODO(zhihuang): Add the ICE and DTLS related variables and methods from
72 // TransportDescription and remove this extra layer of abstraction.
73 TransportDescription transport_desc;
Bjorn A Mellem8e1343a2019-09-30 15:12:47 -070074
75 // Alt-protocols that apply to this JsepTransport. Presence indicates a
76 // request to use an alternative protocol for media and/or data. The
77 // alt-protocol is handled by a datagram transport. If one or both of these
78 // values are present, JsepTransport will attempt to negotiate use of the
79 // datagram transport for media and/or data.
80 absl::optional<std::string> media_alt_protocol;
81 absl::optional<std::string> data_alt_protocol;
Zhi Huange818b6e2018-02-22 15:26:27 -080082};
83
84// Helper class used by JsepTransportController that processes
85// TransportDescriptions. A TransportDescription represents the
86// transport-specific properties of an SDP m= section, processed according to
87// JSEP. Each transport consists of DTLS and ICE transport channels for RTP
88// (and possibly RTCP, if rtcp-mux isn't used).
89//
Zhi Huang365381f2018-04-13 16:44:34 -070090// On Threading: JsepTransport performs work solely on the network thread, and
Zhi Huange818b6e2018-02-22 15:26:27 -080091// so its methods should only be called on the network thread.
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -070092class JsepTransport : public sigslot::has_slots<>,
93 public webrtc::MediaTransportStateCallback {
Zhi Huange818b6e2018-02-22 15:26:27 -080094 public:
95 // |mid| is just used for log statements in order to identify the Transport.
96 // Note that |local_certificate| is allowed to be null since a remote
97 // description may be set before a local certificate is generated.
Anton Sukhanov7940da02018-10-10 10:34:49 -070098 //
99 // |media_trasport| is optional (experimental). If available it will be used
100 // to send / receive encoded audio and video frames instead of RTP.
101 // Currently |media_transport| can co-exist with RTP / RTCP transports.
Zhi Huang365381f2018-04-13 16:44:34 -0700102 JsepTransport(
Zhi Huange818b6e2018-02-22 15:26:27 -0800103 const std::string& mid,
104 const rtc::scoped_refptr<rtc::RTCCertificate>& local_certificate,
Qingsi Wang25ec8882019-11-15 12:33:05 -0800105 rtc::scoped_refptr<webrtc::IceTransportInterface> ice_transport,
106 rtc::scoped_refptr<webrtc::IceTransportInterface> rtcp_ice_transport,
Zhi Huange818b6e2018-02-22 15:26:27 -0800107 std::unique_ptr<webrtc::RtpTransport> unencrypted_rtp_transport,
108 std::unique_ptr<webrtc::SrtpTransport> sdes_transport,
109 std::unique_ptr<webrtc::DtlsSrtpTransport> dtls_srtp_transport,
Bjorn A Mellem364b2672019-08-20 16:58:03 -0700110 std::unique_ptr<webrtc::RtpTransportInternal> datagram_rtp_transport,
Zhi Huange818b6e2018-02-22 15:26:27 -0800111 std::unique_ptr<DtlsTransportInternal> rtp_dtls_transport,
Anton Sukhanov7940da02018-10-10 10:34:49 -0700112 std::unique_ptr<DtlsTransportInternal> rtcp_dtls_transport,
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700113 std::unique_ptr<SctpTransportInternal> sctp_transport,
Anton Sukhanov292ce4e2019-06-03 13:00:24 -0700114 std::unique_ptr<webrtc::MediaTransportInterface> media_transport,
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700115 std::unique_ptr<webrtc::DatagramTransportInterface> datagram_transport,
116 webrtc::DataChannelTransportInterface* data_channel_transport);
Zhi Huange818b6e2018-02-22 15:26:27 -0800117
Zhi Huang365381f2018-04-13 16:44:34 -0700118 ~JsepTransport() override;
Zhi Huange818b6e2018-02-22 15:26:27 -0800119
120 // Returns the MID of this transport. This is only used for logging.
121 const std::string& mid() const { return mid_; }
122
123 // Must be called before applying local session description.
124 // Needed in order to verify the local fingerprint.
125 void SetLocalCertificate(
126 const rtc::scoped_refptr<rtc::RTCCertificate>& local_certificate) {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200127 RTC_DCHECK_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800128 local_certificate_ = local_certificate;
129 }
130
131 // Return the local certificate provided by SetLocalCertificate.
132 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200133 RTC_DCHECK_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800134 return local_certificate_;
135 }
136
137 webrtc::RTCError SetLocalJsepTransportDescription(
138 const JsepTransportDescription& jsep_description,
139 webrtc::SdpType type);
140
141 // Set the remote TransportDescription to be used by DTLS and ICE channels
142 // that are part of this Transport.
143 webrtc::RTCError SetRemoteJsepTransportDescription(
144 const JsepTransportDescription& jsep_description,
145 webrtc::SdpType type);
Zhi Huange818b6e2018-02-22 15:26:27 -0800146 webrtc::RTCError AddRemoteCandidates(const Candidates& candidates);
147
148 // Set the "needs-ice-restart" flag as described in JSEP. After the flag is
149 // set, offers should generate new ufrags/passwords until an ICE restart
150 // occurs.
151 //
152 // This and the below method can be called safely from any thread as long as
153 // SetXTransportDescription is not in progress.
154 void SetNeedsIceRestartFlag();
155 // Returns true if the ICE restart flag above was set, and no ICE restart has
156 // occurred yet for this transport (by applying a local description with
157 // changed ufrag/password).
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200158 bool needs_ice_restart() const {
159 rtc::CritScope scope(&accessor_lock_);
160 return needs_ice_restart_;
161 }
Zhi Huange818b6e2018-02-22 15:26:27 -0800162
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200163 // Returns role if negotiated, or empty absl::optional if it hasn't been
164 // negotiated yet.
165 absl::optional<rtc::SSLRole> GetDtlsRole() const;
Zhi Huange818b6e2018-02-22 15:26:27 -0800166
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700167 absl::optional<OpaqueTransportParameters> GetTransportParameters() const;
168
Zhi Huange818b6e2018-02-22 15:26:27 -0800169 // TODO(deadbeef): Make this const. See comment in transportcontroller.h.
170 bool GetStats(TransportStats* stats);
171
172 const JsepTransportDescription* local_description() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200173 RTC_DCHECK_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800174 return local_description_.get();
175 }
176
177 const JsepTransportDescription* remote_description() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200178 RTC_DCHECK_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800179 return remote_description_.get();
180 }
181
182 webrtc::RtpTransportInternal* rtp_transport() const {
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700183 rtc::CritScope scope(&accessor_lock_);
184 if (composite_rtp_transport_) {
185 return composite_rtp_transport_.get();
186 } else if (datagram_rtp_transport_) {
187 return datagram_rtp_transport_.get();
Zhi Huange818b6e2018-02-22 15:26:27 -0800188 } else {
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700189 return default_rtp_transport();
Zhi Huange818b6e2018-02-22 15:26:27 -0800190 }
191 }
192
Harald Alvestrandad88c882018-11-28 16:47:46 +0100193 const DtlsTransportInternal* rtp_dtls_transport() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200194 rtc::CritScope scope(&accessor_lock_);
Harald Alvestrandad88c882018-11-28 16:47:46 +0100195 if (rtp_dtls_transport_) {
196 return rtp_dtls_transport_->internal();
197 } else {
198 return nullptr;
199 }
Zhi Huange818b6e2018-02-22 15:26:27 -0800200 }
201
Harald Alvestrandad88c882018-11-28 16:47:46 +0100202 DtlsTransportInternal* rtp_dtls_transport() {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200203 rtc::CritScope scope(&accessor_lock_);
Harald Alvestrandad88c882018-11-28 16:47:46 +0100204 if (rtp_dtls_transport_) {
205 return rtp_dtls_transport_->internal();
206 } else {
207 return nullptr;
208 }
209 }
210
211 const DtlsTransportInternal* rtcp_dtls_transport() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200212 rtc::CritScope scope(&accessor_lock_);
Harald Alvestrandad88c882018-11-28 16:47:46 +0100213 if (rtcp_dtls_transport_) {
214 return rtcp_dtls_transport_->internal();
215 } else {
216 return nullptr;
217 }
218 }
219
220 DtlsTransportInternal* rtcp_dtls_transport() {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200221 rtc::CritScope scope(&accessor_lock_);
Harald Alvestrandad88c882018-11-28 16:47:46 +0100222 if (rtcp_dtls_transport_) {
223 return rtcp_dtls_transport_->internal();
224 } else {
225 return nullptr;
226 }
227 }
228
Harald Alvestrand4a7b3ac2019-01-17 10:39:40 +0100229 rtc::scoped_refptr<webrtc::DtlsTransport> RtpDtlsTransport() {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200230 rtc::CritScope scope(&accessor_lock_);
Harald Alvestrandad88c882018-11-28 16:47:46 +0100231 return rtp_dtls_transport_;
Zhi Huange818b6e2018-02-22 15:26:27 -0800232 }
233
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700234 rtc::scoped_refptr<webrtc::SctpTransport> SctpTransport() const {
235 rtc::CritScope scope(&accessor_lock_);
236 return sctp_transport_;
237 }
238
239 webrtc::DataChannelTransportInterface* data_channel_transport() const {
240 rtc::CritScope scope(&accessor_lock_);
241 if (composite_data_channel_transport_) {
242 return composite_data_channel_transport_.get();
243 } else if (sctp_data_channel_transport_) {
244 return sctp_data_channel_transport_.get();
245 }
246 return data_channel_transport_;
247 }
248
Anton Sukhanov7940da02018-10-10 10:34:49 -0700249 // Returns media transport, if available.
250 // Note that media transport is owned by jseptransport and the pointer
251 // to media transport will becomes invalid after destruction of jseptransport.
252 webrtc::MediaTransportInterface* media_transport() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200253 rtc::CritScope scope(&accessor_lock_);
Anton Sukhanov7940da02018-10-10 10:34:49 -0700254 return media_transport_.get();
255 }
256
Anton Sukhanov316f3ac2019-05-23 15:50:38 -0700257 // Returns datagram transport, if available.
258 webrtc::DatagramTransportInterface* datagram_transport() const {
259 rtc::CritScope scope(&accessor_lock_);
Anton Sukhanov292ce4e2019-06-03 13:00:24 -0700260 return datagram_transport_.get();
Anton Sukhanov316f3ac2019-05-23 15:50:38 -0700261 }
262
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -0700263 // Returns the latest media transport state.
264 webrtc::MediaTransportState media_transport_state() const {
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200265 rtc::CritScope scope(&accessor_lock_);
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -0700266 return media_transport_state_;
267 }
268
Zhi Huange818b6e2018-02-22 15:26:27 -0800269 // This is signaled when RTCP-mux becomes active and
270 // |rtcp_dtls_transport_| is destroyed. The JsepTransportController will
271 // handle the signal and update the aggregate transport states.
272 sigslot::signal<> SignalRtcpMuxActive;
273
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -0700274 // This is signaled for changes in |media_transport_| state.
275 sigslot::signal<> SignalMediaTransportStateChanged;
276
Bjorn A Mellemb689af42019-08-21 10:44:59 -0700277 // Signals that a data channel transport was negotiated and may be used to
278 // send data. The first parameter is |this|. The second parameter is the
279 // transport that was negotiated, or null if negotiation rejected the data
280 // channel transport. The third parameter (bool) indicates whether the
281 // negotiation was provisional or final. If true, it is provisional, if
282 // false, it is final.
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700283 sigslot::signal2<JsepTransport*, webrtc::DataChannelTransportInterface*>
Bjorn A Mellemb689af42019-08-21 10:44:59 -0700284 SignalDataChannelTransportNegotiated;
285
Zhi Huange818b6e2018-02-22 15:26:27 -0800286 // TODO(deadbeef): The methods below are only public for testing. Should make
287 // them utility functions or objects so they can be tested independently from
288 // this class.
289
290 // Returns an error if the certificate's identity does not match the
291 // fingerprint, or either is NULL.
292 webrtc::RTCError VerifyCertificateFingerprint(
293 const rtc::RTCCertificate* certificate,
294 const rtc::SSLFingerprint* fingerprint) const;
295
Zhi Huangb57e1692018-06-12 11:41:11 -0700296 void SetActiveResetSrtpParams(bool active_reset_srtp_params);
297
Zhi Huange818b6e2018-02-22 15:26:27 -0800298 private:
299 bool SetRtcpMux(bool enable, webrtc::SdpType type, ContentSource source);
300
301 void ActivateRtcpMux();
302
303 bool SetSdes(const std::vector<CryptoParams>& cryptos,
304 const std::vector<int>& encrypted_extension_ids,
305 webrtc::SdpType type,
306 ContentSource source);
307
308 // Negotiates and sets the DTLS parameters based on the current local and
309 // remote transport description, such as the DTLS role to use, and whether
310 // DTLS should be activated.
311 //
312 // Called when an answer TransportDescription is applied.
313 webrtc::RTCError NegotiateAndSetDtlsParameters(
314 webrtc::SdpType local_description_type);
315
316 // Negotiates the DTLS role based off the offer and answer as specified by
317 // RFC 4145, section-4.1. Returns an RTCError if role cannot be determined
318 // from the local description and remote description.
319 webrtc::RTCError NegotiateDtlsRole(
320 webrtc::SdpType local_description_type,
321 ConnectionRole local_connection_role,
322 ConnectionRole remote_connection_role,
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200323 absl::optional<rtc::SSLRole>* negotiated_dtls_role);
Zhi Huange818b6e2018-02-22 15:26:27 -0800324
325 // Pushes down the ICE parameters from the local description, such
326 // as the ICE ufrag and pwd.
327 void SetLocalIceParameters(IceTransportInternal* ice);
328
329 // Pushes down the ICE parameters from the remote description.
330 void SetRemoteIceParameters(IceTransportInternal* ice);
331
332 // Pushes down the DTLS parameters obtained via negotiation.
333 webrtc::RTCError SetNegotiatedDtlsParameters(
334 DtlsTransportInternal* dtls_transport,
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200335 absl::optional<rtc::SSLRole> dtls_role,
Zhi Huange818b6e2018-02-22 15:26:27 -0800336 rtc::SSLFingerprint* remote_fingerprint);
337
338 bool GetTransportStats(DtlsTransportInternal* dtls_transport,
339 TransportStats* stats);
340
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -0700341 // Invoked whenever the state of the media transport changes.
342 void OnStateChanged(webrtc::MediaTransportState state) override;
343
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700344 // Deactivates, signals removal, and deletes |composite_rtp_transport_| if the
345 // current state of negotiation is sufficient to determine which rtp_transport
Bjorn A Mellemb689af42019-08-21 10:44:59 -0700346 // and data channel transport to use.
347 void NegotiateDatagramTransport(webrtc::SdpType type)
348 RTC_RUN_ON(network_thread_);
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700349
350 // Returns the default (non-datagram) rtp transport, if any.
351 webrtc::RtpTransportInternal* default_rtp_transport() const
352 RTC_EXCLUSIVE_LOCKS_REQUIRED(accessor_lock_) {
353 if (dtls_srtp_transport_) {
354 return dtls_srtp_transport_.get();
355 } else if (sdes_transport_) {
356 return sdes_transport_.get();
357 } else if (unencrypted_rtp_transport_) {
358 return unencrypted_rtp_transport_.get();
359 } else {
360 return nullptr;
361 }
362 }
363
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200364 // Owning thread, for safety checks
365 const rtc::Thread* const network_thread_;
366 // Critical scope for fields accessed off-thread
367 // TODO(https://bugs.webrtc.org/10300): Stop doing this.
368 rtc::CriticalSection accessor_lock_;
Zhi Huange818b6e2018-02-22 15:26:27 -0800369 const std::string mid_;
370 // needs-ice-restart bit as described in JSEP.
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200371 bool needs_ice_restart_ RTC_GUARDED_BY(accessor_lock_) = false;
372 rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_
373 RTC_GUARDED_BY(network_thread_);
374 std::unique_ptr<JsepTransportDescription> local_description_
375 RTC_GUARDED_BY(network_thread_);
376 std::unique_ptr<JsepTransportDescription> remote_description_
377 RTC_GUARDED_BY(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800378
Bjorn A Mellem0c1c1b42019-05-29 17:34:13 -0700379 // Ice transport which may be used by any of upper-layer transports (below).
380 // Owned by JsepTransport and guaranteed to outlive the transports below.
Qingsi Wang25ec8882019-11-15 12:33:05 -0800381 const rtc::scoped_refptr<webrtc::IceTransportInterface> ice_transport_;
382 const rtc::scoped_refptr<webrtc::IceTransportInterface> rtcp_ice_transport_;
Bjorn A Mellem0c1c1b42019-05-29 17:34:13 -0700383
Zhi Huange818b6e2018-02-22 15:26:27 -0800384 // To avoid downcasting and make it type safe, keep three unique pointers for
385 // different SRTP mode and only one of these is non-nullptr.
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700386 std::unique_ptr<webrtc::RtpTransport> unencrypted_rtp_transport_
387 RTC_GUARDED_BY(accessor_lock_);
388 std::unique_ptr<webrtc::SrtpTransport> sdes_transport_
389 RTC_GUARDED_BY(accessor_lock_);
390 std::unique_ptr<webrtc::DtlsSrtpTransport> dtls_srtp_transport_
391 RTC_GUARDED_BY(accessor_lock_);
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700392
393 // If multiple RTP transports are in use, |composite_rtp_transport_| will be
394 // passed to callers. This is only valid for offer-only, receive-only
395 // scenarios, as it is not possible for the composite to correctly choose
396 // which transport to use for sending.
397 std::unique_ptr<webrtc::CompositeRtpTransport> composite_rtp_transport_
398 RTC_GUARDED_BY(accessor_lock_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800399
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200400 rtc::scoped_refptr<webrtc::DtlsTransport> rtp_dtls_transport_
401 RTC_GUARDED_BY(accessor_lock_);
402 rtc::scoped_refptr<webrtc::DtlsTransport> rtcp_dtls_transport_
403 RTC_GUARDED_BY(accessor_lock_);
Bjorn A Mellemc85ebbe2019-06-07 10:28:06 -0700404 rtc::scoped_refptr<webrtc::DtlsTransport> datagram_dtls_transport_
405 RTC_GUARDED_BY(accessor_lock_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800406
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700407 std::unique_ptr<webrtc::DataChannelTransportInterface>
408 sctp_data_channel_transport_ RTC_GUARDED_BY(accessor_lock_);
409 rtc::scoped_refptr<webrtc::SctpTransport> sctp_transport_
410 RTC_GUARDED_BY(accessor_lock_);
411
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200412 SrtpFilter sdes_negotiator_ RTC_GUARDED_BY(network_thread_);
413 RtcpMuxFilter rtcp_mux_negotiator_ RTC_GUARDED_BY(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800414
415 // Cache the encrypted header extension IDs for SDES negoitation.
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200416 absl::optional<std::vector<int>> send_extension_ids_
417 RTC_GUARDED_BY(network_thread_);
418 absl::optional<std::vector<int>> recv_extension_ids_
419 RTC_GUARDED_BY(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800420
Anton Sukhanov7940da02018-10-10 10:34:49 -0700421 // Optional media transport (experimental).
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200422 std::unique_ptr<webrtc::MediaTransportInterface> media_transport_
423 RTC_GUARDED_BY(accessor_lock_);
Anton Sukhanov7940da02018-10-10 10:34:49 -0700424
Anton Sukhanov292ce4e2019-06-03 13:00:24 -0700425 // Optional datagram transport (experimental).
426 std::unique_ptr<webrtc::DatagramTransportInterface> datagram_transport_
427 RTC_GUARDED_BY(accessor_lock_);
428
Bjorn A Mellemfc604aa2019-09-24 14:59:21 -0700429 std::unique_ptr<webrtc::RtpTransportInternal> datagram_rtp_transport_
430 RTC_GUARDED_BY(accessor_lock_);
431
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700432 // Non-SCTP data channel transport. Set to one of |media_transport_| or
433 // |datagram_transport_| if that transport should be used for data chanels.
434 // Unset if neither should be used for data channels.
435 webrtc::DataChannelTransportInterface* data_channel_transport_
436 RTC_GUARDED_BY(accessor_lock_) = nullptr;
437
438 // Composite data channel transport, used during negotiation.
439 std::unique_ptr<webrtc::CompositeDataChannelTransport>
440 composite_data_channel_transport_ RTC_GUARDED_BY(accessor_lock_);
441
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -0700442 // If |media_transport_| is provided, this variable represents the state of
443 // media transport.
Anton Sukhanov316f3ac2019-05-23 15:50:38 -0700444 //
445 // NOTE: datagram transport state is handled by DatagramDtlsAdaptor, because
446 // DatagramDtlsAdaptor owns DatagramTransport. This state only represents
447 // media transport.
Harald Alvestrand78a5e962019-04-03 10:42:39 +0200448 webrtc::MediaTransportState media_transport_state_
449 RTC_GUARDED_BY(accessor_lock_) = webrtc::MediaTransportState::kPending;
Piotr (Peter) Slatala4eb41122018-11-01 07:26:03 -0700450
Zhi Huang365381f2018-04-13 16:44:34 -0700451 RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport);
Zhi Huange818b6e2018-02-22 15:26:27 -0800452};
453
454} // namespace cricket
455
Steve Anton10542f22019-01-11 09:11:00 -0800456#endif // PC_JSEP_TRANSPORT_H_