Add "videocontrol" command variable to issue controls other than those which we expli...
authorAntoine Cellerier <dionoea@videolan.org>
Sun, 2 Dec 2007 14:14:50 +0000 (14:14 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Sun, 2 Dec 2007 14:14:50 +0000 (14:14 +0000)
modules/access/v4l2.c

index ce3002f..b9f36ae 100644 (file)
@@ -392,6 +392,9 @@ static int Open( vlc_object_t *p_this )
     var_AddCallback( p_demux, "v4l2-hue", VideoControlCallback, NULL );
     var_AddCallback( p_demux, "v4l2-gamma", VideoControlCallback, NULL );
 
+    var_Create( p_demux, "videocontrol", VLC_VAR_STRING | VLC_VAR_ISCOMMAND );
+    var_AddCallback( p_demux, "videocontrol", VideoControlCallback, NULL );
+
     var_Create( p_demux, "v4l2-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
     var_Get( p_demux, "v4l2-fps", &val );
     p_sys->f_fps = val.f_float;
@@ -2405,21 +2408,25 @@ static int VideoControl( demux_t *p_demux, int i_fd,
 {
     struct v4l2_queryctrl queryctrl;
     struct v4l2_control control;
-    memset( &queryctrl, 0, sizeof( queryctrl ) );
 
     if( i_value == -1 )
         return VLC_SUCCESS;
 
+    memset( &queryctrl, 0, sizeof( queryctrl ) );
+
     queryctrl.id = i_cid;
 
     if( ioctl( i_fd, VIDIOC_QUERYCTRL, &queryctrl ) < 0
         || queryctrl.flags & V4L2_CTRL_FLAG_DISABLED )
     {
         msg_Err( p_demux, "%s (%x) control is not supported.", psz_label,
-                 i_value );
+                 i_cid );
         return VLC_EGENERIC;
     }
 
+    if( !psz_label )
+        psz_label = (const char*)queryctrl.name;
+
     memset( &control, 0, sizeof( control ) );
     control.id = i_cid;
 
@@ -2485,6 +2492,13 @@ static int VideoControlCallback( vlc_object_t *p_this,
         return VideoControl( p_demux, i_fd,
                     "gamma", V4L2_CID_HUE, p_sys->i_gamma );
     }
+    else if( !strcmp( psz_var, "videocontrol" ) )
+    {
+        char *psz_var = newval.psz_string;
+        int i_cid = strtol( psz_var, &psz_var, 16 );
+        int i_value = strtol( psz_var, &psz_var, 0 );
+        return VideoControl( p_demux, i_fd, NULL, i_cid, i_value );
+    }
 
     return VLC_EGENERIC;
 }