Sets our main struct and passes it to the parent class.
The Element parameter should usually be your videosink that you want to create your XOverlay with.
Tell an overlay that it has been exposed. This will redraw the current frame in the drawable even if the pipeline is PAUSED.
the main Gtk struct as a void*
Get the main Gtk struct
This will post a "have-window-handle" element message on the bus.
Tell an overlay that it should handle events from the window system. These events are forwarded upstream as navigation events. In some window system, 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 gstinterfaces.VideoOverlay
This will post a "prepare-window-handle" element message on the bus to give applications an opportunity to call VideoOverlay.setWindowHandle before a plugin creates its own window.
Configure a subregion as a video target within the window set by VideoOverlay.setWindowHandle. If this is not used or not supported 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 VideoOverlay.expose to force a redraw. To unset the region pass -1 for the width and height parameters.
This will call the video overlay's set_window_handle method. You should use this method to tell to an overlay to display video output to a 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.
This helper shall be used by classes implementing the gstinterfaces.VideoOverlay interface that want the render rectangle to be controllable using properties. This helper will install "render-rectangle" property into the class.
This helper shall be used by classes implementing the gstinterfaces.VideoOverlay interface that want the render rectangle to be controllable using properties. This helper will parse and set the render rectangle calling VideoOverlay.setRenderRectangle.
the main Gtk struct
The gstinterfaces.VideoOverlay interface is used for 2 main purposes :
* 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 gstreamer.Pipeline 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.
Using the Window created by the video sink is probably the simplest scenario, in some cases, though, it might not be flexible enough for application developers if they need to catch events such as mouse moves and button clicks.
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 gstreamer.Message is posted on the bus to inform the application that it should set the Window identifier immediately. Here is an example on how to do that correctly: |[ static GstBusSyncReply create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline) { // ignore anything but 'prepare-window-handle' element messages if (!gst_is_video_overlay_prepare_window_handle_message (message)) return GST_BUS_PASS;
win = XCreateSimpleWindow (disp, root, 0, 0, 320, 240, 0, 0, 0);
XSetWindowBackgroundPixmap (disp, win, None);
XMapRaised (disp, win);
XSync (disp, FALSE);
gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (GST_MESSAGE_SRC (message)), win);
gst_message_unref (message);
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, NULL); ... }
GstVideoOverlay and Qt
|[ include <glib.h> include <gst/gst.h> include <gst/video/videooverlay.h>
include <QApplication> include <QTimer> include <QWidget>
int main(int argc, char *argv[]) { if (!g_thread_supported ()) g_thread_init (NULL);
gst_init (&argc, &argv); QApplication app(argc, argv); app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));
// prepare the pipeline
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);
// prepare the ui
QWidget window; window.resize(320, 240); window.show();
WId xwinid = window.winId(); gst_video_overlay_set_window_handle (GST_VIDEO_OVERLAY (sink), xwinid);
// run the pipeline
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())); }
int ret = app.exec();
window.hide(); gst_element_set_state (pipeline, GST_STATE_NULL); gst_object_unref (pipeline);
return ret; }