2011-08-07 15:55:25 +00:00
|
|
|
/* GStreamer Video Overlay interface
|
2003-10-10 12:47:41 +00:00
|
|
|
* Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
|
2011-08-07 15:55:25 +00:00
|
|
|
* Copyright (C) 2011 Tim-Philipp Müller <tim@centricular.net>
|
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
|
2012-11-03 23:05:09 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-10-10 12:47:41 +00:00
|
|
|
*/
|
2005-11-28 13:06:05 +00:00
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* SECTION:gstvideooverlay
|
2017-01-23 19:36:11 +00:00
|
|
|
* @title: GstVideoOverlay
|
2011-08-07 15:55:25 +00:00
|
|
|
* @short_description: Interface for setting/getting a window system resource
|
|
|
|
* on elements supporting it to configure a window into which to render a
|
|
|
|
* video.
|
2005-11-28 13:06:05 +00:00
|
|
|
*
|
2011-08-07 15:55:25 +00:00
|
|
|
* The #GstVideoOverlay interface is used for 2 main purposes :
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* * 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.
|
|
|
|
* * To force a redrawing of the latest video frame the video sink element
|
|
|
|
* displayed on the Window. Indeed if the #GstPipeline is in #GST_STATE_PAUSED
|
|
|
|
* state, moving the Window around will damage its content. Application
|
|
|
|
* developers will want to handle the Expose events themselves and force the
|
|
|
|
* video sink element to refresh the Window's content.
|
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* 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.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
* 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)
|
|
|
|
* {
|
2011-08-07 15:55:25 +00:00
|
|
|
* // ignore anything but 'prepare-window-handle' element messages
|
2011-08-08 13:41:17 +00:00
|
|
|
* if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
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
|
|
|
*
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_set_window_handle (GST_VIDEO_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));
|
2012-06-20 10:30:36 +00:00
|
|
|
* gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, pipeline,
|
|
|
|
NULL);
|
2005-11-28 13:06:05 +00:00
|
|
|
* ...
|
|
|
|
* }
|
2010-02-16 13:43:26 +00:00
|
|
|
* ]|
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## Two basic usage scenarios
|
|
|
|
*
|
2010-01-10 23:50:02 +00:00
|
|
|
* There are two basic usage scenarios: in the simplest case, the application
|
2014-01-14 12:17:26 +00:00
|
|
|
* uses #playbin or #plasink or 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 render the video on and then
|
|
|
|
* call gst_video_overlay_set_window_handle() directly with the XID or native
|
|
|
|
* window handle, before starting up the pipeline.
|
|
|
|
* As #playbin and #playsink implement the video overlay interface and proxy
|
|
|
|
* it transparently to the actual video sink even if it is created later, this
|
|
|
|
* case also applies when using these elements.
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2010-01-10 23:50:02 +00:00
|
|
|
* 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
|
2014-01-14 12:17:26 +00:00
|
|
|
* usually the case when an element such as #autovideosink is used.
|
|
|
|
* In this case, the video sink element itself is created
|
2010-01-10 23:50:02 +00:00
|
|
|
* 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
|
2011-08-07 15:55:25 +00:00
|
|
|
* posts a prepare-window-handle message, and that is also why this message needs
|
2010-01-10 23:50:02 +00:00
|
|
|
* 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).
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2011-08-07 15:55:25 +00:00
|
|
|
* As response to the prepare-window-handle element message in the bus sync
|
|
|
|
* handler, the application may use gst_video_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
|
2011-08-07 15:55:25 +00:00
|
|
|
* prepare-window-handle message is handled, because most GUI toolkits and
|
2010-01-10 23:50:02 +00:00
|
|
|
* 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).
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## GstVideoOverlay and Gtk+
|
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* |[
|
2012-12-10 13:35:37 +00:00
|
|
|
* #include <gst/video/videooverlay.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)
|
|
|
|
* {
|
2011-08-07 15:55:25 +00:00
|
|
|
* // ignore anything but 'prepare-window-handle' element messages
|
2011-08-08 13:41:17 +00:00
|
|
|
* if (!gst_is_video_overlay_prepare_window_handle_message (message))
|
2010-01-10 23:50:02 +00:00
|
|
|
* 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) {
|
2012-12-10 13:35:37 +00:00
|
|
|
* GstVideoOverlay *overlay;
|
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
|
2012-12-10 13:35:37 +00:00
|
|
|
* overlay = GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message));
|
|
|
|
* gst_video_overlay_set_window_handle (overlay, 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))
|
2011-08-07 15:55:25 +00:00
|
|
|
* g_error ("Couldn't create native window needed for GstVideoOverlay!");
|
2010-01-10 23:50:02 +00:00
|
|
|
* #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));
|
2012-06-20 10:30:36 +00:00
|
|
|
* gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bus_sync_handler, NULL,
|
|
|
|
* NULL);
|
2010-01-10 23:50:02 +00:00
|
|
|
* gst_object_unref (bus);
|
|
|
|
* ...
|
|
|
|
* gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
* ...
|
|
|
|
* }
|
2010-02-16 13:43:26 +00:00
|
|
|
* ]|
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
|
|
|
* ## GstVideoOverlay and Qt
|
|
|
|
*
|
2010-02-16 13:43:26 +00:00
|
|
|
* |[
|
|
|
|
* #include <glib.h>
|
|
|
|
* #include <gst/gst.h>
|
2012-04-13 09:01:03 +00:00
|
|
|
* #include <gst/video/videooverlay.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();
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_set_window_handle (GST_VIDEO_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;
|
|
|
|
* }
|
|
|
|
* ]|
|
2017-01-23 19:36:11 +00:00
|
|
|
*
|
2005-11-28 13:06:05 +00:00
|
|
|
*/
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
#include "videooverlay.h"
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2018-01-22 20:40:32 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_RENDER_RECTANGLE,
|
|
|
|
};
|
|
|
|
|
2015-07-15 10:45:10 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_video_overlay_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_video_overlay_debug
|
|
|
|
|
2003-10-10 12:47:41 +00:00
|
|
|
GType
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_get_type (void)
|
2003-10-10 12:47:41 +00:00
|
|
|
{
|
2011-08-07 15:55:25 +00:00
|
|
|
static GType gst_video_overlay_type = 0;
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
if (!gst_video_overlay_type) {
|
|
|
|
static const GTypeInfo gst_video_overlay_info = {
|
2011-10-21 12:37:31 +00:00
|
|
|
sizeof (GstVideoOverlayInterface),
|
2011-08-07 15:55:25 +00:00
|
|
|
NULL,
|
2003-10-10 12:47:41 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_type = g_type_register_static (G_TYPE_INTERFACE,
|
|
|
|
"GstVideoOverlay", &gst_video_overlay_info, 0);
|
2015-07-15 10:45:10 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_video_overlay_debug, "videooverlay", 0,
|
|
|
|
"videooverlay interface");
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
return gst_video_overlay_type;
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
|
2003-11-17 16:29:38 +00:00
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_set_window_handle:
|
|
|
|
* @overlay: a #GstVideoOverlay to set the window on.
|
2011-05-23 20:41:56 +00:00
|
|
|
* @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
|
2012-12-10 13:35:37 +00:00
|
|
|
* should use this method to tell to an overlay 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
|
|
|
*/
|
|
|
|
void
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_set_window_handle (GstVideoOverlay * overlay, guintptr handle)
|
2003-10-10 12:47:41 +00:00
|
|
|
{
|
2011-10-21 12:37:31 +00:00
|
|
|
GstVideoOverlayInterface *iface;
|
2006-10-08 16:59:31 +00:00
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
2011-08-07 15:55:25 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEO_OVERLAY (overlay));
|
2006-10-08 16:59:31 +00:00
|
|
|
|
2011-10-21 12:37:31 +00:00
|
|
|
iface = GST_VIDEO_OVERLAY_GET_INTERFACE (overlay);
|
2003-10-10 12:47:41 +00:00
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
if (iface->set_window_handle) {
|
|
|
|
iface->set_window_handle (overlay, handle);
|
2003-10-10 12:47:41 +00:00
|
|
|
}
|
|
|
|
}
|
2003-11-17 16:29:38 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_got_window_handle:
|
|
|
|
* @overlay: a #GstVideoOverlay which got a window
|
2010-09-05 22:17:47 +00:00
|
|
|
* @handle: a platform-specific handle referencing the window
|
|
|
|
*
|
2011-08-07 15:55:25 +00:00
|
|
|
* This will post a "have-window-handle" element message on the bus.
|
2010-09-05 22:17:47 +00:00
|
|
|
*
|
|
|
|
* This function should only be used by video overlay plugin developers.
|
|
|
|
*/
|
|
|
|
void
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_got_window_handle (GstVideoOverlay * 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);
|
2011-08-07 15:55:25 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEO_OVERLAY (overlay));
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
GST_LOG_OBJECT (GST_OBJECT (overlay), "window_handle = %p", (gpointer)
|
2010-09-05 22:17:47 +00:00
|
|
|
handle);
|
2011-08-07 15:55:25 +00:00
|
|
|
s = gst_structure_new ("have-window-handle",
|
2010-09-05 22:17:47 +00:00
|
|
|
"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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_prepare_window_handle:
|
|
|
|
* @overlay: a #GstVideoOverlay which does not yet have an Window handle set
|
2004-01-04 18:02:30 +00:00
|
|
|
*
|
2011-08-07 15:55:25 +00:00
|
|
|
* This will post a "prepare-window-handle" element message on the bus
|
2011-05-23 20:41:56 +00:00
|
|
|
* to give applications an opportunity to call
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_set_window_handle() before a plugin creates its own
|
2005-11-21 20:28:23 +00:00
|
|
|
* 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
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_prepare_window_handle (GstVideoOverlay * 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);
|
2011-08-07 15:55:25 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEO_OVERLAY (overlay));
|
2004-03-14 22:34:34 +00:00
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
GST_LOG_OBJECT (GST_OBJECT (overlay), "prepare window handle");
|
2011-10-29 07:03:07 +00:00
|
|
|
s = gst_structure_new_empty ("prepare-window-handle");
|
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
|
|
|
}
|
2004-02-03 23:05:46 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_expose:
|
|
|
|
* @overlay: a #GstVideoOverlay to expose.
|
2004-02-03 23:05:46 +00:00
|
|
|
*
|
|
|
|
* Tell an overlay that it has been exposed. This will redraw the current frame
|
|
|
|
* in the drawable even if the pipeline is PAUSED.
|
|
|
|
*/
|
|
|
|
void
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_expose (GstVideoOverlay * overlay)
|
2004-02-03 23:05:46 +00:00
|
|
|
{
|
2011-10-21 12:37:31 +00:00
|
|
|
GstVideoOverlayInterface *iface;
|
2006-10-08 16:59:31 +00:00
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
2011-08-07 15:55:25 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEO_OVERLAY (overlay));
|
2006-10-08 16:59:31 +00:00
|
|
|
|
2011-10-21 12:37:31 +00:00
|
|
|
iface = GST_VIDEO_OVERLAY_GET_INTERFACE (overlay);
|
2004-02-03 23:05:46 +00:00
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
if (iface->expose) {
|
|
|
|
iface->expose (overlay);
|
2004-02-03 23:05:46 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_handle_events:
|
|
|
|
* @overlay: a #GstVideoOverlay to expose.
|
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
|
|
|
* @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
|
2012-12-10 13:35:37 +00:00
|
|
|
* from the #GstVideoOverlay.
|
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
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_handle_events (GstVideoOverlay * overlay,
|
|
|
|
gboolean handle_events)
|
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
|
|
|
{
|
2011-10-21 12:37:31 +00:00
|
|
|
GstVideoOverlayInterface *iface;
|
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
|
|
|
|
|
|
|
g_return_if_fail (overlay != NULL);
|
2011-08-07 15:55:25 +00:00
|
|
|
g_return_if_fail (GST_IS_VIDEO_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
|
|
|
|
2011-10-21 12:37:31 +00:00
|
|
|
iface = GST_VIDEO_OVERLAY_GET_INTERFACE (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
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
if (iface->handle_events) {
|
|
|
|
iface->handle_events (overlay, handle_events);
|
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
|
|
|
}
|
|
|
|
}
|
2010-02-17 13:00:13 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_overlay_set_render_rectangle:
|
|
|
|
* @overlay: a #GstVideoOverlay
|
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
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_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
|
2011-08-07 15:55:25 +00:00
|
|
|
* gst_video_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
|
|
|
*/
|
|
|
|
gboolean
|
2011-08-07 15:55:25 +00:00
|
|
|
gst_video_overlay_set_render_rectangle (GstVideoOverlay * 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
|
|
|
{
|
2011-10-21 12:37:31 +00:00
|
|
|
GstVideoOverlayInterface *iface;
|
2010-02-17 13:00:13 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (overlay != NULL, FALSE);
|
2011-08-07 15:55:25 +00:00
|
|
|
g_return_val_if_fail (GST_IS_VIDEO_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
|
|
|
|
2011-10-21 12:37:31 +00:00
|
|
|
iface = GST_VIDEO_OVERLAY_GET_INTERFACE (overlay);
|
2010-02-17 13:00:13 +00:00
|
|
|
|
2011-08-07 15:55:25 +00:00
|
|
|
if (iface->set_render_rectangle) {
|
|
|
|
iface->set_render_rectangle (overlay, x, y, width, height);
|
2010-02-17 13:00:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2011-08-08 13:41:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_is_video_overlay_prepare_window_handle_message:
|
|
|
|
* @msg: a #GstMessage
|
|
|
|
*
|
|
|
|
* Convenience function to check if the given message is a
|
|
|
|
* "prepare-window-handle" message from a #GstVideoOverlay.
|
|
|
|
*
|
|
|
|
* Returns: whether @msg is a "prepare-window-handle" message
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_is_video_overlay_prepare_window_handle_message (GstMessage * msg)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (msg != NULL, FALSE);
|
|
|
|
|
|
|
|
if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gst_message_has_name (msg, "prepare-window-handle");
|
|
|
|
}
|
2018-01-22 20:40:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_video_overlay_install_properties:
|
|
|
|
* @oclass: The class on which the properties will be installed
|
|
|
|
* @last_prop_id: The first free property ID to use
|
|
|
|
*
|
|
|
|
* This helper shall be used by classes implementing the #GstVideoOverlay
|
|
|
|
* interface that want the render rectangle to be controllable using
|
|
|
|
* properties. This helper will install "render-rectangle" property into the
|
|
|
|
* class.
|
|
|
|
*
|
2019-04-23 12:05:43 +00:00
|
|
|
* Since: 1.14
|
2018-01-22 20:40:32 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_video_overlay_install_properties (GObjectClass * oclass, gint last_prop_id)
|
|
|
|
{
|
|
|
|
g_object_class_install_property (oclass, last_prop_id + PROP_RENDER_RECTANGLE,
|
|
|
|
gst_param_spec_array ("render-rectangle", "Render Rectangle",
|
|
|
|
"The render rectangle ('<x, y, width, height>')",
|
|
|
|
g_param_spec_int ("rect-value", "Rectangle Value",
|
2019-03-04 22:05:04 +00:00
|
|
|
"One of x, y, width or height value.", G_MININT, G_MAXINT, -1,
|
2018-01-22 20:40:32 +00:00
|
|
|
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS),
|
|
|
|
G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_video_overlay_set_property:
|
|
|
|
* @object: The instance on which the property is set
|
|
|
|
* @last_prop_id: The highest property ID.
|
|
|
|
* @property_id: The property ID
|
|
|
|
* @value: The #GValue to be set
|
|
|
|
*
|
|
|
|
* This helper shall be used by classes implementing the #GstVideoOverlay
|
|
|
|
* interface that want the render rectangle to be controllable using
|
|
|
|
* properties. This helper will parse and set the render rectangle calling
|
|
|
|
* gst_video_overlay_set_render_rectangle().
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the @property_id matches the GstVideoOverlay property
|
|
|
|
*
|
2019-04-23 12:05:43 +00:00
|
|
|
* Since: 1.14
|
2018-01-22 20:40:32 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_video_overlay_set_property (GObject * object, gint last_prop_id,
|
|
|
|
guint property_id, const GValue * value)
|
|
|
|
{
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
if (property_id == last_prop_id) {
|
|
|
|
const GValue *v;
|
|
|
|
gint rect[4], i;
|
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
if (gst_value_array_get_size (value) != 4)
|
|
|
|
goto wrong_format;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
v = gst_value_array_get_value (value, i);
|
|
|
|
if (!G_VALUE_HOLDS_INT (v))
|
|
|
|
goto wrong_format;
|
|
|
|
|
|
|
|
rect[i] = g_value_get_int (v);
|
|
|
|
}
|
|
|
|
|
|
|
|
gst_video_overlay_set_render_rectangle (GST_VIDEO_OVERLAY (object),
|
|
|
|
rect[0], rect[1], rect[2], rect[3]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
wrong_format:
|
|
|
|
{
|
|
|
|
GValue string = G_VALUE_INIT;
|
|
|
|
|
|
|
|
g_value_init (&string, G_TYPE_STRING);
|
|
|
|
g_value_transform (value, &string);
|
|
|
|
|
|
|
|
g_critical ("Badly formated rectangle, must contains four gint (got '%s')",
|
|
|
|
g_value_get_string (&string));
|
|
|
|
|
|
|
|
g_value_unset (&string);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|