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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 @synthesize isInitiator = _isInitiator; | 124 @synthesize isInitiator = _isInitiator; |
125 @synthesize iceServers = _iceServers; | 125 @synthesize iceServers = _iceServers; |
126 @synthesize webSocketURL = _websocketURL; | 126 @synthesize webSocketURL = _websocketURL; |
127 @synthesize webSocketRestURL = _websocketRestURL; | 127 @synthesize webSocketRestURL = _websocketRestURL; |
128 @synthesize defaultPeerConnectionConstraints = | 128 @synthesize defaultPeerConnectionConstraints = |
129 _defaultPeerConnectionConstraints; | 129 _defaultPeerConnectionConstraints; |
130 @synthesize isLoopback = _isLoopback; | 130 @synthesize isLoopback = _isLoopback; |
131 @synthesize isAudioOnly = _isAudioOnly; | 131 @synthesize isAudioOnly = _isAudioOnly; |
132 @synthesize shouldMakeAecDump = _shouldMakeAecDump; | 132 @synthesize shouldMakeAecDump = _shouldMakeAecDump; |
133 @synthesize isAecDumpActive = _isAecDumpActive; | 133 @synthesize isAecDumpActive = _isAecDumpActive; |
| 134 @synthesize shouldUseLevelControl = _shouldUseLevelControl; |
134 | 135 |
135 - (instancetype)init { | 136 - (instancetype)init { |
136 if (self = [super init]) { | 137 if (self = [super init]) { |
137 _roomServerClient = [[ARDAppEngineClient alloc] init]; | 138 _roomServerClient = [[ARDAppEngineClient alloc] init]; |
138 NSURL *turnRequestURL = [NSURL URLWithString:kARDTurnRequestUrl]; | 139 NSURL *turnRequestURL = [NSURL URLWithString:kARDTurnRequestUrl]; |
139 _turnClient = [[ARDCEODTURNClient alloc] initWithURL:turnRequestURL]; | 140 _turnClient = [[ARDCEODTURNClient alloc] initWithURL:turnRequestURL]; |
140 [self configure]; | 141 [self configure]; |
141 } | 142 } |
142 return self; | 143 return self; |
143 } | 144 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 if (_state == state) { | 217 if (_state == state) { |
217 return; | 218 return; |
218 } | 219 } |
219 _state = state; | 220 _state = state; |
220 [_delegate appClient:self didChangeState:_state]; | 221 [_delegate appClient:self didChangeState:_state]; |
221 } | 222 } |
222 | 223 |
223 - (void)connectToRoomWithId:(NSString *)roomId | 224 - (void)connectToRoomWithId:(NSString *)roomId |
224 isLoopback:(BOOL)isLoopback | 225 isLoopback:(BOOL)isLoopback |
225 isAudioOnly:(BOOL)isAudioOnly | 226 isAudioOnly:(BOOL)isAudioOnly |
226 shouldMakeAecDump:(BOOL)shouldMakeAecDump { | 227 shouldMakeAecDump:(BOOL)shouldMakeAecDump |
| 228 shouldUseLevelControl:(BOOL)shouldUseLevelControl { |
227 NSParameterAssert(roomId.length); | 229 NSParameterAssert(roomId.length); |
228 NSParameterAssert(_state == kARDAppClientStateDisconnected); | 230 NSParameterAssert(_state == kARDAppClientStateDisconnected); |
229 _isLoopback = isLoopback; | 231 _isLoopback = isLoopback; |
230 _isAudioOnly = isAudioOnly; | 232 _isAudioOnly = isAudioOnly; |
231 _shouldMakeAecDump = shouldMakeAecDump; | 233 _shouldMakeAecDump = shouldMakeAecDump; |
| 234 _shouldUseLevelControl = shouldUseLevelControl; |
232 self.state = kARDAppClientStateConnecting; | 235 self.state = kARDAppClientStateConnecting; |
233 | 236 |
234 #if defined(WEBRTC_IOS) | 237 #if defined(WEBRTC_IOS) |
235 if (kARDAppClientEnableTracing) { | 238 if (kARDAppClientEnableTracing) { |
236 NSString *filePath = [self documentsFilePathForFileName:@"webrtc-trace.txt"]
; | 239 NSString *filePath = [self documentsFilePathForFileName:@"webrtc-trace.txt"]
; |
237 RTCStartInternalCapture(filePath); | 240 RTCStartInternalCapture(filePath); |
238 } | 241 } |
239 #endif | 242 #endif |
240 | 243 |
241 // Request TURN. | 244 // Request TURN. |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 streamId:kARDMediaStreamId]; | 685 streamId:kARDMediaStreamId]; |
683 RTCVideoTrack *track = [self createLocalVideoTrack]; | 686 RTCVideoTrack *track = [self createLocalVideoTrack]; |
684 if (track) { | 687 if (track) { |
685 sender.track = track; | 688 sender.track = track; |
686 [_delegate appClient:self didReceiveLocalVideoTrack:track]; | 689 [_delegate appClient:self didReceiveLocalVideoTrack:track]; |
687 } | 690 } |
688 return sender; | 691 return sender; |
689 } | 692 } |
690 | 693 |
691 - (RTCRtpSender *)createAudioSender { | 694 - (RTCRtpSender *)createAudioSender { |
| 695 RTCMediaConstraints *constraints = [self defaultMediaAudioConstraints]; |
| 696 RTCAudioSource *source = [_factory audioSourceWithConstraints:constraints]; |
| 697 RTCAudioTrack *track = [_factory audioTrackWithSource:source |
| 698 trackId:kARDAudioTrackId]; |
692 RTCRtpSender *sender = | 699 RTCRtpSender *sender = |
693 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindAudio | 700 [_peerConnection senderWithKind:kRTCMediaStreamTrackKindAudio |
694 streamId:kARDMediaStreamId]; | 701 streamId:kARDMediaStreamId]; |
695 RTCAudioTrack *track = [_factory audioTrackWithTrackId:kARDAudioTrackId]; | |
696 sender.track = track; | 702 sender.track = track; |
697 return sender; | 703 return sender; |
698 } | 704 } |
699 | 705 |
700 - (RTCVideoTrack *)createLocalVideoTrack { | 706 - (RTCVideoTrack *)createLocalVideoTrack { |
701 RTCVideoTrack* localVideoTrack = nil; | 707 RTCVideoTrack* localVideoTrack = nil; |
702 // The iOS simulator doesn't provide any sort of camera capture | 708 // The iOS simulator doesn't provide any sort of camera capture |
703 // support or emulation (http://goo.gl/rHAnC1) so don't bother | 709 // support or emulation (http://goo.gl/rHAnC1) so don't bother |
704 // trying to open a local stream. | 710 // trying to open a local stream. |
705 // TODO(tkchin): local video capture for OSX. See | 711 // TODO(tkchin): local video capture for OSX. See |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
737 } | 743 } |
738 } | 744 } |
739 [_channel registerForRoomId:_roomId clientId:_clientId]; | 745 [_channel registerForRoomId:_roomId clientId:_clientId]; |
740 if (_isLoopback) { | 746 if (_isLoopback) { |
741 [_loopbackChannel registerForRoomId:_roomId clientId:@"LOOPBACK_CLIENT_ID"]; | 747 [_loopbackChannel registerForRoomId:_roomId clientId:@"LOOPBACK_CLIENT_ID"]; |
742 } | 748 } |
743 } | 749 } |
744 | 750 |
745 #pragma mark - Defaults | 751 #pragma mark - Defaults |
746 | 752 |
| 753 - (RTCMediaConstraints *)defaultMediaAudioConstraints { |
| 754 NSString *valueLevelControl = _shouldUseLevelControl ? |
| 755 kRTCMediaConstraintsValueTrue : kRTCMediaConstraintsValueFalse; |
| 756 NSDictionary *mandatoryConstraints = @{ kRTCMediaConstraintsLevelControl : va
lueLevelControl }; |
| 757 RTCMediaConstraints* constraints = |
| 758 [[RTCMediaConstraints alloc] initWithMandatoryConstraints:mandatoryConst
raints |
| 759 optionalConstraints:nil]; |
| 760 return constraints; |
| 761 } |
| 762 |
747 - (RTCMediaConstraints *)defaultMediaStreamConstraints { | 763 - (RTCMediaConstraints *)defaultMediaStreamConstraints { |
748 RTCMediaConstraints* constraints = | 764 RTCMediaConstraints* constraints = |
749 [[RTCMediaConstraints alloc] | 765 [[RTCMediaConstraints alloc] |
750 initWithMandatoryConstraints:nil | 766 initWithMandatoryConstraints:nil |
751 optionalConstraints:nil]; | 767 optionalConstraints:nil]; |
752 return constraints; | 768 return constraints; |
753 } | 769 } |
754 | 770 |
755 - (RTCMediaConstraints *)defaultAnswerConstraints { | 771 - (RTCMediaConstraints *)defaultAnswerConstraints { |
756 return [self defaultOfferConstraints]; | 772 return [self defaultOfferConstraints]; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 code:kARDAppClientErrorInvalidRoom | 854 code:kARDAppClientErrorInvalidRoom |
839 userInfo:@{ | 855 userInfo:@{ |
840 NSLocalizedDescriptionKey: @"Invalid room.", | 856 NSLocalizedDescriptionKey: @"Invalid room.", |
841 }]; | 857 }]; |
842 break; | 858 break; |
843 } | 859 } |
844 return error; | 860 return error; |
845 } | 861 } |
846 | 862 |
847 @end | 863 @end |
OLD | NEW |