RTCConfiguration.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * Copyright 2015 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. #import <Foundation/Foundation.h>
  11. #import "RTCCertificate.h"
  12. #import "RTCCryptoOptions.h"
  13. #import "RTCMacros.h"
  14. @class RTCIceServer;
  15. @class RTCIntervalRange;
  16. /**
  17. * Represents the ice transport policy. This exposes the same states in C++,
  18. * which include one more state than what exists in the W3C spec.
  19. */
  20. typedef NS_ENUM(NSInteger, RTCIceTransportPolicy) {
  21. RTCIceTransportPolicyNone,
  22. RTCIceTransportPolicyRelay,
  23. RTCIceTransportPolicyNoHost,
  24. RTCIceTransportPolicyAll
  25. };
  26. /** Represents the bundle policy. */
  27. typedef NS_ENUM(NSInteger, RTCBundlePolicy) {
  28. RTCBundlePolicyBalanced,
  29. RTCBundlePolicyMaxCompat,
  30. RTCBundlePolicyMaxBundle
  31. };
  32. /** Represents the rtcp mux policy. */
  33. typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { RTCRtcpMuxPolicyNegotiate, RTCRtcpMuxPolicyRequire };
  34. /** Represents the tcp candidate policy. */
  35. typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) {
  36. RTCTcpCandidatePolicyEnabled,
  37. RTCTcpCandidatePolicyDisabled
  38. };
  39. /** Represents the candidate network policy. */
  40. typedef NS_ENUM(NSInteger, RTCCandidateNetworkPolicy) {
  41. RTCCandidateNetworkPolicyAll,
  42. RTCCandidateNetworkPolicyLowCost
  43. };
  44. /** Represents the continual gathering policy. */
  45. typedef NS_ENUM(NSInteger, RTCContinualGatheringPolicy) {
  46. RTCContinualGatheringPolicyGatherOnce,
  47. RTCContinualGatheringPolicyGatherContinually
  48. };
  49. /** Represents the encryption key type. */
  50. typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) {
  51. RTCEncryptionKeyTypeRSA,
  52. RTCEncryptionKeyTypeECDSA,
  53. };
  54. /** Represents the chosen SDP semantics for the RTCPeerConnection. */
  55. typedef NS_ENUM(NSInteger, RTCSdpSemantics) {
  56. RTCSdpSemanticsPlanB,
  57. RTCSdpSemanticsUnifiedPlan,
  58. };
  59. NS_ASSUME_NONNULL_BEGIN
  60. RTC_OBJC_EXPORT
  61. @interface RTCConfiguration : NSObject
  62. /** An array of Ice Servers available to be used by ICE. */
  63. @property(nonatomic, copy) NSArray<RTCIceServer *> *iceServers;
  64. /** An RTCCertificate for 're' use. */
  65. @property(nonatomic, nullable) RTCCertificate *certificate;
  66. /** Which candidates the ICE agent is allowed to use. The W3C calls it
  67. * |iceTransportPolicy|, while in C++ it is called |type|. */
  68. @property(nonatomic, assign) RTCIceTransportPolicy iceTransportPolicy;
  69. /** The media-bundling policy to use when gathering ICE candidates. */
  70. @property(nonatomic, assign) RTCBundlePolicy bundlePolicy;
  71. /** The rtcp-mux policy to use when gathering ICE candidates. */
  72. @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy;
  73. @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy;
  74. @property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy;
  75. @property(nonatomic, assign) RTCContinualGatheringPolicy continualGatheringPolicy;
  76. /** If set to YES, don't gather IPv6 ICE candidates.
  77. * Default is NO.
  78. */
  79. @property(nonatomic, assign) BOOL disableIPV6;
  80. /** If set to YES, don't gather IPv6 ICE candidates on Wi-Fi.
  81. * Only intended to be used on specific devices. Certain phones disable IPv6
  82. * when the screen is turned off and it would be better to just disable the
  83. * IPv6 ICE candidates on Wi-Fi in those cases.
  84. * Default is NO.
  85. */
  86. @property(nonatomic, assign) BOOL disableIPV6OnWiFi;
  87. /** By default, the PeerConnection will use a limited number of IPv6 network
  88. * interfaces, in order to avoid too many ICE candidate pairs being created
  89. * and delaying ICE completion.
  90. *
  91. * Can be set to INT_MAX to effectively disable the limit.
  92. */
  93. @property(nonatomic, assign) int maxIPv6Networks;
  94. /** Exclude link-local network interfaces
  95. * from considertaion for gathering ICE candidates.
  96. * Defaults to NO.
  97. */
  98. @property(nonatomic, assign) BOOL disableLinkLocalNetworks;
  99. @property(nonatomic, assign) int audioJitterBufferMaxPackets;
  100. @property(nonatomic, assign) BOOL audioJitterBufferFastAccelerate;
  101. @property(nonatomic, assign) int iceConnectionReceivingTimeout;
  102. @property(nonatomic, assign) int iceBackupCandidatePairPingInterval;
  103. /** Key type used to generate SSL identity. Default is ECDSA. */
  104. @property(nonatomic, assign) RTCEncryptionKeyType keyType;
  105. /** ICE candidate pool size as defined in JSEP. Default is 0. */
  106. @property(nonatomic, assign) int iceCandidatePoolSize;
  107. /** Prune turn ports on the same network to the same turn server.
  108. * Default is NO.
  109. */
  110. @property(nonatomic, assign) BOOL shouldPruneTurnPorts;
  111. /** If set to YES, this means the ICE transport should presume TURN-to-TURN
  112. * candidate pairs will succeed, even before a binding response is received.
  113. */
  114. @property(nonatomic, assign) BOOL shouldPresumeWritableWhenFullyRelayed;
  115. /** If set to non-nil, controls the minimal interval between consecutive ICE
  116. * check packets.
  117. */
  118. @property(nonatomic, copy, nullable) NSNumber *iceCheckMinInterval;
  119. /** ICE Periodic Regathering
  120. * If set, WebRTC will periodically create and propose candidates without
  121. * starting a new ICE generation. The regathering happens continuously with
  122. * interval specified in milliseconds by the uniform distribution [a, b].
  123. */
  124. @property(nonatomic, strong, nullable) RTCIntervalRange *iceRegatherIntervalRange;
  125. /** Configure the SDP semantics used by this PeerConnection. Note that the
  126. * WebRTC 1.0 specification requires UnifiedPlan semantics. The
  127. * RTCRtpTransceiver API is only available with UnifiedPlan semantics.
  128. *
  129. * PlanB will cause RTCPeerConnection to create offers and answers with at
  130. * most one audio and one video m= section with multiple RTCRtpSenders and
  131. * RTCRtpReceivers specified as multiple a=ssrc lines within the section. This
  132. * will also cause RTCPeerConnection to ignore all but the first m= section of
  133. * the same media type.
  134. *
  135. * UnifiedPlan will cause RTCPeerConnection to create offers and answers with
  136. * multiple m= sections where each m= section maps to one RTCRtpSender and one
  137. * RTCRtpReceiver (an RTCRtpTransceiver), either both audio or both video. This
  138. * will also cause RTCPeerConnection to ignore all but the first a=ssrc lines
  139. * that form a Plan B stream.
  140. *
  141. * For users who wish to send multiple audio/video streams and need to stay
  142. * interoperable with legacy WebRTC implementations or use legacy APIs,
  143. * specify PlanB.
  144. *
  145. * For all other users, specify UnifiedPlan.
  146. */
  147. @property(nonatomic, assign) RTCSdpSemantics sdpSemantics;
  148. /** Actively reset the SRTP parameters when the DTLS transports underneath are
  149. * changed after offer/answer negotiation. This is only intended to be a
  150. * workaround for crbug.com/835958
  151. */
  152. @property(nonatomic, assign) BOOL activeResetSrtpParams;
  153. /**
  154. * If MediaTransportFactory is provided in PeerConnectionFactory, this flag informs PeerConnection
  155. * that it should use the MediaTransportInterface.
  156. */
  157. @property(nonatomic, assign) BOOL useMediaTransport;
  158. /**
  159. * If MediaTransportFactory is provided in PeerConnectionFactory, this flag informs PeerConnection
  160. * that it should use the MediaTransportInterface for data channels.
  161. */
  162. @property(nonatomic, assign) BOOL useMediaTransportForDataChannels;
  163. /**
  164. * Defines advanced optional cryptographic settings related to SRTP and
  165. * frame encryption for native WebRTC. Setting this will overwrite any
  166. * options set through the PeerConnectionFactory (which is deprecated).
  167. */
  168. @property(nonatomic, nullable) RTCCryptoOptions *cryptoOptions;
  169. /**
  170. * Time interval between audio RTCP reports.
  171. */
  172. @property(nonatomic, assign) int rtcpAudioReportIntervalMs;
  173. /**
  174. * Time interval between video RTCP reports.
  175. */
  176. @property(nonatomic, assign) int rtcpVideoReportIntervalMs;
  177. - (instancetype)init;
  178. @end
  179. NS_ASSUME_NONNULL_END