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 |
11 #import "ARDVideoCallViewController.h" | 11 #import "ARDVideoCallViewController.h" |
12 | 12 |
13 #import "webrtc/base/objc/RTCDispatcher.h" | 13 #import "webrtc/base/objc/RTCDispatcher.h" |
14 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" | 14 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" |
15 | 15 |
16 #import "RTCAVFoundationVideoSource.h" | 16 #import "webrtc/api/objc/RTCAVFoundationVideoSource.h" |
17 #import "RTCLogging.h" | 17 #import "webrtc/base/objc/RTCLogging.h" |
18 | 18 |
19 #import "ARDAppClient.h" | 19 #import "ARDAppClient.h" |
20 #import "ARDVideoCallView.h" | 20 #import "ARDVideoCallView.h" |
21 | 21 |
22 @interface ARDVideoCallViewController () <ARDAppClientDelegate, | 22 @interface ARDVideoCallViewController () <ARDAppClientDelegate, |
23 ARDVideoCallViewDelegate> | 23 ARDVideoCallViewDelegate> |
24 @property(nonatomic, strong) RTCVideoTrack *localVideoTrack; | 24 @property(nonatomic, strong) RTCVideoTrack *localVideoTrack; |
25 @property(nonatomic, strong) RTCVideoTrack *remoteVideoTrack; | 25 @property(nonatomic, strong) RTCVideoTrack *remoteVideoTrack; |
26 @property(nonatomic, readonly) ARDVideoCallView *videoCallView; | 26 @property(nonatomic, readonly) ARDVideoCallView *videoCallView; |
27 @end | 27 @end |
(...skipping 16 matching lines...) Expand all Loading... |
44 isLoopback:isLoopback | 44 isLoopback:isLoopback |
45 isAudioOnly:isAudioOnly]; | 45 isAudioOnly:isAudioOnly]; |
46 } | 46 } |
47 return self; | 47 return self; |
48 } | 48 } |
49 | 49 |
50 - (void)loadView { | 50 - (void)loadView { |
51 _videoCallView = [[ARDVideoCallView alloc] initWithFrame:CGRectZero]; | 51 _videoCallView = [[ARDVideoCallView alloc] initWithFrame:CGRectZero]; |
52 _videoCallView.delegate = self; | 52 _videoCallView.delegate = self; |
53 _videoCallView.statusLabel.text = | 53 _videoCallView.statusLabel.text = |
54 [self statusTextForState:RTCICEConnectionNew]; | 54 [self statusTextForState:RTCIceConnectionStateNew]; |
55 self.view = _videoCallView; | 55 self.view = _videoCallView; |
56 } | 56 } |
57 | 57 |
58 #pragma mark - ARDAppClientDelegate | 58 #pragma mark - ARDAppClientDelegate |
59 | 59 |
60 - (void)appClient:(ARDAppClient *)client | 60 - (void)appClient:(ARDAppClient *)client |
61 didChangeState:(ARDAppClientState)state { | 61 didChangeState:(ARDAppClientState)state { |
62 switch (state) { | 62 switch (state) { |
63 case kARDAppClientStateConnected: | 63 case kARDAppClientStateConnected: |
64 RTCLog(@"Client connected."); | 64 RTCLog(@"Client connected."); |
65 break; | 65 break; |
66 case kARDAppClientStateConnecting: | 66 case kARDAppClientStateConnecting: |
67 RTCLog(@"Client connecting."); | 67 RTCLog(@"Client connecting."); |
68 break; | 68 break; |
69 case kARDAppClientStateDisconnected: | 69 case kARDAppClientStateDisconnected: |
70 RTCLog(@"Client disconnected."); | 70 RTCLog(@"Client disconnected."); |
71 [self hangup]; | 71 [self hangup]; |
72 break; | 72 break; |
73 } | 73 } |
74 } | 74 } |
75 | 75 |
76 - (void)appClient:(ARDAppClient *)client | 76 - (void)appClient:(ARDAppClient *)client |
77 didChangeConnectionState:(RTCICEConnectionState)state { | 77 didChangeConnectionState:(RTCIceConnectionState)state { |
78 RTCLog(@"ICE state changed: %d", state); | 78 RTCLog(@"ICE state changed: %ld", (long)state); |
79 __weak ARDVideoCallViewController *weakSelf = self; | 79 __weak ARDVideoCallViewController *weakSelf = self; |
80 dispatch_async(dispatch_get_main_queue(), ^{ | 80 dispatch_async(dispatch_get_main_queue(), ^{ |
81 ARDVideoCallViewController *strongSelf = weakSelf; | 81 ARDVideoCallViewController *strongSelf = weakSelf; |
82 strongSelf.videoCallView.statusLabel.text = | 82 strongSelf.videoCallView.statusLabel.text = |
83 [strongSelf statusTextForState:state]; | 83 [strongSelf statusTextForState:state]; |
84 }); | 84 }); |
85 } | 85 } |
86 | 86 |
87 - (void)appClient:(ARDAppClient *)client | 87 - (void)appClient:(ARDAppClient *)client |
88 didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack { | 88 didReceiveLocalVideoTrack:(RTCVideoTrack *)localVideoTrack { |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 _videoCallView.localVideoView.transform = avSource.useBackCamera ? | 191 _videoCallView.localVideoView.transform = avSource.useBackCamera ? |
192 CGAffineTransformIdentity : CGAffineTransformMakeScale(-1, 1); | 192 CGAffineTransformIdentity : CGAffineTransformMakeScale(-1, 1); |
193 } | 193 } |
194 } | 194 } |
195 | 195 |
196 - (NSString *)statusTextForState:(RTCICEConnectionState)state { | 196 - (NSString *)statusTextForState:(RTCIceConnectionState)state { |
197 switch (state) { | 197 switch (state) { |
198 case RTCICEConnectionNew: | 198 case RTCIceConnectionStateNew: |
199 case RTCICEConnectionChecking: | 199 case RTCIceConnectionStateChecking: |
200 return @"Connecting..."; | 200 return @"Connecting..."; |
201 case RTCICEConnectionConnected: | 201 case RTCIceConnectionStateConnected: |
202 case RTCICEConnectionCompleted: | 202 case RTCIceConnectionStateCompleted: |
203 case RTCICEConnectionFailed: | 203 case RTCIceConnectionStateFailed: |
204 case RTCICEConnectionDisconnected: | 204 case RTCIceConnectionStateDisconnected: |
205 case RTCICEConnectionClosed: | 205 case RTCIceConnectionStateClosed: |
206 case RTCICEConnectionMax: | 206 case RTCIceConnectionStateMax: |
207 return nil; | 207 return nil; |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
211 - (void)showAlertWithMessage:(NSString*)message { | 211 - (void)showAlertWithMessage:(NSString*)message { |
212 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil | 212 UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:nil |
213 message:message | 213 message:message |
214 delegate:nil | 214 delegate:nil |
215 cancelButtonTitle:@"OK" | 215 cancelButtonTitle:@"OK" |
216 otherButtonTitles:nil]; | 216 otherButtonTitles:nil]; |
217 [alertView show]; | 217 [alertView show]; |
218 } | 218 } |
219 | 219 |
220 @end | 220 @end |
OLD | NEW |