OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2014 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 "ARDAppClient+Internal.h" | 11 #import "ARDAppClient+Internal.h" |
12 | 12 |
13 #if defined(WEBRTC_IOS) | 13 #if defined(WEBRTC_IOS) |
| 14 #import "webrtc/base/objc/RTCTracing.h" |
14 #import "RTCAVFoundationVideoSource.h" | 15 #import "RTCAVFoundationVideoSource.h" |
15 #endif | 16 #endif |
16 #import "RTCFileLogger.h" | 17 #import "RTCFileLogger.h" |
17 #import "RTCICEServer.h" | 18 #import "RTCICEServer.h" |
18 #import "RTCLogging.h" | 19 #import "RTCLogging.h" |
19 #import "RTCMediaConstraints.h" | 20 #import "RTCMediaConstraints.h" |
20 #import "RTCMediaStream.h" | 21 #import "RTCMediaStream.h" |
21 #import "RTCPair.h" | 22 #import "RTCPair.h" |
22 #import "RTCPeerConnectionInterface.h" | 23 #import "RTCPeerConnectionInterface.h" |
23 #import "RTCVideoCapturer.h" | 24 #import "RTCVideoCapturer.h" |
(...skipping 17 matching lines...) Expand all Loading... |
41 @"/turn?username=iapprtc&key=4080218913"; | 42 @"/turn?username=iapprtc&key=4080218913"; |
42 | 43 |
43 static NSString * const kARDAppClientErrorDomain = @"ARDAppClient"; | 44 static NSString * const kARDAppClientErrorDomain = @"ARDAppClient"; |
44 static NSInteger const kARDAppClientErrorUnknown = -1; | 45 static NSInteger const kARDAppClientErrorUnknown = -1; |
45 static NSInteger const kARDAppClientErrorRoomFull = -2; | 46 static NSInteger const kARDAppClientErrorRoomFull = -2; |
46 static NSInteger const kARDAppClientErrorCreateSDP = -3; | 47 static NSInteger const kARDAppClientErrorCreateSDP = -3; |
47 static NSInteger const kARDAppClientErrorSetSDP = -4; | 48 static NSInteger const kARDAppClientErrorSetSDP = -4; |
48 static NSInteger const kARDAppClientErrorInvalidClient = -5; | 49 static NSInteger const kARDAppClientErrorInvalidClient = -5; |
49 static NSInteger const kARDAppClientErrorInvalidRoom = -6; | 50 static NSInteger const kARDAppClientErrorInvalidRoom = -6; |
50 | 51 |
| 52 // TODO(tkchin): Remove guard once rtc_base_objc compiles on Mac. |
| 53 #if defined(WEBRTC_IOS) |
| 54 // TODO(tkchin): Add this as a UI option. |
| 55 static BOOL const kARDAppClientEnableTracing = NO; |
| 56 #endif |
| 57 |
51 // We need a proxy to NSTimer because it causes a strong retain cycle. When | 58 // We need a proxy to NSTimer because it causes a strong retain cycle. When |
52 // using the proxy, |invalidate| must be called before it properly deallocs. | 59 // using the proxy, |invalidate| must be called before it properly deallocs. |
53 @interface ARDTimerProxy : NSObject | 60 @interface ARDTimerProxy : NSObject |
54 | 61 |
55 - (instancetype)initWithInterval:(NSTimeInterval)interval | 62 - (instancetype)initWithInterval:(NSTimeInterval)interval |
56 repeats:(BOOL)repeats | 63 repeats:(BOOL)repeats |
57 timerHandler:(void (^)(void))timerHandler; | 64 timerHandler:(void (^)(void))timerHandler; |
58 - (void)invalidate; | 65 - (void)invalidate; |
59 | 66 |
60 @end | 67 @end |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 209 |
203 - (void)connectToRoomWithId:(NSString *)roomId | 210 - (void)connectToRoomWithId:(NSString *)roomId |
204 isLoopback:(BOOL)isLoopback | 211 isLoopback:(BOOL)isLoopback |
205 isAudioOnly:(BOOL)isAudioOnly { | 212 isAudioOnly:(BOOL)isAudioOnly { |
206 NSParameterAssert(roomId.length); | 213 NSParameterAssert(roomId.length); |
207 NSParameterAssert(_state == kARDAppClientStateDisconnected); | 214 NSParameterAssert(_state == kARDAppClientStateDisconnected); |
208 _isLoopback = isLoopback; | 215 _isLoopback = isLoopback; |
209 _isAudioOnly = isAudioOnly; | 216 _isAudioOnly = isAudioOnly; |
210 self.state = kARDAppClientStateConnecting; | 217 self.state = kARDAppClientStateConnecting; |
211 | 218 |
| 219 #if defined(WEBRTC_IOS) |
| 220 if (kARDAppClientEnableTracing) { |
| 221 NSArray *paths = NSSearchPathForDirectoriesInDomains( |
| 222 NSDocumentDirectory, NSUserDomainMask, YES); |
| 223 NSString *documentsDirPath = paths.firstObject; |
| 224 NSString *filePath = |
| 225 [documentsDirPath stringByAppendingPathComponent:@"webrtc-trace.txt"]; |
| 226 RTCStartInternalCapture(filePath); |
| 227 } |
| 228 #endif |
| 229 |
212 // Request TURN. | 230 // Request TURN. |
213 __weak ARDAppClient *weakSelf = self; | 231 __weak ARDAppClient *weakSelf = self; |
214 [_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers, | 232 [_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers, |
215 NSError *error) { | 233 NSError *error) { |
216 if (error) { | 234 if (error) { |
217 RTCLogError("Error retrieving TURN servers: %@", | 235 RTCLogError("Error retrieving TURN servers: %@", |
218 error.localizedDescription); | 236 error.localizedDescription); |
219 } | 237 } |
220 ARDAppClient *strongSelf = weakSelf; | 238 ARDAppClient *strongSelf = weakSelf; |
221 [strongSelf.iceServers addObjectsFromArray:turnServers]; | 239 [strongSelf.iceServers addObjectsFromArray:turnServers]; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // Disconnect from collider. | 296 // Disconnect from collider. |
279 _channel = nil; | 297 _channel = nil; |
280 } | 298 } |
281 _clientId = nil; | 299 _clientId = nil; |
282 _roomId = nil; | 300 _roomId = nil; |
283 _isInitiator = NO; | 301 _isInitiator = NO; |
284 _hasReceivedSdp = NO; | 302 _hasReceivedSdp = NO; |
285 _messageQueue = [NSMutableArray array]; | 303 _messageQueue = [NSMutableArray array]; |
286 _peerConnection = nil; | 304 _peerConnection = nil; |
287 self.state = kARDAppClientStateDisconnected; | 305 self.state = kARDAppClientStateDisconnected; |
| 306 #if defined(WEBRTC_IOS) |
| 307 RTCStopInternalCapture(); |
| 308 #endif |
288 } | 309 } |
289 | 310 |
290 #pragma mark - ARDSignalingChannelDelegate | 311 #pragma mark - ARDSignalingChannelDelegate |
291 | 312 |
292 - (void)channel:(id<ARDSignalingChannel>)channel | 313 - (void)channel:(id<ARDSignalingChannel>)channel |
293 didReceiveMessage:(ARDSignalingMessage *)message { | 314 didReceiveMessage:(ARDSignalingMessage *)message { |
294 switch (message.type) { | 315 switch (message.type) { |
295 case kARDSignalingMessageTypeOffer: | 316 case kARDSignalingMessageTypeOffer: |
296 case kARDSignalingMessageTypeAnswer: | 317 case kARDSignalingMessageTypeAnswer: |
297 // Offers and answers must be processed before any other message, so we | 318 // Offers and answers must be processed before any other message, so we |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 code:kARDAppClientErrorInvalidRoom | 745 code:kARDAppClientErrorInvalidRoom |
725 userInfo:@{ | 746 userInfo:@{ |
726 NSLocalizedDescriptionKey: @"Invalid room.", | 747 NSLocalizedDescriptionKey: @"Invalid room.", |
727 }]; | 748 }]; |
728 break; | 749 break; |
729 } | 750 } |
730 return error; | 751 return error; |
731 } | 752 } |
732 | 753 |
733 @end | 754 @end |
OLD | NEW |