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 "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 NSParameterAssert(urlStrings.count); |
23 return [self initWithURLStrings:urlStrings | 24 return [self initWithURLStrings:urlStrings |
24 username:nil | 25 username:nil |
25 credential:nil]; | 26 credential:nil]; |
26 } | 27 } |
27 | 28 |
28 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings | 29 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings |
29 username:(NSString *)username | 30 username:(NSString *)username |
30 credential:(NSString *)credential { | 31 credential:(NSString *)credential { |
31 NSParameterAssert(urlStrings.count); | 32 NSParameterAssert(urlStrings.count); |
33 return [self initWithURLStrings:urlStrings | |
34 username:username | |
35 credential:credential | |
36 tlsCertPolicy:RTCTlsCertPolicySecure]; | |
37 } | |
38 | |
39 - (instancetype)initWithURLStrings:(NSArray<NSString*>*)urlStrings | |
40 username:(NSString*)username | |
41 credential:(NSString*)credential | |
42 tlsCertPolicy:(RTCTlsCertPolicy)tlsCertPolicy { | |
43 NSParameterAssert(urlStrings.count); | |
32 if (self = [super init]) { | 44 if (self = [super init]) { |
33 _urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES]; | 45 _urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES]; |
34 _username = [username copy]; | 46 _username = [username copy]; |
35 _credential = [credential copy]; | 47 _credential = [credential copy]; |
48 _tlsCertPolicy = tlsCertPolicy; | |
36 } | 49 } |
37 return self; | 50 return self; |
38 } | 51 } |
39 | 52 |
40 - (NSString *)description { | 53 - (NSString *)description { |
41 return [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@", | 54 return [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@\n%lu", |
42 _urlStrings, | 55 _urlStrings, _username, _credential, |
43 _username, | 56 (unsigned long)_tlsCertPolicy]; |
44 _credential]; | |
45 } | 57 } |
46 | 58 |
47 #pragma mark - Private | 59 #pragma mark - Private |
48 | 60 |
49 - (webrtc::PeerConnectionInterface::IceServer)nativeServer { | 61 - (webrtc::PeerConnectionInterface::IceServer)nativeServer { |
50 __block webrtc::PeerConnectionInterface::IceServer iceServer; | 62 __block webrtc::PeerConnectionInterface::IceServer iceServer; |
51 | 63 |
52 iceServer.username = [NSString stdStringForString:_username]; | 64 iceServer.username = [NSString stdStringForString:_username]; |
53 iceServer.password = [NSString stdStringForString:_credential]; | 65 iceServer.password = [NSString stdStringForString:_credential]; |
54 | 66 |
55 [_urlStrings enumerateObjectsUsingBlock:^(NSString *url, | 67 [_urlStrings enumerateObjectsUsingBlock:^(NSString *url, |
56 NSUInteger idx, | 68 NSUInteger idx, |
57 BOOL *stop) { | 69 BOOL *stop) { |
58 iceServer.urls.push_back(url.stdString); | 70 iceServer.urls.push_back(url.stdString); |
59 }]; | 71 }]; |
72 | |
73 if (_tlsCertPolicy == RTCTlsCertPolicySecure) { | |
74 iceServer.tls_cert_policy = | |
75 webrtc::PeerConnectionInterface::kTlsCertPolicySecure; | |
76 } else if (_tlsCertPolicy == RTCTlsCertPolicyInsecureNoCheck) { | |
77 iceServer.tls_cert_policy = | |
78 webrtc::PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck; | |
79 } else { | |
daniela-webrtc
2017/02/01 14:26:53
I don't think this else will ever be executed.
hnsl1
2017/02/01 16:11:47
Done.
| |
80 iceServer.tls_cert_policy = | |
81 webrtc::PeerConnectionInterface::kTlsCertPolicySecure; | |
82 } | |
60 return iceServer; | 83 return iceServer; |
61 } | 84 } |
62 | 85 |
63 - (instancetype)initWithNativeServer: | 86 - (instancetype)initWithNativeServer: |
64 (webrtc::PeerConnectionInterface::IceServer)nativeServer { | 87 (webrtc::PeerConnectionInterface::IceServer)nativeServer { |
65 NSMutableArray *urls = | 88 NSMutableArray *urls = |
66 [NSMutableArray arrayWithCapacity:nativeServer.urls.size()]; | 89 [NSMutableArray arrayWithCapacity:nativeServer.urls.size()]; |
67 for (auto const &url : nativeServer.urls) { | 90 for (auto const &url : nativeServer.urls) { |
68 [urls addObject:[NSString stringForStdString:url]]; | 91 [urls addObject:[NSString stringForStdString:url]]; |
69 } | 92 } |
70 NSString *username = [NSString stringForStdString:nativeServer.username]; | 93 NSString *username = [NSString stringForStdString:nativeServer.username]; |
71 NSString *credential = [NSString stringForStdString:nativeServer.password]; | 94 NSString *credential = [NSString stringForStdString:nativeServer.password]; |
95 RTCTlsCertPolicy tlsCertPolicy; | |
96 | |
97 if (nativeServer.tls_cert_policy == | |
98 webrtc::PeerConnectionInterface::kTlsCertPolicySecure) { | |
99 tlsCertPolicy = RTCTlsCertPolicySecure; | |
100 } else if (nativeServer.tls_cert_policy == | |
101 webrtc::PeerConnectionInterface::kTlsCertPolicyInsecureNoCheck) { | |
102 tlsCertPolicy = RTCTlsCertPolicyInsecureNoCheck; | |
103 } else { | |
daniela-webrtc
2017/02/01 14:26:53
Same here
hnsl1
2017/02/01 16:11:47
Done.
| |
104 tlsCertPolicy = RTCTlsCertPolicySecure; | |
105 } | |
106 | |
72 self = [self initWithURLStrings:urls | 107 self = [self initWithURLStrings:urls |
73 username:username | 108 username:username |
74 credential:credential]; | 109 credential:credential |
110 tlsCertPolicy:tlsCertPolicy]; | |
75 return self; | 111 return self; |
76 } | 112 } |
77 | 113 |
78 @end | 114 @end |
OLD | NEW |