[vlc-commits] v4l2 access: use --v4l2-chroma if specified

Rémi Denis-Courmont git at videolan.org
Sun Sep 9 23:18:08 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Sep 10 00:12:34 2012 +0300| [70b74020f979b451ec998289f5b0360d8a833bd7] | committer: Rémi Denis-Courmont

v4l2 access: use --v4l2-chroma if specified

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=70b74020f979b451ec998289f5b0360d8a833bd7
---

 modules/access/v4l2/access.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/modules/access/v4l2/access.c b/modules/access/v4l2/access.c
index 7e98786..df5add0 100644
--- a/modules/access/v4l2/access.c
+++ b/modules/access/v4l2/access.c
@@ -106,16 +106,32 @@ int InitVideo (access_t *access, int fd, uint32_t caps)
     if (SetupInput (VLC_OBJECT(access), fd))
         return -1;
 
-    /* Try and find default resolution if not specified */
-    struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
-    if (v4l2_ioctl (fd, VIDIOC_G_FMT, &fmt) < 0)
+    /* NOTE: The V4L access_demux expects a VLC FOURCC as "chroma". It is used to set the
+     * es_format_t structure correctly. However, the V4L access (*here*) has no use for a
+     * VLC FOURCC and expects a V4L2 format directly instead. That is confusing :-( */
+    uint32_t pixfmt = 0;
+    char *fmtstr = var_InheritString (access, CFG_PREFIX"chroma");
+    if (fmtstr != NULL && strlen (fmtstr) <= 4)
     {
-        msg_Err (access, "cannot get default format: %m");
-        return -1;
+        memcpy (&pixfmt, fmtstr, strlen (fmtstr));
+        free (fmtstr);
+    }
+    else
+    /* Use the default^Wprevious format if none specified */
+    {
+        struct v4l2_format fmt = { .type = V4L2_BUF_TYPE_VIDEO_CAPTURE };
+        if (v4l2_ioctl (fd, VIDIOC_G_FMT, &fmt) < 0)
+        {
+            msg_Err (access, "cannot get default format: %m");
+            return -1;
+        }
+        pixfmt = fmt.fmt.pix.pixelformat;
     }
+    msg_Dbg (access, "selected format %4.4s", (const char *)&pixfmt);
 
+    struct v4l2_format fmt;
     struct v4l2_streamparm parm;
-    if (SetupFormat (access, fd, fmt.fmt.pix.pixelformat, &fmt, &parm))
+    if (SetupFormat (access, fd, pixfmt, &fmt, &parm))
         return -1;
 
     msg_Dbg (access, "%"PRIu32" bytes for complete image", fmt.fmt.pix.sizeimage);



More information about the vlc-commits mailing list