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., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, 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:
38 * gst_bus_post (bus, gst_message_new_eos());
41 * A #GstElement usually posts messages on the bus provided by the parent
42 * container using gst_element_post_message().
44 * Last reviewed on 2005-11-09 (0.9.4)
48 #include "gst_private.h"
49 #include <string.h> /* memcpy */
51 #include "gstenumtypes.h"
53 #include "gstmessage.h"
54 #include "gsttaglist.h"
63 GstMessageExtendedType extended_type;
65 GstStructure *structure;
68 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
77 static GstMessageQuarks message_quarks[] = {
78 {GST_MESSAGE_UNKNOWN, "unknown", 0},
79 {GST_MESSAGE_EOS, "eos", 0},
80 {GST_MESSAGE_ERROR, "error", 0},
81 {GST_MESSAGE_WARNING, "warning", 0},
82 {GST_MESSAGE_INFO, "info", 0},
83 {GST_MESSAGE_TAG, "tag", 0},
84 {GST_MESSAGE_BUFFERING, "buffering", 0},
85 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
86 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
87 {GST_MESSAGE_STEP_DONE, "step-done", 0},
88 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
89 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
90 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
91 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
92 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
93 {GST_MESSAGE_APPLICATION, "application", 0},
94 {GST_MESSAGE_ELEMENT, "element", 0},
95 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
96 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
97 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
98 {GST_MESSAGE_LATENCY, "latency", 0},
99 {GST_MESSAGE_ASYNC_START, "async-start", 0},
100 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
101 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
102 {GST_MESSAGE_STEP_START, "step-start", 0},
103 {GST_MESSAGE_QOS, "qos", 0},
104 {GST_MESSAGE_PROGRESS, "progress", 0},
105 {GST_MESSAGE_TOC, "toc", 0},
106 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
107 {GST_MESSAGE_STREAM_START, "stream-start", 0},
108 {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
109 {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
110 {GST_MESSAGE_EXTENDED, "extended", 0},
111 {GST_MESSAGE_DEVICE, "device", 0},
115 static GType _gst_message_type = 0;
116 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
119 _priv_gst_message_initialize (void)
123 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
125 /* the GstMiniObject types need to be class_ref'd once before it can be
126 * done from multiple threads;
127 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
128 gst_message_get_type ();
130 for (i = 0; message_quarks[i].name; i++) {
131 message_quarks[i].quark =
132 g_quark_from_static_string (message_quarks[i].name);
135 _gst_message_type = gst_message_get_type ();
139 * gst_message_type_get_name:
140 * @type: the message type
142 * Get a printable name for the given message type. Do not modify or free.
144 * Returns: a reference to the static name of the message.
147 gst_message_type_get_name (GstMessageType type)
151 for (i = 0; message_quarks[i].name; i++) {
152 if (type == message_quarks[i].type)
153 return message_quarks[i].name;
159 * gst_message_type_to_quark:
160 * @type: the message type
162 * Get the unique quark for the given message type.
164 * Returns: the quark associated with the message type
167 gst_message_type_to_quark (GstMessageType type)
171 for (i = 0; message_quarks[i].name; i++) {
172 if (type == message_quarks[i].type)
173 return message_quarks[i].quark;
179 _gst_message_free (GstMessage * message)
181 GstStructure *structure;
183 g_return_if_fail (message != NULL);
185 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
186 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
188 if (GST_MESSAGE_SRC (message)) {
189 gst_object_unref (GST_MESSAGE_SRC (message));
190 GST_MESSAGE_SRC (message) = NULL;
193 if (message->lock.p) {
194 GST_MESSAGE_LOCK (message);
195 GST_MESSAGE_SIGNAL (message);
196 GST_MESSAGE_UNLOCK (message);
199 structure = GST_MESSAGE_STRUCTURE (message);
201 gst_structure_set_parent_refcount (structure, NULL);
202 gst_structure_free (structure);
205 g_slice_free1 (sizeof (GstMessageImpl), message);
209 gst_message_init (GstMessageImpl * message, GstMessageType type,
213 _gst_message_copy (GstMessage * message)
215 GstMessageImpl *copy;
216 GstStructure *structure;
218 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
219 GST_MESSAGE_TYPE_NAME (message),
220 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
222 copy = g_slice_new0 (GstMessageImpl);
224 gst_message_init (copy, GST_MESSAGE_TYPE (message),
225 GST_MESSAGE_SRC (message));
227 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
228 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
230 structure = GST_MESSAGE_STRUCTURE (message);
232 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
233 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
234 ©->message.mini_object.refcount);
236 GST_MESSAGE_STRUCTURE (copy) = NULL;
239 return GST_MESSAGE_CAST (copy);
242 GstMessageExtendedType
243 gst_message_get_extended_type (GstMessage * msg)
245 GstMessageImpl *message = (GstMessageImpl *) msg;
247 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
249 return message->extended_type;
253 gst_message_init (GstMessageImpl * message, GstMessageType type,
256 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
257 (GstMiniObjectCopyFunction) _gst_message_copy, NULL,
258 (GstMiniObjectFreeFunction) _gst_message_free);
260 GST_MESSAGE_TYPE (message) = type;
262 gst_object_ref (src);
263 GST_MESSAGE_SRC (message) = src;
264 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
265 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
270 * gst_message_new_custom:
271 * @type: The #GstMessageType to distinguish messages
272 * @src: The object originating the message.
273 * @structure: (transfer full): the structure for the message. The message
274 * will take ownership of the structure.
276 * Create a new custom-typed message. This can be used for anything not
277 * handled by other message-specific functions to pass a message to the
278 * app. The structure field can be NULL.
280 * Returns: (transfer full): The new message.
285 gst_message_new_custom (GstMessageType type, GstObject * src,
286 GstStructure * structure)
288 GstMessageImpl *message;
290 message = g_slice_new0 (GstMessageImpl);
292 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
293 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
294 gst_message_type_get_name (type));
297 /* structure must not have a parent */
298 if (!gst_structure_set_parent_refcount (structure,
299 &message->message.mini_object.refcount))
302 gst_message_init (message, type, src);
304 GST_MESSAGE_STRUCTURE (message) = structure;
306 return GST_MESSAGE_CAST (message);
311 g_slice_free1 (sizeof (GstMessageImpl), message);
312 g_warning ("structure is already owned by another object");
317 static inline GstMessage *
318 gst_message_new_extended (GstMessageExtendedType extended_type, GstObject * src,
319 GstStructure * structure)
321 GstMessageImpl *message;
323 message = (GstMessageImpl *) gst_message_new_custom (GST_MESSAGE_EXTENDED,
326 message->extended_type = extended_type;
328 return GST_MESSAGE_CAST (message);
332 * gst_message_get_seqnum:
333 * @message: A #GstMessage.
335 * Retrieve the sequence number of a message.
337 * Messages have ever-incrementing sequence numbers, which may also be set
338 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
339 * to indicate that a message corresponds to some other set of messages or
340 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
341 * is considered good practice to make this correspondence when possible, though
342 * it is not required.
344 * Note that events and messages share the same sequence number incrementor;
345 * two events or messages will never have the same sequence number unless
346 * that correspondence was made explicitly.
348 * Returns: The message's sequence number.
353 gst_message_get_seqnum (GstMessage * message)
355 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
357 return GST_MESSAGE_SEQNUM (message);
361 * gst_message_set_seqnum:
362 * @message: A #GstMessage.
363 * @seqnum: A sequence number.
365 * Set the sequence number of a message.
367 * This function might be called by the creator of a message to indicate that
368 * the message relates to other messages or events. See gst_message_get_seqnum()
369 * for more information.
374 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
376 g_return_if_fail (GST_IS_MESSAGE (message));
378 GST_MESSAGE_SEQNUM (message) = seqnum;
382 * gst_message_new_eos:
383 * @src: (transfer none): The object originating the message.
385 * Create a new eos message. This message is generated and posted in
386 * the sink elements of a GstBin. The bin will only forward the EOS
387 * message to the application if all sinks have posted an EOS message.
389 * Returns: (transfer full): The new eos message.
394 gst_message_new_eos (GstObject * src)
398 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
404 * gst_message_new_error:
405 * @src: (transfer none): The object originating the message.
406 * @error: (transfer none): The GError for this message.
407 * @debug: A debugging string.
409 * Create a new error message. The message will copy @error and
410 * @debug. This message is posted by element when a fatal event
411 * occurred. The pipeline will probably (partially) stop. The application
412 * receiving this message should stop the pipeline.
414 * Returns: (transfer full): the new error message.
419 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
422 GstStructure *structure;
424 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
425 GST_QUARK (GERROR), G_TYPE_ERROR, error,
426 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
427 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
433 * gst_message_new_warning:
434 * @src: (transfer none): The object originating the message.
435 * @error: (transfer none): The GError for this message.
436 * @debug: A debugging string.
438 * Create a new warning message. The message will make copies of @error and
441 * Returns: (transfer full): The new warning message.
446 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
449 GstStructure *structure;
451 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
452 GST_QUARK (GERROR), G_TYPE_ERROR, error,
453 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
454 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
460 * gst_message_new_info:
461 * @src: (transfer none): The object originating the message.
462 * @error: (transfer none): The GError for this message.
463 * @debug: A debugging string.
465 * Create a new info message. The message will make copies of @error and
470 * Returns: (transfer full): the new info message.
473 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
476 GstStructure *structure;
478 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
479 GST_QUARK (GERROR), G_TYPE_ERROR, error,
480 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
481 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
487 * gst_message_new_tag:
488 * @src: (transfer none): The object originating the message.
489 * @tag_list: (transfer full): the tag list for the message.
491 * Create a new tag message. The message will take ownership of the tag list.
492 * The message is posted by elements that discovered a new taglist.
494 * Returns: (transfer full): the new tag message.
499 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
503 GValue val = G_VALUE_INIT;
505 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
507 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
508 g_value_init (&val, GST_TYPE_TAG_LIST);
509 g_value_take_boxed (&val, tag_list);
510 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
511 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
516 * gst_message_new_buffering:
517 * @src: (transfer none): The object originating the message.
518 * @percent: The buffering percent
520 * Create a new buffering message. This message can be posted by an element that
521 * needs to buffer data before it can continue processing. @percent should be a
522 * value between 0 and 100. A value of 100 means that the buffering completed.
524 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
525 * @percent is 100, the application can set the pipeline (back) to PLAYING.
526 * The application must be prepared to receive BUFFERING messages in the
527 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
528 * message with @percent set to 100, which can happen after the pipeline
529 * completed prerolling.
533 * Returns: (transfer full): The new buffering message.
536 gst_message_new_buffering (GstObject * src, gint percent)
539 GstStructure *structure;
540 gint64 buffering_left;
542 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
544 buffering_left = (percent == 100 ? 0 : -1);
546 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
547 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
548 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
549 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
550 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
551 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
552 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
558 * gst_message_new_state_changed:
559 * @src: (transfer none): the object originating the message
560 * @oldstate: the previous state
561 * @newstate: the new (current) state
562 * @pending: the pending (target) state
564 * Create a state change message. This message is posted whenever an element
567 * Returns: (transfer full): the new state change message.
572 gst_message_new_state_changed (GstObject * src,
573 GstState oldstate, GstState newstate, GstState pending)
576 GstStructure *structure;
578 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
579 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
580 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
581 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
582 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
588 * gst_message_new_state_dirty:
589 * @src: (transfer none): the object originating the message
591 * Create a state dirty message. This message is posted whenever an element
592 * changed its state asynchronously and is used internally to update the
593 * states of container objects.
595 * Returns: (transfer full): the new state dirty message.
600 gst_message_new_state_dirty (GstObject * src)
604 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
610 * gst_message_new_clock_provide:
611 * @src: (transfer none): the object originating the message.
612 * @clock: (transfer none): the clock it provides
613 * @ready: TRUE if the sender can provide a clock
615 * Create a clock provide message. This message is posted whenever an
616 * element is ready to provide a clock or lost its ability to provide
617 * a clock (maybe because it paused or became EOS).
619 * This message is mainly used internally to manage the clock
622 * Returns: (transfer full): the new provide clock message.
627 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
631 GstStructure *structure;
633 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
634 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
635 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
636 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
642 * gst_message_new_clock_lost:
643 * @src: (transfer none): the object originating the message.
644 * @clock: (transfer none): the clock that was lost
646 * Create a clock lost message. This message is posted whenever the
647 * clock is not valid anymore.
649 * If this message is posted by the pipeline, the pipeline will
650 * select a new clock again when it goes to PLAYING. It might therefore
651 * be needed to set the pipeline to PAUSED and PLAYING again.
653 * Returns: (transfer full): The new clock lost message.
658 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
661 GstStructure *structure;
663 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
664 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
665 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
671 * gst_message_new_new_clock:
672 * @src: (transfer none): The object originating the message.
673 * @clock: (transfer none): the new selected clock
675 * Create a new clock message. This message is posted whenever the
676 * pipeline selects a new clock for the pipeline.
678 * Returns: (transfer full): The new new clock message.
683 gst_message_new_new_clock (GstObject * src, GstClock * clock)
686 GstStructure *structure;
688 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
689 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
690 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
696 * gst_message_new_structure_change:
697 * @src: (transfer none): The object originating the message.
698 * @type: The change type.
699 * @owner: (transfer none): The owner element of @src.
700 * @busy: Whether the structure change is busy.
702 * Create a new structure change message. This message is posted when the
703 * structure of a pipeline is in the process of being changed, for example
704 * when pads are linked or unlinked.
706 * @src should be the sinkpad that unlinked or linked.
708 * Returns: (transfer full): the new structure change message.
713 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
714 GstElement * owner, gboolean busy)
717 GstStructure *structure;
719 g_return_val_if_fail (GST_IS_PAD (src), NULL);
720 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
721 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
723 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
724 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
725 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
726 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
728 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
735 * gst_message_new_segment_start:
736 * @src: (transfer none): The object originating the message.
737 * @format: The format of the position being played
738 * @position: The position of the segment being played
740 * Create a new segment message. This message is posted by elements that
741 * start playback of a segment as a result of a segment seek. This message
742 * is not received by the application but is used for maintenance reasons in
743 * container elements.
745 * Returns: (transfer full): the new segment start message.
750 gst_message_new_segment_start (GstObject * src, GstFormat format,
754 GstStructure *structure;
756 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
757 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
758 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
759 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
765 * gst_message_new_segment_done:
766 * @src: (transfer none): the object originating the message.
767 * @format: The format of the position being done
768 * @position: The position of the segment being done
770 * Create a new segment done message. This message is posted by elements that
771 * finish playback of a segment as a result of a segment seek. This message
772 * is received by the application after all elements that posted a segment_start
773 * have posted the segment_done.
775 * Returns: (transfer full): the new segment done message.
780 gst_message_new_segment_done (GstObject * src, GstFormat format,
784 GstStructure *structure;
786 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
787 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
788 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
789 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
795 * gst_message_new_application:
796 * @src: (transfer none): the object originating the message.
797 * @structure: (transfer full): the structure for the message. The message
798 * will take ownership of the structure.
800 * Create a new application-typed message. GStreamer will never create these
801 * messages; they are a gift from us to you. Enjoy.
803 * Returns: (transfer full): The new application message.
808 gst_message_new_application (GstObject * src, GstStructure * structure)
810 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
814 * gst_message_new_element:
815 * @src: (transfer none): The object originating the message.
816 * @structure: (transfer full): The structure for the message. The message
817 * will take ownership of the structure.
819 * Create a new element-specific message. This is meant as a generic way of
820 * allowing one-way communication from an element to an application, for example
821 * "the firewire cable was unplugged". The format of the message should be
822 * documented in the element's documentation. The structure field can be NULL.
824 * Returns: (transfer full): The new element message.
829 gst_message_new_element (GstObject * src, GstStructure * structure)
831 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
835 * gst_message_new_duration_changed:
836 * @src: (transfer none): The object originating the message.
838 * Create a new duration changed message. This message is posted by elements
839 * that know the duration of a stream when the duration changes. This message
840 * is received by bins and is used to calculate the total duration of a
841 * pipeline. Elements may post a duration message with a duration of
842 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
843 * cached duration should be discarded. The new duration can then be
844 * retrieved via a query.
846 * Returns: (transfer full): The new duration-changed message.
851 gst_message_new_duration_changed (GstObject * src)
855 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
856 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
862 * gst_message_new_async_start:
863 * @src: (transfer none): The object originating the message.
865 * This message is posted by elements when they start an ASYNC state change.
867 * Returns: (transfer full): The new async_start message.
872 gst_message_new_async_start (GstObject * src)
876 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
882 * gst_message_new_async_done:
883 * @src: (transfer none): The object originating the message.
884 * @running_time: the desired running_time
886 * The message is posted when elements completed an ASYNC state change.
887 * @running_time contains the time of the desired running_time when this
888 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
889 * means that the element has no clock interaction and thus doesn't care about
890 * the running_time of the pipeline.
892 * Returns: (transfer full): The new async_done message.
897 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
900 GstStructure *structure;
902 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
903 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
904 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
910 * gst_message_new_latency:
911 * @src: (transfer none): The object originating the message.
913 * This message can be posted by elements when their latency requirements have
916 * Returns: (transfer full): The new latency message.
921 gst_message_new_latency (GstObject * src)
925 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
931 * gst_message_new_request_state:
932 * @src: (transfer none): the object originating the message.
933 * @state: The new requested state
935 * This message can be posted by elements when they want to have their state
936 * changed. A typical use case would be an audio server that wants to pause the
937 * pipeline because a higher priority stream is being played.
939 * Returns: (transfer full): the new request state message.
944 gst_message_new_request_state (GstObject * src, GstState state)
947 GstStructure *structure;
949 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
950 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
951 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
957 * gst_message_get_structure:
958 * @message: The #GstMessage.
960 * Access the structure of the message.
962 * Returns: (transfer none): The structure of the message. The structure is
963 * still owned by the message, which means that you should not free it and
964 * that the pointer becomes invalid when you free the message.
969 gst_message_get_structure (GstMessage * message)
971 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
973 return GST_MESSAGE_STRUCTURE (message);
977 * gst_message_has_name:
978 * @message: The #GstMessage.
979 * @name: name to check
981 * Checks if @message has the given @name. This function is usually used to
982 * check the name of a custom message.
984 * Returns: %TRUE if @name matches the name of the message structure.
987 gst_message_has_name (GstMessage * message, const gchar * name)
989 GstStructure *structure;
991 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
993 structure = GST_MESSAGE_STRUCTURE (message);
994 if (structure == NULL)
997 return gst_structure_has_name (structure, name);
1001 * gst_message_parse_tag:
1002 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1003 * @tag_list: (out callee-allocates): return location for the tag-list.
1005 * Extracts the tag list from the GstMessage. The tag list returned in the
1006 * output argument is a copy; the caller must free it when done.
1008 * Typical usage of this function might be:
1011 * switch (GST_MESSAGE_TYPE (msg)) {
1012 * case GST_MESSAGE_TAG: {
1013 * GstTagList *tags = NULL;
1015 * gst_message_parse_tag (msg, &tags);
1016 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1017 * handle_tags (tags);
1018 * gst_tag_list_unref (tags);
1029 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1031 g_return_if_fail (GST_IS_MESSAGE (message));
1032 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1033 g_return_if_fail (tag_list != NULL);
1035 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1036 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1040 * gst_message_parse_buffering:
1041 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1042 * @percent: (out) (allow-none): Return location for the percent.
1044 * Extracts the buffering percent from the GstMessage. see also
1045 * gst_message_new_buffering().
1050 gst_message_parse_buffering (GstMessage * message, gint * percent)
1052 g_return_if_fail (GST_IS_MESSAGE (message));
1053 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1057 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1058 (message), GST_QUARK (BUFFER_PERCENT)));
1062 * gst_message_set_buffering_stats:
1063 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1064 * @mode: a buffering mode
1065 * @avg_in: the average input rate
1066 * @avg_out: the average output rate
1067 * @buffering_left: amount of buffering time left in milliseconds
1069 * Configures the buffering stats values in @message.
1072 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1073 gint avg_in, gint avg_out, gint64 buffering_left)
1075 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1077 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1078 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1079 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1080 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1081 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1085 * gst_message_parse_buffering_stats:
1086 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1087 * @mode: (out) (allow-none): a buffering mode, or NULL
1088 * @avg_in: (out) (allow-none): the average input rate, or NULL
1089 * @avg_out: (out) (allow-none): the average output rate, or NULL
1090 * @buffering_left: (out) (allow-none): amount of buffering time left in
1091 * milliseconds, or NULL
1093 * Extracts the buffering stats values from @message.
1096 gst_message_parse_buffering_stats (GstMessage * message,
1097 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1098 gint64 * buffering_left)
1100 GstStructure *structure;
1102 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1104 structure = GST_MESSAGE_STRUCTURE (message);
1106 *mode = (GstBufferingMode)
1107 g_value_get_enum (gst_structure_id_get_value (structure,
1108 GST_QUARK (BUFFERING_MODE)));
1110 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1111 GST_QUARK (AVG_IN_RATE)));
1113 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1114 GST_QUARK (AVG_OUT_RATE)));
1117 g_value_get_int64 (gst_structure_id_get_value (structure,
1118 GST_QUARK (BUFFERING_LEFT)));
1122 * gst_message_parse_state_changed:
1123 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1124 * @oldstate: (out) (allow-none): the previous state, or NULL
1125 * @newstate: (out) (allow-none): the new (current) state, or NULL
1126 * @pending: (out) (allow-none): the pending (target) state, or NULL
1128 * Extracts the old and new states from the GstMessage.
1130 * Typical usage of this function might be:
1133 * switch (GST_MESSAGE_TYPE (msg)) {
1134 * case GST_MESSAGE_STATE_CHANGED: {
1135 * GstState old_state, new_state;
1137 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1138 * g_print ("Element %s changed state from %s to %s.\n",
1139 * GST_OBJECT_NAME (msg->src),
1140 * gst_element_state_get_name (old_state),
1141 * gst_element_state_get_name (new_state));
1152 gst_message_parse_state_changed (GstMessage * message,
1153 GstState * oldstate, GstState * newstate, GstState * pending)
1155 GstStructure *structure;
1157 g_return_if_fail (GST_IS_MESSAGE (message));
1158 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1160 structure = GST_MESSAGE_STRUCTURE (message);
1162 *oldstate = (GstState)
1163 g_value_get_enum (gst_structure_id_get_value (structure,
1164 GST_QUARK (OLD_STATE)));
1166 *newstate = (GstState)
1167 g_value_get_enum (gst_structure_id_get_value (structure,
1168 GST_QUARK (NEW_STATE)));
1170 *pending = (GstState)
1171 g_value_get_enum (gst_structure_id_get_value (structure,
1172 GST_QUARK (PENDING_STATE)));
1176 * gst_message_parse_clock_provide:
1177 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1178 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1180 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1182 * Extracts the clock and ready flag from the GstMessage.
1183 * The clock object returned remains valid until the message is freed.
1188 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1191 const GValue *clock_gvalue;
1192 GstStructure *structure;
1194 g_return_if_fail (GST_IS_MESSAGE (message));
1195 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1197 structure = GST_MESSAGE_STRUCTURE (message);
1198 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1199 g_return_if_fail (clock_gvalue != NULL);
1200 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1204 g_value_get_boolean (gst_structure_id_get_value (structure,
1205 GST_QUARK (READY)));
1207 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1211 * gst_message_parse_clock_lost:
1212 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1213 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1215 * Extracts the lost clock from the GstMessage.
1216 * The clock object returned remains valid until the message is freed.
1221 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1223 const GValue *clock_gvalue;
1224 GstStructure *structure;
1226 g_return_if_fail (GST_IS_MESSAGE (message));
1227 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1229 structure = GST_MESSAGE_STRUCTURE (message);
1230 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1231 g_return_if_fail (clock_gvalue != NULL);
1232 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1235 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1239 * gst_message_parse_new_clock:
1240 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1241 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1244 * Extracts the new clock from the GstMessage.
1245 * The clock object returned remains valid until the message is freed.
1250 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1252 const GValue *clock_gvalue;
1253 GstStructure *structure;
1255 g_return_if_fail (GST_IS_MESSAGE (message));
1256 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1258 structure = GST_MESSAGE_STRUCTURE (message);
1259 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1260 g_return_if_fail (clock_gvalue != NULL);
1261 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1264 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1268 * gst_message_parse_structure_change:
1269 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1270 * @type: (out): A pointer to hold the change type
1271 * @owner: (out) (allow-none) (transfer none): The owner element of the
1273 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1274 * progress or has been completed
1276 * Extracts the change type and completion status from the GstMessage.
1281 gst_message_parse_structure_change (GstMessage * message,
1282 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1284 const GValue *owner_gvalue;
1285 GstStructure *structure;
1287 g_return_if_fail (GST_IS_MESSAGE (message));
1288 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1290 structure = GST_MESSAGE_STRUCTURE (message);
1291 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1292 g_return_if_fail (owner_gvalue != NULL);
1293 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1296 *type = (GstStructureChangeType)
1297 g_value_get_enum (gst_structure_id_get_value (structure,
1300 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1303 g_value_get_boolean (gst_structure_id_get_value (structure,
1308 * gst_message_parse_error:
1309 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1310 * @gerror: (out) (allow-none) (transfer full): location for the GError
1311 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1314 * Extracts the GError and debug string from the GstMessage. The values returned
1315 * in the output arguments are copies; the caller must free them when done.
1317 * Typical usage of this function might be:
1320 * switch (GST_MESSAGE_TYPE (msg)) {
1321 * case GST_MESSAGE_ERROR: {
1322 * GError *err = NULL;
1323 * gchar *dbg_info = NULL;
1325 * gst_message_parse_error (msg, &err, &dbg_info);
1326 * g_printerr ("ERROR from element %s: %s\n",
1327 * GST_OBJECT_NAME (msg->src), err->message);
1328 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1329 * g_error_free (err);
1330 * g_free (dbg_info);
1341 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1343 g_return_if_fail (GST_IS_MESSAGE (message));
1344 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1346 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1347 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1348 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1352 * gst_message_parse_warning:
1353 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1354 * @gerror: (out) (allow-none) (transfer full): location for the GError
1355 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1358 * Extracts the GError and debug string from the GstMessage. The values returned
1359 * in the output arguments are copies; the caller must free them when done.
1364 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1367 g_return_if_fail (GST_IS_MESSAGE (message));
1368 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1370 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1371 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1372 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1376 * gst_message_parse_info:
1377 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1378 * @gerror: (out) (allow-none) (transfer full): location for the GError
1379 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1382 * Extracts the GError and debug string from the GstMessage. The values returned
1383 * in the output arguments are copies; the caller must free them when done.
1388 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1390 g_return_if_fail (GST_IS_MESSAGE (message));
1391 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1393 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1394 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1395 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1399 * gst_message_parse_segment_start:
1400 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1401 * @format: (out) (allow-none): Result location for the format, or NULL
1402 * @position: (out) (allow-none): Result location for the position, or NULL
1404 * Extracts the position and format from the segment start message.
1409 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1412 GstStructure *structure;
1414 g_return_if_fail (GST_IS_MESSAGE (message));
1415 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1417 structure = GST_MESSAGE_STRUCTURE (message);
1419 *format = (GstFormat)
1420 g_value_get_enum (gst_structure_id_get_value (structure,
1421 GST_QUARK (FORMAT)));
1424 g_value_get_int64 (gst_structure_id_get_value (structure,
1425 GST_QUARK (POSITION)));
1429 * gst_message_parse_segment_done:
1430 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1431 * @format: (out) (allow-none): Result location for the format, or NULL
1432 * @position: (out) (allow-none): Result location for the position, or NULL
1434 * Extracts the position and format from the segment done message.
1439 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1442 GstStructure *structure;
1444 g_return_if_fail (GST_IS_MESSAGE (message));
1445 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1447 structure = GST_MESSAGE_STRUCTURE (message);
1449 *format = (GstFormat)
1450 g_value_get_enum (gst_structure_id_get_value (structure,
1451 GST_QUARK (FORMAT)));
1454 g_value_get_int64 (gst_structure_id_get_value (structure,
1455 GST_QUARK (POSITION)));
1459 * gst_message_parse_async_done:
1460 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1461 * @running_time: (out) (allow-none): Result location for the running_time or NULL
1463 * Extract the running_time from the async_done message.
1468 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1470 GstStructure *structure;
1472 g_return_if_fail (GST_IS_MESSAGE (message));
1473 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1475 structure = GST_MESSAGE_STRUCTURE (message);
1478 g_value_get_uint64 (gst_structure_id_get_value (structure,
1479 GST_QUARK (RUNNING_TIME)));
1483 * gst_message_parse_request_state:
1484 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1485 * @state: (out) (allow-none): Result location for the requested state or NULL
1487 * Extract the requested state from the request_state message.
1492 gst_message_parse_request_state (GstMessage * message, GstState * state)
1494 GstStructure *structure;
1496 g_return_if_fail (GST_IS_MESSAGE (message));
1497 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1499 structure = GST_MESSAGE_STRUCTURE (message);
1502 g_value_get_enum (gst_structure_id_get_value (structure,
1503 GST_QUARK (NEW_STATE)));
1507 * gst_message_new_stream_status:
1508 * @src: The object originating the message.
1509 * @type: The stream status type.
1510 * @owner: (transfer none): the owner element of @src.
1512 * Create a new stream status message. This message is posted when a streaming
1513 * thread is created/destroyed or when the state changed.
1515 * Returns: (transfer full): the new stream status message.
1520 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1523 GstMessage *message;
1524 GstStructure *structure;
1526 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1527 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1528 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1529 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1535 * gst_message_parse_stream_status:
1536 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1537 * @type: (out): A pointer to hold the status type
1538 * @owner: (out) (transfer none): The owner element of the message source
1540 * Extracts the stream status type and owner the GstMessage. The returned
1541 * owner remains valid for as long as the reference to @message is valid and
1542 * should thus not be unreffed.
1547 gst_message_parse_stream_status (GstMessage * message,
1548 GstStreamStatusType * type, GstElement ** owner)
1550 const GValue *owner_gvalue;
1551 GstStructure *structure;
1553 g_return_if_fail (GST_IS_MESSAGE (message));
1554 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1556 structure = GST_MESSAGE_STRUCTURE (message);
1557 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1558 g_return_if_fail (owner_gvalue != NULL);
1561 *type = (GstStreamStatusType)
1562 g_value_get_enum (gst_structure_id_get_value (structure,
1565 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1569 * gst_message_set_stream_status_object:
1570 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1571 * @object: the object controlling the streaming
1573 * Configures the object handling the streaming thread. This is usually a
1574 * GstTask object but other objects might be added in the future.
1577 gst_message_set_stream_status_object (GstMessage * message,
1578 const GValue * object)
1580 GstStructure *structure;
1582 g_return_if_fail (GST_IS_MESSAGE (message));
1583 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1585 structure = GST_MESSAGE_STRUCTURE (message);
1586 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1590 * gst_message_get_stream_status_object:
1591 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1593 * Extracts the object managing the streaming thread from @message.
1595 * Returns: a GValue containing the object that manages the streaming thread.
1596 * This object is usually of type GstTask but other types can be added in the
1597 * future. The object remains valid as long as @message is valid.
1600 gst_message_get_stream_status_object (GstMessage * message)
1602 const GValue *result;
1603 GstStructure *structure;
1605 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1606 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1609 structure = GST_MESSAGE_STRUCTURE (message);
1610 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1616 * gst_message_new_step_done:
1617 * @src: The object originating the message.
1618 * @format: the format of @amount
1619 * @amount: the amount of stepped data
1620 * @rate: the rate of the stepped amount
1621 * @flush: is this an flushing step
1622 * @intermediate: is this an intermediate step
1623 * @duration: the duration of the data
1624 * @eos: the step caused EOS
1626 * This message is posted by elements when they complete a part, when @intermediate set
1627 * to TRUE, or a complete step operation.
1629 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1630 * @amount of media in format @format.
1632 * Returns: (transfer full): the new step_done message.
1637 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1638 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1641 GstMessage *message;
1642 GstStructure *structure;
1644 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1645 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1646 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1647 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1648 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1649 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1650 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1651 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1652 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1658 * gst_message_parse_step_done:
1659 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1660 * @format: (out) (allow-none): result location for the format
1661 * @amount: (out) (allow-none): result location for the amount
1662 * @rate: (out) (allow-none): result location for the rate
1663 * @flush: (out) (allow-none): result location for the flush flag
1664 * @intermediate: (out) (allow-none): result location for the intermediate flag
1665 * @duration: (out) (allow-none): result location for the duration
1666 * @eos: (out) (allow-none): result location for the EOS flag
1668 * Extract the values the step_done message.
1673 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1674 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1675 guint64 * duration, gboolean * eos)
1677 GstStructure *structure;
1679 g_return_if_fail (GST_IS_MESSAGE (message));
1680 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1682 structure = GST_MESSAGE_STRUCTURE (message);
1683 gst_structure_id_get (structure,
1684 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1685 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1686 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1687 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1688 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1689 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1690 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1694 * gst_message_new_step_start:
1695 * @src: The object originating the message.
1696 * @active: if the step is active or queued
1697 * @format: the format of @amount
1698 * @amount: the amount of stepped data
1699 * @rate: the rate of the stepped amount
1700 * @flush: is this an flushing step
1701 * @intermediate: is this an intermediate step
1703 * This message is posted by elements when they accept or activate a new step
1704 * event for @amount in @format.
1706 * @active is set to FALSE when the element accepted the new step event and has
1707 * queued it for execution in the streaming threads.
1709 * @active is set to TRUE when the element has activated the step operation and
1710 * is now ready to start executing the step in the streaming thread. After this
1711 * message is emitted, the application can queue a new step operation in the
1714 * Returns: (transfer full): The new step_start message.
1719 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1720 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1722 GstMessage *message;
1723 GstStructure *structure;
1725 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1726 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1727 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1728 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1729 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1730 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1731 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1732 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1738 * gst_message_parse_step_start:
1739 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1740 * @active: (out) (allow-none): result location for the active flag
1741 * @format: (out) (allow-none): result location for the format
1742 * @amount: (out) (allow-none): result location for the amount
1743 * @rate: (out) (allow-none): result location for the rate
1744 * @flush: (out) (allow-none): result location for the flush flag
1745 * @intermediate: (out) (allow-none): result location for the intermediate flag
1747 * Extract the values from step_start message.
1752 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1753 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1754 gboolean * intermediate)
1756 GstStructure *structure;
1758 g_return_if_fail (GST_IS_MESSAGE (message));
1759 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1761 structure = GST_MESSAGE_STRUCTURE (message);
1762 gst_structure_id_get (structure,
1763 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1764 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1765 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1766 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1767 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1768 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1772 * gst_message_new_qos:
1773 * @src: The object originating the message.
1774 * @live: if the message was generated by a live element
1775 * @running_time: the running time of the buffer that generated the message
1776 * @stream_time: the stream time of the buffer that generated the message
1777 * @timestamp: the timestamps of the buffer that generated the message
1778 * @duration: the duration of the buffer that generated the message
1780 * A QOS message is posted on the bus whenever an element decides to drop a
1781 * buffer because of QoS reasons or whenever it changes its processing strategy
1782 * because of QoS reasons (quality adjustments such as processing at lower
1785 * This message can be posted by an element that performs synchronisation against the
1786 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1787 * events received from a downstream element (!live).
1789 * @running_time, @stream_time, @timestamp, @duration should be set to the
1790 * respective running-time, stream-time, timestamp and duration of the (dropped)
1791 * buffer that generated the QoS event. Values can be left to
1792 * GST_CLOCK_TIME_NONE when unknown.
1794 * Returns: (transfer full): The new qos message.
1799 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1800 guint64 stream_time, guint64 timestamp, guint64 duration)
1802 GstMessage *message;
1803 GstStructure *structure;
1805 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1806 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1807 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1808 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1809 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1810 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1811 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1812 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1813 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1814 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1815 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1816 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1817 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1823 * gst_message_set_qos_values:
1824 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1825 * @jitter: The difference of the running-time against the deadline.
1826 * @proportion: Long term prediction of the ideal rate relative to normal rate
1827 * to get optimal quality.
1828 * @quality: An element dependent integer value that specifies the current
1829 * quality level of the element. The default maximum quality is 1000000.
1831 * Set the QoS values that have been calculated/analysed from the QoS data
1836 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1837 gdouble proportion, gint quality)
1839 GstStructure *structure;
1841 g_return_if_fail (GST_IS_MESSAGE (message));
1842 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1844 structure = GST_MESSAGE_STRUCTURE (message);
1845 gst_structure_id_set (structure,
1846 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1847 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1848 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1852 * gst_message_set_qos_stats:
1853 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1854 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1855 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1856 * will likely use GST_FORMAT_DEFAULT (samples).
1857 * @processed: Total number of units correctly processed since the last state
1858 * change to READY or a flushing operation.
1859 * @dropped: Total number of units dropped since the last state change to READY
1860 * or a flushing operation.
1862 * Set the QoS stats representing the history of the current continuous pipeline
1865 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1866 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1871 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1872 guint64 processed, guint64 dropped)
1874 GstStructure *structure;
1876 g_return_if_fail (GST_IS_MESSAGE (message));
1877 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1879 structure = GST_MESSAGE_STRUCTURE (message);
1880 gst_structure_id_set (structure,
1881 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1882 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1883 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1887 * gst_message_parse_qos:
1888 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1889 * @live: (out) (allow-none): if the message was generated by a live element
1890 * @running_time: (out) (allow-none): the running time of the buffer that
1891 * generated the message
1892 * @stream_time: (out) (allow-none): the stream time of the buffer that
1893 * generated the message
1894 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1895 * generated the message
1896 * @duration: (out) (allow-none): the duration of the buffer that
1897 * generated the message
1899 * Extract the timestamps and live status from the QoS message.
1901 * The returned values give the running_time, stream_time, timestamp and
1902 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1908 gst_message_parse_qos (GstMessage * message, gboolean * live,
1909 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1912 GstStructure *structure;
1914 g_return_if_fail (GST_IS_MESSAGE (message));
1915 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1917 structure = GST_MESSAGE_STRUCTURE (message);
1918 gst_structure_id_get (structure,
1919 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1920 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1921 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1922 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1923 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1927 * gst_message_parse_qos_values:
1928 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1929 * @jitter: (out) (allow-none): The difference of the running-time against
1931 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1932 * relative to normal rate to get optimal quality.
1933 * @quality: (out) (allow-none): An element dependent integer value that
1934 * specifies the current quality level of the element. The default
1935 * maximum quality is 1000000.
1937 * Extract the QoS values that have been calculated/analysed from the QoS data
1942 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1943 gdouble * proportion, gint * quality)
1945 GstStructure *structure;
1947 g_return_if_fail (GST_IS_MESSAGE (message));
1948 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1950 structure = GST_MESSAGE_STRUCTURE (message);
1951 gst_structure_id_get (structure,
1952 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1953 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1954 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1958 * gst_message_parse_qos_stats:
1959 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1960 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1961 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1962 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1964 * @processed: (out) (allow-none): Total number of units correctly processed
1965 * since the last state change to READY or a flushing operation.
1966 * @dropped: (out) (allow-none): Total number of units dropped since the last
1967 * state change to READY or a flushing operation.
1969 * Extract the QoS stats representing the history of the current continuous
1970 * pipeline playback period.
1972 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1973 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1978 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1979 guint64 * processed, guint64 * dropped)
1981 GstStructure *structure;
1983 g_return_if_fail (GST_IS_MESSAGE (message));
1984 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1986 structure = GST_MESSAGE_STRUCTURE (message);
1987 gst_structure_id_get (structure,
1988 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1989 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1990 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1994 * gst_message_new_progress:
1995 * @src: The object originating the message.
1996 * @type: a #GstProgressType
1997 * @code: a progress code
1998 * @text: free, user visible text describing the progress
2000 * Progress messages are posted by elements when they use an asynchronous task
2001 * to perform actions triggered by a state change.
2003 * @code contains a well defined string describing the action.
2004 * @test should contain a user visible string detailing the current action.
2006 * Returns: (transfer full): The new qos message.
2009 gst_message_new_progress (GstObject * src, GstProgressType type,
2010 const gchar * code, const gchar * text)
2012 GstMessage *message;
2013 GstStructure *structure;
2014 gint percent = 100, timeout = -1;
2016 g_return_val_if_fail (code != NULL, NULL);
2017 g_return_val_if_fail (text != NULL, NULL);
2019 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2022 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2023 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2024 GST_QUARK (CODE), G_TYPE_STRING, code,
2025 GST_QUARK (TEXT), G_TYPE_STRING, text,
2026 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2027 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2028 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2034 * gst_message_parse_progress:
2035 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2036 * @type: (out) (allow-none): location for the type
2037 * @code: (out) (allow-none) (transfer full): location for the code
2038 * @text: (out) (allow-none) (transfer full): location for the text
2040 * Parses the progress @type, @code and @text.
2043 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2044 gchar ** code, gchar ** text)
2046 GstStructure *structure;
2048 g_return_if_fail (GST_IS_MESSAGE (message));
2049 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2051 structure = GST_MESSAGE_STRUCTURE (message);
2052 gst_structure_id_get (structure,
2053 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2054 GST_QUARK (CODE), G_TYPE_STRING, code,
2055 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2059 * gst_message_new_toc:
2060 * @src: the object originating the message.
2061 * @toc: (transfer none): #GstToc structure for the message.
2062 * @updated: whether TOC was updated or not.
2064 * Create a new TOC message. The message is posted by elements
2065 * that discovered or updated a TOC.
2067 * Returns: (transfer full): a new TOC message.
2072 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2074 GstStructure *toc_struct;
2076 g_return_val_if_fail (toc != NULL, NULL);
2078 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2079 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2080 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2082 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2086 * gst_message_parse_toc:
2087 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2088 * @toc: (out) (transfer full): return location for the TOC.
2089 * @updated: (out): return location for the updated flag.
2091 * Extract the TOC from the #GstMessage. The TOC returned in the
2092 * output argument is a copy; the caller must free it with
2093 * gst_toc_unref() when done.
2098 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2100 g_return_if_fail (GST_IS_MESSAGE (message));
2101 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2102 g_return_if_fail (toc != NULL);
2104 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2105 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2106 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2110 * gst_message_new_reset_time:
2111 * @src: (transfer none): The object originating the message.
2112 * @running_time: the requested running-time
2114 * This message is posted when the pipeline running-time should be reset to
2115 * @running_time, like after a flushing seek.
2117 * Returns: (transfer full): The new reset_time message.
2122 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2124 GstMessage *message;
2125 GstStructure *structure;
2127 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2128 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2129 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2135 * gst_message_parse_reset_time:
2136 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2137 * @running_time: (out) (allow-none): Result location for the running_time or
2140 * Extract the running-time from the RESET_TIME message.
2145 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2147 GstStructure *structure;
2149 g_return_if_fail (GST_IS_MESSAGE (message));
2150 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2152 structure = GST_MESSAGE_STRUCTURE (message);
2155 g_value_get_uint64 (gst_structure_id_get_value (structure,
2156 GST_QUARK (RUNNING_TIME)));
2160 * gst_message_new_stream_start:
2161 * @src: (transfer none): The object originating the message.
2163 * Create a new stream_start message. This message is generated and posted in
2164 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2165 * message to the application if all sinks have posted an STREAM_START message.
2167 * Returns: (transfer full): The new stream_start message.
2172 gst_message_new_stream_start (GstObject * src)
2174 GstMessage *message;
2177 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2178 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2185 * gst_message_set_group_id:
2186 * @message: the message
2187 * @group_id: the group id
2189 * Sets the group id on the stream-start message.
2191 * All streams that have the same group id are supposed to be played
2192 * together, i.e. all streams inside a container file should have the
2193 * same group id but different stream ids. The group id should change
2194 * each time the stream is started, resulting in different group ids
2195 * each time a file is played for example.
2202 gst_message_set_group_id (GstMessage * message, guint group_id)
2204 GstStructure *structure;
2206 g_return_if_fail (GST_IS_MESSAGE (message));
2207 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2208 g_return_if_fail (gst_message_is_writable (message));
2210 structure = GST_MESSAGE_STRUCTURE (message);
2211 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2216 * gst_message_parse_group_id:
2217 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2218 * @group_id: (out) (allow-none): Result location for the group id or
2221 * Extract the group from the STREAM_START message.
2223 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2230 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2232 GstStructure *structure;
2235 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2236 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2242 structure = GST_MESSAGE_STRUCTURE (message);
2244 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2248 *group_id = g_value_get_uint (v);
2253 * gst_message_new_need_context:
2254 * @src: (transfer none): The object originating the message.
2255 * @context_type: The context type that is needed
2257 * This message is posted when an element needs a specific #GstContext.
2259 * Returns: (transfer full): The new need-context message.
2266 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2268 GstMessage *message;
2269 GstStructure *structure;
2271 g_return_val_if_fail (context_type != NULL, NULL);
2273 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2274 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2275 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2281 * gst_message_parse_context_type:
2282 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2283 * @context_type: (out) (allow-none): the context type, or NULL
2285 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2287 * Returns: a #gboolean indicating if the parsing succeeded.
2292 gst_message_parse_context_type (GstMessage * message,
2293 const gchar ** context_type)
2295 GstStructure *structure;
2296 const GValue *value;
2298 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2301 structure = GST_MESSAGE_STRUCTURE (message);
2304 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2305 *context_type = g_value_get_string (value);
2312 * gst_message_new_have_context:
2313 * @src: (transfer none): The object originating the message.
2314 * @context: (transfer full): the context
2316 * This message is posted when an element has a new local #GstContext.
2318 * Returns: (transfer full): The new have-context message.
2325 gst_message_new_have_context (GstObject * src, GstContext * context)
2327 GstMessage *message;
2328 GstStructure *structure;
2330 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2331 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2332 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2333 gst_context_unref (context);
2339 * gst_message_parse_have_context:
2340 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2341 * @context: (out) (transfer full) (allow-none): Result location for the
2344 * Extract the context from the HAVE_CONTEXT message.
2351 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2353 g_return_if_fail (GST_IS_MESSAGE (message));
2354 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2357 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2358 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);