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  = GstBus.html
27  * outPack = gstreamer
28  * outFile = Bus
29  * strct   = GstBus
30  * realStrct=
31  * ctorStrct=
32  * clss    = Bus
33  * interf  = 
34  * class Code: Yes
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_bus_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * 	- gst_bus_add_watch
45  * 	- gst_bus_set_sync_handler
46  * omit signals:
47  * imports:
48  * 	- glib.Str
49  * 	- glib.Source
50  * 	- gstreamer.Message
51  * structWrap:
52  * 	- GSource* -> Source
53  * 	- GstBus* -> Bus
54  * 	- GstMessage* -> Message
55  * module aliases:
56  * local aliases:
57  * overrides:
58  */
59 
60 module gstreamer.Bus;
61 
62 public  import gstreamerc.gstreamertypes;
63 
64 private import gstreamerc.gstreamer;
65 private import glib.ConstructionException;
66 private import gobject.ObjectG;
67 
68 private import gobject.Signals;
69 public  import gtkc.gdktypes;
70 private import glib.Str;
71 private import glib.Source;
72 private import gstreamer.Message;
73 
74 
75 private import gstreamer.ObjectGst;
76 
77 /**
78  * The GstBus is an object responsible for delivering GstMessage packets in
79  * a first-in first-out way from the streaming threads (see GstTask) to the
80  * application.
81  *
82  * Since the application typically only wants to deal with delivery of these
83  * messages from one thread, the GstBus will marshall the messages between
84  * different threads. This is important since the actual streaming of media
85  * is done in another thread than the application.
86  *
87  * The GstBus provides support for GSource based notifications. This makes it
88  * possible to handle the delivery in the glib mainloop.
89  *
90  * The GSource callback function gst_bus_async_signal_func() can be used to
91  * convert all bus messages into signal emissions.
92  *
93  * A message is posted on the bus with the gst_bus_post() method. With the
94  * gst_bus_peek() and gst_bus_pop() methods one can look at or retrieve a
95  * previously posted message.
96  *
97  * The bus can be polled with the gst_bus_poll() method. This methods blocks
98  * up to the specified timeout value until one of the specified messages types
99  * is posted on the bus. The application can then gst_bus_pop() the messages
100  * from the bus to handle them.
101  * Alternatively the application can register an asynchronous bus function
102  * using gst_bus_add_watch_full() or gst_bus_add_watch(). This function will
103  * install a GSource in the default glib main loop and will deliver messages
104  * a short while after they have been posted. Note that the main loop should
105  * be running for the asynchronous callbacks.
106  *
107  * It is also possible to get messages from the bus without any thread
108  * marshalling with the gst_bus_set_sync_handler() method. This makes it
109  * possible to react to a message in the same thread that posted the
110  * message on the bus. This should only be used if the application is able
111  * to deal with messages from different threads.
112  *
113  * Every GstPipeline has one bus.
114  *
115  * Note that a GstPipeline will set its bus into flushing state when changing
116  * from READY to NULL state.
117  *
118  * Last reviewed on 2012-03-28 (0.11.3)
119  */
120 public class Bus : ObjectGst
121 {
122 	
123 	/** the main Gtk struct */
124 	protected GstBus* gstBus;
125 	
126 	
127 	/** Get the main Gtk struct */
128 	public GstBus* getBusStruct()
129 	{
130 		return gstBus;
131 	}
132 	
133 	
134 	/** the main Gtk struct as a void* */
135 	protected override void* getStruct()
136 	{
137 		return cast(void*)gstBus;
138 	}
139 	
140 	/**
141 	 * Sets our main struct and passes it to the parent class
142 	 */
143 	public this (GstBus* gstBus)
144 	{
145 		super(cast(GstObject*)gstBus);
146 		this.gstBus = gstBus;
147 	}
148 	
149 	protected override void setStruct(GObject* obj)
150 	{
151 		super.setStruct(obj);
152 		gstBus = cast(GstBus*)obj;
153 	}
154 	
155 	/**
156 	 * Adds a bus watch to the default main context with the default priority.
157 	 * This function is used to receive asynchronous messages in the main loop.
158 	 * The watch can be removed using g_source_remove() or by returning FALSE
159 	 * from func.
160 	 * MT safe.
161 	 * Params:
162 	 *  dlg = A function to call when a message is received.
163 	 * Returns:
164 	 *  The event source id.
165 	 */
166 	public uint addWatch( bool delegate(Message) dlg )
167 	{
168 		onWatchListener = dlg;
169 		return gst_bus_add_watch(gstBus, cast(GstBusFunc)&watchCallBack, cast(void*)this);
170 	}
171 	
172 	bool delegate(Message) onWatchListener;
173 	
174 	extern(C) static gboolean watchCallBack(GstBus* bus, GstMessage* msg, Bus bus_d )//gpointer data)
175 	{
176 		Message msg_d = new Message( msg );
177 		
178 		return bus_d.onWatchListener( msg_d );
179 	}
180 	
181 	/**
182 	 * Use this for making an XOverlay.
183 	 * Sets the synchronous handler on the bus. The function will be called
184 	 * every time a new message is posted on the bus. Note that the function
185 	 * will be called in the same thread context as the posting object. This
186 	 * function is usually only called by the creator of the bus. Applications
187 	 * should handle messages asynchronously using the gst_bus watch and poll
188 	 * functions.
189 	 * You cannot replace an existing sync_handler. You can pass NULL to this
190 	 * function, which will clear the existing handler.
191 	 * Params:
192 	 *  dlg = The handler function to install
193 	 */
194 	public void setSyncHandler( GstBusSyncReply delegate(Message) dlg )
195 	{
196 		onSyncHandlerListener = dlg;
197 		gst_bus_set_sync_handler(gstBus, cast(GstBusSyncHandler)&syncHandlerCallBack, cast(void*)this, null);
198 	}
199 	
200 	GstBusSyncReply delegate(Message) onSyncHandlerListener;
201 	
202 	extern(C) static GstBusSyncReply syncHandlerCallBack(GstBus* bus, GstMessage* msg, Bus bus_d)
203 	{
204 		Message msg_d = new Message( msg );
205 		
206 		return bus_d.onSyncHandlerListener( msg_d );
207 	}
208 	
209 	/**
210 	 */
211 	int[string] connectedSignals;
212 	
213 	void delegate(Message, Bus)[] onMessageListeners;
214 	/**
215 	 * A message has been posted on the bus. This signal is emitted from a
216 	 * GSource added to the mainloop. this signal will only be emitted when
217 	 * there is a mainloop running.
218 	 */
219 	void addOnMessage(void delegate(Message, Bus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
220 	{
221 		if ( !("message" in connectedSignals) )
222 		{
223 			Signals.connectData(
224 			getStruct(),
225 			"message",
226 			cast(GCallback)&callBackMessage,
227 			cast(void*)this,
228 			null,
229 			connectFlags);
230 			connectedSignals["message"] = 1;
231 		}
232 		onMessageListeners ~= dlg;
233 	}
234 	extern(C) static void callBackMessage(GstBus* busStruct, GstMessage* message, Bus _bus)
235 	{
236 		foreach ( void delegate(Message, Bus) dlg ; _bus.onMessageListeners )
237 		{
238 			dlg(ObjectG.getDObject!(Message)(message), _bus);
239 		}
240 	}
241 	
242 	void delegate(Message, Bus)[] onSyncMessageListeners;
243 	/**
244 	 * A message has been posted on the bus. This signal is emitted from the
245 	 * thread that posted the message so one has to be careful with locking.
246 	 * This signal will not be emitted by default, you have to call
247 	 * gst_bus_enable_sync_message_emission() before.
248 	 * See Also
249 	 * GstMessage, GstElement
250 	 */
251 	void addOnSyncMessage(void delegate(Message, Bus) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
252 	{
253 		if ( !("sync-message" in connectedSignals) )
254 		{
255 			Signals.connectData(
256 			getStruct(),
257 			"sync-message",
258 			cast(GCallback)&callBackSyncMessage,
259 			cast(void*)this,
260 			null,
261 			connectFlags);
262 			connectedSignals["sync-message"] = 1;
263 		}
264 		onSyncMessageListeners ~= dlg;
265 	}
266 	extern(C) static void callBackSyncMessage(GstBus* busStruct, GstMessage* message, Bus _bus)
267 	{
268 		foreach ( void delegate(Message, Bus) dlg ; _bus.onSyncMessageListeners )
269 		{
270 			dlg(ObjectG.getDObject!(Message)(message), _bus);
271 		}
272 	}
273 	
274 	
275 	/**
276 	 * Creates a new GstBus instance.
277 	 * Throws: ConstructionException GTK+ fails to create the object.
278 	 */
279 	public this ()
280 	{
281 		// GstBus * gst_bus_new (void);
282 		auto p = gst_bus_new();
283 		if(p is null)
284 		{
285 			throw new ConstructionException("null returned by gst_bus_new()");
286 		}
287 		this(cast(GstBus*) p);
288 	}
289 	
290 	/**
291 	 * Post a message on the given bus. Ownership of the message
292 	 * is taken by the bus.
293 	 * Params:
294 	 * message = the GstMessage to post. [transfer full]
295 	 * Returns: TRUE if the message could be posted, FALSE if the bus is flushing. MT safe.
296 	 */
297 	public int post(Message message)
298 	{
299 		// gboolean gst_bus_post (GstBus *bus,  GstMessage *message);
300 		return gst_bus_post(gstBus, (message is null) ? null : message.getMessageStruct());
301 	}
302 	
303 	/**
304 	 * Check if there are pending messages on the bus that
305 	 * should be handled.
306 	 * Returns: TRUE if there are messages on the bus to be handled, FALSE otherwise. MT safe.
307 	 */
308 	public int havePending()
309 	{
310 		// gboolean gst_bus_have_pending (GstBus *bus);
311 		return gst_bus_have_pending(gstBus);
312 	}
313 	
314 	/**
315 	 * Peek the message on the top of the bus' queue. The message will remain
316 	 * on the bus' message queue. A reference is returned, and needs to be unreffed
317 	 * by the caller.
318 	 * Returns: the GstMessage that is on the bus, or NULL if the bus is empty. MT safe. [transfer full]
319 	 */
320 	public Message peek()
321 	{
322 		// GstMessage * gst_bus_peek (GstBus *bus);
323 		auto p = gst_bus_peek(gstBus);
324 		
325 		if(p is null)
326 		{
327 			return null;
328 		}
329 		
330 		return ObjectG.getDObject!(Message)(cast(GstMessage*) p);
331 	}
332 	
333 	/**
334 	 * Get a message from the bus.
335 	 * Returns: the GstMessage that is on the bus, or NULL if the bus is empty. The message is taken from the bus and needs to be unreffed with gst_message_unref() after usage. MT safe. [transfer full]
336 	 */
337 	public Message pop()
338 	{
339 		// GstMessage * gst_bus_pop (GstBus *bus);
340 		auto p = gst_bus_pop(gstBus);
341 		
342 		if(p is null)
343 		{
344 			return null;
345 		}
346 		
347 		return ObjectG.getDObject!(Message)(cast(GstMessage*) p);
348 	}
349 	
350 	/**
351 	 * Get a message matching type from the bus. Will discard all messages on
352 	 * the bus that do not match type and that have been posted before the first
353 	 * message that does match type. If there is no message matching type on
354 	 * the bus, all messages will be discarded.
355 	 * Params:
356 	 * types = message types to take into account
357 	 * Returns: the next GstMessage matching type that is on the bus, or NULL if the bus is empty or there is no message matching type. The message is taken from the bus and needs to be unreffed with gst_message_unref() after usage. MT safe. [transfer full]
358 	 */
359 	public Message popFiltered(GstMessageType types)
360 	{
361 		// GstMessage * gst_bus_pop_filtered (GstBus *bus,  GstMessageType types);
362 		auto p = gst_bus_pop_filtered(gstBus, types);
363 		
364 		if(p is null)
365 		{
366 			return null;
367 		}
368 		
369 		return ObjectG.getDObject!(Message)(cast(GstMessage*) p);
370 	}
371 	
372 	/**
373 	 * Get a message from the bus, waiting up to the specified timeout.
374 	 * If timeout is 0, this function behaves like gst_bus_pop(). If timeout is
375 	 * GST_CLOCK_TIME_NONE, this function will block forever until a message was
376 	 * posted on the bus.
377 	 * Params:
378 	 * timeout = a timeout
379 	 * Returns: the GstMessage that is on the bus after the specified timeout or NULL if the bus is empty after the timeout expired. The message is taken from the bus and needs to be unreffed with gst_message_unref() after usage. MT safe. [transfer full]
380 	 */
381 	public Message timedPop(GstClockTime timeout)
382 	{
383 		// GstMessage * gst_bus_timed_pop (GstBus *bus,  GstClockTime timeout);
384 		auto p = gst_bus_timed_pop(gstBus, timeout);
385 		
386 		if(p is null)
387 		{
388 			return null;
389 		}
390 		
391 		return ObjectG.getDObject!(Message)(cast(GstMessage*) p);
392 	}
393 	
394 	/**
395 	 * Get a message from the bus whose type matches the message type mask types,
396 	 * waiting up to the specified timeout (and discarding any messages that do not
397 	 * match the mask provided).
398 	 * If timeout is 0, this function behaves like gst_bus_pop_filtered(). If
399 	 * timeout is GST_CLOCK_TIME_NONE, this function will block forever until a
400 	 * matching message was posted on the bus.
401 	 * Params:
402 	 * timeout = a timeout in nanoseconds, or GST_CLOCK_TIME_NONE to wait forever
403 	 * types = message types to take into account, GST_MESSAGE_ANY for any type
404 	 * Returns: a GstMessage matching the filter in types, or NULL if no matching message was found on the bus until the timeout expired. The message is taken from the bus and needs to be unreffed with gst_message_unref() after usage. MT safe. [transfer full]
405 	 */
406 	public Message timedPopFiltered(GstClockTime timeout, GstMessageType types)
407 	{
408 		// GstMessage * gst_bus_timed_pop_filtered (GstBus *bus,  GstClockTime timeout,  GstMessageType types);
409 		auto p = gst_bus_timed_pop_filtered(gstBus, timeout, types);
410 		
411 		if(p is null)
412 		{
413 			return null;
414 		}
415 		
416 		return ObjectG.getDObject!(Message)(cast(GstMessage*) p);
417 	}
418 	
419 	/**
420 	 * If flushing, flush out and unref any messages queued in the bus. Releases
421 	 * references to the message origin objects. Will flush future messages until
422 	 * gst_bus_set_flushing() sets flushing to FALSE.
423 	 * MT safe.
424 	 * Params:
425 	 * flushing = whether or not to flush the bus
426 	 */
427 	public void setFlushing(int flushing)
428 	{
429 		// void gst_bus_set_flushing (GstBus *bus,  gboolean flushing);
430 		gst_bus_set_flushing(gstBus, flushing);
431 	}
432 	
433 	/**
434 	 * A helper GstBusSyncHandler that can be used to convert all synchronous
435 	 * messages into signals.
436 	 * Params:
437 	 * message = the GstMessage received
438 	 * data = user data
439 	 * Returns: GST_BUS_PASS
440 	 */
441 	public GstBusSyncReply syncSignalHandler(Message message, void* data)
442 	{
443 		// GstBusSyncReply gst_bus_sync_signal_handler (GstBus *bus,  GstMessage *message,  gpointer data);
444 		return gst_bus_sync_signal_handler(gstBus, (message is null) ? null : message.getMessageStruct(), data);
445 	}
446 	
447 	/**
448 	 * Create watch for this bus. The GSource will be dispatched whenever
449 	 * a message is on the bus. After the GSource is dispatched, the
450 	 * message is popped off the bus and unreffed.
451 	 * Returns: a GSource that can be added to a mainloop. [transfer full]
452 	 */
453 	public Source createWatch()
454 	{
455 		// GSource * gst_bus_create_watch (GstBus *bus);
456 		auto p = gst_bus_create_watch(gstBus);
457 		
458 		if(p is null)
459 		{
460 			return null;
461 		}
462 		
463 		return ObjectG.getDObject!(Source)(cast(GSource*) p);
464 	}
465 	
466 	/**
467 	 * Adds a bus watch to the default main context with the given priority (e.g.
468 	 * G_PRIORITY_DEFAULT). It is also possible to use a non-default main
469 	 * context set up using g_main_context_push_thread_default() (before
470 	 * one had to create a bus watch source and attach it to the desired main
471 	 * context 'manually').
472 	 * This function is used to receive asynchronous messages in the main loop.
473 	 * There can only be a single bus watch per bus, you must remove it before you
474 	 * can set a new one.
475 	 * When func is called, the message belongs to the caller; if you want to
476 	 * keep a copy of it, call gst_message_ref() before leaving func.
477 	 * The watch can be removed using g_source_remove() or by returning FALSE
478 	 * from func.
479 	 * MT safe.
480 	 * Params:
481 	 * priority = The priority of the watch.
482 	 * func = A function to call when a message is received.
483 	 * userData = user data passed to func.
484 	 * notify = the function to call when the source is removed.
485 	 * Returns: The event source id. Rename to: gst_bus_add_watch
486 	 */
487 	public uint addWatchFull(int priority, GstBusFunc func, void* userData, GDestroyNotify notify)
488 	{
489 		// guint gst_bus_add_watch_full (GstBus *bus,  gint priority,  GstBusFunc func,  gpointer user_data,  GDestroyNotify notify);
490 		return gst_bus_add_watch_full(gstBus, priority, func, userData, notify);
491 	}
492 	
493 	/**
494 	 * Instructs GStreamer to stop emitting the "sync-message" signal for this bus.
495 	 * See gst_bus_enable_sync_message_emission() for more information.
496 	 * In the event that multiple pieces of code have called
497 	 * gst_bus_enable_sync_message_emission(), the sync-message emissions will only
498 	 * be stopped after all calls to gst_bus_enable_sync_message_emission() were
499 	 * "cancelled" by calling this function. In this way the semantics are exactly
500 	 * the same as gst_object_ref() that which calls enable should also call
501 	 * disable.
502 	 * MT safe.
503 	 */
504 	public void disableSyncMessageEmission()
505 	{
506 		// void gst_bus_disable_sync_message_emission  (GstBus *bus);
507 		gst_bus_disable_sync_message_emission(gstBus);
508 	}
509 	
510 	/**
511 	 * Instructs GStreamer to emit the "sync-message" signal after running the bus's
512 	 * sync handler. This function is here so that code can ensure that they can
513 	 * synchronously receive messages without having to affect what the bin's sync
514 	 * handler is.
515 	 * This function may be called multiple times. To clean up, the caller is
516 	 * responsible for calling gst_bus_disable_sync_message_emission() as many times
517 	 * as this function is called.
518 	 * While this function looks similar to gst_bus_add_signal_watch(), it is not
519 	 * exactly the same -- this function enables synchronous emission of
520 	 * signals when messages arrive; gst_bus_add_signal_watch() adds an idle callback
521 	 * to pop messages off the bus asynchronously. The sync-message signal
522 	 * comes from the thread of whatever object posted the message; the "message"
523 	 * signal is marshalled to the main thread via the main loop.
524 	 * MT safe.
525 	 */
526 	public void enableSyncMessageEmission()
527 	{
528 		// void gst_bus_enable_sync_message_emission  (GstBus *bus);
529 		gst_bus_enable_sync_message_emission(gstBus);
530 	}
531 	
532 	/**
533 	 * A helper GstBusFunc that can be used to convert all asynchronous messages
534 	 * into signals.
535 	 * Params:
536 	 * message = the GstMessage received
537 	 * data = user data
538 	 * Returns: TRUE
539 	 */
540 	public int asyncSignalFunc(Message message, void* data)
541 	{
542 		// gboolean gst_bus_async_signal_func (GstBus *bus,  GstMessage *message,  gpointer data);
543 		return gst_bus_async_signal_func(gstBus, (message is null) ? null : message.getMessageStruct(), data);
544 	}
545 	
546 	/**
547 	 * Adds a bus signal watch to the default main context with the default priority
548 	 * (G_PRIORITY_DEFAULT). It is also possible to use a non-default
549 	 * main context set up using g_main_context_push_thread_default() (before
550 	 * one had to create a bus watch source and attach it to the desired main
551 	 * context 'manually').
552 	 * After calling this statement, the bus will emit the "message" signal for each
553 	 * message posted on the bus.
554 	 * This function may be called multiple times. To clean up, the caller is
555 	 * responsible for calling gst_bus_remove_signal_watch() as many times as this
556 	 * function is called.
557 	 * MT safe.
558 	 */
559 	public void addSignalWatch()
560 	{
561 		// void gst_bus_add_signal_watch (GstBus *bus);
562 		gst_bus_add_signal_watch(gstBus);
563 	}
564 	
565 	/**
566 	 * Adds a bus signal watch to the default main context with the given priority
567 	 * (e.g. G_PRIORITY_DEFAULT). It is also possible to use a non-default main
568 	 * context set up using g_main_context_push_thread_default()
569 	 * (before one had to create a bus watch source and attach it to the desired
570 	 * main context 'manually').
571 	 * After calling this statement, the bus will emit the "message" signal for each
572 	 * message posted on the bus when the main loop is running.
573 	 * This function may be called multiple times. To clean up, the caller is
574 	 * responsible for calling gst_bus_remove_signal_watch() as many times as this
575 	 * function is called.
576 	 * There can only be a single bus watch per bus, you must remove any signal
577 	 * watch before you can set another type of watch.
578 	 * MT safe.
579 	 * Params:
580 	 * priority = The priority of the watch.
581 	 */
582 	public void addSignalWatchFull(int priority)
583 	{
584 		// void gst_bus_add_signal_watch_full (GstBus *bus,  gint priority);
585 		gst_bus_add_signal_watch_full(gstBus, priority);
586 	}
587 	
588 	/**
589 	 * Removes a signal watch previously added with gst_bus_add_signal_watch().
590 	 * MT safe.
591 	 */
592 	public void removeSignalWatch()
593 	{
594 		// void gst_bus_remove_signal_watch (GstBus *bus);
595 		gst_bus_remove_signal_watch(gstBus);
596 	}
597 	
598 	/**
599 	 * Poll the bus for messages. Will block while waiting for messages to come.
600 	 * You can specify a maximum time to poll with the timeout parameter. If
601 	 * timeout is negative, this function will block indefinitely.
602 	 * All messages not in events will be popped off the bus and will be ignored.
603 	 * Because poll is implemented using the "message" signal enabled by
604 	 * gst_bus_add_signal_watch(), calling gst_bus_poll() will cause the "message"
605 	 * signal to be emitted for every message that poll sees. Thus a "message"
606 	 * signal handler will see the same messages that this function sees -- neither
607 	 * will steal messages from the other.
608 	 * This function will run a main loop from the default main context when
609 	 * polling.
610 	 * You should never use this function, since it is pure evil. This is
611 	 * especially true for GUI applications based on Gtk+ or Qt, but also for any
612 	 * other non-trivial application that uses the GLib main loop. As this function
613 	 * runs a GLib main loop, any callback attached to the default GLib main
614 	 * context may be invoked. This could be timeouts, GUI events, I/O events etc.;
615 	 * even if gst_bus_poll() is called with a 0 timeout. Any of these callbacks
616 	 * may do things you do not expect, e.g. destroy the main application window or
617 	 * some other resource; change other application state; display a dialog and
618 	 * run another main loop until the user clicks it away. In short, using this
619 	 * function may add a lot of complexity to your code through unexpected
620 	 * re-entrancy and unexpected changes to your application's state.
621 	 * For 0 timeouts use gst_bus_pop_filtered() instead of this function; for
622 	 * other short timeouts use gst_bus_timed_pop_filtered(); everything else is
623 	 * better handled by setting up an asynchronous bus watch and doing things
624 	 * from there.
625 	 * Params:
626 	 * events = a mask of GstMessageType, representing the set of message types to
627 	 * poll for.
628 	 * timeout = the poll timeout, as a GstClockTime, or GST_CLOCK_TIME_NONE to poll
629 	 * indefinitely.
630 	 * Returns: the message that was received, or NULL if the poll timed out. The message is taken from the bus and needs to be unreffed with gst_message_unref() after usage. [transfer full]
631 	 */
632 	public Message poll(GstMessageType events, GstClockTime timeout)
633 	{
634 		// GstMessage * gst_bus_poll (GstBus *bus,  GstMessageType events,  GstClockTime timeout);
635 		auto p = gst_bus_poll(gstBus, events, timeout);
636 		
637 		if(p is null)
638 		{
639 			return null;
640 		}
641 		
642 		return ObjectG.getDObject!(Message)(cast(GstMessage*) p);
643 	}
644 }