summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdgard Lima <edgard.lima@indt.org.br>2006-09-19 13:08:35 +0000
committerEdgard Lima <edgard.lima@indt.org.br>2006-09-19 13:08:35 +0000
commit7e3c500f05c60b8da5a48dde249e9d777beeb32f (patch)
tree1874cd12654eccb71baf6094862de619c00d3fa4
parentcdbd5ca1704398574665a634950b9023662b4167 (diff)
Add Video Orientation interface support to v4l2src.
Original commit message from CVS: Add Video Orientation interface support to v4l2src.
-rw-r--r--sys/v4l2/Makefile.am3
-rw-r--r--sys/v4l2/gstv4l2src.c16
-rw-r--r--sys/v4l2/gstv4l2vidorient.c96
-rw-r--r--sys/v4l2/gstv4l2vidorient.h127
-rw-r--r--tests/icles/v4l2src-test.c93
5 files changed, 330 insertions, 5 deletions
diff --git a/sys/v4l2/Makefile.am b/sys/v4l2/Makefile.am
index b3f58816..d40e7fe7 100644
--- a/sys/v4l2/Makefile.am
+++ b/sys/v4l2/Makefile.am
@@ -13,6 +13,7 @@ libgstvideo4linux2_la_SOURCES = gstv4l2.c \
gstv4l2object.c \
gstv4l2src.c \
gstv4l2tuner.c \
+ gstv4l2vidorient.c \
v4l2_calls.c \
v4l2src_calls.c \
$(xv_source)
@@ -33,4 +34,4 @@ libgstvideo4linux2_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
noinst_HEADERS = gstv4l2object.h v4l2_calls.h \
gstv4l2src.h v4l2src_calls.h \
gstv4l2tuner.h gstv4l2xoverlay.h \
- gstv4l2colorbalance.h
+ gstv4l2colorbalance.h gstv4l2vidorient.h
diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c
index cb6335b6..f652539e 100644
--- a/sys/v4l2/gstv4l2src.c
+++ b/sys/v4l2/gstv4l2src.c
@@ -54,6 +54,7 @@
#include "gstv4l2colorbalance.h"
#include "gstv4l2tuner.h"
#include "gstv4l2xoverlay.h"
+#include "gstv4l2vidorient.h"
static const GstElementDetails gst_v4l2src_details =
GST_ELEMENT_DETAILS ("Video (video4linux2/raw) Source",
@@ -138,6 +139,7 @@ GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Src, gst_v4l2src);
#ifdef HAVE_XVIDEO
GST_IMPLEMENT_V4L2_XOVERLAY_METHODS (GstV4l2Src, gst_v4l2src);
#endif
+GST_IMPLEMENT_V4L2_VIDORIENT_METHODS (GstV4l2Src, gst_v4l2src);
static gboolean
gst_v4l2src_iface_supported (GstImplementsInterface * iface, GType iface_type)
@@ -146,10 +148,13 @@ gst_v4l2src_iface_supported (GstImplementsInterface * iface, GType iface_type)
#ifdef HAVE_XVIDEO
g_assert (iface_type == GST_TYPE_TUNER ||
- iface_type == GST_TYPE_X_OVERLAY || iface_type == GST_TYPE_COLOR_BALANCE);
+ iface_type == GST_TYPE_X_OVERLAY ||
+ iface_type == GST_TYPE_COLOR_BALANCE ||
+ iface_type == GST_TYPE_VIDEO_ORIENTATION);
#else
g_assert (iface_type == GST_TYPE_TUNER ||
- iface_type == GST_TYPE_COLOR_BALANCE);
+ iface_type == GST_TYPE_COLOR_BALANCE ||
+ iface_type == GST_TYPE_VIDEO_ORIENTATION);
#endif
if (v4l2object->video_fd == -1)
@@ -197,6 +202,11 @@ gst_v4l2src_init_interfaces (GType type)
NULL,
NULL,
};
+ static const GInterfaceInfo v4l2_videoorientation_info = {
+ (GInterfaceInitFunc) gst_v4l2src_video_orientation_interface_init,
+ NULL,
+ NULL,
+ };
static const GInterfaceInfo v4l2_propertyprobe_info = {
(GInterfaceInitFunc) gst_v4l2src_property_probe_interface_init,
NULL,
@@ -211,6 +221,8 @@ gst_v4l2src_init_interfaces (GType type)
#endif
g_type_add_interface_static (type,
GST_TYPE_COLOR_BALANCE, &v4l2_colorbalance_info);
+ g_type_add_interface_static (type,
+ GST_TYPE_VIDEO_ORIENTATION, &v4l2_videoorientation_info);
g_type_add_interface_static (type, GST_TYPE_PROPERTY_PROBE,
&v4l2_propertyprobe_info);
}
diff --git a/sys/v4l2/gstv4l2vidorient.c b/sys/v4l2/gstv4l2vidorient.c
new file mode 100644
index 00000000..8f9c91af
--- /dev/null
+++ b/sys/v4l2/gstv4l2vidorient.c
@@ -0,0 +1,96 @@
+/* GStreamer
+ *
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * gstv4l2vidorient.c: video orientation interface implementation for V4L2
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gst/gst.h>
+
+#include "gstv4l2vidorient.h"
+#include "gstv4l2object.h"
+#include "v4l2_calls.h"
+#include "v4l2src_calls.h"
+
+GST_DEBUG_CATEGORY_STATIC (v4l2vo_debug);
+#define GST_CAT_DEFAULT v4l2vo_debug
+
+void
+gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * klass)
+{
+ GST_DEBUG_CATEGORY_INIT (v4l2vo_debug, "v4l2vo", 0,
+ "V4L2 VideoOrientation interface debugging");
+}
+
+
+gboolean
+gst_v4l2_video_orientation_get_hflip (GstV4l2Object * v4l2object,
+ gboolean * flip)
+{
+
+ return gst_v4l2_get_attribute (v4l2object, V4L2_CID_HFLIP, flip);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_get_vflip (GstV4l2Object * v4l2object,
+ gboolean * flip)
+{
+ return gst_v4l2_get_attribute (v4l2object, V4L2_CID_VFLIP, flip);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_get_hcenter (GstV4l2Object * v4l2object,
+ gint * center)
+{
+ return gst_v4l2_get_attribute (v4l2object, V4L2_CID_HCENTER, center);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_get_vcenter (GstV4l2Object * v4l2object,
+ gint * center)
+{
+ return gst_v4l2_get_attribute (v4l2object, V4L2_CID_VCENTER, center);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_set_hflip (GstV4l2Object * v4l2object, gboolean flip)
+{
+ return gst_v4l2_set_attribute (v4l2object, V4L2_CID_HFLIP, flip);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_set_vflip (GstV4l2Object * v4l2object, gboolean flip)
+{
+ return gst_v4l2_set_attribute (v4l2object, V4L2_CID_VFLIP, flip);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_set_hcenter (GstV4l2Object * v4l2object, gint center)
+{
+ return gst_v4l2_set_attribute (v4l2object, V4L2_CID_HCENTER, center);
+}
+
+extern gboolean
+gst_v4l2_video_orientation_set_vcenter (GstV4l2Object * v4l2object, gint center)
+{
+ return gst_v4l2_set_attribute (v4l2object, V4L2_CID_VCENTER, center);
+}
diff --git a/sys/v4l2/gstv4l2vidorient.h b/sys/v4l2/gstv4l2vidorient.h
new file mode 100644
index 00000000..fecaee56
--- /dev/null
+++ b/sys/v4l2/gstv4l2vidorient.h
@@ -0,0 +1,127 @@
+/* GStreamer
+ *
+ * Copyright (C) 2006 Edgard Lima <edgard.lima@indt.org.br>
+ *
+ * gstv4l2vidorient.h: video orientation interface implementation for V4L2
+ *
+ * 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., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GST_V4L2_VIDORIENT_H__
+#define __GST_V4L2_VIDORIENT_H__
+
+#include <gst/gst.h>
+#include <gst/interfaces/videoorientation.h>
+
+#include "gstv4l2object.h"
+
+G_BEGIN_DECLS
+
+extern gboolean
+gst_v4l2_video_orientation_get_hflip (GstV4l2Object *v4l2object, gboolean *flip);
+extern gboolean
+gst_v4l2_video_orientation_get_vflip (GstV4l2Object *v4l2object, gboolean *flip);
+extern gboolean
+gst_v4l2_video_orientation_get_hcenter (GstV4l2Object *v4l2object, gint *center);
+extern gboolean
+gst_v4l2_video_orientation_get_vcenter (GstV4l2Object *v4l2object, gint *center);
+
+extern gboolean
+gst_v4l2_video_orientation_set_hflip (GstV4l2Object *v4l2object, gboolean flip);
+extern gboolean
+gst_v4l2_video_orientation_set_vflip (GstV4l2Object *v4l2object, gboolean flip);
+extern gboolean
+gst_v4l2_video_orientation_set_hcenter (GstV4l2Object *v4l2object, gint center);
+extern gboolean
+gst_v4l2_video_orientation_set_vcenter (GstV4l2Object *v4l2object, gint center);
+
+
+extern void
+gst_v4l2_video_orientation_interface_init (GstVideoOrientationInterface * klass);
+
+#define GST_IMPLEMENT_V4L2_VIDORIENT_METHODS(Type, interface_as_function) \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_get_hflip (GstVideoOrientation *vo, gboolean *flip) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_get_hflip (this->v4l2object, flip); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_get_vflip (GstVideoOrientation *vo, gboolean *flip) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_get_vflip (this->v4l2object, flip); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_get_hcenter (GstVideoOrientation *vo, gint *center) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_get_hcenter (this->v4l2object, center); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_get_vcenter (GstVideoOrientation *vo, gint *center) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_get_vcenter (this->v4l2object, center); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_set_hflip (GstVideoOrientation *vo, gboolean flip) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_set_hflip (this->v4l2object, flip); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_set_vflip (GstVideoOrientation *vo, gboolean flip) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_set_vflip (this->v4l2object, flip); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_set_hcenter (GstVideoOrientation *vo, gint center) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_set_hcenter (this->v4l2object, center); \
+ } \
+ \
+ static gboolean \
+ interface_as_function ## _video_orientation_set_vcenter (GstVideoOrientation *vo, gint center) \
+ { \
+ Type *this = (Type*) vo; \
+ return gst_v4l2_video_orientation_set_vcenter (this->v4l2object, center); \
+ } \
+ \
+ void \
+ interface_as_function ## _video_orientation_interface_init (GstVideoOrientationInterface * klass) \
+ { \
+ /* default virtual functions */ \
+ klass->get_hflip = interface_as_function ## _video_orientation_get_hflip; \
+ klass->get_vflip = interface_as_function ## _video_orientation_get_vflip; \
+ klass->get_hcenter = interface_as_function ## _video_orientation_get_hcenter; \
+ klass->get_vcenter = interface_as_function ## _video_orientation_get_vcenter; \
+ klass->set_hflip = interface_as_function ## _video_orientation_set_hflip; \
+ klass->set_vflip = interface_as_function ## _video_orientation_set_vflip; \
+ klass->set_hcenter = interface_as_function ## _video_orientation_set_hcenter; \
+ klass->set_vcenter = interface_as_function ## _video_orientation_set_vcenter; \
+ }
+
+#endif /* __GST_V4L2_VIDORIENT_H__ */
diff --git a/tests/icles/v4l2src-test.c b/tests/icles/v4l2src-test.c
index 84f2e7cd..9689bfbf 100644
--- a/tests/icles/v4l2src-test.c
+++ b/tests/icles/v4l2src-test.c
@@ -5,6 +5,7 @@
#include <gst/gst.h>
#include <gst/interfaces/tuner.h>
#include <gst/interfaces/colorbalance.h>
+#include <gst/interfaces/videoorientation.h>
GstElement *pipeline, *source, *sink;
GMainLoop *loop;
@@ -17,6 +18,7 @@ print_options ()
printf ("i - to change the input\n");
printf ("n - to change the norm\n");
printf ("c - list color balance\n");
+ printf ("v - change video orientarion\n");
printf ("e - to exit\n");
}
@@ -34,7 +36,8 @@ run_options (char opt)
freq = gst_tuner_get_frequency (tuner, channel);
- printf ("type the new frequency (current = %lu) (-1 to cancel): ", freq);
+ printf ("\ntype the new frequency (current = %lu) (-1 to cancel): ",
+ freq);
scanf ("%u", &freq);
if (freq != -1)
gst_tuner_set_frequency (tuner, channel, freq);
@@ -134,13 +137,15 @@ run_options (char opt)
controls = gst_color_balance_list_channels (balance);
+ printf ("\n");
+
if (controls == NULL) {
printf ("There is no list of colorbalance controls\n");
goto done;
}
if (controls) {
- printf ("\nlist of controls:\n");
+ printf ("list of controls:\n");
for (item = controls, index = 0; item != NULL;
item = item->next, ++index) {
channel = item->data;
@@ -165,6 +170,90 @@ run_options (char opt)
gst_color_balance_set_value (balance, channel, new_value);
}
}
+ case 'v':
+ {
+ GstVideoOrientation *vidorient = GST_VIDEO_ORIENTATION (source);
+ gboolean flip = FALSE;
+ gint center = 0;
+
+ printf ("\n");
+
+ if (gst_video_orientation_get_hflip (vidorient, &flip)) {
+ gint new_value;
+
+ printf ("Horizontal flip is %s\n", flip ? "on" : "off");
+ printf ("\ntype 1 to toggle (-1 to cancel): ");
+ scanf ("%d", &new_value);
+ if (new_value == 1) {
+ flip = !flip;
+ if (gst_video_orientation_set_hflip (vidorient, flip)) {
+ gst_video_orientation_get_hflip (vidorient, &flip);
+ printf ("Now horizontal flip is %s\n", flip ? "on" : "off");
+ } else {
+ printf ("Error toggling horizontal flip\n");
+ }
+ } else {
+ }
+ } else {
+ printf ("Horizontal flip control not available\n");
+ }
+
+ if (gst_video_orientation_get_vflip (vidorient, &flip)) {
+ gint new_value;
+
+ printf ("\nVertical flip is %s\n", flip ? "on" : "off");
+ printf ("\ntype 1 to toggle (-1 to cancel): ");
+ scanf ("%d", &new_value);
+ if (new_value == 1) {
+ flip = !flip;
+ if (gst_video_orientation_set_vflip (vidorient, flip)) {
+ gst_video_orientation_get_vflip (vidorient, &flip);
+ printf ("Now vertical flip is %s\n", flip ? "on" : "off");
+ } else {
+ printf ("Error toggling vertical flip\n");
+ }
+ } else {
+ }
+ } else {
+ printf ("Vertical flip control not available\n");
+ }
+
+ if (gst_video_orientation_get_hcenter (vidorient, &center)) {
+ printf ("Horizontal center is %d\n", center);
+ printf ("\ntype the new horizontal center value (-1 to cancel): ");
+ scanf ("%d", &center);
+ if (center != -1) {
+ if (gst_video_orientation_set_hcenter (vidorient, center)) {
+ gst_video_orientation_get_hcenter (vidorient, &center);
+ printf ("Now horizontal center is %d\n", center);
+ } else {
+ printf ("Error setting horizontal center\n");
+ }
+ } else {
+ }
+ } else {
+ printf ("Horizontal center control not available\n");
+ }
+
+ if (gst_video_orientation_get_vcenter (vidorient, &center)) {
+ printf ("Vertical center is %d\n", center);
+ printf ("\ntype the new vertical center value (-1 to cancel): ");
+ scanf ("%d", &center);
+ if (center != -1) {
+ if (gst_video_orientation_set_vcenter (vidorient, center)) {
+ gst_video_orientation_get_vcenter (vidorient, &center);
+ printf ("Now vertical center is %d\n", center);
+ } else {
+ printf ("Error setting vertical center\n");
+ }
+ } else {
+ }
+ } else {
+ printf ("Vertical center control not available\n");
+ }
+
+ }
+ break;
break;
default:
if (opt != 10)