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/rtccertificategenerator.h" | |
18 #include "webrtc/base/sslidentity.h" | 19 #include "webrtc/base/sslidentity.h" |
19 | 20 |
20 @implementation RTCConfiguration | 21 @implementation RTCConfiguration |
21 | 22 |
22 @synthesize iceServers = _iceServers; | 23 @synthesize iceServers = _iceServers; |
23 @synthesize iceTransportPolicy = _iceTransportPolicy; | 24 @synthesize iceTransportPolicy = _iceTransportPolicy; |
24 @synthesize bundlePolicy = _bundlePolicy; | 25 @synthesize bundlePolicy = _bundlePolicy; |
25 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; | 26 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; |
26 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; | 27 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; |
27 @synthesize continualGatheringPolicy = _continualGatheringPolicy; | 28 @synthesize continualGatheringPolicy = _continualGatheringPolicy; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
67 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], | 68 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], |
68 [[self class] | 69 [[self class] |
69 stringForContinualGatheringPolicy:_continualGatheringPolicy], | 70 stringForContinualGatheringPolicy:_continualGatheringPolicy], |
70 _audioJitterBufferMaxPackets, | 71 _audioJitterBufferMaxPackets, |
71 _iceConnectionReceivingTimeout, | 72 _iceConnectionReceivingTimeout, |
72 _iceBackupCandidatePairPingInterval]; | 73 _iceBackupCandidatePairPingInterval]; |
73 } | 74 } |
74 | 75 |
75 #pragma mark - Private | 76 #pragma mark - Private |
76 | 77 |
77 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration { | 78 - (webrtc::PeerConnectionInterface::RTCConfiguration*)nativeConfiguration { |
tkchin_webrtc
2016/05/13 17:48:05
RTCConfiguration *)
hbos
2016/05/16 12:49:05
Done.
| |
78 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig; | 79 std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> |
tkchin_webrtc
2016/05/13 17:48:05
Are we returning a pointer to avoid memory copy? O
tkchin_webrtc
2016/05/13 18:07:38
and by factory I meant peerconnection's private in
hbos
2016/05/16 12:49:05
To say that we failed to generate the configuratio
| |
80 nativeConfig(new webrtc::PeerConnectionInterface::RTCConfiguration()); | |
79 | 81 |
80 for (RTCIceServer *iceServer in _iceServers) { | 82 for (RTCIceServer *iceServer in _iceServers) { |
81 nativeConfig.servers.push_back(iceServer.nativeServer); | 83 nativeConfig->servers.push_back(iceServer.nativeServer); |
82 } | 84 } |
83 nativeConfig.type = | 85 nativeConfig->type = |
84 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; | 86 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy]; |
85 nativeConfig.bundle_policy = | 87 nativeConfig->bundle_policy = |
86 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; | 88 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; |
87 nativeConfig.rtcp_mux_policy = | 89 nativeConfig->rtcp_mux_policy = |
88 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; | 90 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; |
89 nativeConfig.tcp_candidate_policy = | 91 nativeConfig->tcp_candidate_policy = |
90 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; | 92 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; |
91 nativeConfig.continual_gathering_policy = [[self class] | 93 nativeConfig->continual_gathering_policy = [[self class] |
92 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; | 94 nativeContinualGatheringPolicyForPolicy:_continualGatheringPolicy]; |
93 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; | 95 nativeConfig->audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; |
94 nativeConfig.ice_connection_receiving_timeout = | 96 nativeConfig->ice_connection_receiving_timeout = |
95 _iceConnectionReceivingTimeout; | 97 _iceConnectionReceivingTimeout; |
96 nativeConfig.ice_backup_candidate_pair_ping_interval = | 98 nativeConfig->ice_backup_candidate_pair_ping_interval = |
97 _iceBackupCandidatePairPingInterval; | 99 _iceBackupCandidatePairPingInterval; |
98 if (_keyType == RTCEncryptionKeyTypeECDSA) { | 100 rtc::KeyType keyType = |
99 std::unique_ptr<rtc::SSLIdentity> identity( | 101 [[self class] nativeEncryptionKeyTypeForKeyType:_keyType]; |
100 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA)); | 102 // Generate non-default certificate. |
101 if (identity) { | 103 if (keyType != rtc::KT_DEFAULT) { |
102 nativeConfig.certificates.push_back( | 104 rtc::scoped_refptr<rtc::RTCCertificate> certificate = |
103 rtc::RTCCertificate::Create(std::move(identity))); | 105 rtc::RTCCertificateGenerator::GenerateCertificate( |
104 } else { | 106 rtc::KeyParams(keyType), rtc::Optional<uint64_t>()); |
105 RTCLogWarning(@"Failed to generate ECDSA identity. RSA will be used."); | 107 if (!certificate) { |
108 RTCLogWarning(@"Failed to generate certificate."); | |
tkchin_webrtc
2016/05/13 17:48:05
this is an error because you will fail to create t
tkchin_webrtc
2016/05/13 18:07:38
I meant peerconnection via [factory peerconnection
hbos
2016/05/16 12:49:05
RTCLogError - Done.
| |
109 return nullptr; | |
106 } | 110 } |
111 nativeConfig->certificates.push_back(certificate); | |
107 } | 112 } |
108 | 113 |
109 return nativeConfig; | 114 return nativeConfig.release(); |
110 } | 115 } |
111 | 116 |
112 + (webrtc::PeerConnectionInterface::IceTransportsType) | 117 + (webrtc::PeerConnectionInterface::IceTransportsType) |
113 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { | 118 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { |
114 switch (policy) { | 119 switch (policy) { |
115 case RTCIceTransportPolicyNone: | 120 case RTCIceTransportPolicyNone: |
116 return webrtc::PeerConnectionInterface::kNone; | 121 return webrtc::PeerConnectionInterface::kNone; |
117 case RTCIceTransportPolicyRelay: | 122 case RTCIceTransportPolicyRelay: |
118 return webrtc::PeerConnectionInterface::kRelay; | 123 return webrtc::PeerConnectionInterface::kRelay; |
119 case RTCIceTransportPolicyNoHost: | 124 case RTCIceTransportPolicyNoHost: |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) | 222 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy) |
218 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { | 223 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy { |
219 switch (policy) { | 224 switch (policy) { |
220 case RTCTcpCandidatePolicyEnabled: | 225 case RTCTcpCandidatePolicyEnabled: |
221 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; | 226 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled; |
222 case RTCTcpCandidatePolicyDisabled: | 227 case RTCTcpCandidatePolicyDisabled: |
223 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; | 228 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled; |
224 } | 229 } |
225 } | 230 } |
226 | 231 |
232 + (rtc::KeyType)nativeEncryptionKeyTypeForKeyType: | |
233 (RTCEncryptionKeyType)keyType { | |
234 switch (keyType) { | |
235 case RTCEncryptionKeyTypeRSA: | |
236 return rtc::KT_RSA; | |
237 case RTCEncryptionKeyTypeECDSA: | |
238 return rtc::KT_ECDSA; | |
239 } | |
240 } | |
241 | |
227 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: | 242 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy: |
228 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { | 243 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy { |
229 switch (nativePolicy) { | 244 switch (nativePolicy) { |
230 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: | 245 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled: |
231 return RTCTcpCandidatePolicyEnabled; | 246 return RTCTcpCandidatePolicyEnabled; |
232 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: | 247 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled: |
233 return RTCTcpCandidatePolicyDisabled; | 248 return RTCTcpCandidatePolicyDisabled; |
234 } | 249 } |
235 } | 250 } |
236 | 251 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
268 (RTCContinualGatheringPolicy)policy { | 283 (RTCContinualGatheringPolicy)policy { |
269 switch (policy) { | 284 switch (policy) { |
270 case RTCContinualGatheringPolicyGatherOnce: | 285 case RTCContinualGatheringPolicyGatherOnce: |
271 return @"GATHER_ONCE"; | 286 return @"GATHER_ONCE"; |
272 case RTCContinualGatheringPolicyGatherContinually: | 287 case RTCContinualGatheringPolicyGatherContinually: |
273 return @"GATHER_CONTINUALLY"; | 288 return @"GATHER_CONTINUALLY"; |
274 } | 289 } |
275 } | 290 } |
276 | 291 |
277 @end | 292 @end |
OLD | NEW |