Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: webrtc/examples/objc/AppRTCMobile/mac/APPRTCViewController.m

Issue 2778693003: MacOS: Add metal renderer and view. (Closed)
Patch Set: Address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/RTCMTLNSVideoView.h"
15 #import "WebRTC/RTCNSGLVideoView.h" 16 #import "WebRTC/RTCNSGLVideoView.h"
16 #import "WebRTC/RTCVideoTrack.h" 17 #import "WebRTC/RTCVideoTrack.h"
17 18
18 #import "ARDAppClient.h" 19 #import "ARDAppClient.h"
19 20
20 static NSUInteger const kContentWidth = 900; 21 static NSUInteger const kContentWidth = 900;
21 static NSUInteger const kRoomFieldWidth = 200; 22 static NSUInteger const kRoomFieldWidth = 200;
22 static NSUInteger const kActionItemHeight = 30; 23 static NSUInteger const kActionItemHeight = 30;
23 static NSUInteger const kBottomViewHeight = 200; 24 static NSUInteger const kBottomViewHeight = 200;
24 25
25 @class APPRTCMainView; 26 @class APPRTCMainView;
26 @protocol APPRTCMainViewDelegate 27 @protocol APPRTCMainViewDelegate
27 28
28 - (void)appRTCMainView:(APPRTCMainView*)mainView 29 - (void)appRTCMainView:(APPRTCMainView*)mainView
29 didEnterRoomId:(NSString*)roomId 30 didEnterRoomId:(NSString*)roomId
30 loopback:(BOOL)isLoopback; 31 loopback:(BOOL)isLoopback;
31 32
32 @end 33 @end
33 34
34 @interface APPRTCMainView : NSView 35 @interface APPRTCMainView : NSView
35 36
36 @property(nonatomic, weak) id<APPRTCMainViewDelegate> delegate; 37 @property(nonatomic, weak) id<APPRTCMainViewDelegate> delegate;
37 @property(nonatomic, readonly) RTCNSGLVideoView* localVideoView; 38 @property(nonatomic, readonly) NSView<RTCVideoRenderer>* localVideoView;
38 @property(nonatomic, readonly) RTCNSGLVideoView* remoteVideoView; 39 @property(nonatomic, readonly) NSView<RTCVideoRenderer>* remoteVideoView;
39 40
40 - (void)displayLogMessage:(NSString*)message; 41 - (void)displayLogMessage:(NSString*)message;
41 42
42 @end 43 @end
43 44
44 @interface APPRTCMainView () <NSTextFieldDelegate, RTCNSGLVideoViewDelegate> 45 @interface APPRTCMainView () <NSTextFieldDelegate, RTCNSGLVideoViewDelegate>
45 @end 46 @end
46 @implementation APPRTCMainView { 47 @implementation APPRTCMainView {
47 NSScrollView* _scrollView; 48 NSScrollView* _scrollView;
48 NSView* _actionItemsView; 49 NSView* _actionItemsView;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 162
162 #pragma mark - Control actions 163 #pragma mark - Control actions
163 164
164 - (void)startCall:(id)sender { 165 - (void)startCall:(id)sender {
165 NSString* roomString = _roomField.stringValue; 166 NSString* roomString = _roomField.stringValue;
166 // Generate room id for loopback options. 167 // Generate room id for loopback options.
167 if (_loopbackButton.intValue && [roomString isEqualToString:@""]) { 168 if (_loopbackButton.intValue && [roomString isEqualToString:@""]) {
168 roomString = [NSUUID UUID].UUIDString; 169 roomString = [NSUUID UUID].UUIDString;
169 roomString = [roomString stringByReplacingOccurrencesOfString:@"-" withStrin g:@""]; 170 roomString = [roomString stringByReplacingOccurrencesOfString:@"-" withStrin g:@""];
170 } 171 }
171
172 [self.delegate appRTCMainView:self 172 [self.delegate appRTCMainView:self
173 didEnterRoomId:roomString 173 didEnterRoomId:roomString
174 loopback:_loopbackButton.intValue]; 174 loopback:_loopbackButton.intValue];
175 [self setNeedsUpdateConstraints:YES];
175 } 176 }
176 177
177 #pragma mark - RTCNSGLVideoViewDelegate 178 #pragma mark - RTCNSGLVideoViewDelegate
178 179
179 - (void)videoView:(RTCNSGLVideoView*)videoView 180 - (void)videoView:(RTCNSGLVideoView*)videoView
180 didChangeVideoSize:(NSSize)size { 181 didChangeVideoSize:(NSSize)size {
181 if (videoView == _remoteVideoView) { 182 if (videoView == _remoteVideoView) {
182 _remoteVideoSize = size; 183 _remoteVideoSize = size;
183 } else if (videoView == _localVideoView) { 184 } else if (videoView == _localVideoView) {
184 _localVideoSize = size; 185 _localVideoSize = size;
(...skipping 21 matching lines...) Expand all
206 [_logView setEditable:NO]; 207 [_logView setEditable:NO];
207 208
208 [self setupActionItemsView]; 209 [self setupActionItemsView];
209 210
210 _scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect]; 211 _scrollView = [[NSScrollView alloc] initWithFrame:NSZeroRect];
211 [_scrollView setTranslatesAutoresizingMaskIntoConstraints:NO]; 212 [_scrollView setTranslatesAutoresizingMaskIntoConstraints:NO];
212 [_scrollView setHasVerticalScroller:YES]; 213 [_scrollView setHasVerticalScroller:YES];
213 [_scrollView setDocumentView:_logView]; 214 [_scrollView setDocumentView:_logView];
214 [self addSubview:_scrollView]; 215 [self addSubview:_scrollView];
215 216
216 NSOpenGLPixelFormatAttribute attributes[] = { 217
217 NSOpenGLPFADoubleBuffer, 218 // NOTE (daniela): Ignoring Clang diagonstic here.
218 NSOpenGLPFADepthSize, 24, 219 // We're performing run time check to make sure class is available on runtime.
219 NSOpenGLPFAOpenGLProfile, 220 // If not we're providing sensible default.
220 NSOpenGLProfileVersion3_2Core, 221 #pragma clang diagnostic push
221 0 222 #pragma clang diagnostic ignored "-Wpartial-availability"
222 }; 223 if ([RTCMTLNSVideoView class]) {
223 NSOpenGLPixelFormat* pixelFormat = 224 _remoteVideoView = [[RTCMTLNSVideoView alloc] initWithFrame:NSZeroRect];
224 [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; 225 _localVideoView = [[RTCMTLNSVideoView alloc] initWithFrame:NSZeroRect];
225 _remoteVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect 226 } else {
226 pixelFormat:pixelFormat]; 227 NSOpenGLPixelFormatAttribute attributes[] = {
228 NSOpenGLPFADoubleBuffer,
229 NSOpenGLPFADepthSize, 24,
230 NSOpenGLPFAOpenGLProfile,
231 NSOpenGLProfileVersion3_2Core,
232 0
233 };
234 NSOpenGLPixelFormat* pixelFormat =
235 [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
236
237 RTCNSGLVideoView* remote =
238 [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect pixelFormat:pixelForm at];
239 remote.delegate = self;
240 _remoteVideoView = remote;
241
242 RTCNSGLVideoView* local =
243 [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect pixelFormat:pixelForm at];
244 local.delegate = self;
245 _localVideoView = local;
246 }
247 #pragma clang diagnostic pop
248
227 [_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; 249 [_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
228 _remoteVideoView.delegate = self;
229 [self addSubview:_remoteVideoView]; 250 [self addSubview:_remoteVideoView];
230
231 _localVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect
232 pixelFormat:pixelFormat];
233 [_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO]; 251 [_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
234 _localVideoView.delegate = self;
235 [self addSubview:_localVideoView]; 252 [self addSubview:_localVideoView];
236 } 253 }
237 254
238 - (void)setupActionItemsView { 255 - (void)setupActionItemsView {
239 _actionItemsView = [[NSView alloc] initWithFrame:NSZeroRect]; 256 _actionItemsView = [[NSView alloc] initWithFrame:NSZeroRect];
240 [_actionItemsView setTranslatesAutoresizingMaskIntoConstraints:NO]; 257 [_actionItemsView setTranslatesAutoresizingMaskIntoConstraints:NO];
241 [self addSubview:_actionItemsView]; 258 [self addSubview:_actionItemsView];
242 259
243 _roomField = [[NSTextField alloc] initWithFrame:NSZeroRect]; 260 _roomField = [[NSTextField alloc] initWithFrame:NSZeroRect];
244 [_roomField setTranslatesAutoresizingMaskIntoConstraints:NO]; 261 [_roomField setTranslatesAutoresizingMaskIntoConstraints:NO];
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 [self.mainView.remoteVideoView renderFrame:nil]; 416 [self.mainView.remoteVideoView renderFrame:nil];
400 [self.mainView.localVideoView renderFrame:nil]; 417 [self.mainView.localVideoView renderFrame:nil];
401 } 418 }
402 419
403 - (void)disconnect { 420 - (void)disconnect {
404 [self resetUI]; 421 [self resetUI];
405 [_client disconnect]; 422 [_client disconnect];
406 } 423 }
407 424
408 @end 425 @end
OLDNEW
« no previous file with comments | « no previous file | webrtc/sdk/BUILD.gn » ('j') | webrtc/sdk/objc/Framework/Classes/Metal/RTCMTLI420Renderer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698