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 |
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 Loading... |
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 RTCVideoTrack *_localVideoTrack; |
103 } | 106 } |
104 | 107 |
105 @synthesize shouldGetStats = _shouldGetStats; | 108 @synthesize shouldGetStats = _shouldGetStats; |
106 @synthesize state = _state; | 109 @synthesize state = _state; |
107 @synthesize delegate = _delegate; | 110 @synthesize delegate = _delegate; |
108 @synthesize roomServerClient = _roomServerClient; | 111 @synthesize roomServerClient = _roomServerClient; |
109 @synthesize channel = _channel; | 112 @synthesize channel = _channel; |
110 @synthesize loopbackChannel = _loopbackChannel; | 113 @synthesize loopbackChannel = _loopbackChannel; |
111 @synthesize turnClient = _turnClient; | 114 @synthesize turnClient = _turnClient; |
112 @synthesize peerConnection = _peerConnection; | 115 @synthesize peerConnection = _peerConnection; |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 [_channel sendMessage:byeMessage]; | 301 [_channel sendMessage:byeMessage]; |
299 } | 302 } |
300 // Disconnect from collider. | 303 // Disconnect from collider. |
301 _channel = nil; | 304 _channel = nil; |
302 } | 305 } |
303 _clientId = nil; | 306 _clientId = nil; |
304 _roomId = nil; | 307 _roomId = nil; |
305 _isInitiator = NO; | 308 _isInitiator = NO; |
306 _hasReceivedSdp = NO; | 309 _hasReceivedSdp = NO; |
307 _messageQueue = [NSMutableArray array]; | 310 _messageQueue = [NSMutableArray array]; |
| 311 _localVideoTrack = nil; |
308 #if defined(WEBRTC_IOS) | 312 #if defined(WEBRTC_IOS) |
309 [_factory stopAecDump]; | 313 [_factory stopAecDump]; |
310 [_peerConnection stopRtcEventLog]; | 314 [_peerConnection stopRtcEventLog]; |
311 #endif | 315 #endif |
312 _peerConnection = nil; | 316 _peerConnection = nil; |
313 self.state = kARDAppClientStateDisconnected; | 317 self.state = kARDAppClientStateDisconnected; |
314 #if defined(WEBRTC_IOS) | 318 #if defined(WEBRTC_IOS) |
315 if (kARDAppClientEnableTracing) { | 319 if (kARDAppClientEnableTracing) { |
316 RTCStopInternalCapture(); | 320 RTCStopInternalCapture(); |
317 } | 321 } |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
659 }]; | 663 }]; |
660 } else { | 664 } else { |
661 [_channel sendMessage:message]; | 665 [_channel sendMessage:message]; |
662 } | 666 } |
663 } | 667 } |
664 | 668 |
665 - (RTCRtpSender *)createVideoSender { | 669 - (RTCRtpSender *)createVideoSender { |
666 RTCRtpSender *sender = | 670 RTCRtpSender *sender = |
667 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo | 671 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindVideo |
668 streamId:kARDMediaStreamId]; | 672 streamId:kARDMediaStreamId]; |
669 RTCVideoTrack *track = [self createLocalVideoTrack]; | 673 _localVideoTrack = [self createLocalVideoTrack]; |
670 if (track) { | 674 if (_localVideoTrack) { |
671 sender.track = track; | 675 sender.track = _localVideoTrack; |
672 [_delegate appClient:self didReceiveLocalVideoTrack:track]; | 676 [_delegate appClient:self didReceiveLocalVideoTrack:_localVideoTrack]; |
673 } | 677 } |
674 | 678 |
675 return sender; | 679 return sender; |
676 } | 680 } |
677 | 681 |
678 - (void)setMaxBitrateForPeerConnectionVideoSender { | 682 - (void)setMaxBitrateForPeerConnectionVideoSender { |
679 for (RTCRtpSender *sender in _peerConnection.senders) { | 683 for (RTCRtpSender *sender in _peerConnection.senders) { |
680 if (sender.track != nil) { | 684 if (sender.track != nil) { |
681 if ([sender.track.kind isEqualToString:kARDVideoTrackKind]) { | 685 if ([sender.track.kind isEqualToString:kARDVideoTrackKind]) { |
682 [self setMaxBitrate:[_settings currentMaxBitrateSettingFromStore] forVid
eoSender:sender]; | 686 [self setMaxBitrate:[_settings currentMaxBitrateSettingFromStore] forVid
eoSender:sender]; |
(...skipping 26 matching lines...) Expand all Loading... |
709 return sender; | 713 return sender; |
710 } | 714 } |
711 | 715 |
712 - (RTCVideoTrack *)createLocalVideoTrack { | 716 - (RTCVideoTrack *)createLocalVideoTrack { |
713 RTCVideoTrack* localVideoTrack = nil; | 717 RTCVideoTrack* localVideoTrack = nil; |
714 // The iOS simulator doesn't provide any sort of camera capture | 718 // The iOS simulator doesn't provide any sort of camera capture |
715 // support or emulation (http://goo.gl/rHAnC1) so don't bother | 719 // support or emulation (http://goo.gl/rHAnC1) so don't bother |
716 // trying to open a local stream. | 720 // trying to open a local stream. |
717 #if !TARGET_IPHONE_SIMULATOR | 721 #if !TARGET_IPHONE_SIMULATOR |
718 if (!_isAudioOnly) { | 722 if (!_isAudioOnly) { |
719 RTCMediaConstraints *cameraConstraints = | 723 RTCVideoSource *source = [_factory videoSource]; |
720 [self cameraConstraints]; | 724 RTCCameraVideoCapturer *capturer = [[RTCCameraVideoCapturer alloc] initWithD
elegate:source]; |
721 RTCAVFoundationVideoSource *source = | 725 [_delegate appClient:self didCreateLocalCapturer:capturer]; |
722 [_factory avFoundationVideoSourceWithConstraints:cameraConstraints]; | |
723 localVideoTrack = | 726 localVideoTrack = |
724 [_factory videoTrackWithSource:source | 727 [_factory videoTrackWithSource:source |
725 trackId:kARDVideoTrackId]; | 728 trackId:kARDVideoTrackId]; |
726 } | 729 } |
727 #endif | 730 #endif |
728 return localVideoTrack; | 731 return localVideoTrack; |
729 } | 732 } |
730 | 733 |
731 #pragma mark - Collider methods | 734 #pragma mark - Collider methods |
732 | 735 |
(...skipping 24 matching lines...) Expand all Loading... |
757 - (RTCMediaConstraints *)defaultMediaAudioConstraints { | 760 - (RTCMediaConstraints *)defaultMediaAudioConstraints { |
758 NSString *valueLevelControl = _shouldUseLevelControl ? | 761 NSString *valueLevelControl = _shouldUseLevelControl ? |
759 kRTCMediaConstraintsValueTrue : kRTCMediaConstraintsValueFalse; | 762 kRTCMediaConstraintsValueTrue : kRTCMediaConstraintsValueFalse; |
760 NSDictionary *mandatoryConstraints = @{ kRTCMediaConstraintsLevelControl : va
lueLevelControl }; | 763 NSDictionary *mandatoryConstraints = @{ kRTCMediaConstraintsLevelControl : va
lueLevelControl }; |
761 RTCMediaConstraints *constraints = | 764 RTCMediaConstraints *constraints = |
762 [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstr
aints | 765 [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConstr
aints |
763 optionalConstraints:nil]; | 766 optionalConstraints:nil]; |
764 return constraints; | 767 return constraints; |
765 } | 768 } |
766 | 769 |
767 - (RTCMediaConstraints *)cameraConstraints { | |
768 RTCMediaConstraints *cameraConstraints = [[RTCMediaConstraints alloc] | |
769 initWithMandatoryConstraints:nil | |
770 optionalConstraints:[_settings currentMediaConstraintFromStoreAsR
TCDictionary]]; | |
771 return cameraConstraints; | |
772 } | |
773 | |
774 - (RTCMediaConstraints *)defaultAnswerConstraints { | 770 - (RTCMediaConstraints *)defaultAnswerConstraints { |
775 return [self defaultOfferConstraints]; | 771 return [self defaultOfferConstraints]; |
776 } | 772 } |
777 | 773 |
778 - (RTCMediaConstraints *)defaultOfferConstraints { | 774 - (RTCMediaConstraints *)defaultOfferConstraints { |
779 NSDictionary *mandatoryConstraints = @{ | 775 NSDictionary *mandatoryConstraints = @{ |
780 @"OfferToReceiveAudio" : @"true", | 776 @"OfferToReceiveAudio" : @"true", |
781 @"OfferToReceiveVideo" : @"true" | 777 @"OfferToReceiveVideo" : @"true" |
782 }; | 778 }; |
783 RTCMediaConstraints* constraints = | 779 RTCMediaConstraints* constraints = |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 code:kARDAppClientErrorInvalidRoom | 847 code:kARDAppClientErrorInvalidRoom |
852 userInfo:@{ | 848 userInfo:@{ |
853 NSLocalizedDescriptionKey: @"Invalid room.", | 849 NSLocalizedDescriptionKey: @"Invalid room.", |
854 }]; | 850 }]; |
855 break; | 851 break; |
856 } | 852 } |
857 return error; | 853 return error; |
858 } | 854 } |
859 | 855 |
860 @end | 856 @end |
OLD | NEW |