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 module gstreamer.Event;
26 
27 private import glib.ConstructionException;
28 private import glib.Str;
29 private import gobject.ObjectG;
30 private import gstreamer.Caps;
31 private import gstreamer.Message;
32 private import gstreamer.Segment;
33 private import gstreamer.Structure;
34 private import gstreamer.TagList;
35 private import gstreamer.Toc;
36 private import gstreamerc.gstreamer;
37 public  import gstreamerc.gstreamertypes;
38 
39 
40 /**
41  * The event class provides factory methods to construct events for sending
42  * and functions to query (parse) received events.
43  * 
44  * Events are usually created with gst_event_new_*() which takes event-type
45  * specific parameters as arguments.
46  * To send an event application will usually use gst_element_send_event() and
47  * elements will use gst_pad_send_event() or gst_pad_push_event().
48  * The event should be unreffed with gst_event_unref() if it has not been sent.
49  * 
50  * Events that have been received can be parsed with their respective
51  * gst_event_parse_*() functions. It is valid to pass %NULL for unwanted details.
52  * 
53  * Events are passed between elements in parallel to the data stream. Some events
54  * are serialized with buffers, others are not. Some events only travel downstream,
55  * others only upstream. Some events can travel both upstream and downstream.
56  * 
57  * The events are used to signal special conditions in the datastream such as
58  * EOS (end of stream) or the start of a new stream-segment.
59  * Events are also used to flush the pipeline of any pending data.
60  * 
61  * Most of the event API is used inside plugins. Applications usually only
62  * construct and use seek events.
63  * To do that gst_event_new_seek() is used to create a seek event. It takes
64  * the needed parameters to specify seeking time and mode.
65  * |[
66  * GstEvent *event;
67  * gboolean result;
68  * ...
69  * // construct a seek event to play the media from second 2 to 5, flush
70  * // the pipeline to decrease latency.
71  * event = gst_event_new_seek (1.0,
72  * GST_FORMAT_TIME,
73  * GST_SEEK_FLAG_FLUSH,
74  * GST_SEEK_TYPE_SET, 2 * GST_SECOND,
75  * GST_SEEK_TYPE_SET, 5 * GST_SECOND);
76  * ...
77  * result = gst_element_send_event (pipeline, event);
78  * if (!result)
79  * g_warning ("seek failed");
80  * ...
81  * ]|
82  */
83 public class Event
84 {
85 	/** the main Gtk struct */
86 	protected GstEvent* gstEvent;
87 
88 	/** Get the main Gtk struct */
89 	public GstEvent* getEventStruct()
90 	{
91 		return gstEvent;
92 	}
93 
94 	/** the main Gtk struct as a void* */
95 	protected void* getStruct()
96 	{
97 		return cast(void*)gstEvent;
98 	}
99 
100 	/**
101 	 * Sets our main struct and passes it to the parent class.
102 	 */
103 	public this (GstEvent* gstEvent)
104 	{
105 		this.gstEvent = gstEvent;
106 	}
107 
108 	/**
109 	 * Create a new EOS event. The eos event can only travel downstream
110 	 * synchronized with the buffer flow. Elements that receive the EOS
111 	 * event on a pad can return UNEXPECTED as a GstFlowReturn when data
112 	 * after the EOS event arrives.
113 	 * The EOS event will travel down to the sink elements in the pipeline
114 	 * which will then post the GST_MESSAGE_EOS on the bus after they have
115 	 * finished playing any buffered data.
116 	 * When all sinks have posted an EOS message, the EOS message is
117 	 * forwarded to the application.
118 	 * Returns:
119 	 *  The new EOS event.
120 	 */
121 	public static Event newEOS()
122 	{
123 		// GstEvent* gst_event_new_eos (void);
124 		auto p = gst_event_new_eos();
125 		
126 		if(p is null)
127 		{
128 			throw new ConstructionException("null returned by gst_event_new_eos");
129 		}
130 		
131 		return new Event(cast(GstEvent*)p );
132 	}
133 	
134 	/**
135 	 * Allocate a new flush start event. The flush start event can be send
136 	 * upstream and downstream and travels out-of-bounds with the dataflow.
137 	 * It marks pads as being in a WRONG_STATE to process more data.
138 	 * Elements unlock and blocking functions and exit their streaming functions
139 	 * as fast as possible.
140 	 * This event is typically generated after a seek to minimize the latency
141 	 * after the seek.
142 	 * Returns:
143 	 *  A new flush start event.
144 	 */
145 	public static Event newFlushStart()
146 	{
147 		// GstEvent* gst_event_new_flush_start (void);
148 		auto p = gst_event_new_flush_start();
149 		
150 		if(p is null)
151 		{
152 			throw new ConstructionException("null returned by gst_event_new_flush_start");
153 		}
154 		
155 		return new Event(cast(GstEvent*)p );
156 	}
157 	
158 	/**
159 	 * Generate a TOC select event with the given uid. The purpose of the
160 	 * TOC select event is to start playback based on the TOC's entry with
161 	 * the given uid.
162 	 */
163 	public static Event newTocSelect(string uid)
164 	{
165 		// GstEvent* gst_event_new_toc_select (const gchar *uid);
166 		auto p = gst_event_new_toc_select(cast(char*)uid.ptr);
167 		
168 		if(p is null)
169 		{
170 			throw new ConstructionException("null returned by gst_event_new_toc_select");
171 		}
172 		
173 		return new Event(cast(GstEvent*)p );
174 	}
175 
176 	/**
177 	 */
178 
179 	public static GType getType()
180 	{
181 		return gst_event_get_type();
182 	}
183 
184 	/**
185 	 * Create a new buffersize event. The event is sent downstream and notifies
186 	 * elements that they should provide a buffer of the specified dimensions.
187 	 *
188 	 * When the @async flag is set, a thread boundary is preferred.
189 	 *
190 	 * Params:
191 	 *     format = buffer format
192 	 *     minsize = minimum buffer size
193 	 *     maxsize = maximum buffer size
194 	 *     async = thread behavior
195 	 *
196 	 * Return: a new #GstEvent
197 	 *
198 	 * Throws: ConstructionException GTK+ fails to create the object.
199 	 */
200 	public this(GstFormat format, long minsize, long maxsize, bool async)
201 	{
202 		auto p = gst_event_new_buffer_size(format, minsize, maxsize, async);
203 		
204 		if(p is null)
205 		{
206 			throw new ConstructionException("null returned by new_buffer_size");
207 		}
208 		
209 		this(cast(GstEvent*) p);
210 	}
211 
212 	/**
213 	 * Create a new CAPS event for @caps. The caps event can only travel downstream
214 	 * synchronized with the buffer flow and contains the format of the buffers
215 	 * that will follow after the event.
216 	 *
217 	 * Params:
218 	 *     caps = a #GstCaps
219 	 *
220 	 * Return: the new CAPS event.
221 	 *
222 	 * Throws: ConstructionException GTK+ fails to create the object.
223 	 */
224 	public this(Caps caps)
225 	{
226 		auto p = gst_event_new_caps((caps is null) ? null : caps.getCapsStruct());
227 		
228 		if(p is null)
229 		{
230 			throw new ConstructionException("null returned by new_caps");
231 		}
232 		
233 		this(cast(GstEvent*) p);
234 	}
235 
236 	/**
237 	 * Create a new custom-typed event. This can be used for anything not
238 	 * handled by other event-specific functions to pass an event to another
239 	 * element.
240 	 *
241 	 * Make sure to allocate an event type with the #GST_EVENT_MAKE_TYPE macro,
242 	 * assigning a free number and filling in the correct direction and
243 	 * serialization flags.
244 	 *
245 	 * New custom events can also be created by subclassing the event type if
246 	 * needed.
247 	 *
248 	 * Params:
249 	 *     type = The type of the new event
250 	 *     structure = the structure for the event. The event will
251 	 *         take ownership of the structure.
252 	 *
253 	 * Return: the new custom event.
254 	 *
255 	 * Throws: ConstructionException GTK+ fails to create the object.
256 	 */
257 	public this(GstEventType type, Structure structure)
258 	{
259 		auto p = gst_event_new_custom(type, (structure is null) ? null : structure.getStructureStruct());
260 		
261 		if(p is null)
262 		{
263 			throw new ConstructionException("null returned by new_custom");
264 		}
265 		
266 		this(cast(GstEvent*) p);
267 	}
268 
269 	/**
270 	 * Allocate a new flush stop event. The flush stop event can be sent
271 	 * upstream and downstream and travels serialized with the dataflow.
272 	 * It is typically sent after sending a FLUSH_START event to make the
273 	 * pads accept data again.
274 	 *
275 	 * Elements can process this event synchronized with the dataflow since
276 	 * the preceding FLUSH_START event stopped the dataflow.
277 	 *
278 	 * This event is typically generated to complete a seek and to resume
279 	 * dataflow.
280 	 *
281 	 * Params:
282 	 *     resetTime = if time should be reset
283 	 *
284 	 * Return: a new flush stop event.
285 	 *
286 	 * Throws: ConstructionException GTK+ fails to create the object.
287 	 */
288 	public this(bool resetTime)
289 	{
290 		auto p = gst_event_new_flush_stop(resetTime);
291 		
292 		if(p is null)
293 		{
294 			throw new ConstructionException("null returned by new_flush_stop");
295 		}
296 		
297 		this(cast(GstEvent*) p);
298 	}
299 
300 	/**
301 	 * Create a new GAP event. A gap event can be thought of as conceptually
302 	 * equivalent to a buffer to signal that there is no data for a certain
303 	 * amount of time. This is useful to signal a gap to downstream elements
304 	 * which may wait for data, such as muxers or mixers or overlays, especially
305 	 * for sparse streams such as subtitle streams.
306 	 *
307 	 * Params:
308 	 *     timestamp = the start time (pts) of the gap
309 	 *     duration = the duration of the gap
310 	 *
311 	 * Return: the new GAP event.
312 	 *
313 	 * Throws: ConstructionException GTK+ fails to create the object.
314 	 */
315 	public this(GstClockTime timestamp, GstClockTime duration)
316 	{
317 		auto p = gst_event_new_gap(timestamp, duration);
318 		
319 		if(p is null)
320 		{
321 			throw new ConstructionException("null returned by new_gap");
322 		}
323 		
324 		this(cast(GstEvent*) p);
325 	}
326 
327 	/**
328 	 * Create a new latency event. The event is sent upstream from the sinks and
329 	 * notifies elements that they should add an additional @latency to the
330 	 * running time before synchronising against the clock.
331 	 *
332 	 * The latency is mostly used in live sinks and is always expressed in
333 	 * the time format.
334 	 *
335 	 * Params:
336 	 *     latency = the new latency value
337 	 *
338 	 * Return: a new #GstEvent
339 	 *
340 	 * Throws: ConstructionException GTK+ fails to create the object.
341 	 */
342 	public this(GstClockTime latency)
343 	{
344 		auto p = gst_event_new_latency(latency);
345 		
346 		if(p is null)
347 		{
348 			throw new ConstructionException("null returned by new_latency");
349 		}
350 		
351 		this(cast(GstEvent*) p);
352 	}
353 
354 	/**
355 	 * Create a new navigation event from the given description.
356 	 *
357 	 * Params:
358 	 *     structure = description of the event. The event will take
359 	 *         ownership of the structure.
360 	 *
361 	 * Return: a new #GstEvent
362 	 *
363 	 * Throws: ConstructionException GTK+ fails to create the object.
364 	 */
365 	public this(Structure structure)
366 	{
367 		auto p = gst_event_new_navigation((structure is null) ? null : structure.getStructureStruct());
368 		
369 		if(p is null)
370 		{
371 			throw new ConstructionException("null returned by new_navigation");
372 		}
373 		
374 		this(cast(GstEvent*) p);
375 	}
376 
377 	/**
378 	 * Allocate a new qos event with the given values.
379 	 * The QOS event is generated in an element that wants an upstream
380 	 * element to either reduce or increase its rate because of
381 	 * high/low CPU load or other resource usage such as network performance or
382 	 * throttling. Typically sinks generate these events for each buffer
383 	 * they receive.
384 	 *
385 	 * @type indicates the reason for the QoS event. #GST_QOS_TYPE_OVERFLOW is
386 	 * used when a buffer arrived in time or when the sink cannot keep up with
387 	 * the upstream datarate. #GST_QOS_TYPE_UNDERFLOW is when the sink is not
388 	 * receiving buffers fast enough and thus has to drop late buffers.
389 	 * #GST_QOS_TYPE_THROTTLE is used when the datarate is artificially limited
390 	 * by the application, for example to reduce power consumption.
391 	 *
392 	 * @proportion indicates the real-time performance of the streaming in the
393 	 * element that generated the QoS event (usually the sink). The value is
394 	 * generally computed based on more long term statistics about the streams
395 	 * timestamps compared to the clock.
396 	 * A value < 1.0 indicates that the upstream element is producing data faster
397 	 * than real-time. A value > 1.0 indicates that the upstream element is not
398 	 * producing data fast enough. 1.0 is the ideal @proportion value. The
399 	 * proportion value can safely be used to lower or increase the quality of
400 	 * the element.
401 	 *
402 	 * @diff is the difference against the clock in running time of the last
403 	 * buffer that caused the element to generate the QOS event. A negative value
404 	 * means that the buffer with @timestamp arrived in time. A positive value
405 	 * indicates how late the buffer with @timestamp was. When throttling is
406 	 * enabled, @diff will be set to the requested throttling interval.
407 	 *
408 	 * @timestamp is the timestamp of the last buffer that cause the element
409 	 * to generate the QOS event. It is expressed in running time and thus an ever
410 	 * increasing value.
411 	 *
412 	 * The upstream element can use the @diff and @timestamp values to decide
413 	 * whether to process more buffers. For positive @diff, all buffers with
414 	 * timestamp <= @timestamp + @diff will certainly arrive late in the sink
415 	 * as well. A (negative) @diff value so that @timestamp + @diff would yield a
416 	 * result smaller than 0 is not allowed.
417 	 *
418 	 * The application can use general event probes to intercept the QoS
419 	 * event and implement custom application specific QoS handling.
420 	 *
421 	 * Params:
422 	 *     type = the QoS type
423 	 *     proportion = the proportion of the qos message
424 	 *     diff = The time difference of the last Clock sync
425 	 *     timestamp = The timestamp of the buffer
426 	 *
427 	 * Return: a new QOS event.
428 	 *
429 	 * Throws: ConstructionException GTK+ fails to create the object.
430 	 */
431 	public this(GstQOSType type, double proportion, GstClockTimeDiff diff, GstClockTime timestamp)
432 	{
433 		auto p = gst_event_new_qos(type, proportion, diff, timestamp);
434 		
435 		if(p is null)
436 		{
437 			throw new ConstructionException("null returned by new_qos");
438 		}
439 		
440 		this(cast(GstEvent*) p);
441 	}
442 
443 	/**
444 	 * Create a new reconfigure event. The purpose of the reconfigure event is
445 	 * to travel upstream and make elements renegotiate their caps or reconfigure
446 	 * their buffer pools. This is useful when changing properties on elements
447 	 * or changing the topology of the pipeline.
448 	 *
449 	 * Return: a new #GstEvent
450 	 *
451 	 * Throws: ConstructionException GTK+ fails to create the object.
452 	 */
453 	public this()
454 	{
455 		auto p = gst_event_new_reconfigure();
456 		
457 		if(p is null)
458 		{
459 			throw new ConstructionException("null returned by new_reconfigure");
460 		}
461 		
462 		this(cast(GstEvent*) p);
463 	}
464 
465 	/**
466 	 * Allocate a new seek event with the given parameters.
467 	 *
468 	 * The seek event configures playback of the pipeline between @start to @stop
469 	 * at the speed given in @rate, also called a playback segment.
470 	 * The @start and @stop values are expressed in @format.
471 	 *
472 	 * A @rate of 1.0 means normal playback rate, 2.0 means double speed.
473 	 * Negatives values means backwards playback. A value of 0.0 for the
474 	 * rate is not allowed and should be accomplished instead by PAUSING the
475 	 * pipeline.
476 	 *
477 	 * A pipeline has a default playback segment configured with a start
478 	 * position of 0, a stop position of -1 and a rate of 1.0. The currently
479 	 * configured playback segment can be queried with #GST_QUERY_SEGMENT.
480 	 *
481 	 * @start_type and @stop_type specify how to adjust the currently configured
482 	 * start and stop fields in playback segment. Adjustments can be made relative
483 	 * or absolute to the last configured values. A type of #GST_SEEK_TYPE_NONE
484 	 * means that the position should not be updated.
485 	 *
486 	 * When the rate is positive and @start has been updated, playback will start
487 	 * from the newly configured start position.
488 	 *
489 	 * For negative rates, playback will start from the newly configured stop
490 	 * position (if any). If the stop position is updated, it must be different from
491 	 * -1 (#GST_CLOCK_TIME_NONE) for negative rates.
492 	 *
493 	 * It is not possible to seek relative to the current playback position, to do
494 	 * this, PAUSE the pipeline, query the current playback position with
495 	 * #GST_QUERY_POSITION and update the playback segment current position with a
496 	 * #GST_SEEK_TYPE_SET to the desired position.
497 	 *
498 	 * Params:
499 	 *     rate = The new playback rate
500 	 *     format = The format of the seek values
501 	 *     flags = The optional seek flags
502 	 *     startType = The type and flags for the new start position
503 	 *     start = The value of the new start position
504 	 *     stopType = The type and flags for the new stop position
505 	 *     stop = The value of the new stop position
506 	 *
507 	 * Return: a new seek event.
508 	 *
509 	 * Throws: ConstructionException GTK+ fails to create the object.
510 	 */
511 	public this(double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop)
512 	{
513 		auto p = gst_event_new_seek(rate, format, flags, startType, start, stopType, stop);
514 		
515 		if(p is null)
516 		{
517 			throw new ConstructionException("null returned by new_seek");
518 		}
519 		
520 		this(cast(GstEvent*) p);
521 	}
522 
523 	/**
524 	 * Create a new SEGMENT event for @segment. The segment event can only travel
525 	 * downstream synchronized with the buffer flow and contains timing information
526 	 * and playback properties for the buffers that will follow.
527 	 *
528 	 * The newsegment event marks the range of buffers to be processed. All
529 	 * data not within the segment range is not to be processed. This can be
530 	 * used intelligently by plugins to apply more efficient methods of skipping
531 	 * unneeded data. The valid range is expressed with the @start and @stop
532 	 * values.
533 	 *
534 	 * The time value of the segment is used in conjunction with the start
535 	 * value to convert the buffer timestamps into the stream time. This is
536 	 * usually done in sinks to report the current stream_time.
537 	 * @time represents the stream_time of a buffer carrying a timestamp of
538 	 * @start. @time cannot be -1.
539 	 *
540 	 * @start cannot be -1, @stop can be -1. If there
541 	 * is a valid @stop given, it must be greater or equal the @start, including
542 	 * when the indicated playback @rate is < 0.
543 	 *
544 	 * The @applied_rate value provides information about any rate adjustment that
545 	 * has already been made to the timestamps and content on the buffers of the
546 	 * stream. (@rate * @applied_rate) should always equal the rate that has been
547 	 * requested for playback. For example, if an element has an input segment
548 	 * with intended playback @rate of 2.0 and applied_rate of 1.0, it can adjust
549 	 * incoming timestamps and buffer content by half and output a newsegment event
550 	 * with @rate of 1.0 and @applied_rate of 2.0
551 	 *
552 	 * After a newsegment event, the buffer stream time is calculated with:
553 	 *
554 	 * time + (TIMESTAMP(buf) - start) * ABS (rate * applied_rate)
555 	 *
556 	 * Params:
557 	 *     segment = a #GstSegment
558 	 *
559 	 * Return: the new SEGMENT event.
560 	 *
561 	 * Throws: ConstructionException GTK+ fails to create the object.
562 	 */
563 	public this(Segment segment)
564 	{
565 		auto p = gst_event_new_segment((segment is null) ? null : segment.getSegmentStruct());
566 		
567 		if(p is null)
568 		{
569 			throw new ConstructionException("null returned by new_segment");
570 		}
571 		
572 		this(cast(GstEvent*) p);
573 	}
574 
575 	/**
576 	 * Create a new segment-done event. This event is sent by elements that
577 	 * finish playback of a segment as a result of a segment seek.
578 	 *
579 	 * Params:
580 	 *     format = The format of the position being done
581 	 *     position = The position of the segment being done
582 	 *
583 	 * Return: a new #GstEvent
584 	 *
585 	 * Throws: ConstructionException GTK+ fails to create the object.
586 	 */
587 	public this(GstFormat format, long position)
588 	{
589 		auto p = gst_event_new_segment_done(format, position);
590 		
591 		if(p is null)
592 		{
593 			throw new ConstructionException("null returned by new_segment_done");
594 		}
595 		
596 		this(cast(GstEvent*) p);
597 	}
598 
599 	/**
600 	 * Create a new sink-message event. The purpose of the sink-message event is
601 	 * to instruct a sink to post the message contained in the event synchronized
602 	 * with the stream.
603 	 *
604 	 * @name is used to store multiple sticky events on one pad.
605 	 *
606 	 * Params:
607 	 *     name = a name for the event
608 	 *     msg = the #GstMessage to be posted
609 	 *
610 	 * Return: a new #GstEvent
611 	 *
612 	 * Throws: ConstructionException GTK+ fails to create the object.
613 	 */
614 	public this(string name, Message msg)
615 	{
616 		auto p = gst_event_new_sink_message(Str.toStringz(name), (msg is null) ? null : msg.getMessageStruct());
617 		
618 		if(p is null)
619 		{
620 			throw new ConstructionException("null returned by new_sink_message");
621 		}
622 		
623 		this(cast(GstEvent*) p);
624 	}
625 
626 	/**
627 	 * Create a new step event. The purpose of the step event is to instruct a sink
628 	 * to skip @amount (expressed in @format) of media. It can be used to implement
629 	 * stepping through the video frame by frame or for doing fast trick modes.
630 	 *
631 	 * A rate of <= 0.0 is not allowed. Pause the pipeline, for the effect of rate
632 	 * = 0.0 or first reverse the direction of playback using a seek event to get
633 	 * the same effect as rate < 0.0.
634 	 *
635 	 * The @flush flag will clear any pending data in the pipeline before starting
636 	 * the step operation.
637 	 *
638 	 * The @intermediate flag instructs the pipeline that this step operation is
639 	 * part of a larger step operation.
640 	 *
641 	 * Params:
642 	 *     format = the format of @amount
643 	 *     amount = the amount of data to step
644 	 *     rate = the step rate
645 	 *     flush = flushing steps
646 	 *     intermediate = intermediate steps
647 	 *
648 	 * Return: a new #GstEvent
649 	 *
650 	 * Throws: ConstructionException GTK+ fails to create the object.
651 	 */
652 	public this(GstFormat format, ulong amount, double rate, bool flush, bool intermediate)
653 	{
654 		auto p = gst_event_new_step(format, amount, rate, flush, intermediate);
655 		
656 		if(p is null)
657 		{
658 			throw new ConstructionException("null returned by new_step");
659 		}
660 		
661 		this(cast(GstEvent*) p);
662 	}
663 
664 	/**
665 	 * Create a new STREAM_START event. The stream start event can only
666 	 * travel downstream synchronized with the buffer flow. It is expected
667 	 * to be the first event that is sent for a new stream.
668 	 *
669 	 * Source elements, demuxers and other elements that create new streams
670 	 * are supposed to send this event as the first event of a new stream. It
671 	 * should not be send after a flushing seek or in similar situations
672 	 * and is used to mark the beginning of a new logical stream. Elements
673 	 * combining multiple streams must ensure that this event is only forwarded
674 	 * downstream once and not for every single input stream.
675 	 *
676 	 * The @stream_id should be a unique string that consists of the upstream
677 	 * stream-id, / as separator and a unique stream-id for this specific
678 	 * stream. A new stream-id should only be created for a stream if the upstream
679 	 * stream is split into (potentially) multiple new streams, e.g. in a demuxer,
680 	 * but not for every single element in the pipeline.
681 	 * gst_pad_create_stream_id() or gst_pad_create_stream_id_printf() can be
682 	 * used to create a stream-id.
683 	 *
684 	 * Params:
685 	 *     streamId = Identifier for this stream
686 	 *
687 	 * Return: the new STREAM_START event.
688 	 *
689 	 * Throws: ConstructionException GTK+ fails to create the object.
690 	 */
691 	public this(string streamId)
692 	{
693 		auto p = gst_event_new_stream_start(Str.toStringz(streamId));
694 		
695 		if(p is null)
696 		{
697 			throw new ConstructionException("null returned by new_stream_start");
698 		}
699 		
700 		this(cast(GstEvent*) p);
701 	}
702 
703 	/**
704 	 * Generates a metadata tag event from the given @taglist.
705 	 *
706 	 * The scope of the taglist specifies if the taglist applies to the
707 	 * complete medium or only to this specific stream. As the tag event
708 	 * is a sticky event, elements should merge tags received from
709 	 * upstream with a given scope with their own tags with the same
710 	 * scope and create a new tag event from it.
711 	 *
712 	 * Params:
713 	 *     taglist = metadata list. The event will take ownership
714 	 *         of the taglist.
715 	 *
716 	 * Return: a new #GstEvent
717 	 *
718 	 * Throws: ConstructionException GTK+ fails to create the object.
719 	 */
720 	public this(TagList taglist)
721 	{
722 		auto p = gst_event_new_tag((taglist is null) ? null : taglist.getTagListStruct());
723 		
724 		if(p is null)
725 		{
726 			throw new ConstructionException("null returned by new_tag");
727 		}
728 		
729 		this(cast(GstEvent*) p);
730 	}
731 
732 	/**
733 	 * Generate a TOC event from the given @toc. The purpose of the TOC event is to
734 	 * inform elements that some kind of the TOC was found.
735 	 *
736 	 * Params:
737 	 *     toc = #GstToc structure.
738 	 *     updated = whether @toc was updated or not.
739 	 *
740 	 * Return: a new #GstEvent.
741 	 *
742 	 * Throws: ConstructionException GTK+ fails to create the object.
743 	 */
744 	public this(Toc toc, bool updated)
745 	{
746 		auto p = gst_event_new_toc((toc is null) ? null : toc.getTocStruct(), updated);
747 		
748 		if(p is null)
749 		{
750 			throw new ConstructionException("null returned by new_toc");
751 		}
752 		
753 		this(cast(GstEvent*) p);
754 	}
755 
756 	/**
757 	 * Parses a segment @event and copies the #GstSegment into the location
758 	 * given by @segment.
759 	 *
760 	 * Params:
761 	 *     segment = a pointer to a #GstSegment
762 	 */
763 	public void copySegment(Segment segment)
764 	{
765 		gst_event_copy_segment(gstEvent, (segment is null) ? null : segment.getSegmentStruct());
766 	}
767 
768 	/**
769 	 * Retrieve the accumulated running time offset of the event.
770 	 *
771 	 * Events passing through #GstPads that have a running time
772 	 * offset set via gst_pad_set_offset() will get their offset
773 	 * adjusted according to the pad's offset.
774 	 *
775 	 * If the event contains any information that related to the
776 	 * running time, this information will need to be updated
777 	 * before usage with this offset.
778 	 *
779 	 * Return: The event's running time offset
780 	 *
781 	 *     MT safe.
782 	 *
783 	 * Since: 1.4
784 	 */
785 	public long getRunningTimeOffset()
786 	{
787 		return gst_event_get_running_time_offset(gstEvent);
788 	}
789 
790 	/**
791 	 * Retrieve the sequence number of a event.
792 	 *
793 	 * Events have ever-incrementing sequence numbers, which may also be set
794 	 * explicitly via gst_event_set_seqnum(). Sequence numbers are typically used to
795 	 * indicate that a event corresponds to some other set of events or messages,
796 	 * for example an EOS event corresponding to a SEEK event. It is considered good
797 	 * practice to make this correspondence when possible, though it is not
798 	 * required.
799 	 *
800 	 * Note that events and messages share the same sequence number incrementor;
801 	 * two events or messages will never have the same sequence number unless
802 	 * that correspondence was made explicitly.
803 	 *
804 	 * Return: The event's sequence number.
805 	 *
806 	 *     MT safe.
807 	 */
808 	public uint getSeqnum()
809 	{
810 		return gst_event_get_seqnum(gstEvent);
811 	}
812 
813 	/**
814 	 * Access the structure of the event.
815 	 *
816 	 * Return: The structure of the event. The structure is still
817 	 *     owned by the event, which means that you should not free it and
818 	 *     that the pointer becomes invalid when you free the event.
819 	 *
820 	 *     MT safe.
821 	 */
822 	public Structure getStructure()
823 	{
824 		auto p = gst_event_get_structure(gstEvent);
825 		
826 		if(p is null)
827 		{
828 			return null;
829 		}
830 		
831 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
832 	}
833 
834 	/**
835 	 * Checks if @event has the given @name. This function is usually used to
836 	 * check the name of a custom event.
837 	 *
838 	 * Params:
839 	 *     name = name to check
840 	 *
841 	 * Return: %TRUE if @name matches the name of the event structure.
842 	 */
843 	public bool hasName(string name)
844 	{
845 		return gst_event_has_name(gstEvent, Str.toStringz(name)) != 0;
846 	}
847 
848 	/**
849 	 * Get the format, minsize, maxsize and async-flag in the buffersize event.
850 	 *
851 	 * Params:
852 	 *     format = A pointer to store the format in
853 	 *     minsize = A pointer to store the minsize in
854 	 *     maxsize = A pointer to store the maxsize in
855 	 *     async = A pointer to store the async-flag in
856 	 */
857 	public void parseBufferSize(out GstFormat format, out long minsize, out long maxsize, out bool async)
858 	{
859 		int outasync;
860 		
861 		gst_event_parse_buffer_size(gstEvent, &format, &minsize, &maxsize, &outasync);
862 		
863 		async = (outasync == 1);
864 	}
865 
866 	/**
867 	 * Get the caps from @event. The caps remains valid as long as @event remains
868 	 * valid.
869 	 *
870 	 * Params:
871 	 *     caps = A pointer to the caps
872 	 */
873 	public void parseCaps(out Caps caps)
874 	{
875 		GstCaps* outcaps = null;
876 		
877 		gst_event_parse_caps(gstEvent, &outcaps);
878 		
879 		caps = ObjectG.getDObject!(Caps)(outcaps);
880 	}
881 
882 	/**
883 	 * Parse the FLUSH_STOP event and retrieve the @reset_time member.
884 	 *
885 	 * Params:
886 	 *     resetTime = if time should be reset
887 	 */
888 	public void parseFlushStop(out bool resetTime)
889 	{
890 		int outresetTime;
891 		
892 		gst_event_parse_flush_stop(gstEvent, &outresetTime);
893 		
894 		resetTime = (outresetTime == 1);
895 	}
896 
897 	/**
898 	 * Extract timestamp and duration from a new GAP event.
899 	 *
900 	 * Params:
901 	 *     timestamp = location where to store the
902 	 *         start time (pts) of the gap, or %NULL
903 	 *     duration = location where to store the duration of
904 	 *         the gap, or %NULL
905 	 */
906 	public void parseGap(out GstClockTime timestamp, out GstClockTime duration)
907 	{
908 		gst_event_parse_gap(gstEvent, &timestamp, &duration);
909 	}
910 
911 	/**
912 	 *
913 	 * Params:
914 	 *     groupId = address of variable where to store the group id
915 	 * Return: %TRUE if a group id was set on the event and could be parsed,
916 	 *     %FALSE otherwise.
917 	 *
918 	 * Since: 1.2
919 	 */
920 	public bool parseGroupId(out uint groupId)
921 	{
922 		return gst_event_parse_group_id(gstEvent, &groupId) != 0;
923 	}
924 
925 	/**
926 	 * Get the latency in the latency event.
927 	 *
928 	 * Params:
929 	 *     latency = A pointer to store the latency in.
930 	 */
931 	public void parseLatency(out GstClockTime latency)
932 	{
933 		gst_event_parse_latency(gstEvent, &latency);
934 	}
935 
936 	/**
937 	 * Get the type, proportion, diff and timestamp in the qos event. See
938 	 * gst_event_new_qos() for more information about the different QoS values.
939 	 *
940 	 * @timestamp will be adjusted for any pad offsets of pads it was passing through.
941 	 *
942 	 * Params:
943 	 *     type = A pointer to store the QoS type in
944 	 *     proportion = A pointer to store the proportion in
945 	 *     diff = A pointer to store the diff in
946 	 *     timestamp = A pointer to store the timestamp in
947 	 */
948 	public void parseQos(out GstQOSType type, out double proportion, out GstClockTimeDiff diff, out GstClockTime timestamp)
949 	{
950 		gst_event_parse_qos(gstEvent, &type, &proportion, &diff, &timestamp);
951 	}
952 
953 	/**
954 	 * Parses a seek @event and stores the results in the given result locations.
955 	 *
956 	 * Params:
957 	 *     rate = result location for the rate
958 	 *     format = result location for the stream format
959 	 *     flags = result location for the #GstSeekFlags
960 	 *     startType = result location for the #GstSeekType of the start position
961 	 *     start = result location for the start position expressed in @format
962 	 *     stopType = result location for the #GstSeekType of the stop position
963 	 *     stop = result location for the stop position expressed in @format
964 	 */
965 	public void parseSeek(out double rate, out GstFormat format, out GstSeekFlags flags, out GstSeekType startType, out long start, out GstSeekType stopType, out long stop)
966 	{
967 		gst_event_parse_seek(gstEvent, &rate, &format, &flags, &startType, &start, &stopType, &stop);
968 	}
969 
970 	/**
971 	 * Parses a segment @event and stores the result in the given @segment location.
972 	 * @segment remains valid only until the @event is freed. Don't modify the segment
973 	 * and make a copy if you want to modify it or store it for later use.
974 	 *
975 	 * Params:
976 	 *     segment = a pointer to a #GstSegment
977 	 */
978 	public void parseSegment(out Segment segment)
979 	{
980 		GstSegment* outsegment = null;
981 		
982 		gst_event_parse_segment(gstEvent, &outsegment);
983 		
984 		segment = ObjectG.getDObject!(Segment)(outsegment);
985 	}
986 
987 	/**
988 	 * Extracts the position and format from the segment done message.
989 	 *
990 	 * Params:
991 	 *     format = Result location for the format, or %NULL
992 	 *     position = Result location for the position, or %NULL
993 	 */
994 	public void parseSegmentDone(out GstFormat format, out long position)
995 	{
996 		gst_event_parse_segment_done(gstEvent, &format, &position);
997 	}
998 
999 	/**
1000 	 * Parse the sink-message event. Unref @msg after usage.
1001 	 *
1002 	 * Params:
1003 	 *     msg = a pointer to store the #GstMessage in.
1004 	 */
1005 	public void parseSinkMessage(out Message msg)
1006 	{
1007 		GstMessage* outmsg = null;
1008 		
1009 		gst_event_parse_sink_message(gstEvent, &outmsg);
1010 		
1011 		msg = ObjectG.getDObject!(Message)(outmsg);
1012 	}
1013 
1014 	/**
1015 	 * Parse the step event.
1016 	 *
1017 	 * Params:
1018 	 *     format = a pointer to store the format in
1019 	 *     amount = a pointer to store the amount in
1020 	 *     rate = a pointer to store the rate in
1021 	 *     flush = a pointer to store the flush boolean in
1022 	 *     intermediate = a pointer to store the intermediate
1023 	 *         boolean in
1024 	 */
1025 	public void parseStep(out GstFormat format, out ulong amount, out double rate, out bool flush, out bool intermediate)
1026 	{
1027 		int outflush;
1028 		int outintermediate;
1029 		
1030 		gst_event_parse_step(gstEvent, &format, &amount, &rate, &outflush, &outintermediate);
1031 		
1032 		flush = (outflush == 1);
1033 		intermediate = (outintermediate == 1);
1034 	}
1035 
1036 	public void parseStreamFlags(out GstStreamFlags flags)
1037 	{
1038 		gst_event_parse_stream_flags(gstEvent, &flags);
1039 	}
1040 
1041 	/**
1042 	 * Parse a stream-id @event and store the result in the given @stream_id
1043 	 * location. The string stored in @stream_id must not be modified and will
1044 	 * remain valid only until @event gets freed. Make a copy if you want to
1045 	 * modify it or store it for later use.
1046 	 *
1047 	 * Params:
1048 	 *     streamId = pointer to store the stream-id
1049 	 */
1050 	public void parseStreamStart(out string streamId)
1051 	{
1052 		char* outstreamId = null;
1053 		
1054 		gst_event_parse_stream_start(gstEvent, &outstreamId);
1055 		
1056 		streamId = Str.toString(outstreamId);
1057 	}
1058 
1059 	/**
1060 	 * Parses a tag @event and stores the results in the given @taglist location.
1061 	 * No reference to the taglist will be returned, it remains valid only until
1062 	 * the @event is freed. Don't modify or free the taglist, make a copy if you
1063 	 * want to modify it or store it for later use.
1064 	 *
1065 	 * Params:
1066 	 *     taglist = pointer to metadata list
1067 	 */
1068 	public void parseTag(out TagList taglist)
1069 	{
1070 		GstTagList* outtaglist = null;
1071 		
1072 		gst_event_parse_tag(gstEvent, &outtaglist);
1073 		
1074 		taglist = ObjectG.getDObject!(TagList)(outtaglist);
1075 	}
1076 
1077 	/**
1078 	 * Parse a TOC @event and store the results in the given @toc and @updated locations.
1079 	 *
1080 	 * Params:
1081 	 *     toc = pointer to #GstToc structure.
1082 	 *     updated = pointer to store TOC updated flag.
1083 	 */
1084 	public void parseToc(out Toc toc, out bool updated)
1085 	{
1086 		GstToc* outtoc = null;
1087 		int outupdated;
1088 		
1089 		gst_event_parse_toc(gstEvent, &outtoc, &outupdated);
1090 		
1091 		toc = ObjectG.getDObject!(Toc)(outtoc);
1092 		updated = (outupdated == 1);
1093 	}
1094 
1095 	/**
1096 	 * Parse a TOC select @event and store the results in the given @uid location.
1097 	 *
1098 	 * Params:
1099 	 *     uid = storage for the selection UID.
1100 	 */
1101 	public void parseTocSelect(out string uid)
1102 	{
1103 		char* outuid = null;
1104 		
1105 		gst_event_parse_toc_select(gstEvent, &outuid);
1106 		
1107 		uid = Str.toString(outuid);
1108 	}
1109 
1110 	/**
1111 	 * All streams that have the same group id are supposed to be played
1112 	 * together, i.e. all streams inside a container file should have the
1113 	 * same group id but different stream ids. The group id should change
1114 	 * each time the stream is started, resulting in different group ids
1115 	 * each time a file is played for example.
1116 	 *
1117 	 * Use gst_util_group_id_next() to get a new group id.
1118 	 *
1119 	 * Params:
1120 	 *     groupId = the group id to set
1121 	 *
1122 	 * Since: 1.2
1123 	 */
1124 	public void setGroupId(uint groupId)
1125 	{
1126 		gst_event_set_group_id(gstEvent, groupId);
1127 	}
1128 
1129 	/**
1130 	 * Set the running time offset of a event. See
1131 	 * gst_event_get_running_time_offset() for more information.
1132 	 *
1133 	 * MT safe.
1134 	 *
1135 	 * Params:
1136 	 *     offset = A the new running time offset
1137 	 *
1138 	 * Since: 1.4
1139 	 */
1140 	public void setRunningTimeOffset(long offset)
1141 	{
1142 		gst_event_set_running_time_offset(gstEvent, offset);
1143 	}
1144 
1145 	/**
1146 	 * Set the sequence number of a event.
1147 	 *
1148 	 * This function might be called by the creator of a event to indicate that the
1149 	 * event relates to other events or messages. See gst_event_get_seqnum() for
1150 	 * more information.
1151 	 *
1152 	 * MT safe.
1153 	 *
1154 	 * Params:
1155 	 *     seqnum = A sequence number.
1156 	 */
1157 	public void setSeqnum(uint seqnum)
1158 	{
1159 		gst_event_set_seqnum(gstEvent, seqnum);
1160 	}
1161 
1162 	public void setStreamFlags(GstStreamFlags flags)
1163 	{
1164 		gst_event_set_stream_flags(gstEvent, flags);
1165 	}
1166 
1167 	/**
1168 	 * Get a writable version of the structure.
1169 	 *
1170 	 * Return: The structure of the event. The structure
1171 	 *     is still owned by the event, which means that you should not free
1172 	 *     it and that the pointer becomes invalid when you free the event.
1173 	 *     This function checks if @event is writable and will never return
1174 	 *     %NULL.
1175 	 *
1176 	 *     MT safe.
1177 	 */
1178 	public Structure writableStructure()
1179 	{
1180 		auto p = gst_event_writable_structure(gstEvent);
1181 		
1182 		if(p is null)
1183 		{
1184 			return null;
1185 		}
1186 		
1187 		return ObjectG.getDObject!(Structure)(cast(GstStructure*) p);
1188 	}
1189 
1190 	/**
1191 	 * Gets the #GstEventTypeFlags associated with @type.
1192 	 *
1193 	 * Params:
1194 	 *     type = a #GstEventType
1195 	 *
1196 	 * Return: a #GstEventTypeFlags.
1197 	 */
1198 	public static GstEventTypeFlags typeGetFlags(GstEventType type)
1199 	{
1200 		return gst_event_type_get_flags(type);
1201 	}
1202 
1203 	/**
1204 	 * Get a printable name for the given event type. Do not modify or free.
1205 	 *
1206 	 * Params:
1207 	 *     type = the event type
1208 	 *
1209 	 * Return: a reference to the static name of the event.
1210 	 */
1211 	public static string typeGetName(GstEventType type)
1212 	{
1213 		return Str.toString(gst_event_type_get_name(type));
1214 	}
1215 
1216 	/**
1217 	 * Get the unique quark for the given event type.
1218 	 *
1219 	 * Params:
1220 	 *     type = the event type
1221 	 *
1222 	 * Return: the quark associated with the event type
1223 	 */
1224 	public static GQuark typeToQuark(GstEventType type)
1225 	{
1226 		return gst_event_type_to_quark(type);
1227 	}
1228 }