| OLD | NEW |
| (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 "RTCIceServer.h" | |
| 12 | |
| 13 #import "webrtc/api/objc/RTCIceServer+Private.h" | |
| 14 #import "webrtc/base/objc/NSString+StdString.h" | |
| 15 | |
| 16 @implementation RTCIceServer | |
| 17 | |
| 18 @synthesize urlStrings = _urlStrings; | |
| 19 @synthesize username = _username; | |
| 20 @synthesize credential = _credential; | |
| 21 | |
| 22 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings { | |
| 23 NSParameterAssert(urlStrings.count); | |
| 24 return [self initWithURLStrings:urlStrings | |
| 25 username:nil | |
| 26 credential:nil]; | |
| 27 } | |
| 28 | |
| 29 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urlStrings | |
| 30 username:(NSString *)username | |
| 31 credential:(NSString *)credential { | |
| 32 NSParameterAssert(urlStrings.count); | |
| 33 if (self = [super init]) { | |
| 34 _urlStrings = [[NSArray alloc] initWithArray:urlStrings copyItems:YES]; | |
| 35 _username = [username copy]; | |
| 36 _credential = [credential copy]; | |
| 37 } | |
| 38 return self; | |
| 39 } | |
| 40 | |
| 41 - (NSString *)description { | |
| 42 return [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@", | |
| 43 _urlStrings, | |
| 44 _username, | |
| 45 _credential]; | |
| 46 } | |
| 47 | |
| 48 #pragma mark - Private | |
| 49 | |
| 50 - (webrtc::PeerConnectionInterface::IceServer)nativeServer { | |
| 51 __block webrtc::PeerConnectionInterface::IceServer iceServer; | |
| 52 | |
| 53 iceServer.username = [NSString stdStringForString:_username]; | |
| 54 iceServer.password = [NSString stdStringForString:_credential]; | |
| 55 | |
| 56 [_urlStrings enumerateObjectsUsingBlock:^(NSString *url, | |
| 57 NSUInteger idx, | |
| 58 BOOL *stop) { | |
| 59 iceServer.urls.push_back(url.stdString); | |
| 60 }]; | |
| 61 return iceServer; | |
| 62 } | |
| 63 | |
| 64 - (instancetype)initWithNativeServer: | |
| 65 (webrtc::PeerConnectionInterface::IceServer)nativeServer { | |
| 66 NSMutableArray *urls = | |
| 67 [NSMutableArray arrayWithCapacity:nativeServer.urls.size()]; | |
| 68 for (auto const &url : nativeServer.urls) { | |
| 69 [urls addObject:[NSString stringForStdString:url]]; | |
| 70 } | |
| 71 NSString *username = [NSString stringForStdString:nativeServer.username]; | |
| 72 NSString *credential = [NSString stringForStdString:nativeServer.password]; | |
| 73 self = [self initWithURLStrings:urls | |
| 74 username:username | |
| 75 credential:credential]; | |
| 76 return self; | |
| 77 } | |
| 78 | |
| 79 @end | |
| OLD | NEW |