From 7a539c59bff3d81f745a27aaba25f8367f99af98 Mon Sep 17 00:00:00 2001 From: Edgard Lima Date: Tue, 19 Sep 2006 13:08:35 +0000 Subject: Add Video Orientation interface support to v4l2src. Original commit message from CVS: Add Video Orientation interface support to v4l2src. --- sys/v4l2/Makefile.am | 3 +- sys/v4l2/gstv4l2src.c | 16 +++++- sys/v4l2/gstv4l2vidorient.c | 96 +++++++++++++++++++++++++++++++++ sys/v4l2/gstv4l2vidorient.h | 127 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 sys/v4l2/gstv4l2vidorient.c create mode 100644 sys/v4l2/gstv4l2vidorient.h (limited to 'sys/v4l2') 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 + * + * 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 + +#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 + * + * 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 +#include + +#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__ */ -- cgit v1.2.1