alternative to assert
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Event.d
bloba040df250ec022dfc02b4efdde6a15c311279bc2
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gstreamer-GstEvent.html
26 * outPack = gstreamer
27 * outFile = Event
28 * strct = GstEvent
29 * realStrct=
30 * ctorStrct=
31 * clss = Event
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_event_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gst_event_new_buffer_size
45 * - gst_event_new_eos
46 * - gst_event_new_flush_start
47 * - gst_event_new_flush_stop
48 * - gst_event_new_navigation
49 * imports:
50 * - glib.Str
51 * - gstreamer.Structure
52 * - gstreamer.TagList
53 * - gstreamer.MiniObject
54 * structWrap:
55 * - GstEvent* -> Event
56 * - GstMiniObject -> MiniObject
57 * - GstMiniObject* -> MiniObject
58 * - GstStructure* -> Structure
59 * - GstTagList* -> TagList
60 * module aliases:
61 * local aliases:
64 module gstreamer.Event;
66 private import gstreamerc.gstreamertypes;
68 private import gstreamerc.gstreamer;
70 private import glib.Str;
71 private import gstreamer.Structure;
72 private import gstreamer.TagList;
73 private import gstreamer.MiniObject;
77 /**
78 * Description
79 * The event class provides factory methods to construct and functions query
80 * (parse) events.
81 * Events are usually created with gst_event_new_*() which takes event-type
82 * specific parameters as arguments.
83 * To send an event application will usually use gst_element_send_event() and
84 * elements will use gst_pad_send_event() or gst_pad_push_event().
85 * The event should be unreffed with gst_event_unref() if it has not been sent.
86 * Events that have been received can be parsed with their respective
87 * gst_event_parse_*() functions.
88 * Events are passed between elements in parallel to the data stream. Some events
89 * are serialized with buffers, others are not. Some events only travel downstream,
90 * others only upstream. Some events can travel both upstream and downstream.
91 * The events are used to signal special conditions in the datastream such as
92 * EOS (end of stream) or the start of a new stream-segment.
93 * Events are also used to flush the pipeline of any pending data.
94 * Most of the event API is used inside plugins. Applications usually only
95 * construct and use seek events.
96 * To do that gst_event_new_seek() is used to create a seek event. It takes
97 * the needed parameters to specity seeking time and mode.
98 * Example8.performing a seek on a pipeline
99 * GstEvent *event;
100 * gboolean result;
101 * ...
102 * // construct a seek event to play the media from second 2 to 5, flush
103 * // the pipeline to decrease latency.
104 * event = gst_event_new_seek (1.0,
105 * GST_FORMAT_TIME,
106 * GST_SEEK_FLAG_FLUSH,
107 * GST_SEEK_TYPE_SET, 2 * GST_SECOND,
108 * GST_SEEK_TYPE_SET, 5 * GST_SECOND);
109 * ...
110 * result = gst_element_send_event (pipeline, event);
111 * if (!result)
112 * g_warning ("seek failed");
113 * ...
114 * Last reviewed on 2006-09-6 (0.10.10)
116 public class Event
119 /** the main Gtk struct */
120 protected GstEvent* gstEvent;
123 public GstEvent* getEventStruct()
125 return gstEvent;
129 /** the main Gtk struct as a void* */
130 protected void* getStruct()
132 return cast(void*)gstEvent;
136 * Sets our main struct and passes it to the parent class
138 public this (GstEvent* gstEvent)
140 this.gstEvent = gstEvent;
144 * Create a new buffersize event. The event is sent downstream and notifies
145 * elements that they should provide a buffer of the specified dimensions.
146 * When the async flag is set, a thread boundary is prefered.
147 * format:
148 * buffer format
149 * minsize:
150 * minimum buffer size
151 * maxsize:
152 * maximum buffer size
153 * async:
154 * thread behavior
155 * Returns:
156 * a new GstEvent
158 public static Event newBufferSize(GstFormat format, long minsize, long maxsize, int async)
160 // GstEvent* gst_event_new_buffer_size (GstFormat format, gint64 minsize, gint64 maxsize, gboolean async);
161 return new Event(cast(GstEvent*)gst_event_new_buffer_size(format, minsize, maxsize, async) );
162 } /**
163 * Create a new EOS event. The eos event can only travel downstream
164 * synchronized with the buffer flow. Elements that receive the EOS
165 * event on a pad can return UNEXPECTED as a GstFlowReturn when data
166 * after the EOS event arrives.
167 * The EOS event will travel down to the sink elements in the pipeline
168 * which will then post the GST_MESSAGE_EOS on the bus after they have
169 * finished playing any buffered data.
170 * When all sinks have posted an EOS message, the EOS message is
171 * forwarded to the application.
172 * Returns:
173 * The new EOS event.
175 public static Event newEOS()
177 // GstEvent* gst_event_new_eos (void);
178 return new Event(cast(GstEvent*)gst_event_new_eos() );
179 } /**
180 * Allocate a new flush start event. The flush start event can be send
181 * upstream and downstream and travels out-of-bounds with the dataflow.
182 * It marks pads as being in a WRONG_STATE to process more data.
183 * Elements unlock and blocking functions and exit their streaming functions
184 * as fast as possible.
185 * This event is typically generated after a seek to minimize the latency
186 * after the seek.
187 * Returns:
188 * A new flush start event.
190 public static Event newFlushStart()
192 // GstEvent* gst_event_new_flush_start (void);
193 return new Event(cast(GstEvent*)gst_event_new_flush_start() );
194 } /**
195 * Allocate a new flush stop event. The flush start event can be send
196 * upstream and downstream and travels out-of-bounds with the dataflow.
197 * It is typically send after sending a FLUSH_START event to make the
198 * pads accept data again.
199 * Elements can process this event synchronized with the dataflow since
200 * the preceeding FLUSH_START event stopped the dataflow.
201 * This event is typically generated to complete a seek and to resume
202 * dataflow.
203 * Returns:
204 * A new flush stop event.
206 public static Event newFlushStop()
208 // GstEvent* gst_event_new_flush_stop (void);
209 return new Event(cast(GstEvent*)gst_event_new_flush_stop() );
210 }/**
211 * Create a new navigation event from the given description.
212 * structure:
213 * description of the event
214 * Returns:
215 * a new GstEvent
217 public static Event newNavigation(Structure structure)
219 // GstEvent* gst_event_new_navigation (GstStructure *structure);
220 return new Event(cast(GstEvent*)gst_event_new_navigation((structure is null) ? null : structure.getStructureStruct()) );
243 * Access the structure of the event.
244 * event:
245 * The GstEvent.
246 * Returns:
247 * The structure of the event. The structure is still
248 * owned by the event, which means that you should not free it and
249 * that the pointer becomes invalid when you free the event.
250 * MT safe.
252 public Structure getStructure()
254 // const GstStructure* gst_event_get_structure (GstEvent *event);
255 return new Structure( gst_event_get_structure(gstEvent) );
260 * Create a new custom-typed event. This can be used for anything not
261 * handled by other event-specific functions to pass an event to another
262 * element.
263 * Make sure to allocate an event type with the GST_EVENT_MAKE_TYPE macro,
264 * assigning a free number and filling in the correct direction and
265 * serialization flags.
266 * New custom events can also be created by subclassing the event type if
267 * needed.
268 * type:
269 * The type of the new event
270 * structure:
271 * The structure for the event. The event will take ownership of
272 * the structure.
273 * Returns:
274 * The new custom event.
276 public this (GstEventType type, Structure structure)
278 // GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure);
279 this(cast(GstEvent*)gst_event_new_custom(type, (structure is null) ? null : structure.getStructureStruct()) );
286 * Create a new latency event. The event is sent upstream from the sinks and
287 * notifies elements that they should add an additional latency to the
288 * timestamps before synchronising against the clock.
289 * The latency is mostly used in live sinks and is always expressed in
290 * the time format.
291 * latency:
292 * the new latency value
293 * Returns:
294 * a new GstEvent
295 * Since 0.10.12
297 public this (GstClockTime latency)
299 // GstEvent* gst_event_new_latency (GstClockTime latency);
300 this(cast(GstEvent*)gst_event_new_latency(latency) );
305 * Allocate a new newsegment event with the given format/values tripplets
306 * This method calls gst_event_new_new_segment_full() passing a default
307 * value of 1.0 for applied_rate
308 * update:
309 * is this segment an update to a previous one
310 * rate:
311 * a new rate for playback
312 * format:
313 * The format of the segment values
314 * start:
315 * the start value of the segment
316 * stop:
317 * the stop value of the segment
318 * position:
319 * stream position
320 * Returns:
321 * A new newsegment event.
323 public this (int update, double rate, GstFormat format, long start, long stop, long position)
325 // GstEvent* gst_event_new_new_segment (gboolean update, gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position);
326 this(cast(GstEvent*)gst_event_new_new_segment(update, rate, format, start, stop, position) );
330 * Allocate a new newsegment event with the given format/values triplets.
331 * The newsegment event marks the range of buffers to be processed. All
332 * data not within the segment range is not to be processed. This can be
333 * used intelligently by plugins to apply more efficient methods of skipping
334 * unneeded data.
335 * The position value of the segment is used in conjunction with the start
336 * value to convert the buffer timestamps into the stream time. This is
337 * usually done in sinks to report the current stream_time.
338 * position represents the stream_time of a buffer carrying a timestamp of
339 * start. position cannot be -1.
340 * start cannot be -1, stop can be -1. If there
341 * is a valid stop given, it must be greater or equal the start, including
342 * when the indicated playback rate is < 0.
343 * The applied_rate value provides information about any rate adjustment that
344 * has already been made to the timestamps and content on the buffers of the
345 * stream. (rate * applied_rate) should always equal the rate that has been
346 * requested for playback. For example, if an element has an input segment
347 * with intended playback rate of 2.0 and applied_rate of 1.0, it can adjust
348 * incoming timestamps and buffer content by half and output a newsegment event
349 * with rate of 1.0 and applied_rate of 2.0
350 * After a newsegment event, the buffer stream time is calculated with:
351 * position + (TIMESTAMP(buf) - start) * ABS (rate * applied_rate)
352 * update:
353 * Whether this segment is an update to a previous one
354 * rate:
355 * A new rate for playback
356 * applied_rate:
357 * The rate factor which has already been applied
358 * format:
359 * The format of the segment values
360 * start:
361 * The start value of the segment
362 * stop:
363 * The stop value of the segment
364 * position:
365 * stream position
366 * Returns:
367 * A new newsegment event.
368 * Since 0.10.6
370 public this (int update, double rate, double appliedRate, GstFormat format, long start, long stop, long position)
372 // GstEvent* gst_event_new_new_segment_full (gboolean update, gdouble rate, gdouble applied_rate, GstFormat format, gint64 start, gint64 stop, gint64 position);
373 this(cast(GstEvent*)gst_event_new_new_segment_full(update, rate, appliedRate, format, start, stop, position) );
377 * Allocate a new qos event with the given values.
378 * The QOS event is generated in an element that wants an upstream
379 * element to either reduce or increase its rate because of
380 * high/low CPU load or other resource usage such as network performance.
381 * Typically sinks generate these events for each buffer they receive.
382 * proportion indicates the real-time performance of the streaming in the
383 * element that generated the QoS event (usually the sink). The value is
384 * generally computed based on more long term statistics about the streams
385 * timestamps compared to the clock.
386 * A value < 1.0 indicates that the upstream element is producing data faster
387 * than real-time. A value > 1.0 indicates that the upstream element is not
388 * producing data fast enough. 1.0 is the ideal proportion value. The
389 * proportion value can safely be used to lower or increase the quality of
390 * the element.
391 * diff is the difference against the clock in running time of the last
392 * buffer that caused the element to generate the QOS event. A negative value
393 * means that the buffer with timestamp arrived in time. A positive value
394 * indicates how late the buffer with timestamp was.
395 * timestamp is the timestamp of the last buffer that cause the element
396 * to generate the QOS event. It is expressed in running time and thus an ever
397 * increasing value.
398 * The upstream element can use the diff and timestamp values to decide
399 * whether to process more buffers. For possitive diff, all buffers with
400 * timestamp <= timestamp + diff will certainly arrive late in the sink
401 * as well.
402 * The application can use general event probes to intercept the QoS
403 * event and implement custom application specific QoS handling.
404 * proportion:
405 * the proportion of the qos message
406 * diff:
407 * The time difference of the last Clock sync
408 * timestamp:
409 * The timestamp of the buffer
410 * Returns:
411 * A new QOS event.
413 public this (double proportion, GstClockTimeDiff diff, GstClockTime timestamp)
415 // GstEvent* gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp);
416 this(cast(GstEvent*)gst_event_new_qos(proportion, diff, timestamp) );
420 * Allocate a new seek event with the given parameters.
421 * The seek event configures playback of the pipeline between start to stop
422 * at the speed given in rate, also called a playback segment.
423 * The start and stop values are expressed in format.
424 * A rate of 1.0 means normal playback rate, 2.0 means double speed.
425 * Negatives values means backwards playback. A value of 0.0 for the
426 * rate is not allowed and should be accomplished instead by PAUSING the
427 * pipeline.
428 * A pipeline has a default playback segment configured with a start
429 * position of 0, a stop position of -1 and a rate of 1.0. The currently
430 * configured playback segment can be queried with GST_QUERY_SEGMENT.
431 * start_type and stop_type specify how to adjust the currently configured
432 * start and stop fields in segment. Adjustments can be made relative or
433 * absolute to the last configured values. A type of GST_SEEK_TYPE_NONE means
434 * that the position should not be updated.
435 * When the rate is positive and start has been updated, playback will start
436 * from the newly configured start position.
437 * For negative rates, playback will start from the newly configured stop
438 * position (if any). If the stop position if updated, it must be different from
439 * -1 for negative rates.
440 * It is not possible to seek relative to the current playback position, to do
441 * this, PAUSE the pipeline, query the current playback position with
442 * GST_QUERY_POSITION and update the playback segment current position with a
443 * GST_SEEK_TYPE_SET to the desired position.
444 * rate:
445 * The new playback rate
446 * format:
447 * The format of the seek values
448 * flags:
449 * The optional seek flags
450 * start_type:
451 * The type and flags for the new start position
452 * start:
453 * The value of the new start position
454 * stop_type:
455 * The type and flags for the new stop position
456 * stop:
457 * The value of the new stop position
458 * Returns:
459 * A new seek event.
461 public this (double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop)
463 // GstEvent* gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags, GstSeekType start_type, gint64 start, GstSeekType stop_type, gint64 stop);
464 this(cast(GstEvent*)gst_event_new_seek(rate, format, flags, startType, start, stopType, stop) );
468 * Generates a metadata tag event from the given taglist.
469 * taglist:
470 * metadata list
471 * Returns:
472 * a new GstEvent
474 public this (TagList taglist)
476 // GstEvent* gst_event_new_tag (GstTagList *taglist);
477 this(cast(GstEvent*)gst_event_new_tag((taglist is null) ? null : taglist.getTagListStruct()) );
481 * Get the format, minsize, maxsize and async-flag in the buffersize event.
482 * event:
483 * The event to query
484 * format:
485 * A pointer to store the format in
486 * minsize:
487 * A pointer to store the minsize in
488 * maxsize:
489 * A pointer to store the maxsize in
490 * async:
491 * A pointer to store the async-flag in
493 public void parseBufferSize(GstFormat* format, long* minsize, long* maxsize, int* async)
495 // void gst_event_parse_buffer_size (GstEvent *event, GstFormat *format, gint64 *minsize, gint64 *maxsize, gboolean *async);
496 gst_event_parse_buffer_size(gstEvent, format, minsize, maxsize, async);
500 * Get the latency in the latency event.
501 * event:
502 * The event to query
503 * latency:
504 * A pointer to store the latency in.
505 * Since 0.10.12
507 public void parseLatency(GstClockTime* latency)
509 // void gst_event_parse_latency (GstEvent *event, GstClockTime *latency);
510 gst_event_parse_latency(gstEvent, latency);
514 * Get the update flag, rate, format, start, stop and position in the
515 * newsegment event. In general, gst_event_parse_new_segment_full() should
516 * be used instead of this, to also retrieve the applied_rate value of the
517 * segment. See gst_event_new_new_segment_full() for a full description
518 * of the newsegment event.
519 * event:
520 * The event to query
521 * update:
522 * A pointer to the update flag of the segment
523 * rate:
524 * A pointer to the rate of the segment
525 * format:
526 * A pointer to the format of the newsegment values
527 * start:
528 * A pointer to store the start value in
529 * stop:
530 * A pointer to store the stop value in
531 * position:
532 * A pointer to store the stream time in
534 public void parseNewSegment(int* update, double* rate, GstFormat* format, long* start, long* stop, long* position)
536 // void gst_event_parse_new_segment (GstEvent *event, gboolean *update, gdouble *rate, GstFormat *format, gint64 *start, gint64 *stop, gint64 *position);
537 gst_event_parse_new_segment(gstEvent, update, rate, format, start, stop, position);
541 * Get the update, rate, applied_rate, format, start, stop and
542 * position in the newsegment event. See gst_event_new_new_segment_full()
543 * for a full description of the newsegment event.
544 * event:
545 * The event to query
546 * update:
547 * A pointer to the update flag of the segment
548 * rate:
549 * A pointer to the rate of the segment
550 * applied_rate:
551 * A pointer to the applied_rate of the segment
552 * format:
553 * A pointer to the format of the newsegment values
554 * start:
555 * A pointer to store the start value in
556 * stop:
557 * A pointer to store the stop value in
558 * position:
559 * A pointer to store the stream time in
560 * Since 0.10.6
562 public void parseNewSegmentFull(int* update, double* rate, double* appliedRate, GstFormat* format, long* start, long* stop, long* position)
564 // void gst_event_parse_new_segment_full (GstEvent *event, gboolean *update, gdouble *rate, gdouble *applied_rate, GstFormat *format, gint64 *start, gint64 *stop, gint64 *position);
565 gst_event_parse_new_segment_full(gstEvent, update, rate, appliedRate, format, start, stop, position);
569 * Get the proportion, diff and timestamp in the qos event. See
570 * gst_event_new_qos() for more information about the different QoS values.
571 * event:
572 * The event to query
573 * proportion:
574 * A pointer to store the proportion in
575 * diff:
576 * A pointer to store the diff in
577 * timestamp:
578 * A pointer to store the timestamp in
580 public void parseQos(double* proportion, GstClockTimeDiff* diff, GstClockTime* timestamp)
582 // void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff, GstClockTime *timestamp);
583 gst_event_parse_qos(gstEvent, proportion, diff, timestamp);
587 * Parses a seek event and stores the results in the given result locations.
588 * event:
589 * a seek event
590 * rate:
591 * result location for the rate
592 * format:
593 * result location for the stream format
594 * flags:
595 * result location for the GstSeekFlags
596 * start_type:
597 * result location for the GstSeekType of the start position
598 * start:
599 * result location for the start postion expressed in format
600 * stop_type:
601 * result location for the GstSeekType of the stop position
602 * stop:
603 * result location for the stop postion expressed in format
605 public void parseSeek(double* rate, GstFormat* format, GstSeekFlags* flags, GstSeekType* startType, long* start, GstSeekType* stopType, long* stop)
607 // void gst_event_parse_seek (GstEvent *event, gdouble *rate, GstFormat *format, GstSeekFlags *flags, GstSeekType *start_type, gint64 *start, GstSeekType *stop_type, gint64 *stop);
608 gst_event_parse_seek(gstEvent, rate, format, flags, startType, start, stopType, stop);
612 * Parses a tag event and stores the results in the given taglist location.
613 * event:
614 * a tag event
615 * taglist:
616 * pointer to metadata list
618 public void parseTag(GstTagList** taglist)
620 // void gst_event_parse_tag (GstEvent *event, GstTagList **taglist);
621 gst_event_parse_tag(gstEvent, taglist);
625 * Increase the refcount of this event.
626 * event:
627 * The event to refcount
628 * Returns:
629 * event (for convenience when doing assignments)
631 public Event doref()
633 // GstEvent* gst_event_ref (GstEvent *event);
634 return new Event( gst_event_ref(gstEvent) );
640 * Gets the GstEventTypeFlags associated with type.
641 * type:
642 * a GstEventType
643 * Returns:
644 * a GstEventTypeFlags.
646 public static GstEventTypeFlags typeGetFlags(GstEventType type)
648 // GstEventTypeFlags gst_event_type_get_flags (GstEventType type);
649 return gst_event_type_get_flags(type);
653 * Get a printable name for the given event type. Do not modify or free.
654 * type:
655 * the event type
656 * Returns:
657 * a reference to the static name of the event.
659 public static char[] typeGetName(GstEventType type)
661 // const gchar* gst_event_type_get_name (GstEventType type);
662 return Str.toString(gst_event_type_get_name(type) );
666 * Get the unique quark for the given event type.
667 * type:
668 * the event type
669 * Returns:
670 * the quark associated with the event type
671 * See Also
672 * GstPad, GstElement
674 public static GQuark typeToQuark(GstEventType type)
676 // GQuark gst_event_type_to_quark (GstEventType type);
677 return gst_event_type_to_quark(type);