v4l2: Merge v4l2_calls.h into gstv4l2object.h
First step of a larger cleanup, all function from v4l2_calls are in fact
methods on GstV4l2Object. This split makes the code really confusing.
This also remove no longer unused macros.
diff --git a/sys/v4l2/Makefile.am b/sys/v4l2/Makefile.am
index ccb34f5..4485f11 100644
--- a/sys/v4l2/Makefile.am
+++ b/sys/v4l2/Makefile.am
@@ -59,7 +59,6 @@
gstv4l2videoenc.h \
gstv4l2h264enc.h \
gstv4l2vidorient.h \
- v4l2_calls.h \
v4l2-utils.h \
tuner.h \
tunerchannel.h \
diff --git a/sys/v4l2/gstv4l2.c b/sys/v4l2/gstv4l2.c
index dfe4ecd..9c84735 100644
--- a/sys/v4l2/gstv4l2.c
+++ b/sys/v4l2/gstv4l2.c
@@ -51,7 +51,7 @@
#include "gstv4l2deviceprovider.h"
#include "gstv4l2transform.h"
-/* used in v4l2_calls.c and v4l2src_calls.c */
+/* used in gstv4l2object.c and v4l2_calls.c */
GST_DEBUG_CATEGORY (v4l2_debug);
#define GST_CAT_DEFAULT v4l2_debug
diff --git a/sys/v4l2/gstv4l2allocator.c b/sys/v4l2/gstv4l2allocator.c
index 656091a..122a8b5 100644
--- a/sys/v4l2/gstv4l2allocator.c
+++ b/sys/v4l2/gstv4l2allocator.c
@@ -26,8 +26,9 @@
#endif
#include "ext/videodev2.h"
+
+#include "gstv4l2object.h"
#include "gstv4l2allocator.h"
-#include "v4l2_calls.h"
#include <gst/allocators/gstdmabuf.h>
diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c
index 16abfcc..edfba00 100644
--- a/sys/v4l2/gstv4l2bufferpool.c
+++ b/sys/v4l2/gstv4l2bufferpool.c
@@ -42,7 +42,7 @@
#include <gstv4l2bufferpool.h>
-#include "v4l2_calls.h"
+#include "gstv4l2object.h"
#include "gst/gst-i18n-plugin.h"
#include <gst/glib-compat-private.h>
diff --git a/sys/v4l2/gstv4l2colorbalance.h b/sys/v4l2/gstv4l2colorbalance.h
index 2668906..90ba7ab 100644
--- a/sys/v4l2/gstv4l2colorbalance.h
+++ b/sys/v4l2/gstv4l2colorbalance.h
@@ -26,7 +26,8 @@
#include <gst/gst.h>
#include <gst/video/colorbalance.h>
-#include "v4l2_calls.h"
+
+#include "gstv4l2object.h"
G_BEGIN_DECLS
diff --git a/sys/v4l2/gstv4l2deviceprovider.c b/sys/v4l2/gstv4l2deviceprovider.c
index 61ca135..4b003e7 100644
--- a/sys/v4l2/gstv4l2deviceprovider.c
+++ b/sys/v4l2/gstv4l2deviceprovider.c
@@ -31,7 +31,6 @@
#include <gst/gst.h>
#include "gstv4l2object.h"
-#include "v4l2_calls.h"
#include "v4l2-utils.h"
#ifdef HAVE_GUDEV
diff --git a/sys/v4l2/gstv4l2h264enc.c b/sys/v4l2/gstv4l2h264enc.c
index 232840b..0a1faec 100644
--- a/sys/v4l2/gstv4l2h264enc.c
+++ b/sys/v4l2/gstv4l2h264enc.c
@@ -29,8 +29,8 @@
#include <unistd.h>
#include <string.h>
+#include "gstv4l2object.h"
#include "gstv4l2h264enc.h"
-#include "v4l2_calls.h"
#include <string.h>
#include <gst/gst-i18n-plugin.h>
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index 14abf7c..4c27372 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -32,7 +32,7 @@
#include <gudev/gudev.h>
#endif
-#include "v4l2_calls.h"
+#include "gstv4l2object.h"
#include "gstv4l2tuner.h"
#include "gstv4l2colorbalance.h"
diff --git a/sys/v4l2/gstv4l2object.h b/sys/v4l2/gstv4l2object.h
index 231b1ab..54fb1be 100644
--- a/sys/v4l2/gstv4l2object.h
+++ b/sys/v4l2/gstv4l2object.h
@@ -24,6 +24,22 @@
#ifndef __GST_V4L2_OBJECT_H__
#define __GST_V4L2_OBJECT_H__
+#ifdef HAVE_LIBV4L2
+# include <libv4l2.h>
+#else
+# include "ext/videodev2.h"
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <unistd.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
+#endif
+
#include "ext/videodev2.h"
#include "v4l2-utils.h"
@@ -78,6 +94,34 @@
#define GST_V4L2_SET_ACTIVE(o) ((o)->active = TRUE)
#define GST_V4L2_SET_INACTIVE(o) ((o)->active = FALSE)
+/* checks whether the current v4lv4l2object has already been open()'ed or not */
+#define GST_V4L2_CHECK_OPEN(v4l2object) \
+ if (!GST_V4L2_IS_OPEN(v4l2object)) \
+ { \
+ GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
+ (_("Device is not open.")), (NULL)); \
+ return FALSE; \
+ }
+
+/* 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)) \
+ { \
+ GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
+ (_("Device is open.")), (NULL)); \
+ return FALSE; \
+ }
+
+/* checks whether we're out of capture mode or not */
+#define GST_V4L2_CHECK_NOT_ACTIVE(v4l2object) \
+ if (GST_V4L2_IS_ACTIVE(v4l2object)) \
+ { \
+ GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
+ (NULL), ("Device is in streaming mode")); \
+ return FALSE; \
+ }
+
+
struct _GstV4l2Object {
GstElement * element;
@@ -208,7 +252,7 @@
GstV4l2SetInOutFunction set_in_out_func,
GstV4l2UpdateFpsFunction update_fps_func);
-void gst_v4l2_object_destroy (GstV4l2Object * v4l2object);
+void gst_v4l2_object_destroy (GstV4l2Object * v4l2object);
/* properties */
@@ -225,49 +269,70 @@
guint prop_id, GValue * value,
GParamSpec * pspec);
/* open/close */
-gboolean gst_v4l2_object_open (GstV4l2Object *v4l2object);
-gboolean gst_v4l2_object_open_shared (GstV4l2Object *v4l2object, GstV4l2Object *other);
-gboolean gst_v4l2_object_close (GstV4l2Object *v4l2object);
+gboolean gst_v4l2_object_open (GstV4l2Object * v4l2object);
+gboolean gst_v4l2_object_open_shared (GstV4l2Object * v4l2object, GstV4l2Object * other);
+gboolean gst_v4l2_object_close (GstV4l2Object * v4l2object);
/* probing */
-GstCaps* gst_v4l2_object_get_all_caps (void);
+GstCaps* gst_v4l2_object_get_all_caps (void);
-GstCaps* gst_v4l2_object_get_raw_caps (void);
+GstCaps* gst_v4l2_object_get_raw_caps (void);
-GstCaps* gst_v4l2_object_get_codec_caps (void);
+GstCaps* gst_v4l2_object_get_codec_caps (void);
-gint gst_v4l2_object_extrapolate_stride (const GstVideoFormatInfo * finfo,
+gint gst_v4l2_object_extrapolate_stride (const GstVideoFormatInfo * finfo,
gint plane, gint stride);
-gboolean gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps, GstV4l2Error *error);
-gboolean gst_v4l2_object_try_format (GstV4l2Object * v4l2object, GstCaps * caps, GstV4l2Error *error);
+gboolean gst_v4l2_object_set_format (GstV4l2Object * v4l2object, GstCaps * caps, GstV4l2Error * error);
+gboolean gst_v4l2_object_try_format (GstV4l2Object * v4l2object, GstCaps * caps, GstV4l2Error * error);
-gboolean gst_v4l2_object_caps_equal (GstV4l2Object * v4l2object, GstCaps * caps);
+gboolean gst_v4l2_object_caps_equal (GstV4l2Object * v4l2object, GstCaps * caps);
-gboolean gst_v4l2_object_unlock (GstV4l2Object * v4l2object);
-gboolean gst_v4l2_object_unlock_stop (GstV4l2Object * v4l2object);
+gboolean gst_v4l2_object_unlock (GstV4l2Object * v4l2object);
+gboolean gst_v4l2_object_unlock_stop (GstV4l2Object * v4l2object);
-gboolean gst_v4l2_object_stop (GstV4l2Object * v4l2object);
+gboolean gst_v4l2_object_stop (GstV4l2Object * v4l2object);
-GstCaps * gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object,
- GstCaps * filter);
-GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object,
- GstCaps * filter);
+GstCaps * gst_v4l2_object_probe_caps (GstV4l2Object * v4l2object, GstCaps * filter);
+GstCaps * gst_v4l2_object_get_caps (GstV4l2Object * v4l2object, GstCaps * filter);
-gboolean gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object,
- GstVideoInfo * info);
+gboolean gst_v4l2_object_acquire_format (GstV4l2Object * v4l2object, GstVideoInfo * info);
-gboolean gst_v4l2_object_set_crop (GstV4l2Object * obj);
+gboolean gst_v4l2_object_set_crop (GstV4l2Object * obj);
-gboolean gst_v4l2_object_decide_allocation (GstV4l2Object * v4l2object,
- GstQuery * query);
+gboolean gst_v4l2_object_decide_allocation (GstV4l2Object * v4l2object, GstQuery * query);
-gboolean gst_v4l2_object_propose_allocation (GstV4l2Object * obj,
- GstQuery * query);
+gboolean gst_v4l2_object_propose_allocation (GstV4l2Object * obj, GstQuery * query);
GstStructure * gst_v4l2_object_v4l2fourcc_to_structure (guint32 fourcc);
+/* TODO Move to proper namespace */
+/* open/close the device */
+gboolean gst_v4l2_open (GstV4l2Object * v4l2object);
+gboolean gst_v4l2_dup (GstV4l2Object * v4l2object, GstV4l2Object * other);
+gboolean gst_v4l2_close (GstV4l2Object * v4l2object);
+
+/* norm/input/output */
+gboolean gst_v4l2_get_norm (GstV4l2Object * v4l2object, v4l2_std_id * norm);
+gboolean gst_v4l2_set_norm (GstV4l2Object * v4l2object, v4l2_std_id norm);
+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, gint * output);
+gboolean gst_v4l2_set_output (GstV4l2Object * v4l2object, gint output);
+
+/* frequency control */
+gboolean gst_v4l2_get_frequency (GstV4l2Object * v4l2object, gint tunernum, gulong * frequency);
+gboolean gst_v4l2_set_frequency (GstV4l2Object * v4l2object, gint tunernum, gulong frequency);
+gboolean gst_v4l2_signal_strength (GstV4l2Object * v4l2object, gint tunernum, gulong * signal);
+
+/* attribute control */
+gboolean gst_v4l2_get_attribute (GstV4l2Object * v4l2object, int attribute, int * value);
+gboolean gst_v4l2_set_attribute (GstV4l2Object * v4l2object, int attribute, const int value);
+gboolean gst_v4l2_set_controls (GstV4l2Object * v4l2object, GstStructure * controls);
+
+gboolean gst_v4l2_get_capabilities (GstV4l2Object * v4l2object);
+
G_END_DECLS
#endif /* __GST_V4L2_OBJECT_H__ */
diff --git a/sys/v4l2/gstv4l2radio.c b/sys/v4l2/gstv4l2radio.c
index 5d74e7e..77e4715 100644
--- a/sys/v4l2/gstv4l2radio.c
+++ b/sys/v4l2/gstv4l2radio.c
@@ -44,9 +44,9 @@
#include "gst/gst-i18n-plugin.h"
+#include "gstv4l2object.h"
#include "gstv4l2tuner.h"
#include "gstv4l2radio.h"
-#include "v4l2_calls.h"
GST_DEBUG_CATEGORY_STATIC (v4l2radio_debug);
#define GST_CAT_DEFAULT v4l2radio_debug
diff --git a/sys/v4l2/gstv4l2transform.c b/sys/v4l2/gstv4l2transform.c
index 96e8ef5..e74d79e 100644
--- a/sys/v4l2/gstv4l2transform.c
+++ b/sys/v4l2/gstv4l2transform.c
@@ -29,8 +29,8 @@
#include <unistd.h>
#include <string.h>
+#include "gstv4l2object.h"
#include "gstv4l2transform.h"
-#include "v4l2_calls.h"
#include <string.h>
#include <gst/gst-i18n-plugin.h>
diff --git a/sys/v4l2/gstv4l2tuner.c b/sys/v4l2/gstv4l2tuner.c
index ac3f1b6..66cc2c1 100644
--- a/sys/v4l2/gstv4l2tuner.c
+++ b/sys/v4l2/gstv4l2tuner.c
@@ -27,9 +27,9 @@
#include <gst/gst.h>
+#include "gstv4l2object.h"
#include "gstv4l2tuner.h"
#include "gstv4l2object.h"
-#include "v4l2_calls.h"
G_DEFINE_TYPE (GstV4l2TunerChannel, gst_v4l2_tuner_channel,
GST_TYPE_TUNER_CHANNEL);
diff --git a/sys/v4l2/gstv4l2videodec.c b/sys/v4l2/gstv4l2videodec.c
index ed1369b..1377e10 100644
--- a/sys/v4l2/gstv4l2videodec.c
+++ b/sys/v4l2/gstv4l2videodec.c
@@ -29,8 +29,8 @@
#include <unistd.h>
#include <string.h>
+#include "gstv4l2object.h"
#include "gstv4l2videodec.h"
-#include "v4l2_calls.h"
#include <string.h>
#include <gst/gst-i18n-plugin.h>
diff --git a/sys/v4l2/gstv4l2videoenc.c b/sys/v4l2/gstv4l2videoenc.c
index 11d0e3c..12f1eb4 100644
--- a/sys/v4l2/gstv4l2videoenc.c
+++ b/sys/v4l2/gstv4l2videoenc.c
@@ -31,8 +31,8 @@
#include <unistd.h>
#include <string.h>
+#include "gstv4l2object.h"
#include "gstv4l2videoenc.h"
-#include "v4l2_calls.h"
#include <string.h>
#include <gst/gst-i18n-plugin.h>
diff --git a/sys/v4l2/gstv4l2vidorient.c b/sys/v4l2/gstv4l2vidorient.c
index 488371c..9ccb455 100644
--- a/sys/v4l2/gstv4l2vidorient.c
+++ b/sys/v4l2/gstv4l2vidorient.c
@@ -26,9 +26,9 @@
#include <gst/gst.h>
+#include "gstv4l2object.h"
#include "gstv4l2vidorient.h"
#include "gstv4l2object.h"
-#include "v4l2_calls.h"
GST_DEBUG_CATEGORY_STATIC (v4l2vo_debug);
#define GST_CAT_DEFAULT v4l2vo_debug
diff --git a/sys/v4l2/v4l2_calls.c b/sys/v4l2/v4l2_calls.c
index da5e7e9..89517e9 100644
--- a/sys/v4l2/v4l2_calls.c
+++ b/sys/v4l2/v4l2_calls.c
@@ -38,11 +38,8 @@
#include <stropts.h>
#include <sys/ioccom.h>
#endif
-#include "v4l2_calls.h"
+#include "gstv4l2object.h"
#include "gstv4l2tuner.h"
-#if 0
-#include "gstv4l2xoverlay.h"
-#endif
#include "gstv4l2colorbalance.h"
#include "gstv4l2src.h"
diff --git a/sys/v4l2/v4l2_calls.h b/sys/v4l2/v4l2_calls.h
deleted file mode 100644
index 1560b9a..0000000
--- a/sys/v4l2/v4l2_calls.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* GStreamer
- *
- * Copyright (C) 2002 Ronald Bultje <rbultje@ronald.bitfreak.net>
- * 2006 Edgard Lima <edgard.lima@gmail.com>
- *
- * v4l2_calls.h - generic V4L2 calls handling
- *
- * 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
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef __V4L2_CALLS_H__
-#define __V4L2_CALLS_H__
-
-#include "gstv4l2object.h"
-
-#ifdef HAVE_LIBV4L2
-# include <libv4l2.h>
-#else
-# include "ext/videodev2.h"
-# include <sys/ioctl.h>
-# include <sys/mman.h>
-# include <unistd.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
-#endif
-
-#define GST_V4L2_IS_OVERLAY(v4l2object) \
- (v4l2object->vcap.capabilities & V4L2_CAP_VIDEO_OVERLAY)
-
-/* checks whether the current v4lv4l2object has already been open()'ed or not */
-#define GST_V4L2_CHECK_OPEN(v4l2object) \
- if (!GST_V4L2_IS_OPEN(v4l2object)) \
- { \
- GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
- (_("Device is not open.")), (NULL)); \
- return FALSE; \
- }
-
-/* 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)) \
- { \
- GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
- (_("Device is open.")), (NULL)); \
- return FALSE; \
- }
-
-/* checks whether the current v4lv4l2object does video overlay */
-#define GST_V4L2_CHECK_OVERLAY(v4l2object) \
- if (!GST_V4L2_IS_OVERLAY(v4l2object)) \
- { \
- GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
- (NULL), ("Device cannot handle overlay")); \
- return FALSE; \
- }
-
-/* checks whether we're in capture mode or not */
-#define GST_V4L2_CHECK_ACTIVE(v4l2object) \
- if (!GST_V4L2_IS_ACTIVE(v4l2object)) \
- { \
- GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
- (NULL), ("Device is not in streaming mode")); \
- return FALSE; \
- }
-
-/* checks whether we're out of capture mode or not */
-#define GST_V4L2_CHECK_NOT_ACTIVE(v4l2object) \
- if (GST_V4L2_IS_ACTIVE(v4l2object)) \
- { \
- GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, SETTINGS, \
- (NULL), ("Device is in streaming mode")); \
- return FALSE; \
- }
-
-
-/* open/close the device */
-gboolean gst_v4l2_open (GstV4l2Object *v4l2object);
-gboolean gst_v4l2_dup (GstV4l2Object *v4l2object, GstV4l2Object *other);
-gboolean gst_v4l2_close (GstV4l2Object *v4l2object);
-
-/* norm/input/output */
-gboolean gst_v4l2_get_norm (GstV4l2Object *v4l2object,
- v4l2_std_id *norm);
-gboolean gst_v4l2_set_norm (GstV4l2Object *v4l2object,
- v4l2_std_id norm);
-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,
- gint *output);
-gboolean gst_v4l2_set_output (GstV4l2Object *v4l2object,
- gint output);
-
-/* frequency control */
-gboolean gst_v4l2_get_frequency (GstV4l2Object *v4l2object,
- gint tunernum,
- gulong *frequency);
-gboolean gst_v4l2_set_frequency (GstV4l2Object *v4l2object,
- gint tunernum,
- gulong frequency);
-gboolean gst_v4l2_signal_strength (GstV4l2Object *v4l2object,
- gint tunernum,
- gulong *signal);
-
-/* attribute control */
-gboolean gst_v4l2_get_attribute (GstV4l2Object *v4l2object,
- int attribute,
- int *value);
-gboolean gst_v4l2_set_attribute (GstV4l2Object *v4l2object,
- int attribute,
- const int value);
-
-gboolean gst_v4l2_set_controls (GstV4l2Object * v4l2object,
- GstStructure * controls);
-
-gboolean gst_v4l2_get_capabilities (GstV4l2Object * v4l2object);
-
-
-#endif /* __V4L2_CALLS_H__ */