[vlc-devel] [PATCH] Add MacOSX OpenGL callbacks to enable Syphon broadcast
Adam Fedor
adampcc at runbox.com
Wed May 16 16:30:50 CEST 2018
Here's a slight update to my previous patch. This patch pre-computes
if the drawing container responds to the callbacks required for Syphon
support. Now there is just a simple bool check for using Syphon and any
container not using it should have essentially no measureable impact on
performance.
---
modules/video_output/macosx.m | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 050cc073a1..38389cd12d 100644
--- a/modules/video_output/macosx.m
+++ b/modules/video_output/macosx.m
@@ -88,6 +88,10 @@ @protocol VLCOpenGLVideoViewEmbedding <NSObject>
- (void)addVoutSubview:(NSView *)view;
- (void)removeVoutSubview:(NSView *)view;
@end
+ at protocol VLCOpenGLVideoDrawing <NSObject>
+- (void)willDrawVoutSize:(NSSize)size;
+- (void)didDrawVout;
+ at end
@interface VLCOpenGLVideoView : NSOpenGLView
{
@@ -102,7 +106,8 @@ - (void)setVoutFlushing:(BOOL)flushing;
struct vout_display_sys_t
{
VLCOpenGLVideoView *glView;
- id<VLCOpenGLVideoViewEmbedding> container;
+ id<VLCOpenGLVideoViewEmbedding, VLCOpenGLVideoDrawing> container;
+ bool containerImplementsVideoDrawing;
vout_window_t *embed;
vlc_gl_t *gl;
@@ -197,6 +202,8 @@ static int Open (vlc_object_t *this)
msg_Err(vd, "Invalid drawable-nsobject object. drawable-nsobject must either be an NSView or comply to the @protocol VLCOpenGLVideoViewEmbedding.");
goto error;
}
+ sys->containerImplementsVideoDrawing = ([(id)container respondsToSelector:@selector(willDrawVoutSize:)]
+ && [(id)container respondsToSelector:@selector(didDrawVout)]);
/* Initialize common OpenGL video display */
sys->gl = vlc_object_create(this, sizeof(*sys->gl));
@@ -333,13 +340,30 @@ static void PictureRender (vout_display_t *vd, picture_t *pic, subpicture_t *sub
}
}
+static void WillDisplayPicture (vout_display_sys_t *sys)
+{
+ GLint params[4];
+ glGetIntegerv(GL_VIEWPORT, params);
+ NSSize size = NSMakeSize(params[2], params[3]);
+ [sys->container willDrawVoutSize:size];
+}
+
+static void DidDisplayPicture (vout_display_sys_t *sys)
+{
+ [sys->container didDrawVout];
+}
+
static void PictureDisplay (vout_display_t *vd, picture_t *pic, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
[sys->glView setVoutFlushing:YES];
if (vlc_gl_MakeCurrent(sys->gl) == VLC_SUCCESS)
{
+ if (sys->containerImplementsVideoDrawing)
+ WillDisplayPicture(sys);
vout_display_opengl_Display (sys->vgl, &vd->source);
+ if (sys->containerImplementsVideoDrawing)
+ DidDisplayPicture(sys);
vlc_gl_ReleaseCurrent(sys->gl);
}
[sys->glView setVoutFlushing:NO];
--
2.15.1 (Apple Git-101)
More information about the vlc-devel
mailing list