MacOS: Add metal renderer and view.
BUG=webrtc:7079 Review-Url: https://codereview.webrtc.org/2778693003 Cr-Commit-Position: refs/heads/master@{#17482}
This commit is contained in:
@ -12,6 +12,7 @@
|
||||
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
|
||||
#import "WebRTC/RTCMTLNSVideoView.h"
|
||||
#import "WebRTC/RTCNSGLVideoView.h"
|
||||
#import "WebRTC/RTCVideoTrack.h"
|
||||
|
||||
@ -35,8 +36,8 @@ static NSUInteger const kBottomViewHeight = 200;
|
||||
@interface APPRTCMainView : NSView
|
||||
|
||||
@property(nonatomic, weak) id<APPRTCMainViewDelegate> delegate;
|
||||
@property(nonatomic, readonly) RTCNSGLVideoView* localVideoView;
|
||||
@property(nonatomic, readonly) RTCNSGLVideoView* remoteVideoView;
|
||||
@property(nonatomic, readonly) NSView<RTCVideoRenderer>* localVideoView;
|
||||
@property(nonatomic, readonly) NSView<RTCVideoRenderer>* remoteVideoView;
|
||||
|
||||
- (void)displayLogMessage:(NSString*)message;
|
||||
|
||||
@ -169,10 +170,10 @@ static NSUInteger const kBottomViewHeight = 200;
|
||||
roomString = [NSUUID UUID].UUIDString;
|
||||
roomString = [roomString stringByReplacingOccurrencesOfString:@"-" withString:@""];
|
||||
}
|
||||
|
||||
[self.delegate appRTCMainView:self
|
||||
didEnterRoomId:roomString
|
||||
loopback:_loopbackButton.intValue];
|
||||
[self setNeedsUpdateConstraints:YES];
|
||||
}
|
||||
|
||||
#pragma mark - RTCNSGLVideoViewDelegate
|
||||
@ -214,25 +215,41 @@ static NSUInteger const kBottomViewHeight = 200;
|
||||
[_scrollView setDocumentView:_logView];
|
||||
[self addSubview:_scrollView];
|
||||
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFADepthSize, 24,
|
||||
NSOpenGLPFAOpenGLProfile,
|
||||
NSOpenGLProfileVersion3_2Core,
|
||||
0
|
||||
};
|
||||
NSOpenGLPixelFormat* pixelFormat =
|
||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
_remoteVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect
|
||||
pixelFormat:pixelFormat];
|
||||
[_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
_remoteVideoView.delegate = self;
|
||||
[self addSubview:_remoteVideoView];
|
||||
|
||||
_localVideoView = [[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect
|
||||
pixelFormat:pixelFormat];
|
||||
// NOTE (daniela): Ignoring Clang diagonstic here.
|
||||
// We're performing run time check to make sure class is available on runtime.
|
||||
// If not we're providing sensible default.
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wpartial-availability"
|
||||
if ([RTCMTLNSVideoView class]) {
|
||||
_remoteVideoView = [[RTCMTLNSVideoView alloc] initWithFrame:NSZeroRect];
|
||||
_localVideoView = [[RTCMTLNSVideoView alloc] initWithFrame:NSZeroRect];
|
||||
} else {
|
||||
NSOpenGLPixelFormatAttribute attributes[] = {
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
NSOpenGLPFADepthSize, 24,
|
||||
NSOpenGLPFAOpenGLProfile,
|
||||
NSOpenGLProfileVersion3_2Core,
|
||||
0
|
||||
};
|
||||
NSOpenGLPixelFormat* pixelFormat =
|
||||
[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
|
||||
|
||||
RTCNSGLVideoView* remote =
|
||||
[[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect pixelFormat:pixelFormat];
|
||||
remote.delegate = self;
|
||||
_remoteVideoView = remote;
|
||||
|
||||
RTCNSGLVideoView* local =
|
||||
[[RTCNSGLVideoView alloc] initWithFrame:NSZeroRect pixelFormat:pixelFormat];
|
||||
local.delegate = self;
|
||||
_localVideoView = local;
|
||||
}
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
[_remoteVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
[self addSubview:_remoteVideoView];
|
||||
[_localVideoView setTranslatesAutoresizingMaskIntoConstraints:NO];
|
||||
_localVideoView.delegate = self;
|
||||
[self addSubview:_localVideoView];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user