Home | History | Annotate | Download | only in base
      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/base/rtccertificate.h"
     15 #include "webrtc/p2p/base/transportdescription.h"
     16 
     17 namespace rtc {
     18 class SSLIdentity;
     19 }
     20 
     21 namespace cricket {
     22 
     23 struct TransportOptions {
     24   TransportOptions() : ice_restart(false), prefer_passive_role(false) {}
     25   bool ice_restart;
     26   bool prefer_passive_role;
     27 };
     28 
     29 // Creates transport descriptions according to the supplied configuration.
     30 // When creating answers, performs the appropriate negotiation
     31 // of the various fields to determine the proper result.
     32 class TransportDescriptionFactory {
     33  public:
     34   // Default ctor; use methods below to set configuration.
     35   TransportDescriptionFactory();
     36   SecurePolicy secure() const { return secure_; }
     37   // The certificate to use when setting up DTLS.
     38   const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() const {
     39     return certificate_;
     40   }
     41 
     42   // Specifies the transport security policy to use.
     43   void set_secure(SecurePolicy s) { secure_ = s; }
     44   // Specifies the certificate to use (only used when secure != SEC_DISABLED).
     45   void set_certificate(
     46       const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
     47     certificate_ = certificate;
     48   }
     49 
     50   // Creates a transport description suitable for use in an offer.
     51   TransportDescription* CreateOffer(const TransportOptions& options,
     52       const TransportDescription* current_description) const;
     53   // Create a transport description that is a response to an offer.
     54   TransportDescription* CreateAnswer(
     55       const TransportDescription* offer,
     56       const TransportOptions& options,
     57       const TransportDescription* current_description) const;
     58 
     59  private:
     60   bool SetSecurityInfo(TransportDescription* description,
     61                        ConnectionRole role) const;
     62 
     63   SecurePolicy secure_;
     64   rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
     65 };
     66 
     67 }  // namespace cricket
     68 
     69 #endif  // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_
     70