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 P2P_BASE_TRANSPORT_DESCRIPTION_FACTORY_H_ 12 #define P2P_BASE_TRANSPORT_DESCRIPTION_FACTORY_H_ 13 14 #include <memory> 15 16 #include "p2p/base/ice_credentials_iterator.h" 17 #include "p2p/base/transport_description.h" 18 #include "rtc_base/rtc_certificate.h" 19 20 namespace rtc { 21 class SSLIdentity; 22 } 23 24 namespace cricket { 25 26 struct TransportOptions { 27 bool ice_restart = false; 28 bool prefer_passive_role = false; 29 // If true, ICE renomination is supported and will be used if it is also 30 // supported by the remote side. 31 bool enable_ice_renomination = false; 32 }; 33 34 // Creates transport descriptions according to the supplied configuration. 35 // When creating answers, performs the appropriate negotiation 36 // of the various fields to determine the proper result. 37 class TransportDescriptionFactory { 38 public: 39 // Default ctor; use methods below to set configuration. 40 TransportDescriptionFactory(); 41 ~TransportDescriptionFactory(); 42 secure()43 SecurePolicy secure() const { return secure_; } 44 // The certificate to use when setting up DTLS. certificate()45 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() const { 46 return certificate_; 47 } 48 49 // Specifies the transport security policy to use. set_secure(SecurePolicy s)50 void set_secure(SecurePolicy s) { secure_ = s; } 51 // Specifies the certificate to use (only used when secure != SEC_DISABLED). set_certificate(const rtc::scoped_refptr<rtc::RTCCertificate> & certificate)52 void set_certificate( 53 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) { 54 certificate_ = certificate; 55 } 56 57 // Creates a transport description suitable for use in an offer. 58 std::unique_ptr<TransportDescription> CreateOffer( 59 const TransportOptions& options, 60 const TransportDescription* current_description, 61 IceCredentialsIterator* ice_credentials) const; 62 // Create a transport description that is a response to an offer. 63 // 64 // If |require_transport_attributes| is true, then TRANSPORT category 65 // attributes are expected to be present in |offer|, as defined by 66 // sdp-mux-attributes, and null will be returned otherwise. It's expected 67 // that this will be set to false for an m= section that's in a BUNDLE group 68 // but isn't the first m= section in the group. 69 std::unique_ptr<TransportDescription> CreateAnswer( 70 const TransportDescription* offer, 71 const TransportOptions& options, 72 bool require_transport_attributes, 73 const TransportDescription* current_description, 74 IceCredentialsIterator* ice_credentials) const; 75 76 private: 77 bool SetSecurityInfo(TransportDescription* description, 78 ConnectionRole role) const; 79 80 SecurePolicy secure_; 81 rtc::scoped_refptr<rtc::RTCCertificate> certificate_; 82 }; 83 84 } // namespace cricket 85 86 #endif // P2P_BASE_TRANSPORT_DESCRIPTION_FACTORY_H_ 87