Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: webrtc/examples/objc/AppRTCDemo/ARDAppClient.m

Issue 1820193002: Refactor some ObjC API init methods. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/api/objc/RTCVideoTrack+Private.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 - (void)startSignalingIfReady { 495 - (void)startSignalingIfReady {
496 if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) { 496 if (!_isTurnComplete || !self.hasJoinedRoomServerRoom) {
497 return; 497 return;
498 } 498 }
499 self.state = kARDAppClientStateConnected; 499 self.state = kARDAppClientStateConnected;
500 500
501 // Create peer connection. 501 // Create peer connection.
502 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints]; 502 RTCMediaConstraints *constraints = [self defaultPeerConnectionConstraints];
503 RTCConfiguration *config = [[RTCConfiguration alloc] init]; 503 RTCConfiguration *config = [[RTCConfiguration alloc] init];
504 config.iceServers = _iceServers; 504 config.iceServers = _iceServers;
505 _peerConnection = [[RTCPeerConnection alloc] initWithFactory:_factory 505 _peerConnection = [_factory peerConnectionWithConfiguration:config
506 configuration:config 506 constraints:constraints
507 constraints:constraints 507 delegate:self];
508 delegate:self];
509 // Create AV media stream and add it to the peer connection. 508 // Create AV media stream and add it to the peer connection.
510 RTCMediaStream *localStream = [self createLocalMediaStream]; 509 RTCMediaStream *localStream = [self createLocalMediaStream];
511 [_peerConnection addStream:localStream]; 510 [_peerConnection addStream:localStream];
512 if (_isInitiator) { 511 if (_isInitiator) {
513 // Send offer. 512 // Send offer.
514 __weak ARDAppClient *weakSelf = self; 513 __weak ARDAppClient *weakSelf = self;
515 [_peerConnection offerForConstraints:[self defaultOfferConstraints] 514 [_peerConnection offerForConstraints:[self defaultOfferConstraints]
516 completionHandler:^(RTCSessionDescription *sdp, 515 completionHandler:^(RTCSessionDescription *sdp,
517 NSError *error) { 516 NSError *error) {
518 ARDAppClient *strongSelf = weakSelf; 517 ARDAppClient *strongSelf = weakSelf;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 [strongSelf.delegate appClient:strongSelf didError:messageError]; 600 [strongSelf.delegate appClient:strongSelf didError:messageError];
602 return; 601 return;
603 } 602 }
604 }]; 603 }];
605 } else { 604 } else {
606 [_channel sendMessage:message]; 605 [_channel sendMessage:message];
607 } 606 }
608 } 607 }
609 608
610 - (RTCMediaStream *)createLocalMediaStream { 609 - (RTCMediaStream *)createLocalMediaStream {
611 RTCMediaStream *localStream = 610 RTCMediaStream *localStream = [_factory mediaStreamWithStreamId:@"ARDAMS"];
612 [[RTCMediaStream alloc] initWithFactory:_factory streamId:@"ARDAMS"];
613 RTCVideoTrack *localVideoTrack = [self createLocalVideoTrack]; 611 RTCVideoTrack *localVideoTrack = [self createLocalVideoTrack];
614 if (localVideoTrack) { 612 if (localVideoTrack) {
615 [localStream addVideoTrack:localVideoTrack]; 613 [localStream addVideoTrack:localVideoTrack];
616 [_delegate appClient:self didReceiveLocalVideoTrack:localVideoTrack]; 614 [_delegate appClient:self didReceiveLocalVideoTrack:localVideoTrack];
617 } 615 }
618 RTCAudioTrack *localAudioTrack = 616 RTCAudioTrack *localAudioTrack =
619 [[RTCAudioTrack alloc] initWithFactory:_factory 617 [_factory audioTrackWithTrackId:@"ARDAMSa0"];
620 trackId:@"ARDAMSa0"];
621 [localStream addAudioTrack:localAudioTrack]; 618 [localStream addAudioTrack:localAudioTrack];
622 return localStream; 619 return localStream;
623 } 620 }
624 621
625 - (RTCVideoTrack *)createLocalVideoTrack { 622 - (RTCVideoTrack *)createLocalVideoTrack {
626 RTCVideoTrack* localVideoTrack = nil; 623 RTCVideoTrack* localVideoTrack = nil;
627 // The iOS simulator doesn't provide any sort of camera capture 624 // The iOS simulator doesn't provide any sort of camera capture
628 // support or emulation (http://goo.gl/rHAnC1) so don't bother 625 // support or emulation (http://goo.gl/rHAnC1) so don't bother
629 // trying to open a local stream. 626 // trying to open a local stream.
630 // TODO(tkchin): local video capture for OSX. See 627 // TODO(tkchin): local video capture for OSX. See
631 // https://code.google.com/p/webrtc/issues/detail?id=3417. 628 // https://code.google.com/p/webrtc/issues/detail?id=3417.
632 #if !TARGET_IPHONE_SIMULATOR && TARGET_OS_IPHONE 629 #if !TARGET_IPHONE_SIMULATOR && TARGET_OS_IPHONE
633 if (!_isAudioOnly) { 630 if (!_isAudioOnly) {
634 RTCMediaConstraints *mediaConstraints = 631 RTCMediaConstraints *mediaConstraints =
635 [self defaultMediaStreamConstraints]; 632 [self defaultMediaStreamConstraints];
636 RTCAVFoundationVideoSource *source = 633 RTCAVFoundationVideoSource *source =
637 [[RTCAVFoundationVideoSource alloc] initWithFactory:_factory 634 [_factory avFoundationVideoSourceWithConstraints:mediaConstraints];
638 constraints:mediaConstraints];
639 localVideoTrack = 635 localVideoTrack =
640 [[RTCVideoTrack alloc] initWithFactory:_factory 636 [_factory videoTrackWithSource:source
641 source:source 637 trackId:@"ARDAMSv0"];
642 trackId:@"ARDAMSv0"];
643 } 638 }
644 #endif 639 #endif
645 return localVideoTrack; 640 return localVideoTrack;
646 } 641 }
647 642
648 #pragma mark - Collider methods 643 #pragma mark - Collider methods
649 644
650 - (void)registerWithColliderIfReady { 645 - (void)registerWithColliderIfReady {
651 if (!self.hasJoinedRoomServerRoom) { 646 if (!self.hasJoinedRoomServerRoom) {
652 return; 647 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
765 code:kARDAppClientErrorInvalidRoom 760 code:kARDAppClientErrorInvalidRoom
766 userInfo:@{ 761 userInfo:@{
767 NSLocalizedDescriptionKey: @"Invalid room.", 762 NSLocalizedDescriptionKey: @"Invalid room.",
768 }]; 763 }];
769 break; 764 break;
770 } 765 }
771 return error; 766 return error;
772 } 767 }
773 768
774 @end 769 @end
OLDNEW
« no previous file with comments | « webrtc/api/objc/RTCVideoTrack+Private.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698