| 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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 didReceiveMessage:(ARDSignalingMessage *)message { | 323 didReceiveMessage:(ARDSignalingMessage *)message { |
| 324 switch (message.type) { | 324 switch (message.type) { |
| 325 case kARDSignalingMessageTypeOffer: | 325 case kARDSignalingMessageTypeOffer: |
| 326 case kARDSignalingMessageTypeAnswer: | 326 case kARDSignalingMessageTypeAnswer: |
| 327 // Offers and answers must be processed before any other message, so we | 327 // Offers and answers must be processed before any other message, so we |
| 328 // place them at the front of the queue. | 328 // place them at the front of the queue. |
| 329 _hasReceivedSdp = YES; | 329 _hasReceivedSdp = YES; |
| 330 [_messageQueue insertObject:message atIndex:0]; | 330 [_messageQueue insertObject:message atIndex:0]; |
| 331 break; | 331 break; |
| 332 case kARDSignalingMessageTypeCandidate: | 332 case kARDSignalingMessageTypeCandidate: |
| 333 case kARDSignalingMessageTypeCandidateRemoval: |
| 333 [_messageQueue addObject:message]; | 334 [_messageQueue addObject:message]; |
| 334 break; | 335 break; |
| 335 case kARDSignalingMessageTypeBye: | 336 case kARDSignalingMessageTypeBye: |
| 336 // Disconnects can be processed immediately. | 337 // Disconnects can be processed immediately. |
| 337 [self processSignalingMessage:message]; | 338 [self processSignalingMessage:message]; |
| 338 return; | 339 return; |
| 339 } | 340 } |
| 340 [self drainMessageQueueIfReady]; | 341 [self drainMessageQueueIfReady]; |
| 341 } | 342 } |
| 342 | 343 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 404 - (void)peerConnection:(RTCPeerConnection *)peerConnection |
| 404 didGenerateIceCandidate:(RTCIceCandidate *)candidate { | 405 didGenerateIceCandidate:(RTCIceCandidate *)candidate { |
| 405 dispatch_async(dispatch_get_main_queue(), ^{ | 406 dispatch_async(dispatch_get_main_queue(), ^{ |
| 406 ARDICECandidateMessage *message = | 407 ARDICECandidateMessage *message = |
| 407 [[ARDICECandidateMessage alloc] initWithCandidate:candidate]; | 408 [[ARDICECandidateMessage alloc] initWithCandidate:candidate]; |
| 408 [self sendSignalingMessage:message]; | 409 [self sendSignalingMessage:message]; |
| 409 }); | 410 }); |
| 410 } | 411 } |
| 411 | 412 |
| 412 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 413 - (void)peerConnection:(RTCPeerConnection *)peerConnection |
| 414 didRemoveIceCandidates:(NSArray<RTCIceCandidate *> *)candidates { |
| 415 dispatch_async(dispatch_get_main_queue(), ^{ |
| 416 ARDICECandidateRemovalMessage *message = |
| 417 [[ARDICECandidateRemovalMessage alloc] |
| 418 initWithRemovedCandidates:candidates]; |
| 419 [self sendSignalingMessage:message]; |
| 420 }); |
| 421 } |
| 422 |
| 423 - (void)peerConnection:(RTCPeerConnection *)peerConnection |
| 413 didOpenDataChannel:(RTCDataChannel *)dataChannel { | 424 didOpenDataChannel:(RTCDataChannel *)dataChannel { |
| 414 } | 425 } |
| 415 | 426 |
| 416 #pragma mark - RTCSessionDescriptionDelegate | 427 #pragma mark - RTCSessionDescriptionDelegate |
| 417 // Callbacks for this delegate occur on non-main thread and need to be | 428 // Callbacks for this delegate occur on non-main thread and need to be |
| 418 // dispatched back to main queue as needed. | 429 // dispatched back to main queue as needed. |
| 419 | 430 |
| 420 - (void)peerConnection:(RTCPeerConnection *)peerConnection | 431 - (void)peerConnection:(RTCPeerConnection *)peerConnection |
| 421 didCreateSessionDescription:(RTCSessionDescription *)sdp | 432 didCreateSessionDescription:(RTCSessionDescription *)sdp |
| 422 error:(NSError *)error { | 433 error:(NSError *)error { |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 didSetSessionDescriptionWithError:error]; | 577 didSetSessionDescriptionWithError:error]; |
| 567 }]; | 578 }]; |
| 568 break; | 579 break; |
| 569 } | 580 } |
| 570 case kARDSignalingMessageTypeCandidate: { | 581 case kARDSignalingMessageTypeCandidate: { |
| 571 ARDICECandidateMessage *candidateMessage = | 582 ARDICECandidateMessage *candidateMessage = |
| 572 (ARDICECandidateMessage *)message; | 583 (ARDICECandidateMessage *)message; |
| 573 [_peerConnection addIceCandidate:candidateMessage.candidate]; | 584 [_peerConnection addIceCandidate:candidateMessage.candidate]; |
| 574 break; | 585 break; |
| 575 } | 586 } |
| 587 case kARDSignalingMessageTypeCandidateRemoval: { |
| 588 ARDICECandidateRemovalMessage *candidateMessage = |
| 589 (ARDICECandidateRemovalMessage *)message; |
| 590 [_peerConnection removeIceCandidates:candidateMessage.candidates]; |
| 591 break; |
| 592 } |
| 576 case kARDSignalingMessageTypeBye: | 593 case kARDSignalingMessageTypeBye: |
| 577 // Other client disconnected. | 594 // Other client disconnected. |
| 578 // TODO(tkchin): support waiting in room for next client. For now just | 595 // TODO(tkchin): support waiting in room for next client. For now just |
| 579 // disconnect. | 596 // disconnect. |
| 580 [self disconnect]; | 597 [self disconnect]; |
| 581 break; | 598 break; |
| 582 } | 599 } |
| 583 } | 600 } |
| 584 | 601 |
| 585 // Sends a signaling message to the other client. The caller will send messages | 602 // Sends a signaling message to the other client. The caller will send messages |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 code:kARDAppClientErrorInvalidRoom | 789 code:kARDAppClientErrorInvalidRoom |
| 773 userInfo:@{ | 790 userInfo:@{ |
| 774 NSLocalizedDescriptionKey: @"Invalid room.", | 791 NSLocalizedDescriptionKey: @"Invalid room.", |
| 775 }]; | 792 }]; |
| 776 break; | 793 break; |
| 777 } | 794 } |
| 778 return error; | 795 return error; |
| 779 } | 796 } |
| 780 | 797 |
| 781 @end | 798 @end |
| OLD | NEW |