[vlc-devel] [PATCH] Add MacOSX OpenGL callbacks to enable Syphon broadcast

adampcc at runbox.com adampcc at runbox.com
Mon May 14 19:21:41 CEST 2018


From: Adam Fedor <afedor at t1v.com>

This is a fairly simple patch that adds callbacks to the MacOSX OpenGL 
rendering so that VLC output can be broadcast using Syphon (I imagine 
there are other uses for the callbacks, but that is not my purpose). I
know other people are interested in this as well (See 
https://github.com/rsodre/VLCSyphon and 
http://v002.info/forums/topic/vlckit-to-syphon/)

I am not quite sure I'm using the right method to get the size of the
display output, so any help with that is appreciated.

---
 modules/video_output/macosx.m | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/modules/video_output/macosx.m b/modules/video_output/macosx.m
index 050cc073a1..ff67f9d039 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,7 @@ - (void)setVoutFlushing:(BOOL)flushing;
 struct vout_display_sys_t
 {
     VLCOpenGLVideoView *glView;
-    id<VLCOpenGLVideoViewEmbedding> container;
+    id<VLCOpenGLVideoViewEmbedding, VLCOpenGLVideoDrawing> container;
 
     vout_window_t *embed;
     vlc_gl_t *gl;
@@ -333,13 +337,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]);
+  if ([sys->container respondsToSelector:@selector(willDrawVoutSize:)])
+    [sys->container willDrawVoutSize:size];
+}
+
+static void DidDisplayPicture (vout_display_sys_t *sys)
+{
+  if ([sys->container respondsToSelector:@selector(didDrawVout)])
+    [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)
     {
+        WillDisplayPicture(sys);
         vout_display_opengl_Display (sys->vgl, &vd->source);
+        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