blob: b9b3c5b2d792dc1edf7c2874a97b04f016eaf070 [file] [log] [blame]
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +00001/*
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 Lemurc20978e2017-07-06 19:44:34 +020015#include "webrtc/rtc_base/rtccertificate.h"
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000016
17namespace rtc {
18class SSLIdentity;
19}
20
21namespace cricket {
22
23struct TransportOptions {
Honghai Zhang4cedf2b2016-08-31 08:18:11 -070024 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.org269fb4b2014-10-28 22:20:11 +000029};
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.
34class TransportDescriptionFactory {
35 public:
36 // Default ctor; use methods below to set configuration.
37 TransportDescriptionFactory();
38 SecurePolicy secure() const { return secure_; }
Henrik Boström3a14bf32015-08-31 09:27:58 +020039 // The certificate to use when setting up DTLS.
40 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate() const {
41 return certificate_;
42 }
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000043
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000044 // Specifies the transport security policy to use.
45 void set_secure(SecurePolicy s) { secure_ = s; }
Henrik Boström3a14bf32015-08-31 09:27:58 +020046 // 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.org269fb4b2014-10-28 22:20:11 +000051
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.
deadbeefb7892532017-02-22 19:35:18 -080056 //
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.org269fb4b2014-10-28 22:20:11 +000062 TransportDescription* CreateAnswer(
63 const TransportDescription* offer,
64 const TransportOptions& options,
deadbeefb7892532017-02-22 19:35:18 -080065 bool require_transport_attributes,
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000066 const TransportDescription* current_description) const;
67
68 private:
69 bool SetSecurityInfo(TransportDescription* description,
70 ConnectionRole role) const;
71
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000072 SecurePolicy secure_;
Henrik Boström3a14bf32015-08-31 09:27:58 +020073 rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
henrike@webrtc.org269fb4b2014-10-28 22:20:11 +000074};
75
76} // namespace cricket
77
78#endif // WEBRTC_P2P_BASE_TRANSPORTDESCRIPTIONFACTORY_H_