[FFmpeg-devel] [PATCH] libavdevice: v4l2: use libv4l2 when requested.

Konstantin Pavlov thresh
Thu May 13 21:17:28 CEST 2010


From: Konstantin Pavlov <thresh at altlinux.org>

This adds support for numerous pixfmts used in web cameras through
libv4l2.
---
 configure          |    7 +++++++
 libavdevice/v4l2.c |    9 +++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/configure b/configure
index 2b206c1..b2f5c91 100755
--- a/configure
+++ b/configure
@@ -181,6 +181,7 @@ External library support:
   --enable-libschroedinger enable Dirac support via libschroedinger [no]
   --enable-libspeex        enable Speex decoding via libspeex [no]
   --enable-libtheora       enable Theora encoding via libtheora [no]
+  --enable-libv4l2         enable libv4l2 support [no]
   --enable-libvorbis       enable Vorbis encoding via libvorbis,
                            native implementation exists [no]
   --enable-libx264         enable H.264 encoding via x264 [no]
@@ -926,6 +927,7 @@ CONFIG_LIST="
     libschroedinger
     libspeex
     libtheora
+    libv4l2
     libvorbis
     libx264
     libxvid
@@ -1323,6 +1325,8 @@ zmbv_encoder_select="zlib"
 vaapi_deps="va_va_h"
 vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 
+libv4l2_deps="libv4l2_h"
+
 # parsers
 h264_parser_select="golomb h264dsp"
 
@@ -2546,6 +2550,7 @@ check_header termios.h
 check_header vdpau/vdpau.h
 check_header vdpau/vdpau_x11.h
 check_header X11/extensions/XvMClib.h
+check_header libv4l2.h
 
 check_struct dxva2api.h DXVA_PictureParameters wDecodedPictureIndex
 
@@ -2616,6 +2621,7 @@ enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
                            require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
+enabled libv4l2    && require  libv4l2 libv4l2.h v4l2_open $(pkg-config --libs libv4l2)
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
 enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
                       { check_cpp_condition x264.h "X264_BUILD >= 83" ||
@@ -2885,6 +2891,7 @@ echo "librtmp enabled           ${librtmp-no}"
 echo "libschroedinger enabled   ${libschroedinger-no}"
 echo "libspeex enabled          ${libspeex-no}"
 echo "libtheora enabled         ${libtheora-no}"
+echo "libv4l2 enabled           ${libv4l2-no}"
 echo "libvorbis enabled         ${libvorbis-no}"
 echo "libx264 enabled           ${libx264-no}"
 echo "libxvid enabled           ${libxvid-no}"
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index ce88903..85f2089 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -44,6 +44,15 @@
 #include <time.h>
 #include <strings.h>
 
+#if CONFIG_LIBV4L2
+#include <libv4l2.h>
+#define open    v4l2_open
+#define close   v4l2_close
+#define ioctl   v4l2_ioctl
+#define mmap    v4l2_mmap
+#define munmap  v4l2_munmap
+#endif
+
 static const int desired_video_buffers = 256;
 
 enum io_method {
-- 
1.7.0.4




More information about the ffmpeg-devel mailing list