Commit 418a4940 authored by Nicolas Dufresne's avatar Nicolas Dufresne

v4l2: Use a copy of videodev2.h header

With years the amount of ifdef have grown up and we are not even sure if the
old code path compiles. Each time we need to update the v4l2 framework to add
the new feature, we break compilation on older kernel. With exception of two
controls in the video orientation control, this patch get rid of all ifdef by
including the latest version of videodev2.h inside GStreamer.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=723446
parent 5d06735d
......@@ -498,73 +498,14 @@ AG_GST_CHECK_FEATURE(OSX_VIDEO, [OSX video], osxvideosink, [
]], [[return 0;]])],[HAVE_OSX_VIDEO="yes"],[HAVE_OSX_VIDEO="no"])
])
dnl *** Video 4 Linux 2 ***
dnl for information about the header/define, see sys/v4l2/gstv4l2element.h
dnl renamed to GST_V4L2 because of some conflict with kernel headers
translit(dnm, m, l) AM_CONDITIONAL(USE_GST_V4L2, true)
AG_GST_CHECK_FEATURE(GST_V4L2, [Video 4 Linux 2], v4l2src, [
AC_MSG_CHECKING([Checking for up to date v4l2 installation])
HAVE_V4L2_PLANE=no
AC_CHECK_TYPE(struct v4l2_plane,HAVE_V4L2_PLANE=yes,,[
#include <sys/types.h>
#ifdef __sun /* Solaris */
#include <sys/types.h>
#include <sys/videodev2.h>
#elif __FreeBSD__
#include <linux/videodev2.h>
#else /* Linux */
#include <linux/types.h>
#define _LINUX_TIME_H
#define __user
#include <linux/videodev2.h>
#endif
])
if [ test x$HAVE_V4L2_PLANE = xyes ]; then
HAVE_GST_V4L2="yes"
AC_MSG_RESULT(yes)
else
HAVE_GST_V4L2="no"
AC_MSG_RESULT(no)
HAVE_VIDEODEV=no
AC_CHECK_HEADER(linux/videodev2.h, [ HAVE_VIDEODEV=yes ],
[
AC_CHECK_HEADER(sys/videodev2.h, [ HAVE_VIDEODEV=yes ])
])
if test "x$HAVE_VIDEODEV" = "xyes"; then
AC_MSG_WARN([video4linux2 headers were found, but they're old.])
AC_MSG_WARN([Please update v4l2 to compile the v4l2 plugins])
else
AC_MSG_WARN([video4linux2 was not found])
fi
fi
if [ test x$HAVE_GST_V4L2 = xyes ]; then
dnl check for XOverlay libraries
AG_GST_CHECK_XV
fi
])
dnl check for XOverlay libraries
AG_GST_CHECK_XV
# Optional gudev for device probing
AC_ARG_WITH([gudev],
AS_HELP_STRING([--with-gudev],[device detection with gudev]),
[],
[with_gudev=check])
if test x$HAVE_GST_V4L2 = xyes; then
if test x$with_gudev != xno; then
PKG_CHECK_MODULES(GUDEV, [ gudev-1.0 >= 143 ],
[ have_gudev=yes
AC_DEFINE(HAVE_GUDEV, 1,
[Whether gudev is available for device detection])
AC_DEFINE([G_UDEV_API_IS_SUBJECT_TO_CHANGE], 1, [I know the API is subject to change.])
], [
have_gudev=no
])
else
have_gudev=no
fi
fi
AC_SUBST(GUDEV_CFLAGS)
AC_SUBST(GUDEV_LIBS)
......@@ -587,24 +528,6 @@ if test x$HAVE_GST_V4L2 = xyes; then
fi
fi
# Check if v4l2 support dmabuf
if test x$HAVE_GST_V4L2 = xyes; then
AC_CHECK_DECLS(V4L2_MEMORY_DMABUF,,,[
#include <sys/types.h>
#ifdef __sun /* Solaris */
#include <sys/types.h>
#include <sys/videodev2.h>
#elif __FreeBSD__
#include <linux/videodev2.h>
#else /* Linux */
#include <linux/types.h>
#define _LINUX_TIME_H
#define __user
#include <linux/videodev2.h>
#endif
])
fi
dnl Check for X11
translit(dnm, m, l) AM_CONDITIONAL(USE_X, true)
AG_GST_CHECK_FEATURE(X, [X libraries and plugins],
......@@ -1002,7 +925,6 @@ AM_CONDITIONAL(USE_DIRECTSOUND, false)
AM_CONDITIONAL(USE_DV1394, false)
AM_CONDITIONAL(USE_FLAC, false)
AM_CONDITIONAL(USE_GDK_PIXBUF, false)
AM_CONDITIONAL(USE_GST_V4L2, false)
AM_CONDITIONAL(USE_JACK, false)
AM_CONDITIONAL(USE_JPEG, false)
AM_CONDITIONAL(USE_LIBCACA, false)
......
......@@ -132,9 +132,7 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/gstreamer-%{majorminor}/libgstvideofilter.so
%{_libdir}/gstreamer-%{majorminor}/libgstaudioparsers.so
%{_libdir}/gstreamer-%{majorminor}/libgstdtmf.so
# sys plugins
@USE_GST_V4L2_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstvideo4linux2.so
%{_libdir}/gstreamer-%{majorminor}/libgstvideo4linux2.so
# gstreamer-plugins with external dependencies but in the main package
@USE_LIBCACA_TRUE@%{_libdir}/gstreamer-%{majorminor}/libgstcacasink.so
......
......@@ -53,12 +53,6 @@ endif
# QCAM_DIR=
# endif
if USE_GST_V4L2
V4L2_DIR=v4l2
else
V4L2_DIR=
endif
# if USE_VCD
# VCD_DIR=vcd
# else
......@@ -83,7 +77,7 @@ else
XIMAGE_DIR=
endif
SUBDIRS=$(DIRECTSOUND_DIR) $(WAVEFORM_DIR) $(OSS_DIR) $(OSS4_DIR) $(OSX_AUDIO_DIR) $(OSX_VIDEO_DIR) $(SUNAUDIO_DIR) $(V4L2_DIR) $(XIMAGE_DIR)
SUBDIRS=$(DIRECTSOUND_DIR) $(WAVEFORM_DIR) $(OSS_DIR) $(OSS4_DIR) $(OSX_AUDIO_DIR) $(OSX_VIDEO_DIR) $(SUNAUDIO_DIR) $(XIMAGE_DIR)
DIST_SUBDIRS=directsound oss oss4 osxaudio osxvideo sunaudio v4l2 waveform ximage
......
/*
* include/linux/v4l2-common.h
*
* Common V4L2 and V4L2 subdev definitions.
*
* Users are advised to #include this file either through videodev2.h
* (V4L2) or through v4l2-subdev.h (V4L2 subdev) rather than to refer
* to this file directly.
*
* Copyright (C) 2012 Nokia Corporation
* Contact: Sakari Ailus <sakari.ailus@iki.fi>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef __V4L2_COMMON__
#define __V4L2_COMMON__
/*
*
* Selection interface definitions
*
*/
/* Current cropping area */
#define V4L2_SEL_TGT_CROP 0x0000
/* Default cropping area */
#define V4L2_SEL_TGT_CROP_DEFAULT 0x0001
/* Cropping bounds */
#define V4L2_SEL_TGT_CROP_BOUNDS 0x0002
/* Current composing area */
#define V4L2_SEL_TGT_COMPOSE 0x0100
/* Default composing area */
#define V4L2_SEL_TGT_COMPOSE_DEFAULT 0x0101
/* Composing bounds */
#define V4L2_SEL_TGT_COMPOSE_BOUNDS 0x0102
/* Current composing area plus all padding pixels */
#define V4L2_SEL_TGT_COMPOSE_PADDED 0x0103
/* Backward compatibility target definitions --- to be removed. */
#define V4L2_SEL_TGT_CROP_ACTIVE V4L2_SEL_TGT_CROP
#define V4L2_SEL_TGT_COMPOSE_ACTIVE V4L2_SEL_TGT_COMPOSE
#define V4L2_SUBDEV_SEL_TGT_CROP_ACTUAL V4L2_SEL_TGT_CROP
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_ACTUAL V4L2_SEL_TGT_COMPOSE
#define V4L2_SUBDEV_SEL_TGT_CROP_BOUNDS V4L2_SEL_TGT_CROP_BOUNDS
#define V4L2_SUBDEV_SEL_TGT_COMPOSE_BOUNDS V4L2_SEL_TGT_COMPOSE_BOUNDS
/* Selection flags */
#define V4L2_SEL_FLAG_GE (1 << 0)
#define V4L2_SEL_FLAG_LE (1 << 1)
#define V4L2_SEL_FLAG_KEEP_CONFIG (1 << 2)
/* Backward compatibility flag definitions --- to be removed. */
#define V4L2_SUBDEV_SEL_FLAG_SIZE_GE V4L2_SEL_FLAG_GE
#define V4L2_SUBDEV_SEL_FLAG_SIZE_LE V4L2_SEL_FLAG_LE
#define V4L2_SUBDEV_SEL_FLAG_KEEP_CONFIG V4L2_SEL_FLAG_KEEP_CONFIG
#endif /* __V4L2_COMMON__ */
This diff is collapsed.
This diff is collapsed.
......@@ -26,12 +26,10 @@
# include <config.h>
#endif
#if HAVE_DECL_V4L2_MEMORY_DMABUF
#ifndef _GNU_SOURCE
# define _GNU_SOURCE /* O_CLOEXEC */
#endif
#include <fcntl.h>
#endif
#include <sys/mman.h>
#include <string.h>
......@@ -48,14 +46,6 @@
#include "gst/gst-i18n-plugin.h"
#include <gst/glib-compat-private.h>
/* videodev2.h is not versioned and we can't easily check for the presence
* of enum values at compile time, but the V4L2_CAP_VIDEO_OUTPUT_OVERLAY define
* was added in the same commit as V4L2_FIELD_INTERLACED_{TB,BT} (b2787845) */
#ifndef V4L2_CAP_VIDEO_OUTPUT_OVERLAY
#define V4L2_FIELD_INTERLACED_TB 8
#define V4L2_FIELD_INTERLACED_BT 9
#endif
GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
#define GST_CAT_DEFAULT v4l2_debug
......@@ -167,7 +157,6 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
case GST_V4L2_IO_MMAP:
case GST_V4L2_IO_DMABUF:
{
#ifdef VIDIOC_CREATE_BUFS
if (pool->num_allocated == pool->num_buffers) {
struct v4l2_create_buffers create_bufs;
......@@ -188,7 +177,7 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
pool->buffers = g_renew (GstBuffer *, pool->buffers, pool->num_buffers);
pool->buffers[pool->num_buffers - 1] = NULL;
}
#endif
newbuf = gst_buffer_new ();
meta = GST_V4L2_META_ADD (newbuf);
......@@ -264,7 +253,7 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
meta->vplanes[i].length, NULL, NULL));
}
}
#if HAVE_DECL_V4L2_MEMORY_DMABUF
if (obj->mode == GST_V4L2_IO_DMABUF) {
struct v4l2_exportbuffer expbuf;
......@@ -292,7 +281,7 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
if (!V4L2_TYPE_IS_MULTIPLANAR (obj->type))
meta->vplanes[0].m.fd = meta->vbuffer.m.fd;
}
#endif
/* add metadata to raw video buffers */
if (pool->add_videometa && info->finfo) {
const GstVideoFormatInfo *finfo = info->finfo;
......@@ -365,7 +354,6 @@ gst_v4l2_buffer_pool_alloc_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
return GST_FLOW_OK;
/* ERRORS */
#ifdef VIDIOC_CREATE_BUFS
g_fmt_failed:
{
gint errnosave = errno;
......@@ -382,7 +370,6 @@ create_bufs_failed:
errno = errnosave;
return GST_FLOW_ERROR;
}
#endif
querybuf_failed:
{
gint errnosave = errno;
......@@ -401,7 +388,6 @@ mmap_failed:
errno = errnosave;
return GST_FLOW_ERROR;
}
#if HAVE_DECL_V4L2_MEMORY_DMABUF
expbuf_failed:
{
gint errnosave = errno;
......@@ -411,7 +397,6 @@ expbuf_failed:
errno = errnosave;
return GST_FLOW_ERROR;
}
#endif
}
static gboolean
......@@ -895,11 +880,10 @@ gst_v4l2_buffer_pool_dqbuf (GstV4l2BufferPool * pool, GstBuffer ** buffer)
/* prepare the buffer */
memset (&vbuffer, 0x00, sizeof (vbuffer));
vbuffer.type = obj->type;
#if HAVE_DECL_V4L2_MEMORY_DMABUF
if (obj->mode == GST_V4L2_IO_DMABUF)
vbuffer.memory = V4L2_MEMORY_DMABUF;
else
#endif
vbuffer.memory = V4L2_MEMORY_MMAP;
/* prepare the planes of the buffer */
......@@ -1106,7 +1090,7 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
/* start copying buffers when we are running low on buffers */
if (pool->num_queued < pool->copy_threshold) {
GstBuffer *copy;
#ifdef VIDIOC_CREATE_BUFS
if (pool->can_alloc) {
if (GST_BUFFER_POOL_CLASS (parent_class)->acquire_buffer (bpool,
&copy, params) == GST_FLOW_OK) {
......@@ -1116,7 +1100,6 @@ gst_v4l2_buffer_pool_acquire_buffer (GstBufferPool * bpool, GstBuffer ** buffer,
pool->can_alloc = FALSE;
}
}
#endif
/* copy the buffer */
copy = gst_buffer_copy_region (*buffer,
......
This diff is collapsed.
......@@ -24,30 +24,7 @@
#ifndef __GST_V4L2_OBJECT_H__
#define __GST_V4L2_OBJECT_H__
/* Because of some really cool feature in video4linux1, also known as
* 'not including sys/types.h and sys/time.h', we had to include it
* ourselves. In all their intelligence, these people decided to fix
* this in the next version (video4linux2) in such a cool way that it
* breaks all compilations of old stuff...
* The real problem is actually that linux/time.h doesn't use proper
* macro checks before defining types like struct timeval. The proper
* fix here is to either fuck the kernel header (which is what we do
* by defining _LINUX_TIME_H, an innocent little hack) or by fixing it
* upstream, which I'll consider doing later on. If you get compiler
* errors here, check your linux/time.h && sys/time.h header setup.
*/
#include <sys/ioctl.h>
#include <sys/types.h>
#ifdef __sun
#include <sys/videodev2.h>
#elif defined(__FreeBSD__)
#include <linux/videodev2.h>
#else /* linux */
#include <linux/types.h>
#define _LINUX_TIME_H
#define __user
#include <linux/videodev2.h>
#endif
#include "ext/videodev2.h"
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
......
......@@ -33,14 +33,6 @@
GST_DEBUG_CATEGORY_STATIC (v4l2vo_debug);
#define GST_CAT_DEFAULT v4l2vo_debug
/* Those are deprecated calls that have been replaced */
#ifndef V4L2_CID_HCENTER
#define V4L2_CID_HCENTER V4L2_CID_PAN_RESET
#endif
#ifndef V4L2_CID_VCENTER
#define V4L2_CID_VCENTER V4L2_CID_TILT_RESET
#endif
void
gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * iface)
{
......@@ -64,18 +56,20 @@ gst_v4l2_video_orientation_get_vflip (GstV4l2Object * v4l2object,
return gst_v4l2_get_attribute (v4l2object, V4L2_CID_VFLIP, flip);
}
/* named hcenter because of historical v4l2 naming */
gboolean
gst_v4l2_video_orientation_get_hcenter (GstV4l2Object * v4l2object,
gint * center)
{
return gst_v4l2_get_attribute (v4l2object, V4L2_CID_HCENTER, center);
return gst_v4l2_get_attribute (v4l2object, V4L2_CID_PAN_RESET, center);
}
/* named vcenter because of historical v4l2 naming */
gboolean
gst_v4l2_video_orientation_get_vcenter (GstV4l2Object * v4l2object,
gint * center)
{
return gst_v4l2_get_attribute (v4l2object, V4L2_CID_VCENTER, center);
return gst_v4l2_get_attribute (v4l2object, V4L2_CID_TILT_RESET, center);
}
gboolean
......@@ -93,11 +87,11 @@ gst_v4l2_video_orientation_set_vflip (GstV4l2Object * v4l2object, gboolean flip)
gboolean
gst_v4l2_video_orientation_set_hcenter (GstV4l2Object * v4l2object, gint center)
{
return gst_v4l2_set_attribute (v4l2object, V4L2_CID_HCENTER, center);
return gst_v4l2_set_attribute (v4l2object, V4L2_CID_PAN_RESET, center);
}
gboolean
gst_v4l2_video_orientation_set_vcenter (GstV4l2Object * v4l2object, gint center)
{
return gst_v4l2_set_attribute (v4l2object, V4L2_CID_VCENTER, center);
return gst_v4l2_set_attribute (v4l2object, V4L2_CID_TILT_RESET, center);
}
......@@ -51,21 +51,6 @@
#include "gst/gst-i18n-plugin.h"
/* Those are ioctl calls */
#ifndef V4L2_CID_HCENTER
#define V4L2_CID_HCENTER V4L2_CID_HCENTER_DEPRECATED
#endif
#ifndef V4L2_CID_VCENTER
#define V4L2_CID_VCENTER V4L2_CID_VCENTER_DEPRECATED
#endif
#ifndef V4L2_CAP_VIDEO_M2M
#define V4L2_CAP_VIDEO_M2M 0x00008000
#endif
#ifndef V4L2_CAP_VIDEO_M2M_MPLANE
#define V4L2_CAP_VIDEO_M2M_MPLANE 0x00004000
#endif
GST_DEBUG_CATEGORY_EXTERN (v4l2_debug);
#define GST_CAT_DEFAULT v4l2_debug
......@@ -273,14 +258,10 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
GST_DEBUG_OBJECT (e, " controls+menus");
/* and lastly, controls+menus (if appropriate) */
#ifdef V4L2_CTRL_FLAG_NEXT_CTRL
next = V4L2_CTRL_FLAG_NEXT_CTRL;
n = 0;
#else
next = 0;
n = V4L2_CID_BASE;
#endif
control.id = next;
while (TRUE) {
GstV4l2ColorBalanceChannel *v4l2channel;
GstColorBalanceChannel *channel;
......@@ -332,22 +313,18 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
GST_DEBUG_OBJECT (e, "skipping disabled control");
continue;
}
#ifdef V4L2_CTRL_TYPE_CTRL_CLASS
if (control.type == V4L2_CTRL_TYPE_CTRL_CLASS) {
GST_DEBUG_OBJECT (e, "starting control class '%s'", control.name);
continue;
}
#endif
switch (control.type) {
case V4L2_CTRL_TYPE_INTEGER:
case V4L2_CTRL_TYPE_BOOLEAN:
case V4L2_CTRL_TYPE_MENU:
#ifdef V4L2_CTRL_TYPE_INTEGER_MENU
case V4L2_CTRL_TYPE_INTEGER_MENU:
#endif
#ifdef V4L2_CTRL_TYPE_BITMASK
case V4L2_CTRL_TYPE_BITMASK:
#endif
case V4L2_CTRL_TYPE_BUTTON:{
control.name[31] = '\0';
gst_v4l2_normalise_control_name ((gchar *) control.name);
......@@ -377,25 +354,13 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
case V4L2_CID_EXPOSURE:
case V4L2_CID_AUTOGAIN:
case V4L2_CID_GAIN:
#ifdef V4L2_CID_SHARPNESS
case V4L2_CID_SHARPNESS:
#endif
/* we only handle these for now (why?) */
break;
case V4L2_CID_HFLIP:
case V4L2_CID_VFLIP:
#ifndef V4L2_CID_PAN_RESET
case V4L2_CID_HCENTER:
#endif
#ifndef V4L2_CID_TILT_RESET
case V4L2_CID_VCENTER:
#endif
#ifdef V4L2_CID_PAN_RESET
case V4L2_CID_PAN_RESET:
#endif
#ifdef V4L2_CID_TILT_RESET
case V4L2_CID_TILT_RESET:
#endif
/* not handled here, handled by VideoOrientation interface */
control.id++;
break;
......@@ -515,12 +480,7 @@ gst_v4l2_adjust_buf_type (GstV4l2Object * v4l2object)
* in a contiguous manner. In this case the first v4l2 plane
* contains all the gst planes.
*/
#ifdef V4L2_CAP_VIDEO_M2M_MPLANE
#define CHECK_CAPS (V4L2_CAP_VIDEO_OUTPUT_MPLANE | V4L2_CAP_VIDEO_M2M_MPLANE)
#else
#define CHECK_CAPS (V4L2_CAP_VIDEO_OUTPUT_MPLANE)
#endif
switch (v4l2object->type) {
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
if (v4l2object->vcap.capabilities & CHECK_CAPS) {
......@@ -537,6 +497,7 @@ gst_v4l2_adjust_buf_type (GstV4l2Object * v4l2object)
default:
break;
}
#undef CHECK_CAPS
}
/******************************************************
......
......@@ -7,7 +7,6 @@ else
GTK_TESTS =
endif
if USE_GST_V4L2
V4L2_TESTS = v4l2src-test
v4l2src_test_SOURCES = v4l2src-test.c
......@@ -15,10 +14,6 @@ v4l2src_test_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) $(GST_CFLAGS)
v4l2src_test_LDADD = $(GST_PLUGINS_BASE_LIBS) \
-lgstvideo-$(GST_API_VERSION)
else
V4L2_TESTS =
endif
if USE_OSS4
OSS4_TESTS=test-oss4
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment