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-gstvideooverlay.html
27  * outPack = gstinterfaces
28  * outFile = VideoOverlay
29  * strct   = GstVideoOverlay
30  * realStrct=
31  * ctorStrct=
32  * clss    = VideoOverlay
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_video_overlay_
41  * 	- gst_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- gtkc.glibtypes
48  * 	- glib.Str
49  * 	- gstreamer.Element
50  * 	- gstreamer.Message
51  * structWrap:
52  * 	- GstMessage* -> Message
53  * module aliases:
54  * local aliases:
55  * overrides:
56  */
57 
58 module gstinterfaces.VideoOverlay;
59 
60 public  import gstreamerc.gstinterfacestypes;
61 
62 private import gstreamerc.gstinterfaces;
63 private import glib.ConstructionException;
64 private import gobject.ObjectG;
65 
66 private import gtkc.glibtypes;
67 private import glib.Str;
68 private import gstreamer.Element;
69 private import gstreamer.Message;
70 
71 
72 
73 /**
74  * The GstVideoOverlay interface is used for 2 main purposes :
75  *
76  * To get a grab on the Window where the video sink element is going to render.
77  * This is achieved by either being informed about the Window identifier that
78  * the video sink element generated, or by forcing the video sink element to use
79  * a specific Window identifier for rendering.
80  *
81  * To force a redrawing of the latest video frame the video sink element
82  * displayed on the Window. Indeed if the GstPipeline is in GST_STATE_PAUSED
83  * state, moving the Window around will damage its content. Application
84  * developers will want to handle the Expose events themselves and force the
85  * video sink element to refresh the Window's content.
86  *
87  * Using the Window created by the video sink is probably the simplest scenario,
88  * in some cases, though, it might not be flexible enough for application
89  * developers if they need to catch events such as mouse moves and button
90  * clicks.
91  *
92  * Setting a specific Window identifier on the video sink element is the most
93  * flexible solution but it has some issues. Indeed the application needs to set
94  * its Window identifier at the right time to avoid internal Window creation
95  * from the video sink element. To solve this issue a GstMessage is posted on
96  * the bus to inform the application that it should set the Window identifier
97  * immediately. Here is an example on how to do that correctly:
98  *
99  * $(DDOC_COMMENT example)
100  *
101  * <hr>
102  *
103  * Two basic usage scenarios
104  *
105  * There are two basic usage scenarios: in the simplest case, the application
106  * knows exactly what particular element is used for video output, which is
107  * usually the case when the application creates the videosink to use
108  * (e.g. xvimagesink, ximagesink, etc.) itself; in this case, the application
109  * can just create the videosink element, create and realize the window to
110  * render the video on and then call gst_video_overlay_set_window_handle() directly
111  * with the XID or native window handle, before starting up the pipeline.
112  *
113  * In the other and more common case, the application does not know in advance
114  * what GStreamer video sink element will be used for video output. This is
115  * usually the case when an element such as autovideosink or gconfvideosink
116  * is used. In this case, the video sink element itself is created
117  * asynchronously from a GStreamer streaming thread some time after the
118  * pipeline has been started up. When that happens, however, the video sink
119  * will need to know right then whether to render onto an already existing
120  * application window or whether to create its own window. This is when it
121  * posts a prepare-window-handle message, and that is also why this message needs
122  * to be handled in a sync bus handler which will be called from the streaming
123  * thread directly (because the video sink will need an answer right then).
124  *
125  * As response to the prepare-window-handle element message in the bus sync
126  * handler, the application may use gst_video_overlay_set_window_handle() to tell
127  * the video sink to render onto an existing window surface. At this point the
128  * application should already have obtained the window handle / XID, so it
129  * just needs to set it. It is generally not advisable to call any GUI toolkit
130  * functions or window system functions from the streaming thread in which the
131  * prepare-window-handle message is handled, because most GUI toolkits and
132  * windowing systems are not thread-safe at all and a lot of care would be
133  * required to co-ordinate the toolkit and window system calls of the
134  * different threads (Gtk+ users please note: prior to Gtk+ 2.18
135  * GDK_WINDOW_XID() was just a simple structure access, so generally fine to do
136  * within the bus sync handler; this macro was changed to a function call in
137  * Gtk+ 2.18 and later, which is likely to cause problems when called from a
138  * sync handler; see below for a better approach without GDK_WINDOW_XID()
139  * used in the callback).
140  *
141  * <hr>
142  *
143  * GstVideoOverlay and Gtk+
144  *
145  * $(DDOC_COMMENT example)
146  *
147  * <hr>
148  *
149  * GstVideoOverlay and Qt
150  *
151  * $(DDOC_COMMENT example)
152  */
153 public class VideoOverlay
154 {
155 	
156 	/** the main Gtk struct */
157 	protected GstVideoOverlay* gstVideoOverlay;
158 	
159 	
160 	/** Get the main Gtk struct */
161 	public GstVideoOverlay* getVideoOverlayStruct()
162 	{
163 		return gstVideoOverlay;
164 	}
165 	
166 	
167 	/** the main Gtk struct as a void* */
168 	protected void* getStruct()
169 	{
170 		return cast(void*)gstVideoOverlay;
171 	}
172 	
173 	/**
174 	 * Sets our main struct and passes it to the parent class
175 	 */
176 	public this (GstVideoOverlay* gstVideoOverlay)
177 	{
178 		this.gstVideoOverlay = gstVideoOverlay;
179 	}
180 	
181 	/**
182 	 * The Element parameter should usually be
183 	 * your videosink that you want to create your
184 	 * XOverlay with.
185 	 */
186 	public this(Element elem)
187 	{
188 		this( cast(GstVideoOverlay*)elem.getElementStruct() );
189 	}
190 	
191 	/**
192 	 */
193 	
194 	/**
195 	 * This will post a "have-window-handle" element message on the bus.
196 	 * This function should only be used by video overlay plugin developers.
197 	 * Params:
198 	 * handle = a platform-specific handle referencing the window
199 	 */
200 	public void gotWindowHandle(guintptr handle)
201 	{
202 		// void gst_video_overlay_got_window_handle (GstVideoOverlay *overlay,  guintptr handle);
203 		gst_video_overlay_got_window_handle(gstVideoOverlay, handle);
204 	}
205 	
206 	/**
207 	 * This will call the video overlay's set_window_handle method. You
208 	 * should use this method to tell to an overlay to display video output to a
209 	 * specific window (e.g. an XWindow on X11). Passing 0 as the handle will
210 	 * tell the overlay to stop using that window and create an internal one.
211 	 * Params:
212 	 * handle = a handle referencing the window.
213 	 */
214 	public void setWindowHandle(guintptr handle)
215 	{
216 		// void gst_video_overlay_set_window_handle (GstVideoOverlay *overlay,  guintptr handle);
217 		gst_video_overlay_set_window_handle(gstVideoOverlay, handle);
218 	}
219 	
220 	/**
221 	 * This will post a "prepare-window-handle" element message on the bus
222 	 * to give applications an opportunity to call
223 	 * gst_video_overlay_set_window_handle() before a plugin creates its own
224 	 * window.
225 	 * This function should only be used by video overlay plugin developers.
226 	 */
227 	public void prepareWindowHandle()
228 	{
229 		// void gst_video_overlay_prepare_window_handle  (GstVideoOverlay *overlay);
230 		gst_video_overlay_prepare_window_handle(gstVideoOverlay);
231 	}
232 	
233 	/**
234 	 * Tell an overlay that it has been exposed. This will redraw the current frame
235 	 * in the drawable even if the pipeline is PAUSED.
236 	 */
237 	public void expose()
238 	{
239 		// void gst_video_overlay_expose (GstVideoOverlay *overlay);
240 		gst_video_overlay_expose(gstVideoOverlay);
241 	}
242 	
243 	/**
244 	 * Tell an overlay that it should handle events from the window system. These
245 	 * events are forwarded upstream as navigation events. In some window system,
246 	 * events are not propagated in the window hierarchy if a client is listening
247 	 * for them. This method allows you to disable events handling completely
248 	 * from the GstVideoOverlay.
249 	 * Params:
250 	 * handleEvents = a gboolean indicating if events should be handled or not.
251 	 */
252 	public void handleEvents(int handleEvents)
253 	{
254 		// void gst_video_overlay_handle_events (GstVideoOverlay *overlay,  gboolean handle_events);
255 		gst_video_overlay_handle_events(gstVideoOverlay, handleEvents);
256 	}
257 	
258 	/**
259 	 * Configure a subregion as a video target within the window set by
260 	 * gst_video_overlay_set_window_handle(). If this is not used or not supported
261 	 * the video will fill the area of the window set as the overlay to 100%.
262 	 * By specifying the rectangle, the video can be overlayed to a specific region
263 	 * of that window only. After setting the new rectangle one should call
264 	 * gst_video_overlay_expose() to force a redraw. To unset the region pass -1 for
265 	 * the width and height parameters.
266 	 * This method is needed for non fullscreen video overlay in UI toolkits that
267 	 * do not support subwindows.
268 	 * Params:
269 	 * x = the horizontal offset of the render area inside the window
270 	 * y = the vertical offset of the render area inside the window
271 	 * width = the width of the render area inside the window
272 	 * height = the height of the render area inside the window
273 	 * Returns: FALSE if not supported by the sink.
274 	 */
275 	public int setRenderRectangle(int x, int y, int width, int height)
276 	{
277 		// gboolean gst_video_overlay_set_render_rectangle  (GstVideoOverlay *overlay,  gint x,  gint y,  gint width,  gint height);
278 		return gst_video_overlay_set_render_rectangle(gstVideoOverlay, x, y, width, height);
279 	}
280 	
281 	/**
282 	 * Convenience function to check if the given message is a
283 	 * "prepare-window-handle" message from a GstVideoOverlay.
284 	 * Params:
285 	 * msg = a GstMessage
286 	 * Returns: whether msg is a "prepare-window-handle" message
287 	 */
288 	public static int isVideoOverlayPrepareWindowHandleMessage(Message msg)
289 	{
290 		// gboolean gst_is_video_overlay_prepare_window_handle_message  (GstMessage *msg);
291 		return gst_is_video_overlay_prepare_window_handle_message((msg is null) ? null : msg.getMessageStruct());
292 	}
293 }