OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ | 11 #ifndef WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ |
12 #define WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ | 12 #define WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ |
13 | 13 |
14 #include <map> | 14 #include <map> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
| 20 #include "webrtc/base/messagequeue.h" |
20 #include "webrtc/base/optional.h" | 21 #include "webrtc/base/optional.h" |
| 22 #include "webrtc/base/rtccertificate.h" |
| 23 #include "webrtc/base/sigslot.h" |
| 24 #include "webrtc/base/sslstreamadapter.h" |
21 #include "webrtc/p2p/base/candidate.h" | 25 #include "webrtc/p2p/base/candidate.h" |
22 #include "webrtc/p2p/base/p2pconstants.h" | 26 #include "webrtc/p2p/base/p2pconstants.h" |
23 #include "webrtc/p2p/base/sessiondescription.h" | 27 #include "webrtc/p2p/base/sessiondescription.h" |
24 #include "webrtc/p2p/base/transportinfo.h" | 28 #include "webrtc/p2p/base/transportinfo.h" |
25 #include "webrtc/base/messagequeue.h" | |
26 #include "webrtc/base/rtccertificate.h" | |
27 #include "webrtc/base/sigslot.h" | |
28 #include "webrtc/base/sslstreamadapter.h" | |
29 | 29 |
30 namespace cricket { | 30 namespace cricket { |
31 | 31 |
32 class TransportChannelImpl; | 32 class DtlsTransportInternal; |
33 class TransportChannelImpl; | |
34 enum class IceCandidatePairState; | 33 enum class IceCandidatePairState; |
35 | 34 |
36 typedef std::vector<Candidate> Candidates; | 35 typedef std::vector<Candidate> Candidates; |
37 | 36 |
38 // TODO(deadbeef): Move all of these enums, POD types and utility methods to | 37 // TODO(deadbeef): Move all of these enums, POD types and utility methods to |
39 // another header file. | 38 // another header file. |
40 | 39 |
41 // TODO(deadbeef): Unify with PeerConnectionInterface::IceConnectionState | 40 // TODO(deadbeef): Unify with PeerConnectionInterface::IceConnectionState |
42 // once /talk/ and /webrtc/ are combined, and also switch to ENUM_NAME naming | 41 // once /talk/ and /webrtc/ are combined, and also switch to ENUM_NAME naming |
43 // style. | 42 // style. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // may be set before a local certificate is generated. | 238 // may be set before a local certificate is generated. |
240 JsepTransport(const std::string& mid, | 239 JsepTransport(const std::string& mid, |
241 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); | 240 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
242 | 241 |
243 // Returns the MID of this transport. | 242 // Returns the MID of this transport. |
244 const std::string& mid() const { return mid_; } | 243 const std::string& mid() const { return mid_; } |
245 | 244 |
246 // Add or remove channel that is affected when a local/remote transport | 245 // Add or remove channel that is affected when a local/remote transport |
247 // description is set on this transport. Need to add all channels before | 246 // description is set on this transport. Need to add all channels before |
248 // setting a transport description. | 247 // setting a transport description. |
249 bool AddChannel(TransportChannelImpl* dtls, int component); | 248 bool AddChannel(DtlsTransportInternal* dtls, int component); |
250 bool RemoveChannel(int component); | 249 bool RemoveChannel(int component); |
251 bool HasChannels() const; | 250 bool HasChannels() const; |
252 | 251 |
253 bool ready_for_remote_candidates() const { | 252 bool ready_for_remote_candidates() const { |
254 return local_description_set_ && remote_description_set_; | 253 return local_description_set_ && remote_description_set_; |
255 } | 254 } |
256 | 255 |
257 // Must be called before applying local session description. | 256 // Must be called before applying local session description. |
258 // Needed in order to verify the local fingerprint. | 257 // Needed in order to verify the local fingerprint. |
259 void SetLocalCertificate( | 258 void SetLocalCertificate( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 std::string* error_desc) const; | 314 std::string* error_desc) const; |
316 | 315 |
317 // Negotiates the SSL role based off the offer and answer as specified by | 316 // Negotiates the SSL role based off the offer and answer as specified by |
318 // RFC 4145, section-4.1. Returns false if the SSL role cannot be determined | 317 // RFC 4145, section-4.1. Returns false if the SSL role cannot be determined |
319 // from the local description and remote description. | 318 // from the local description and remote description. |
320 bool NegotiateRole(ContentAction local_role, | 319 bool NegotiateRole(ContentAction local_role, |
321 rtc::SSLRole* ssl_role, | 320 rtc::SSLRole* ssl_role, |
322 std::string* error_desc) const; | 321 std::string* error_desc) const; |
323 | 322 |
324 private: | 323 private: |
325 TransportChannelImpl* GetChannel(int component); | |
326 | |
327 // Negotiates the transport parameters based on the current local and remote | 324 // Negotiates the transport parameters based on the current local and remote |
328 // transport description, such as the ICE role to use, and whether DTLS | 325 // transport description, such as the ICE role to use, and whether DTLS |
329 // should be activated. | 326 // should be activated. |
330 // | 327 // |
331 // Called when an answer TransportDescription is applied. | 328 // Called when an answer TransportDescription is applied. |
332 bool NegotiateTransportDescription(ContentAction local_role, | 329 bool NegotiateTransportDescription(ContentAction local_role, |
333 std::string* error_desc); | 330 std::string* error_desc); |
334 | 331 |
335 // Pushes down the transport parameters from the local description, such | 332 // Pushes down the transport parameters from the local description, such |
336 // as the ICE ufrag and pwd. | 333 // as the ICE ufrag and pwd. |
337 bool ApplyLocalTransportDescription(TransportChannelImpl* channel, | 334 bool ApplyLocalTransportDescription(DtlsTransportInternal* dtls_transport, |
338 std::string* error_desc); | 335 std::string* error_desc); |
339 | 336 |
340 // Pushes down the transport parameters from the remote description to the | 337 // Pushes down the transport parameters from the remote description to the |
341 // transport channel. | 338 // transport channel. |
342 bool ApplyRemoteTransportDescription(TransportChannelImpl* channel, | 339 bool ApplyRemoteTransportDescription(DtlsTransportInternal* dtls_transport, |
343 std::string* error_desc); | 340 std::string* error_desc); |
344 | 341 |
345 // Pushes down the transport parameters obtained via negotiation. | 342 // Pushes down the transport parameters obtained via negotiation. |
346 bool ApplyNegotiatedTransportDescription(TransportChannelImpl* channel, | 343 bool ApplyNegotiatedTransportDescription( |
347 std::string* error_desc); | 344 DtlsTransportInternal* dtls_transport, |
| 345 std::string* error_desc); |
348 | 346 |
349 const std::string mid_; | 347 const std::string mid_; |
350 // needs-ice-restart bit as described in JSEP. | 348 // needs-ice-restart bit as described in JSEP. |
351 bool needs_ice_restart_ = false; | 349 bool needs_ice_restart_ = false; |
352 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; | 350 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
353 rtc::SSLRole secure_role_ = rtc::SSL_CLIENT; | 351 rtc::SSLRole secure_role_ = rtc::SSL_CLIENT; |
354 std::unique_ptr<rtc::SSLFingerprint> remote_fingerprint_; | 352 std::unique_ptr<rtc::SSLFingerprint> remote_fingerprint_; |
355 std::unique_ptr<TransportDescription> local_description_; | 353 std::unique_ptr<TransportDescription> local_description_; |
356 std::unique_ptr<TransportDescription> remote_description_; | 354 std::unique_ptr<TransportDescription> remote_description_; |
357 bool local_description_set_ = false; | 355 bool local_description_set_ = false; |
358 bool remote_description_set_ = false; | 356 bool remote_description_set_ = false; |
359 | 357 |
360 // Candidate component => DTLS channel | 358 // Candidate component => DTLS channel |
361 std::map<int, TransportChannelImpl*> channels_; | 359 std::map<int, DtlsTransportInternal*> channels_; |
362 | 360 |
363 RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport); | 361 RTC_DISALLOW_COPY_AND_ASSIGN(JsepTransport); |
364 }; | 362 }; |
365 | 363 |
366 } // namespace cricket | 364 } // namespace cricket |
367 | 365 |
368 #endif // WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ | 366 #endif // WEBRTC_P2P_BASE_JSEPTRANSPORT_H_ |
OLD | NEW |