diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2014-03-15 16:17:21 +0400 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.com> | 2014-03-15 16:54:47 +0400 |
commit | 11103c6c47c2e4804bfce9b5277d2e044a1c24b0 (patch) | |
tree | 00d51b6c2ab1fbc6bef6c303e28d6cdd4a5f427d | |
parent | 418a4940a8c41411cef33a0054879cbd4c9bd181 (diff) |
v4l2: Remove XV support
XV support for v4l2 never became upstream and ended up being
commented out with an undef for a long time now.
-rw-r--r-- | configure.ac | 11 | ||||
-rw-r--r-- | po/POTFILES.in | 1 | ||||
-rw-r--r-- | po/POTFILES.skip | 2 | ||||
-rw-r--r-- | sys/v4l2/Makefile.am | 13 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2object.c | 15 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2sink.c | 69 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2src.c | 13 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2videooverlay.c | 492 | ||||
-rw-r--r-- | sys/v4l2/gstv4l2videooverlay.h | 69 |
9 files changed, 1 insertions, 684 deletions
diff --git a/configure.ac b/configure.ac index 8b0fb73c5..06c9bfe59 100644 --- a/configure.ac +++ b/configure.ac @@ -498,9 +498,6 @@ AG_GST_CHECK_FEATURE(OSX_VIDEO, [OSX video], osxvideosink, [ ]], [[return 0;]])],[HAVE_OSX_VIDEO="yes"],[HAVE_OSX_VIDEO="no"]) ]) -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]), @@ -603,13 +600,6 @@ AG_GST_CHECK_FEATURE(XSHM, [X Shared Memory extension], , [ AC_SUBST(XSHM_LIBS) ]) -dnl for V4L2, we also need to know if we have XVIDEO -translit(dnm, m, l) AM_CONDITIONAL(USE_XVIDEO, true) -AG_GST_CHECK_FEATURE(XVIDEO, [X11 XVideo extensions], - [], [ - AG_GST_CHECK_XV -]) - dnl *** ext plug-ins *** dnl keep this list sorted alphabetically ! @@ -946,7 +936,6 @@ AM_CONDITIONAL(USE_WAVEFORM, false) AM_CONDITIONAL(USE_WAVPACK, false) AM_CONDITIONAL(USE_X, false) AM_CONDITIONAL(USE_XSHM, false) -AM_CONDITIONAL(USE_XVIDEO, false) AM_CONDITIONAL(USE_ZLIB, false) fi dnl of EXT plugins diff --git a/po/POTFILES.in b/po/POTFILES.in index 596eda7e7..689ae8f1c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -21,6 +21,5 @@ sys/sunaudio/gstsunaudiomixertrack.c sys/v4l2/gstv4l2bufferpool.c sys/v4l2/gstv4l2object.c sys/v4l2/gstv4l2radio.c -sys/v4l2/gstv4l2videooverlay.c sys/v4l2/v4l2_calls.c sys/ximage/gstximagesrc.c diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 02201b7d5..a7f30e53f 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -2,5 +2,3 @@ gst/goom/convolve_fx.c gst/goom/mmx.c gst/goom/xmmx.c gst/oldcore/gstmultifilesrc.c -sys/v4l2/gstv4l2xoverlay.c - diff --git a/sys/v4l2/Makefile.am b/sys/v4l2/Makefile.am index 37199c5be..4e62c6eb0 100644 --- a/sys/v4l2/Makefile.am +++ b/sys/v4l2/Makefile.am @@ -1,13 +1,5 @@ plugin_LTLIBRARIES = libgstvideo4linux2.la -if USE_XVIDEO -xv_source = gstv4l2videooverlay.c -xv_libs = $(X_LIBS) $(XVIDEO_LIBS) -else -xv_source = -xv_libs = -endif - include $(top_srcdir)/common/gst-glib-gen.mak libgstvideo4linux2_la_SOURCES = gstv4l2.c \ @@ -23,8 +15,7 @@ libgstvideo4linux2_la_SOURCES = gstv4l2.c \ v4l2_calls.c \ tuner.c \ tunerchannel.c \ - tunernorm.c \ - $(xv_source) + tunernorm.c libgstvideo4linux2_la_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ @@ -40,7 +31,6 @@ libgstvideo4linux2_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \ -lgstvideo-$(GST_API_VERSION) \ $(GST_BASE_LIBS) \ $(GST_LIBS) \ - $(xv_libs) \ $(LIBV4L2_LIBS) \ $(GUDEV_LIBS) \ $(LIBRT) @@ -55,7 +45,6 @@ noinst_HEADERS = \ gstv4l2tuner.h \ gstv4l2videodec.h \ gstv4l2vidorient.h \ - gstv4l2videooverlay.h \ v4l2_calls.h \ tuner.h \ tunerchannel.h \ diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c index 37bc43484..a8dcbb6b9 100644 --- a/sys/v4l2/gstv4l2object.c +++ b/sys/v4l2/gstv4l2object.c @@ -38,9 +38,6 @@ #include "v4l2_calls.h" #include "gstv4l2tuner.h" -#ifdef HAVE_XVIDEO -#include "gstv4l2videooverlay.h" -#endif #include "gstv4l2colorbalance.h" #include "gst/gst-i18n-plugin.h" @@ -901,10 +898,6 @@ gst_v4l2_object_open (GstV4l2Object * v4l2object) else return FALSE; -#ifdef HAVE_XVIDEO - gst_v4l2_video_overlay_start (v4l2object); -#endif - return TRUE; } @@ -915,20 +908,12 @@ gst_v4l2_object_open_shared (GstV4l2Object * v4l2object, GstV4l2Object * other) ret = gst_v4l2_dup (v4l2object, other); -#ifdef HAVE_XVIDEO - gst_v4l2_video_overlay_start (v4l2object); -#endif - return ret; } gboolean gst_v4l2_object_close (GstV4l2Object * v4l2object) { -#ifdef HAVE_XVIDEO - gst_v4l2_video_overlay_stop (v4l2object); -#endif - if (!gst_v4l2_close (v4l2object)) return FALSE; diff --git a/sys/v4l2/gstv4l2sink.c b/sys/v4l2/gstv4l2sink.c index ef0941216..24f6d3f9d 100644 --- a/sys/v4l2/gstv4l2sink.c +++ b/sys/v4l2/gstv4l2sink.c @@ -57,9 +57,6 @@ #include "gstv4l2colorbalance.h" #include "gstv4l2tuner.h" -#ifdef HAVE_XVIDEO -#include "gstv4l2videooverlay.h" -#endif #include "gstv4l2vidorient.h" #include "gstv4l2sink.h" @@ -89,29 +86,11 @@ enum GST_IMPLEMENT_V4L2_COLOR_BALANCE_METHODS (GstV4l2Sink, gst_v4l2sink); GST_IMPLEMENT_V4L2_TUNER_METHODS (GstV4l2Sink, gst_v4l2sink); -#ifdef HAVE_XVIDEO -GST_IMPLEMENT_V4L2_VIDEO_OVERLAY_METHODS (GstV4l2Sink, gst_v4l2sink); -#endif GST_IMPLEMENT_V4L2_VIDORIENT_METHODS (GstV4l2Sink, gst_v4l2sink); -#ifdef HAVE_XVIDEO -static void gst_v4l2sink_navigation_send_event (GstNavigation * navigation, - GstStructure * structure); -static void -gst_v4l2sink_navigation_init (GstNavigationInterface * iface) -{ - iface->send_event = gst_v4l2sink_navigation_send_event; -} -#endif - #define gst_v4l2sink_parent_class parent_class G_DEFINE_TYPE_WITH_CODE (GstV4l2Sink, gst_v4l2sink, GST_TYPE_VIDEO_SINK, G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER, gst_v4l2sink_tuner_interface_init); -#ifdef HAVE_XVIDEO - G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_OVERLAY, - gst_v4l2sink_video_overlay_interface_init); - G_IMPLEMENT_INTERFACE (GST_TYPE_NAVIGATION, gst_v4l2sink_navigation_init); -#endif G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE, gst_v4l2sink_color_balance_interface_init); G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION, @@ -526,10 +505,6 @@ gst_v4l2sink_set_caps (GstBaseSink * bsink, GstCaps * caps) gst_v4l2sink_sync_overlay_fields (v4l2sink); gst_v4l2sink_sync_crop_fields (v4l2sink); -#ifdef HAVE_XVIDEO - gst_v4l2_video_overlay_prepare_window_handle (v4l2sink->v4l2object, TRUE); -#endif - GST_INFO_OBJECT (v4l2sink, "outputting buffers via mmap()"); v4l2sink->video_width = GST_V4L2_WIDTH (v4l2sink->v4l2object); @@ -643,47 +618,3 @@ not_negotiated: return GST_FLOW_NOT_NEGOTIATED; } } - -#ifdef HAVE_XVIDEO -static void -gst_v4l2sink_navigation_send_event (GstNavigation * navigation, - GstStructure * structure) -{ - GstV4l2Sink *v4l2sink = GST_V4L2SINK (navigation); - GstV4l2Xv *xv = v4l2sink->v4l2object->xv; - GstPad *peer; - - if (!xv) - return; - - if ((peer = gst_pad_get_peer (GST_VIDEO_SINK_PAD (v4l2sink)))) { - GstVideoRectangle rect; - gdouble x, y, xscale = 1.0, yscale = 1.0; - - gst_v4l2_video_overlay_get_render_rect (v4l2sink->v4l2object, &rect); - - /* We calculate scaling using the original video frames geometry to - * include pixel aspect ratio scaling. - */ - xscale = (gdouble) v4l2sink->video_width / rect.w; - yscale = (gdouble) v4l2sink->video_height / rect.h; - - /* Converting pointer coordinates to the non scaled geometry */ - if (gst_structure_get_double (structure, "pointer_x", &x)) { - x = MIN (x, rect.x + rect.w); - x = MAX (x - rect.x, 0); - gst_structure_set (structure, "pointer_x", G_TYPE_DOUBLE, - (gdouble) x * xscale, NULL); - } - if (gst_structure_get_double (structure, "pointer_y", &y)) { - y = MIN (y, rect.y + rect.h); - y = MAX (y - rect.y, 0); - gst_structure_set (structure, "pointer_y", G_TYPE_DOUBLE, - (gdouble) y * yscale, NULL); - } - - gst_pad_send_event (peer, gst_event_new_navigation (structure)); - gst_object_unref (peer); - } -} -#endif diff --git a/sys/v4l2/gstv4l2src.c b/sys/v4l2/gstv4l2src.c index e292f2d21..2543b4e1c 100644 --- a/sys/v4l2/gstv4l2src.c +++ b/sys/v4l2/gstv4l2src.c @@ -44,8 +44,6 @@ #include <config.h> #endif -#undef HAVE_XVIDEO - #include <string.h> #include <sys/time.h> #include <unistd.h> @@ -57,9 +55,6 @@ #include "gstv4l2colorbalance.h" #include "gstv4l2tuner.h" -#ifdef HAVE_XVIDEO -#include "gstv4l2xoverlay.h" -#endif #include "gstv4l2vidorient.h" #include "gst/gst-i18n-plugin.h" @@ -87,9 +82,6 @@ static guint gst_v4l2_signals[LAST_SIGNAL] = { 0 }; GST_IMPLEMENT_V4L2_COLOR_BALANCE_METHODS (GstV4l2Src, gst_v4l2src); 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 void gst_v4l2src_uri_handler_init (gpointer g_iface, @@ -99,11 +91,6 @@ static void gst_v4l2src_uri_handler_init (gpointer g_iface, G_DEFINE_TYPE_WITH_CODE (GstV4l2Src, gst_v4l2src, GST_TYPE_PUSH_SRC, G_IMPLEMENT_INTERFACE (GST_TYPE_URI_HANDLER, gst_v4l2src_uri_handler_init); G_IMPLEMENT_INTERFACE (GST_TYPE_TUNER, gst_v4l2src_tuner_interface_init); -#ifdef HAVE_XVIDEO - /* FIXME: does GstXOverlay for v4l2src make sense in a GStreamer context? */ - G_IMPLEMENT_INTERFACE (GST_TYPE_X_OVERLAY, - gst_v4l2src_xoverlay_interface_init); -#endif G_IMPLEMENT_INTERFACE (GST_TYPE_COLOR_BALANCE, gst_v4l2src_color_balance_interface_init); G_IMPLEMENT_INTERFACE (GST_TYPE_VIDEO_ORIENTATION, diff --git a/sys/v4l2/gstv4l2videooverlay.c b/sys/v4l2/gstv4l2videooverlay.c deleted file mode 100644 index 66d2109be..000000000 --- a/sys/v4l2/gstv4l2videooverlay.c +++ /dev/null @@ -1,492 +0,0 @@ -/* GStreamer - * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net> - * 2006 Edgard Lima <edgard.lima@indt.org.br> - * - * gstv4l2video_overlay.c: X-based overlay 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <string.h> -#include <gst/gst.h> -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/extensions/Xv.h> -#include <X11/extensions/Xvlib.h> -#include <sys/stat.h> -/* for XkbKeycodeToKeysym */ -#include <X11/XKBlib.h> - -#include <gst/video/navigation.h> - -#include "gstv4l2videooverlay.h" -#include "gstv4l2object.h" -#include "v4l2_calls.h" - -#include "gst/gst-i18n-plugin.h" -#include <gst/glib-compat-private.h> - -struct _GstV4l2Xv -{ - Display *dpy; - gint port, idle_id, event_id; - GMutex mutex; /* to serialize calls to X11 */ -}; - -GST_DEBUG_CATEGORY_STATIC (v4l2xv_debug); -#define GST_CAT_DEFAULT v4l2xv_debug - -void -gst_v4l2_video_overlay_interface_init (GstVideoOverlayInterface * iface) -{ - GST_DEBUG_CATEGORY_INIT (v4l2xv_debug, "v4l2xv", 0, - "V4L2 GstVideoOverlay interface debugging"); -} - -static void -gst_v4l2_video_overlay_open (GstV4l2Object * v4l2object) -{ - struct stat s; - GstV4l2Xv *v4l2xv; - const gchar *name = g_getenv ("DISPLAY"); - unsigned int ver, rel, req, ev, err, anum; - int i, id = 0, first_id = 0, min; - XvAdaptorInfo *ai; - Display *dpy; - - /* we need a display, obviously */ - if (!name || !(dpy = XOpenDisplay (name))) { - GST_WARNING_OBJECT (v4l2object->element, - "No $DISPLAY set or failed to open - no overlay"); - return; - } - - /* First let's check that XVideo extension is available */ - if (!XQueryExtension (dpy, "XVideo", &i, &i, &i)) { - GST_WARNING_OBJECT (v4l2object->element, - "Xv extension not available - no overlay"); - XCloseDisplay (dpy); - return; - } - - /* find port that belongs to this device */ - if (XvQueryExtension (dpy, &ver, &rel, &req, &ev, &err) != Success) { - GST_WARNING_OBJECT (v4l2object->element, - "Xv extension not supported - no overlay"); - XCloseDisplay (dpy); - return; - } - if (XvQueryAdaptors (dpy, DefaultRootWindow (dpy), &anum, &ai) != Success) { - GST_WARNING_OBJECT (v4l2object->element, "Failed to query Xv adaptors"); - XCloseDisplay (dpy); - return; - } - if (fstat (v4l2object->video_fd, &s) < 0) { - GST_ELEMENT_ERROR (v4l2object->element, RESOURCE, NOT_FOUND, - (_("Cannot identify device '%s'."), v4l2object->videodev), - GST_ERROR_SYSTEM); - XCloseDisplay (dpy); - return; - } - min = s.st_rdev & 0xff; - for (i = 0; i < anum; i++) { - GST_DEBUG_OBJECT (v4l2object->element, "found adapter: %s", ai[i].name); - if (!strcmp (ai[i].name, "video4linux2") || - !strcmp (ai[i].name, "video4linux")) { - if (first_id == 0) - first_id = ai[i].base_id; - - GST_DEBUG_OBJECT (v4l2object->element, - "first_id=%d, base_id=%lu, min=%d", first_id, ai[i].base_id, min); - - /* hmm... */ - if (first_id != 0 && ai[i].base_id == first_id + min) - id = ai[i].base_id; - } - } - XvFreeAdaptorInfo (ai); - - if (id == 0) { - GST_WARNING_OBJECT (v4l2object->element, - "Did not find XvPortID for device - no overlay"); - XCloseDisplay (dpy); - return; - } - - v4l2xv = g_new0 (GstV4l2Xv, 1); - v4l2xv->dpy = dpy; - v4l2xv->port = id; - g_mutex_init (&v4l2xv->mutex); - v4l2xv->idle_id = 0; - v4l2xv->event_id = 0; - v4l2object->xv = v4l2xv; - - if (v4l2object->xwindow_id) { - gst_v4l2_video_overlay_set_window_handle (v4l2object, - v4l2object->xwindow_id); - } -} - -static void -gst_v4l2_video_overlay_close (GstV4l2Object * v4l2object) -{ - GstV4l2Xv *v4l2xv = v4l2object->xv; - - if (!v4l2object->xv) - return; - - if (v4l2object->xwindow_id) { - gst_v4l2_video_overlay_set_window_handle (v4l2object, 0); - } - - XCloseDisplay (v4l2xv->dpy); - g_mutex_clear (&v4l2xv->mutex); - if (v4l2xv->idle_id) - g_source_remove (v4l2xv->idle_id); - if (v4l2xv->event_id) - g_source_remove (v4l2xv->event_id); - g_free (v4l2xv); - v4l2object->xv = NULL; -} - -void -gst_v4l2_video_overlay_start (GstV4l2Object * v4l2object) -{ - if (v4l2object->xwindow_id) { - gst_v4l2_video_overlay_open (v4l2object); - } -} - -void -gst_v4l2_video_overlay_stop (GstV4l2Object * v4l2object) -{ - gst_v4l2_video_overlay_close (v4l2object); -} - -/* should be called with mutex held */ -static gboolean -get_render_rect (GstV4l2Object * v4l2object, GstVideoRectangle * rect) -{ - GstV4l2Xv *v4l2xv = v4l2object->xv; - if (v4l2xv && v4l2xv->dpy && v4l2object->xwindow_id) { - XWindowAttributes attr; - XGetWindowAttributes (v4l2xv->dpy, v4l2object->xwindow_id, &attr); - /* this is where we'd add support to maintain aspect ratio */ - rect->x = 0; - rect->y = 0; - rect->w = attr.width; - rect->h = attr.height; - return TRUE; - } else { - return FALSE; - } -} - -gboolean -gst_v4l2_video_overlay_get_render_rect (GstV4l2Object * v4l2object, - GstVideoRectangle * rect) -{ - GstV4l2Xv *v4l2xv = v4l2object->xv; - gboolean ret = FALSE; - if (v4l2xv) { - g_mutex_lock (&v4l2xv->mutex); - ret = get_render_rect (v4l2object, rect); - g_mutex_unlock (&v4l2xv->mutex); - } - return ret; -} - -static void -update_geometry (GstV4l2Object * v4l2object) -{ - GstV4l2Xv *v4l2xv = v4l2object->xv; - GstVideoRectangle rect; - if (!get_render_rect (v4l2object, &rect)) - return; - /* note: we don't pass in valid video x/y/w/h.. currently the xserver - * doesn't need to know these, as they come from v4l2 by setting the - * crop.. - */ - XvPutVideo (v4l2xv->dpy, v4l2xv->port, v4l2object->xwindow_id, - DefaultGC (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy)), - 0, 0, rect.w, rect.h, rect.x, rect.y, rect.w, rect.h); -} - -static gboolean -idle_refresh (gpointer data) -{ - GstV4l2Object *v4l2object = GST_V4L2_OBJECT (data); - GstV4l2Xv *v4l2xv = v4l2object->xv; - - GST_LOG_OBJECT (v4l2object->element, "idle refresh"); - - if (v4l2xv) { - g_mutex_lock (&v4l2xv->mutex); - - update_geometry (v4l2object); - - v4l2xv->idle_id = 0; - g_mutex_unlock (&v4l2xv->mutex); - } - - /* once */ - return FALSE; -} - - -static gboolean -event_refresh (gpointer data) -{ - GstV4l2Object *v4l2object = GST_V4L2_OBJECT (data); - GstV4l2Xv *v4l2xv = v4l2object->xv; - - GST_LOG_OBJECT (v4l2object->element, "event refresh"); - - if (v4l2xv) { - XEvent e; - - g_mutex_lock (&v4l2xv->mutex); - - /* If the element supports navigation, collect the relavent input - * events and push them upstream as navigation events - */ - if (GST_IS_NAVIGATION (v4l2object->element)) { - guint pointer_x = 0, pointer_y = 0; - gboolean pointer_moved = FALSE; - - /* We get all pointer motion events, only the last position is - * interesting. - */ - while (XCheckWindowEvent (v4l2xv->dpy, v4l2object->xwindow_id, - PointerMotionMask, &e)) { - switch (e.type) { - case MotionNotify: - pointer_x = e.xmotion.x; - pointer_y = e.xmotion.y; - pointer_moved = TRUE; - break; - default: - break; - } - } - if (pointer_moved) { - GST_DEBUG_OBJECT (v4l2object->element, - "pointer moved over window at %d,%d", pointer_x, pointer_y); - g_mutex_unlock (&v4l2xv->mutex); - gst_navigation_send_mouse_event (GST_NAVIGATION (v4l2object->element), - "mouse-move", 0, e.xbutton.x, e.xbutton.y); - g_mutex_lock (&v4l2xv->mutex); - } - - /* We get all events on our window to throw them upstream - */ - while (XCheckWindowEvent (v4l2xv->dpy, v4l2object->xwindow_id, - KeyPressMask | KeyReleaseMask | - ButtonPressMask | ButtonReleaseMask, &e)) { - KeySym keysym; - const char *key_str = NULL; - - g_mutex_unlock (&v4l2xv->mutex); - - switch (e.type) { - case ButtonPress: - GST_DEBUG_OBJECT (v4l2object->element, - "button %d pressed over window at %d,%d", - e.xbutton.button, e.xbutton.x, e.xbutton.y); - gst_navigation_send_mouse_event (GST_NAVIGATION - (v4l2object->element), "mouse-button-press", e.xbutton.button, - e.xbutton.x, e.xbutton.y); - break; - case ButtonRelease: - GST_DEBUG_OBJECT (v4l2object->element, - "button %d released over window at %d,%d", - e.xbutton.button, e.xbutton.x, e.xbutton.y); - gst_navigation_send_mouse_event (GST_NAVIGATION - (v4l2object->element), "mouse-button-release", e.xbutton.button, - e.xbutton.x, e.xbutton.y); - break; - case KeyPress: - case KeyRelease: - g_mutex_lock (&v4l2xv->mutex); - keysym = XkbKeycodeToKeysym (v4l2xv->dpy, e.xkey.keycode, 0, 0); - if (keysym != NoSymbol) { - key_str = XKeysymToString (keysym); - } else { - key_str = "unknown"; - } - g_mutex_unlock (&v4l2xv->mutex); - GST_DEBUG_OBJECT (v4l2object->element, - "key %d pressed over window at %d,%d (%s)", - e.xkey.keycode, e.xkey.x, e.xkey.y, key_str); - gst_navigation_send_key_event (GST_NAVIGATION (v4l2object->element), - e.type == KeyPress ? "key-press" : "key-release", key_str); - break; - default: - GST_DEBUG_OBJECT (v4l2object->element, - "unhandled X event (%d)", e.type); - } - - g_mutex_lock (&v4l2xv->mutex); - } - } - - /* Handle ConfigureNotify */ - while (XCheckWindowEvent (v4l2xv->dpy, v4l2object->xwindow_id, - StructureNotifyMask, &e)) { - switch (e.type) { - case ConfigureNotify: - update_geometry (v4l2object); - break; - default: - break; - } - } - g_mutex_unlock (&v4l2xv->mutex); - } - - /* repeat */ - return TRUE; -} - -void -gst_v4l2_video_overlay_set_window_handle (GstV4l2Object * v4l2object, - guintptr id) -{ - GstV4l2Xv *v4l2xv; - XID xwindow_id = id; - gboolean change = (v4l2object->xwindow_id != xwindow_id); - - GST_LOG_OBJECT (v4l2object->element, "Setting XID to %lx", - (gulong) xwindow_id); - - if (!v4l2object->xv && GST_V4L2_IS_OPEN (v4l2object)) - gst_v4l2_video_overlay_open (v4l2object); - - v4l2xv = v4l2object->xv; - - if (v4l2xv) - g_mutex_lock (&v4l2xv->mutex); - - if (change) { - if (v4l2object->xwindow_id && v4l2xv) { - GST_DEBUG_OBJECT (v4l2object->element, - "Deactivating old port %lx", v4l2object->xwindow_id); - - XvSelectPortNotify (v4l2xv->dpy, v4l2xv->port, 0); - XvSelectVideoNotify (v4l2xv->dpy, v4l2object->xwindow_id, 0); - XvStopVideo (v4l2xv->dpy, v4l2xv->port, v4l2object->xwindow_id); - } - - v4l2object->xwindow_id = xwindow_id; - } - - if (!v4l2xv || xwindow_id == 0) { - if (v4l2xv) - g_mutex_unlock (&v4l2xv->mutex); - return; - } - - if (change) { - GST_DEBUG_OBJECT (v4l2object->element, "Activating new port %lx", - xwindow_id); - - /* draw */ - XvSelectPortNotify (v4l2xv->dpy, v4l2xv->port, 1); - XvSelectVideoNotify (v4l2xv->dpy, v4l2object->xwindow_id, 1); - } - - update_geometry (v4l2object); - - if (v4l2xv->idle_id) - g_source_remove (v4l2xv->idle_id); - v4l2xv->idle_id = g_idle_add (idle_refresh, v4l2object); - g_mutex_unlock (&v4l2xv->mutex); -} - -/** - * gst_v4l2_video_overlay_prepare_window_handle: - * @v4l2object: the v4l2object - * @required: %TRUE if display is required (ie. TRUE for v4l2sink, but - * FALSE for any other element with optional overlay capabilities) - * - * Helper function to create a windo if none is set from the application. - */ -void -gst_v4l2_video_overlay_prepare_window_handle (GstV4l2Object * v4l2object, - gboolean required) -{ - GstVideoOverlay *overlay; - - if (!GST_V4L2_IS_OVERLAY (v4l2object)) - return; - - overlay = GST_VIDEO_OVERLAY (v4l2object->element); - gst_video_overlay_prepare_window_handle (overlay); - - if (required && !v4l2object->xwindow_id) { - GstV4l2Xv *v4l2xv; - Window win; - int width, height; - long event_mask; - - if (!v4l2object->xv && GST_V4L2_IS_OPEN (v4l2object)) - gst_v4l2_video_overlay_open (v4l2object); - - v4l2xv = v4l2object->xv; - - /* if video_overlay is not supported, just bail */ - if (!v4l2xv) - return; - - /* video_overlay is supported, but we don't have a window.. so create one */ - GST_DEBUG_OBJECT (v4l2object->element, "creating window"); - - g_mutex_lock (&v4l2xv->mutex); - - width = XDisplayWidth (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy)); - height = XDisplayHeight (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy)); - GST_DEBUG_OBJECT (v4l2object->element, "dpy=%p", v4l2xv->dpy); - - win = XCreateSimpleWindow (v4l2xv->dpy, - DefaultRootWindow (v4l2xv->dpy), - 0, 0, width, height, 0, 0, - XBlackPixel (v4l2xv->dpy, DefaultScreen (v4l2xv->dpy))); - - GST_DEBUG_OBJECT (v4l2object->element, "win=%lu", win); - - event_mask = ExposureMask | StructureNotifyMask; - if (GST_IS_NAVIGATION (v4l2object->element)) { - event_mask |= PointerMotionMask | - KeyPressMask | KeyReleaseMask | ButtonPressMask | ButtonReleaseMask; - } - XSelectInput (v4l2xv->dpy, win, event_mask); - v4l2xv->event_id = g_timeout_add (45, event_refresh, v4l2object); - - XMapRaised (v4l2xv->dpy, win); - - XSync (v4l2xv->dpy, FALSE); - - g_mutex_unlock (&v4l2xv->mutex); - - GST_DEBUG_OBJECT (v4l2object->element, "got window"); - - gst_v4l2_video_overlay_set_window_handle (v4l2object, win); - } -} diff --git a/sys/v4l2/gstv4l2videooverlay.h b/sys/v4l2/gstv4l2videooverlay.h deleted file mode 100644 index cd4091621..000000000 --- a/sys/v4l2/gstv4l2videooverlay.h +++ /dev/null @@ -1,69 +0,0 @@ -/* GStreamer - * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net> - * 2006 Edgard Lima <edgard.lima@indt.org.br> - * - * gstv4l2videooverlay.h: tv mixer 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., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#ifndef __GST_V4L2_VIDEO_OVERLAY_H__ -#define __GST_V4L2_VIDEO_OVERLAY_H__ - -#include <X11/X.h> - -#include <gst/gst.h> -#include <gst/video/navigation.h> -#include <gst/video/gstvideosink.h> /* for GstVideoRectange */ -#include <gst/video/videooverlay.h> - -#include "gstv4l2object.h" - -G_BEGIN_DECLS - -void gst_v4l2_video_overlay_start (GstV4l2Object *v4l2object); -void gst_v4l2_video_overlay_stop (GstV4l2Object *v4l2object); -gboolean gst_v4l2_video_overlay_get_render_rect (GstV4l2Object *v4l2object, - GstVideoRectangle *rect); - -void gst_v4l2_video_overlay_interface_init (GstVideoOverlayInterface * iface); -void gst_v4l2_video_overlay_set_window_handle (GstV4l2Object * v4l2object, - guintptr id); -void gst_v4l2_video_overlay_prepare_window_handle (GstV4l2Object * v4l2object, - gboolean required); - - -#define GST_IMPLEMENT_V4L2_VIDEO_OVERLAY_METHODS(Type, interface_as_function) \ - \ -static void \ -interface_as_function ## _video_overlay_set_window_handle (GstVideoOverlay * overlay, \ - guintptr id) \ -{ \ - Type *this = (Type*) overlay; \ - gst_v4l2_video_overlay_set_window_handle (this->v4l2object, id); \ -} \ - \ -static void \ -interface_as_function ## _video_overlay_interface_init (GstVideoOverlayInterface * iface) \ -{ \ - /* default virtual functions */ \ - iface->set_window_handle = interface_as_function ## _video_overlay_set_window_handle; \ - \ - gst_v4l2_video_overlay_interface_init (iface); \ -} \ - - -#endif /* __GST_V4L2_VIDEO_OVERLAY_H__ */ |