hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [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 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 11 | #import "RTCConfiguration+Private.h" |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 12 | |
jbauch | 555604a | 2016-04-26 03:13:22 -0700 | [diff] [blame] | 13 | #include <memory> |
| 14 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 15 | #import "RTCCertificate.h" |
Zeke Chin | ef1140e | 2017-10-27 15:42:08 -0700 | [diff] [blame] | 16 | #import "RTCConfiguration+Native.h" |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 17 | #import "RTCIceServer+Private.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 18 | #import "base/RTCLogging.h" |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 19 | |
Henrik Boström | 62995db | 2022-01-03 09:58:10 +0100 | [diff] [blame] | 20 | #include "rtc_base/checks.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 21 | #include "rtc_base/rtc_certificate_generator.h" |
| 22 | #include "rtc_base/ssl_identity.h" |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 23 | |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 24 | @implementation RTC_OBJC_TYPE (RTCConfiguration) |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 25 | |
Taylor Brandstetter | 21c8032 | 2020-03-24 15:41:19 -0700 | [diff] [blame] | 26 | @synthesize enableDscp = _enableDscp; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 27 | @synthesize iceServers = _iceServers; |
Michael Iedema | ccee56b | 2018-07-05 15:28:24 +0200 | [diff] [blame] | 28 | @synthesize certificate = _certificate; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 29 | @synthesize iceTransportPolicy = _iceTransportPolicy; |
| 30 | @synthesize bundlePolicy = _bundlePolicy; |
| 31 | @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
| 32 | @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 33 | @synthesize candidateNetworkPolicy = _candidateNetworkPolicy; |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 34 | @synthesize continualGatheringPolicy = _continualGatheringPolicy; |
Uladzislau Susha | bf0d0c1 | 2018-11-05 12:48:35 +0300 | [diff] [blame] | 35 | @synthesize disableIPV6 = _disableIPV6; |
| 36 | @synthesize disableIPV6OnWiFi = _disableIPV6OnWiFi; |
deadbeef | 2059bb3 | 2017-07-26 18:25:43 -0700 | [diff] [blame] | 37 | @synthesize maxIPv6Networks = _maxIPv6Networks; |
Daniel Lazarenko | 2870b0a | 2018-01-25 10:30:22 +0100 | [diff] [blame] | 38 | @synthesize disableLinkLocalNetworks = _disableLinkLocalNetworks; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 39 | @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; |
haysc | c9f9500 | 2016-12-05 14:24:32 -0800 | [diff] [blame] | 40 | @synthesize audioJitterBufferFastAccelerate = _audioJitterBufferFastAccelerate; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 41 | @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; |
| 42 | @synthesize iceBackupCandidatePairPingInterval = |
| 43 | _iceBackupCandidatePairPingInterval; |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 44 | @synthesize keyType = _keyType; |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 45 | @synthesize iceCandidatePoolSize = _iceCandidatePoolSize; |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 46 | @synthesize shouldPruneTurnPorts = _shouldPruneTurnPorts; |
| 47 | @synthesize shouldPresumeWritableWhenFullyRelayed = |
| 48 | _shouldPresumeWritableWhenFullyRelayed; |
Qingsi Wang | 1fe119f | 2019-05-31 16:55:33 -0700 | [diff] [blame] | 49 | @synthesize shouldSurfaceIceCandidatesOnIceTransportTypeChanged = |
| 50 | _shouldSurfaceIceCandidatesOnIceTransportTypeChanged; |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 51 | @synthesize iceCheckMinInterval = _iceCheckMinInterval; |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 52 | @synthesize sdpSemantics = _sdpSemantics; |
Zeke Chin | ef1140e | 2017-10-27 15:42:08 -0700 | [diff] [blame] | 53 | @synthesize turnCustomizer = _turnCustomizer; |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 54 | @synthesize activeResetSrtpParams = _activeResetSrtpParams; |
philipel | 3eb84f0 | 2019-11-11 12:57:44 +0100 | [diff] [blame] | 55 | @synthesize allowCodecSwitching = _allowCodecSwitching; |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 56 | @synthesize cryptoOptions = _cryptoOptions; |
Brad Pugh | f24143d | 2020-11-16 16:27:20 -0800 | [diff] [blame] | 57 | @synthesize turnLoggingId = _turnLoggingId; |
Jiawei Ou | b1e4775 | 2018-11-13 23:48:19 -0800 | [diff] [blame] | 58 | @synthesize rtcpAudioReportIntervalMs = _rtcpAudioReportIntervalMs; |
| 59 | @synthesize rtcpVideoReportIntervalMs = _rtcpVideoReportIntervalMs; |
Yura Yaroshevich | 4173614 | 2021-03-16 18:04:36 +0300 | [diff] [blame] | 60 | @synthesize enableImplicitRollback = _enableImplicitRollback; |
Yura Yaroshevich | cbadb8b | 2021-03-17 17:39:52 +0300 | [diff] [blame] | 61 | @synthesize offerExtmapAllowMixed = _offerExtmapAllowMixed; |
Yura Yaroshevich | b9fa319 | 2021-03-31 16:48:39 +0300 | [diff] [blame] | 62 | @synthesize iceCheckIntervalStrongConnectivity = _iceCheckIntervalStrongConnectivity; |
| 63 | @synthesize iceCheckIntervalWeakConnectivity = _iceCheckIntervalWeakConnectivity; |
| 64 | @synthesize iceUnwritableTimeout = _iceUnwritableTimeout; |
| 65 | @synthesize iceUnwritableMinChecks = _iceUnwritableMinChecks; |
| 66 | @synthesize iceInactiveTimeout = _iceInactiveTimeout; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 67 | |
| 68 | - (instancetype)init { |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 69 | // Copy defaults. |
Yuriy Pavlyshak | 8cec4fb | 2018-09-07 16:43:31 +0200 | [diff] [blame] | 70 | webrtc::PeerConnectionInterface::RTCConfiguration config; |
Henrik Boström | 2832bbf | 2022-01-21 09:49:31 +0100 | [diff] [blame] | 71 | config.sdp_semantics = webrtc::SdpSemantics::kUnifiedPlan; |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 72 | return [self initWithNativeConfiguration:config]; |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | - (instancetype)initWithNativeConfiguration: |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 76 | (const webrtc::PeerConnectionInterface::RTCConfiguration &)config { |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 77 | if (self = [super init]) { |
Taylor Brandstetter | 21c8032 | 2020-03-24 15:41:19 -0700 | [diff] [blame] | 78 | _enableDscp = config.dscp(); |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 79 | NSMutableArray *iceServers = [NSMutableArray array]; |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 80 | for (const webrtc::PeerConnectionInterface::IceServer& server : config.servers) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 81 | RTC_OBJC_TYPE(RTCIceServer) *iceServer = |
| 82 | [[RTC_OBJC_TYPE(RTCIceServer) alloc] initWithNativeServer:server]; |
jtteh | 4eeb537 | 2017-04-03 15:06:37 -0700 | [diff] [blame] | 83 | [iceServers addObject:iceServer]; |
| 84 | } |
| 85 | _iceServers = iceServers; |
Michael Iedema | ccee56b | 2018-07-05 15:28:24 +0200 | [diff] [blame] | 86 | if (!config.certificates.empty()) { |
| 87 | rtc::scoped_refptr<rtc::RTCCertificate> native_cert; |
| 88 | native_cert = config.certificates[0]; |
| 89 | rtc::RTCCertificatePEM native_pem = native_cert->ToPEM(); |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 90 | _certificate = [[RTC_OBJC_TYPE(RTCCertificate) alloc] |
| 91 | initWithPrivateKey:@(native_pem.private_key().c_str()) |
| 92 | certificate:@(native_pem.certificate().c_str())]; |
Michael Iedema | ccee56b | 2018-07-05 15:28:24 +0200 | [diff] [blame] | 93 | } |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 94 | _iceTransportPolicy = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 95 | [[self class] transportPolicyForTransportsType:config.type]; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 96 | _bundlePolicy = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 97 | [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 98 | _rtcpMuxPolicy = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 99 | [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 100 | _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 101 | config.tcp_candidate_policy]; |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 102 | _candidateNetworkPolicy = [[self class] |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 103 | candidateNetworkPolicyForNativePolicy:config.candidate_network_policy]; |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 104 | webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 105 | config.continual_gathering_policy; |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 106 | _continualGatheringPolicy = |
| 107 | [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; |
Uladzislau Susha | bf0d0c1 | 2018-11-05 12:48:35 +0300 | [diff] [blame] | 108 | _disableIPV6 = config.disable_ipv6; |
| 109 | _disableIPV6OnWiFi = config.disable_ipv6_on_wifi; |
deadbeef | 2059bb3 | 2017-07-26 18:25:43 -0700 | [diff] [blame] | 110 | _maxIPv6Networks = config.max_ipv6_networks; |
Daniel Lazarenko | 2870b0a | 2018-01-25 10:30:22 +0100 | [diff] [blame] | 111 | _disableLinkLocalNetworks = config.disable_link_local_networks; |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 112 | _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; |
| 113 | _audioJitterBufferFastAccelerate = config.audio_jitter_buffer_fast_accelerate; |
| 114 | _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 115 | _iceBackupCandidatePairPingInterval = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 116 | config.ice_backup_candidate_pair_ping_interval; |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 117 | _keyType = RTCEncryptionKeyTypeECDSA; |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 118 | _iceCandidatePoolSize = config.ice_candidate_pool_size; |
| 119 | _shouldPruneTurnPorts = config.prune_turn_ports; |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 120 | _shouldPresumeWritableWhenFullyRelayed = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 121 | config.presume_writable_when_fully_relayed; |
Qingsi Wang | 1fe119f | 2019-05-31 16:55:33 -0700 | [diff] [blame] | 122 | _shouldSurfaceIceCandidatesOnIceTransportTypeChanged = |
| 123 | config.surface_ice_candidates_on_ice_transport_type_changed; |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 124 | if (config.ice_check_min_interval) { |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 125 | _iceCheckMinInterval = |
jtteh | 465faf0 | 2017-04-04 14:00:16 -0700 | [diff] [blame] | 126 | [NSNumber numberWithInt:*config.ice_check_min_interval]; |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 127 | } |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 128 | _sdpSemantics = [[self class] sdpSemanticsForNativeSdpSemantics:config.sdp_semantics]; |
Zeke Chin | ef1140e | 2017-10-27 15:42:08 -0700 | [diff] [blame] | 129 | _turnCustomizer = config.turn_customizer; |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 130 | _activeResetSrtpParams = config.active_reset_srtp_params; |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 131 | if (config.crypto_options) { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 132 | _cryptoOptions = [[RTC_OBJC_TYPE(RTCCryptoOptions) alloc] |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 133 | initWithSrtpEnableGcmCryptoSuites:config.crypto_options->srtp |
| 134 | .enable_gcm_crypto_suites |
| 135 | srtpEnableAes128Sha1_32CryptoCipher:config.crypto_options->srtp |
| 136 | .enable_aes128_sha1_32_crypto_cipher |
| 137 | srtpEnableEncryptedRtpHeaderExtensions:config.crypto_options->srtp |
| 138 | .enable_encrypted_rtp_header_extensions |
| 139 | sframeRequireFrameEncryption:config.crypto_options->sframe |
| 140 | .require_frame_encryption]; |
| 141 | } |
Brad Pugh | f24143d | 2020-11-16 16:27:20 -0800 | [diff] [blame] | 142 | _turnLoggingId = [NSString stringWithUTF8String:config.turn_logging_id.c_str()]; |
Jiawei Ou | b1e4775 | 2018-11-13 23:48:19 -0800 | [diff] [blame] | 143 | _rtcpAudioReportIntervalMs = config.audio_rtcp_report_interval_ms(); |
| 144 | _rtcpVideoReportIntervalMs = config.video_rtcp_report_interval_ms(); |
philipel | 3eb84f0 | 2019-11-11 12:57:44 +0100 | [diff] [blame] | 145 | _allowCodecSwitching = config.allow_codec_switching.value_or(false); |
Yura Yaroshevich | 4173614 | 2021-03-16 18:04:36 +0300 | [diff] [blame] | 146 | _enableImplicitRollback = config.enable_implicit_rollback; |
Yura Yaroshevich | cbadb8b | 2021-03-17 17:39:52 +0300 | [diff] [blame] | 147 | _offerExtmapAllowMixed = config.offer_extmap_allow_mixed; |
Yura Yaroshevich | b9fa319 | 2021-03-31 16:48:39 +0300 | [diff] [blame] | 148 | _iceCheckIntervalStrongConnectivity = |
| 149 | config.ice_check_interval_strong_connectivity.has_value() ? |
| 150 | [NSNumber numberWithInt:*config.ice_check_interval_strong_connectivity] : |
| 151 | nil; |
| 152 | _iceCheckIntervalWeakConnectivity = config.ice_check_interval_weak_connectivity.has_value() ? |
| 153 | [NSNumber numberWithInt:*config.ice_check_interval_weak_connectivity] : |
| 154 | nil; |
| 155 | _iceUnwritableTimeout = config.ice_unwritable_timeout.has_value() ? |
| 156 | [NSNumber numberWithInt:*config.ice_unwritable_timeout] : |
| 157 | nil; |
| 158 | _iceUnwritableMinChecks = config.ice_unwritable_min_checks.has_value() ? |
| 159 | [NSNumber numberWithInt:*config.ice_unwritable_min_checks] : |
| 160 | nil; |
| 161 | _iceInactiveTimeout = config.ice_inactive_timeout.has_value() ? |
| 162 | [NSNumber numberWithInt:*config.ice_inactive_timeout] : |
| 163 | nil; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 164 | } |
| 165 | return self; |
| 166 | } |
| 167 | |
| 168 | - (NSString *)description { |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 169 | static NSString *formatString = @"RTC_OBJC_TYPE(RTCConfiguration): " |
Uladzislau Susha | bf0d0c1 | 2018-11-05 12:48:35 +0300 | [diff] [blame] | 170 | @"{\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n" |
Yura Yaroshevich | 1153974 | 2021-04-20 13:38:36 +0300 | [diff] [blame] | 171 | @"%d\n%@\n%d\n%d\n%d\n%d\n%d\n%d\n%d\n}\n"; |
Daniel Lazarenko | 2870b0a | 2018-01-25 10:30:22 +0100 | [diff] [blame] | 172 | |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 173 | return [NSString |
| 174 | stringWithFormat:formatString, |
| 175 | _iceServers, |
| 176 | [[self class] stringForTransportPolicy:_iceTransportPolicy], |
| 177 | [[self class] stringForBundlePolicy:_bundlePolicy], |
| 178 | [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], |
| 179 | [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
| 180 | [[self class] stringForCandidateNetworkPolicy:_candidateNetworkPolicy], |
| 181 | [[self class] stringForContinualGatheringPolicy:_continualGatheringPolicy], |
| 182 | [[self class] stringForSdpSemantics:_sdpSemantics], |
| 183 | _audioJitterBufferMaxPackets, |
| 184 | _audioJitterBufferFastAccelerate, |
| 185 | _iceConnectionReceivingTimeout, |
| 186 | _iceBackupCandidatePairPingInterval, |
| 187 | _iceCandidatePoolSize, |
| 188 | _shouldPruneTurnPorts, |
| 189 | _shouldPresumeWritableWhenFullyRelayed, |
Qingsi Wang | 1fe119f | 2019-05-31 16:55:33 -0700 | [diff] [blame] | 190 | _shouldSurfaceIceCandidatesOnIceTransportTypeChanged, |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 191 | _iceCheckMinInterval, |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 192 | _disableLinkLocalNetworks, |
Uladzislau Susha | bf0d0c1 | 2018-11-05 12:48:35 +0300 | [diff] [blame] | 193 | _disableIPV6, |
| 194 | _disableIPV6OnWiFi, |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 195 | _maxIPv6Networks, |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 196 | _activeResetSrtpParams, |
Yura Yaroshevich | 4173614 | 2021-03-16 18:04:36 +0300 | [diff] [blame] | 197 | _enableDscp, |
| 198 | _enableImplicitRollback]; |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | #pragma mark - Private |
| 202 | |
hbos | a73ca56 | 2016-05-17 03:28:58 -0700 | [diff] [blame] | 203 | - (webrtc::PeerConnectionInterface::RTCConfiguration *) |
| 204 | createNativeConfiguration { |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 205 | std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> |
Honghai Zhang | f7ddc06 | 2016-09-01 15:34:01 -0700 | [diff] [blame] | 206 | nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration( |
| 207 | webrtc::PeerConnectionInterface::RTCConfigurationType::kAggressive)); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 208 | |
Taylor Brandstetter | 21c8032 | 2020-03-24 15:41:19 -0700 | [diff] [blame] | 209 | nativeConfig->set_dscp(_enableDscp); |
Mirko Bonadei | a81e9c8 | 2020-05-04 16:14:32 +0200 | [diff] [blame] | 210 | for (RTC_OBJC_TYPE(RTCIceServer) * iceServer in _iceServers) { |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 211 | nativeConfig->servers.push_back(iceServer.nativeServer); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 212 | } |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 213 | nativeConfig->type = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 214 | [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 215 | nativeConfig->bundle_policy = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 216 | [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 217 | nativeConfig->rtcp_mux_policy = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 218 | [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 219 | nativeConfig->tcp_candidate_policy = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 220 | [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 221 | nativeConfig->candidate_network_policy = [[self class] |
| 222 | nativeCandidateNetworkPolicyForPolicy:_candidateNetworkPolicy]; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 223 | nativeConfig->continual_gathering_policy = [[self class] |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 224 | nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; |
Uladzislau Susha | bf0d0c1 | 2018-11-05 12:48:35 +0300 | [diff] [blame] | 225 | nativeConfig->disable_ipv6 = _disableIPV6; |
| 226 | nativeConfig->disable_ipv6_on_wifi = _disableIPV6OnWiFi; |
deadbeef | 2059bb3 | 2017-07-26 18:25:43 -0700 | [diff] [blame] | 227 | nativeConfig->max_ipv6_networks = _maxIPv6Networks; |
Daniel Lazarenko | 2870b0a | 2018-01-25 10:30:22 +0100 | [diff] [blame] | 228 | nativeConfig->disable_link_local_networks = _disableLinkLocalNetworks; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 229 | nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
haysc | c9f9500 | 2016-12-05 14:24:32 -0800 | [diff] [blame] | 230 | nativeConfig->audio_jitter_buffer_fast_accelerate = |
| 231 | _audioJitterBufferFastAccelerate ? true : false; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 232 | nativeConfig->ice_connection_receiving_timeout = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 233 | _iceConnectionReceivingTimeout; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 234 | nativeConfig->ice_backup_candidate_pair_ping_interval = |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 235 | _iceBackupCandidatePairPingInterval; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 236 | rtc::KeyType keyType = |
| 237 | [[self class] nativeEncryptionKeyTypeForKeyType:_keyType]; |
Michael Iedema | ccee56b | 2018-07-05 15:28:24 +0200 | [diff] [blame] | 238 | if (_certificate != nullptr) { |
| 239 | // if offered a pemcert use it... |
| 240 | RTC_LOG(LS_INFO) << "Have configured cert - using it."; |
| 241 | std::string pem_private_key = [[_certificate private_key] UTF8String]; |
| 242 | std::string pem_certificate = [[_certificate certificate] UTF8String]; |
| 243 | rtc::RTCCertificatePEM pem = rtc::RTCCertificatePEM(pem_private_key, pem_certificate); |
| 244 | rtc::scoped_refptr<rtc::RTCCertificate> certificate = rtc::RTCCertificate::FromPEM(pem); |
| 245 | RTC_LOG(LS_INFO) << "Created cert from PEM strings."; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 246 | if (!certificate) { |
Michael Iedema | ccee56b | 2018-07-05 15:28:24 +0200 | [diff] [blame] | 247 | RTC_LOG(LS_ERROR) << "Failed to generate certificate from PEM."; |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 248 | return nullptr; |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 249 | } |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 250 | nativeConfig->certificates.push_back(certificate); |
Michael Iedema | ccee56b | 2018-07-05 15:28:24 +0200 | [diff] [blame] | 251 | } else { |
| 252 | RTC_LOG(LS_INFO) << "Don't have configured cert."; |
| 253 | // Generate non-default certificate. |
| 254 | if (keyType != rtc::KT_DEFAULT) { |
| 255 | rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
| 256 | rtc::RTCCertificateGenerator::GenerateCertificate(rtc::KeyParams(keyType), |
| 257 | absl::optional<uint64_t>()); |
| 258 | if (!certificate) { |
| 259 | RTCLogError(@"Failed to generate certificate."); |
| 260 | return nullptr; |
| 261 | } |
| 262 | nativeConfig->certificates.push_back(certificate); |
| 263 | } |
tkchin | ab8f82f | 2016-01-27 17:50:11 -0800 | [diff] [blame] | 264 | } |
deadbeef | be0c96f | 2016-05-18 16:20:14 -0700 | [diff] [blame] | 265 | nativeConfig->ice_candidate_pool_size = _iceCandidatePoolSize; |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 266 | nativeConfig->prune_turn_ports = _shouldPruneTurnPorts ? true : false; |
Taylor Brandstetter | e985111 | 2016-07-01 11:11:13 -0700 | [diff] [blame] | 267 | nativeConfig->presume_writable_when_fully_relayed = |
honghaiz | af6b6e0 | 2016-07-11 15:09:26 -0700 | [diff] [blame] | 268 | _shouldPresumeWritableWhenFullyRelayed ? true : false; |
Qingsi Wang | 1fe119f | 2019-05-31 16:55:33 -0700 | [diff] [blame] | 269 | nativeConfig->surface_ice_candidates_on_ice_transport_type_changed = |
| 270 | _shouldSurfaceIceCandidatesOnIceTransportTypeChanged ? true : false; |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 271 | if (_iceCheckMinInterval != nil) { |
Danil Chapovalov | 196100e | 2018-06-21 10:17:24 +0200 | [diff] [blame] | 272 | nativeConfig->ice_check_min_interval = absl::optional<int>(_iceCheckMinInterval.intValue); |
skvlad | a5d94ff | 2017-02-02 13:02:30 -0800 | [diff] [blame] | 273 | } |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 274 | nativeConfig->sdp_semantics = [[self class] nativeSdpSemanticsForSdpSemantics:_sdpSemantics]; |
Zeke Chin | ef1140e | 2017-10-27 15:42:08 -0700 | [diff] [blame] | 275 | if (_turnCustomizer) { |
| 276 | nativeConfig->turn_customizer = _turnCustomizer; |
| 277 | } |
Zhi Huang | b57e169 | 2018-06-12 11:41:11 -0700 | [diff] [blame] | 278 | nativeConfig->active_reset_srtp_params = _activeResetSrtpParams ? true : false; |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 279 | if (_cryptoOptions) { |
| 280 | webrtc::CryptoOptions nativeCryptoOptions; |
| 281 | nativeCryptoOptions.srtp.enable_gcm_crypto_suites = |
| 282 | _cryptoOptions.srtpEnableGcmCryptoSuites ? true : false; |
| 283 | nativeCryptoOptions.srtp.enable_aes128_sha1_32_crypto_cipher = |
| 284 | _cryptoOptions.srtpEnableAes128Sha1_32CryptoCipher ? true : false; |
| 285 | nativeCryptoOptions.srtp.enable_encrypted_rtp_header_extensions = |
| 286 | _cryptoOptions.srtpEnableEncryptedRtpHeaderExtensions ? true : false; |
| 287 | nativeCryptoOptions.sframe.require_frame_encryption = |
| 288 | _cryptoOptions.sframeRequireFrameEncryption ? true : false; |
| 289 | nativeConfig->crypto_options = absl::optional<webrtc::CryptoOptions>(nativeCryptoOptions); |
| 290 | } |
Brad Pugh | f24143d | 2020-11-16 16:27:20 -0800 | [diff] [blame] | 291 | nativeConfig->turn_logging_id = [_turnLoggingId UTF8String]; |
Jiawei Ou | b1e4775 | 2018-11-13 23:48:19 -0800 | [diff] [blame] | 292 | nativeConfig->set_audio_rtcp_report_interval_ms(_rtcpAudioReportIntervalMs); |
| 293 | nativeConfig->set_video_rtcp_report_interval_ms(_rtcpVideoReportIntervalMs); |
philipel | 3eb84f0 | 2019-11-11 12:57:44 +0100 | [diff] [blame] | 294 | nativeConfig->allow_codec_switching = _allowCodecSwitching; |
Yura Yaroshevich | 4173614 | 2021-03-16 18:04:36 +0300 | [diff] [blame] | 295 | nativeConfig->enable_implicit_rollback = _enableImplicitRollback; |
Yura Yaroshevich | cbadb8b | 2021-03-17 17:39:52 +0300 | [diff] [blame] | 296 | nativeConfig->offer_extmap_allow_mixed = _offerExtmapAllowMixed; |
Yura Yaroshevich | b9fa319 | 2021-03-31 16:48:39 +0300 | [diff] [blame] | 297 | if (_iceCheckIntervalStrongConnectivity != nil) { |
| 298 | nativeConfig->ice_check_interval_strong_connectivity = |
| 299 | absl::optional<int>(_iceCheckIntervalStrongConnectivity.intValue); |
| 300 | } |
| 301 | if (_iceCheckIntervalWeakConnectivity != nil) { |
| 302 | nativeConfig->ice_check_interval_weak_connectivity = |
| 303 | absl::optional<int>(_iceCheckIntervalWeakConnectivity.intValue); |
| 304 | } |
| 305 | if (_iceUnwritableTimeout != nil) { |
| 306 | nativeConfig->ice_unwritable_timeout = absl::optional<int>(_iceUnwritableTimeout.intValue); |
| 307 | } |
| 308 | if (_iceUnwritableMinChecks != nil) { |
| 309 | nativeConfig->ice_unwritable_min_checks = absl::optional<int>(_iceUnwritableMinChecks.intValue); |
| 310 | } |
| 311 | if (_iceInactiveTimeout != nil) { |
| 312 | nativeConfig->ice_inactive_timeout = absl::optional<int>(_iceInactiveTimeout.intValue); |
| 313 | } |
Henrik Boström | e06c2dd | 2016-05-13 13:50:38 +0200 | [diff] [blame] | 314 | return nativeConfig.release(); |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 315 | } |
| 316 | |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 317 | + (webrtc::PeerConnectionInterface::IceTransportsType) |
| 318 | nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { |
| 319 | switch (policy) { |
| 320 | case RTCIceTransportPolicyNone: |
| 321 | return webrtc::PeerConnectionInterface::kNone; |
| 322 | case RTCIceTransportPolicyRelay: |
| 323 | return webrtc::PeerConnectionInterface::kRelay; |
| 324 | case RTCIceTransportPolicyNoHost: |
| 325 | return webrtc::PeerConnectionInterface::kNoHost; |
| 326 | case RTCIceTransportPolicyAll: |
| 327 | return webrtc::PeerConnectionInterface::kAll; |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | + (RTCIceTransportPolicy)transportPolicyForTransportsType: |
| 332 | (webrtc::PeerConnectionInterface::IceTransportsType)nativeType { |
| 333 | switch (nativeType) { |
| 334 | case webrtc::PeerConnectionInterface::kNone: |
| 335 | return RTCIceTransportPolicyNone; |
| 336 | case webrtc::PeerConnectionInterface::kRelay: |
| 337 | return RTCIceTransportPolicyRelay; |
| 338 | case webrtc::PeerConnectionInterface::kNoHost: |
| 339 | return RTCIceTransportPolicyNoHost; |
| 340 | case webrtc::PeerConnectionInterface::kAll: |
| 341 | return RTCIceTransportPolicyAll; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | + (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy { |
| 346 | switch (policy) { |
| 347 | case RTCIceTransportPolicyNone: |
| 348 | return @"NONE"; |
| 349 | case RTCIceTransportPolicyRelay: |
| 350 | return @"RELAY"; |
| 351 | case RTCIceTransportPolicyNoHost: |
| 352 | return @"NO_HOST"; |
| 353 | case RTCIceTransportPolicyAll: |
| 354 | return @"ALL"; |
| 355 | } |
| 356 | } |
| 357 | |
| 358 | + (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy: |
| 359 | (RTCBundlePolicy)policy { |
| 360 | switch (policy) { |
| 361 | case RTCBundlePolicyBalanced: |
| 362 | return webrtc::PeerConnectionInterface::kBundlePolicyBalanced; |
| 363 | case RTCBundlePolicyMaxCompat: |
| 364 | return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat; |
| 365 | case RTCBundlePolicyMaxBundle: |
| 366 | return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle; |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | + (RTCBundlePolicy)bundlePolicyForNativePolicy: |
| 371 | (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy { |
| 372 | switch (nativePolicy) { |
| 373 | case webrtc::PeerConnectionInterface::kBundlePolicyBalanced: |
| 374 | return RTCBundlePolicyBalanced; |
| 375 | case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat: |
| 376 | return RTCBundlePolicyMaxCompat; |
| 377 | case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle: |
| 378 | return RTCBundlePolicyMaxBundle; |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | + (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy { |
| 383 | switch (policy) { |
| 384 | case RTCBundlePolicyBalanced: |
| 385 | return @"BALANCED"; |
| 386 | case RTCBundlePolicyMaxCompat: |
| 387 | return @"MAX_COMPAT"; |
| 388 | case RTCBundlePolicyMaxBundle: |
| 389 | return @"MAX_BUNDLE"; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy: |
| 394 | (RTCRtcpMuxPolicy)policy { |
| 395 | switch (policy) { |
| 396 | case RTCRtcpMuxPolicyNegotiate: |
| 397 | return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate; |
| 398 | case RTCRtcpMuxPolicyRequire: |
| 399 | return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire; |
| 400 | } |
| 401 | } |
| 402 | |
| 403 | + (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy: |
| 404 | (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy { |
| 405 | switch (nativePolicy) { |
| 406 | case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate: |
| 407 | return RTCRtcpMuxPolicyNegotiate; |
| 408 | case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire: |
| 409 | return RTCRtcpMuxPolicyRequire; |
| 410 | } |
| 411 | } |
| 412 | |
| 413 | + (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy { |
| 414 | switch (policy) { |
| 415 | case RTCRtcpMuxPolicyNegotiate: |
| 416 | return @"NEGOTIATE"; |
| 417 | case RTCRtcpMuxPolicyRequire: |
| 418 | return @"REQUIRE"; |
| 419 | } |
| 420 | } |
| 421 | |
| 422 | + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) |
| 423 | nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { |
| 424 | switch (policy) { |
| 425 | case RTCTcpCandidatePolicyEnabled: |
| 426 | return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; |
| 427 | case RTCTcpCandidatePolicyDisabled: |
| 428 | return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; |
| 429 | } |
| 430 | } |
| 431 | |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 432 | + (webrtc::PeerConnectionInterface::CandidateNetworkPolicy) |
| 433 | nativeCandidateNetworkPolicyForPolicy:(RTCCandidateNetworkPolicy)policy { |
| 434 | switch (policy) { |
| 435 | case RTCCandidateNetworkPolicyAll: |
| 436 | return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll; |
| 437 | case RTCCandidateNetworkPolicyLowCost: |
| 438 | return webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost; |
| 439 | } |
| 440 | } |
| 441 | |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 442 | + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: |
| 443 | (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { |
| 444 | switch (nativePolicy) { |
| 445 | case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: |
| 446 | return RTCTcpCandidatePolicyEnabled; |
| 447 | case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: |
| 448 | return RTCTcpCandidatePolicyDisabled; |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { |
| 453 | switch (policy) { |
| 454 | case RTCTcpCandidatePolicyEnabled: |
| 455 | return @"TCP_ENABLED"; |
| 456 | case RTCTcpCandidatePolicyDisabled: |
| 457 | return @"TCP_DISABLED"; |
| 458 | } |
| 459 | } |
| 460 | |
Honghai Zhang | 46007ae | 2016-06-03 16:31:32 -0700 | [diff] [blame] | 461 | + (RTCCandidateNetworkPolicy)candidateNetworkPolicyForNativePolicy: |
| 462 | (webrtc::PeerConnectionInterface::CandidateNetworkPolicy)nativePolicy { |
| 463 | switch (nativePolicy) { |
| 464 | case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyAll: |
| 465 | return RTCCandidateNetworkPolicyAll; |
| 466 | case webrtc::PeerConnectionInterface::kCandidateNetworkPolicyLowCost: |
| 467 | return RTCCandidateNetworkPolicyLowCost; |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | + (NSString *)stringForCandidateNetworkPolicy: |
| 472 | (RTCCandidateNetworkPolicy)policy { |
| 473 | switch (policy) { |
| 474 | case RTCCandidateNetworkPolicyAll: |
| 475 | return @"CANDIDATE_ALL_NETWORKS"; |
| 476 | case RTCCandidateNetworkPolicyLowCost: |
| 477 | return @"CANDIDATE_LOW_COST_NETWORKS"; |
| 478 | } |
| 479 | } |
| 480 | |
Honghai Zhang | 3108fc9 | 2016-05-11 10:10:39 -0700 | [diff] [blame] | 481 | + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) |
| 482 | nativeContinualGatheringPolicyForPolicy: |
| 483 | (RTCContinualGatheringPolicy)policy { |
| 484 | switch (policy) { |
| 485 | case RTCContinualGatheringPolicyGatherOnce: |
| 486 | return webrtc::PeerConnectionInterface::GATHER_ONCE; |
| 487 | case RTCContinualGatheringPolicyGatherContinually: |
| 488 | return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | + (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy: |
| 493 | (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy { |
| 494 | switch (nativePolicy) { |
| 495 | case webrtc::PeerConnectionInterface::GATHER_ONCE: |
| 496 | return RTCContinualGatheringPolicyGatherOnce; |
| 497 | case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY: |
| 498 | return RTCContinualGatheringPolicyGatherContinually; |
| 499 | } |
| 500 | } |
| 501 | |
| 502 | + (NSString *)stringForContinualGatheringPolicy: |
| 503 | (RTCContinualGatheringPolicy)policy { |
| 504 | switch (policy) { |
| 505 | case RTCContinualGatheringPolicyGatherOnce: |
| 506 | return @"GATHER_ONCE"; |
| 507 | case RTCContinualGatheringPolicyGatherContinually: |
| 508 | return @"GATHER_CONTINUALLY"; |
| 509 | } |
| 510 | } |
| 511 | |
hbos | f9da44d | 2016-06-09 03:18:28 -0700 | [diff] [blame] | 512 | + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: |
| 513 | (RTCEncryptionKeyType)keyType { |
| 514 | switch (keyType) { |
| 515 | case RTCEncryptionKeyTypeRSA: |
| 516 | return rtc::KT_RSA; |
| 517 | case RTCEncryptionKeyTypeECDSA: |
| 518 | return rtc::KT_ECDSA; |
| 519 | } |
| 520 | } |
| 521 | |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 522 | + (webrtc::SdpSemantics)nativeSdpSemanticsForSdpSemantics:(RTCSdpSemantics)sdpSemantics { |
| 523 | switch (sdpSemantics) { |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 524 | case RTCSdpSemanticsPlanB: |
Harald Alvestrand | fa67aef | 2021-12-08 14:30:55 +0000 | [diff] [blame] | 525 | return webrtc::SdpSemantics::kPlanB_DEPRECATED; |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 526 | case RTCSdpSemanticsUnifiedPlan: |
| 527 | return webrtc::SdpSemantics::kUnifiedPlan; |
| 528 | } |
| 529 | } |
| 530 | |
| 531 | + (RTCSdpSemantics)sdpSemanticsForNativeSdpSemantics:(webrtc::SdpSemantics)sdpSemantics { |
| 532 | switch (sdpSemantics) { |
Harald Alvestrand | fa67aef | 2021-12-08 14:30:55 +0000 | [diff] [blame] | 533 | case webrtc::SdpSemantics::kPlanB_DEPRECATED: |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 534 | return RTCSdpSemanticsPlanB; |
| 535 | case webrtc::SdpSemantics::kUnifiedPlan: |
| 536 | return RTCSdpSemanticsUnifiedPlan; |
| 537 | } |
| 538 | } |
| 539 | |
| 540 | + (NSString *)stringForSdpSemantics:(RTCSdpSemantics)sdpSemantics { |
| 541 | switch (sdpSemantics) { |
Steve Anton | 8cb344a | 2018-02-27 15:34:53 -0800 | [diff] [blame] | 542 | case RTCSdpSemanticsPlanB: |
| 543 | return @"PLAN_B"; |
| 544 | case RTCSdpSemanticsUnifiedPlan: |
| 545 | return @"UNIFIED_PLAN"; |
| 546 | } |
| 547 | } |
| 548 | |
hjon | 6d49a8e | 2016-01-26 13:06:42 -0800 | [diff] [blame] | 549 | @end |