| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #import "RTCConfiguration+Private.h" | 11 #import "RTCConfiguration+Private.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 #import "RTCIceServer+Private.h" | 15 #import "RTCIceServer+Private.h" |
| 16 #import "WebRTC/RTCLogging.h" | 16 #import "WebRTC/RTCLogging.h" |
| 17 | 17 |
| 18 #include "webrtc/base/sslidentity.h" | 18 #include "webrtc/base/sslidentity.h" |
| 19 | 19 |
| 20 @implementation RTCConfiguration | 20 @implementation RTCConfiguration |
| 21 | 21 |
| 22 @synthesize iceServers = _iceServers; | 22 @synthesize iceServers = _iceServers; |
| 23 @synthesize iceTransportPolicy = _iceTransportPolicy; | 23 @synthesize iceTransportPolicy = _iceTransportPolicy; |
| 24 @synthesize bundlePolicy = _bundlePolicy; | 24 @synthesize bundlePolicy = _bundlePolicy; |
| 25 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; | 25 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
| 26 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; | 26 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
| 27 @synthesize continualGatheringPolicy = _continualGatheringPolicy; |
| 27 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; | 28 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; |
| 28 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; | 29 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; |
| 29 @synthesize iceBackupCandidatePairPingInterval = | 30 @synthesize iceBackupCandidatePairPingInterval = |
| 30 _iceBackupCandidatePairPingInterval; | 31 _iceBackupCandidatePairPingInterval; |
| 31 @synthesize keyType = _keyType; | 32 @synthesize keyType = _keyType; |
| 32 | 33 |
| 33 - (instancetype)init { | 34 - (instancetype)init { |
| 34 if (self = [super init]) { | 35 if (self = [super init]) { |
| 35 _iceServers = [NSMutableArray array]; | 36 _iceServers = [NSMutableArray array]; |
| 36 // Copy defaults. | 37 // Copy defaults. |
| 37 webrtc::PeerConnectionInterface::RTCConfiguration config; | 38 webrtc::PeerConnectionInterface::RTCConfiguration config; |
| 38 _iceTransportPolicy = | 39 _iceTransportPolicy = |
| 39 [[self class] transportPolicyForTransportsType:config.type]; | 40 [[self class] transportPolicyForTransportsType:config.type]; |
| 40 _bundlePolicy = | 41 _bundlePolicy = |
| 41 [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; | 42 [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; |
| 42 _rtcpMuxPolicy = | 43 _rtcpMuxPolicy = |
| 43 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; | 44 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; |
| 44 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: | 45 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: |
| 45 config.tcp_candidate_policy]; | 46 config.tcp_candidate_policy]; |
| 47 webrtc::PeerConnectionInterface::ContinualGatheringPolicy nativePolicy = |
| 48 config.continual_gathering_policy; |
| 49 _continualGatheringPolicy = |
| 50 [[self class] continualGatheringPolicyForNativePolicy:nativePolicy]; |
| 46 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; | 51 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; |
| 47 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; | 52 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; |
| 48 _iceBackupCandidatePairPingInterval = | 53 _iceBackupCandidatePairPingInterval = |
| 49 config.ice_backup_candidate_pair_ping_interval; | 54 config.ice_backup_candidate_pair_ping_interval; |
| 50 _keyType = RTCEncryptionKeyTypeECDSA; | 55 _keyType = RTCEncryptionKeyTypeECDSA; |
| 51 } | 56 } |
| 52 return self; | 57 return self; |
| 53 } | 58 } |
| 54 | 59 |
| 55 - (NSString *)description { | 60 - (NSString *)description { |
| 56 return [NSString stringWithFormat: | 61 return [NSString stringWithFormat: |
| 57 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", | 62 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", |
| 58 _iceServers, | 63 _iceServers, |
| 59 [[self class] stringForTransportPolicy:_iceTransportPolicy], | 64 [[self class] stringForTransportPolicy:_iceTransportPolicy], |
| 60 [[self class] stringForBundlePolicy:_bundlePolicy], | 65 [[self class] stringForBundlePolicy:_bundlePolicy], |
| 61 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], | 66 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], |
| 62 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], | 67 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
| 68 [[self class] |
| 69 stringForContinualGatheringPolicy:_continualGatheringPolicy], |
| 63 _audioJitterBufferMaxPackets, | 70 _audioJitterBufferMaxPackets, |
| 64 _iceConnectionReceivingTimeout, | 71 _iceConnectionReceivingTimeout, |
| 65 _iceBackupCandidatePairPingInterval]; | 72 _iceBackupCandidatePairPingInterval]; |
| 66 } | 73 } |
| 67 | 74 |
| 68 #pragma mark - Private | 75 #pragma mark - Private |
| 69 | 76 |
| 70 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { | 77 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { |
| 71 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; | 78 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; |
| 72 | 79 |
| 73 for (RTCIceServer *iceServer in _iceServers) { | 80 for (RTCIceServer *iceServer in _iceServers) { |
| 74 nativeConfig.servers.push_back(iceServer.nativeServer); | 81 nativeConfig.servers.push_back(iceServer.nativeServer); |
| 75 } | 82 } |
| 76 nativeConfig.type = | 83 nativeConfig.type = |
| 77 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; | 84 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; |
| 78 nativeConfig.bundle_policy = | 85 nativeConfig.bundle_policy = |
| 79 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; | 86 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; |
| 80 nativeConfig.rtcp_mux_policy = | 87 nativeConfig.rtcp_mux_policy = |
| 81 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; | 88 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; |
| 82 nativeConfig.tcp_candidate_policy = | 89 nativeConfig.tcp_candidate_policy = |
| 83 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; | 90 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; |
| 91 nativeConfig.continual_gathering_policy = [[self class] |
| 92 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; |
| 84 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; | 93 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
| 85 nativeConfig.ice_connection_receiving_timeout = | 94 nativeConfig.ice_connection_receiving_timeout = |
| 86 _iceConnectionReceivingTimeout; | 95 _iceConnectionReceivingTimeout; |
| 87 nativeConfig.ice_backup_candidate_pair_ping_interval = | 96 nativeConfig.ice_backup_candidate_pair_ping_interval = |
| 88 _iceBackupCandidatePairPingInterval; | 97 _iceBackupCandidatePairPingInterval; |
| 89 if (_keyType == RTCEncryptionKeyTypeECDSA) { | 98 if (_keyType == RTCEncryptionKeyTypeECDSA) { |
| 90 std::unique_ptr<rtc::SSLIdentity> identity( | 99 std::unique_ptr<rtc::SSLIdentity> identity( |
| 91 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); | 100 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); |
| 92 if (identity) { | 101 if (identity) { |
| 93 nativeConfig.certificates.push_back( | 102 nativeConfig.certificates.push_back( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 | 236 |
| 228 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { | 237 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { |
| 229 switch (policy) { | 238 switch (policy) { |
| 230 case RTCTcpCandidatePolicyEnabled: | 239 case RTCTcpCandidatePolicyEnabled: |
| 231 return @"TCP_ENABLED"; | 240 return @"TCP_ENABLED"; |
| 232 case RTCTcpCandidatePolicyDisabled: | 241 case RTCTcpCandidatePolicyDisabled: |
| 233 return @"TCP_DISABLED"; | 242 return @"TCP_DISABLED"; |
| 234 } | 243 } |
| 235 } | 244 } |
| 236 | 245 |
| 246 + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) |
| 247 nativeContinualGatheringPolicyForPolicy: |
| 248 (RTCContinualGatheringPolicy)policy { |
| 249 switch (policy) { |
| 250 case RTCGatherOnce: |
| 251 return webrtc::PeerConnectionInterface::GATHER_ONCE; |
| 252 case RTCGatherContinually: |
| 253 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; |
| 254 } |
| 255 } |
| 256 |
| 257 + (RTCContinualGatheringPolicy)continualGatheringPolicyForNativePolicy: |
| 258 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy { |
| 259 switch (nativePolicy) { |
| 260 case webrtc::PeerConnectionInterface::GATHER_ONCE: |
| 261 return RTCGatherOnce; |
| 262 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY: |
| 263 return RTCGatherContinually; |
| 264 } |
| 265 } |
| 266 |
| 267 + (NSString *)stringForContinualGatheringPolicy: |
| 268 (RTCContinualGatheringPolicy)policy { |
| 269 switch (policy) { |
| 270 case RTCGatherOnce: |
| 271 return @"GATHER_ONCE"; |
| 272 case RTCGatherContinually: |
| 273 return @"GATHER_CONTINUALLY"; |
| 274 } |
| 275 } |
| 276 |
| 237 @end | 277 @end |
| OLD | NEW |