1 /* GStreamer X-based overlay interface implementation
2 * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
4 * gstv4l2xoverlay.c: X-based overlay interface implementation for V4L2
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
27 #include <gst/xoverlay/xoverlay.h>
28 #include <gst/xwindowlistener/xwindowlistener.h>
30 #include "gstv4l2xoverlay.h"
31 #include "gstv4l2element.h"
32 #include "v4l2_calls.h"
34 static void gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
38 gst_v4l2_xoverlay_interface_init (GstXOverlayClass *klass)
40 /* default virtual functions */
41 klass->set_xwindow_id = gst_v4l2_xoverlay_set_xwindow_id;
45 gst_v4l2_xoverlay_new (GstV4l2Element *v4l2element)
47 GstXWindowListener *xwin =
48 gst_x_window_listener_new (NULL,
49 (MapWindowFunc) gst_v4l2_enable_overlay,
50 (SetWindowFunc) gst_v4l2_set_window,
51 (gpointer) v4l2element);
53 v4l2element->overlay = xwin;
54 v4l2element->xwindow_id = 0;
60 gst_v4l2_xoverlay_free (GstV4l2Element *v4l2element)
62 gst_v4l2_xoverlay_close (v4l2element);
63 g_object_unref (G_OBJECT (v4l2element->overlay));
64 v4l2element->overlay = NULL;
68 gst_v4l2_xoverlay_open (GstV4l2Element *v4l2element)
70 GstXWindowListener *xwin = v4l2element->overlay;
73 xwin->display_name = g_strdup (v4l2element->display);
75 if (v4l2element->xwindow_id != 0 &&
77 xwin->display_name[0] == ':') {
78 gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
84 gst_v4l2_xoverlay_close (GstV4l2Element *v4l2element)
86 GstXWindowListener *xwin = v4l2element->overlay;
89 if (v4l2element->xwindow_id != 0 &&
91 xwin->display_name[0] == ':') {
92 gst_x_window_listener_set_xid (xwin, 0);
95 g_free (xwin->display_name);
96 xwin->display_name = NULL;
101 gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay *overlay,
104 GstV4l2Element *v4l2element = GST_V4L2ELEMENT (overlay);
105 GstXWindowListener *xwin = v4l2element->overlay;
107 if (v4l2element->xwindow_id == xwindow_id) {
111 if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
112 v4l2element->xwindow_id != 0 &&
114 xwin->display_name &&
115 xwin->display_name[0] == ':') {
116 gst_x_window_listener_set_xid (xwin, 0);
119 v4l2element->xwindow_id = xwindow_id;
121 if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
122 v4l2element->xwindow_id != 0 &&
124 xwin->display_name &&
125 xwin->display_name[0] == ':') {
126 gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);