2006-09-02 14:28:55 +00:00
|
|
|
/* GStreamer
|
|
|
|
*
|
2002-09-09 07:14:35 +00:00
|
|
|
* Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2006-09-02 14:28:55 +00:00
|
|
|
* 2006 Edgard Lima <edgard.lima@indt.org.br>
|
|
|
|
*
|
|
|
|
* v4l2_calls.h - generic V4L2 calls handling
|
2002-09-09 07:14:35 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:07:18 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2002-09-09 07:14:35 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __V4L2_CALLS_H__
|
|
|
|
#define __V4L2_CALLS_H__
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
#include "gstv4l2object.h"
|
2002-09-09 07:14:35 +00:00
|
|
|
|
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
Original commit message from CVS:
Patch by: Bastien Nocera <hadess at hadess dot net>,
Hans de Goede <jwrdegoede at fedoraproject dot org>
* configure.ac:
* sys/v4l2/Makefile.am:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_close),
(gst_v4l2_get_norm), (gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2_calls.h:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_new), (gst_v4l2_buffer_pool_finalize),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format_and_size),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_get_nearest_size):
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
2008-11-04 12:32:48 +00:00
|
|
|
#ifdef HAVE_LIBV4L2
|
2009-08-04 07:14:20 +00:00
|
|
|
# include <libv4l2.h>
|
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
Original commit message from CVS:
Patch by: Bastien Nocera <hadess at hadess dot net>,
Hans de Goede <jwrdegoede at fedoraproject dot org>
* configure.ac:
* sys/v4l2/Makefile.am:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_close),
(gst_v4l2_get_norm), (gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2_calls.h:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_new), (gst_v4l2_buffer_pool_finalize),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format_and_size),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_get_nearest_size):
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
2008-11-04 12:32:48 +00:00
|
|
|
#else
|
2009-08-04 07:14:20 +00:00
|
|
|
# include <sys/ioctl.h>
|
|
|
|
# include <linux/videodev2.h>
|
|
|
|
# define v4l2_fd_open(fd, flags) (fd)
|
|
|
|
# define v4l2_close close
|
|
|
|
# define v4l2_dup dup
|
|
|
|
# define v4l2_ioctl ioctl
|
|
|
|
# define v4l2_read read
|
|
|
|
# define v4l2_mmap mmap
|
|
|
|
# define v4l2_munmap munmap
|
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
Original commit message from CVS:
Patch by: Bastien Nocera <hadess at hadess dot net>,
Hans de Goede <jwrdegoede at fedoraproject dot org>
* configure.ac:
* sys/v4l2/Makefile.am:
* sys/v4l2/gstv4l2src.c: (gst_v4l2src_get_read):
* sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities),
(gst_v4l2_fill_lists), (gst_v4l2_open), (gst_v4l2_close),
(gst_v4l2_get_norm), (gst_v4l2_set_norm), (gst_v4l2_get_frequency),
(gst_v4l2_set_frequency), (gst_v4l2_signal_strength),
(gst_v4l2_get_attribute), (gst_v4l2_set_attribute),
(gst_v4l2_get_input), (gst_v4l2_set_input):
* sys/v4l2/v4l2_calls.h:
* sys/v4l2/v4l2src_calls.c: (gst_v4l2_buffer_finalize),
(gst_v4l2_buffer_new), (gst_v4l2_buffer_pool_finalize),
(gst_v4l2_buffer_pool_new), (gst_v4l2_buffer_pool_activate),
(gst_v4l2src_fill_format_list),
(gst_v4l2src_probe_caps_for_format_and_size),
(gst_v4l2src_probe_caps_for_format), (gst_v4l2src_grab_frame),
(gst_v4l2src_set_capture), (gst_v4l2src_capture_init),
(gst_v4l2src_capture_start), (gst_v4l2src_capture_stop),
(gst_v4l2src_get_nearest_size):
Optionally use libv4l to access v4l2 devices. Fixes bug #545033.
2008-11-04 12:32:48 +00:00
|
|
|
#endif
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
#define GST_V4L2_IS_OVERLAY(v4l2object) \
|
|
|
|
(v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
/* checks whether the current v4lv4l2object has already been open()'ed or not */
|
|
|
|
#define GST_V4L2_CHECK_OPEN(v4l2object) \
|
|
|
|
if (!GST_V4L2_IS_OPEN(v4l2object)) \
|
2006-03-11 22:50:03 +00:00
|
|
|
{ \
|
2006-09-26 13:18:06 +00:00
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
|
2004-02-02 17:23:33 +00:00
|
|
|
(_("Device is not open.")), (NULL)); \
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE; \
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
/* checks whether the current v4lv4l2object is close()'ed or whether it is still open */
|
|
|
|
#define GST_V4L2_CHECK_NOT_OPEN(v4l2object) \
|
|
|
|
if (GST_V4L2_IS_OPEN(v4l2object)) \
|
2006-03-11 22:50:03 +00:00
|
|
|
{ \
|
2006-09-26 13:18:06 +00:00
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
|
2004-02-02 17:23:33 +00:00
|
|
|
(_("Device is open.")), (NULL)); \
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE; \
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
/* checks whether the current v4lv4l2object does video overlay */
|
|
|
|
#define GST_V4L2_CHECK_OVERLAY(v4l2object) \
|
|
|
|
if (!GST_V4L2_IS_OVERLAY(v4l2object)) \
|
2006-03-11 22:50:03 +00:00
|
|
|
{ \
|
2006-09-26 13:18:06 +00:00
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
|
2004-02-02 17:23:33 +00:00
|
|
|
(NULL), ("Device cannot handle overlay")); \
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE; \
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* checks whether we're in capture mode or not */
|
2006-05-11 17:59:59 +00:00
|
|
|
#define GST_V4L2_CHECK_ACTIVE(v4l2object) \
|
|
|
|
if (!GST_V4L2_IS_ACTIVE(v4l2object)) \
|
2006-03-11 22:50:03 +00:00
|
|
|
{ \
|
2006-05-11 17:59:59 +00:00
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
|
2004-02-02 17:23:33 +00:00
|
|
|
(NULL), ("Device is not in streaming mode")); \
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE; \
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* checks whether we're out of capture mode or not */
|
2006-05-11 17:59:59 +00:00
|
|
|
#define GST_V4L2_CHECK_NOT_ACTIVE(v4l2object) \
|
|
|
|
if (GST_V4L2_IS_ACTIVE(v4l2object)) \
|
2006-03-11 22:50:03 +00:00
|
|
|
{ \
|
2006-05-11 17:59:59 +00:00
|
|
|
GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
|
2004-02-02 17:23:33 +00:00
|
|
|
(NULL), ("Device is in streaming mode")); \
|
2006-03-11 22:50:03 +00:00
|
|
|
return FALSE; \
|
2002-09-09 07:14:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* open/close the device */
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_open (GstV4l2Object *v4l2object);
|
|
|
|
gboolean gst_v4l2_close (GstV4l2Object *v4l2object);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
/* norm/input/output */
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_get_norm (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
v4l2_std_id *norm);
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_set_norm (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
v4l2_std_id norm);
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_get_input (GstV4l2Object * v4l2object,
|
|
|
|
gint * input);
|
|
|
|
gboolean gst_v4l2_set_input (GstV4l2Object * v4l2object,
|
|
|
|
gint input);
|
|
|
|
gboolean gst_v4l2_get_output (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
gint *output);
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_set_output (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
gint output);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
/* frequency control */
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_get_frequency (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
gint tunernum,
|
|
|
|
gulong *frequency);
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_set_frequency (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
gint tunernum,
|
|
|
|
gulong frequency);
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_signal_strength (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
gint tunernum,
|
|
|
|
gulong *signal);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
|
|
|
/* attribute control */
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_get_attribute (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
int attribute,
|
|
|
|
int *value);
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_set_attribute (GstV4l2Object *v4l2object,
|
2006-03-11 22:50:03 +00:00
|
|
|
int attribute,
|
|
|
|
const int value);
|
|
|
|
|
2006-05-11 17:59:59 +00:00
|
|
|
gboolean gst_v4l2_get_capabilities (GstV4l2Object * v4l2object);
|
2002-09-09 07:14:35 +00:00
|
|
|
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2009-08-04 12:44:36 +00:00
|
|
|
#define LOG_CAPS(obj, caps) GST_DEBUG_OBJECT (obj, "%s: %" GST_PTR_FORMAT, #caps, caps)
|
2009-08-04 07:14:20 +00:00
|
|
|
|
2002-09-09 07:14:35 +00:00
|
|
|
#endif /* __V4L2_CALLS_H__ */
|