Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 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 | |
| 11 | #import <Foundation/Foundation.h> |
| 12 | |
| 13 | #import "RTCCertificate.h" |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 14 | #import "RTCCryptoOptions.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 15 | #import "RTCMacros.h" |
| 16 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 17 | @class RTC_OBJC_TYPE(RTCIceServer); |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * Represents the ice transport policy. This exposes the same states in C++, |
| 21 | * which include one more state than what exists in the W3C spec. |
| 22 | */ |
| 23 | typedef NS_ENUM(NSInteger, RTCIceTransportPolicy) { |
| 24 | RTCIceTransportPolicyNone, |
| 25 | RTCIceTransportPolicyRelay, |
| 26 | RTCIceTransportPolicyNoHost, |
| 27 | RTCIceTransportPolicyAll |
| 28 | }; |
| 29 | |
| 30 | /** Represents the bundle policy. */ |
| 31 | typedef NS_ENUM(NSInteger, RTCBundlePolicy) { |
| 32 | RTCBundlePolicyBalanced, |
| 33 | RTCBundlePolicyMaxCompat, |
| 34 | RTCBundlePolicyMaxBundle |
| 35 | }; |
| 36 | |
| 37 | /** Represents the rtcp mux policy. */ |
| 38 | typedef NS_ENUM(NSInteger, RTCRtcpMuxPolicy) { RTCRtcpMuxPolicyNegotiate, RTCRtcpMuxPolicyRequire }; |
| 39 | |
| 40 | /** Represents the tcp candidate policy. */ |
| 41 | typedef NS_ENUM(NSInteger, RTCTcpCandidatePolicy) { |
| 42 | RTCTcpCandidatePolicyEnabled, |
| 43 | RTCTcpCandidatePolicyDisabled |
| 44 | }; |
| 45 | |
| 46 | /** Represents the candidate network policy. */ |
| 47 | typedef NS_ENUM(NSInteger, RTCCandidateNetworkPolicy) { |
| 48 | RTCCandidateNetworkPolicyAll, |
| 49 | RTCCandidateNetworkPolicyLowCost |
| 50 | }; |
| 51 | |
| 52 | /** Represents the continual gathering policy. */ |
| 53 | typedef NS_ENUM(NSInteger, RTCContinualGatheringPolicy) { |
| 54 | RTCContinualGatheringPolicyGatherOnce, |
| 55 | RTCContinualGatheringPolicyGatherContinually |
| 56 | }; |
| 57 | |
| 58 | /** Represents the encryption key type. */ |
| 59 | typedef NS_ENUM(NSInteger, RTCEncryptionKeyType) { |
| 60 | RTCEncryptionKeyTypeRSA, |
| 61 | RTCEncryptionKeyTypeECDSA, |
| 62 | }; |
| 63 | |
| 64 | /** Represents the chosen SDP semantics for the RTCPeerConnection. */ |
| 65 | typedef NS_ENUM(NSInteger, RTCSdpSemantics) { |
| 66 | RTCSdpSemanticsPlanB, |
| 67 | RTCSdpSemanticsUnifiedPlan, |
| 68 | }; |
| 69 | |
| 70 | NS_ASSUME_NONNULL_BEGIN |
| 71 | |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 72 | RTC_OBJC_EXPORT |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 73 | @interface RTC_OBJC_TYPE (RTCConfiguration) : NSObject |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 74 | |
Taylor Brandstetter | 21c8032 | 2020-03-24 15:41:19 -0700 | [diff] [blame] | 75 | /** If true, allows DSCP codes to be set on outgoing packets, configured using |
| 76 | * networkPriority field of RTCRtpEncodingParameters. Defaults to false. |
| 77 | */ |
| 78 | @property(nonatomic, assign) BOOL enableDscp; |
| 79 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 80 | /** An array of Ice Servers available to be used by ICE. */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 81 | @property(nonatomic, copy) NSArray<RTC_OBJC_TYPE(RTCIceServer) *> *iceServers; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 82 | |
| 83 | /** An RTCCertificate for 're' use. */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 84 | @property(nonatomic, nullable) RTC_OBJC_TYPE(RTCCertificate) * certificate; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 85 | |
| 86 | /** Which candidates the ICE agent is allowed to use. The W3C calls it |
Artem Titov | d7ac581 | 2021-07-27 12:23:39 +0200 | [diff] [blame] | 87 | * `iceTransportPolicy`, while in C++ it is called `type`. */ |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 88 | @property(nonatomic, assign) RTCIceTransportPolicy iceTransportPolicy; |
| 89 | |
| 90 | /** The media-bundling policy to use when gathering ICE candidates. */ |
| 91 | @property(nonatomic, assign) RTCBundlePolicy bundlePolicy; |
| 92 | |
| 93 | /** The rtcp-mux policy to use when gathering ICE candidates. */ |
| 94 | @property(nonatomic, assign) RTCRtcpMuxPolicy rtcpMuxPolicy; |
| 95 | @property(nonatomic, assign) RTCTcpCandidatePolicy tcpCandidatePolicy; |
| 96 | @property(nonatomic, assign) RTCCandidateNetworkPolicy candidateNetworkPolicy; |
| 97 | @property(nonatomic, assign) RTCContinualGatheringPolicy continualGatheringPolicy; |
| 98 | |
Uladzislau Susha | bf0d0c1 | 2018-11-05 12:48:35 +0300 | [diff] [blame] | 99 | /** If set to YES, don't gather IPv6 ICE candidates. |
| 100 | * Default is NO. |
| 101 | */ |
| 102 | @property(nonatomic, assign) BOOL disableIPV6; |
| 103 | |
| 104 | /** If set to YES, don't gather IPv6 ICE candidates on Wi-Fi. |
| 105 | * Only intended to be used on specific devices. Certain phones disable IPv6 |
| 106 | * when the screen is turned off and it would be better to just disable the |
| 107 | * IPv6 ICE candidates on Wi-Fi in those cases. |
| 108 | * Default is NO. |
| 109 | */ |
| 110 | @property(nonatomic, assign) BOOL disableIPV6OnWiFi; |
| 111 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 112 | /** By default, the PeerConnection will use a limited number of IPv6 network |
| 113 | * interfaces, in order to avoid too many ICE candidate pairs being created |
| 114 | * and delaying ICE completion. |
| 115 | * |
| 116 | * Can be set to INT_MAX to effectively disable the limit. |
| 117 | */ |
| 118 | @property(nonatomic, assign) int maxIPv6Networks; |
| 119 | |
| 120 | /** Exclude link-local network interfaces |
| 121 | * from considertaion for gathering ICE candidates. |
| 122 | * Defaults to NO. |
| 123 | */ |
| 124 | @property(nonatomic, assign) BOOL disableLinkLocalNetworks; |
| 125 | |
| 126 | @property(nonatomic, assign) int audioJitterBufferMaxPackets; |
| 127 | @property(nonatomic, assign) BOOL audioJitterBufferFastAccelerate; |
| 128 | @property(nonatomic, assign) int iceConnectionReceivingTimeout; |
| 129 | @property(nonatomic, assign) int iceBackupCandidatePairPingInterval; |
| 130 | |
| 131 | /** Key type used to generate SSL identity. Default is ECDSA. */ |
| 132 | @property(nonatomic, assign) RTCEncryptionKeyType keyType; |
| 133 | |
| 134 | /** ICE candidate pool size as defined in JSEP. Default is 0. */ |
| 135 | @property(nonatomic, assign) int iceCandidatePoolSize; |
| 136 | |
| 137 | /** Prune turn ports on the same network to the same turn server. |
| 138 | * Default is NO. |
| 139 | */ |
| 140 | @property(nonatomic, assign) BOOL shouldPruneTurnPorts; |
| 141 | |
| 142 | /** If set to YES, this means the ICE transport should presume TURN-to-TURN |
| 143 | * candidate pairs will succeed, even before a binding response is received. |
| 144 | */ |
| 145 | @property(nonatomic, assign) BOOL shouldPresumeWritableWhenFullyRelayed; |
| 146 | |
Artem Titov | d7ac581 | 2021-07-27 12:23:39 +0200 | [diff] [blame] | 147 | /* This flag is only effective when `continualGatheringPolicy` is |
Qingsi Wang | 1fe119f | 2019-05-31 16:55:33 -0700 | [diff] [blame] | 148 | * RTCContinualGatheringPolicyGatherContinually. |
| 149 | * |
| 150 | * If YES, after the ICE transport type is changed such that new types of |
| 151 | * ICE candidates are allowed by the new transport type, e.g. from |
| 152 | * RTCIceTransportPolicyRelay to RTCIceTransportPolicyAll, candidates that |
| 153 | * have been gathered by the ICE transport but not matching the previous |
| 154 | * transport type and as a result not observed by PeerConnectionDelegateAdapter, |
| 155 | * will be surfaced to the delegate. |
| 156 | */ |
| 157 | @property(nonatomic, assign) BOOL shouldSurfaceIceCandidatesOnIceTransportTypeChanged; |
| 158 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 159 | /** If set to non-nil, controls the minimal interval between consecutive ICE |
| 160 | * check packets. |
| 161 | */ |
| 162 | @property(nonatomic, copy, nullable) NSNumber *iceCheckMinInterval; |
| 163 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 164 | /** Configure the SDP semantics used by this PeerConnection. Note that the |
| 165 | * WebRTC 1.0 specification requires UnifiedPlan semantics. The |
| 166 | * RTCRtpTransceiver API is only available with UnifiedPlan semantics. |
| 167 | * |
| 168 | * PlanB will cause RTCPeerConnection to create offers and answers with at |
| 169 | * most one audio and one video m= section with multiple RTCRtpSenders and |
| 170 | * RTCRtpReceivers specified as multiple a=ssrc lines within the section. This |
| 171 | * will also cause RTCPeerConnection to ignore all but the first m= section of |
| 172 | * the same media type. |
| 173 | * |
| 174 | * UnifiedPlan will cause RTCPeerConnection to create offers and answers with |
| 175 | * multiple m= sections where each m= section maps to one RTCRtpSender and one |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 176 | * RTCRtpReceiver (an RTCRtpTransceiver), either both audio or both |
| 177 | * video. This will also cause RTCPeerConnection) to ignore all but the first a=ssrc |
| 178 | * lines that form a Plan B stream. |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 179 | * |
| 180 | * For users who wish to send multiple audio/video streams and need to stay |
| 181 | * interoperable with legacy WebRTC implementations or use legacy APIs, |
| 182 | * specify PlanB. |
| 183 | * |
| 184 | * For all other users, specify UnifiedPlan. |
| 185 | */ |
| 186 | @property(nonatomic, assign) RTCSdpSemantics sdpSemantics; |
| 187 | |
| 188 | /** Actively reset the SRTP parameters when the DTLS transports underneath are |
| 189 | * changed after offer/answer negotiation. This is only intended to be a |
| 190 | * workaround for crbug.com/835958 |
| 191 | */ |
| 192 | @property(nonatomic, assign) BOOL activeResetSrtpParams; |
| 193 | |
philipel | 3eb84f0 | 2019-11-11 12:57:44 +0100 | [diff] [blame] | 194 | /** If the remote side support mid-stream codec switches then allow encoder |
| 195 | * switching to be performed. |
| 196 | */ |
| 197 | |
| 198 | @property(nonatomic, assign) BOOL allowCodecSwitching; |
| 199 | |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 200 | /** |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 201 | * Defines advanced optional cryptographic settings related to SRTP and |
| 202 | * frame encryption for native WebRTC. Setting this will overwrite any |
| 203 | * options set through the PeerConnectionFactory (which is deprecated). |
| 204 | */ |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 205 | @property(nonatomic, nullable) RTC_OBJC_TYPE(RTCCryptoOptions) * cryptoOptions; |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 206 | |
Jiawei Ou | b1e4775 | 2018-11-13 23:48:19 -0800 | [diff] [blame] | 207 | /** |
Brad Pugh | f24143d | 2020-11-16 16:27:20 -0800 | [diff] [blame] | 208 | * An optional string that will be attached to the TURN_ALLOCATE_REQUEST which |
| 209 | * which can be used to correlate client logs with backend logs. |
| 210 | */ |
| 211 | @property(nonatomic, nullable, copy) NSString *turnLoggingId; |
| 212 | |
| 213 | /** |
Jiawei Ou | b1e4775 | 2018-11-13 23:48:19 -0800 | [diff] [blame] | 214 | * Time interval between audio RTCP reports. |
| 215 | */ |
| 216 | @property(nonatomic, assign) int rtcpAudioReportIntervalMs; |
| 217 | |
| 218 | /** |
| 219 | * Time interval between video RTCP reports. |
| 220 | */ |
| 221 | @property(nonatomic, assign) int rtcpVideoReportIntervalMs; |
| 222 | |
Yura Yaroshevich | 4173614 | 2021-03-16 18:04:36 +0300 | [diff] [blame] | 223 | /** |
| 224 | * Allow implicit rollback of local description when remote description |
| 225 | * conflicts with local description. |
| 226 | * See: https://w3c.github.io/webrtc-pc/#dom-peerconnection-setremotedescription |
| 227 | */ |
| 228 | @property(nonatomic, assign) BOOL enableImplicitRollback; |
| 229 | |
Yura Yaroshevich | cbadb8b | 2021-03-17 17:39:52 +0300 | [diff] [blame] | 230 | /** |
| 231 | * Control if "a=extmap-allow-mixed" is included in the offer. |
| 232 | * See: https://www.chromestatus.com/feature/6269234631933952 |
| 233 | */ |
| 234 | @property(nonatomic, assign) BOOL offerExtmapAllowMixed; |
| 235 | |
Yura Yaroshevich | b9fa319 | 2021-03-31 16:48:39 +0300 | [diff] [blame] | 236 | /** |
| 237 | * Defines the interval applied to ALL candidate pairs |
| 238 | * when ICE is strongly connected, and it overrides the |
| 239 | * default value of this interval in the ICE implementation; |
| 240 | */ |
| 241 | @property(nonatomic, copy, nullable) NSNumber *iceCheckIntervalStrongConnectivity; |
| 242 | |
| 243 | /** |
| 244 | * Defines the counterpart for ALL pairs when ICE is |
| 245 | * weakly connected, and it overrides the default value of |
| 246 | * this interval in the ICE implementation |
| 247 | */ |
| 248 | @property(nonatomic, copy, nullable) NSNumber *iceCheckIntervalWeakConnectivity; |
| 249 | |
| 250 | /** |
| 251 | * The min time period for which a candidate pair must wait for response to |
| 252 | * connectivity checks before it becomes unwritable. This parameter |
| 253 | * overrides the default value in the ICE implementation if set. |
| 254 | */ |
| 255 | @property(nonatomic, copy, nullable) NSNumber *iceUnwritableTimeout; |
| 256 | |
| 257 | /** |
| 258 | * The min number of connectivity checks that a candidate pair must sent |
| 259 | * without receiving response before it becomes unwritable. This parameter |
| 260 | * overrides the default value in the ICE implementation if set. |
| 261 | */ |
| 262 | @property(nonatomic, copy, nullable) NSNumber *iceUnwritableMinChecks; |
| 263 | |
| 264 | /** |
| 265 | * The min time period for which a candidate pair must wait for response to |
| 266 | * connectivity checks it becomes inactive. This parameter overrides the |
| 267 | * default value in the ICE implementation if set. |
| 268 | */ |
| 269 | @property(nonatomic, copy, nullable) NSNumber *iceInactiveTimeout; |
| 270 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 271 | - (instancetype)init; |
| 272 | |
| 273 | @end |
| 274 | |
| 275 | NS_ASSUME_NONNULL_END |