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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 [_channel sendMessage:byeMessage]; | 301 [_channel sendMessage:byeMessage]; |
302 } | 302 } |
303 // Disconnect from collider. | 303 // Disconnect from collider. |
304 _channel = nil; | 304 _channel = nil; |
305 } | 305 } |
306 _clientId = nil; | 306 _clientId = nil; |
307 _roomId = nil; | 307 _roomId = nil; |
308 _isInitiator = NO; | 308 _isInitiator = NO; |
309 _hasReceivedSdp = NO; | 309 _hasReceivedSdp = NO; |
310 _messageQueue = [NSMutableArray array]; | 310 _messageQueue = [NSMutableArray array]; |
311 #if defined(WEBRTC_IOS) | |
312 [_peerConnection stopRtcEventLog]; | |
313 #endif | |
314 _peerConnection = nil; | 311 _peerConnection = nil; |
315 self.state = kARDAppClientStateDisconnected; | 312 self.state = kARDAppClientStateDisconnected; |
316 #if defined(WEBRTC_IOS) | 313 #if defined(WEBRTC_IOS) |
317 RTCStopInternalCapture(); | 314 RTCStopInternalCapture(); |
| 315 [_factory stopRtcEventLog]; |
318 #endif | 316 #endif |
319 } | 317 } |
320 | 318 |
321 #pragma mark - ARDSignalingChannelDelegate | 319 #pragma mark - ARDSignalingChannelDelegate |
322 | 320 |
323 - (void)channel:(id<ARDSignalingChannel>)channel | 321 - (void)channel:(id<ARDSignalingChannel>)channel |
324 didReceiveMessage:(ARDSignalingMessage *)message { | 322 didReceiveMessage:(ARDSignalingMessage *)message { |
325 switch (message.type) { | 323 switch (message.type) { |
326 case kARDSignalingMessageTypeOffer: | 324 case kARDSignalingMessageTypeOffer: |
327 case kARDSignalingMessageTypeAnswer: | 325 case kARDSignalingMessageTypeAnswer: |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 // 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. |
522 // 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 |
523 // 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 |
524 // well, otherwise the client will wait for an offer to arrive. | 522 // well, otherwise the client will wait for an offer to arrive. |
525 - (void)startSignalingIfReady { | 523 - (void)startSignalingIfReady { |
526 if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) { | 524 if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) { |
527 return; | 525 return; |
528 } | 526 } |
529 self.state = kARDAppClientStateConnected; | 527 self.state = kARDAppClientStateConnected; |
530 | 528 |
| 529 #if defined(WEBRTC_IOS) |
| 530 // Start event log. |
| 531 if (kARDAppClientEnableRtcEventLog) { |
| 532 NSString *filePath = [self documentsFilePathForFileName:@"webrtc-rtceventlog
"]; |
| 533 if (![_factory startRtcEventLogWithFilePath:filePath |
| 534 maxSizeInBytes:kARDAppClientRtcEventLogMaxSizeI
nBytes]) { |
| 535 RTCLogError(@"Failed to start event logging."); |
| 536 } |
| 537 } |
| 538 #endif |
| 539 |
531 // Create peer connection. | 540 // Create peer connection. |
532 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; | 541 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; |
533 RTCConfiguration *config = [[RTCConfiguration alloc] init]; | 542 RTCConfiguration *config = [[RTCConfiguration alloc] init]; |
534 config.iceServers = _iceServers; | 543 config.iceServers = _iceServers; |
535 _peerConnection = [_factory peerConnectionWithConfiguration:config | 544 _peerConnection = [_factory peerConnectionWithConfiguration:config |
536 constraints:constraints | 545 constraints:constraints |
537 delegate:self]; | 546 delegate:self]; |
538 // Create AV senders. | 547 // Create AV senders. |
539 [self createAudioSender]; | 548 [self createAudioSender]; |
540 [self createVideoSender]; | 549 [self createVideoSender]; |
541 if (_isInitiator) { | 550 if (_isInitiator) { |
542 // Send offer. | 551 // Send offer. |
543 __weak ARDAppClient *weakSelf = self; | 552 __weak ARDAppClient *weakSelf = self; |
544 [_peerConnection offerForConstraints:[self defaultOfferConstraints] | 553 [_peerConnection offerForConstraints:[self defaultOfferConstraints] |
545 completionHandler:^(RTCSessionDescription *sdp, | 554 completionHandler:^(RTCSessionDescription *sdp, |
546 NSError *error) { | 555 NSError *error) { |
547 ARDAppClient *strongSelf = weakSelf; | 556 ARDAppClient *strongSelf = weakSelf; |
548 [strongSelf peerConnection:strongSelf.peerConnection | 557 [strongSelf peerConnection:strongSelf.peerConnection |
549 didCreateSessionDescription:sdp | 558 didCreateSessionDescription:sdp |
550 error:error]; | 559 error:error]; |
551 }]; | 560 }]; |
552 } else { | 561 } else { |
553 // Check if we've received an offer. | 562 // Check if we've received an offer. |
554 [self drainMessageQueueIfReady]; | 563 [self drainMessageQueueIfReady]; |
555 } | 564 } |
556 #if defined(WEBRTC_IOS) | |
557 // Start event log. | |
558 if (kARDAppClientEnableRtcEventLog) { | |
559 NSString *filePath = [self documentsFilePathForFileName:@"webrtc-rtceventlog
"]; | |
560 if (![_peerConnection startRtcEventLogWithFilePath:filePath | |
561 maxSizeInBytes:kARDAppClientRtcEventLogMaxSizeI
nBytes]) { | |
562 RTCLogError(@"Failed to start event logging."); | |
563 } | |
564 } | |
565 #endif | |
566 } | 565 } |
567 | 566 |
568 // Processes the messages that we've received from the room server and the | 567 // Processes the messages that we've received from the room server and the |
569 // signaling channel. The offer or answer message must be processed before other | 568 // signaling channel. The offer or answer message must be processed before other |
570 // signaling messages, however they can arrive out of order. Hence, this method | 569 // signaling messages, however they can arrive out of order. Hence, this method |
571 // only processes pending messages if there is a peer connection object and | 570 // only processes pending messages if there is a peer connection object and |
572 // if we have received either an offer or answer. | 571 // if we have received either an offer or answer. |
573 - (void)drainMessageQueueIfReady { | 572 - (void)drainMessageQueueIfReady { |
574 if (!_peerConnection || !_hasReceivedSdp) { | 573 if (!_peerConnection || !_hasReceivedSdp) { |
575 return; | 574 return; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
814 code:kARDAppClientErrorInvalidRoom | 813 code:kARDAppClientErrorInvalidRoom |
815 userInfo:@{ | 814 userInfo:@{ |
816 NSLocalizedDescriptionKey: @"Invalid room.", | 815 NSLocalizedDescriptionKey: @"Invalid room.", |
817 }]; | 816 }]; |
818 break; | 817 break; |
819 } | 818 } |
820 return error; | 819 return error; |
821 } | 820 } |
822 | 821 |
823 @end | 822 @end |
OLD | NEW |