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