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

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

Issue 2778163005: Use new RTCCameraVideoCapturer in AppRTCMobile. (Closed)
Patch Set: Rename remaining media constraint references. Created 3 years, 8 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
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
11 #import "ARDAppClient+Internal.h" 11 #import "ARDAppClient+Internal.h"
12 12
13 #import "WebRTC/RTCAVFoundationVideoSource.h" 13 #import "WebRTC/RTCAVFoundationVideoSource.h"
14 #import "WebRTC/RTCAudioTrack.h" 14 #import "WebRTC/RTCAudioTrack.h"
15 #import "WebRTC/RTCCameraVideoCapturer.h"
15 #import "WebRTC/RTCConfiguration.h" 16 #import "WebRTC/RTCConfiguration.h"
16 #import "WebRTC/RTCFileLogger.h" 17 #import "WebRTC/RTCFileLogger.h"
17 #import "WebRTC/RTCIceServer.h" 18 #import "WebRTC/RTCIceServer.h"
18 #import "WebRTC/RTCLogging.h" 19 #import "WebRTC/RTCLogging.h"
19 #import "WebRTC/RTCMediaConstraints.h" 20 #import "WebRTC/RTCMediaConstraints.h"
20 #import "WebRTC/RTCMediaStream.h" 21 #import "WebRTC/RTCMediaStream.h"
21 #import "WebRTC/RTCPeerConnectionFactory.h" 22 #import "WebRTC/RTCPeerConnectionFactory.h"
22 #import "WebRTC/RTCRtpSender.h" 23 #import "WebRTC/RTCRtpSender.h"
23 #import "WebRTC/RTCTracing.h" 24 #import "WebRTC/RTCTracing.h"
25 #import "WebRTC/RTCVideoTrack.h"
24 26
25 #import "ARDAppEngineClient.h" 27 #import "ARDAppEngineClient.h"
26 #import "ARDJoinResponse.h" 28 #import "ARDJoinResponse.h"
27 #import "ARDMessageResponse.h" 29 #import "ARDMessageResponse.h"
28 #import "ARDSDPUtils.h" 30 #import "ARDSDPUtils.h"
29 #import "ARDSettingsModel.h" 31 #import "ARDSettingsModel.h"
30 #import "ARDSignalingMessage.h" 32 #import "ARDSignalingMessage.h"
31 #import "ARDTURNClient+Internal.h" 33 #import "ARDTURNClient+Internal.h"
32 #import "ARDUtilities.h" 34 #import "ARDUtilities.h"
33 #import "ARDWebSocketChannel.h" 35 #import "ARDWebSocketChannel.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 - (void)timerDidFire:(NSTimer *)timer { 95 - (void)timerDidFire:(NSTimer *)timer {
94 _timerHandler(); 96 _timerHandler();
95 } 97 }
96 98
97 @end 99 @end
98 100
99 @implementation ARDAppClient { 101 @implementation ARDAppClient {
100 RTCFileLogger *_fileLogger; 102 RTCFileLogger *_fileLogger;
101 ARDTimerProxy *_statsTimer; 103 ARDTimerProxy *_statsTimer;
102 ARDSettingsModel *_settings; 104 ARDSettingsModel *_settings;
105 RTCCameraVideoCapturer *_capturer;
106 RTCVideoTrack *_localVideoTrack;
103 } 107 }
104 108
105 @synthesize shouldGetStats = _shouldGetStats; 109 @synthesize shouldGetStats = _shouldGetStats;
106 @synthesize state = _state; 110 @synthesize state = _state;
107 @synthesize delegate = _delegate; 111 @synthesize delegate = _delegate;
108 @synthesize roomServerClient = _roomServerClient; 112 @synthesize roomServerClient = _roomServerClient;
109 @synthesize channel = _channel; 113 @synthesize channel = _channel;
110 @synthesize loopbackChannel = _loopbackChannel; 114 @synthesize loopbackChannel = _loopbackChannel;
111 @synthesize turnClient = _turnClient; 115 @synthesize turnClient = _turnClient;
112 @synthesize peerConnection = _peerConnection; 116 @synthesize peerConnection = _peerConnection;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 } 297 }
294 if (_channel) { 298 if (_channel) {
295 if (_channel.state == kARDSignalingChannelStateRegistered) { 299 if (_channel.state == kARDSignalingChannelStateRegistered) {
296 // Tell the other client we're hanging up. 300 // Tell the other client we're hanging up.
297 ARDByeMessage *byeMessage = [[ARDByeMessage alloc] init]; 301 ARDByeMessage *byeMessage = [[ARDByeMessage alloc] init];
298 [_channel sendMessage:byeMessage]; 302 [_channel sendMessage:byeMessage];
299 } 303 }
300 // Disconnect from collider. 304 // Disconnect from collider.
301 _channel = nil; 305 _channel = nil;
302 } 306 }
307 if (_capturer) {
308 [_capturer stopCapture];
309 _capturer = nil;
310 }
303 _clientId = nil; 311 _clientId = nil;
304 _roomId = nil; 312 _roomId = nil;
305 _isInitiator = NO; 313 _isInitiator = NO;
306 _hasReceivedSdp = NO; 314 _hasReceivedSdp = NO;
307 _messageQueue = [NSMutableArray array]; 315 _messageQueue = [NSMutableArray array];
316 _localVideoTrack = nil;
308 #if defined(WEBRTC_IOS) 317 #if defined(WEBRTC_IOS)
309 [_factory stopAecDump]; 318 [_factory stopAecDump];
310 [_peerConnection stopRtcEventLog]; 319 [_peerConnection stopRtcEventLog];
311 #endif 320 #endif
312 _peerConnection = nil; 321 _peerConnection = nil;
313 self.state = kARDAppClientStateDisconnected; 322 self.state = kARDAppClientStateDisconnected;
314 #if defined(WEBRTC_IOS) 323 #if defined(WEBRTC_IOS)
315 if (kARDAppClientEnableTracing) { 324 if (kARDAppClientEnableTracing) {
316 RTCStopInternalCapture(); 325 RTCStopInternalCapture();
317 } 326 }
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 }]; 668 }];
660 } else { 669 } else {
661 [_channel sendMessage:message]; 670 [_channel sendMessage:message];
662 } 671 }
663 } 672 }
664 673
665 - (RTCRtpSender *)createVideoSender { 674 - (RTCRtpSender *)createVideoSender {
666 RTCRtpSender *sender = 675 RTCRtpSender *sender =
667 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo 676 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo
668 streamId:kARDMediaStreamId]; 677 streamId:kARDMediaStreamId];
669 RTCVideoTrack *track = [self createLocalVideoTrack]; 678 _localVideoTrack = [self createLocalVideoTrack];
670 if (track) { 679 if (_localVideoTrack) {
671 sender.track = track; 680 sender.track = _localVideoTrack;
672 [_delegate appClient:self didReceiveLocalVideoTrack:track]; 681 [_delegate appClient:self didReceiveLocalVideoTrack:_localVideoTrack];
673 } 682 }
674 683
675 return sender; 684 return sender;
676 } 685 }
677 686
678 - (void)setMaxBitrateForPeerConnectionVideoSender { 687 - (void)setMaxBitrateForPeerConnectionVideoSender {
679 for (RTCRtpSender *sender in _peerConnection.senders) { 688 for (RTCRtpSender *sender in _peerConnection.senders) {
680 if (sender.track != nil) { 689 if (sender.track != nil) {
681 if ([sender.track.kind isEqualToString:kARDVideoTrackKind]) { 690 if ([sender.track.kind isEqualToString:kARDVideoTrackKind]) {
682 [self setMaxBitrate:[_settings currentMaxBitrateSettingFromStore] forVid eoSender:sender]; 691 [self setMaxBitrate:[_settings currentMaxBitrateSettingFromStore] forVid eoSender:sender];
(...skipping 26 matching lines...) Expand all
709 return sender; 718 return sender;
710 } 719 }
711 720
712 - (RTCVideoTrack *)createLocalVideoTrack { 721 - (RTCVideoTrack *)createLocalVideoTrack {
713 RTCVideoTrack* localVideoTrack = nil; 722 RTCVideoTrack* localVideoTrack = nil;
714 // The iOS simulator doesn't provide any sort of camera capture 723 // The iOS simulator doesn't provide any sort of camera capture
715 // support or emulation (http://goo.gl/rHAnC1) so don't bother 724 // support or emulation (http://goo.gl/rHAnC1) so don't bother
716 // trying to open a local stream. 725 // trying to open a local stream.
717 #if !TARGET_IPHONE_SIMULATOR 726 #if !TARGET_IPHONE_SIMULATOR
718 if (!_isAudioOnly) { 727 if (!_isAudioOnly) {
719 RTCMediaConstraints *cameraConstraints = 728 RTCVideoSource *source = [_factory videoSource];
720 [self cameraConstraints]; 729 _capturer = [[RTCCameraVideoCapturer alloc] initWithDelegate:source];
721 RTCAVFoundationVideoSource *source = 730 [_delegate appClient:self didCreateLocalCapturer:_capturer];
722 [_factory avFoundationVideoSourceWithConstraints:cameraConstraints];
723 localVideoTrack = 731 localVideoTrack =
724 [_factory videoTrackWithSource:source 732 [_factory videoTrackWithSource:source
725 trackId:kARDVideoTrackId]; 733 trackId:kARDVideoTrackId];
726 } 734 }
727 #endif 735 #endif
728 return localVideoTrack; 736 return localVideoTrack;
729 } 737 }
730 738
731 #pragma mark - Collider methods 739 #pragma mark - Collider methods
732 740
(...skipping 24 matching lines...) Expand all
757 - (RTCMediaConstraints *)defaultMediaAudioConstraints { 765 - (RTCMediaConstraints *)defaultMediaAudioConstraints {
758 NSString *valueLevelControl = _shouldUseLevelControl ? 766 NSString *valueLevelControl = _shouldUseLevelControl ?
759 kRTCMediaConstraintsValueTrue : kRTCMediaConstraintsValueFalse; 767 kRTCMediaConstraintsValueTrue : kRTCMediaConstraintsValueFalse;
760 NSDictionary *mandatoryConstraints = @{ kRTCMediaConstraintsLevelControl : va lueLevelControl }; 768 NSDictionary *mandatoryConstraints = @{ kRTCMediaConstraintsLevelControl : va lueLevelControl };
761 RTCMediaConstraints *constraints = 769 RTCMediaConstraints *constraints =
762 [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstr aints 770 [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstr aints
763 optionalConstraints:nil]; 771 optionalConstraints:nil];
764 return constraints; 772 return constraints;
765 } 773 }
766 774
767 - (RTCMediaConstraints *)cameraConstraints {
768 RTCMediaConstraints *cameraConstraints = [[RTCMediaConstraints alloc]
769 initWithMandatoryConstraints:nil
770 optionalConstraints:[_settings currentMediaConstraintFromStoreAsR TCDictionary]];
771 return cameraConstraints;
772 }
773
774 - (RTCMediaConstraints *)defaultAnswerConstraints { 775 - (RTCMediaConstraints *)defaultAnswerConstraints {
775 return [self defaultOfferConstraints]; 776 return [self defaultOfferConstraints];
776 } 777 }
777 778
778 - (RTCMediaConstraints *)defaultOfferConstraints { 779 - (RTCMediaConstraints *)defaultOfferConstraints {
779 NSDictionary *mandatoryConstraints = @{ 780 NSDictionary *mandatoryConstraints = @{
780 @"OfferToReceiveAudio" : @"true", 781 @"OfferToReceiveAudio" : @"true",
781 @"OfferToReceiveVideo" : @"true" 782 @"OfferToReceiveVideo" : @"true"
782 }; 783 };
783 RTCMediaConstraints* constraints = 784 RTCMediaConstraints* constraints =
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 code:kARDAppClientErrorInvalidRoom 852 code:kARDAppClientErrorInvalidRoom
852 userInfo:@{ 853 userInfo:@{
853 NSLocalizedDescriptionKey: @"Invalid room.", 854 NSLocalizedDescriptionKey: @"Invalid room.",
854 }]; 855 }];
855 break; 856 break;
856 } 857 }
857 return error; 858 return error;
858 } 859 }
859 860
860 @end 861 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698