2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
4 * gstmessage.c: GstMessage subsystem
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
24 * @short_description: Lightweight objects to signal the application of
26 * @see_also: #GstBus, #GstMiniObject, #GstElement
28 * Messages are implemented as a subclass of #GstMiniObject with a generic
29 * #GstStructure as the content. This allows for writing custom messages without
30 * requiring an API change while allowing a wide range of different types
33 * Messages are posted by objects in the pipeline and are passed to the
34 * application using the #GstBus.
36 * The basic use pattern of posting a message on a #GstBus is as follows:
39 * <title>Posting a #GstMessage</title>
41 * gst_bus_post (bus, gst_message_new_eos());
45 * A #GstElement usually posts messages on the bus provided by the parent
46 * container using gst_element_post_message().
48 * Last reviewed on 2005-11-09 (0.9.4)
52 #include "gst_private.h"
53 #include <string.h> /* memcpy */
55 #include "gstenumtypes.h"
57 #include "gstmessage.h"
58 #include "gsttaglist.h"
63 #define GST_MESSAGE_SEQNUM(e) ((GstMessage*)e)->abidata.ABI.seqnum
65 static void gst_message_finalize (GstMessage * message);
66 static GstMessage *_gst_message_copy (GstMessage * message);
68 static GstMiniObjectClass *parent_class = NULL;
71 _gst_message_initialize (void)
73 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
75 /* the GstMiniObject types need to be class_ref'd once before it can be
76 * done from multiple threads;
77 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
78 g_type_class_ref (gst_message_get_type ());
88 static GstMessageQuarks message_quarks[] = {
89 {GST_MESSAGE_UNKNOWN, "unknown", 0},
90 {GST_MESSAGE_EOS, "eos", 0},
91 {GST_MESSAGE_ERROR, "error", 0},
92 {GST_MESSAGE_WARNING, "warning", 0},
93 {GST_MESSAGE_INFO, "info", 0},
94 {GST_MESSAGE_TAG, "tag", 0},
95 {GST_MESSAGE_BUFFERING, "buffering", 0},
96 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
97 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
98 {GST_MESSAGE_STEP_DONE, "step-done", 0},
99 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
100 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
101 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
102 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
103 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
104 {GST_MESSAGE_APPLICATION, "application", 0},
105 {GST_MESSAGE_ELEMENT, "element", 0},
106 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
107 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
108 {GST_MESSAGE_DURATION, "duration", 0},
109 {GST_MESSAGE_LATENCY, "latency", 0},
110 {GST_MESSAGE_ASYNC_START, "async-start", 0},
111 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
112 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
113 {GST_MESSAGE_STEP_START, "step-start", 0},
118 * gst_message_type_get_name:
119 * @type: the message type
121 * Get a printable name for the given message type. Do not modify or free.
123 * Returns: a reference to the static name of the message.
126 gst_message_type_get_name (GstMessageType type)
130 for (i = 0; message_quarks[i].name; i++) {
131 if (type == message_quarks[i].type)
132 return message_quarks[i].name;
138 * gst_message_type_to_quark:
139 * @type: the message type
141 * Get the unique quark for the given message type.
143 * Returns: the quark associated with the message type
146 gst_message_type_to_quark (GstMessageType type)
150 for (i = 0; message_quarks[i].name; i++) {
151 if (type == message_quarks[i].type)
152 return message_quarks[i].quark;
161 for (i = 0; message_quarks[i].name; i++) { \
162 message_quarks[i].quark = \
163 g_quark_from_static_string (message_quarks[i].name); \
167 G_DEFINE_TYPE_WITH_CODE (GstMessage, gst_message, GST_TYPE_MINI_OBJECT,
171 gst_message_class_init (GstMessageClass * klass)
173 parent_class = g_type_class_peek_parent (klass);
175 klass->mini_object_class.copy = (GstMiniObjectCopyFunction) _gst_message_copy;
176 klass->mini_object_class.finalize =
177 (GstMiniObjectFinalizeFunction) gst_message_finalize;
181 gst_message_init (GstMessage * message)
183 GST_CAT_LOG (GST_CAT_MESSAGE, "new message %p", message);
184 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
188 gst_message_finalize (GstMessage * message)
190 g_return_if_fail (message != NULL);
192 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p", message);
194 if (GST_MESSAGE_SRC (message)) {
195 gst_object_unref (GST_MESSAGE_SRC (message));
196 GST_MESSAGE_SRC (message) = NULL;
200 GST_MESSAGE_LOCK (message);
201 GST_MESSAGE_SIGNAL (message);
202 GST_MESSAGE_UNLOCK (message);
205 if (message->structure) {
206 gst_structure_set_parent_refcount (message->structure, NULL);
207 gst_structure_free (message->structure);
210 /* GST_MINI_OBJECT_CLASS (parent_class)->finalize (GST_MINI_OBJECT (message)); */
214 _gst_message_copy (GstMessage * message)
218 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p", message);
220 copy = (GstMessage *) gst_mini_object_new (GST_TYPE_MESSAGE);
222 /* FIXME, need to copy relevant data from the miniobject. */
223 //memcpy (copy, message, sizeof (GstMessage));
225 GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message);
226 GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message);
227 GST_MESSAGE_TYPE (copy) = GST_MESSAGE_TYPE (message);
228 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
229 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
231 if (GST_MESSAGE_SRC (message)) {
232 GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
235 if (message->structure) {
236 copy->structure = gst_structure_copy (message->structure);
237 gst_structure_set_parent_refcount (copy->structure,
238 ©->mini_object.refcount);
245 * gst_message_new_custom:
246 * @type: The #GstMessageType to distinguish messages
247 * @src: The object originating the message.
248 * @structure: The structure for the message. The message will take ownership of
251 * Create a new custom-typed message. This can be used for anything not
252 * handled by other message-specific functions to pass a message to the
253 * app. The structure field can be NULL.
255 * Returns: The new message.
260 gst_message_new_custom (GstMessageType type, GstObject * src,
261 GstStructure * structure)
265 message = (GstMessage *) gst_mini_object_new (GST_TYPE_MESSAGE);
267 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
268 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
269 gst_message_type_get_name (type));
271 message->type = type;
274 gst_object_ref (src);
278 gst_structure_set_parent_refcount (structure,
279 &message->mini_object.refcount);
281 message->structure = structure;
283 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
289 * gst_message_get_seqnum:
290 * @message: A #GstMessage.
292 * Retrieve the sequence number of a message.
294 * Messages have ever-incrementing sequence numbers, which may also be set
295 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
296 * to indicate that a message corresponds to some other set of messages or
297 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
298 * is considered good practice to make this correspondence when possible, though
299 * it is not required.
301 * Note that events and messages share the same sequence number incrementor;
302 * two events or messages will never not have the same sequence number unless
303 * that correspondence was made explicitly.
305 * Returns: The message's sequence number.
312 gst_message_get_seqnum (GstMessage * message)
314 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
316 return GST_MESSAGE_SEQNUM (message);
320 * gst_message_set_seqnum:
321 * @message: A #GstMessage.
322 * @seqnum: A sequence number.
324 * Set the sequence number of a message.
326 * This function might be called by the creator of a message to indicate that
327 * the message relates to other messages or events. See gst_message_get_seqnum()
328 * for more information.
335 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
337 g_return_if_fail (GST_IS_MESSAGE (message));
339 GST_MESSAGE_SEQNUM (message) = seqnum;
343 * gst_message_new_eos:
344 * @src: The object originating the message.
346 * Create a new eos message. This message is generated and posted in
347 * the sink elements of a GstBin. The bin will only forward the EOS
348 * message to the application if all sinks have posted an EOS message.
350 * Returns: The new eos message.
355 gst_message_new_eos (GstObject * src)
359 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
365 * gst_message_new_error:
366 * @src: The object originating the message.
367 * @error: The GError for this message.
368 * @debug: A debugging string.
370 * Create a new error message. The message will copy @error and
371 * @debug. This message is posted by element when a fatal event
372 * occured. The pipeline will probably (partially) stop. The application
373 * receiving this message should stop the pipeline.
375 * Returns: The new error message.
380 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
383 GstStructure *structure;
385 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ERROR),
386 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
387 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
388 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
394 * gst_message_new_warning:
395 * @src: The object originating the message.
396 * @error: The GError for this message.
397 * @debug: A debugging string.
399 * Create a new warning message. The message will make copies of @error and
402 * Returns: The new warning message.
407 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
410 GstStructure *structure;
412 structure = gst_structure_id_new (GST_QUARK (MESSAGE_WARNING),
413 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
414 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
415 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
421 * gst_message_new_info:
422 * @src: The object originating the message.
423 * @error: The GError for this message.
424 * @debug: A debugging string.
426 * Create a new info message. The message will make copies of @error and
431 * Returns: The new info message.
436 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
439 GstStructure *structure;
441 structure = gst_structure_id_new (GST_QUARK (MESSAGE_INFO),
442 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
443 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
444 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
450 * gst_message_new_tag:
451 * @src: The object originating the message.
452 * @tag_list: The tag list for the message.
454 * Create a new tag message. The message will take ownership of the tag list.
455 * The message is posted by elements that discovered a new taglist.
457 * Returns: The new tag message.
462 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
466 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
469 gst_message_new_custom (GST_MESSAGE_TAG, src, (GstStructure *) tag_list);
475 * gst_message_new_tag_full:
476 * @src: The object originating the message.
477 * @pad: The originating pad for the tag.
478 * @tag_list: The tag list for the message.
480 * Create a new tag message. The message will take ownership of the tag list.
481 * The message is posted by elements that discovered a new taglist.
485 * Returns: The new tag message.
490 gst_message_new_tag_full (GstObject * src, GstPad * pad, GstTagList * tag_list)
495 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
496 g_return_val_if_fail (pad == NULL || GST_IS_PAD (pad), NULL);
498 s = (GstStructure *) tag_list;
500 gst_structure_set (s, "source-pad", GST_TYPE_PAD, pad, NULL);
502 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
508 * gst_message_new_buffering:
509 * @src: The object originating the message.
510 * @percent: The buffering percent
512 * Create a new buffering message. This message can be posted by an element that
513 * needs to buffer data before it can continue processing. @percent should be a
514 * value between 0 and 100. A value of 100 means that the buffering completed.
516 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
517 * @percent is 100, the application can set the pipeline (back) to PLAYING.
518 * The application must be prepared to receive BUFFERING messages in the
519 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
520 * message with @percent set to 100, which can happen after the pipeline
521 * completed prerolling.
525 * Returns: The new buffering message.
530 gst_message_new_buffering (GstObject * src, gint percent)
533 GstStructure *structure;
535 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
537 structure = gst_structure_id_new (GST_QUARK (MESSAGE_BUFFERING),
538 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
539 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
540 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
541 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
542 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
543 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
544 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
550 * gst_message_new_state_changed:
551 * @src: the object originating the message
552 * @oldstate: the previous state
553 * @newstate: the new (current) state
554 * @pending: the pending (target) state
556 * Create a state change message. This message is posted whenever an element
559 * Returns: The new state change message.
564 gst_message_new_state_changed (GstObject * src,
565 GstState oldstate, GstState newstate, GstState pending)
568 GstStructure *structure;
570 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STATE),
571 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
572 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
573 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
574 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
580 * gst_message_new_state_dirty:
581 * @src: the object originating the message
583 * Create a state dirty message. This message is posted whenever an element
584 * changed its state asynchronously and is used internally to update the
585 * states of container objects.
587 * Returns: The new state dirty message.
592 gst_message_new_state_dirty (GstObject * src)
596 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
602 * gst_message_new_clock_provide:
603 * @src: The object originating the message.
604 * @clock: The clock it provides
605 * @ready: TRUE if the sender can provide a clock
607 * Create a clock provide message. This message is posted whenever an
608 * element is ready to provide a clock or lost its ability to provide
609 * a clock (maybe because it paused or became EOS).
611 * This message is mainly used internally to manage the clock
614 * Returns: The new provide clock message.
619 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
623 GstStructure *structure;
625 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
626 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
627 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
628 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
634 * gst_message_new_clock_lost:
635 * @src: The object originating the message.
636 * @clock: the clock that was lost
638 * Create a clock lost message. This message is posted whenever the
639 * clock is not valid anymore.
641 * If this message is posted by the pipeline, the pipeline will
642 * select a new clock again when it goes to PLAYING. It might therefore
643 * be needed to set the pipeline to PAUSED and PLAYING again.
645 * Returns: The new clock lost message.
650 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
653 GstStructure *structure;
655 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_LOST),
656 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
657 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
663 * gst_message_new_new_clock:
664 * @src: The object originating the message.
665 * @clock: the new selected clock
667 * Create a new clock message. This message is posted whenever the
668 * pipeline selectes a new clock for the pipeline.
670 * Returns: The new new clock message.
675 gst_message_new_new_clock (GstObject * src, GstClock * clock)
678 GstStructure *structure;
680 structure = gst_structure_id_new (GST_QUARK (MESSAGE_NEW_CLOCK),
681 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
682 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
688 * gst_message_new_structure_change:
689 * @src: The object originating the message.
690 * @type: The change type.
691 * @owner: The owner element of @src.
692 * @busy: Whether the structure change is busy.
694 * Create a new structure change message. This message is posted when the
695 * structure of a pipeline is in the process of being changed, for example
696 * when pads are linked or unlinked.
698 * @src should be the srcpad that unlinked or linked.
700 * Returns: The new structure change message.
707 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
708 GstElement * owner, gboolean busy)
711 GstStructure *structure;
713 g_return_val_if_fail (GST_IS_PAD (src), NULL);
714 g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SRC, NULL);
715 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
717 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
718 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
719 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
720 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
722 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
729 * gst_message_new_segment_start:
730 * @src: The object originating the message.
731 * @format: The format of the position being played
732 * @position: The position of the segment being played
734 * Create a new segment message. This message is posted by elements that
735 * start playback of a segment as a result of a segment seek. This message
736 * is not received by the application but is used for maintenance reasons in
737 * container elements.
739 * Returns: The new segment start message.
744 gst_message_new_segment_start (GstObject * src, GstFormat format,
748 GstStructure *structure;
750 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_START),
751 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
752 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
753 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
759 * gst_message_new_segment_done:
760 * @src: The object originating the message.
761 * @format: The format of the position being done
762 * @position: The position of the segment being done
764 * Create a new segment done message. This message is posted by elements that
765 * finish playback of a segment as a result of a segment seek. This message
766 * is received by the application after all elements that posted a segment_start
767 * have posted the segment_done.
769 * Returns: The new segment done message.
774 gst_message_new_segment_done (GstObject * src, GstFormat format,
778 GstStructure *structure;
780 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_DONE),
781 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
782 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
783 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
789 * gst_message_new_application:
790 * @src: The object originating the message.
791 * @structure: The structure for the message. The message will take ownership of
794 * Create a new application-typed message. GStreamer will never create these
795 * messages; they are a gift from us to you. Enjoy.
797 * Returns: The new application message.
802 gst_message_new_application (GstObject * src, GstStructure * structure)
804 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
808 * gst_message_new_element:
809 * @src: The object originating the message.
810 * @structure: The structure for the message. The message will take ownership of
813 * Create a new element-specific message. This is meant as a generic way of
814 * allowing one-way communication from an element to an application, for example
815 * "the firewire cable was unplugged". The format of the message should be
816 * documented in the element's documentation. The structure field can be NULL.
818 * Returns: The new element message.
823 gst_message_new_element (GstObject * src, GstStructure * structure)
825 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
829 * gst_message_new_duration:
830 * @src: The object originating the message.
831 * @format: The format of the duration
832 * @duration: The new duration
834 * Create a new duration message. This message is posted by elements that
835 * know the duration of a stream in a specific format. This message
836 * is received by bins and is used to calculate the total duration of a
837 * pipeline. Elements may post a duration message with a duration of
838 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
839 * cached duration should be discarded. The new duration can then be
840 * retrieved via a query.
842 * Returns: The new duration message.
847 gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration)
850 GstStructure *structure;
852 structure = gst_structure_id_new (GST_QUARK (MESSAGE_DURATION),
853 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
854 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
855 message = gst_message_new_custom (GST_MESSAGE_DURATION, src, structure);
861 * gst_message_new_async_start:
862 * @src: The object originating the message.
863 * @new_base_time: if a new base_time should be set on the element
865 * This message is posted by elements when they start an ASYNC state change.
866 * @new_base_time is set to TRUE when the element lost its state when it was
869 * Returns: The new async_start message.
876 gst_message_new_async_start (GstObject * src, gboolean new_base_time)
879 GstStructure *structure;
881 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ASYNC_START),
882 GST_QUARK (NEW_BASE_TIME), G_TYPE_BOOLEAN, new_base_time, NULL);
883 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, structure);
889 * gst_message_new_async_done:
890 * @src: The object originating the message.
892 * The message is posted when elements completed an ASYNC state change.
894 * Returns: The new async_done message.
901 gst_message_new_async_done (GstObject * src)
905 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, NULL);
911 * gst_message_new_latency:
912 * @src: The object originating the message.
914 * This message can be posted by elements when their latency requirements have
917 * Returns: The new latency message.
924 gst_message_new_latency (GstObject * src)
928 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
934 * gst_message_new_request_state:
935 * @src: The object originating the message.
936 * @state: The new requested state
938 * This message can be posted by elements when they want to have their state
939 * changed. A typical use case would be an audio server that wants to pause the
940 * pipeline because a higher priority stream is being played.
942 * Returns: The new requst state message.
949 gst_message_new_request_state (GstObject * src, GstState state)
952 GstStructure *structure;
954 structure = gst_structure_id_new (GST_QUARK (MESSAGE_REQUEST_STATE),
955 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
956 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
962 * gst_message_get_structure:
963 * @message: The #GstMessage.
965 * Access the structure of the message.
967 * Returns: The structure of the message. The structure is still
968 * owned by the message, which means that you should not free it and
969 * that the pointer becomes invalid when you free the message.
974 gst_message_get_structure (GstMessage * message)
976 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
978 return message->structure;
982 * gst_message_parse_tag:
983 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
984 * @tag_list: Return location for the tag-list.
986 * Extracts the tag list from the GstMessage. The tag list returned in the
987 * output argument is a copy; the caller must free it when done.
992 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
996 g_return_if_fail (GST_IS_MESSAGE (message));
997 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
998 g_return_if_fail (tag_list != NULL);
1000 ret = gst_structure_copy (message->structure);
1001 gst_structure_remove_field (ret, "source-pad");
1003 *tag_list = (GstTagList *) ret;
1007 * gst_message_parse_tag_full:
1008 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1009 * @pad: Location where the originating pad is stored, unref after usage
1010 * @tag_list: Return location for the tag-list.
1012 * Extracts the tag list from the GstMessage. The tag list returned in the
1013 * output argument is a copy; the caller must free it when done.
1020 gst_message_parse_tag_full (GstMessage * message, GstPad ** pad,
1021 GstTagList ** tag_list)
1025 g_return_if_fail (GST_IS_MESSAGE (message));
1026 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1027 g_return_if_fail (tag_list != NULL);
1029 ret = gst_structure_copy (message->structure);
1031 if (gst_structure_has_field (ret, "source-pad") && pad) {
1034 v = gst_structure_get_value (ret, "source-pad");
1035 if (v && G_VALUE_HOLDS (v, GST_TYPE_PAD))
1036 *pad = g_value_dup_object (v);
1042 gst_structure_remove_field (ret, "source-pad");
1044 *tag_list = (GstTagList *) ret;
1048 * gst_message_parse_buffering:
1049 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1050 * @percent: Return location for the percent.
1052 * Extracts the buffering percent from the GstMessage. see also
1053 * gst_message_new_buffering().
1060 gst_message_parse_buffering (GstMessage * message, gint * percent)
1062 g_return_if_fail (GST_IS_MESSAGE (message));
1063 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1066 *percent = g_value_get_int (gst_structure_id_get_value (message->structure,
1067 GST_QUARK (BUFFER_PERCENT)));
1071 * gst_message_set_buffering_stats:
1072 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1073 * @mode: a buffering mode
1074 * @avg_in: the average input rate
1075 * @avg_out: the average output rate
1076 * @buffering_left: amount of buffering time left in milliseconds
1078 * Configures the buffering stats values in @message.
1083 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1084 gint avg_in, gint avg_out, gint64 buffering_left)
1086 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1088 gst_structure_id_set (message->structure,
1089 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1090 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1091 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1092 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1096 * gst_message_parse_buffering_stats:
1097 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1098 * @mode: a buffering mode
1099 * @avg_in: the average input rate
1100 * @avg_out: the average output rate
1101 * @buffering_left: amount of buffering time left in milliseconds.
1103 * Extracts the buffering stats values from @message.
1108 gst_message_parse_buffering_stats (GstMessage * message,
1109 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1110 gint64 * buffering_left)
1112 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1115 *mode = g_value_get_enum (gst_structure_id_get_value (message->structure,
1116 GST_QUARK (BUFFERING_MODE)));
1118 *avg_in = g_value_get_int (gst_structure_id_get_value (message->structure,
1119 GST_QUARK (AVG_IN_RATE)));
1121 *avg_out = g_value_get_int (gst_structure_id_get_value (message->structure,
1122 GST_QUARK (AVG_OUT_RATE)));
1125 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1126 GST_QUARK (BUFFERING_LEFT)));
1130 * gst_message_parse_state_changed:
1131 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1132 * @oldstate: the previous state, or NULL
1133 * @newstate: the new (current) state, or NULL
1134 * @pending: the pending (target) state, or NULL
1136 * Extracts the old and new states from the GstMessage.
1141 gst_message_parse_state_changed (GstMessage * message,
1142 GstState * oldstate, GstState * newstate, GstState * pending)
1144 g_return_if_fail (GST_IS_MESSAGE (message));
1145 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1149 g_value_get_enum (gst_structure_id_get_value (message->structure,
1150 GST_QUARK (OLD_STATE)));
1153 g_value_get_enum (gst_structure_id_get_value (message->structure,
1154 GST_QUARK (NEW_STATE)));
1156 *pending = g_value_get_enum (gst_structure_id_get_value (message->structure,
1157 GST_QUARK (PENDING_STATE)));
1161 * gst_message_parse_clock_provide:
1162 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1163 * @clock: A pointer to hold a clock object.
1164 * @ready: A pointer to hold the ready flag.
1166 * Extracts the clock and ready flag from the GstMessage.
1167 * The clock object returned remains valid until the message is freed.
1172 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1175 const GValue *clock_gvalue;
1177 g_return_if_fail (GST_IS_MESSAGE (message));
1178 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1181 gst_structure_id_get_value (message->structure, GST_QUARK (CLOCK));
1182 g_return_if_fail (clock_gvalue != NULL);
1183 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1187 g_value_get_boolean (gst_structure_id_get_value (message->structure,
1188 GST_QUARK (READY)));
1190 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1194 * gst_message_parse_clock_lost:
1195 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1196 * @clock: A pointer to hold the lost clock
1198 * Extracts the lost clock from the GstMessage.
1199 * The clock object returned remains valid until the message is freed.
1204 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1206 const GValue *clock_gvalue;
1208 g_return_if_fail (GST_IS_MESSAGE (message));
1209 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1212 gst_structure_id_get_value (message->structure, GST_QUARK (CLOCK));
1213 g_return_if_fail (clock_gvalue != NULL);
1214 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1217 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1221 * gst_message_parse_new_clock:
1222 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1223 * @clock: A pointer to hold the selected new clock
1225 * Extracts the new clock from the GstMessage.
1226 * The clock object returned remains valid until the message is freed.
1231 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1233 const GValue *clock_gvalue;
1235 g_return_if_fail (GST_IS_MESSAGE (message));
1236 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1239 gst_structure_id_get_value (message->structure, GST_QUARK (CLOCK));
1240 g_return_if_fail (clock_gvalue != NULL);
1241 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1244 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1248 * gst_message_parse_structure_change:
1249 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1250 * @type: A pointer to hold the change type
1251 * @owner: The owner element of the message source
1252 * @busy: A pointer to hold whether the change is in progress or has been
1255 * Extracts the change type and completion status from the GstMessage.
1262 gst_message_parse_structure_change (GstMessage * message,
1263 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1265 const GValue *owner_gvalue;
1267 g_return_if_fail (GST_IS_MESSAGE (message));
1268 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1271 gst_structure_id_get_value (message->structure, GST_QUARK (OWNER));
1272 g_return_if_fail (owner_gvalue != NULL);
1273 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1276 *type = g_value_get_enum (gst_structure_id_get_value (message->structure,
1279 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1282 g_value_get_boolean (gst_structure_id_get_value (message->structure,
1287 * gst_message_parse_error:
1288 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1289 * @gerror: Location for the GError
1290 * @debug: Location for the debug message, or NULL
1292 * Extracts the GError and debug string from the GstMessage. The values returned
1293 * in the output arguments are copies; the caller must free them when done.
1298 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1300 const GValue *error_gvalue;
1303 g_return_if_fail (GST_IS_MESSAGE (message));
1304 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1307 gst_structure_id_get_value (message->structure, GST_QUARK (GERROR));
1308 g_return_if_fail (error_gvalue != NULL);
1309 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1311 error_val = (GError *) g_value_get_boxed (error_gvalue);
1313 *gerror = g_error_copy (error_val);
1319 g_value_dup_string (gst_structure_id_get_value (message->structure,
1320 GST_QUARK (DEBUG)));
1324 * gst_message_parse_warning:
1325 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1326 * @gerror: Location for the GError
1327 * @debug: Location for the debug message, or NULL
1329 * Extracts the GError and debug string from the GstMessage. The values returned
1330 * in the output arguments are copies; the caller must free them when done.
1335 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1338 const GValue *error_gvalue;
1341 g_return_if_fail (GST_IS_MESSAGE (message));
1342 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1345 gst_structure_id_get_value (message->structure, GST_QUARK (GERROR));
1346 g_return_if_fail (error_gvalue != NULL);
1347 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1349 error_val = (GError *) g_value_get_boxed (error_gvalue);
1351 *gerror = g_error_copy (error_val);
1357 g_value_dup_string (gst_structure_id_get_value (message->structure,
1358 GST_QUARK (DEBUG)));
1362 * gst_message_parse_info:
1363 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1364 * @gerror: Location for the GError
1365 * @debug: Location for the debug message, or NULL
1367 * Extracts the GError and debug string from the GstMessage. The values returned
1368 * in the output arguments are copies; the caller must free them when done.
1375 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1377 const GValue *error_gvalue;
1380 g_return_if_fail (GST_IS_MESSAGE (message));
1381 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1384 gst_structure_id_get_value (message->structure, GST_QUARK (GERROR));
1385 g_return_if_fail (error_gvalue != NULL);
1386 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1388 error_val = (GError *) g_value_get_boxed (error_gvalue);
1390 *gerror = g_error_copy (error_val);
1396 g_value_dup_string (gst_structure_id_get_value (message->structure,
1397 GST_QUARK (DEBUG)));
1401 * gst_message_parse_segment_start:
1402 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1403 * @format: Result location for the format, or NULL
1404 * @position: Result location for the position, or NULL
1406 * Extracts the position and format from the segment start message.
1411 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1414 g_return_if_fail (GST_IS_MESSAGE (message));
1415 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1419 g_value_get_enum (gst_structure_id_get_value (message->structure,
1420 GST_QUARK (FORMAT)));
1423 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1424 GST_QUARK (POSITION)));
1428 * gst_message_parse_segment_done:
1429 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1430 * @format: Result location for the format, or NULL
1431 * @position: Result location for the position, or NULL
1433 * Extracts the position and format from the segment start message.
1438 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1441 g_return_if_fail (GST_IS_MESSAGE (message));
1442 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1446 g_value_get_enum (gst_structure_id_get_value (message->structure,
1447 GST_QUARK (FORMAT)));
1450 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1451 GST_QUARK (POSITION)));
1455 * gst_message_parse_duration:
1456 * @message: A valid #GstMessage of type GST_MESSAGE_DURATION.
1457 * @format: Result location for the format, or NULL
1458 * @duration: Result location for the duration, or NULL
1460 * Extracts the duration and format from the duration message. The duration
1461 * might be GST_CLOCK_TIME_NONE, which indicates that the duration has
1462 * changed. Applications should always use a query to retrieve the duration
1468 gst_message_parse_duration (GstMessage * message, GstFormat * format,
1471 g_return_if_fail (GST_IS_MESSAGE (message));
1472 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DURATION);
1476 g_value_get_enum (gst_structure_id_get_value (message->structure,
1477 GST_QUARK (FORMAT)));
1480 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1481 GST_QUARK (DURATION)));
1485 * gst_message_parse_async_start:
1486 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1487 * @new_base_time: Result location for the new_base_time or NULL
1489 * Extract the new_base_time from the async_start message.
1496 gst_message_parse_async_start (GstMessage * message, gboolean * new_base_time)
1498 g_return_if_fail (GST_IS_MESSAGE (message));
1499 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_START);
1503 g_value_get_boolean (gst_structure_id_get_value (message->structure,
1504 GST_QUARK (NEW_BASE_TIME)));
1508 * gst_message_parse_request_state:
1509 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1510 * @state: Result location for the requested state or NULL
1512 * Extract the requested state from the request_state message.
1519 gst_message_parse_request_state (GstMessage * message, GstState * state)
1521 g_return_if_fail (GST_IS_MESSAGE (message));
1522 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1525 *state = g_value_get_enum (gst_structure_id_get_value (message->structure,
1526 GST_QUARK (NEW_STATE)));
1530 * gst_message_new_stream_status:
1531 * @src: The object originating the message.
1532 * @type: The stream status type.
1533 * @owner: The owner element of @src.
1535 * Create a new stream status message. This message is posted when a streaming
1536 * thread is created/destroyed or when the state changed.
1538 * Returns: The new stream status message.
1545 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1548 GstMessage *message;
1549 GstStructure *structure;
1551 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STREAM_STATUS),
1552 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1553 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1554 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1560 * gst_message_parse_stream_status:
1561 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1562 * @type: A pointer to hold the status type
1563 * @owner: The owner element of the message source
1565 * Extracts the stream status type and owner the GstMessage. The returned
1566 * owner remains valid for as long as the reference to @message is valid and
1567 * should thus not be unreffed.
1574 gst_message_parse_stream_status (GstMessage * message,
1575 GstStreamStatusType * type, GstElement ** owner)
1577 const GValue *owner_gvalue;
1579 g_return_if_fail (GST_IS_MESSAGE (message));
1580 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1583 gst_structure_id_get_value (message->structure, GST_QUARK (OWNER));
1584 g_return_if_fail (owner_gvalue != NULL);
1587 *type = g_value_get_enum (gst_structure_id_get_value (message->structure,
1590 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1594 * gst_message_set_stream_status_object:
1595 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1596 * @object: the object controlling the streaming
1598 * Configures the object handling the streaming thread. This is usually a
1599 * GstTask object but other objects might be added in the future.
1604 gst_message_set_stream_status_object (GstMessage * message,
1605 const GValue * object)
1607 g_return_if_fail (GST_IS_MESSAGE (message));
1608 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1610 gst_structure_id_set_value (message->structure, GST_QUARK (OBJECT), object);
1614 * gst_message_get_stream_status_object:
1615 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1617 * Extracts the object managing the streaming thread from @message.
1619 * Returns: a GValue containing the object that manages the streaming thread.
1620 * This object is usually of type GstTask but other types can be added in the
1621 * future. The object remains valid as long as @message is valid.
1626 gst_message_get_stream_status_object (GstMessage * message)
1628 const GValue *result;
1630 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1631 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1634 result = gst_structure_id_get_value (message->structure, GST_QUARK (OBJECT));
1640 * gst_message_new_step_done:
1641 * @src: The object originating the message.
1642 * @format: the format of @amount
1643 * @amount: the amount of stepped data
1644 * @rate: the rate of the stepped amount
1645 * @flush: is this an flushing step
1646 * @intermediate: is this an intermediate step
1647 * @duration: the duration of the data
1648 * @eos: the step caused EOS
1650 * This message is posted by elements when they complete a part, when @intermediate set
1651 * to TRUE, or a complete step operation.
1653 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1654 * @amount of media in format @format.
1656 * Returns: The new step_done message.
1663 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1664 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1667 GstMessage *message;
1668 GstStructure *structure;
1670 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_DONE),
1671 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1672 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1673 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1674 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1675 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1676 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1677 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1678 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1684 * gst_message_parse_step_done:
1685 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1686 * @format: result location for the format
1687 * @amount: result location for the amount
1688 * @rate: result location for the rate
1689 * @flush: result location for the flush flag
1690 * @intermediate: result location for the intermediate flag
1691 * @duration: result location for the duration
1692 * @eos: result location for the EOS flag
1694 * Extract the values the step_done message.
1701 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1702 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1703 guint64 * duration, gboolean * eos)
1705 g_return_if_fail (GST_IS_MESSAGE (message));
1706 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1708 gst_structure_id_get (message->structure,
1709 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1710 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1711 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1712 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1713 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1714 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1715 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1719 * gst_message_new_step_start:
1720 * @src: The object originating the message.
1721 * @active: if the step is active or queued
1722 * @format: the format of @amount
1723 * @amount: the amount of stepped data
1724 * @rate: the rate of the stepped amount
1725 * @flush: is this an flushing step
1726 * @intermediate: is this an intermediate step
1728 * This message is posted by elements when they accept or activate a new step
1729 * event for @amount in @format.
1731 * @active is set to FALSE when the element accepted the new step event and has
1732 * queued it for execution in the streaming threads.
1734 * @active is set to TRUE when the element has activated the step operation and
1735 * is now ready to start executing the step in the streaming thread. After this
1736 * message is emited, the application can queue a new step operation in the
1739 * Returns: The new step_start message.
1746 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1747 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1749 GstMessage *message;
1750 GstStructure *structure;
1752 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_START),
1753 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1754 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1755 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1756 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1757 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1758 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1759 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1765 * gst_message_parse_step_start:
1766 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1767 * @active: result location for the active flag
1768 * @format: result location for the format
1769 * @amount: result location for the amount
1770 * @rate: result location for the rate
1771 * @flush: result location for the flush flag
1772 * @intermediate: result location for the intermediate flag
1774 * Extract the values from step_start message.
1781 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1782 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1783 gboolean * intermediate)
1785 g_return_if_fail (GST_IS_MESSAGE (message));
1786 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1788 gst_structure_id_get (message->structure,
1789 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1790 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1791 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1792 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1793 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1794 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);