]> git.sesse.net Git - vlc/blobdiff - modules/access/v4l/v4l.c
Improvements to preferences
[vlc] / modules / access / v4l / v4l.c
index a15caa1032281587e86145a004f29dad7e667aa8..e0c316692671888e072e508136fd23aea79e780f 100644 (file)
@@ -89,6 +89,8 @@ static void Close( vlc_object_t * );
 vlc_module_begin();
     set_shortname( _("Video4Linux") );
     set_description( _("Video4Linux input") );
+    set_category( CAT_INPUT );
+    set_subcategory( SUBCAT_INPUT_ACCESS );
 
     add_integer( "v4l-caching", DEFAULT_PTS_DELAY / 1000, NULL,
                  CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
@@ -227,6 +229,10 @@ static int Open( vlc_object_t *p_this )
     demux_t     *p_demux = (demux_t*)p_this;
     demux_sys_t *p_sys;
 
+    /* Only when selected */
+    if( *p_demux->psz_access == '\0' )
+        return VLC_EGENERIC;
+
     /* Set up p_demux */
     p_demux->pf_demux = Demux;
     p_demux->pf_control = Control;
@@ -347,6 +353,16 @@ static int Open( vlc_object_t *p_this )
         es_format_Init( &fmt, VIDEO_ES, p_sys->i_fourcc );
         fmt.video.i_width  = p_sys->i_width;
         fmt.video.i_height = p_sys->i_height;
+        fmt.video.i_aspect = 4 * VOUT_ASPECT_FACTOR / 3;
+
+        /* Setup rgb mask for RGB formats */
+        if( p_sys->i_fourcc == VLC_FOURCC('R','V','2','4') )
+        {
+            /* This is in BGR format */
+            fmt.video.i_bmask = 0x00ff0000;
+            fmt.video.i_gmask = 0x0000ff00;
+            fmt.video.i_rmask = 0x000000ff;
+        }
 
         msg_Dbg( p_demux, "added new video es %4.4s %dx%d",
                  (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height );
@@ -434,6 +450,11 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
             *pi64 = (int64_t)var_GetInteger( p_demux, "v4l-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;
@@ -449,7 +470,7 @@ static int Demux( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     es_out_id_t  *p_es = p_sys->p_es_audio;
-    block_t *p_block;
+    block_t *p_block = NULL;
 
     /* Try grabbing audio frames first */
     if( p_sys->fd_audio < 0 || !( p_block = GrabAudio( p_demux ) ) )
@@ -1047,7 +1068,6 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
                     break;
                 }
             }
-
         }
         else
         {
@@ -1105,7 +1125,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device )
         p_sys->i_video_frame_size = 0;
         for( i = 0; i < p_sys->pic.i_planes; i++ )
         {
-            p_sys->i_video_frame_size += p_sys->pic.p[i].i_lines *
+            p_sys->i_video_frame_size += p_sys->pic.p[i].i_visible_lines *
               p_sys->pic.p[i].i_visible_pitch;
         }