 Chromium Code Reviews
 Chromium Code Reviews Issue 2067683002:
  Add RTCEventLog API to ObjC.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master
    
  
    Issue 2067683002:
  Add RTCEventLog API to ObjC.  (Closed) 
  Base URL: https://chromium.googlesource.com/external/webrtc.git@master| 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 | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 static NSInteger const kARDAppClientErrorCreateSDP = -3; | 48 static NSInteger const kARDAppClientErrorCreateSDP = -3; | 
| 49 static NSInteger const kARDAppClientErrorSetSDP = -4; | 49 static NSInteger const kARDAppClientErrorSetSDP = -4; | 
| 50 static NSInteger const kARDAppClientErrorInvalidClient = -5; | 50 static NSInteger const kARDAppClientErrorInvalidClient = -5; | 
| 51 static NSInteger const kARDAppClientErrorInvalidRoom = -6; | 51 static NSInteger const kARDAppClientErrorInvalidRoom = -6; | 
| 52 static NSString * const kARDMediaStreamId = @"ARDAMS"; | 52 static NSString * const kARDMediaStreamId = @"ARDAMS"; | 
| 53 static NSString * const kARDAudioTrackId = @"ARDAMSa0"; | 53 static NSString * const kARDAudioTrackId = @"ARDAMSa0"; | 
| 54 static NSString * const kARDVideoTrackId = @"ARDAMSv0"; | 54 static NSString * const kARDVideoTrackId = @"ARDAMSv0"; | 
| 55 | 55 | 
| 56 // TODO(tkchin): Remove guard once rtc_sdk_common_objc compiles on Mac. | 56 // TODO(tkchin): Remove guard once rtc_sdk_common_objc compiles on Mac. | 
| 57 #if defined(WEBRTC_IOS) | 57 #if defined(WEBRTC_IOS) | 
| 58 // TODO(tkchin): Add this as a UI option. | 58 // TODO(tkchin): Add these as UI options. | 
| 59 static BOOL const kARDAppClientEnableTracing = NO; | 59 static BOOL const kARDAppClientEnableTracing = NO; | 
| 60 static BOOL const kARDAppClientEnableRtcEventLog = YES; | |
| 61 static int64_t const kARDAppClientRtcEventLogMaxSizeInBytes = 5e6; // 5 MB. | |
| 60 #endif | 62 #endif | 
| 61 | 63 | 
| 62 // We need a proxy to NSTimer because it causes a strong retain cycle. When | 64 // We need a proxy to NSTimer because it causes a strong retain cycle. When | 
| 63 // using the proxy, |invalidate| must be called before it properly deallocs. | 65 // using the proxy, |invalidate| must be called before it properly deallocs. | 
| 64 @interface ARDTimerProxy : NSObject | 66 @interface ARDTimerProxy : NSObject | 
| 65 | 67 | 
| 66 - (instancetype)initWithInterval:(NSTimeInterval)interval | 68 - (instancetype)initWithInterval:(NSTimeInterval)interval | 
| 67 repeats:(BOOL)repeats | 69 repeats:(BOOL)repeats | 
| 68 timerHandler:(void (^)(void))timerHandler; | 70 timerHandler:(void (^)(void))timerHandler; | 
| 69 - (void)invalidate; | 71 - (void)invalidate; | 
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 isLoopback:(BOOL)isLoopback | 222 isLoopback:(BOOL)isLoopback | 
| 221 isAudioOnly:(BOOL)isAudioOnly { | 223 isAudioOnly:(BOOL)isAudioOnly { | 
| 222 NSParameterAssert(roomId.length); | 224 NSParameterAssert(roomId.length); | 
| 223 NSParameterAssert(_state == kARDAppClientStateDisconnected); | 225 NSParameterAssert(_state == kARDAppClientStateDisconnected); | 
| 224 _isLoopback = isLoopback; | 226 _isLoopback = isLoopback; | 
| 225 _isAudioOnly = isAudioOnly; | 227 _isAudioOnly = isAudioOnly; | 
| 226 self.state = kARDAppClientStateConnecting; | 228 self.state = kARDAppClientStateConnecting; | 
| 227 | 229 | 
| 228 #if defined(WEBRTC_IOS) | 230 #if defined(WEBRTC_IOS) | 
| 229 if (kARDAppClientEnableTracing) { | 231 if (kARDAppClientEnableTracing) { | 
| 230 NSArray *paths = NSSearchPathForDirectoriesInDomains( | 232 NSString *filePath = [self documentsFilePathForFileName:@"webrtc-trace.txt"] ; | 
| 231 NSDocumentDirectory, NSUserDomainMask, YES); | |
| 232 NSString *documentsDirPath = paths.firstObject; | |
| 233 NSString *filePath = | |
| 234 [documentsDirPath stringByAppendingPathComponent:@"webrtc-trace.txt"]; | |
| 235 RTCStartInternalCapture(filePath); | 233 RTCStartInternalCapture(filePath); | 
| 236 } | 234 } | 
| 237 #endif | 235 #endif | 
| 238 | 236 | 
| 239 // Request TURN. | 237 // Request TURN. | 
| 240 __weak ARDAppClient *weakSelf = self; | 238 __weak ARDAppClient *weakSelf = self; | 
| 241 [_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers, | 239 [_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers, | 
| 242 NSError *error) { | 240 NSError *error) { | 
| 243 if (error) { | 241 if (error) { | 
| 244 RTCLogError("Error retrieving TURN servers: %@", | 242 RTCLogError("Error retrieving TURN servers: %@", | 
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 } | 305 } | 
| 308 _clientId = nil; | 306 _clientId = nil; | 
| 309 _roomId = nil; | 307 _roomId = nil; | 
| 310 _isInitiator = NO; | 308 _isInitiator = NO; | 
| 311 _hasReceivedSdp = NO; | 309 _hasReceivedSdp = NO; | 
| 312 _messageQueue = [NSMutableArray array]; | 310 _messageQueue = [NSMutableArray array]; | 
| 313 _peerConnection = nil; | 311 _peerConnection = nil; | 
| 314 self.state = kARDAppClientStateDisconnected; | 312 self.state = kARDAppClientStateDisconnected; | 
| 315 #if defined(WEBRTC_IOS) | 313 #if defined(WEBRTC_IOS) | 
| 316 RTCStopInternalCapture(); | 314 RTCStopInternalCapture(); | 
| 315 [_factory stopRtcEventLog]; | |
| 
Chuck
2016/06/14 14:01:17
Do you need the #if guards here?
 
tkchin_webrtc
2016/06/14 17:40:59
Prob not.
 
Chuck
2016/06/14 19:36:44
I think I confused myself, I didn't see them in th
 | |
| 317 #endif | 316 #endif | 
| 318 } | 317 } | 
| 319 | 318 | 
| 320 #pragma mark - ARDSignalingChannelDelegate | 319 #pragma mark - ARDSignalingChannelDelegate | 
| 321 | 320 | 
| 322 - (void)channel:(id<ARDSignalingChannel>)channel | 321 - (void)channel:(id<ARDSignalingChannel>)channel | 
| 323 didReceiveMessage:(ARDSignalingMessage *)message { | 322 didReceiveMessage:(ARDSignalingMessage *)message { | 
| 324 switch (message.type) { | 323 switch (message.type) { | 
| 325 case kARDSignalingMessageTypeOffer: | 324 case kARDSignalingMessageTypeOffer: | 
| 326 case kARDSignalingMessageTypeAnswer: | 325 case kARDSignalingMessageTypeAnswer: | 
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 491 [strongSelf peerConnection:strongSelf.peerConnection | 490 [strongSelf peerConnection:strongSelf.peerConnection | 
| 492 didCreateSessionDescription:sdp | 491 didCreateSessionDescription:sdp | 
| 493 error:error]; | 492 error:error]; | 
| 494 }]; | 493 }]; | 
| 495 } | 494 } | 
| 496 }); | 495 }); | 
| 497 } | 496 } | 
| 498 | 497 | 
| 499 #pragma mark - Private | 498 #pragma mark - Private | 
| 500 | 499 | 
| 500 #if defined(WEBRTC_IOS) | |
| 501 | |
| 502 - (NSString *)documentsFilePathForFileName:(NSString *)fileName { | |
| 503 NSParameterAssert(fileName.length); | |
| 504 NSArray *paths = NSSearchPathForDirectoriesInDomains( | |
| 505 NSDocumentDirectory, NSUserDomainMask, YES); | |
| 506 NSString *documentsDirPath = paths.firstObject; | |
| 507 NSString *filePath = | |
| 508 [documentsDirPath stringByAppendingPathComponent:fileName]; | |
| 509 return filePath; | |
| 510 } | |
| 511 | |
| 512 #endif | |
| 513 | |
| 501 - (BOOL)hasJoinedRoomServerRoom { | 514 - (BOOL)hasJoinedRoomServerRoom { | 
| 502 return _clientId.length; | 515 return _clientId.length; | 
| 503 } | 516 } | 
| 504 | 517 | 
| 505 // Begins the peer connection connection process if we have both joined a room | 518 // Begins the peer connection connection process if we have both joined a room | 
| 506 // on the room server and tried to obtain a TURN server. Otherwise does nothing. | 519 // on the room server and tried to obtain a TURN server. Otherwise does nothing. | 
| 507 // A peer connection object will be created with a stream that contains local | 520 // A peer connection object will be created with a stream that contains local | 
| 508 // audio and video capture. If this client is the caller, an offer is created as | 521 // audio and video capture. If this client is the caller, an offer is created as | 
| 509 // well, otherwise the client will wait for an offer to arrive. | 522 // well, otherwise the client will wait for an offer to arrive. | 
| 510 - (void)startSignalingIfReady { | 523 - (void)startSignalingIfReady { | 
| 511 if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) { | 524 if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) { | 
| 512 return; | 525 return; | 
| 513 } | 526 } | 
| 514 self.state = kARDAppClientStateConnected; | 527 self.state = kARDAppClientStateConnected; | 
| 515 | 528 | 
| 529 #if defined(WEBRTC_IOS) | |
| 530 // Start event log. | |
| 531 if (kARDAppClientEnableRtcEventLog) { | |
| 532 NSString *filePath = [self documentsFilePathForFileName:@"webrtc-rtceventlog "]; | |
| 533 [_factory startRtcEventLogWithFilePath:filePath | |
| 
Chuck
2016/06/14 14:01:17
Your comment suggests this is temporary, but shoul
 
tkchin_webrtc
2016/06/14 17:40:59
Done.
 | |
| 534 maxSizeInBytes:kARDAppClientRtcEventLogMaxSizeInByte s]; | |
| 535 } | |
| 536 #endif | |
| 537 | |
| 516 // Create peer connection. | 538 // Create peer connection. | 
| 517 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; | 539 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; | 
| 518 RTCConfiguration *config = [[RTCConfiguration alloc] init]; | 540 RTCConfiguration *config = [[RTCConfiguration alloc] init]; | 
| 519 config.iceServers = _iceServers; | 541 config.iceServers = _iceServers; | 
| 520 _peerConnection = [_factory peerConnectionWithConfiguration:config | 542 _peerConnection = [_factory peerConnectionWithConfiguration:config | 
| 521 constraints:constraints | 543 constraints:constraints | 
| 522 delegate:self]; | 544 delegate:self]; | 
| 523 // Create AV senders. | 545 // Create AV senders. | 
| 524 [self createAudioSender]; | 546 [self createAudioSender]; | 
| 525 [self createVideoSender]; | 547 [self createVideoSender]; | 
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 code:kARDAppClientErrorInvalidRoom | 811 code:kARDAppClientErrorInvalidRoom | 
| 790 userInfo:@{ | 812 userInfo:@{ | 
| 791 NSLocalizedDescriptionKey: @"Invalid room.", | 813 NSLocalizedDescriptionKey: @"Invalid room.", | 
| 792 }]; | 814 }]; | 
| 793 break; | 815 break; | 
| 794 } | 816 } | 
| 795 return error; | 817 return error; | 
| 796 } | 818 } | 
| 797 | 819 | 
| 798 @end | 820 @end | 
| OLD | NEW |