Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: webrtc/api/objc/RTCConfiguration.mm

Issue 1649533002: Make ECDSA default for RTCPeerConnection (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Update comment Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/objc/RTCConfiguration.h ('k') | webrtc/api/objc/RTCConfiguration+Private.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h" 11 #import "RTCConfiguration.h"
12 12
13 #include "webrtc/base/sslidentity.h"
14
13 #import "webrtc/api/objc/RTCConfiguration+Private.h" 15 #import "webrtc/api/objc/RTCConfiguration+Private.h"
14 #import "webrtc/api/objc/RTCIceServer+Private.h" 16 #import "webrtc/api/objc/RTCIceServer+Private.h"
17 #import "webrtc/base/objc/RTCLogging.h"
15 18
16 @implementation RTCConfiguration 19 @implementation RTCConfiguration
17 20
18 @synthesize iceServers = _iceServers; 21 @synthesize iceServers = _iceServers;
19 @synthesize iceTransportPolicy = _iceTransportPolicy; 22 @synthesize iceTransportPolicy = _iceTransportPolicy;
20 @synthesize bundlePolicy = _bundlePolicy; 23 @synthesize bundlePolicy = _bundlePolicy;
21 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy; 24 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
22 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy; 25 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
23 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets; 26 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
24 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout; 27 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
25 @synthesize iceBackupCandidatePairPingInterval = 28 @synthesize iceBackupCandidatePairPingInterval =
26 _iceBackupCandidatePairPingInterval; 29 _iceBackupCandidatePairPingInterval;
30 @synthesize keyType = _keyType;
27 31
28 - (instancetype)init { 32 - (instancetype)init {
29 if (self = [super init]) { 33 if (self = [super init]) {
30 _iceServers = [NSMutableArray array]; 34 _iceServers = [NSMutableArray array];
31 // Copy defaults. 35 // Copy defaults.
32 webrtc::PeerConnectionInterface::RTCConfiguration config; 36 webrtc::PeerConnectionInterface::RTCConfiguration config;
33 _iceTransportPolicy = 37 _iceTransportPolicy =
34 [[self class] transportPolicyForTransportsType:config.type]; 38 [[self class] transportPolicyForTransportsType:config.type];
35 _bundlePolicy = 39 _bundlePolicy =
36 [[self class] bundlePolicyForNativePolicy:config.bundle_policy]; 40 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
37 _rtcpMuxPolicy = 41 _rtcpMuxPolicy =
38 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy]; 42 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
39 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy: 43 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
40 config.tcp_candidate_policy]; 44 config.tcp_candidate_policy];
41 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets; 45 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
42 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout; 46 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
43 _iceBackupCandidatePairPingInterval = 47 _iceBackupCandidatePairPingInterval =
44 config.ice_backup_candidate_pair_ping_interval; 48 config.ice_backup_candidate_pair_ping_interval;
49 _keyType = RTCEncryptionKeyTypeECDSA;
45 } 50 }
46 return self; 51 return self;
47 } 52 }
48
49 - (instancetype)initWithIceServers:(NSArray<RTCIceServer *> *)iceServers
50 iceTransportPolicy:(RTCIceTransportPolicy)iceTransportPolicy
51 bundlePolicy:(RTCBundlePolicy)bundlePolicy
52 rtcpMuxPolicy:(RTCRtcpMuxPolicy)rtcpMuxPolicy
53 tcpCandidatePolicy:(RTCTcpCandidatePolicy)tcpCandidatePolicy
54 audioJitterBufferMaxPackets:(int)audioJitterBufferMaxPackets
55 iceConnectionReceivingTimeout:(int)iceConnectionReceivingTimeout
56 iceBackupCandidatePairPingInterval:(int)iceBackupCandidatePairPingInterval {
57 if (self = [self init]) {
58 if (iceServers) {
59 _iceServers = [iceServers copy];
60 }
61 _iceTransportPolicy = iceTransportPolicy;
62 _bundlePolicy = bundlePolicy;
63 _rtcpMuxPolicy = rtcpMuxPolicy;
64 _tcpCandidatePolicy = tcpCandidatePolicy;
65 _audioJitterBufferMaxPackets = audioJitterBufferMaxPackets;
66 _iceConnectionReceivingTimeout = iceConnectionReceivingTimeout;
67 _iceBackupCandidatePairPingInterval = iceBackupCandidatePairPingInterval;
68 }
69 return self;
70 }
71 53
72 - (NSString *)description { 54 - (NSString *)description {
73 return [NSString stringWithFormat: 55 return [NSString stringWithFormat:
74 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n", 56 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n",
75 _iceServers, 57 _iceServers,
76 [[self class] stringForTransportPolicy:_iceTransportPolicy], 58 [[self class] stringForTransportPolicy:_iceTransportPolicy],
77 [[self class] stringForBundlePolicy:_bundlePolicy], 59 [[self class] stringForBundlePolicy:_bundlePolicy],
78 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy], 60 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
79 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy], 61 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
80 _audioJitterBufferMaxPackets, 62 _audioJitterBufferMaxPackets,
(...skipping 15 matching lines...) Expand all
96 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy]; 78 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
97 nativeConfig.rtcp_mux_policy = 79 nativeConfig.rtcp_mux_policy =
98 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy]; 80 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
99 nativeConfig.tcp_candidate_policy = 81 nativeConfig.tcp_candidate_policy =
100 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy]; 82 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
101 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets; 83 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
102 nativeConfig.ice_connection_receiving_timeout = 84 nativeConfig.ice_connection_receiving_timeout =
103 _iceConnectionReceivingTimeout; 85 _iceConnectionReceivingTimeout;
104 nativeConfig.ice_backup_candidate_pair_ping_interval = 86 nativeConfig.ice_backup_candidate_pair_ping_interval =
105 _iceBackupCandidatePairPingInterval; 87 _iceBackupCandidatePairPingInterval;
88 if (_keyType == RTCEncryptionKeyTypeECDSA) {
89 rtc::scoped_ptr<rtc::SSLIdentity> identity(
90 rtc::SSLIdentity::Generate(webrtc::kIdentityName, rtc::KT_ECDSA));
91 if (identity) {
92 nativeConfig.certificates.push_back(
93 rtc::RTCCertificate::Create(std::move(identity)));
94 } else {
95 RTCLogWarning(@"Failed to generate ECDSA identity. RSA will be used.");
96 }
97 }
106 98
107 return nativeConfig; 99 return nativeConfig;
108 } 100 }
109 101
110 - (instancetype)initWithNativeConfiguration:
111 (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfig {
112 NSMutableArray *iceServers =
113 [NSMutableArray arrayWithCapacity:nativeConfig.servers.size()];
114 for (auto const &server : nativeConfig.servers) {
115 RTCIceServer *iceServer =
116 [[RTCIceServer alloc] initWithNativeServer:server];
117 [iceServers addObject:iceServer];
118 }
119
120 if (self = [self init]) {
121 if (iceServers) {
122 _iceServers = [iceServers copy];
123 }
124 _iceTransportPolicy =
125 [[self class] transportPolicyForTransportsType:nativeConfig.type];
126 _bundlePolicy =
127 [[self class] bundlePolicyForNativePolicy:nativeConfig.bundle_policy];
128 _rtcpMuxPolicy = [[self class] rtcpMuxPolicyForNativePolicy:
129 nativeConfig.rtcp_mux_policy];
130 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
131 nativeConfig.tcp_candidate_policy];
132 _audioJitterBufferMaxPackets = nativeConfig.audio_jitter_buffer_max_packets;
133 _iceConnectionReceivingTimeout =
134 nativeConfig.ice_connection_receiving_timeout;
135 _iceBackupCandidatePairPingInterval =
136 nativeConfig.ice_backup_candidate_pair_ping_interval;
137 }
138
139 return self;
140 }
141
142 + (webrtc::PeerConnectionInterface::IceTransportsType) 102 + (webrtc::PeerConnectionInterface::IceTransportsType)
143 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy { 103 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
144 switch (policy) { 104 switch (policy) {
145 case RTCIceTransportPolicyNone: 105 case RTCIceTransportPolicyNone:
146 return webrtc::PeerConnectionInterface::kNone; 106 return webrtc::PeerConnectionInterface::kNone;
147 case RTCIceTransportPolicyRelay: 107 case RTCIceTransportPolicyRelay:
148 return webrtc::PeerConnectionInterface::kRelay; 108 return webrtc::PeerConnectionInterface::kRelay;
149 case RTCIceTransportPolicyNoHost: 109 case RTCIceTransportPolicyNoHost:
150 return webrtc::PeerConnectionInterface::kNoHost; 110 return webrtc::PeerConnectionInterface::kNoHost;
151 case RTCIceTransportPolicyAll: 111 case RTCIceTransportPolicyAll:
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy { 227 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
268 switch (policy) { 228 switch (policy) {
269 case RTCTcpCandidatePolicyEnabled: 229 case RTCTcpCandidatePolicyEnabled:
270 return @"TCP_ENABLED"; 230 return @"TCP_ENABLED";
271 case RTCTcpCandidatePolicyDisabled: 231 case RTCTcpCandidatePolicyDisabled:
272 return @"TCP_DISABLED"; 232 return @"TCP_DISABLED";
273 } 233 }
274 } 234 }
275 235
276 @end 236 @end
OLDNEW
« no previous file with comments | « webrtc/api/objc/RTCConfiguration.h ('k') | webrtc/api/objc/RTCConfiguration+Private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698