OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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 16 matching lines...) Expand all Loading... |
27 @end | 27 @end |
28 | 28 |
29 @implementation ARDVideoCallViewController { | 29 @implementation ARDVideoCallViewController { |
30 ARDAppClient *_client; | 30 ARDAppClient *_client; |
31 RTCVideoTrack *_remoteVideoTrack; | 31 RTCVideoTrack *_remoteVideoTrack; |
32 RTCVideoTrack *_localVideoTrack; | 32 RTCVideoTrack *_localVideoTrack; |
33 AVAudioSessionPortOverride _portOverride; | 33 AVAudioSessionPortOverride _portOverride; |
34 } | 34 } |
35 | 35 |
36 @synthesize videoCallView = _videoCallView; | 36 @synthesize videoCallView = _videoCallView; |
| 37 @synthesize delegate = _delegate; |
37 | 38 |
38 - (instancetype)initForRoom:(NSString *)room | 39 - (instancetype)initForRoom:(NSString *)room |
39 isLoopback:(BOOL)isLoopback | 40 isLoopback:(BOOL)isLoopback |
40 isAudioOnly:(BOOL)isAudioOnly { | 41 isAudioOnly:(BOOL)isAudioOnly |
| 42 delegate:(id<ARDVideoCallViewControllerDelegate>)delegate { |
41 if (self = [super init]) { | 43 if (self = [super init]) { |
| 44 _delegate = delegate; |
42 _client = [[ARDAppClient alloc] initWithDelegate:self]; | 45 _client = [[ARDAppClient alloc] initWithDelegate:self]; |
43 [_client connectToRoomWithId:room | 46 [_client connectToRoomWithId:room |
44 isLoopback:isLoopback | 47 isLoopback:isLoopback |
45 isAudioOnly:isAudioOnly]; | 48 isAudioOnly:isAudioOnly]; |
46 } | 49 } |
47 return self; | 50 return self; |
48 } | 51 } |
49 | 52 |
50 - (void)loadView { | 53 - (void)loadView { |
51 _videoCallView = [[ARDVideoCallView alloc] initWithFrame:CGRectZero]; | 54 _videoCallView = [[ARDVideoCallView alloc] initWithFrame:CGRectZero]; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 _remoteVideoTrack = nil; | 173 _remoteVideoTrack = nil; |
171 [_videoCallView.remoteVideoView renderFrame:nil]; | 174 [_videoCallView.remoteVideoView renderFrame:nil]; |
172 _remoteVideoTrack = remoteVideoTrack; | 175 _remoteVideoTrack = remoteVideoTrack; |
173 [_remoteVideoTrack addRenderer:_videoCallView.remoteVideoView]; | 176 [_remoteVideoTrack addRenderer:_videoCallView.remoteVideoView]; |
174 } | 177 } |
175 | 178 |
176 - (void)hangup { | 179 - (void)hangup { |
177 self.remoteVideoTrack = nil; | 180 self.remoteVideoTrack = nil; |
178 self.localVideoTrack = nil; | 181 self.localVideoTrack = nil; |
179 [_client disconnect]; | 182 [_client disconnect]; |
180 if (![self isBeingDismissed]) { | 183 [_delegate viewControllerDidFinish:self]; |
181 [self.presentingViewController dismissViewControllerAnimated:YES | |
182 completion:nil]; | |
183 } | |
184 } | 184 } |
185 | 185 |
186 - (void)switchCamera { | 186 - (void)switchCamera { |
187 RTCVideoSource* source = self.localVideoTrack.source; | 187 RTCVideoSource* source = self.localVideoTrack.source; |
188 if ([source isKindOfClass:[RTCAVFoundationVideoSource class]]) { | 188 if ([source isKindOfClass:[RTCAVFoundationVideoSource class]]) { |
189 RTCAVFoundationVideoSource* avSource = (RTCAVFoundationVideoSource*)source; | 189 RTCAVFoundationVideoSource* avSource = (RTCAVFoundationVideoSource*)source; |
190 avSource.useBackCamera = !avSource.useBackCamera; | 190 avSource.useBackCamera = !avSource.useBackCamera; |
191 } | 191 } |
192 } | 192 } |
193 | 193 |
(...skipping 15 matching lines...) Expand all Loading... |
209 - (void)showAlertWithMessage:(NSString*)message { | 209 - (void)showAlertWithMessage:(NSString*)message { |
210 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil | 210 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil |
211 message:message | 211 message:message |
212 delegate:nil | 212 delegate:nil |
213 cancelButtonTitle:@"OK" | 213 cancelButtonTitle:@"OK" |
214 otherButtonTitles:nil]; | 214 otherButtonTitles:nil]; |
215 [alertView show]; | 215 [alertView show]; |
216 } | 216 } |
217 | 217 |
218 @end | 218 @end |
OLD | NEW |