]> git.sesse.net Git - vlc/blobdiff - modules/video_output/opengllayer.m
Merge branch '1.0-bugfix'
[vlc] / modules / video_output / opengllayer.m
index bb31d25e836133209ed0959f4b6de582d2345d3d..fe5717c03b1ca7f28eb467bb5e1d3a90433697b6 100644 (file)
@@ -3,7 +3,7 @@
  * a layer. The layer will register itself to the drawable object stored in 
  * the "drawable" variable. 
  *****************************************************************************
- * Copyright (C) 2004 the VideoLAN team
+ * Copyright (C) 2004-2009 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet <asmax@videolan.org>
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
+#include <vlc_plugin.h>
 #include <vlc_vout.h>
 
 #import <QuartzCore/QuartzCore.h>
 #import <Cocoa/Cocoa.h>
 #import <OpenGL/OpenGL.h>
 
-#ifdef CALayer
-
 /* On OS X, use GL_TEXTURE_RECTANGLE_EXT instead of GL_TEXTURE_2D.
    This allows sizes which are not powers of 2 */
 #define VLCGL_TARGET GL_TEXTURE_RECTANGLE_EXT
@@ -90,15 +89,15 @@ static int  Control      ( vout_thread_t *, int, va_list );
 
 static int InitTextures  ( vout_thread_t * );
 
-vlc_module_begin();
-    set_shortname( "OpenGLLayer" );
-    set_category( CAT_VIDEO );
-    set_subcategory( SUBCAT_VIDEO_VOUT );
-    set_description( _("Core Animation OpenGL Layer (Mac OS X)") );
-    set_capability( "video output", 20 );
-    add_shortcut( "opengllayer" );
-    set_callbacks( CreateVout, DestroyVout );
-vlc_module_end();
+vlc_module_begin ()
+    set_shortname( "OpenGLLayer" )
+    set_category( CAT_VIDEO )
+    set_subcategory( SUBCAT_VIDEO_VOUT )
+    set_description( N_("Core Animation OpenGL Layer (Mac OS X)") )
+    set_capability( "video output", 20 )
+    add_shortcut( "opengllayer" )
+    set_callbacks( CreateVout, DestroyVout )
+vlc_module_end ()
 
 @interface VLCVoutLayer : CAOpenGLLayer {
     vout_thread_t * p_vout;
@@ -136,35 +135,14 @@ struct vout_sys_t
  *****************************************************************************/
 static int CreateVout( vlc_object_t *p_this )
 {
-    /* This module is Leopard only */
-#ifdef __APPLE__
-    long minorMacVersion;
-    if( Gestalt( gestaltSystemVersionMinor, &minorMacVersion ) == noErr )
-    {
-        if( minorMacVersion < 6 )
-        {
-            msg_Warn( p_vout, "current osx version is 10.%ld, non-suitable for OpenglLayer video output", minorMacVersion );
-            return VLC_ENOOBJ;
-        }
-    }
-    else
-    {
-        msg_Warn( p_vout, "couldn't get OS version" );
-        return VLC_EGENERIC;
-    }
-#endif
-
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     vout_sys_t *p_sys;
     char * psz;
 
     /* Allocate structure */
-    p_vout->p_sys = p_sys = calloc( sizeof( vout_sys_t ), 1 );
+    p_vout->p_sys = p_sys = calloc( 1, sizeof( vout_sys_t ) );
     if( p_sys == NULL )
-    {
-        msg_Err( p_vout, "out of memory" );
         return VLC_EGENERIC;
-    }
 
     p_sys->i_tex_width  = p_vout->fmt_in.i_width;
     p_sys->i_tex_height = p_vout->fmt_in.i_height;
@@ -192,10 +170,10 @@ static int Init( vout_thread_t *p_vout )
     vlc_value_t val;
 
 #if ( defined( WORDS_BIGENDIAN ) && VLCGL_FORMAT == GL_YCBCR_422_APPLE ) || (VLCGL_FORMAT == YCBCR_MESA)
-    p_vout->output.i_chroma = VLC_FOURCC('Y','U','Y','2');
+    p_vout->output.i_chroma = VLC_CODEC_YUYV;
     i_pixel_pitch = 2;
 #elif (VLCGL_FORMAT == GL_YCBCR_422_APPLE)
-    p_vout->output.i_chroma = VLC_FOURCC('U','Y','V','Y');
+    p_vout->output.i_chroma = VLC_CODEC_UYVY;
     i_pixel_pitch = 2;
 #endif
 
@@ -207,8 +185,8 @@ static int Init( vout_thread_t *p_vout )
 
     /* We do need a drawable to work properly */
     vlc_value_t value_drawable;
-    var_Create( p_vout, "drawable", VLC_VAR_DOINHERIT );
-    var_Get( p_vout, "drawable", &value_drawable );
+    var_Create( p_vout, "drawable-gl", VLC_VAR_DOINHERIT );
+    var_Get( p_vout, "drawable-gl", &value_drawable );
 
     p_vout->p_sys->o_cocoa_container = (id) value_drawable.i_int;
     
@@ -223,10 +201,7 @@ static int Init( vout_thread_t *p_vout )
         p_sys->pp_buffer[i] =
             malloc( p_sys->i_tex_width * p_sys->i_tex_height * i_pixel_pitch );
         if( !p_sys->pp_buffer[i] )
-        {
-            msg_Err( p_vout, "out of memory" );
             return VLC_EGENERIC;
-        }
     }
     p_sys->b_frame_available = false;
     p_sys->i_index = 0;
@@ -359,17 +334,9 @@ static int Control( vout_thread_t *p_vout, int i_query, va_list args )
 {
     vout_sys_t *p_sys = p_vout->p_sys;
 
-    switch( i_query )
-    {
-    case VOUT_SNAPSHOT:
-        return vout_vaControlDefault( p_vout, i_query, args );
-
-    default:
-        if( p_sys->p_vout->pf_control )
-            return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
-        else
-            return vout_vaControlDefault( p_vout, i_query, args );
-    }
+    if( p_sys->p_vout->pf_control )
+        return p_sys->p_vout->pf_control( p_sys->p_vout, i_query, args );
+    return VLC_EGENERIC;
 }
 
 /*****************************************************************************
@@ -535,5 +502,3 @@ static int InitTextures( vout_thread_t *p_vout )
     CGLUnlockContext( glContext );
 }
 @end
-
-#endif