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

Side by Side Diff: webrtc/sdk/objc/Framework/Classes/RTCIceServer.mm

Issue 2664233002: Implement new PeerConnection certificate policy API in ObjC API (Closed)
Patch Set: Remove another default. Created 3 years, 10 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 | « no previous file | webrtc/sdk/objc/Framework/Headers/WebRTC/RTCIceServer.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 "RTCIceServer+Private.h" 11 #import "RTCIceServer+Private.h"
12 12
13 #import "NSString+StdString.h" 13 #import "NSString+StdString.h"
14 14
15 @implementation RTCIceServer 15 @implementation RTCIceServer
16 16
17 @synthesize urlStrings = _urlStrings; 17 @synthesize urlStrings = _urlStrings;
18 @synthesize username = _username; 18 @synthesize username = _username;
19 @synthesize credential = _credential; 19 @synthesize credential = _credential;
20 @synthesize tlsCertPolicy = _tlsCertPolicy;
20 21
21 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings { 22 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings {
22 NSParameterAssert(urlStrings.count);
23 return [self initWithURLStrings:urlStrings 23 return [self initWithURLStrings:urlStrings
24 username:nil 24 username:nil
25 credential:nil]; 25 credential:nil];
26 } 26 }
27 27
28 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings 28 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
29 username:(NSString *)username 29 username:(NSString *)username
30 credential:(NSString *)credential { 30 credential:(NSString *)credential {
31 return [self initWithURLStrings:urlStrings
32 username:username
33 credential:credential
34 tlsCertPolicy:RTCTlsCertPolicySecure];
35 }
36
37 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings
38 username:(NSString *)username
39 credential:(NSString *)credential
40 tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy {
31 NSParameterAssert(urlStrings.count); 41 NSParameterAssert(urlStrings.count);
32 if (self = [super init]) { 42 if (self = [super init]) {
33 _urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES]; 43 _urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES];
34 _username = [username copy]; 44 _username = [username copy];
35 _credential = [credential copy]; 45 _credential = [credential copy];
46 _tlsCertPolicy = tlsCertPolicy;
36 } 47 }
37 return self; 48 return self;
38 } 49 }
39 50
40 - (NSString *)description { 51 - (NSString *)description {
41 return [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@", 52 return
42 _urlStrings, 53 [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@\n%@", _urlStrings,
43 _username, 54 _username, _credential,
44 _credential]; 55 [self stringForTlsCertPolicy:_tlsCertPolicy]];
45 } 56 }
46 57
47 #pragma mark - Private 58 #pragma mark - Private
48 59
60 - (NSString *)stringForTlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy {
61 switch (tlsCertPolicy) {
62 case RTCTlsCertPolicySecure:
63 return @"RTCTlsCertPolicySecure";
64 case RTCTlsCertPolicyInsecureNoCheck:
65 return @"RTCTlsCertPolicyInsecureNoCheck";
66 }
67 }
68
49 - (webrtc::PeerConnectionInterface::IceServer)nativeServer { 69 - (webrtc::PeerConnectionInterface::IceServer)nativeServer {
50 __block webrtc::PeerConnectionInterface::IceServer iceServer; 70 __block webrtc::PeerConnectionInterface::IceServer iceServer;
51 71
52 iceServer.username = [NSString stdStringForString:_username]; 72 iceServer.username = [NSString stdStringForString:_username];
53 iceServer.password = [NSString stdStringForString:_credential]; 73 iceServer.password = [NSString stdStringForString:_credential];
54 74
55 [_urlStrings enumerateObjectsUsingBlock:^(NSString *url, 75 [_urlStrings enumerateObjectsUsingBlock:^(NSString *url,
56 NSUInteger idx, 76 NSUInteger idx,
57 BOOL *stop) { 77 BOOL *stop) {
58 iceServer.urls.push_back(url.stdString); 78 iceServer.urls.push_back(url.stdString);
59 }]; 79 }];
80
81 switch (_tlsCertPolicy) {
82 case RTCTlsCertPolicySecure:
83 iceServer.tls_cert_policy =
84 webrtc::PeerConnectionInterface::kTlsCertPolicySecure;
85 break;
86 case RTCTlsCertPolicyInsecureNoCheck:
87 iceServer.tls_cert_policy =
88 webrtc::PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck;
89 break;
90 }
60 return iceServer; 91 return iceServer;
61 } 92 }
62 93
63 - (instancetype)initWithNativeServer: 94 - (instancetype)initWithNativeServer:
64 (webrtc::PeerConnectionInterface::IceServer)nativeServer { 95 (webrtc::PeerConnectionInterface::IceServer)nativeServer {
65 NSMutableArray *urls = 96 NSMutableArray *urls =
66 [NSMutableArray arrayWithCapacity:nativeServer.urls.size()]; 97 [NSMutableArray arrayWithCapacity:nativeServer.urls.size()];
67 for (auto const &url : nativeServer.urls) { 98 for (auto const &url : nativeServer.urls) {
68 [urls addObject:[NSString stringForStdString:url]]; 99 [urls addObject:[NSString stringForStdString:url]];
69 } 100 }
70 NSString *username = [NSString stringForStdString:nativeServer.username]; 101 NSString *username = [NSString stringForStdString:nativeServer.username];
71 NSString *credential = [NSString stringForStdString:nativeServer.password]; 102 NSString *credential = [NSString stringForStdString:nativeServer.password];
103 RTCTlsCertPolicy tlsCertPolicy;
104
105 switch (nativeServer.tls_cert_policy) {
106 case webrtc::PeerConnectionInterface::kTlsCertPolicySecure:
107 tlsCertPolicy = RTCTlsCertPolicySecure;
108 break;
109 case webrtc::PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck:
110 tlsCertPolicy = RTCTlsCertPolicyInsecureNoCheck;
111 break;
112 }
113
72 self = [self initWithURLStrings:urls 114 self = [self initWithURLStrings:urls
73 username:username 115 username:username
74 credential:credential]; 116 credential:credential
117 tlsCertPolicy:tlsCertPolicy];
75 return self; 118 return self;
76 } 119 }
77 120
78 @end 121 @end
OLDNEW
« no previous file with comments | « no previous file | webrtc/sdk/objc/Framework/Headers/WebRTC/RTCIceServer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698