blob: 64a599088e5a5adfaaf9543c94fb0f8bdf285880 [file] [log] [blame]
Zhi Huange818b6e2018-02-22 15:26:27 -08001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef PC_JSEP_TRANSPORT_CONTROLLER_H_
12#define PC_JSEP_TRANSPORT_CONTROLLER_H_
Zhi Huange818b6e2018-02-22 15:26:27 -080013
14#include <map>
15#include <memory>
16#include <string>
17#include <utility>
18#include <vector>
19
20#include "api/candidate.h"
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/crypto/crypto_options.h"
Qingsi Wang25ec8882019-11-15 12:33:05 -080022#include "api/ice_transport_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080023#include "api/peer_connection_interface.h"
Danil Chapovalov83bbe912019-08-07 12:24:53 +020024#include "api/rtc_event_log/rtc_event_log.h"
Steve Anton10542f22019-01-11 09:11:00 -080025#include "media/sctp/sctp_transport_internal.h"
26#include "p2p/base/dtls_transport.h"
Qingsi Wang25ec8882019-11-15 12:33:05 -080027#include "p2p/base/dtls_transport_factory.h"
Steve Anton10542f22019-01-11 09:11:00 -080028#include "p2p/base/p2p_transport_channel.h"
Zhi Huange818b6e2018-02-22 15:26:27 -080029#include "pc/channel.h"
Steve Anton10542f22019-01-11 09:11:00 -080030#include "pc/dtls_srtp_transport.h"
31#include "pc/dtls_transport.h"
32#include "pc/jsep_transport.h"
33#include "pc/rtp_transport.h"
34#include "pc/srtp_transport.h"
35#include "rtc_base/async_invoker.h"
36#include "rtc_base/constructor_magic.h"
37#include "rtc_base/ref_counted_object.h"
Mirko Bonadei3d259352020-10-23 12:04:40 +020038#include "rtc_base/callback_list.h"
Artem Titove41c4332018-07-25 15:04:28 +020039#include "rtc_base/third_party/sigslot/sigslot.h"
Zhi Huange818b6e2018-02-22 15:26:27 -080040
41namespace rtc {
42class Thread;
43class PacketTransportInternal;
44} // namespace rtc
45
46namespace webrtc {
47
Steve Antond25828a2018-08-31 13:06:05 -070048class JsepTransportController : public sigslot::has_slots<> {
Zhi Huange818b6e2018-02-22 15:26:27 -080049 public:
Zhi Huang365381f2018-04-13 16:44:34 -070050 // Used when the RtpTransport/DtlsTransport of the m= section is changed
51 // because the section is rejected or BUNDLE is enabled.
52 class Observer {
53 public:
54 virtual ~Observer() {}
55
56 // Returns true if media associated with |mid| was successfully set up to be
57 // demultiplexed on |rtp_transport|. Could return false if two bundled m=
58 // sections use the same SSRC, for example.
Bjorn A Mellemb689af42019-08-21 10:44:59 -070059 //
60 // If a data channel transport must be negotiated, |data_channel_transport|
61 // and |negotiation_state| indicate negotiation status. If
62 // |data_channel_transport| is null, the data channel transport should not
63 // be used. Otherwise, the value is a pointer to the transport to be used
64 // for data channels on |mid|, if any.
65 //
66 // The observer should not send data on |data_channel_transport| until
67 // |negotiation_state| is provisional or final. It should not delete
68 // |data_channel_transport| or any fallback transport until
69 // |negotiation_state| is final.
Taylor Brandstettercbaa2542018-04-16 16:42:14 -070070 virtual bool OnTransportChanged(
Zhi Huang365381f2018-04-13 16:44:34 -070071 const std::string& mid,
Taylor Brandstettercbaa2542018-04-16 16:42:14 -070072 RtpTransportInternal* rtp_transport,
Harald Alvestrandc85328f2019-02-28 07:51:00 +010073 rtc::scoped_refptr<DtlsTransport> dtls_transport,
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -070074 DataChannelTransportInterface* data_channel_transport) = 0;
Zhi Huang365381f2018-04-13 16:44:34 -070075 };
76
Zhi Huange818b6e2018-02-22 15:26:27 -080077 struct Config {
78 // If |redetermine_role_on_ice_restart| is true, ICE role is redetermined
79 // upon setting a local transport description that indicates an ICE
80 // restart.
81 bool redetermine_role_on_ice_restart = true;
82 rtc::SSLProtocolVersion ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
83 // |crypto_options| is used to determine if created DTLS transports
84 // negotiate GCM crypto suites or not.
Benjamin Wrighta54daf12018-10-11 15:33:17 -070085 webrtc::CryptoOptions crypto_options;
Zhi Huange818b6e2018-02-22 15:26:27 -080086 PeerConnectionInterface::BundlePolicy bundle_policy =
87 PeerConnectionInterface::kBundlePolicyBalanced;
88 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy =
89 PeerConnectionInterface::kRtcpMuxPolicyRequire;
90 bool disable_encryption = false;
91 bool enable_external_auth = false;
92 // Used to inject the ICE/DTLS transports created externally.
Qingsi Wang25ec8882019-11-15 12:33:05 -080093 webrtc::IceTransportFactory* ice_transport_factory = nullptr;
94 cricket::DtlsTransportFactory* dtls_transport_factory = nullptr;
Zhi Huang365381f2018-04-13 16:44:34 -070095 Observer* transport_observer = nullptr;
Sebastian Jansson1b83a9e2019-09-18 18:22:12 +020096 // Must be provided and valid for the lifetime of the
97 // JsepTransportController instance.
98 std::function<void(const rtc::CopyOnWriteBuffer& packet,
99 int64_t packet_time_us)>
100 rtcp_handler;
Zhi Huangb57e1692018-06-12 11:41:11 -0700101 bool active_reset_srtp_params = false;
Qingsi Wang7685e862018-06-11 20:15:46 -0700102 RtcEventLog* event_log = nullptr;
Anton Sukhanov7940da02018-10-10 10:34:49 -0700103
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700104 // Factory for SCTP transports.
Per Kjellander2bca0082020-08-28 09:15:15 +0200105 SctpTransportFactoryInterface* sctp_factory = nullptr;
Zhi Huange818b6e2018-02-22 15:26:27 -0800106 };
107
108 // The ICE related events are signaled on the |signaling_thread|.
109 // All the transport related methods are called on the |network_thread|.
110 JsepTransportController(rtc::Thread* signaling_thread,
111 rtc::Thread* network_thread,
112 cricket::PortAllocator* port_allocator,
Zach Steine20867f2018-08-02 13:20:15 -0700113 AsyncResolverFactory* async_resolver_factory,
Zhi Huange818b6e2018-02-22 15:26:27 -0800114 Config config);
115 virtual ~JsepTransportController();
116
117 // The main method to be called; applies a description at the transport
118 // level, creating/destroying transport objects as needed and updating their
119 // properties. This includes RTP, DTLS, and ICE (but not SCTP). At least not
120 // yet? May make sense to in the future.
121 RTCError SetLocalDescription(SdpType type,
122 const cricket::SessionDescription* description);
123
124 RTCError SetRemoteDescription(SdpType type,
125 const cricket::SessionDescription* description);
126
127 // Get transports to be used for the provided |mid|. If bundling is enabled,
128 // calling GetRtpTransport for multiple MIDs may yield the same object.
129 RtpTransportInternal* GetRtpTransport(const std::string& mid) const;
Harald Alvestrandad88c882018-11-28 16:47:46 +0100130 cricket::DtlsTransportInternal* GetDtlsTransport(const std::string& mid);
131 const cricket::DtlsTransportInternal* GetRtcpDtlsTransport(
Zhi Huange818b6e2018-02-22 15:26:27 -0800132 const std::string& mid) const;
Harald Alvestrandad88c882018-11-28 16:47:46 +0100133 // Gets the externally sharable version of the DtlsTransport.
Harald Alvestrand4a7b3ac2019-01-17 10:39:40 +0100134 rtc::scoped_refptr<webrtc::DtlsTransport> LookupDtlsTransportByMid(
Harald Alvestrandad88c882018-11-28 16:47:46 +0100135 const std::string& mid);
Bjorn A Mellembc3eebc2019-09-23 14:53:54 -0700136 rtc::scoped_refptr<SctpTransport> GetSctpTransport(
137 const std::string& mid) const;
Zhi Huange818b6e2018-02-22 15:26:27 -0800138
Bjorn A Mellemb689af42019-08-21 10:44:59 -0700139 DataChannelTransportInterface* GetDataChannelTransport(
Anton Sukhanov316f3ac2019-05-23 15:50:38 -0700140 const std::string& mid) const;
141
Zhi Huange818b6e2018-02-22 15:26:27 -0800142 /*********************
143 * ICE-related methods
144 ********************/
145 // This method is public to allow PeerConnection to update it from
146 // SetConfiguration.
147 void SetIceConfig(const cricket::IceConfig& config);
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 void SetNeedsIceRestartFlag();
152 // Returns true if the ICE restart flag above was set, and no ICE restart has
153 // occurred yet for this transport (by applying a local description with
154 // changed ufrag/password). If the transport has been deleted as a result of
155 // bundling, returns false.
156 bool NeedsIceRestart(const std::string& mid) const;
157 // Start gathering candidates for any new transports, or transports doing an
158 // ICE restart.
159 void MaybeStartGathering();
160 RTCError AddRemoteCandidates(
161 const std::string& mid,
162 const std::vector<cricket::Candidate>& candidates);
163 RTCError RemoveRemoteCandidates(
164 const std::vector<cricket::Candidate>& candidates);
165
166 /**********************
167 * DTLS-related methods
168 *********************/
169 // Specifies the identity to use in this session.
170 // Can only be called once.
171 bool SetLocalCertificate(
172 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
173 rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate(
174 const std::string& mid) const;
Taylor Brandstetterc3928662018-02-23 13:04:51 -0800175 // Caller owns returned certificate chain. This method mainly exists for
176 // stats reporting.
177 std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
Zhi Huange818b6e2018-02-22 15:26:27 -0800178 const std::string& mid) const;
179 // Get negotiated role, if one has been negotiated.
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200180 absl::optional<rtc::SSLRole> GetDtlsRole(const std::string& mid) const;
Zhi Huange818b6e2018-02-22 15:26:27 -0800181
182 // TODO(deadbeef): GetStats isn't const because all the way down to
183 // OpenSSLStreamAdapter, GetSslCipherSuite and GetDtlsSrtpCryptoSuite are not
184 // const. Fix this.
185 bool GetStats(const std::string& mid, cricket::TransportStats* stats);
Zhi Huange818b6e2018-02-22 15:26:27 -0800186
Zhi Huange830e682018-03-30 10:48:35 -0700187 bool initial_offerer() const { return initial_offerer_ && *initial_offerer_; }
Zhi Huang365381f2018-04-13 16:44:34 -0700188
Zhi Huangb57e1692018-06-12 11:41:11 -0700189 void SetActiveResetSrtpParams(bool active_reset_srtp_params);
190
Eldar Rellod85ea752020-02-19 20:41:07 +0200191 // For now the rollback only removes mid to transport mappings
Eldar Rello353a7182019-11-25 18:49:44 +0200192 // and deletes unused transports, but doesn't consider anything more complex.
Eldar Rellod85ea752020-02-19 20:41:07 +0200193 void RollbackTransports();
Eldar Rello5ab79e62019-10-09 18:29:44 +0300194
Zhi Huange818b6e2018-02-22 15:26:27 -0800195 // All of these signals are fired on the signaling thread.
196
197 // If any transport failed => failed,
198 // Else if all completed => completed,
199 // Else if all connected => connected,
200 // Else => connecting
Mirko Bonadei3d259352020-10-23 12:04:40 +0200201 CallbackList<cricket::IceConnectionState> SignalIceConnectionState;
Zhi Huange818b6e2018-02-22 15:26:27 -0800202
Guido Urdanetaff791322020-10-09 18:07:37 +0000203 sigslot::signal1<PeerConnectionInterface::PeerConnectionState>
Jonas Olsson635474e2018-10-18 15:58:17 +0200204 SignalConnectionState;
Lahiru Ginnaliya Gamathigee99c68d2020-09-30 14:33:45 -0700205
Guido Urdanetaff791322020-10-09 18:07:37 +0000206 sigslot::signal1<PeerConnectionInterface::IceConnectionState>
Alex Loiko9289eda2018-11-23 16:18:59 +0000207 SignalStandardizedIceConnectionState;
Jonas Olsson635474e2018-10-18 15:58:17 +0200208
Zhi Huange818b6e2018-02-22 15:26:27 -0800209 // If all transports done gathering => complete,
210 // Else if any are gathering => gathering,
211 // Else => new
Guido Urdanetaff791322020-10-09 18:07:37 +0000212 sigslot::signal1<cricket::IceGatheringState> SignalIceGatheringState;
Zhi Huange818b6e2018-02-22 15:26:27 -0800213
Guido Urdanetaff791322020-10-09 18:07:37 +0000214 // (mid, candidates)
215 sigslot::signal2<const std::string&, const std::vector<cricket::Candidate>&>
Zhi Huange818b6e2018-02-22 15:26:27 -0800216 SignalIceCandidatesGathered;
217
Guido Urdanetaff791322020-10-09 18:07:37 +0000218 sigslot::signal1<const cricket::IceCandidateErrorEvent&>
219 SignalIceCandidateError;
Eldar Relloda13ea22019-06-01 12:23:43 +0300220
Guido Urdanetaff791322020-10-09 18:07:37 +0000221 sigslot::signal1<const std::vector<cricket::Candidate>&>
222 SignalIceCandidatesRemoved;
Zhi Huange818b6e2018-02-22 15:26:27 -0800223
Guido Urdanetaff791322020-10-09 18:07:37 +0000224 sigslot::signal1<const cricket::CandidatePairChangeEvent&>
Alex Drake00c7ecf2019-08-06 10:54:47 -0700225 SignalIceCandidatePairChanged;
226
Guido Urdanetaff791322020-10-09 18:07:37 +0000227 sigslot::signal1<rtc::SSLHandshakeError> SignalDtlsHandshakeError;
Zhi Huange818b6e2018-02-22 15:26:27 -0800228
Zhi Huange818b6e2018-02-22 15:26:27 -0800229 private:
Zhi Huange818b6e2018-02-22 15:26:27 -0800230 RTCError ApplyDescription_n(bool local,
231 SdpType type,
Niels Möller5cf0ef02021-01-18 14:00:36 +0100232 const cricket::SessionDescription* description)
233 RTC_RUN_ON(network_thread_);
Zhi Huangd2248f82018-04-10 14:41:03 -0700234 RTCError ValidateAndMaybeUpdateBundleGroup(
235 bool local,
236 SdpType type,
237 const cricket::SessionDescription* description);
Zhi Huange830e682018-03-30 10:48:35 -0700238 RTCError ValidateContent(const cricket::ContentInfo& content_info);
Zhi Huange818b6e2018-02-22 15:26:27 -0800239
Taylor Brandstettercbaa2542018-04-16 16:42:14 -0700240 void HandleRejectedContent(const cricket::ContentInfo& content_info,
Niels Möller5cf0ef02021-01-18 14:00:36 +0100241 const cricket::SessionDescription* description)
242 RTC_RUN_ON(network_thread_);
243 bool HandleBundledContent(const cricket::ContentInfo& content_info)
244 RTC_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800245
Zhi Huang365381f2018-04-13 16:44:34 -0700246 bool SetTransportForMid(const std::string& mid,
Taylor Brandstettercbaa2542018-04-16 16:42:14 -0700247 cricket::JsepTransport* jsep_transport);
248 void RemoveTransportForMid(const std::string& mid);
Zhi Huangd2248f82018-04-10 14:41:03 -0700249
Zhi Huange818b6e2018-02-22 15:26:27 -0800250 cricket::JsepTransportDescription CreateJsepTransportDescription(
Harald Alvestrand1716d392019-06-03 20:35:45 +0200251 const cricket::ContentInfo& content_info,
252 const cricket::TransportInfo& transport_info,
Zhi Huange830e682018-03-30 10:48:35 -0700253 const std::vector<int>& encrypted_extension_ids,
Niels Möllerdc80aaf2020-06-18 10:10:17 +0200254 int rtp_abs_sendtime_extn_id);
Zhi Huange818b6e2018-02-22 15:26:27 -0800255
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200256 absl::optional<std::string> bundled_mid() const {
257 absl::optional<std::string> bundled_mid;
Taylor Brandstetter0ab56512018-04-12 10:30:48 -0700258 if (bundle_group_ && bundle_group_->FirstContentName()) {
259 bundled_mid = *(bundle_group_->FirstContentName());
Zhi Huange818b6e2018-02-22 15:26:27 -0800260 }
261 return bundled_mid;
262 }
263
264 bool IsBundled(const std::string& mid) const {
265 return bundle_group_ && bundle_group_->HasContentName(mid);
266 }
267
268 bool ShouldUpdateBundleGroup(SdpType type,
269 const cricket::SessionDescription* description);
270
271 std::vector<int> MergeEncryptedHeaderExtensionIdsForBundle(
272 const cricket::SessionDescription* description);
Zhi Huange818b6e2018-02-22 15:26:27 -0800273 std::vector<int> GetEncryptedHeaderExtensionIds(
274 const cricket::ContentInfo& content_info);
275
Zhi Huange830e682018-03-30 10:48:35 -0700276 int GetRtpAbsSendTimeHeaderExtensionId(
277 const cricket::ContentInfo& content_info);
Zhi Huange818b6e2018-02-22 15:26:27 -0800278
Zhi Huange830e682018-03-30 10:48:35 -0700279 // This method takes the BUNDLE group into account. If the JsepTransport is
280 // destroyed because of BUNDLE, it would return the transport which other
281 // transports are bundled on (In current implementation, it is the first
282 // content in the BUNDLE group).
Zhi Huang365381f2018-04-13 16:44:34 -0700283 const cricket::JsepTransport* GetJsepTransportForMid(
Zhi Huange830e682018-03-30 10:48:35 -0700284 const std::string& mid) const;
Zhi Huang365381f2018-04-13 16:44:34 -0700285 cricket::JsepTransport* GetJsepTransportForMid(const std::string& mid);
Zhi Huange830e682018-03-30 10:48:35 -0700286
287 // Get the JsepTransport without considering the BUNDLE group. Return nullptr
288 // if the JsepTransport is destroyed.
Zhi Huang365381f2018-04-13 16:44:34 -0700289 const cricket::JsepTransport* GetJsepTransportByName(
Zhi Huange830e682018-03-30 10:48:35 -0700290 const std::string& transport_name) const;
Zhi Huang365381f2018-04-13 16:44:34 -0700291 cricket::JsepTransport* GetJsepTransportByName(
Zhi Huange830e682018-03-30 10:48:35 -0700292 const std::string& transport_name);
293
Anton Sukhanov7940da02018-10-10 10:34:49 -0700294 // Creates jsep transport. Noop if transport is already created.
295 // Transport is created either during SetLocalDescription (|local| == true) or
296 // during SetRemoteDescription (|local| == false). Passing |local| helps to
297 // differentiate initiator (caller) from answerer (callee).
Piotr (Peter) Slatala105ded32019-02-27 14:26:15 -0800298 RTCError MaybeCreateJsepTransport(
299 bool local,
300 const cricket::ContentInfo& content_info,
Niels Möller5cf0ef02021-01-18 14:00:36 +0100301 const cricket::SessionDescription& description)
302 RTC_RUN_ON(network_thread_);
Piotr (Peter) Slatala47dfdca2018-11-16 14:13:58 -0800303
Niels Möller5cf0ef02021-01-18 14:00:36 +0100304 void MaybeDestroyJsepTransport(const std::string& mid)
305 RTC_RUN_ON(network_thread_);
306 void DestroyAllJsepTransports_n() RTC_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800307
Niels Möller5cf0ef02021-01-18 14:00:36 +0100308 void SetIceRole_n(cricket::IceRole ice_role) RTC_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800309
310 cricket::IceRole DetermineIceRole(
Zhi Huang365381f2018-04-13 16:44:34 -0700311 cricket::JsepTransport* jsep_transport,
Zhi Huange818b6e2018-02-22 15:26:27 -0800312 const cricket::TransportInfo& transport_info,
313 SdpType type,
314 bool local);
315
316 std::unique_ptr<cricket::DtlsTransportInternal> CreateDtlsTransport(
Anton Sukhanovac6c0962019-07-10 15:44:56 -0700317 const cricket::ContentInfo& content_info,
Niels Möller2a707032020-06-16 16:39:13 +0200318 cricket::IceTransportInternal* ice);
Qingsi Wang25ec8882019-11-15 12:33:05 -0800319 rtc::scoped_refptr<webrtc::IceTransportInterface> CreateIceTransport(
320 const std::string& transport_name,
Zhi Huange818b6e2018-02-22 15:26:27 -0800321 bool rtcp);
322
323 std::unique_ptr<webrtc::RtpTransport> CreateUnencryptedRtpTransport(
324 const std::string& transport_name,
325 rtc::PacketTransportInternal* rtp_packet_transport,
326 rtc::PacketTransportInternal* rtcp_packet_transport);
327 std::unique_ptr<webrtc::SrtpTransport> CreateSdesTransport(
328 const std::string& transport_name,
Zhi Huange830e682018-03-30 10:48:35 -0700329 cricket::DtlsTransportInternal* rtp_dtls_transport,
330 cricket::DtlsTransportInternal* rtcp_dtls_transport);
Zhi Huange818b6e2018-02-22 15:26:27 -0800331 std::unique_ptr<webrtc::DtlsSrtpTransport> CreateDtlsSrtpTransport(
332 const std::string& transport_name,
333 cricket::DtlsTransportInternal* rtp_dtls_transport,
334 cricket::DtlsTransportInternal* rtcp_dtls_transport);
335
336 // Collect all the DtlsTransports, including RTP and RTCP, from the
337 // JsepTransports. JsepTransportController can iterate all the DtlsTransports
338 // and update the aggregate states.
339 std::vector<cricket::DtlsTransportInternal*> GetDtlsTransports();
340
341 // Handlers for signals from Transport.
Niels Möller5cf0ef02021-01-18 14:00:36 +0100342 void OnTransportWritableState_n(rtc::PacketTransportInternal* transport)
343 RTC_RUN_ON(network_thread_);
344 void OnTransportReceivingState_n(rtc::PacketTransportInternal* transport)
345 RTC_RUN_ON(network_thread_);
346 void OnTransportGatheringState_n(cricket::IceTransportInternal* transport)
347 RTC_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800348 void OnTransportCandidateGathered_n(cricket::IceTransportInternal* transport,
Niels Möller5cf0ef02021-01-18 14:00:36 +0100349 const cricket::Candidate& candidate)
350 RTC_RUN_ON(network_thread_);
351 void OnTransportCandidateError_n(cricket::IceTransportInternal* transport,
352 const cricket::IceCandidateErrorEvent& event)
353 RTC_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800354 void OnTransportCandidatesRemoved_n(cricket::IceTransportInternal* transport,
Niels Möller5cf0ef02021-01-18 14:00:36 +0100355 const cricket::Candidates& candidates)
356 RTC_RUN_ON(network_thread_);
357 void OnTransportRoleConflict_n(cricket::IceTransportInternal* transport)
358 RTC_RUN_ON(network_thread_);
359 void OnTransportStateChanged_n(cricket::IceTransportInternal* transport)
360 RTC_RUN_ON(network_thread_);
Alex Drake00c7ecf2019-08-06 10:54:47 -0700361 void OnTransportCandidatePairChanged_n(
Niels Möller5cf0ef02021-01-18 14:00:36 +0100362 const cricket::CandidatePairChangeEvent& event)
363 RTC_RUN_ON(network_thread_);
364 void UpdateAggregateStates_n() RTC_RUN_ON(network_thread_);
Zhi Huange818b6e2018-02-22 15:26:27 -0800365
Sebastian Jansson1b83a9e2019-09-18 18:22:12 +0200366 void OnRtcpPacketReceived_n(rtc::CopyOnWriteBuffer* packet,
Niels Möller5cf0ef02021-01-18 14:00:36 +0100367 int64_t packet_time_us)
368 RTC_RUN_ON(network_thread_);
Sebastian Jansson1b83a9e2019-09-18 18:22:12 +0200369
Zhi Huange818b6e2018-02-22 15:26:27 -0800370 void OnDtlsHandshakeError(rtc::SSLHandshakeError error);
371
372 rtc::Thread* const signaling_thread_ = nullptr;
373 rtc::Thread* const network_thread_ = nullptr;
374 cricket::PortAllocator* const port_allocator_ = nullptr;
Zach Steine20867f2018-08-02 13:20:15 -0700375 AsyncResolverFactory* const async_resolver_factory_ = nullptr;
Zhi Huange818b6e2018-02-22 15:26:27 -0800376
Zhi Huang365381f2018-04-13 16:44:34 -0700377 std::map<std::string, std::unique_ptr<cricket::JsepTransport>>
Zhi Huange830e682018-03-30 10:48:35 -0700378 jsep_transports_by_name_;
Zhi Huangd2248f82018-04-10 14:41:03 -0700379 // This keeps track of the mapping between media section
Zhi Huang365381f2018-04-13 16:44:34 -0700380 // (BaseChannel/SctpTransport) and the JsepTransport underneath.
381 std::map<std::string, cricket::JsepTransport*> mid_to_transport_;
Eldar Rellod85ea752020-02-19 20:41:07 +0200382 // Keep track of mids that have been mapped to transports. Used for rollback.
383 std::vector<std::string> pending_mids_ RTC_GUARDED_BY(network_thread_);
Jonas Olsson635474e2018-10-18 15:58:17 +0200384 // Aggregate states for Transports.
Alex Loiko9289eda2018-11-23 16:18:59 +0000385 // standardized_ice_connection_state_ is intended to replace
386 // ice_connection_state, see bugs.webrtc.org/9308
387 cricket::IceConnectionState ice_connection_state_ =
388 cricket::kIceConnectionConnecting;
389 PeerConnectionInterface::IceConnectionState
390 standardized_ice_connection_state_ =
391 PeerConnectionInterface::kIceConnectionNew;
Jonas Olsson635474e2018-10-18 15:58:17 +0200392 PeerConnectionInterface::PeerConnectionState combined_connection_state_ =
393 PeerConnectionInterface::PeerConnectionState::kNew;
Zhi Huange818b6e2018-02-22 15:26:27 -0800394 cricket::IceGatheringState ice_gathering_state_ = cricket::kIceGatheringNew;
395
396 Config config_;
Piotr (Peter) Slatalab1ae10b2019-03-01 11:14:05 -0800397
Zhi Huange818b6e2018-02-22 15:26:27 -0800398 const cricket::SessionDescription* local_desc_ = nullptr;
399 const cricket::SessionDescription* remote_desc_ = nullptr;
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200400 absl::optional<bool> initial_offerer_;
Zhi Huange818b6e2018-02-22 15:26:27 -0800401
Danil Chapovalov66cadcc2018-06-19 16:47:43 +0200402 absl::optional<cricket::ContentGroup> bundle_group_;
Zhi Huange818b6e2018-02-22 15:26:27 -0800403
404 cricket::IceConfig ice_config_;
405 cricket::IceRole ice_role_ = cricket::ICEROLE_CONTROLLING;
406 uint64_t ice_tiebreaker_ = rtc::CreateRandomId64();
407 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
408 rtc::AsyncInvoker invoker_;
409
Zhi Huange818b6e2018-02-22 15:26:27 -0800410 RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransportController);
411};
412
413} // namespace webrtc
414
Steve Anton10542f22019-01-11 09:11:00 -0800415#endif // PC_JSEP_TRANSPORT_CONTROLLER_H_