henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012 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 | |
| 11 | #ifndef WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_ |
| 12 | #define WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_ |
| 13 | |
| 14 | #include "webrtc/p2p/base/transportdescription.h" |
Edward Lemur | c20978e | 2017-07-06 19:44:34 +0200 | [diff] [blame] | 15 | #include "webrtc/rtc_base/rtccertificate.h" |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 16 | |
| 17 | namespace rtc { |
| 18 | class SSLIdentity; |
| 19 | } |
| 20 | |
| 21 | namespace cricket { |
| 22 | |
| 23 | struct TransportOptions { |
Honghai Zhang | 4cedf2b | 2016-08-31 08:18:11 -0700 | [diff] [blame] | 24 | bool ice_restart = false; |
| 25 | bool prefer_passive_role = false; |
| 26 | // If true, ICE renomination is supported and will be used if it is also |
| 27 | // supported by the remote side. |
| 28 | bool enable_ice_renomination = false; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
| 31 | // Creates transport descriptions according to the supplied configuration. |
| 32 | // When creating answers, performs the appropriate negotiation |
| 33 | // of the various fields to determine the proper result. |
| 34 | class TransportDescriptionFactory { |
| 35 | public: |
| 36 | // Default ctor; use methods below to set configuration. |
| 37 | TransportDescriptionFactory(); |
| 38 | SecurePolicy secure() const { return secure_; } |
Henrik Boström | 3a14bf3 | 2015-08-31 09:27:58 +0200 | [diff] [blame] | 39 | // The certificate to use when setting up DTLS. |
| 40 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() const { |
| 41 | return certificate_; |
| 42 | } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 43 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 44 | // Specifies the transport security policy to use. |
| 45 | void set_secure(SecurePolicy s) { secure_ = s; } |
Henrik Boström | 3a14bf3 | 2015-08-31 09:27:58 +0200 | [diff] [blame] | 46 | // Specifies the certificate to use (only used when secure != SEC_DISABLED). |
| 47 | void set_certificate( |
| 48 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { |
| 49 | certificate_ = certificate; |
| 50 | } |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 51 | |
| 52 | // Creates a transport description suitable for use in an offer. |
| 53 | TransportDescription* CreateOffer(const TransportOptions& options, |
| 54 | const TransportDescription* current_description) const; |
| 55 | // Create a transport description that is a response to an offer. |
deadbeef | b789253 | 2017-02-22 19:35:18 -0800 | [diff] [blame] | 56 | // |
| 57 | // If |require_transport_attributes| is true, then TRANSPORT category |
| 58 | // attributes are expected to be present in |offer|, as defined by |
| 59 | // sdp-mux-attributes, and null will be returned otherwise. It's expected |
| 60 | // that this will be set to false for an m= section that's in a BUNDLE group |
| 61 | // but isn't the first m= section in the group. |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 62 | TransportDescription* CreateAnswer( |
| 63 | const TransportDescription* offer, |
| 64 | const TransportOptions& options, |
deadbeef | b789253 | 2017-02-22 19:35:18 -0800 | [diff] [blame] | 65 | bool require_transport_attributes, |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 66 | const TransportDescription* current_description) const; |
| 67 | |
| 68 | private: |
| 69 | bool SetSecurityInfo(TransportDescription* description, |
| 70 | ConnectionRole role) const; |
| 71 | |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 72 | SecurePolicy secure_; |
Henrik Boström | 3a14bf3 | 2015-08-31 09:27:58 +0200 | [diff] [blame] | 73 | rtc::scoped_refptr<rtc::RTCCertificate> certificate_; |
henrike@webrtc.org | 269fb4b | 2014-10-28 22:20:11 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | } // namespace cricket |
| 77 | |
| 78 | #endif // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_ |