1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gst-plugins-base-libs-gstxoverlay.html 27 * outPack = gstinterfaces 28 * outFile = XOverlay 29 * strct = GstXOverlay 30 * realStrct= 31 * ctorStrct= 32 * clss = XOverlay 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_x_overlay_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - gtkc.glibtypes 47 * - glib.Str 48 * - gstreamer.Element 49 * structWrap: 50 * module aliases: 51 * local aliases: 52 * overrides: 53 */ 54 55 module gstinterfaces.XOverlay; 56 57 public import gstreamerc.gstinterfacestypes; 58 59 private import gstreamerc.gstinterfaces; 60 private import glib.ConstructionException; 61 private import gobject.ObjectG; 62 63 64 private import gtkc.glibtypes; 65 private import glib.Str; 66 private import gstreamer.Element; 67 68 69 70 71 /** 72 * Description 73 * The XOverlay interface is used for 2 main purposes : 74 * To get a grab on the Window where the video sink element is going to render. 75 * This is achieved by either being informed about the Window identifier that 76 * the video sink element generated, or by forcing the video sink element to use 77 * a specific Window identifier for rendering. 78 * To force a redrawing of the latest video frame the video sink element 79 * displayed on the Window. Indeed if the GstPipeline is in GST_STATE_PAUSED 80 * state, moving the Window around will damage its content. Application 81 * developers will want to handle the Expose events themselves and force the 82 * video sink element to refresh the Window's content. 83 * Using the Window created by the video sink is probably the simplest scenario, 84 * in some cases, though, it might not be flexible enough for application 85 * developers if they need to catch events such as mouse moves and button 86 * clicks. 87 * Setting a specific Window identifier on the video sink element is the most 88 * flexible solution but it has some issues. Indeed the application needs to set 89 * its Window identifier at the right time to avoid internal Window creation 90 * from the video sink element. To solve this issue a GstMessage is posted on 91 * the bus to inform the application that it should set the Window identifier 92 * immediately. Here is an example on how to do that correctly: 93 * static GstBusSyncReply 94 * create_window (GstBus * bus, GstMessage * message, GstPipeline * pipeline) 95 * { 96 * // ignore anything but 'prepare-xwindow-id' element messages 97 * if (GST_MESSAGE_TYPE (message) != GST_MESSAGE_ELEMENT) 98 * return GST_BUS_PASS; 99 * if (!gst_structure_has_name (message->structure, "prepare-xwindow-id")) 100 * return GST_BUS_PASS; 101 * win = XCreateSimpleWindow (disp, root, 0, 0, 320, 240, 0, 0, 0); 102 * XSetWindowBackgroundPixmap (disp, win, None); 103 * XMapRaised (disp, win); 104 * XSync (disp, FALSE); 105 * gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (GST_MESSAGE_SRC (message)), 106 * win); 107 * gst_message_unref (message); 108 * return GST_BUS_DROP; 109 * } 110 * ... 111 * int 112 * main (int argc, char **argv) 113 * { 114 * ... 115 * bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); 116 * gst_bus_set_sync_handler (bus, (GstBusSyncHandler) create_window, pipeline); 117 * ... 118 * } 119 */ 120 public class XOverlay 121 { 122 123 /** the main Gtk struct */ 124 protected GstXOverlay* gstXOverlay; 125 126 127 public GstXOverlay* getXOverlayStruct() 128 { 129 return gstXOverlay; 130 } 131 132 133 /** the main Gtk struct as a void* */ 134 protected void* getStruct() 135 { 136 return cast(void*)gstXOverlay; 137 } 138 139 /** 140 * Sets our main struct and passes it to the parent class 141 */ 142 public this (GstXOverlay* gstXOverlay) 143 { 144 this.gstXOverlay = gstXOverlay; 145 } 146 147 /** 148 * The Element parameter should usually be 149 * your videosink that you want to create your 150 * XOverlay with. 151 */ 152 public this(Element elem) 153 { 154 this( cast(GstXOverlay*)elem.getElementStruct() ); 155 } 156 157 /** 158 */ 159 160 /** 161 * This will call the video overlay's set_xwindow_id method. You should 162 * use this method to tell to a XOverlay to display video output to a 163 * specific XWindow. Passing 0 as the xwindow_id will tell the overlay to 164 * stop using that window and create an internal one. 165 * Params: 166 * xwindowId = a XID referencing the XWindow. 167 */ 168 public void setXwindowId(gulong xwindowId) 169 { 170 // void gst_x_overlay_set_xwindow_id (GstXOverlay *overlay, gulong xwindow_id); 171 gst_x_overlay_set_xwindow_id(gstXOverlay, xwindowId); 172 } 173 174 /** 175 * This will post a "have-xwindow-id" element message on the bus. 176 * This function should only be used by video overlay plugin developers. 177 * Params: 178 * xwindowId = a XID referencing the XWindow. 179 */ 180 public void gotXwindowId(gulong xwindowId) 181 { 182 // void gst_x_overlay_got_xwindow_id (GstXOverlay *overlay, gulong xwindow_id); 183 gst_x_overlay_got_xwindow_id(gstXOverlay, xwindowId); 184 } 185 186 /** 187 * This will post a "prepare-xwindow-id" element message on the bus 188 * to give applications an opportunity to call 189 * gst_x_overlay_set_xwindow_id() before a plugin creates its own 190 * window. 191 * This function should only be used by video overlay plugin developers. 192 */ 193 public void prepareXwindowId() 194 { 195 // void gst_x_overlay_prepare_xwindow_id (GstXOverlay *overlay); 196 gst_x_overlay_prepare_xwindow_id(gstXOverlay); 197 } 198 199 /** 200 * Tell an overlay that it has been exposed. This will redraw the current frame 201 * in the drawable even if the pipeline is PAUSED. 202 */ 203 public void expose() 204 { 205 // void gst_x_overlay_expose (GstXOverlay *overlay); 206 gst_x_overlay_expose(gstXOverlay); 207 } 208 209 /** 210 * Tell an overlay that it should handle events from the window system. These 211 * events are forwared upstream as navigation events. In some window system, 212 * events are not propagated in the window hierarchy if a client is listening 213 * for them. This method allows you to disable events handling completely 214 * from the XOverlay. 215 * Params: 216 * handleEvents = a gboolean indicating if events should be handled or not. 217 */ 218 public void handleEvents(int handleEvents) 219 { 220 // void gst_x_overlay_handle_events (GstXOverlay *overlay, gboolean handle_events); 221 gst_x_overlay_handle_events(gstXOverlay, handleEvents); 222 } 223 }