Chromium Code Reviews| 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 _continualGatheringPolicy = | |
|
tkchin_webrtc
2016/05/10 23:00:35
nit: if it doesn't fit, put it in to a local var f
honghaiz3
2016/05/10 23:26:08
Done.
| |
| 48 [[self class] continualGatheringPolicyForNativePolicy: | |
| 49 config.continual_gathering_policy]; | |
| 46 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; | 50 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; |
| 47 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; | 51 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; |
| 48 _iceBackupCandidatePairPingInterval = | 52 _iceBackupCandidatePairPingInterval = |
| 49 config.ice_backup_candidate_pair_ping_interval; | 53 config.ice_backup_candidate_pair_ping_interval; |
| 50 _keyType = RTCEncryptionKeyTypeECDSA; | 54 _keyType = RTCEncryptionKeyTypeECDSA; |
| 51 } | 55 } |
| 52 return self; | 56 return self; |
| 53 } | 57 } |
| 54 | 58 |
| 55 - (NSString *)description { | 59 - (NSString *)description { |
| 56 return [NSString stringWithFormat: | 60 return [NSString stringWithFormat: |
| 57 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", | 61 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", |
| 58 _iceServers, | 62 _iceServers, |
| 59 [[self class] stringForTransportPolicy:_iceTransportPolicy], | 63 [[self class] stringForTransportPolicy:_iceTransportPolicy], |
| 60 [[self class] stringForBundlePolicy:_bundlePolicy], | 64 [[self class] stringForBundlePolicy:_bundlePolicy], |
| 61 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], | 65 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], |
| 62 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], | 66 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
| 67 [[self class] | |
| 68 stringForContinualGatheringPolicy:_continualGatheringPolicy], | |
| 63 _audioJitterBufferMaxPackets, | 69 _audioJitterBufferMaxPackets, |
| 64 _iceConnectionReceivingTimeout, | 70 _iceConnectionReceivingTimeout, |
| 65 _iceBackupCandidatePairPingInterval]; | 71 _iceBackupCandidatePairPingInterval]; |
| 66 } | 72 } |
| 67 | 73 |
| 68 #pragma mark - Private | 74 #pragma mark - Private |
| 69 | 75 |
| 70 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { | 76 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { |
| 71 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; | 77 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; |
| 72 | 78 |
| 73 for (RTCIceServer *iceServer in _iceServers) { | 79 for (RTCIceServer *iceServer in _iceServers) { |
| 74 nativeConfig.servers.push_back(iceServer.nativeServer); | 80 nativeConfig.servers.push_back(iceServer.nativeServer); |
| 75 } | 81 } |
| 76 nativeConfig.type = | 82 nativeConfig.type = |
| 77 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; | 83 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; |
| 78 nativeConfig.bundle_policy = | 84 nativeConfig.bundle_policy = |
| 79 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; | 85 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; |
| 80 nativeConfig.rtcp_mux_policy = | 86 nativeConfig.rtcp_mux_policy = |
| 81 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; | 87 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; |
| 82 nativeConfig.tcp_candidate_policy = | 88 nativeConfig.tcp_candidate_policy = |
| 83 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; | 89 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; |
| 90 nativeConfig.continual_gathering_policy = [[self class] | |
| 91 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; | |
| 84 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; | 92 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
| 85 nativeConfig.ice_connection_receiving_timeout = | 93 nativeConfig.ice_connection_receiving_timeout = |
| 86 _iceConnectionReceivingTimeout; | 94 _iceConnectionReceivingTimeout; |
| 87 nativeConfig.ice_backup_candidate_pair_ping_interval = | 95 nativeConfig.ice_backup_candidate_pair_ping_interval = |
| 88 _iceBackupCandidatePairPingInterval; | 96 _iceBackupCandidatePairPingInterval; |
| 89 if (_keyType == RTCEncryptionKeyTypeECDSA) { | 97 if (_keyType == RTCEncryptionKeyTypeECDSA) { |
| 90 std::unique_ptr<rtc::SSLIdentity> identity( | 98 std::unique_ptr<rtc::SSLIdentity> identity( |
| 91 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); | 99 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); |
| 92 if (identity) { | 100 if (identity) { |
| 93 nativeConfig.certificates.push_back( | 101 nativeConfig.certificates.push_back( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 235 |
| 228 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { | 236 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { |
| 229 switch (policy) { | 237 switch (policy) { |
| 230 case RTCTcpCandidatePolicyEnabled: | 238 case RTCTcpCandidatePolicyEnabled: |
| 231 return @"TCP_ENABLED"; | 239 return @"TCP_ENABLED"; |
| 232 case RTCTcpCandidatePolicyDisabled: | 240 case RTCTcpCandidatePolicyDisabled: |
| 233 return @"TCP_DISABLED"; | 241 return @"TCP_DISABLED"; |
| 234 } | 242 } |
| 235 } | 243 } |
| 236 | 244 |
| 245 + (webrtc::PeerConnectionInterface::ContinualGatheringPolicy) | |
| 246 nativeContinualGatheringPolicyForPolicy: | |
| 247 (RTCContinualGatheringPolicy)policy { | |
| 248 switch (policy) { | |
| 249 case RTCGatherOnce: | |
| 250 return webrtc::PeerConnectionInterface::GATHER_ONCE; | |
| 251 case RTCGatherContinually: | |
| 252 return webrtc::PeerConnectionInterface::GATHER_CONTINUALLY; | |
| 253 } | |
| 254 } | |
| 255 | |
| 256 + (RTCContinualGatheringPolicy) continualGatheringPolicyForNativePolicy: | |
|
tkchin_webrtc
2016/05/10 23:00:35
nit: remove space
honghaiz3
2016/05/10 23:26:08
Done.
| |
| 257 (webrtc::PeerConnectionInterface::ContinualGatheringPolicy)nativePolicy { | |
| 258 switch (nativePolicy) { | |
| 259 case webrtc::PeerConnectionInterface::GATHER_ONCE: | |
| 260 return RTCGatherOnce; | |
| 261 case webrtc::PeerConnectionInterface::GATHER_CONTINUALLY: | |
| 262 return RTCGatherContinually; | |
| 263 } | |
| 264 } | |
| 265 | |
| 266 + (NSString *) stringForContinualGatheringPolicy: | |
|
tkchin_webrtc
2016/05/10 23:00:34
nit: remove space
honghaiz3
2016/05/10 23:26:08
Done.
| |
| 267 (RTCContinualGatheringPolicy)policy { | |
| 268 switch (policy) { | |
| 269 case RTCGatherOnce: | |
| 270 return @"GATHER_ONCE"; | |
| 271 case RTCGatherContinually: | |
| 272 return @"GATHER_CONTINUALLY"; | |
| 273 } | |
| 274 } | |
| 275 | |
| 237 @end | 276 @end |
| OLD | NEW |