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

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

Issue 1616303002: Update API for Objective-C RTCConfiguration. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Changes based on feedback 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
(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 #import "webrtc/api/objc/RTCConfiguration+Private.h"
14 #import "webrtc/api/objc/RTCIceServer+Private.h"
15
16 @implementation RTCConfiguration
17
18 @synthesize iceServers = _iceServers;
19 @synthesize iceTransportPolicy = _iceTransportPolicy;
20 @synthesize bundlePolicy = _bundlePolicy;
21 @synthesize rtcpMuxPolicy = _rtcpMuxPolicy;
22 @synthesize tcpCandidatePolicy = _tcpCandidatePolicy;
23 @synthesize audioJitterBufferMaxPackets = _audioJitterBufferMaxPackets;
24 @synthesize iceConnectionReceivingTimeout = _iceConnectionReceivingTimeout;
25 @synthesize iceBackupCandidatePairPingInterval =
26 _iceBackupCandidatePairPingInterval;
27
28 - (instancetype)init {
29 if (self = [super init]) {
30 _iceServers = [NSMutableArray array];
31 // Copy defaults.
32 webrtc::PeerConnectionInterface::RTCConfiguration config;
33 _iceTransportPolicy =
34 [[self class] transportPolicyForTransportsType:config.type];
35 _bundlePolicy =
36 [[self class] bundlePolicyForNativePolicy:config.bundle_policy];
37 _rtcpMuxPolicy =
38 [[self class] rtcpMuxPolicyForNativePolicy:config.rtcp_mux_policy];
39 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
40 config.tcp_candidate_policy];
41 _audioJitterBufferMaxPackets = config.audio_jitter_buffer_max_packets;
42 _iceConnectionReceivingTimeout = config.ice_connection_receiving_timeout;
43 _iceBackupCandidatePairPingInterval =
44 config.ice_backup_candidate_pair_ping_interval;
45 }
46 return self;
47 }
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 {
tkchin_webrtc 2016/01/22 22:29:14 indent 4 and align : with the line that was indent
hjon_webrtc 2016/01/22 22:37:40 Done.
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
72 - (NSString *)description {
73 return [NSString stringWithFormat:@"RTCConfiguration:\n%@\n%@\n%@\n%@\n%@\n"
74 "%d\n%d\n%d\n",
tkchin_webrtc 2016/01/22 22:29:14 I'm okay with an indent 4 here return [NSString..
hjon_webrtc 2016/01/22 22:37:40 Done.
75 _iceServers,
76 [[self class] stringForTransportPolicy:
77 _iceTransportPolicy],
78 [[self class] stringForBundlePolicy:
79 _bundlePolicy],
80 [[self class] stringForRtcpMuxPolicy:
81 _rtcpMuxPolicy],
82 [[self class] stringForTcpCandidatePolicy:
83 _tcpCandidatePolicy],
84 _audioJitterBufferMaxPackets,
85 _iceConnectionReceivingTimeout,
86 _iceBackupCandidatePairPingInterval];
87 }
88
89 #pragma mark - Private
90
91 - (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfiguration {
92 webrtc::PeerConnectionInterface::RTCConfiguration nativeConfig;
93
94 for (RTCIceServer *iceServer in _iceServers) {
95 nativeConfig.servers.push_back(iceServer.iceServer);
96 }
97 nativeConfig.type =
98 [[self class] nativeTransportsTypeForTransportPolicy:_iceTransportPolicy];
99 nativeConfig.bundle_policy =
100 [[self class] nativeBundlePolicyForPolicy:_bundlePolicy];
101 nativeConfig.rtcp_mux_policy =
102 [[self class] nativeRtcpMuxPolicyForPolicy:_rtcpMuxPolicy];
103 nativeConfig.tcp_candidate_policy =
104 [[self class] nativeTcpCandidatePolicyForPolicy:_tcpCandidatePolicy];
105 nativeConfig.audio_jitter_buffer_max_packets = _audioJitterBufferMaxPackets;
106 nativeConfig.ice_connection_receiving_timeout =
107 _iceConnectionReceivingTimeout;
108 nativeConfig.ice_backup_candidate_pair_ping_interval =
109 _iceBackupCandidatePairPingInterval;
110
111 return nativeConfig;
112 }
113
114 - (instancetype)initWithNativeConfiguration:
115 (webrtc::PeerConnectionInterface::RTCConfiguration)nativeConfig {
116 NSMutableArray *iceServers =
117 [NSMutableArray arrayWithCapacity:nativeConfig.servers.size()];
118 for (auto const &server : nativeConfig.servers) {
119 RTCIceServer *iceServer =
120 [[RTCIceServer alloc] initWithNativeServer:server];
121 [iceServers addObject:iceServer];
122 }
123
124 if (self = [self init]) {
125 if (iceServers) {
126 _iceServers = [iceServers copy];
127 }
128 _iceTransportPolicy =
129 [[self class] transportPolicyForTransportsType:nativeConfig.type];
130 _bundlePolicy =
131 [[self class] bundlePolicyForNativePolicy:nativeConfig.bundle_policy];
132 _rtcpMuxPolicy = [[self class] rtcpMuxPolicyForNativePolicy:
133 nativeConfig.rtcp_mux_policy];
134 _tcpCandidatePolicy = [[self class] tcpCandidatePolicyForNativePolicy:
135 nativeConfig.tcp_candidate_policy];
136 _audioJitterBufferMaxPackets = nativeConfig.audio_jitter_buffer_max_packets;
137 _iceConnectionReceivingTimeout =
138 nativeConfig.ice_connection_receiving_timeout;
139 _iceBackupCandidatePairPingInterval =
140 nativeConfig.ice_backup_candidate_pair_ping_interval;
141 }
142
143 return self;
144 }
145
146 + (webrtc::PeerConnectionInterface::IceTransportsType)
147 nativeTransportsTypeForTransportPolicy:(RTCIceTransportPolicy)policy {
148 switch (policy) {
149 case RTCIceTransportPolicyNone:
150 return webrtc::PeerConnectionInterface::kNone;
151 case RTCIceTransportPolicyRelay:
152 return webrtc::PeerConnectionInterface::kRelay;
153 case RTCIceTransportPolicyNoHost:
154 return webrtc::PeerConnectionInterface::kNoHost;
155 case RTCIceTransportPolicyAll:
156 return webrtc::PeerConnectionInterface::kAll;
157 }
158 }
159
160 + (RTCIceTransportPolicy)transportPolicyForTransportsType:
161 (webrtc::PeerConnectionInterface::IceTransportsType)nativeType {
162 switch (nativeType) {
163 case webrtc::PeerConnectionInterface::kNone:
164 return RTCIceTransportPolicyNone;
165 case webrtc::PeerConnectionInterface::kRelay:
166 return RTCIceTransportPolicyRelay;
167 case webrtc::PeerConnectionInterface::kNoHost:
168 return RTCIceTransportPolicyNoHost;
169 case webrtc::PeerConnectionInterface::kAll:
170 return RTCIceTransportPolicyAll;
171 }
172 }
173
174 + (NSString *)stringForTransportPolicy:(RTCIceTransportPolicy)policy {
175 switch (policy) {
176 case RTCIceTransportPolicyNone:
177 return @"NONE";
178 case RTCIceTransportPolicyRelay:
179 return @"RELAY";
180 case RTCIceTransportPolicyNoHost:
181 return @"NO_HOST";
182 case RTCIceTransportPolicyAll:
183 return @"ALL";
184 }
185 }
186
187 + (webrtc::PeerConnectionInterface::BundlePolicy)nativeBundlePolicyForPolicy:
188 (RTCBundlePolicy)policy {
189 switch (policy) {
190 case RTCBundlePolicyBalanced:
191 return webrtc::PeerConnectionInterface::kBundlePolicyBalanced;
192 case RTCBundlePolicyMaxCompat:
193 return webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat;
194 case RTCBundlePolicyMaxBundle:
195 return webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
196 }
197 }
198
199 + (RTCBundlePolicy)bundlePolicyForNativePolicy:
200 (webrtc::PeerConnectionInterface::BundlePolicy)nativePolicy {
201 switch (nativePolicy) {
202 case webrtc::PeerConnectionInterface::kBundlePolicyBalanced:
203 return RTCBundlePolicyBalanced;
204 case webrtc::PeerConnectionInterface::kBundlePolicyMaxCompat:
205 return RTCBundlePolicyMaxCompat;
206 case webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle:
207 return RTCBundlePolicyMaxBundle;
208 }
209 }
210
211 + (NSString *)stringForBundlePolicy:(RTCBundlePolicy)policy {
212 switch (policy) {
213 case RTCBundlePolicyBalanced:
214 return @"Balanced";
tkchin_webrtc 2016/01/22 22:29:14 ditto caps here and elsewhere
hjon_webrtc 2016/01/22 22:37:40 Done.
215 case RTCBundlePolicyMaxCompat:
216 return @"Max compat";
217 case RTCBundlePolicyMaxBundle:
218 return @"Max bundle";
219 }
220 }
221
222 + (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativeRtcpMuxPolicyForPolicy:
223 (RTCRtcpMuxPolicy)policy {
224 switch (policy) {
225 case RTCRtcpMuxPolicyNegotiate:
226 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate;
227 case RTCRtcpMuxPolicyRequire:
228 return webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire;
229 }
230 }
231
232 + (RTCRtcpMuxPolicy)rtcpMuxPolicyForNativePolicy:
233 (webrtc::PeerConnectionInterface::RtcpMuxPolicy)nativePolicy {
234 switch (nativePolicy) {
235 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyNegotiate:
236 return RTCRtcpMuxPolicyNegotiate;
237 case webrtc::PeerConnectionInterface::kRtcpMuxPolicyRequire:
238 return RTCRtcpMuxPolicyRequire;
239 }
240 }
241
242 + (NSString *)stringForRtcpMuxPolicy:(RTCRtcpMuxPolicy)policy {
243 switch (policy) {
244 case RTCRtcpMuxPolicyNegotiate:
245 return @"Negotiate";
246 case RTCRtcpMuxPolicyRequire:
247 return @"Require";
248 }
249 }
250
251 + (webrtc::PeerConnectionInterface::TcpCandidatePolicy)
252 nativeTcpCandidatePolicyForPolicy:(RTCTcpCandidatePolicy)policy {
253 switch (policy) {
254 case RTCTcpCandidatePolicyEnabled:
255 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled;
256 case RTCTcpCandidatePolicyDisabled:
257 return webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled;
258 }
259 }
260
261 + (RTCTcpCandidatePolicy)tcpCandidatePolicyForNativePolicy:
262 (webrtc::PeerConnectionInterface::TcpCandidatePolicy)nativePolicy {
263 switch (nativePolicy) {
264 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyEnabled:
265 return RTCTcpCandidatePolicyEnabled;
266 case webrtc::PeerConnectionInterface::kTcpCandidatePolicyDisabled:
267 return RTCTcpCandidatePolicyDisabled;
268 }
269 }
270
271 + (NSString *)stringForTcpCandidatePolicy:(RTCTcpCandidatePolicy)policy {
272 switch (policy) {
273 case RTCTcpCandidatePolicyEnabled:
274 return @"Enabled";
275 case RTCTcpCandidatePolicyDisabled:
276 return @"Disabled";
277 }
278 }
279
280 @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