transport_description_factory.h 3.0 KB

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