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 = gst_x_window_listener_new (NULL,
48 (MapWindowFunc) gst_v4l2_enable_overlay,
49 (SetWindowFunc) gst_v4l2_set_window,
50 (gpointer) v4l2element);
52 v4l2element->overlay = xwin;
53 v4l2element->xwindow_id = 0;
59 gst_v4l2_xoverlay_free (GstV4l2Element * v4l2element)
61 gst_v4l2_xoverlay_close (v4l2element);
62 g_object_unref (G_OBJECT (v4l2element->overlay));
63 v4l2element->overlay = NULL;
67 gst_v4l2_xoverlay_open (GstV4l2Element * v4l2element)
69 GstXWindowListener *xwin = v4l2element->overlay;
72 xwin->display_name = g_strdup (v4l2element->display);
74 if (v4l2element->xwindow_id != 0 &&
75 xwin->display_name && xwin->display_name[0] == ':') {
76 gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);
82 gst_v4l2_xoverlay_close (GstV4l2Element * v4l2element)
84 GstXWindowListener *xwin = v4l2element->overlay;
87 if (v4l2element->xwindow_id != 0 &&
88 xwin->display_name && xwin->display_name[0] == ':') {
89 gst_x_window_listener_set_xid (xwin, 0);
92 g_free (xwin->display_name);
93 xwin->display_name = NULL;
98 gst_v4l2_xoverlay_set_xwindow_id (GstXOverlay * overlay, XID xwindow_id)
100 GstV4l2Element *v4l2element = GST_V4L2ELEMENT (overlay);
101 GstXWindowListener *xwin = v4l2element->overlay;
103 if (v4l2element->xwindow_id == xwindow_id) {
107 if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
108 v4l2element->xwindow_id != 0 &&
109 xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
110 gst_x_window_listener_set_xid (xwin, 0);
113 v4l2element->xwindow_id = xwindow_id;
115 if (gst_element_get_state (GST_ELEMENT (v4l2element)) != GST_STATE_NULL &&
116 v4l2element->xwindow_id != 0 &&
117 xwin != NULL && xwin->display_name && xwin->display_name[0] == ':') {
118 gst_x_window_listener_set_xid (xwin, v4l2element->xwindow_id);