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 "APPRTCViewController.h" | 11 #import "APPRTCViewController.h" |
12 | 12 |
13 #import <AVFoundation/AVFoundation.h> | 13 #import <AVFoundation/AVFoundation.h> |
14 | 14 |
15 #import "WebRTC/RTCNSGLVideoView.h" | 15 #import "WebRTC/RTCNSGLVideoView.h" |
16 #import "WebRTC/RTCVideoTrack.h" | 16 #import "WebRTC/RTCVideoTrack.h" |
17 | 17 |
18 #import "ARDAppClient.h" | 18 #import "ARDAppClient.h" |
19 | 19 |
20 static NSUInteger const kContentWidth = 1280; | 20 static NSUInteger const kContentWidth = 900; |
21 static NSUInteger const kContentHeight = 720; | 21 static NSUInteger const kRoomFieldWidth = 200; |
22 static NSUInteger const kRoomFieldWidth = 80; | 22 static NSUInteger const kActionItemHeight = 30; |
23 static NSUInteger const kLogViewHeight = 280; | 23 static NSUInteger const kBottomViewHeight = 200; |
24 static NSUInteger const kPreviewWidth = 490; | |
25 | 24 |
26 @class APPRTCMainView; | 25 @class APPRTCMainView; |
27 @protocol APPRTCMainViewDelegate | 26 @protocol APPRTCMainViewDelegate |
28 | 27 |
29 - (void)appRTCMainView:(APPRTCMainView*)mainView | 28 - (void)appRTCMainView:(APPRTCMainView*)mainView |
tkchin_webrtc
2016/10/19 00:57:17
at some point we should change APPRTC->ARD or what
| |
30 didEnterRoomId:(NSString*)roomId; | 29 didEnterRoomId:(NSString*)roomId |
30 loopback:(BOOL)isLoopback; | |
31 | 31 |
32 @end | 32 @end |
33 | 33 |
34 @interface APPRTCMainView : NSView | 34 @interface APPRTCMainView : NSView |
35 | 35 |
36 @property(nonatomic, weak) id<APPRTCMainViewDelegate> delegate; | 36 @property(nonatomic, weak) id<APPRTCMainViewDelegate> delegate; |
37 @property(nonatomic, readonly) RTCNSGLVideoView* localVideoView; | 37 @property(nonatomic, readonly) RTCNSGLVideoView* localVideoView; |
38 @property(nonatomic, readonly) RTCNSGLVideoView* remoteVideoView; | 38 @property(nonatomic, readonly) RTCNSGLVideoView* remoteVideoView; |
39 | 39 |
40 - (void)displayLogMessage:(NSString*)message; | 40 - (void)displayLogMessage:(NSString*)message; |
41 | 41 |
42 @end | 42 @end |
43 | 43 |
44 @interface APPRTCMainView () <NSTextFieldDelegate, RTCNSGLVideoViewDelegate> | 44 @interface APPRTCMainView () <NSTextFieldDelegate, RTCNSGLVideoViewDelegate> |
45 @end | 45 @end |
46 @implementation APPRTCMainView { | 46 @implementation APPRTCMainView { |
47 NSScrollView* _scrollView; | 47 NSScrollView* _scrollView; |
48 NSTextField* _roomLabel; | 48 NSView* _actionItemsView; |
49 NSButton* _connectButton; | |
50 NSButton* _loopbackButton; | |
49 NSTextField* _roomField; | 51 NSTextField* _roomField; |
50 NSTextView* _logView; | 52 NSTextView* _logView; |
51 CGSize _localVideoSize; | 53 CGSize _localVideoSize; |
52 CGSize _remoteVideoSize; | 54 CGSize _remoteVideoSize; |
53 } | 55 } |
54 | 56 |
55 @synthesize delegate = _delegate; | 57 @synthesize delegate = _delegate; |
56 @synthesize localVideoView = _localVideoView; | 58 @synthesize localVideoView = _localVideoView; |
57 @synthesize remoteVideoView = _remoteVideoView; | 59 @synthesize remoteVideoView = _remoteVideoView; |
58 | 60 |
59 + (BOOL)requiresConstraintBasedLayout { | 61 |
60 return YES; | 62 - (void)displayLogMessage:(NSString*)message { |
tkchin_webrtc
2016/10/19 00:57:17
NSString *)
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
63 _logView.string = | |
64 [NSString stringWithFormat:@"%@%@\n", _logView.string, message]; | |
magjed_webrtc
2016/10/17 15:22:41
nit: This line should be indented with 4 spaces.
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
65 NSRange range = NSMakeRange([_logView.string length], 0); | |
tkchin_webrtc
2016/10/19 00:57:17
nit: dot syntax for properties
(when using dot sy
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
66 [_logView scrollRangeToVisible:range]; | |
61 } | 67 } |
62 | 68 |
69 #pragma mark - Internal | |
tkchin_webrtc
2016/10/19 00:57:17
we've usually called it - Private
there are a bunc
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
70 | |
63 - (instancetype)initWithFrame:(NSRect)frame { | 71 - (instancetype)initWithFrame:(NSRect)frame { |
64 if (self = [super initWithFrame:frame]) { | 72 if (self = [super initWithFrame:frame]) { |
65 [self setupViews]; | 73 [self setupViews]; |
66 } | 74 } |
67 return self; | 75 return self; |
68 } | 76 } |
69 | 77 |
78 + (BOOL)requiresConstraintBasedLayout { | |
79 return YES; | |
80 } | |
81 | |
70 - (void)updateConstraints { | 82 - (void)updateConstraints { |
71 NSParameterAssert( | 83 NSParameterAssert( |
tkchin_webrtc
2016/10/19 00:57:17
consider filing a bug to replace NSParameterAssert
daniela-webrtc
2016/10/19 14:45:13
https://bugs.chromium.org/p/webrtc/issues/detail?i
| |
72 _roomField != nil && _scrollView != nil && _remoteVideoView != nil); | 84 _roomField != nil && |
85 _scrollView != nil && | |
86 _remoteVideoView != nil && | |
87 _localVideoView != nil && | |
88 _actionItemsView!= nil && | |
89 _connectButton != nil && | |
90 _loopbackButton != nil); | |
91 | |
73 [self removeConstraints:[self constraints]]; | 92 [self removeConstraints:[self constraints]]; |
74 NSDictionary* viewsDictionary = | 93 NSDictionary* viewsDictionary = |
75 NSDictionaryOfVariableBindings(_roomLabel, | 94 NSDictionaryOfVariableBindings(_roomField, |
76 _roomField, | |
77 _scrollView, | 95 _scrollView, |
78 _remoteVideoView, | 96 _remoteVideoView, |
79 _localVideoView); | 97 _localVideoView, |
98 _actionItemsView, | |
99 _connectButton, | |
100 _loopbackButton); | |
80 | 101 |
81 NSSize remoteViewSize = [self remoteVideoViewSize]; | 102 NSSize remoteViewSize = [self remoteVideoViewSize]; |
82 NSDictionary* metrics = @{ | 103 NSDictionary* metrics = @{ |
83 @"kLogViewHeight" : @(kLogViewHeight), | |
84 @"kPreviewWidth" : @(kPreviewWidth), | |
85 @"kRoomFieldWidth" : @(kRoomFieldWidth), | |
86 @"remoteViewWidth" : @(remoteViewSize.width), | 104 @"remoteViewWidth" : @(remoteViewSize.width), |
87 @"remoteViewHeight" : @(remoteViewSize.height), | 105 @"remoteViewHeight" : @(remoteViewSize.height), |
88 @"localViewHeight" : @(remoteViewSize.height), | 106 @"kBottomViewHeight" : @(kBottomViewHeight), |
89 @"scrollViewWidth" : @(kContentWidth - kPreviewWidth), | 107 @"localViewHeight" : @(remoteViewSize.height/3), |
tkchin_webrtc
2016/10/19 00:57:17
nit .height / 3
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
108 @"localViewWidth" : @(remoteViewSize.width/3), | |
109 @"kRoomFieldWidth" : @(kRoomFieldWidth), | |
110 @"kActionItemHeight" : @(kActionItemHeight) | |
90 }; | 111 }; |
91 // Declare this separately to avoid compiler warning about splitting string | 112 // Declare this separately to avoid compiler warning about splitting string |
92 // within an NSArray expression. | 113 // within an NSArray expression. |
93 NSString* verticalConstraint = | 114 NSString* verticalConstraintLeft = |
tkchin_webrtc
2016/10/19 00:57:17
NSString *vertical
ditto for rest of file. I know
daniela-webrtc
2016/10/19 14:45:13
Bug filled
https://bugs.chromium.org/p/webrtc/iss
| |
94 @"V:|-[_roomLabel]-[_roomField]-[_scrollView(kLogViewHeight)]" | 115 @"V:|-[_remoteVideoView(remoteViewHeight)]-[_scrollView(kBottomViewHeight) ]-|"; |
95 "-[_remoteVideoView(remoteViewHeight)]-|"; | 116 NSString* verticalConstraintRight = |
117 @"V:|-[_remoteVideoView(remoteViewHeight)]-[_actionItemsView(kBottomViewHe ight)]-|"; | |
96 NSArray* constraintFormats = @[ | 118 NSArray* constraintFormats = @[ |
97 verticalConstraint, | 119 verticalConstraintLeft, |
98 @"V:[_localVideoView]-[_remoteVideoView]", | 120 verticalConstraintRight, |
99 @"V:[_localVideoView(kLogViewHeight)]", | 121 @"H:|-[_remoteVideoView(remoteViewWidth)]-|", |
tkchin_webrtc
2016/10/19 00:57:17
not looking too closely at these, if they work the
| |
100 @"|-[_roomLabel]", | 122 @"V:|-[_localVideoView(localViewHeight)]", |
101 @"|-[_roomField(kRoomFieldWidth)]", | 123 @"H:|-[_localVideoView(localViewWidth)]", |
102 @"|-[_scrollView(scrollViewWidth)]", | 124 @"H:|-[_scrollView(==_actionItemsView)]-[_actionItemsView]-|" |
103 @"[_scrollView]-[_localVideoView]", | |
104 @"|-[_remoteVideoView(remoteViewWidth)]-|", | |
105 @"[_localVideoView(kPreviewWidth)]-|", | |
106 ]; | 125 ]; |
107 for (NSString* constraintFormat in constraintFormats) { | 126 |
108 NSArray* constraints = | 127 NSArray* actionItemsConstraints = @[ |
109 [NSLayoutConstraint constraintsWithVisualFormat:constraintFormat | 128 @"H:|-[_roomField(kRoomFieldWidth)]-[_loopbackButton(kRoomFieldWidth)]", |
110 options:0 | 129 @"H:|-[_connectButton(kRoomFieldWidth)]", |
111 metrics:metrics | 130 @"V:|-[_roomField(kActionItemHeight)]-[_connectButton(kActionItemHeight)]" , |
112 views:viewsDictionary]; | 131 @"V:|-[_loopbackButton(kActionItemHeight)]", |
113 for (NSLayoutConstraint* constraint in constraints) { | 132 ]; |
114 [self addConstraint:constraint]; | 133 |
115 } | 134 [APPRTCMainView addConstraints:constraintFormats |
116 } | 135 toView:self |
136 viewsDictionary:viewsDictionary | |
137 metrics:metrics]; | |
138 [APPRTCMainView addConstraints:actionItemsConstraints | |
139 toView:_actionItemsView | |
140 viewsDictionary:viewsDictionary | |
141 metrics:metrics]; | |
117 [super updateConstraints]; | 142 [super updateConstraints]; |
118 } | 143 } |
119 | 144 |
120 - (void)displayLogMessage:(NSString*)message { | 145 #pragma mark - Constraints helper |
121 _logView.string = | |
122 [NSString stringWithFormat:@"%@%@\n", _logView.string, message]; | |
123 NSRange range = NSMakeRange([_logView.string length], 0); | |
124 [_logView scrollRangeToVisible:range]; | |
125 } | |
126 | 146 |
127 #pragma mark - NSControl delegate | 147 + (void)addConstraints:(NSArray*)constraints toView:(NSView*)view |
128 | 148 viewsDictionary:(NSDictionary*)viewsDictionary |
129 - (void)controlTextDidEndEditing:(NSNotification*)notification { | 149 metrics:(NSDictionary*)metrics{ |
kthelgason
2016/10/17 09:30:09
nit: missing space
| |
130 NSDictionary* userInfo = [notification userInfo]; | 150 for (NSString* constraintFormat in constraints) { |
131 NSInteger textMovement = [userInfo[@"NSTextMovement"] intValue]; | 151 NSArray* constraints = |
132 if (textMovement == NSReturnTextMovement) { | 152 [NSLayoutConstraint constraintsWithVisualFormat:constraintFormat |
133 [self.delegate appRTCMainView:self didEnterRoomId:_roomField.stringValue]; | 153 options:0 |
154 metrics:metrics | |
155 views:viewsDictionary]; | |
156 for (NSLayoutConstraint* constraint in constraints) { | |
157 [view addConstraint:constraint]; | |
158 } | |
134 } | 159 } |
135 } | 160 } |
136 | 161 |
162 #pragma mark - Control actions | |
163 | |
164 - (void)startCall:(id)sender { | |
165 | |
tkchin_webrtc
2016/10/19 00:57:17
nit: remove blank line
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
166 NSString* roomString = _roomField.stringValue; | |
167 //generate room id for loopback options | |
magjed_webrtc
2016/10/17 15:22:41
nit: You should format your comment like:
// Gener
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
168 if (_loopbackButton.intValue && [roomString isEqualToString:@""]) { | |
169 roomString = [[NSUUID UUID] UUIDString]; | |
tkchin_webrtc
2016/10/19 00:57:16
ditto dot syntax for properties
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
170 roomString = [roomString stringByReplacingOccurrencesOfString:@"-" withStrin g:@""]; | |
171 } | |
172 | |
173 [self.delegate appRTCMainView:self | |
174 didEnterRoomId:roomString | |
175 loopback:_loopbackButton.intValue]; | |
176 } | |
177 | |
137 #pragma mark - RTCNSGLVideoViewDelegate | 178 #pragma mark - RTCNSGLVideoViewDelegate |
138 | 179 |
139 - (void)videoView:(RTCNSGLVideoView*)videoView | 180 - (void)videoView:(RTCNSGLVideoView*)videoView |
140 didChangeVideoSize:(NSSize)size { | 181 didChangeVideoSize:(NSSize)size { |
141 if (videoView == _remoteVideoView) { | 182 if (videoView == _remoteVideoView) { |
142 _remoteVideoSize = size; | 183 _remoteVideoSize = size; |
143 } else if (videoView == _localVideoView) { | 184 } else if (videoView == _localVideoView) { |
144 _localVideoSize = size; | 185 _localVideoSize = size; |
145 } else { | 186 } else { |
146 return; | 187 return; |
147 } | 188 } |
189 | |
148 [self setNeedsUpdateConstraints:YES]; | 190 [self setNeedsUpdateConstraints:YES]; |
149 } | 191 } |
150 | 192 |
151 #pragma mark - Private | 193 #pragma mark - Private |
152 | 194 |
153 - (void)setupViews { | 195 - (void)setupViews { |
154 NSParameterAssert([[self subviews] count] == 0); | 196 NSParameterAssert([[self subviews] count] == 0); |
155 | 197 |
156 _roomLabel = [[NSTextField alloc] initWithFrame:NSZeroRect]; | |
157 [_roomLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
158 [_roomLabel setBezeled:NO]; | |
159 [_roomLabel setDrawsBackground:NO]; | |
160 [_roomLabel setEditable:NO]; | |
161 [_roomLabel setStringValue:@"Enter AppRTC room id:"]; | |
162 [self addSubview:_roomLabel]; | |
163 | |
164 _roomField = [[NSTextField alloc] initWithFrame:NSZeroRect]; | |
165 [_roomField setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
166 [self addSubview:_roomField]; | |
167 [_roomField setEditable:YES]; | |
168 [_roomField setDelegate:self]; | |
169 | |
170 _logView = [[NSTextView alloc] initWithFrame:NSZeroRect]; | 198 _logView = [[NSTextView alloc] initWithFrame:NSZeroRect]; |
171 [_logView setMinSize:NSMakeSize(0, kLogViewHeight)]; | 199 [_logView setMinSize:NSMakeSize(0, kBottomViewHeight)]; |
172 [_logView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; | 200 [_logView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)]; |
173 [_logView setVerticallyResizable:YES]; | 201 [_logView setVerticallyResizable:YES]; |
174 [_logView setAutoresizingMask:NSViewWidthSizable]; | 202 [_logView setAutoresizingMask:NSViewWidthSizable]; |
175 NSTextContainer* textContainer = [_logView textContainer]; | 203 NSTextContainer* textContainer = [_logView textContainer]; |
176 NSSize containerSize = NSMakeSize(kContentWidth, FLT_MAX); | 204 NSSize containerSize = NSMakeSize(kContentWidth, FLT_MAX); |
177 [textContainer setContainerSize:containerSize]; | 205 [textContainer setContainerSize:containerSize]; |
178 [textContainer setWidthTracksTextView:YES]; | 206 [textContainer setWidthTracksTextView:YES]; |
179 [_logView setEditable:NO]; | 207 [_logView setEditable:NO]; |
180 | 208 |
209 [self setupActionItemsView]; | |
210 | |
181 _scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect]; | 211 _scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect]; |
182 [_scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 212 [_scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
183 [_scrollView setHasVerticalScroller:YES]; | 213 [_scrollView setHasVerticalScroller:YES]; |
184 [_scrollView setDocumentView:_logView]; | 214 [_scrollView setDocumentView:_logView]; |
185 [self addSubview:_scrollView]; | 215 [self addSubview:_scrollView]; |
186 | 216 |
187 NSOpenGLPixelFormatAttribute attributes[] = { | 217 NSOpenGLPixelFormatAttribute attributes[] = { |
188 NSOpenGLPFADoubleBuffer, | 218 NSOpenGLPFADoubleBuffer, |
189 NSOpenGLPFADepthSize, 24, | 219 NSOpenGLPFADepthSize, 24, |
190 NSOpenGLPFAOpenGLProfile, | 220 NSOpenGLPFAOpenGLProfile, |
191 NSOpenGLProfileVersion3_2Core, | 221 NSOpenGLProfileVersion3_2Core, |
192 0 | 222 0 |
193 }; | 223 }; |
194 NSOpenGLPixelFormat* pixelFormat = | 224 NSOpenGLPixelFormat* pixelFormat = |
195 [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; | 225 [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; |
196 _remoteVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect | 226 _remoteVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect |
197 pixelFormat:pixelFormat]; | 227 pixelFormat:pixelFormat]; |
198 [_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 228 [_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
199 _remoteVideoView.delegate = self; | 229 _remoteVideoView.delegate = self; |
200 [self addSubview:_remoteVideoView]; | 230 [self addSubview:_remoteVideoView]; |
201 | 231 |
202 _localVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect | 232 _localVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect |
203 pixelFormat:pixelFormat]; | 233 pixelFormat:pixelFormat]; |
204 [_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 234 [_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
205 _localVideoView.delegate = self; | 235 _localVideoView.delegate = self; |
206 [self addSubview:_localVideoView]; | 236 [self addSubview:_localVideoView]; |
207 } | 237 } |
208 | 238 |
239 - (void)setupActionItemsView { | |
240 _actionItemsView = [[NSView alloc] initWithFrame:NSZeroRect]; | |
241 [_actionItemsView setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
242 [self addSubview:_actionItemsView]; | |
243 | |
244 _roomField = [[NSTextField alloc] initWithFrame:NSZeroRect]; | |
245 [_roomField setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
246 _roomField.placeholderString = @"Enter AppRTC room id"; | |
247 [_actionItemsView addSubview:_roomField]; | |
248 [_roomField setEditable:YES]; | |
249 | |
250 _connectButton = [[NSButton alloc] initWithFrame:NSZeroRect]; | |
251 [_connectButton setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
252 _connectButton.title = @"Start call"; | |
253 _connectButton.bezelStyle = NSRoundedBezelStyle; | |
254 _connectButton.target = self; | |
255 _connectButton.action = @selector(startCall:); | |
256 [_actionItemsView addSubview:_connectButton]; | |
257 | |
258 _loopbackButton = [[NSButton alloc] initWithFrame:NSZeroRect]; | |
259 [_loopbackButton setTranslatesAutoresizingMaskIntoConstraints:NO]; | |
260 _loopbackButton.title = @"Loopback"; | |
261 [_loopbackButton setButtonType:NSSwitchButton]; | |
262 [_actionItemsView addSubview:_loopbackButton]; | |
263 } | |
264 | |
209 - (NSSize)remoteVideoViewSize { | 265 - (NSSize)remoteVideoViewSize { |
210 NSInteger width = MAX(_remoteVideoSize.width, kContentWidth); | 266 if (!_remoteVideoView.bounds.size.width) { |
267 return NSMakeSize(kContentWidth, 0); | |
268 } | |
269 NSInteger width = MAX(_remoteVideoView.bounds.size.width, kContentWidth); | |
211 NSInteger height = (width/16) * 9; | 270 NSInteger height = (width/16) * 9; |
212 return NSMakeSize(width, height); | 271 return NSMakeSize(width, height); |
213 } | 272 } |
214 | 273 |
215 @end | 274 @end |
216 | 275 |
217 @interface APPRTCViewController () | 276 @interface APPRTCViewController () |
218 <ARDAppClientDelegate, APPRTCMainViewDelegate> | 277 <ARDAppClientDelegate, APPRTCMainViewDelegate> |
219 @property(nonatomic, readonly) APPRTCMainView* mainView; | 278 @property(nonatomic, readonly) APPRTCMainView* mainView; |
220 @end | 279 @end |
221 | 280 |
222 @implementation APPRTCViewController { | 281 @implementation APPRTCViewController { |
223 ARDAppClient* _client; | 282 ARDAppClient* _client; |
224 RTCVideoTrack* _localVideoTrack; | 283 RTCVideoTrack* _localVideoTrack; |
225 RTCVideoTrack* _remoteVideoTrack; | 284 RTCVideoTrack* _remoteVideoTrack; |
226 } | 285 } |
227 | 286 |
228 - (void)dealloc { | 287 - (void)dealloc { |
229 [self disconnect]; | 288 [self disconnect]; |
230 } | 289 } |
231 | 290 |
291 - (void)viewDidAppear { | |
292 [super viewDidAppear]; | |
293 [self displayUsageInstructions]; | |
294 } | |
295 | |
232 - (void)loadView { | 296 - (void)loadView { |
233 APPRTCMainView* view = [[APPRTCMainView alloc] initWithFrame:NSZeroRect]; | 297 APPRTCMainView* view = [[APPRTCMainView alloc] initWithFrame:NSZeroRect]; |
234 [view setTranslatesAutoresizingMaskIntoConstraints:NO]; | 298 [view setTranslatesAutoresizingMaskIntoConstraints:NO]; |
235 view.delegate = self; | 299 view.delegate = self; |
236 self.view = view; | 300 self.view = view; |
237 } | 301 } |
238 | 302 |
239 - (void)windowWillClose:(NSNotification*)notification { | 303 - (void)windowWillClose:(NSNotification*)notification { |
240 [self disconnect]; | 304 [self disconnect]; |
241 } | 305 } |
242 | 306 |
307 #pragma mark - Usage | |
308 | |
309 - (void)displayUsageInstructions { | |
310 [self.mainView displayLogMessage: | |
tkchin_webrtc
2016/10/19 00:57:17
might be worth just having this as a label somewhe
| |
311 @"To start call:\n" | |
312 @"• Enter AppRTC room id\n" | |
313 @"• Loopback with or without AppRTC room id"]; | |
magjed_webrtc
2016/10/17 15:22:41
nit: I found this instruction slightly confusing.
daniela-webrtc
2016/10/19 14:45:13
Done.
| |
314 } | |
315 | |
243 #pragma mark - ARDAppClientDelegate | 316 #pragma mark - ARDAppClientDelegate |
244 | 317 |
245 - (void)appClient:(ARDAppClient *)client | 318 - (void)appClient:(ARDAppClient *)client |
246 didChangeState:(ARDAppClientState)state { | 319 didChangeState:(ARDAppClientState)state { |
247 switch (state) { | 320 switch (state) { |
248 case kARDAppClientStateConnected: | 321 case kARDAppClientStateConnected: |
249 NSLog(@"Client connected."); | 322 [self.mainView displayLogMessage:@"Client connected."]; |
250 break; | 323 break; |
251 case kARDAppClientStateConnecting: | 324 case kARDAppClientStateConnecting: |
252 NSLog(@"Client connecting."); | 325 [self.mainView displayLogMessage:@"Client connecting."]; |
253 break; | 326 break; |
254 case kARDAppClientStateDisconnected: | 327 case kARDAppClientStateDisconnected: |
255 NSLog(@"Client disconnected."); | 328 [self.mainView displayLogMessage:@"Client disconnected."]; |
256 [self resetUI]; | 329 [self resetUI]; |
257 _client = nil; | 330 _client = nil; |
258 break; | 331 break; |
259 } | 332 } |
260 } | 333 } |
261 | 334 |
262 - (void)appClient:(ARDAppClient *)client | 335 - (void)appClient:(ARDAppClient *)client |
263 didChangeConnectionState:(RTCIceConnectionState)state { | 336 didChangeConnectionState:(RTCIceConnectionState)state { |
264 } | 337 } |
265 | 338 |
(...skipping 15 matching lines...) Expand all Loading... | |
281 [self disconnect]; | 354 [self disconnect]; |
282 } | 355 } |
283 | 356 |
284 - (void)appClient:(ARDAppClient *)client | 357 - (void)appClient:(ARDAppClient *)client |
285 didGetStats:(NSArray *)stats { | 358 didGetStats:(NSArray *)stats { |
286 } | 359 } |
287 | 360 |
288 #pragma mark - APPRTCMainViewDelegate | 361 #pragma mark - APPRTCMainViewDelegate |
289 | 362 |
290 - (void)appRTCMainView:(APPRTCMainView*)mainView | 363 - (void)appRTCMainView:(APPRTCMainView*)mainView |
291 didEnterRoomId:(NSString*)roomId { | 364 didEnterRoomId:(NSString*)roomId |
365 loopback:(BOOL)isLoopback { | |
366 | |
367 if ([roomId isEqualToString:@""]) { | |
368 [self.mainView displayLogMessage:@"Missing room id"]; | |
369 return; | |
370 } | |
371 | |
292 [_client disconnect]; | 372 [_client disconnect]; |
293 ARDAppClient *client = [[ARDAppClient alloc] initWithDelegate:self]; | 373 ARDAppClient *client = [[ARDAppClient alloc] initWithDelegate:self]; |
294 [client connectToRoomWithId:roomId | 374 [client connectToRoomWithId:roomId |
295 isLoopback:NO | 375 isLoopback:isLoopback |
296 isAudioOnly:NO | 376 isAudioOnly:NO |
297 shouldMakeAecDump:NO | 377 shouldMakeAecDump:NO |
298 shouldUseLevelControl:NO]; | 378 shouldUseLevelControl:NO]; |
299 _client = client; | 379 _client = client; |
300 } | 380 } |
301 | 381 |
302 #pragma mark - Private | 382 #pragma mark - Private |
303 | 383 |
304 - (APPRTCMainView*)mainView { | 384 - (APPRTCMainView*)mainView { |
305 return (APPRTCMainView*)self.view; | 385 return (APPRTCMainView*)self.view; |
(...skipping 13 matching lines...) Expand all Loading... | |
319 [self.mainView.remoteVideoView renderFrame:nil]; | 399 [self.mainView.remoteVideoView renderFrame:nil]; |
320 [self.mainView.localVideoView renderFrame:nil]; | 400 [self.mainView.localVideoView renderFrame:nil]; |
321 } | 401 } |
322 | 402 |
323 - (void)disconnect { | 403 - (void)disconnect { |
324 [self resetUI]; | 404 [self resetUI]; |
325 [_client disconnect]; | 405 [_client disconnect]; |
326 } | 406 } |
327 | 407 |
328 @end | 408 @end |
OLD | NEW |