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

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

Issue 1903663002: Build dynamic iOS SDK. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 8 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
OLDNEW
(Empty)
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
11 #import "RTCConfiguration.h"
12
13 #include "webrtc/base/sslidentity.h"
14
15 #import "webrtc/api/objc/RTCConfiguration+Private.h"
16 #import "webrtc/api/objc/RTCIceServer+Private.h"
17 #import "webrtc/base/objc/RTCLogging.h"
18
19 @implementation RTCConfiguration
20
21 @synthesize iceServers = _iceServers;
22 @synthesize iceTransportPolicy = _iceTransportPolicy;
23 @synthesize bundlePolicy = _bundlePolicy;
24 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
25 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
26 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
27 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
28 @synthesize iceBackupCandidatePairPingInterval =
29 _iceBackupCandidatePairPingInterval;
30 @synthesize keyType = _keyType;
31
32 - (instancetype)init {
33 if (self = [super init]) {
34 _iceServers = [NSMutableArray array];
35 // Copy defaults.
36 webrtc::PeerConnectionInterface::RTCConfiguration config;
37 _iceTransportPolicy =
38 [[self class] transportPolicyForTransportsType:config.type];
39 _bundlePolicy =
40 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
41 _rtcpMuxPolicy =
42 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
43 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
44 config.tcp_candidate_policy];
45 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
46 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
47 _iceBackupCandidatePairPingInterval =
48 config.ice_backup_candidate_pair_ping_interval;
49 _keyType = RTCEncryptionKeyTypeECDSA;
50 }
51 return self;
52 }
53
54 - (NSString *)description {
55 return [NSString stringWithFormat:
56 @"RTCConfiguration: {\n%@\n%@\n%@\n%@\n%@\n%d\n%d\n%d\n}\n",
57 _iceServers,
58 [[self class] stringForTransportPolicy:_iceTransportPolicy],
59 [[self class] stringForBundlePolicy:_bundlePolicy],
60 [[self class] stringForRtcpMuxPolicy:_rtcpMuxPolicy],
61 [[self class] stringForTcpCandidatePolicy:_tcpCandidatePolicy],
62 _audioJitterBufferMaxPackets,
63 _iceConnectionReceivingTimeout,
64 _iceBackupCandidatePairPingInterval];
65 }
66
67 #pragma mark - Private
68
69 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration {
70 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig;
71
72 for (RTCIceServer *iceServer in _iceServers) {
73 nativeConfig.servers.push_back(iceServer.nativeServer);
74 }
75 nativeConfig.type =
76 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
77 nativeConfig.bundle_policy =
78 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
79 nativeConfig.rtcp_mux_policy =
80 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
81 nativeConfig.tcp_candidate_policy =
82 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
83 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
84 nativeConfig.ice_connection_receiving_timeout =
85 _iceConnectionReceivingTimeout;
86 nativeConfig.ice_backup_candidate_pair_ping_interval =
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 }
98
99 return nativeConfig;
100 }
101
102 + (webrtc::PeerConnectionInterface::IceTransportsType)
103 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
104 switch (policy) {
105 case RTCIceTransportPolicyNone:
106 return webrtc::PeerConnectionInterface::kNone;
107 case RTCIceTransportPolicyRelay:
108 return webrtc::PeerConnectionInterface::kRelay;
109 case RTCIceTransportPolicyNoHost:
110 return webrtc::PeerConnectionInterface::kNoHost;
111 case RTCIceTransportPolicyAll:
112 return webrtc::PeerConnectionInterface::kAll;
113 }
114 }
115
116 + (RTCIceTransportPolicy)transportPolicyForTransportsType:
117 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
118 switch (nativeType) {
119 case webrtc::PeerConnectionInterface::kNone:
120 return RTCIceTransportPolicyNone;
121 case webrtc::PeerConnectionInterface::kRelay:
122 return RTCIceTransportPolicyRelay;
123 case webrtc::PeerConnectionInterface::kNoHost:
124 return RTCIceTransportPolicyNoHost;
125 case webrtc::PeerConnectionInterface::kAll:
126 return RTCIceTransportPolicyAll;
127 }
128 }
129
130 + (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
131 switch (policy) {
132 case RTCIceTransportPolicyNone:
133 return @"NONE";
134 case RTCIceTransportPolicyRelay:
135 return @"RELAY";
136 case RTCIceTransportPolicyNoHost:
137 return @"NO_HOST";
138 case RTCIceTransportPolicyAll:
139 return @"ALL";
140 }
141 }
142
143 + (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
144 (RTCBundlePolicy)policy {
145 switch (policy) {
146 case RTCBundlePolicyBalanced:
147 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
148 case RTCBundlePolicyMaxCompat:
149 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
150 case RTCBundlePolicyMaxBundle:
151 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
152 }
153 }
154
155 + (RTCBundlePolicy)bundlePolicyForNativePolicy:
156 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
157 switch (nativePolicy) {
158 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
159 return RTCBundlePolicyBalanced;
160 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
161 return RTCBundlePolicyMaxCompat;
162 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
163 return RTCBundlePolicyMaxBundle;
164 }
165 }
166
167 + (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
168 switch (policy) {
169 case RTCBundlePolicyBalanced:
170 return @"BALANCED";
171 case RTCBundlePolicyMaxCompat:
172 return @"MAX_COMPAT";
173 case RTCBundlePolicyMaxBundle:
174 return @"MAX_BUNDLE";
175 }
176 }
177
178 + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
179 (RTCRtcpMuxPolicy)policy {
180 switch (policy) {
181 case RTCRtcpMuxPolicyNegotiate:
182 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
183 case RTCRtcpMuxPolicyRequire:
184 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
185 }
186 }
187
188 + (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
189 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
190 switch (nativePolicy) {
191 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
192 return RTCRtcpMuxPolicyNegotiate;
193 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
194 return RTCRtcpMuxPolicyRequire;
195 }
196 }
197
198 + (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
199 switch (policy) {
200 case RTCRtcpMuxPolicyNegotiate:
201 return @"NEGOTIATE";
202 case RTCRtcpMuxPolicyRequire:
203 return @"REQUIRE";
204 }
205 }
206
207 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
208 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
209 switch (policy) {
210 case RTCTcpCandidatePolicyEnabled:
211 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
212 case RTCTcpCandidatePolicyDisabled:
213 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
214 }
215 }
216
217 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
218 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
219 switch (nativePolicy) {
220 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
221 return RTCTcpCandidatePolicyEnabled;
222 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
223 return RTCTcpCandidatePolicyDisabled;
224 }
225 }
226
227 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
228 switch (policy) {
229 case RTCTcpCandidatePolicyEnabled:
230 return @"TCP_ENABLED";
231 case RTCTcpCandidatePolicyDisabled:
232 return @"TCP_DISABLED";
233 }
234 }
235
236 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698