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 "ARDVideoCallView.h" | 11 #import "ARDVideoCallView.h" |
12 | 12 |
13 #import <AVFoundation/AVFoundation.h> | 13 #import <AVFoundation/AVFoundation.h> |
14 #import "UIImage+ARDUtilities.h" | 14 #import "UIImage+ARDUtilities.h" |
15 | 15 |
16 static CGFloat const kButtonPadding = 16; | 16 static CGFloat const kButtonPadding = 16; |
17 static CGFloat const kButtonSize = 48; | 17 static CGFloat const kButtonSize = 48; |
18 static CGFloat const kLocalVideoViewSize = 120; | 18 static CGFloat const kLocalVideoViewSize = 120; |
19 static CGFloat const kLocalVideoViewPadding = 8; | 19 static CGFloat const kLocalVideoViewPadding = 8; |
20 static CGFloat const kStatusBarHeight = 20; | 20 static CGFloat const kStatusBarHeight = 20; |
21 | 21 |
22 @interface ARDVideoCallView () <RTCEAGLVideoViewDelegate> | 22 @interface ARDVideoCallView () <RTCEAGLVideoViewDelegate> |
23 @end | 23 @end |
24 | 24 |
25 @implementation ARDVideoCallView { | 25 @implementation ARDVideoCallView { |
| 26 UIButton *_routeChangeButton; |
26 UIButton *_cameraSwitchButton; | 27 UIButton *_cameraSwitchButton; |
27 UIButton *_hangupButton; | 28 UIButton *_hangupButton; |
28 CGSize _remoteVideoSize; | 29 CGSize _remoteVideoSize; |
29 BOOL _useRearCamera; | 30 BOOL _useRearCamera; |
30 } | 31 } |
31 | 32 |
32 @synthesize statusLabel = _statusLabel; | 33 @synthesize statusLabel = _statusLabel; |
33 @synthesize localVideoView = _localVideoView; | 34 @synthesize localVideoView = _localVideoView; |
34 @synthesize remoteVideoView = _remoteVideoView; | 35 @synthesize remoteVideoView = _remoteVideoView; |
35 @synthesize statsView = _statsView; | 36 @synthesize statsView = _statsView; |
36 @synthesize delegate = _delegate; | 37 @synthesize delegate = _delegate; |
37 | 38 |
38 - (instancetype)initWithFrame:(CGRect)frame { | 39 - (instancetype)initWithFrame:(CGRect)frame { |
39 if (self = [super initWithFrame:frame]) { | 40 if (self = [super initWithFrame:frame]) { |
40 _remoteVideoView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectZero]; | 41 _remoteVideoView = [[RTCEAGLVideoView alloc] initWithFrame:CGRectZero]; |
41 _remoteVideoView.delegate = self; | 42 _remoteVideoView.delegate = self; |
42 [self addSubview:_remoteVideoView]; | 43 [self addSubview:_remoteVideoView]; |
43 | 44 |
44 _localVideoView = [[RTCCameraPreviewView alloc] initWithFrame:CGRectZero]; | 45 _localVideoView = [[RTCCameraPreviewView alloc] initWithFrame:CGRectZero]; |
45 [self addSubview:_localVideoView]; | 46 [self addSubview:_localVideoView]; |
46 | 47 |
47 _statsView = [[ARDStatsView alloc] initWithFrame:CGRectZero]; | 48 _statsView = [[ARDStatsView alloc] initWithFrame:CGRectZero]; |
48 _statsView.hidden = YES; | 49 _statsView.hidden = YES; |
49 [self addSubview:_statsView]; | 50 [self addSubview:_statsView]; |
50 | 51 |
| 52 _routeChangeButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
| 53 _routeChangeButton.backgroundColor = [UIColor whiteColor]; |
| 54 _routeChangeButton.layer.cornerRadius = kButtonSize / 2; |
| 55 _routeChangeButton.layer.masksToBounds = YES; |
| 56 UIImage *image = [UIImage imageNamed:@"ic_surround_sound_black_24dp.png"]; |
| 57 [_routeChangeButton setImage:image forState:UIControlStateNormal]; |
| 58 [_routeChangeButton addTarget:self |
| 59 action:@selector(onRouteChange:) |
| 60 forControlEvents:UIControlEventTouchUpInside]; |
| 61 [self addSubview:_routeChangeButton]; |
| 62 |
51 // TODO(tkchin): don't display this if we can't actually do camera switch. | 63 // TODO(tkchin): don't display this if we can't actually do camera switch. |
52 _cameraSwitchButton = [UIButton buttonWithType:UIButtonTypeCustom]; | 64 _cameraSwitchButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
53 _cameraSwitchButton.backgroundColor = [UIColor whiteColor]; | 65 _cameraSwitchButton.backgroundColor = [UIColor whiteColor]; |
54 _cameraSwitchButton.layer.cornerRadius = kButtonSize / 2; | 66 _cameraSwitchButton.layer.cornerRadius = kButtonSize / 2; |
55 _cameraSwitchButton.layer.masksToBounds = YES; | 67 _cameraSwitchButton.layer.masksToBounds = YES; |
56 UIImage *image = [UIImage imageNamed:@"ic_switch_video_black_24dp.png"]; | 68 image = [UIImage imageNamed:@"ic_switch_video_black_24dp.png"]; |
57 [_cameraSwitchButton setImage:image forState:UIControlStateNormal]; | 69 [_cameraSwitchButton setImage:image forState:UIControlStateNormal]; |
58 [_cameraSwitchButton addTarget:self | 70 [_cameraSwitchButton addTarget:self |
59 action:@selector(onCameraSwitch:) | 71 action:@selector(onCameraSwitch:) |
60 forControlEvents:UIControlEventTouchUpInside]; | 72 forControlEvents:UIControlEventTouchUpInside]; |
61 [self addSubview:_cameraSwitchButton]; | 73 [self addSubview:_cameraSwitchButton]; |
62 | 74 |
63 _hangupButton = [UIButton buttonWithType:UIButtonTypeCustom]; | 75 _hangupButton = [UIButton buttonWithType:UIButtonTypeCustom]; |
64 _hangupButton.backgroundColor = [UIColor redColor]; | 76 _hangupButton.backgroundColor = [UIColor redColor]; |
65 _hangupButton.layer.cornerRadius = kButtonSize / 2; | 77 _hangupButton.layer.cornerRadius = kButtonSize / 2; |
66 _hangupButton.layer.masksToBounds = YES; | 78 _hangupButton.layer.masksToBounds = YES; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 kButtonSize, | 145 kButtonSize, |
134 kButtonSize, | 146 kButtonSize, |
135 kButtonSize); | 147 kButtonSize); |
136 | 148 |
137 // Place button to the right of hangup button. | 149 // Place button to the right of hangup button. |
138 CGRect cameraSwitchFrame = _hangupButton.frame; | 150 CGRect cameraSwitchFrame = _hangupButton.frame; |
139 cameraSwitchFrame.origin.x = | 151 cameraSwitchFrame.origin.x = |
140 CGRectGetMaxX(cameraSwitchFrame) + kButtonPadding; | 152 CGRectGetMaxX(cameraSwitchFrame) + kButtonPadding; |
141 _cameraSwitchButton.frame = cameraSwitchFrame; | 153 _cameraSwitchButton.frame = cameraSwitchFrame; |
142 | 154 |
| 155 // Place route button to the right of camera button. |
| 156 CGRect routeChangeFrame = _cameraSwitchButton.frame; |
| 157 routeChangeFrame.origin.x = |
| 158 CGRectGetMaxX(routeChangeFrame) + kButtonPadding; |
| 159 _routeChangeButton.frame = routeChangeFrame; |
| 160 |
143 [_statusLabel sizeToFit]; | 161 [_statusLabel sizeToFit]; |
144 _statusLabel.center = | 162 _statusLabel.center = |
145 CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); | 163 CGPointMake(CGRectGetMidX(bounds), CGRectGetMidY(bounds)); |
146 } | 164 } |
147 | 165 |
148 #pragma mark - RTCEAGLVideoViewDelegate | 166 #pragma mark - RTCEAGLVideoViewDelegate |
149 | 167 |
150 - (void)videoView:(RTCEAGLVideoView*)videoView didChangeVideoSize:(CGSize)size { | 168 - (void)videoView:(RTCEAGLVideoView*)videoView didChangeVideoSize:(CGSize)size { |
151 if (videoView == _remoteVideoView) { | 169 if (videoView == _remoteVideoView) { |
152 _remoteVideoSize = size; | 170 _remoteVideoSize = size; |
153 } | 171 } |
154 [self setNeedsLayout]; | 172 [self setNeedsLayout]; |
155 } | 173 } |
156 | 174 |
157 #pragma mark - Private | 175 #pragma mark - Private |
158 | 176 |
159 - (void)onCameraSwitch:(id)sender { | 177 - (void)onCameraSwitch:(id)sender { |
160 [_delegate videoCallViewDidSwitchCamera:self]; | 178 [_delegate videoCallViewDidSwitchCamera:self]; |
161 } | 179 } |
162 | 180 |
| 181 - (void)onRouteChange:(id)sender { |
| 182 [_delegate videoCallViewDidChangeRoute:self]; |
| 183 } |
| 184 |
163 - (void)onHangup:(id)sender { | 185 - (void)onHangup:(id)sender { |
164 [_delegate videoCallViewDidHangup:self]; | 186 [_delegate videoCallViewDidHangup:self]; |
165 } | 187 } |
166 | 188 |
167 - (void)didTripleTap:(UITapGestureRecognizer *)recognizer { | 189 - (void)didTripleTap:(UITapGestureRecognizer *)recognizer { |
168 [_delegate videoCallViewDidEnableStats:self]; | 190 [_delegate videoCallViewDidEnableStats:self]; |
169 } | 191 } |
170 | 192 |
171 @end | 193 @end |
OLD | NEW |