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