I've no idea here...
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Event.d
blobfd2038bf10bee17d50efc87c9b43434c110c74e4
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 version(noAssert)
68 version(Tango)
70 import tango.io.Stdout; // use the tango loging?
74 private import gstreamerc.gstreamertypes;
76 private import gstreamerc.gstreamer;
79 private import glib.Str;
80 private import gstreamer.Structure;
81 private import gstreamer.TagList;
82 private import gstreamer.MiniObject;
87 /**
88 * Description
89 * The event class provides factory methods to construct and functions query
90 * (parse) events.
91 * Events are usually created with gst_event_new_*() which takes event-type
92 * specific parameters as arguments.
93 * To send an event application will usually use gst_element_send_event() and
94 * elements will use gst_pad_send_event() or gst_pad_push_event().
95 * The event should be unreffed with gst_event_unref() if it has not been sent.
96 * Events that have been received can be parsed with their respective
97 * gst_event_parse_*() functions.
98 * Events are passed between elements in parallel to the data stream. Some events
99 * are serialized with buffers, others are not. Some events only travel downstream,
100 * others only upstream. Some events can travel both upstream and downstream.
101 * The events are used to signal special conditions in the datastream such as
102 * EOS (end of stream) or the start of a new stream-segment.
103 * Events are also used to flush the pipeline of any pending data.
104 * Most of the event API is used inside plugins. Applications usually only
105 * construct and use seek events.
106 * To do that gst_event_new_seek() is used to create a seek event. It takes
107 * the needed parameters to specity seeking time and mode.
108 * Example8.performing a seek on a pipeline
109 * GstEvent *event;
110 * gboolean result;
111 * ...
112 * // construct a seek event to play the media from second 2 to 5, flush
113 * // the pipeline to decrease latency.
114 * event = gst_event_new_seek (1.0,
115 * GST_FORMAT_TIME,
116 * GST_SEEK_FLAG_FLUSH,
117 * GST_SEEK_TYPE_SET, 2 * GST_SECOND,
118 * GST_SEEK_TYPE_SET, 5 * GST_SECOND);
119 * ...
120 * result = gst_element_send_event (pipeline, event);
121 * if (!result)
122 * g_warning ("seek failed");
123 * ...
124 * Last reviewed on 2006-09-6 (0.10.10)
126 public class Event
129 /** the main Gtk struct */
130 protected GstEvent* gstEvent;
133 public GstEvent* getEventStruct()
135 return gstEvent;
139 /** the main Gtk struct as a void* */
140 protected void* getStruct()
142 return cast(void*)gstEvent;
146 * Sets our main struct and passes it to the parent class
148 public this (GstEvent* gstEvent)
150 version(noAssert)
152 if ( gstEvent is null )
154 int zero = 0;
155 version(Tango)
157 Stdout("struct gstEvent is null on constructor").newline;
159 else
161 printf("struct gstEvent is null on constructor");
163 zero = zero / zero;
166 else
168 assert(gstEvent !is null, "struct gstEvent is null on constructor");
170 this.gstEvent = gstEvent;
174 * Create a new buffersize event. The event is sent downstream and notifies
175 * elements that they should provide a buffer of the specified dimensions.
176 * When the async flag is set, a thread boundary is prefered.
177 * format:
178 * buffer format
179 * minsize:
180 * minimum buffer size
181 * maxsize:
182 * maximum buffer size
183 * async:
184 * thread behavior
185 * Returns:
186 * a new GstEvent
188 public static Event newBufferSize(GstFormat format, long minsize, long maxsize, int async)
190 // GstEvent* gst_event_new_buffer_size (GstFormat format, gint64 minsize, gint64 maxsize, gboolean async);
191 return new Event(cast(GstEvent*)gst_event_new_buffer_size(format, minsize, maxsize, async) );
192 } /**
193 * Create a new EOS event. The eos event can only travel downstream
194 * synchronized with the buffer flow. Elements that receive the EOS
195 * event on a pad can return UNEXPECTED as a GstFlowReturn when data
196 * after the EOS event arrives.
197 * The EOS event will travel down to the sink elements in the pipeline
198 * which will then post the GST_MESSAGE_EOS on the bus after they have
199 * finished playing any buffered data.
200 * When all sinks have posted an EOS message, the EOS message is
201 * forwarded to the application.
202 * Returns:
203 * The new EOS event.
205 public static Event newEOS()
207 // GstEvent* gst_event_new_eos (void);
208 return new Event(cast(GstEvent*)gst_event_new_eos() );
209 } /**
210 * Allocate a new flush start event. The flush start event can be send
211 * upstream and downstream and travels out-of-bounds with the dataflow.
212 * It marks pads as being in a WRONG_STATE to process more data.
213 * Elements unlock and blocking functions and exit their streaming functions
214 * as fast as possible.
215 * This event is typically generated after a seek to minimize the latency
216 * after the seek.
217 * Returns:
218 * A new flush start event.
220 public static Event newFlushStart()
222 // GstEvent* gst_event_new_flush_start (void);
223 return new Event(cast(GstEvent*)gst_event_new_flush_start() );
224 } /**
225 * Allocate a new flush stop event. The flush start event can be send
226 * upstream and downstream and travels out-of-bounds with the dataflow.
227 * It is typically send after sending a FLUSH_START event to make the
228 * pads accept data again.
229 * Elements can process this event synchronized with the dataflow since
230 * the preceeding FLUSH_START event stopped the dataflow.
231 * This event is typically generated to complete a seek and to resume
232 * dataflow.
233 * Returns:
234 * A new flush stop event.
236 public static Event newFlushStop()
238 // GstEvent* gst_event_new_flush_stop (void);
239 return new Event(cast(GstEvent*)gst_event_new_flush_stop() );
240 }/**
241 * Create a new navigation event from the given description.
242 * structure:
243 * description of the event
244 * Returns:
245 * a new GstEvent
247 public static Event newNavigation(Structure structure)
249 // GstEvent* gst_event_new_navigation (GstStructure *structure);
250 return new Event(cast(GstEvent*)gst_event_new_navigation((structure is null) ? null : structure.getStructureStruct()) );
273 * Access the structure of the event.
274 * event:
275 * The GstEvent.
276 * Returns:
277 * The structure of the event. The structure is still
278 * owned by the event, which means that you should not free it and
279 * that the pointer becomes invalid when you free the event.
280 * MT safe.
282 public Structure getStructure()
284 // const GstStructure* gst_event_get_structure (GstEvent *event);
285 return new Structure( gst_event_get_structure(gstEvent) );
290 * Create a new custom-typed event. This can be used for anything not
291 * handled by other event-specific functions to pass an event to another
292 * element.
293 * Make sure to allocate an event type with the GST_EVENT_MAKE_TYPE macro,
294 * assigning a free number and filling in the correct direction and
295 * serialization flags.
296 * New custom events can also be created by subclassing the event type if
297 * needed.
298 * type:
299 * The type of the new event
300 * structure:
301 * The structure for the event. The event will take ownership of
302 * the structure.
303 * Returns:
304 * The new custom event.
306 public this (GstEventType type, Structure structure)
308 // GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure);
309 this(cast(GstEvent*)gst_event_new_custom(type, (structure is null) ? null : structure.getStructureStruct()) );
316 * Create a new latency event. The event is sent upstream from the sinks and
317 * notifies elements that they should add an additional latency to the
318 * timestamps before synchronising against the clock.
319 * The latency is mostly used in live sinks and is always expressed in
320 * the time format.
321 * latency:
322 * the new latency value
323 * Returns:
324 * a new GstEvent
325 * Since 0.10.12
327 public this (GstClockTime latency)
329 // GstEvent* gst_event_new_latency (GstClockTime latency);
330 this(cast(GstEvent*)gst_event_new_latency(latency) );
335 * Allocate a new newsegment event with the given format/values tripplets
336 * This method calls gst_event_new_new_segment_full() passing a default
337 * value of 1.0 for applied_rate
338 * update:
339 * is this segment an update to a previous one
340 * rate:
341 * a new rate for playback
342 * format:
343 * The format of the segment values
344 * start:
345 * the start value of the segment
346 * stop:
347 * the stop value of the segment
348 * position:
349 * stream position
350 * Returns:
351 * A new newsegment event.
353 public this (int update, double rate, GstFormat format, long start, long stop, long position)
355 // GstEvent* gst_event_new_new_segment (gboolean update, gdouble rate, GstFormat format, gint64 start, gint64 stop, gint64 position);
356 this(cast(GstEvent*)gst_event_new_new_segment(update, rate, format, start, stop, position) );
360 * Allocate a new newsegment event with the given format/values triplets.
361 * The newsegment event marks the range of buffers to be processed. All
362 * data not within the segment range is not to be processed. This can be
363 * used intelligently by plugins to apply more efficient methods of skipping
364 * unneeded data.
365 * The position value of the segment is used in conjunction with the start
366 * value to convert the buffer timestamps into the stream time. This is
367 * usually done in sinks to report the current stream_time.
368 * position represents the stream_time of a buffer carrying a timestamp of
369 * start. position cannot be -1.
370 * start cannot be -1, stop can be -1. If there
371 * is a valid stop given, it must be greater or equal the start, including
372 * when the indicated playback rate is < 0.
373 * The applied_rate value provides information about any rate adjustment that
374 * has already been made to the timestamps and content on the buffers of the
375 * stream. (rate * applied_rate) should always equal the rate that has been
376 * requested for playback. For example, if an element has an input segment
377 * with intended playback rate of 2.0 and applied_rate of 1.0, it can adjust
378 * incoming timestamps and buffer content by half and output a newsegment event
379 * with rate of 1.0 and applied_rate of 2.0
380 * After a newsegment event, the buffer stream time is calculated with:
381 * position + (TIMESTAMP(buf) - start) * ABS (rate * applied_rate)
382 * update:
383 * Whether this segment is an update to a previous one
384 * rate:
385 * A new rate for playback
386 * applied_rate:
387 * The rate factor which has already been applied
388 * format:
389 * The format of the segment values
390 * start:
391 * The start value of the segment
392 * stop:
393 * The stop value of the segment
394 * position:
395 * stream position
396 * Returns:
397 * A new newsegment event.
398 * Since 0.10.6
400 public this (int update, double rate, double appliedRate, GstFormat format, long start, long stop, long position)
402 // GstEvent* gst_event_new_new_segment_full (gboolean update, gdouble rate, gdouble applied_rate, GstFormat format, gint64 start, gint64 stop, gint64 position);
403 this(cast(GstEvent*)gst_event_new_new_segment_full(update, rate, appliedRate, format, start, stop, position) );
407 * Allocate a new qos event with the given values.
408 * The QOS event is generated in an element that wants an upstream
409 * element to either reduce or increase its rate because of
410 * high/low CPU load or other resource usage such as network performance.
411 * Typically sinks generate these events for each buffer they receive.
412 * proportion indicates the real-time performance of the streaming in the
413 * element that generated the QoS event (usually the sink). The value is
414 * generally computed based on more long term statistics about the streams
415 * timestamps compared to the clock.
416 * A value < 1.0 indicates that the upstream element is producing data faster
417 * than real-time. A value > 1.0 indicates that the upstream element is not
418 * producing data fast enough. 1.0 is the ideal proportion value. The
419 * proportion value can safely be used to lower or increase the quality of
420 * the element.
421 * diff is the difference against the clock in running time of the last
422 * buffer that caused the element to generate the QOS event. A negative value
423 * means that the buffer with timestamp arrived in time. A positive value
424 * indicates how late the buffer with timestamp was.
425 * timestamp is the timestamp of the last buffer that cause the element
426 * to generate the QOS event. It is expressed in running time and thus an ever
427 * increasing value.
428 * The upstream element can use the diff and timestamp values to decide
429 * whether to process more buffers. For possitive diff, all buffers with
430 * timestamp <= timestamp + diff will certainly arrive late in the sink
431 * as well.
432 * The application can use general event probes to intercept the QoS
433 * event and implement custom application specific QoS handling.
434 * proportion:
435 * the proportion of the qos message
436 * diff:
437 * The time difference of the last Clock sync
438 * timestamp:
439 * The timestamp of the buffer
440 * Returns:
441 * A new QOS event.
443 public this (double proportion, GstClockTimeDiff diff, GstClockTime timestamp)
445 // GstEvent* gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp);
446 this(cast(GstEvent*)gst_event_new_qos(proportion, diff, timestamp) );
450 * Allocate a new seek event with the given parameters.
451 * The seek event configures playback of the pipeline between start to stop
452 * at the speed given in rate, also called a playback segment.
453 * The start and stop values are expressed in format.
454 * A rate of 1.0 means normal playback rate, 2.0 means double speed.
455 * Negatives values means backwards playback. A value of 0.0 for the
456 * rate is not allowed and should be accomplished instead by PAUSING the
457 * pipeline.
458 * A pipeline has a default playback segment configured with a start
459 * position of 0, a stop position of -1 and a rate of 1.0. The currently
460 * configured playback segment can be queried with GST_QUERY_SEGMENT.
461 * start_type and stop_type specify how to adjust the currently configured
462 * start and stop fields in segment. Adjustments can be made relative or
463 * absolute to the last configured values. A type of GST_SEEK_TYPE_NONE means
464 * that the position should not be updated.
465 * When the rate is positive and start has been updated, playback will start
466 * from the newly configured start position.
467 * For negative rates, playback will start from the newly configured stop
468 * position (if any). If the stop position if updated, it must be different from
469 * -1 for negative rates.
470 * It is not possible to seek relative to the current playback position, to do
471 * this, PAUSE the pipeline, query the current playback position with
472 * GST_QUERY_POSITION and update the playback segment current position with a
473 * GST_SEEK_TYPE_SET to the desired position.
474 * rate:
475 * The new playback rate
476 * format:
477 * The format of the seek values
478 * flags:
479 * The optional seek flags
480 * start_type:
481 * The type and flags for the new start position
482 * start:
483 * The value of the new start position
484 * stop_type:
485 * The type and flags for the new stop position
486 * stop:
487 * The value of the new stop position
488 * Returns:
489 * A new seek event.
491 public this (double rate, GstFormat format, GstSeekFlags flags, GstSeekType startType, long start, GstSeekType stopType, long stop)
493 // GstEvent* gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags, GstSeekType start_type, gint64 start, GstSeekType stop_type, gint64 stop);
494 this(cast(GstEvent*)gst_event_new_seek(rate, format, flags, startType, start, stopType, stop) );
498 * Generates a metadata tag event from the given taglist.
499 * taglist:
500 * metadata list
501 * Returns:
502 * a new GstEvent
504 public this (TagList taglist)
506 // GstEvent* gst_event_new_tag (GstTagList *taglist);
507 this(cast(GstEvent*)gst_event_new_tag((taglist is null) ? null : taglist.getTagListStruct()) );
511 * Get the format, minsize, maxsize and async-flag in the buffersize event.
512 * event:
513 * The event to query
514 * format:
515 * A pointer to store the format in
516 * minsize:
517 * A pointer to store the minsize in
518 * maxsize:
519 * A pointer to store the maxsize in
520 * async:
521 * A pointer to store the async-flag in
523 public void parseBufferSize(GstFormat* format, long* minsize, long* maxsize, int* async)
525 // void gst_event_parse_buffer_size (GstEvent *event, GstFormat *format, gint64 *minsize, gint64 *maxsize, gboolean *async);
526 gst_event_parse_buffer_size(gstEvent, format, minsize, maxsize, async);
530 * Get the latency in the latency event.
531 * event:
532 * The event to query
533 * latency:
534 * A pointer to store the latency in.
535 * Since 0.10.12
537 public void parseLatency(GstClockTime* latency)
539 // void gst_event_parse_latency (GstEvent *event, GstClockTime *latency);
540 gst_event_parse_latency(gstEvent, latency);
544 * Get the update flag, rate, format, start, stop and position in the
545 * newsegment event. In general, gst_event_parse_new_segment_full() should
546 * be used instead of this, to also retrieve the applied_rate value of the
547 * segment. See gst_event_new_new_segment_full() for a full description
548 * of the newsegment event.
549 * event:
550 * The event to query
551 * update:
552 * A pointer to the update flag of the segment
553 * rate:
554 * A pointer to the rate of the segment
555 * format:
556 * A pointer to the format of the newsegment values
557 * start:
558 * A pointer to store the start value in
559 * stop:
560 * A pointer to store the stop value in
561 * position:
562 * A pointer to store the stream time in
564 public void parseNewSegment(int* update, double* rate, GstFormat* format, long* start, long* stop, long* position)
566 // void gst_event_parse_new_segment (GstEvent *event, gboolean *update, gdouble *rate, GstFormat *format, gint64 *start, gint64 *stop, gint64 *position);
567 gst_event_parse_new_segment(gstEvent, update, rate, format, start, stop, position);
571 * Get the update, rate, applied_rate, format, start, stop and
572 * position in the newsegment event. See gst_event_new_new_segment_full()
573 * for a full description of the newsegment event.
574 * event:
575 * The event to query
576 * update:
577 * A pointer to the update flag of the segment
578 * rate:
579 * A pointer to the rate of the segment
580 * applied_rate:
581 * A pointer to the applied_rate of the segment
582 * format:
583 * A pointer to the format of the newsegment values
584 * start:
585 * A pointer to store the start value in
586 * stop:
587 * A pointer to store the stop value in
588 * position:
589 * A pointer to store the stream time in
590 * Since 0.10.6
592 public void parseNewSegmentFull(int* update, double* rate, double* appliedRate, GstFormat* format, long* start, long* stop, long* position)
594 // void gst_event_parse_new_segment_full (GstEvent *event, gboolean *update, gdouble *rate, gdouble *applied_rate, GstFormat *format, gint64 *start, gint64 *stop, gint64 *position);
595 gst_event_parse_new_segment_full(gstEvent, update, rate, appliedRate, format, start, stop, position);
599 * Get the proportion, diff and timestamp in the qos event. See
600 * gst_event_new_qos() for more information about the different QoS values.
601 * event:
602 * The event to query
603 * proportion:
604 * A pointer to store the proportion in
605 * diff:
606 * A pointer to store the diff in
607 * timestamp:
608 * A pointer to store the timestamp in
610 public void parseQos(double* proportion, GstClockTimeDiff* diff, GstClockTime* timestamp)
612 // void gst_event_parse_qos (GstEvent *event, gdouble *proportion, GstClockTimeDiff *diff, GstClockTime *timestamp);
613 gst_event_parse_qos(gstEvent, proportion, diff, timestamp);
617 * Parses a seek event and stores the results in the given result locations.
618 * event:
619 * a seek event
620 * rate:
621 * result location for the rate
622 * format:
623 * result location for the stream format
624 * flags:
625 * result location for the GstSeekFlags
626 * start_type:
627 * result location for the GstSeekType of the start position
628 * start:
629 * result location for the start postion expressed in format
630 * stop_type:
631 * result location for the GstSeekType of the stop position
632 * stop:
633 * result location for the stop postion expressed in format
635 public void parseSeek(double* rate, GstFormat* format, GstSeekFlags* flags, GstSeekType* startType, long* start, GstSeekType* stopType, long* stop)
637 // void gst_event_parse_seek (GstEvent *event, gdouble *rate, GstFormat *format, GstSeekFlags *flags, GstSeekType *start_type, gint64 *start, GstSeekType *stop_type, gint64 *stop);
638 gst_event_parse_seek(gstEvent, rate, format, flags, startType, start, stopType, stop);
642 * Parses a tag event and stores the results in the given taglist location.
643 * event:
644 * a tag event
645 * taglist:
646 * pointer to metadata list
648 public void parseTag(GstTagList** taglist)
650 // void gst_event_parse_tag (GstEvent *event, GstTagList **taglist);
651 gst_event_parse_tag(gstEvent, taglist);
655 * Increase the refcount of this event.
656 * event:
657 * The event to refcount
658 * Returns:
659 * event (for convenience when doing assignments)
661 public Event doref()
663 // GstEvent* gst_event_ref (GstEvent *event);
664 return new Event( gst_event_ref(gstEvent) );
670 * Gets the GstEventTypeFlags associated with type.
671 * type:
672 * a GstEventType
673 * Returns:
674 * a GstEventTypeFlags.
676 public static GstEventTypeFlags typeGetFlags(GstEventType type)
678 // GstEventTypeFlags gst_event_type_get_flags (GstEventType type);
679 return gst_event_type_get_flags(type);
683 * Get a printable name for the given event type. Do not modify or free.
684 * type:
685 * the event type
686 * Returns:
687 * a reference to the static name of the event.
689 public static char[] typeGetName(GstEventType type)
691 // const gchar* gst_event_type_get_name (GstEventType type);
692 return Str.toString(gst_event_type_get_name(type) );
696 * Get the unique quark for the given event type.
697 * type:
698 * the event type
699 * Returns:
700 * the quark associated with the event type
701 * See Also
702 * GstPad, GstElement
704 public static GQuark typeToQuark(GstEventType type)
706 // GQuark gst_event_type_to_quark (GstEventType type);
707 return gst_event_type_to_quark(type);