2003-10-10 12:47:41 +00:00
|
|
|
/* GStreamer X-based Overlay
|
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
|
|
|
*
|
2005-11-21 20:28:23 +00:00
|
|
|
* x-overlay.c: X-based overlay interface design
|
2003-10-10 12:47:41 +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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-11-28 13:06:05 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstxoverlay
|
|
|
|
* @short_description: Interface for setting/getting a Window on elements
|
2005-12-01 01:29:46 +00:00
|
|
|
* supporting it
|
2005-11-28 13:06:05 +00:00
|
|
|
*
|
|
|
|
* <refsect2>
|
|
|
|
* <para>
|
|
|
|
* The XOverlay interface is used for 2 main purposes :
|
|
|
|
* <itemizedlist>
|
|
|
|
* <listitem>
|
|
|
|
* <para>
|
|
|
|
* To get a grab on the Window where the video sink element is going to render.
|
|
|
|
* This is achieved by either being informed about the Window identifier that
|
|
|
|
* the video sink element generated, or by forcing the video sink element to use
|
|
|
|
* a specific Window identifier for rendering.
|
|
|
|
* </para>
|
|
|
|
* </listitem>
|
|
|
|
* <listitem>
|
|
|
|
* <para>
|
2006-06-07 11:03:03 +00:00
|
|
|
* To force a redrawing of the latest video frame the video sink element
|
2005-11-28 13:06:05 +00:00
|
|
|
* displayed on the Window. Indeed if the #GstPipeline is in #GST_STATE_PAUSED
|
|
|
|
* state, moving the Window around will damage its content. Application
|
2006-06-07 11:03:03 +00:00
|
|
|
* developers will want to handle the Expose events themselves and force the
|
2005-11-28 13:06:05 +00:00
|
|
|
* video sink element to refresh the Window's content.
|
|
|
|
* </para>
|
|
|
|
* </listitem>
|
|
|
|
* </itemizedlist>
|
|
|
|
* </para>
|
|
|
|
* <para>
|
|
|
|
* Using the Window created by the video sink is probably the simplest scenario,
|
2006-06-07 11:03:03 +00:00
|
|
|
* in some cases, though, it might not be flexible enough for application
|
2005-11-28 13:06:05 +00:00
|
|
|
* developers if they need to catch events such as mouse moves and button
|
|
|
|
* clicks.
|
|
|
|
* </para>
|
|
|
|
* <para>
|
|
|
|
* Setting a specific Window identifier on the video sink element is the most
|
|
|
|
* flexible solution but it has some issues. Indeed the application needs to set
|
|
|
|
* its Window identifier at the right time to avoid internal Window creation
|
|
|
|
* from the video sink element. To solve this issue a #GstMessage is posted on
|
2006-06-07 11:03:03 +00:00
|
|
|
* the bus to inform the application that it should set the Window identifier
|
2005-11-28 13:06:05 +00:00
|
|
|
* immediately. Here is an example on how to do that correctly:
|
2010-02-16 13:43:26 +00:00
|
|
|
* |[
|
2005-11-28 13:06:05 +00:00
|
|
|
* static GstBusSyncReply
|
|
|
|
* create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline)
|
|
|
|
* {
|
2006-01-22 14:50:53 +00:00
|
|
|
* // ignore anything but 'prepare-xwindow-id' element messages
|
|
|
|
* if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
|
|
|
|
* return GST_BUS_PASS;
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2006-01-22 14:50:53 +00:00
|
|
|
* if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
|
2005-11-28 13:06:05 +00:00
|
|
|
* return GST_BUS_PASS;
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* win = XCreateSimpleWindow (disp, root, 0, 0, 320, 240, 0, 0, 0);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* XSetWindowBackgroundPixmap (disp, win, None);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* XMapRaised (disp, win);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* XSync (disp, FALSE);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-09-05 22:17:47 +00:00
|
|
|
* gst_x_overlay_set_window_handle (GST_X_OVERLAY (GST_MESSAGE_SRC (message)),
|
2005-11-28 13:06:05 +00:00
|
|
|
* win);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2006-10-06 19:20:53 +00:00
|
|
|
* gst_message_unref (message);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* return GST_BUS_DROP;
|
|
|
|
* }
|
|
|
|
* ...
|
|
|
|
* int
|
|
|
|
* main (int argc, char **argv)
|
|
|
|
* {
|
|
|
|
* ...
|
|
|
|
* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
|
|
* gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, pipeline);
|
|
|
|
* ...
|
|
|
|
* }
|
2010-02-16 13:43:26 +00:00
|
|
|
* ]|
|
2005-11-28 13:06:05 +00:00
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
2010-01-10 23:50:02 +00:00
|
|
|
* <refsect2>
|
|
|
|
* <title>Two basic usage scenarios</title>
|
|
|
|
* <para>
|
|
|
|
* There are two basic usage scenarios: in the simplest case, the application
|
|
|
|
* knows exactly what particular element is used for video output, which is
|
|
|
|
* usually the case when the application creates the videosink to use
|
|
|
|
* (e.g. #xvimagesink, #ximagesink, etc.) itself; in this case, the application
|
|
|
|
* can just create the videosink element, create and realize the window to
|
2010-09-05 22:17:47 +00:00
|
|
|
* render the video on and then call gst_x_overlay_set_window_handle() directly
|
2010-01-10 23:50:02 +00:00
|
|
|
* with the XID or native window handle, before starting up the pipeline.
|
|
|
|
* </para>
|
|
|
|
* <para>
|
|
|
|
* In the other and more common case, the application does not know in advance
|
|
|
|
* what GStreamer video sink element will be used for video output. This is
|
|
|
|
* usually the case when an element such as #autovideosink or #gconfvideosink
|
|
|
|
* is used. In this case, the video sink element itself is created
|
|
|
|
* asynchronously from a GStreamer streaming thread some time after the
|
|
|
|
* pipeline has been started up. When that happens, however, the video sink
|
|
|
|
* will need to know right then whether to render onto an already existing
|
|
|
|
* application window or whether to create its own window. This is when it
|
|
|
|
* posts a prepare-xwindow-id message, and that is also why this message needs
|
|
|
|
* to be handled in a sync bus handler which will be called from the streaming
|
|
|
|
* thread directly (because the video sink will need an answer right then).
|
|
|
|
* </para>
|
|
|
|
* <para>
|
|
|
|
* As response to the prepare-xwindow-id element message in the bus sync
|
2010-09-05 22:17:47 +00:00
|
|
|
* handler, the application may use gst_x_overlay_set_window_handle() to tell
|
2010-01-10 23:50:02 +00:00
|
|
|
* the video sink to render onto an existing window surface. At this point the
|
|
|
|
* application should already have obtained the window handle / XID, so it
|
|
|
|
* just needs to set it. It is generally not advisable to call any GUI toolkit
|
|
|
|
* functions or window system functions from the streaming thread in which the
|
|
|
|
* prepare-xwindow-id message is handled, because most GUI toolkits and
|
|
|
|
* windowing systems are not thread-safe at all and a lot of care would be
|
|
|
|
* required to co-ordinate the toolkit and window system calls of the
|
|
|
|
* different threads (Gtk+ users please note: prior to Gtk+ 2.18
|
|
|
|
* GDK_WINDOW_XID() was just a simple structure access, so generally fine to do
|
|
|
|
* within the bus sync handler; this macro was changed to a function call in
|
|
|
|
* Gtk+ 2.18 and later, which is likely to cause problems when called from a
|
|
|
|
* sync handler; see below for a better approach without GDK_WINDOW_XID()
|
|
|
|
* used in the callback).
|
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
* <refsect2>
|
|
|
|
* <title>GstXOverlay and Gtk+</title>
|
|
|
|
* <para>
|
2010-02-16 13:43:26 +00:00
|
|
|
* |[
|
2011-12-05 08:38:33 +00:00
|
|
|
* #include <gst/interfaces/xoverlay.h>
|
2010-01-10 23:50:02 +00:00
|
|
|
* #include <gtk/gtk.h>
|
|
|
|
* #ifdef GDK_WINDOWING_X11
|
|
|
|
* #include <gdk/gdkx.h> // for GDK_WINDOW_XID
|
|
|
|
* #endif
|
2012-01-05 01:51:35 +00:00
|
|
|
* #ifdef GDK_WINDOWING_WIN32
|
|
|
|
* #include <gdk/gdkwin32.h> // for GDK_WINDOW_HWND
|
|
|
|
* #endif
|
2010-01-10 23:50:02 +00:00
|
|
|
* ...
|
2012-01-05 01:51:35 +00:00
|
|
|
* static guintptr video_window_handle = 0;
|
2010-01-10 23:50:02 +00:00
|
|
|
* ...
|
|
|
|
* static GstBusSyncReply
|
|
|
|
* bus_sync_handler (GstBus * bus, GstMessage * message, gpointer user_data)
|
|
|
|
* {
|
|
|
|
* // ignore anything but 'prepare-xwindow-id' element messages
|
|
|
|
* if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT)
|
|
|
|
* return GST_BUS_PASS;
|
|
|
|
* if (!gst_structure_has_name (message->structure, "prepare-xwindow-id"))
|
|
|
|
* return GST_BUS_PASS;
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2012-01-05 01:51:35 +00:00
|
|
|
* if (video_window_handle != 0) {
|
2010-01-10 23:50:02 +00:00
|
|
|
* GstXOverlay *xoverlay;
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-01-10 23:50:02 +00:00
|
|
|
* // GST_MESSAGE_SRC (message) will be the video sink element
|
|
|
|
* xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (message));
|
2012-01-05 01:51:35 +00:00
|
|
|
* gst_x_overlay_set_window_handle (xoverlay, video_window_handle);
|
2010-01-10 23:50:02 +00:00
|
|
|
* } else {
|
2012-01-05 01:51:35 +00:00
|
|
|
* g_warning ("Should have obtained video_window_handle by now!");
|
2010-01-10 23:50:02 +00:00
|
|
|
* }
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-01-10 23:50:02 +00:00
|
|
|
* gst_message_unref (message);
|
|
|
|
* return GST_BUS_DROP;
|
|
|
|
* }
|
|
|
|
* ...
|
|
|
|
* static void
|
|
|
|
* video_widget_realize_cb (GtkWidget * widget, gpointer data)
|
|
|
|
* {
|
|
|
|
* #if GTK_CHECK_VERSION(2,18,0)
|
2012-01-05 01:51:35 +00:00
|
|
|
* // Tell Gtk+/Gdk to create a native window for this widget instead of
|
|
|
|
* // drawing onto the parent widget.
|
2010-01-10 23:50:02 +00:00
|
|
|
* // This is here just for pedagogical purposes, GDK_WINDOW_XID will call
|
|
|
|
* // it as well in newer Gtk versions
|
|
|
|
* if (!gdk_window_ensure_native (widget->window))
|
|
|
|
* g_error ("Couldn't create native window needed for GstXOverlay!");
|
|
|
|
* #endif
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-01-10 23:50:02 +00:00
|
|
|
* #ifdef GDK_WINDOWING_X11
|
2012-01-05 01:51:35 +00:00
|
|
|
* {
|
|
|
|
* gulong xid = GDK_WINDOW_XID (gtk_widget_get_window (video_window));
|
|
|
|
* video_window_handle = xid;
|
|
|
|
* }
|
|
|
|
* #endif
|
|
|
|
* #ifdef GDK_WINDOWING_WIN32
|
|
|
|
* {
|
|
|
|
* HWND wnd = GDK_WINDOW_HWND (gtk_widget_get_window (video_window));
|
|
|
|
* video_window_handle = (guintptr) wnd;
|
|
|
|
* }
|
2010-01-10 23:50:02 +00:00
|
|
|
* #endif
|
|
|
|
* }
|
|
|
|
* ...
|
|
|
|
* int
|
|
|
|
* main (int argc, char **argv)
|
|
|
|
* {
|
|
|
|
* GtkWidget *video_window;
|
|
|
|
* GtkWidget *app_window;
|
|
|
|
* ...
|
|
|
|
* app_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
* ...
|
|
|
|
* video_window = gtk_drawing_area_new ();
|
|
|
|
* g_signal_connect (video_window, "realize",
|
|
|
|
* G_CALLBACK (video_widget_realize_cb), NULL);
|
|
|
|
* gtk_widget_set_double_buffered (video_window, FALSE);
|
|
|
|
* ...
|
|
|
|
* // usually the video_window will not be directly embedded into the
|
|
|
|
* // application window like this, but there will be many other widgets
|
|
|
|
* // and the video window will be embedded in one of them instead
|
|
|
|
* gtk_container_add (GTK_CONTAINER (ap_window), video_window);
|
|
|
|
* ...
|
|
|
|
* // show the GUI
|
|
|
|
* gtk_widget_show_all (app_window);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-01-10 23:50:02 +00:00
|
|
|
* // realize window now so that the video window gets created and we can
|
2012-01-05 01:51:35 +00:00
|
|
|
* // obtain its XID/HWND before the pipeline is started up and the videosink
|
|
|
|
* // asks for the XID/HWND of the window to render onto
|
2011-12-05 08:38:33 +00:00
|
|
|
* gtk_widget_realize (video_window);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2012-01-05 01:51:35 +00:00
|
|
|
* // we should have the XID/HWND now
|
|
|
|
* g_assert (video_window_handle != 0);
|
2010-01-10 23:50:02 +00:00
|
|
|
* ...
|
|
|
|
* // set up sync handler for setting the xid once the pipeline is started
|
|
|
|
* bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
|
|
|
* gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler, NULL);
|
|
|
|
* gst_object_unref (bus);
|
|
|
|
* ...
|
|
|
|
* gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
* ...
|
|
|
|
* }
|
2010-02-16 13:43:26 +00:00
|
|
|
* ]|
|
2010-01-10 23:50:02 +00:00
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
|
|
|
* <refsect2>
|
|
|
|
* <title>GstXOverlay and Qt</title>
|
|
|
|
* <para>
|
2010-02-16 13:43:26 +00:00
|
|
|
* |[
|
|
|
|
* #include <glib.h>
|
|
|
|
* #include <gst/gst.h>
|
|
|
|
* #include <gst/interfaces/xoverlay.h>
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* #include <QApplication>
|
|
|
|
* #include <QTimer>
|
|
|
|
* #include <QWidget>
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* int main(int argc, char *argv[])
|
|
|
|
* {
|
|
|
|
* if (!g_thread_supported ())
|
|
|
|
* g_thread_init (NULL);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* gst_init (&argc, &argv);
|
|
|
|
* QApplication app(argc, argv);
|
|
|
|
* app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* // prepare the pipeline
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* GstElement *pipeline = gst_pipeline_new ("xvoverlay");
|
|
|
|
* GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
|
|
|
|
* GstElement *sink = gst_element_factory_make ("xvimagesink", NULL);
|
|
|
|
* gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
|
|
|
|
* gst_element_link (src, sink);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* // prepare the ui
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* QWidget window;
|
|
|
|
* window.resize(320, 240);
|
|
|
|
* window.show();
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* WId xwinid = window.winId();
|
2010-09-05 22:17:47 +00:00
|
|
|
* gst_x_overlay_set_window_handle (GST_X_OVERLAY (sink), xwinid);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* // run the pipeline
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* GstStateChangeReturn sret = gst_element_set_state (pipeline,
|
|
|
|
* GST_STATE_PLAYING);
|
|
|
|
* if (sret == GST_STATE_CHANGE_FAILURE) {
|
|
|
|
* gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
* gst_object_unref (pipeline);
|
|
|
|
* // Exit application
|
|
|
|
* QTimer::singleShot(0, QApplication::activeWindow(), SLOT(quit()));
|
|
|
|
* }
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* int ret = app.exec();
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* window.hide();
|
|
|
|
* gst_element_set_state (pipeline, GST_STATE_NULL);
|
|
|
|
* gst_object_unref (pipeline);
|
2011-05-23 20:41:56 +00:00
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* return ret;
|
|
|
|
* }
|
|
|
|
* ]|
|
2010-01-10 23:50:02 +00:00
|
|
|
* </para>
|
|
|
|
* </refsect2>
|
2005-11-28 13:06:05 +00:00
|
|
|
*/
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "xoverlay.h"
|
|
|
|
|
2003-11-19 22:40:59 +00:00
|
|
|
static void gst_x_overlay_base_init (gpointer g_class);
|
2003-10-10 12:47:41 +00:00
|
|
|
|
|
|
|
GType
|
|
|
|
gst_x_overlay_get_type (void)
|
|
|
|
{
|
|
|
|
static GType gst_x_overlay_type = 0;
|
|
|
|
|
|
|
|
if (!gst_x_overlay_type) {
|
|
|
|
static const GTypeInfo gst_x_overlay_info = {
|
|
|
|
sizeof (GstXOverlayClass),
|
2003-11-17 16:29:38 +00:00
|
|
|
gst_x_overlay_base_init,
|
2003-10-10 12:47:41 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
gst_x_overlay_type = g_type_register_static (G_TYPE_INTERFACE,
|
2004-03-15 19:32:28 +00:00
|
|
|
"GstXOverlay", &gst_x_overlay_info, 0);
|
2003-10-10 12:47:41 +00:00
|
|
|
g_type_interface_add_prerequisite (gst_x_overlay_type,
|
2004-03-15 19:32:28 +00:00
|
|
|
GST_TYPE_IMPLEMENTS_INTERFACE);
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return gst_x_overlay_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-17 16:29:38 +00:00
|
|
|
gst_x_overlay_base_init (gpointer g_class)
|
2003-10-10 12:47:41 +00:00
|
|
|
{
|
2003-12-07 12:11:30 +00:00
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
|
2003-11-17 16:29:38 +00:00
|
|
|
/**
|
|
|
|
* gst_x_overlay_set_xwindow_id:
|
2011-05-23 20:41:56 +00:00
|
|
|
* @overlay: a #GstXOverlay to set the window on.
|
|
|
|
* @xwindow_id: a XID referencing the XWindow.
|
2003-11-17 16:29:38 +00:00
|
|
|
*
|
|
|
|
* This will call the video overlay's set_xwindow_id method. You should
|
|
|
|
* use this method to tell to a XOverlay to display video output to a
|
2011-05-23 20:41:56 +00:00
|
|
|
* specific XWindow. Passing 0 as the @xwindow_id will tell the overlay to
|
ext/ffmpeg/gstffmpegcolorspace.c: Implementing gst_pad_alloc_buffer to use optimized buffer allocation.
Original commit message from CVS:
* ext/ffmpeg/gstffmpegcolorspace.c: (gst_ffmpegcsp_chain):
Implementing gst_pad_alloc_buffer to use optimized buffer allocation.
* gst-libs/gst/xoverlay/xoverlay.c:
(gst_x_overlay_got_desired_size): Updating doc for the xid being 0.
* gst/videoscale/gstvideoscale.c: (gst_videoscale_chain):
Implementing gst_pad_alloc_buffer to use optimized buffer allocation.
* gst/videotestsrc/gstvideotestsrc.c: (gst_videotestsrc_get):
Implementing gst_pad_alloc_buffer to use optimized buffer allocation.
* sys/ximage/ximagesink.c: (gst_ximagesink_chain),
(gst_ximagesink_buffer_free), (gst_ximagesink_buffer_alloc),
(gst_ximagesink_set_xwindow_id), (gst_ximagesink_init): Implementing
the bufferalloc_function to replace bufferpools, fixing the XOverlay
interface implementation to handle xid being 0 and fix some bugs
triggered by Benjamin's testcase.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain),
(gst_xvimagesink_buffer_free), (gst_xvimagesink_buffer_alloc),
(gst_xvimagesink_set_xwindow_id), (gst_xvimagesink_init): Implementing
the bufferalloc_function to replace bufferpools, fixing the XOverlay
interface implementation to handle xid being 0 and fix some bugs
triggered by Benjamin's testcase.
2004-01-09 18:05:57 +00:00
|
|
|
* stop using that window and create an internal one.
|
2010-09-05 22:17:47 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use gst_x_overlay_set_window_handle() instead.
|
2003-11-17 16:29:38 +00:00
|
|
|
*/
|
2010-09-05 22:17:47 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
|
|
|
#ifdef GST_DISABLE_DEPRECATED
|
|
|
|
void gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
|
|
|
|
#endif
|
2003-10-10 12:47:41 +00:00
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_x_overlay_set_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
|
2010-09-05 22:17:47 +00:00
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (overlay,
|
|
|
|
"Using deprecated gst_x_overlay_set_xwindow_id()");
|
|
|
|
gst_x_overlay_set_window_handle (overlay, xwindow_id);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_x_overlay_set_window_handle:
|
2011-05-23 20:41:56 +00:00
|
|
|
* @overlay: a #GstXOverlay to set the window on.
|
|
|
|
* @handle: a handle referencing the window.
|
2010-09-05 22:17:47 +00:00
|
|
|
*
|
|
|
|
* This will call the video overlay's set_window_handle method. You
|
|
|
|
* should use this method to tell to a XOverlay to display video output to a
|
2011-05-23 20:41:56 +00:00
|
|
|
* specific window (e.g. an XWindow on X11). Passing 0 as the @handle will
|
|
|
|
* tell the overlay to stop using that window and create an internal one.
|
2010-09-05 22:17:47 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.31
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_x_overlay_set_window_handle (GstXOverlay * overlay, guintptr handle)
|
2003-10-10 12:47:41 +00:00
|
|
|
{
|
2006-10-08 16:59:31 +00:00
|
|
|
GstXOverlayClass *klass;
|
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
|
|
|
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
|
|
|
|
|
|
|
|
klass = GST_X_OVERLAY_GET_CLASS (overlay);
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2010-09-05 22:17:47 +00:00
|
|
|
if (klass->set_window_handle) {
|
|
|
|
klass->set_window_handle (overlay, handle);
|
|
|
|
} else {
|
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
|
|
|
#ifdef GST_DISABLE_DEPRECATED
|
|
|
|
#define set_xwindow_id set_xwindow_id_disabled
|
|
|
|
#endif
|
|
|
|
if (sizeof (guintptr) <= sizeof (gulong) && klass->set_xwindow_id) {
|
|
|
|
GST_WARNING_OBJECT (overlay,
|
|
|
|
"Calling deprecated set_xwindow_id() method");
|
|
|
|
klass->set_xwindow_id (overlay, handle);
|
|
|
|
} else {
|
|
|
|
g_warning ("Refusing to cast guintptr to smaller gulong");
|
|
|
|
}
|
|
|
|
#endif
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-17 16:29:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_x_overlay_got_xwindow_id:
|
|
|
|
* @overlay: a #GstXOverlay which got a XWindow.
|
2011-08-20 17:16:42 +00:00
|
|
|
* @xwindow_id: a XID referencing the XWindow.
|
2003-11-17 16:29:38 +00:00
|
|
|
*
|
2005-11-21 20:28:23 +00:00
|
|
|
* This will post a "have-xwindow-id" element message on the bus.
|
2003-11-17 16:29:38 +00:00
|
|
|
*
|
2005-11-21 20:28:23 +00:00
|
|
|
* This function should only be used by video overlay plugin developers.
|
2010-09-05 22:17:47 +00:00
|
|
|
*
|
|
|
|
* Deprecated: Use gst_x_overlay_got_window_handle() instead.
|
2003-11-17 16:29:38 +00:00
|
|
|
*/
|
2010-09-05 22:17:47 +00:00
|
|
|
#ifndef GST_REMOVE_DEPRECATED
|
|
|
|
#ifdef GST_DISABLE_DEPRECATED
|
|
|
|
void gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id);
|
|
|
|
#endif
|
2003-11-17 16:29:38 +00:00
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_x_overlay_got_xwindow_id (GstXOverlay * overlay, gulong xwindow_id)
|
2010-09-05 22:17:47 +00:00
|
|
|
{
|
|
|
|
GST_WARNING_OBJECT (overlay,
|
|
|
|
"Using deprecated gst_x_overlay_got_xwindow_id()");
|
2010-09-28 12:15:57 +00:00
|
|
|
gst_x_overlay_got_window_handle (overlay, xwindow_id);
|
2010-09-05 22:17:47 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_x_overlay_got_window_handle:
|
|
|
|
* @overlay: a #GstXOverlay which got a window
|
|
|
|
* @handle: a platform-specific handle referencing the window
|
|
|
|
*
|
|
|
|
* This will post a "have-xwindow-id" element message on the bus.
|
|
|
|
*
|
|
|
|
* This function should only be used by video overlay plugin developers.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_x_overlay_got_window_handle (GstXOverlay * overlay, guintptr handle)
|
2003-11-17 16:29:38 +00:00
|
|
|
{
|
2005-11-21 20:28:23 +00:00
|
|
|
GstStructure *s;
|
|
|
|
GstMessage *msg;
|
|
|
|
|
2003-11-17 16:29:38 +00:00
|
|
|
g_return_if_fail (overlay != NULL);
|
|
|
|
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2010-09-16 17:30:59 +00:00
|
|
|
GST_LOG_OBJECT (GST_OBJECT (overlay), "xwindow_id = %p", (gpointer)
|
2010-09-05 22:17:47 +00:00
|
|
|
handle);
|
|
|
|
s = gst_structure_new ("have-xwindow-id",
|
|
|
|
"xwindow-id", G_TYPE_ULONG, (unsigned long) handle,
|
|
|
|
"window-handle", G_TYPE_UINT64, (guint64) handle, NULL);
|
2005-11-21 20:28:23 +00:00
|
|
|
msg = gst_message_new_element (GST_OBJECT (overlay), s);
|
|
|
|
gst_element_post_message (GST_ELEMENT (overlay), msg);
|
2004-01-04 18:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-11-21 20:28:23 +00:00
|
|
|
* gst_x_overlay_prepare_xwindow_id:
|
|
|
|
* @overlay: a #GstXOverlay which does not yet have an XWindow.
|
2004-01-04 18:02:30 +00:00
|
|
|
*
|
2005-11-21 20:28:23 +00:00
|
|
|
* This will post a "prepare-xwindow-id" element message on the bus
|
2011-05-23 20:41:56 +00:00
|
|
|
* to give applications an opportunity to call
|
2005-11-21 20:28:23 +00:00
|
|
|
* gst_x_overlay_set_xwindow_id() before a plugin creates its own
|
|
|
|
* window.
|
2004-01-04 18:02:30 +00:00
|
|
|
*
|
2005-11-21 20:28:23 +00:00
|
|
|
* This function should only be used by video overlay plugin developers.
|
2004-01-04 18:02:30 +00:00
|
|
|
*/
|
|
|
|
void
|
2005-11-21 20:28:23 +00:00
|
|
|
gst_x_overlay_prepare_xwindow_id (GstXOverlay * overlay)
|
2004-01-04 18:02:30 +00:00
|
|
|
{
|
2005-11-21 20:28:23 +00:00
|
|
|
GstStructure *s;
|
|
|
|
GstMessage *msg;
|
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
2004-01-04 18:02:30 +00:00
|
|
|
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2005-11-21 20:28:23 +00:00
|
|
|
GST_LOG_OBJECT (GST_OBJECT (overlay), "prepare xwindow_id");
|
|
|
|
s = gst_structure_new ("prepare-xwindow-id", NULL);
|
|
|
|
msg = gst_message_new_element (GST_OBJECT (overlay), s);
|
|
|
|
gst_element_post_message (GST_ELEMENT (overlay), msg);
|
2004-01-04 18:02:30 +00:00
|
|
|
}
|
2004-02-03 23:05:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_x_overlay_expose:
|
|
|
|
* @overlay: a #GstXOverlay to expose.
|
|
|
|
*
|
|
|
|
* Tell an overlay that it has been exposed. This will redraw the current frame
|
|
|
|
* in the drawable even if the pipeline is PAUSED.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-14 22:34:34 +00:00
|
|
|
gst_x_overlay_expose (GstXOverlay * overlay)
|
2004-02-03 23:05:46 +00:00
|
|
|
{
|
2006-10-08 16:59:31 +00:00
|
|
|
GstXOverlayClass *klass;
|
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
2007-12-15 17:27:48 +00:00
|
|
|
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
|
2006-10-08 16:59:31 +00:00
|
|
|
|
|
|
|
klass = GST_X_OVERLAY_GET_CLASS (overlay);
|
2004-02-03 23:05:46 +00:00
|
|
|
|
|
|
|
if (klass->expose) {
|
|
|
|
klass->expose (overlay);
|
|
|
|
}
|
|
|
|
}
|
Add a method to the XOverlay interface to allow disabling of event handling in x[v]imagesink elements. This will let ...
Original commit message from CVS:
2007-01-04 Julien MOUTTE <julien@moutte.net>
* gst-libs/gst/interfaces/xoverlay.c:
(gst_x_overlay_handle_events):
* gst-libs/gst/interfaces/xoverlay.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),
(gst_ximagesink_set_xwindow_id),
(gst_ximagesink_set_event_handling),
(gst_ximagesink_xoverlay_init), (gst_ximagesink_set_property),
(gst_ximagesink_get_property), (gst_ximagesink_init),
(gst_ximagesink_class_init):
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_new),
(gst_xvimagesink_set_xwindow_id),
(gst_xvimagesink_set_event_handling),
(gst_xvimagesink_xoverlay_init), (gst_xvimagesink_set_property),
(gst_xvimagesink_get_property), (gst_xvimagesink_init),
(gst_xvimagesink_class_init):
* sys/xvimage/xvimagesink.h:
* tests/icles/stress-xoverlay.c: (toggle_events),
(create_window):
Add a method to the XOverlay interface to allow disabling of
event handling in x[v]imagesink elements. This will let X events
propagate to parent windows which can be usefull in some cases.
Be carefull that the application is then responsible of pushing
navigation events and expose events to the video sink.
Fixes: #387138.
2007-01-04 11:30:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_x_overlay_handle_events:
|
|
|
|
* @overlay: a #GstXOverlay to expose.
|
|
|
|
* @handle_events: a #gboolean indicating if events should be handled or not.
|
|
|
|
*
|
|
|
|
* Tell an overlay that it should handle events from the window system. These
|
2011-09-13 19:10:43 +00:00
|
|
|
* events are forwarded upstream as navigation events. In some window system,
|
Add a method to the XOverlay interface to allow disabling of event handling in x[v]imagesink elements. This will let ...
Original commit message from CVS:
2007-01-04 Julien MOUTTE <julien@moutte.net>
* gst-libs/gst/interfaces/xoverlay.c:
(gst_x_overlay_handle_events):
* gst-libs/gst/interfaces/xoverlay.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),
(gst_ximagesink_set_xwindow_id),
(gst_ximagesink_set_event_handling),
(gst_ximagesink_xoverlay_init), (gst_ximagesink_set_property),
(gst_ximagesink_get_property), (gst_ximagesink_init),
(gst_ximagesink_class_init):
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_new),
(gst_xvimagesink_set_xwindow_id),
(gst_xvimagesink_set_event_handling),
(gst_xvimagesink_xoverlay_init), (gst_xvimagesink_set_property),
(gst_xvimagesink_get_property), (gst_xvimagesink_init),
(gst_xvimagesink_class_init):
* sys/xvimage/xvimagesink.h:
* tests/icles/stress-xoverlay.c: (toggle_events),
(create_window):
Add a method to the XOverlay interface to allow disabling of
event handling in x[v]imagesink elements. This will let X events
propagate to parent windows which can be usefull in some cases.
Be carefull that the application is then responsible of pushing
navigation events and expose events to the video sink.
Fixes: #387138.
2007-01-04 11:30:53 +00:00
|
|
|
* events are not propagated in the window hierarchy if a client is listening
|
|
|
|
* for them. This method allows you to disable events handling completely
|
|
|
|
* from the XOverlay.
|
2010-03-20 12:55:36 +00:00
|
|
|
*
|
|
|
|
* Since: 0.10.12
|
Add a method to the XOverlay interface to allow disabling of event handling in x[v]imagesink elements. This will let ...
Original commit message from CVS:
2007-01-04 Julien MOUTTE <julien@moutte.net>
* gst-libs/gst/interfaces/xoverlay.c:
(gst_x_overlay_handle_events):
* gst-libs/gst/interfaces/xoverlay.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),
(gst_ximagesink_set_xwindow_id),
(gst_ximagesink_set_event_handling),
(gst_ximagesink_xoverlay_init), (gst_ximagesink_set_property),
(gst_ximagesink_get_property), (gst_ximagesink_init),
(gst_ximagesink_class_init):
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_new),
(gst_xvimagesink_set_xwindow_id),
(gst_xvimagesink_set_event_handling),
(gst_xvimagesink_xoverlay_init), (gst_xvimagesink_set_property),
(gst_xvimagesink_get_property), (gst_xvimagesink_init),
(gst_xvimagesink_class_init):
* sys/xvimage/xvimagesink.h:
* tests/icles/stress-xoverlay.c: (toggle_events),
(create_window):
Add a method to the XOverlay interface to allow disabling of
event handling in x[v]imagesink elements. This will let X events
propagate to parent windows which can be usefull in some cases.
Be carefull that the application is then responsible of pushing
navigation events and expose events to the video sink.
Fixes: #387138.
2007-01-04 11:30:53 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_x_overlay_handle_events (GstXOverlay * overlay, gboolean handle_events)
|
|
|
|
{
|
|
|
|
GstXOverlayClass *klass;
|
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
2007-12-15 17:27:48 +00:00
|
|
|
g_return_if_fail (GST_IS_X_OVERLAY (overlay));
|
Add a method to the XOverlay interface to allow disabling of event handling in x[v]imagesink elements. This will let ...
Original commit message from CVS:
2007-01-04 Julien MOUTTE <julien@moutte.net>
* gst-libs/gst/interfaces/xoverlay.c:
(gst_x_overlay_handle_events):
* gst-libs/gst/interfaces/xoverlay.h:
* sys/ximage/ximagesink.c: (gst_ximagesink_xwindow_new),
(gst_ximagesink_set_xwindow_id),
(gst_ximagesink_set_event_handling),
(gst_ximagesink_xoverlay_init), (gst_ximagesink_set_property),
(gst_ximagesink_get_property), (gst_ximagesink_init),
(gst_ximagesink_class_init):
* sys/ximage/ximagesink.h:
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_xwindow_new),
(gst_xvimagesink_set_xwindow_id),
(gst_xvimagesink_set_event_handling),
(gst_xvimagesink_xoverlay_init), (gst_xvimagesink_set_property),
(gst_xvimagesink_get_property), (gst_xvimagesink_init),
(gst_xvimagesink_class_init):
* sys/xvimage/xvimagesink.h:
* tests/icles/stress-xoverlay.c: (toggle_events),
(create_window):
Add a method to the XOverlay interface to allow disabling of
event handling in x[v]imagesink elements. This will let X events
propagate to parent windows which can be usefull in some cases.
Be carefull that the application is then responsible of pushing
navigation events and expose events to the video sink.
Fixes: #387138.
2007-01-04 11:30:53 +00:00
|
|
|
|
|
|
|
klass = GST_X_OVERLAY_GET_CLASS (overlay);
|
|
|
|
|
|
|
|
if (klass->handle_events) {
|
|
|
|
klass->handle_events (overlay, handle_events);
|
|
|
|
}
|
|
|
|
}
|
2010-02-17 13:00:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_x_overlay_set_render_rectangle:
|
|
|
|
* @overlay: a #GstXOverlay
|
2010-03-24 09:59:42 +00:00
|
|
|
* @x: the horizontal offset of the render area inside the window
|
|
|
|
* @y: the vertical offset of the render area inside the window
|
|
|
|
* @width: the width of the render area inside the window
|
|
|
|
* @height: the height of the render area inside the window
|
2010-02-17 13:00:13 +00:00
|
|
|
*
|
|
|
|
* Configure a subregion as a video target within the window set by
|
2010-09-05 22:17:47 +00:00
|
|
|
* gst_x_overlay_set_window_handle(). If this is not used or not supported
|
2010-02-17 13:00:13 +00:00
|
|
|
* the video will fill the area of the window set as the overlay to 100%.
|
|
|
|
* By specifying the rectangle, the video can be overlayed to a specific region
|
|
|
|
* of that window only. After setting the new rectangle one should call
|
2010-03-24 09:59:42 +00:00
|
|
|
* gst_x_overlay_expose() to force a redraw. To unset the region pass -1 for
|
2010-06-17 11:33:44 +00:00
|
|
|
* the @width and @height parameters.
|
2010-02-17 13:00:13 +00:00
|
|
|
*
|
2010-03-24 09:59:42 +00:00
|
|
|
* This method is needed for non fullscreen video overlay in UI toolkits that
|
|
|
|
* do not support subwindows.
|
2010-02-17 13:00:13 +00:00
|
|
|
*
|
2010-03-15 13:32:58 +00:00
|
|
|
* Returns: %FALSE if not supported by the sink.
|
2010-02-17 13:00:13 +00:00
|
|
|
*
|
2010-03-11 08:55:21 +00:00
|
|
|
* Since: 0.10.29
|
2010-02-17 13:00:13 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_x_overlay_set_render_rectangle (GstXOverlay * overlay,
|
2010-03-24 09:59:42 +00:00
|
|
|
gint x, gint y, gint width, gint height)
|
2010-02-17 13:00:13 +00:00
|
|
|
{
|
|
|
|
GstXOverlayClass *klass;
|
|
|
|
|
|
|
|
g_return_val_if_fail (overlay != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_X_OVERLAY (overlay), FALSE);
|
2010-06-17 11:33:44 +00:00
|
|
|
g_return_val_if_fail ((width == -1 && height == -1) ||
|
|
|
|
(width > 0 && height > 0), FALSE);
|
2010-02-17 13:00:13 +00:00
|
|
|
|
|
|
|
klass = GST_X_OVERLAY_GET_CLASS (overlay);
|
|
|
|
|
|
|
|
if (klass->set_render_rectangle) {
|
2010-03-24 09:59:42 +00:00
|
|
|
klass->set_render_rectangle (overlay, x, y, width, height);
|
2010-02-17 13:00:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|