Chromium Code Reviews| 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 urls = _urls; | |
| 19 @synthesize username = _username; | |
| 20 @synthesize credential = _credential; | |
| 21 | |
| 22 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urls { | |
|
tkchin_webrtc
2015/12/08 19:04:02
nit: urlStrings
hjon
2015/12/08 19:31:21
Done.
| |
| 23 return [self initWithURLStrings:urls | |
|
tkchin_webrtc
2015/12/08 19:04:02
NSParameterAssert(urlStrings.length)
hjon
2015/12/08 19:31:21
Done.
| |
| 24 username:nil | |
| 25 credential:nil]; | |
| 26 } | |
| 27 | |
| 28 - (instancetype)initWithURLStrings:(NSArray<NSString *> *)urls | |
| 29 username:(NSString *)username | |
| 30 credential:(NSString *)credential { | |
| 31 NSParameterAssert(urls.count); | |
| 32 if (self = [super init]) { | |
| 33 _urls = [[NSArray alloc] initWithArray:urls copyItems:YES]; | |
| 34 _username = [username copy]; | |
| 35 _credential = [credential copy]; | |
| 36 } | |
| 37 return self; | |
| 38 } | |
| 39 | |
| 40 - (NSString *)description { | |
| 41 return [NSString stringWithFormat:@"RTCIceServer:\n%@\n%@\n%@", | |
| 42 _urls, | |
| 43 _username, | |
| 44 _credential]; | |
| 45 } | |
| 46 | |
| 47 #pragma mark - Private | |
| 48 | |
| 49 - (webrtc::PeerConnectionInterface::IceServer)iceServer { | |
| 50 __block webrtc::PeerConnectionInterface::IceServer iceServer; | |
| 51 | |
| 52 iceServer.username = [NSString stdStringForString:_username]; | |
| 53 iceServer.password = [NSString stdStringForString:_credential]; | |
| 54 | |
| 55 [_urls enumerateObjectsUsingBlock:^(NSString *url, | |
| 56 NSUInteger idx, | |
| 57 BOOL *stop) { | |
| 58 iceServer.urls.push_back(url.stdString); | |
| 59 }]; | |
| 60 return iceServer; | |
| 61 } | |
| 62 | |
| 63 @end | |
| OLD | NEW |