]> git.sesse.net Git - vlc/blobdiff - modules/access/screen/screen.c
Used a sar for picture_New/Setup.
[vlc] / modules / access / screen / screen.c
index aff35f8eecd7fd37601e48f4ad94c8bf19ff3c80..7ad87dee6e588f6e29ae8de489f842e88e2c4f35 100644 (file)
@@ -77,7 +77,7 @@
 #ifdef SCREEN_MOUSE
 #define MOUSE_TEXT N_( "Mouse pointer image" )
 #define MOUSE_LONGTEXT N_( \
-    "If specifed, will use the image to draw the mouse pointer on the " \
+    "If specified, will use the image to draw the mouse pointer on the " \
     "capture." )
 #endif
 
@@ -90,39 +90,39 @@ static void Close( vlc_object_t * );
 #   define SCREEN_FPS 5
 #endif
 
-vlc_module_begin();
-    set_description( N_("Screen Input") );
-    set_shortname( N_("Screen" ));
-    set_category( CAT_INPUT );
-    set_subcategory( SUBCAT_INPUT_ACCESS );
+vlc_module_begin ()
+    set_description( N_("Screen Input") )
+    set_shortname( N_("Screen" ))
+    set_category( CAT_INPUT )
+    set_subcategory( SUBCAT_INPUT_ACCESS )
 
     add_integer( "screen-caching", DEFAULT_PTS_DELAY / 1000, NULL,
-        CACHING_TEXT, CACHING_LONGTEXT, true );
-    add_float( "screen-fps", SCREEN_FPS, 0, FPS_TEXT, FPS_LONGTEXT, true );
+        CACHING_TEXT, CACHING_LONGTEXT, true )
+    add_float( "screen-fps", SCREEN_FPS, 0, FPS_TEXT, FPS_LONGTEXT, true )
 
 #ifdef SCREEN_SUBSCREEN
-    add_integer( "screen-top", 0, NULL, TOP_TEXT, TOP_LONGTEXT, true );
-    add_integer( "screen-left", 0, NULL, LEFT_TEXT, LEFT_LONGTEXT, true );
-    add_integer( "screen-width", 0, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, true );
-    add_integer( "screen-height", 0, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, true );
+    add_integer( "screen-top", 0, NULL, TOP_TEXT, TOP_LONGTEXT, true )
+    add_integer( "screen-left", 0, NULL, LEFT_TEXT, LEFT_LONGTEXT, true )
+    add_integer( "screen-width", 0, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, true )
+    add_integer( "screen-height", 0, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, true )
     add_bool( "screen-follow-mouse", false, NULL, FOLLOW_MOUSE_TEXT,
-              FOLLOW_MOUSE_LONGTEXT, true );
+              FOLLOW_MOUSE_LONGTEXT, true )
 #endif
 
 #ifdef SCREEN_MOUSE
     add_file( "screen-mouse-image", "", NULL, MOUSE_TEXT, MOUSE_LONGTEXT,
-              true );
+              true )
 #endif
 
 #ifdef WIN32
     add_integer( "screen-fragment-size", 0, NULL, FRAGS_TEXT,
-        FRAGS_LONGTEXT, true );
+        FRAGS_LONGTEXT, true )
 #endif
 
-    set_capability( "access_demux", 0 );
-    add_shortcut( "screen" );
-    set_callbacks( Open, Close );
-vlc_module_end();
+    set_capability( "access_demux", 0 )
+    add_shortcut( "screen" )
+    set_callbacks( Open, Close )
+vlc_module_end ()
 
 /*****************************************************************************
  * Local prototypes
@@ -137,21 +137,19 @@ static int Open( vlc_object_t *p_this )
 {
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
-    vlc_value_t val;
 
     /* Fill p_demux field */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
-    p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
-    memset( p_sys, 0, sizeof( demux_sys_t ) );
+    p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) );
+    if( !p_sys )
+        return VLC_ENOMEM;
 
     /* Update default_pts to a suitable value for screen access */
     var_Create( p_demux, "screen-caching", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
 
-    var_Create( p_demux, "screen-fps", VLC_VAR_FLOAT|VLC_VAR_DOINHERIT );
-    var_Get( p_demux, "screen-fps", &val );
-    p_sys->f_fps = val.f_float;
-    p_sys->i_incr = 1000000 / val.f_float;
+    p_sys->f_fps = var_CreateGetFloat( p_demux, "screen-fps" );
+    p_sys->i_incr = 1000000 / p_sys->f_fps;;
     p_sys->i_next_date = 0;
 
 #ifdef SCREEN_SUBSCREEN
@@ -214,7 +212,7 @@ static int Open( vlc_object_t *p_this )
         msg_Dbg( p_demux, "Using %s for the mouse pointer image", psz_mouse );
         memset( &fmt_in, 0, sizeof( fmt_in ) );
         memset( &fmt_out, 0, sizeof( fmt_out ) );
-        fmt_out.i_chroma = VLC_FOURCC('R','G','B','A');
+        fmt_out.i_chroma = VLC_CODEC_RGBA;
         p_image = image_HandlerCreate( p_demux );
         if( p_image )
         {
@@ -306,6 +304,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             *pi64 = (int64_t)var_GetInteger( p_demux, "screen-caching" ) *1000;
             return VLC_SUCCESS;
 
+        case DEMUX_GET_TIME:
+            pi64 = (int64_t*)va_arg( args, int64_t * );
+            *pi64 = mdate();
+            return VLC_SUCCESS;
+
         /* TODO implement others */
         default:
             return VLC_EGENERIC;
@@ -333,24 +336,23 @@ void RenderCursor( demux_t *p_demux, int i_x, int i_y,
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     if( !p_sys->dst.i_planes )
-        vout_InitPicture( p_demux, &p_sys->dst,
-                          p_sys->fmt.video.i_chroma,
-                          p_sys->fmt.video.i_width,
-                          p_sys->fmt.video.i_height,
-                          p_sys->fmt.video.i_aspect );
+        picture_Setup( &p_sys->dst,
+                       p_sys->fmt.video.i_chroma,
+                       p_sys->fmt.video.i_width,
+                       p_sys->fmt.video.i_height,
+                       p_sys->fmt.video.i_aspect * p_sys->fmt.video.i_height,
+                       VOUT_ASPECT_FACTOR        * p_sys->fmt.video.i_width );
     if( !p_sys->p_blend )
     {
         p_sys->p_blend = vlc_object_create( p_demux, sizeof(filter_t) );
-        if( !p_sys->p_blend )
-            msg_Err( p_demux, "Could not allocate memory for blending module" );
-        else
+        if( p_sys->p_blend )
         {
             es_format_Init( &p_sys->p_blend->fmt_in, VIDEO_ES,
-                            VLC_FOURCC('R','G','B','A') );
+                            VLC_CODEC_RGBA );
             p_sys->p_blend->fmt_in.video = p_sys->p_mouse->format;
             p_sys->p_blend->fmt_out = p_sys->fmt;
             p_sys->p_blend->p_module =
-                module_need( p_sys->p_blend, "video blending", 0, 0 );
+                module_need( p_sys->p_blend, "video blending", NULL, false );
             if( !p_sys->p_blend->p_module )
             {
                 msg_Err( p_demux, "Could not load video blending module" );