alternative to assert
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Message.d
blob1e44752ad0a7e5cb2756e5f770fff4019403ce69
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-GstMessage.html
26 * outPack = gstreamer
27 * outFile = Message
28 * strct = GstMessage
29 * realStrct=
30 * ctorStrct=
31 * clss = Message
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_message_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * - gst_message_parse_tag
45 * - gst_message_type_to_quark
46 * - gst_message_new_element
47 * - gst_message_new_new_clock
48 * - gst_message_new_segment_done
49 * - gst_message_new_segment_start
50 * - gst_message_new_warning
51 * - gst_message_new_state_dirty
52 * - gst_message_new_eos
53 * - gst_message_new_error
54 * - gst_message_new_info
55 * imports:
56 * - glib.Str
57 * - glib.Quark
58 * - gstreamer.Structure
59 * - gstreamer.ObjectGst
60 * - gstreamer.Clock
61 * - glib.ErrorG
62 * - gstreamer.TagList
63 * structWrap:
64 * - GError* -> ErrorG
65 * - GQuark -> Quark
66 * - GstClock* -> Clock
67 * - GstMessage* -> Message
68 * - GstObject* -> ObjectGst
69 * - GstStructure* -> Structure
70 * - GstTagList* -> TagList
71 * module aliases:
72 * local aliases:
75 module gstreamer.Message;
77 private import gstreamerc.gstreamertypes;
79 private import gstreamerc.gstreamer;
81 private import glib.Str;
82 private import glib.Quark;
83 private import gstreamer.Structure;
84 private import gstreamer.ObjectGst;
85 private import gstreamer.Clock;
86 private import glib.ErrorG;
87 private import gstreamer.TagList;
91 /**
92 * Description
93 * Messages are implemented as a subclass of GstMiniObject with a generic
94 * GstStructure as the content. This allows for writing custom messages without
95 * requiring an API change while allowing a wide range of different types
96 * of messages.
97 * Messages are posted by objects in the pipeline and are passed to the
98 * application using the GstBus.
99 * The basic use pattern of posting a message on a GstBus is as follows:
100 * Example11.Posting a GstMessage
101 * gst_bus_post (bus, gst_message_new_eos());
102 * A GstElement usually posts messages on the bus provided by the parent
103 * container using gst_element_post_message().
104 * Last reviewed on 2005-11-09 (0.9.4)
106 public class Message
109 /** the main Gtk struct */
110 protected GstMessage* gstMessage;
113 public GstMessage* getMessageStruct()
115 return gstMessage;
119 /** the main Gtk struct as a void* */
120 protected void* getStruct()
122 return cast(void*)gstMessage;
126 * Sets our main struct and passes it to the parent class
128 public this (GstMessage* gstMessage)
130 this.gstMessage = gstMessage;
134 * Get the type of the message.
136 public GstMessageType type()
138 return getMessageStruct().type;
142 * Get the src (the element that originated the message) of the message.
144 public ObjectGst src()
146 return new ObjectGst( cast(GstObject*)getMessageStruct().src );
150 * Get the structure.
152 public Structure structure()
154 return new Structure( getMessageStruct().structure );
158 * Extracts the tag list from the GstMessage. The tag list returned in the
159 * output argument is a copy; the caller must free it when done.
160 * MT safe.
161 * message:
162 * A valid GstMessage of type GST_MESSAGE_TAG.
163 * tag_list:
164 * Return location for the tag-list.
166 /*public void parseTag(GstTagList** tagList)
168 // void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
169 gst_message_parse_tag(gstMessage, tagList);
171 public TagList parseTag()
173 // void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
174 GstTagList* tag_list_c;
175 gst_message_parse_tag(gstMessage, &tag_list_c);
176 return new TagList(tag_list_c);
179 //I'm not so sure about the following:
181 * Get the unique quark for the given message type.
182 * type:
183 * the message type
184 * Returns:
185 * the quark associated with the message type
187 public static Quark typeToQuark(GstMessageType type)
189 // GQuark gst_message_type_to_quark (GstMessageType type);
190 return new Quark( cast(uint*)gst_message_type_to_quark(type) );
194 * Create a new element-specific message. This is meant as a generic way of
195 * allowing one-way communication from an element to an application, for example
196 * "the firewire cable was unplugged". The format of the message should be
197 * documented in the element's documentation. The structure field can be NULL.
198 * src:
199 * The object originating the message.
200 * structure:
201 * The structure for the message. The message will take ownership of
202 * the structure.
203 * Returns:
204 * The new element message.
205 * MT safe.
207 public static Message newElement(ObjectGst src, Structure structure)
209 // GstMessage* gst_message_new_element (GstObject *src, GstStructure *structure);
210 return new Message(cast(GstMessage*)gst_message_new_element((src is null) ? null : src.getObjectGstStruct(), (structure is null) ? null : structure.getStructureStruct()) );
214 * Create a new clock message. This message is posted whenever the
215 * pipeline selectes a new clock for the pipeline.
216 * src:
217 * The object originating the message.
218 * clock:
219 * the new selected clock
220 * Returns:
221 * The new new clock message.
222 * MT safe.
224 public static Message newNewClock(ObjectGst src, Clock clock)
226 // GstMessage* gst_message_new_new_clock (GstObject *src, GstClock *clock);
227 return new Message(cast(GstMessage*)gst_message_new_new_clock((src is null) ? null : src.getObjectGstStruct(), (clock is null) ? null : clock.getClockStruct()) );
231 * Create a new segment done message. This message is posted by elements that
232 * finish playback of a segment as a result of a segment seek. This message
233 * is received by the application after all elements that posted a segment_start
234 * have posted the segment_done.
235 * src:
236 * The object originating the message.
237 * format:
238 * The format of the position being done
239 * position:
240 * The position of the segment being done
241 * Returns:
242 * The new segment done message.
243 * MT safe.
245 public static Message newSegmentDone(ObjectGst src, GstFormat format, long position)
247 // GstMessage* gst_message_new_segment_done (GstObject *src, GstFormat format, gint64 position);
248 return new Message(cast(GstMessage*)gst_message_new_segment_done((src is null) ? null : src.getObjectGstStruct(), format, position) );
252 * Create a new segment message. This message is posted by elements that
253 * start playback of a segment as a result of a segment seek. This message
254 * is not received by the application but is used for maintenance reasons in
255 * container elements.
256 * src:
257 * The object originating the message.
258 * format:
259 * The format of the position being played
260 * position:
261 * The position of the segment being played
262 * Returns:
263 * The new segment start message.
264 * MT safe.
266 public static Message newSegmentStart(ObjectGst src, GstFormat format, long position)
268 // GstMessage* gst_message_new_segment_start (GstObject *src, GstFormat format, gint64 position);
269 return new Message(cast(GstMessage*)gst_message_new_segment_start((src is null) ? null : src.getObjectGstStruct(), format, position) );
273 * Create a new warning message. The message will make copies of error and
274 * debug.
275 * src:
276 * The object originating the message.
277 * error:
278 * The GError for this message.
279 * debug:
280 * A debugging string for something or other.
281 * Returns:
282 * The new warning message.
283 * MT safe.
285 public static Message newWarning(ObjectGst src, ErrorG error, char[] dbug)
287 // GstMessage* gst_message_new_warning (GstObject *src, GError *error, gchar *debug);
288 return new Message(cast(GstMessage*)gst_message_new_warning((src is null) ? null : src.getObjectGstStruct(), (error is null) ? null : error.getErrorGStruct(), Str.toStringz(dbug)) );
292 * Create a state dirty message. This message is posted whenever an element
293 * changed its state asynchronously and is used internally to update the
294 * states of container objects.
295 * src:
296 * the object originating the message
297 * Returns:
298 * The new state dirty message.
299 * MT safe.
301 public static Message newStateDirty(ObjectGst src)
303 // GstMessage* gst_message_new_state_dirty (GstObject *src);
304 return new Message(cast(GstMessage*)gst_message_new_state_dirty((src is null) ? null : src.getObjectGstStruct()) );
308 * Create a new eos message. This message is generated and posted in
309 * the sink elements of a GstBin. The bin will only forward the EOS
310 * message to the application if all sinks have posted an EOS message.
311 * src:
312 * The object originating the message.
313 * Returns:
314 * The new eos message.
315 * MT safe.
317 public static Message newEOS(ObjectGst src)
319 // GstMessage* gst_message_new_eos (GstObject *src);
320 return new Message(cast(GstMessage*)gst_message_new_eos((src is null) ? null : src.getObjectGstStruct()) );
324 * Create a new error message. The message will copy error and
325 * debug. This message is posted by element when a fatal event
326 * occured. The pipeline will probably (partially) stop. The application
327 * receiving this message should stop the pipeline.
328 * src:
329 * The object originating the message.
330 * error:
331 * The GError for this message.
332 * debug:
333 * A debugging string for something or other.
334 * Returns:
335 * The new error message.
336 * MT safe.
338 public static Message newError(ObjectGst src, ErrorG error, char[] dbug)
340 // GstMessage* gst_message_new_error (GstObject *src, GError *error, gchar *debug);
341 return new Message(cast(GstMessage*)gst_message_new_error((src is null) ? null : src.getObjectGstStruct(), (error is null) ? null : error.getErrorGStruct(), Str.toStringz(dbug)) );
345 * Create a new info message. The message will make copies of error and
346 * debug.
347 * src:
348 * The object originating the message.
349 * error:
350 * The GError for this message.
351 * debug:
352 * A debugging string for something or other.
353 * Returns:
354 * The new info message.
355 * Since 0.10.12
356 * MT safe.
358 public static Message newInfo(ObjectGst src, ErrorG error, char[] dbug)
360 // GstMessage* gst_message_new_info (GstObject *src, GError *error, gchar *debug);
361 return new Message(cast(GstMessage*)gst_message_new_info((src is null) ? null : src.getObjectGstStruct(), (error is null) ? null : error.getErrorGStruct(), Str.toStringz(dbug)) );
376 * Get a printable name for the given message type. Do not modify or free.
377 * type:
378 * the message type
379 * Returns:
380 * a reference to the static name of the message.
382 public static char[] typeGetName(GstMessageType type)
384 // const gchar* gst_message_type_get_name (GstMessageType type);
385 return Str.toString(gst_message_type_get_name(type) );
390 * Access the structure of the message.
391 * message:
392 * The GstMessage.
393 * Returns:
394 * The structure of the message. The structure is still
395 * owned by the message, which means that you should not free it and
396 * that the pointer becomes invalid when you free the message.
397 * MT safe.
399 public Structure getStructure()
401 // const GstStructure* gst_message_get_structure (GstMessage *message);
402 return new Structure( gst_message_get_structure(gstMessage) );
407 * Create a new application-typed message. GStreamer will never create these
408 * messages; they are a gift from us to you. Enjoy.
409 * src:
410 * The object originating the message.
411 * structure:
412 * The structure for the message. The message will take ownership of
413 * the structure.
414 * Returns:
415 * The new application message.
416 * MT safe.
418 public this (ObjectGst src, Structure structure)
420 // GstMessage* gst_message_new_application (GstObject *src, GstStructure *structure);
421 this(cast(GstMessage*)gst_message_new_application((src is null) ? null : src.getObjectGstStruct(), (structure is null) ? null : structure.getStructureStruct()) );
425 * Create a clock provide message. This message is posted whenever an
426 * element is ready to provide a clock or lost its ability to provide
427 * a clock (maybe because it paused or became EOS).
428 * This message is mainly used internally to manage the clock
429 * selection.
430 * src:
431 * The object originating the message.
432 * clock:
433 * The clock it provides
434 * ready:
435 * TRUE if the sender can provide a clock
436 * Returns:
437 * The new provide clock message.
438 * MT safe.
440 public this (ObjectGst src, Clock clock, int ready)
442 // GstMessage* gst_message_new_clock_provide (GstObject *src, GstClock *clock, gboolean ready);
443 this(cast(GstMessage*)gst_message_new_clock_provide((src is null) ? null : src.getObjectGstStruct(), (clock is null) ? null : clock.getClockStruct(), ready) );
447 * Create a clock lost message. This message is posted whenever the
448 * clock is not valid anymore.
449 * If this message is posted by the pipeline, the pipeline will
450 * select a new clock again when it goes to PLAYING. It might therefore
451 * be needed to set the pipeline to PAUSED and PLAYING again.
452 * src:
453 * The object originating the message.
454 * clock:
455 * the clock that was lost
456 * Returns:
457 * The new clock lost message.
458 * MT safe.
460 public this (ObjectGst src, Clock clock)
462 // GstMessage* gst_message_new_clock_lost (GstObject *src, GstClock *clock);
463 this(cast(GstMessage*)gst_message_new_clock_lost((src is null) ? null : src.getObjectGstStruct(), (clock is null) ? null : clock.getClockStruct()) );
467 * Create a new custom-typed message. This can be used for anything not
468 * handled by other message-specific functions to pass a message to the
469 * app. The structure field can be NULL.
470 * type:
471 * The GstMessageType to distinguish messages
472 * src:
473 * The object originating the message.
474 * structure:
475 * The structure for the message. The message will take ownership of
476 * the structure.
477 * Returns:
478 * The new message.
479 * MT safe.
481 public this (GstMessageType type, ObjectGst src, Structure structure)
483 // GstMessage* gst_message_new_custom (GstMessageType type, GstObject *src, GstStructure *structure);
484 this(cast(GstMessage*)gst_message_new_custom(type, (src is null) ? null : src.getObjectGstStruct(), (structure is null) ? null : structure.getStructureStruct()) );
495 * Create a state change message. This message is posted whenever an element
496 * changed its state.
497 * src:
498 * the object originating the message
499 * oldstate:
500 * the previous state
501 * newstate:
502 * the new (current) state
503 * pending:
504 * the pending (target) state
505 * Returns:
506 * The new state change message.
507 * MT safe.
509 public this (ObjectGst src, GstState oldstate, GstState newstate, GstState pending)
511 // GstMessage* gst_message_new_state_changed (GstObject *src, GstState oldstate, GstState newstate, GstState pending);
512 this(cast(GstMessage*)gst_message_new_state_changed((src is null) ? null : src.getObjectGstStruct(), oldstate, newstate, pending) );
516 * Create a new tag message. The message will take ownership of the tag list.
517 * The message is posted by elements that discovered a new taglist.
518 * src:
519 * The object originating the message.
520 * tag_list:
521 * The tag list for the message.
522 * Returns:
523 * The new tag message.
524 * MT safe.
526 public this (ObjectGst src, TagList tagList)
528 // GstMessage* gst_message_new_tag (GstObject *src, GstTagList *tag_list);
529 this(cast(GstMessage*)gst_message_new_tag((src is null) ? null : src.getObjectGstStruct(), (tagList is null) ? null : tagList.getTagListStruct()) );
533 * Create a new buffering message. This message can be posted by an element that
534 * needs to buffer data before it can continue processing. percent should be a
535 * value between 0 and 100. A value of 100 means that the buffering completed.
536 * When percent is < 100 the application should PAUSE a PLAYING pipeline. When
537 * percent is 100, the application can set the pipeline (back) to PLAYING.
538 * The application must be prepared to receive BUFFERING messages in the
539 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
540 * message with percent set to 100, which can happen after the pipeline
541 * completed prerolling.
542 * src:
543 * The object originating the message.
544 * percent:
545 * The buffering percent
546 * Returns:
547 * The new buffering message.
548 * Since 0.10.11
549 * MT safe.
551 public this (ObjectGst src, int percent)
553 // GstMessage* gst_message_new_buffering (GstObject *src, gint percent);
554 this(cast(GstMessage*)gst_message_new_buffering((src is null) ? null : src.getObjectGstStruct(), percent) );
559 * Create a new duration message. This message is posted by elements that
560 * know the duration of a stream in a specific format. This message
561 * is received by bins and is used to calculate the total duration of a
562 * pipeline. Elements may post a duration message with a duration of
563 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
564 * cached duration should be discarded. The new duration can then be
565 * retrieved via a query.
566 * src:
567 * The object originating the message.
568 * format:
569 * The format of the duration
570 * duration:
571 * The new duration
572 * Returns:
573 * The new duration message.
574 * MT safe.
576 public this (ObjectGst src, GstFormat format, long duration)
578 // GstMessage* gst_message_new_duration (GstObject *src, GstFormat format, gint64 duration);
579 this(cast(GstMessage*)gst_message_new_duration((src is null) ? null : src.getObjectGstStruct(), format, duration) );
584 * This message can be posted by elements when their latency requirements have
585 * changed.
586 * src:
587 * The object originating the message.
588 * Returns:
589 * The new latency message.
590 * MT safe.
591 * Since 0.10.12
593 public this (ObjectGst src)
595 // GstMessage* gst_message_new_latency (GstObject *src);
596 this(cast(GstMessage*)gst_message_new_latency((src is null) ? null : src.getObjectGstStruct()) );
600 * Extracts the lost clock from the GstMessage.
601 * The clock object returned remains valid until the message is freed.
602 * MT safe.
603 * message:
604 * A valid GstMessage of type GST_MESSAGE_CLOCK_LOST.
605 * clock:
606 * A pointer to hold the lost clock
608 public void parseClockLost(GstClock** clock)
610 // void gst_message_parse_clock_lost (GstMessage *message, GstClock **clock);
611 gst_message_parse_clock_lost(gstMessage, clock);
615 * Extracts the clock and ready flag from the GstMessage.
616 * The clock object returned remains valid until the message is freed.
617 * MT safe.
618 * message:
619 * A valid GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
620 * clock:
621 * A pointer to hold a clock object.
622 * ready:
623 * A pointer to hold the ready flag.
625 public void parseClockProvide(GstClock** clock, int* ready)
627 // void gst_message_parse_clock_provide (GstMessage *message, GstClock **clock, gboolean *ready);
628 gst_message_parse_clock_provide(gstMessage, clock, ready);
632 * Extracts the GError and debug string from the GstMessage. The values returned
633 * in the output arguments are copies; the caller must free them when done.
634 * MT safe.
635 * message:
636 * A valid GstMessage of type GST_MESSAGE_ERROR.
637 * gerror:
638 * Location for the GError
639 * debug:
640 * Location for the debug message, or NULL
642 public void parseError(GError** gerror, char** dbug)
644 // void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug);
645 gst_message_parse_error(gstMessage, gerror, dbug);
649 * Extracts the GError and debug string from the GstMessage. The values returned
650 * in the output arguments are copies; the caller must free them when done.
651 * MT safe.
652 * message:
653 * A valid GstMessage of type GST_MESSAGE_INFO.
654 * gerror:
655 * Location for the GError
656 * debug:
657 * Location for the debug message, or NULL
658 * Since 0.10.12
660 public void parseInfo(GError** gerror, char** dbug)
662 // void gst_message_parse_info (GstMessage *message, GError **gerror, gchar **debug);
663 gst_message_parse_info(gstMessage, gerror, dbug);
667 * Extracts the new clock from the GstMessage.
668 * The clock object returned remains valid until the message is freed.
669 * MT safe.
670 * message:
671 * A valid GstMessage of type GST_MESSAGE_NEW_CLOCK.
672 * clock:
673 * A pointer to hold the selected new clock
675 public void parseNewClock(GstClock** clock)
677 // void gst_message_parse_new_clock (GstMessage *message, GstClock **clock);
678 gst_message_parse_new_clock(gstMessage, clock);
682 * Extracts the position and format from the segment start message.
683 * MT safe.
684 * message:
685 * A valid GstMessage of type GST_MESSAGE_SEGMENT_DONE.
686 * format:
687 * Result location for the format, or NULL
688 * position:
689 * Result location for the position, or NULL
691 public void parseSegmentDone(GstFormat* format, long* position)
693 // void gst_message_parse_segment_done (GstMessage *message, GstFormat *format, gint64 *position);
694 gst_message_parse_segment_done(gstMessage, format, position);
698 * Extracts the position and format from the segment start message.
699 * MT safe.
700 * message:
701 * A valid GstMessage of type GST_MESSAGE_SEGMENT_START.
702 * format:
703 * Result location for the format, or NULL
704 * position:
705 * Result location for the position, or NULL
707 public void parseSegmentStart(GstFormat* format, long* position)
709 // void gst_message_parse_segment_start (GstMessage *message, GstFormat *format, gint64 *position);
710 gst_message_parse_segment_start(gstMessage, format, position);
714 * Extracts the old and new states from the GstMessage.
715 * MT safe.
716 * message:
717 * a valid GstMessage of type GST_MESSAGE_STATE_CHANGED
718 * oldstate:
719 * the previous state, or NULL
720 * newstate:
721 * the new (current) state, or NULL
722 * pending:
723 * the pending (target) state, or NULL
725 public void parseStateChanged(GstState* oldstate, GstState* newstate, GstState* pending)
727 // void gst_message_parse_state_changed (GstMessage *message, GstState *oldstate, GstState *newstate, GstState *pending);
728 gst_message_parse_state_changed(gstMessage, oldstate, newstate, pending);
733 * Extracts the buffering percent from the GstMessage. see also
734 * gst_message_new_buffering().
735 * message:
736 * A valid GstMessage of type GST_MESSAGE_BUFFERING.
737 * percent:
738 * Return location for the percent.
739 * Since 0.10.11
740 * MT safe.
742 public void parseBuffering(int* percent)
744 // void gst_message_parse_buffering (GstMessage *message, gint *percent);
745 gst_message_parse_buffering(gstMessage, percent);
749 * Extracts the GError and debug string from the GstMessage. The values returned
750 * in the output arguments are copies; the caller must free them when done.
751 * MT safe.
752 * message:
753 * A valid GstMessage of type GST_MESSAGE_WARNING.
754 * gerror:
755 * Location for the GError
756 * debug:
757 * Location for the debug message, or NULL
759 public void parseWarning(GError** gerror, char** dbug)
761 // void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug);
762 gst_message_parse_warning(gstMessage, gerror, dbug);
766 * Extracts the duration and format from the duration message. The duration
767 * might be GST_CLOCK_TIME_NONE, which indicates that the duration has
768 * changed. Applications should always use a query to retrieve the duration
769 * of a pipeline.
770 * MT safe.
771 * message:
772 * A valid GstMessage of type GST_MESSAGE_DURATION.
773 * format:
774 * Result location for the format, or NULL
775 * duration:
776 * Result location for the duration, or NULL
778 public void parseDuration(GstFormat* format, long* duration)
780 // void gst_message_parse_duration (GstMessage *message, GstFormat *format, gint64 *duration);
781 gst_message_parse_duration(gstMessage, format, duration);
785 * Convenience macro to increase the reference count of the message.
786 * msg:
787 * the message to ref
788 * Returns:
789 * msg (for convenience when doing assignments)
791 public Message doref()
793 // GstMessage* gst_message_ref (GstMessage *msg);
794 return new Message( gst_message_ref(gstMessage) );