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
44 * - gst_event_new_buffer_size
46 * - gst_event_new_flush_start
47 * - gst_event_new_flush_stop
48 * - gst_event_new_navigation
51 * - gstreamer.Structure
53 * - gstreamer.MiniObject
55 * - GstEvent* -> Event
56 * - GstMiniObject -> MiniObject
57 * - GstMiniObject* -> MiniObject
58 * - GstStructure* -> Structure
59 * - GstTagList* -> TagList
64 module gstreamer
.Event
;
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
;
89 * The event class provides factory methods to construct and functions query
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
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,
116 * GST_SEEK_FLAG_FLUSH,
117 * GST_SEEK_TYPE_SET, 2 * GST_SECOND,
118 * GST_SEEK_TYPE_SET, 5 * GST_SECOND);
120 * result = gst_element_send_event (pipeline, event);
122 * g_warning ("seek failed");
124 * Last reviewed on 2006-09-6 (0.10.10)
129 /** the main Gtk struct */
130 protected GstEvent
* gstEvent
;
133 public GstEvent
* getEventStruct()
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
)
152 if ( gstEvent
is null )
157 Stdout("struct gstEvent is null on constructor").newline
;
161 printf("struct gstEvent is null on constructor");
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.
180 * minimum buffer size
182 * maximum buffer size
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
) );
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.
205 public static Event
newEOS()
207 // GstEvent* gst_event_new_eos (void);
208 return new Event(cast(GstEvent
*)gst_event_new_eos() );
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
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() );
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
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() );
241 * Create a new navigation event from the given description.
243 * description of the event
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.
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.
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
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
299 * The type of the new event
301 * The structure for the event. The event will take ownership of
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
322 * the new latency value
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
339 * is this segment an update to a previous one
341 * a new rate for playback
343 * The format of the segment values
345 * the start value of the segment
347 * the stop value of the segment
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
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)
383 * Whether this segment is an update to a previous one
385 * A new rate for playback
387 * The rate factor which has already been applied
389 * The format of the segment values
391 * The start value of the segment
393 * The stop value of the segment
397 * A new newsegment event.
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
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
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
432 * The application can use general event probes to intercept the QoS
433 * event and implement custom application specific QoS handling.
435 * the proportion of the qos message
437 * The time difference of the last Clock sync
439 * The timestamp of the buffer
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
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.
475 * The new playback rate
477 * The format of the seek values
479 * The optional seek flags
481 * The type and flags for the new start position
483 * The value of the new start position
485 * The type and flags for the new stop position
487 * The value of the new stop position
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.
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.
515 * A pointer to store the format in
517 * A pointer to store the minsize in
519 * A pointer to store the maxsize in
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.
534 * A pointer to store the latency in.
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.
552 * A pointer to the update flag of the segment
554 * A pointer to the rate of the segment
556 * A pointer to the format of the newsegment values
558 * A pointer to store the start value in
560 * A pointer to store the stop value in
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.
577 * A pointer to the update flag of the segment
579 * A pointer to the rate of the segment
581 * A pointer to the applied_rate of the segment
583 * A pointer to the format of the newsegment values
585 * A pointer to store the start value in
587 * A pointer to store the stop value in
589 * A pointer to store the stream time in
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.
604 * A pointer to store the proportion in
606 * A pointer to store the diff in
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.
621 * result location for the rate
623 * result location for the stream format
625 * result location for the GstSeekFlags
627 * result location for the GstSeekType of the start position
629 * result location for the start postion expressed in format
631 * result location for the GstSeekType of the stop position
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.
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.
657 * The event to refcount
659 * event (for convenience when doing assignments)
663 // GstEvent* gst_event_ref (GstEvent *event);
664 return new Event( gst_event_ref(gstEvent
) );
670 * Gets the GstEventTypeFlags associated with type.
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.
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.
700 * the quark associated with the event type
704 public static GQuark
typeToQuark(GstEventType type
)
706 // GQuark gst_event_type_to_quark (GstEventType type);
707 return gst_event_type_to_quark(type
);