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 static GType _gst_message_type = 0;
72 static GstMessageQuarks message_quarks[] = {
73 {GST_MESSAGE_UNKNOWN, "unknown", 0},
74 {GST_MESSAGE_EOS, "eos", 0},
75 {GST_MESSAGE_ERROR, "error", 0},
76 {GST_MESSAGE_WARNING, "warning", 0},
77 {GST_MESSAGE_INFO, "info", 0},
78 {GST_MESSAGE_TAG, "tag", 0},
79 {GST_MESSAGE_BUFFERING, "buffering", 0},
80 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
81 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
82 {GST_MESSAGE_STEP_DONE, "step-done", 0},
83 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
84 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
85 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
86 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
87 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
88 {GST_MESSAGE_APPLICATION, "application", 0},
89 {GST_MESSAGE_ELEMENT, "element", 0},
90 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
91 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
92 {GST_MESSAGE_DURATION, "duration", 0},
93 {GST_MESSAGE_LATENCY, "latency", 0},
94 {GST_MESSAGE_ASYNC_START, "async-start", 0},
95 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
96 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
97 {GST_MESSAGE_STEP_START, "step-start", 0},
98 {GST_MESSAGE_QOS, "qos", 0},
99 {GST_MESSAGE_PROGRESS, "progress", 0},
104 _gst_message_initialize (void)
108 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
110 /* the GstMiniObject types need to be class_ref'd once before it can be
111 * done from multiple threads;
112 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
113 gst_message_get_type ();
115 for (i = 0; message_quarks[i].name; i++) {
116 message_quarks[i].quark =
117 g_quark_from_static_string (message_quarks[i].name);
122 * gst_message_type_get_name:
123 * @type: the message type
125 * Get a printable name for the given message type. Do not modify or free.
127 * Returns: a reference to the static name of the message.
130 gst_message_type_get_name (GstMessageType type)
134 for (i = 0; message_quarks[i].name; i++) {
135 if (type == message_quarks[i].type)
136 return message_quarks[i].name;
142 * gst_message_type_to_quark:
143 * @type: the message type
145 * Get the unique quark for the given message type.
147 * Returns: the quark associated with the message type
150 gst_message_type_to_quark (GstMessageType type)
154 for (i = 0; message_quarks[i].name; i++) {
155 if (type == message_quarks[i].type)
156 return message_quarks[i].quark;
162 gst_message_get_type (void)
164 if (G_UNLIKELY (_gst_message_type == 0)) {
165 _gst_message_type = gst_mini_object_register ("GstMessage");
167 return _gst_message_type;
172 _gst_message_free (GstMessage * message)
174 g_return_if_fail (message != NULL);
176 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p", message);
178 if (GST_MESSAGE_SRC (message)) {
179 gst_object_unref (GST_MESSAGE_SRC (message));
180 GST_MESSAGE_SRC (message) = NULL;
184 GST_MESSAGE_LOCK (message);
185 GST_MESSAGE_SIGNAL (message);
186 GST_MESSAGE_UNLOCK (message);
189 if (message->structure) {
190 gst_structure_set_parent_refcount (message->structure, NULL);
191 gst_structure_free (message->structure);
194 g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
198 _gst_message_copy (GstMessage * message)
202 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p", message);
204 copy = g_slice_new0 (GstMessage);
206 gst_mini_object_init (GST_MINI_OBJECT_CAST (copy),
207 _gst_message_type, sizeof (GstMessage));
209 copy->mini_object.copy = (GstMiniObjectCopyFunction) _gst_message_copy;
210 copy->mini_object.free = (GstMiniObjectFreeFunction) _gst_message_free;
212 GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message);
213 GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message);
214 GST_MESSAGE_TYPE (copy) = GST_MESSAGE_TYPE (message);
215 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
216 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
218 if (GST_MESSAGE_SRC (message)) {
219 GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
222 if (message->structure) {
223 copy->structure = gst_structure_copy (message->structure);
224 gst_structure_set_parent_refcount (copy->structure,
225 ©->mini_object.refcount);
232 * gst_message_new_custom:
233 * @type: The #GstMessageType to distinguish messages
234 * @src: The object originating the message.
235 * @structure: (transfer full): the structure for the message. The message
236 * will take ownership of the structure.
238 * Create a new custom-typed message. This can be used for anything not
239 * handled by other message-specific functions to pass a message to the
240 * app. The structure field can be NULL.
242 * Returns: (transfer full): The new message.
247 gst_message_new_custom (GstMessageType type, GstObject * src,
248 GstStructure * structure)
252 message = g_slice_new0 (GstMessage);
254 gst_mini_object_init (GST_MINI_OBJECT_CAST (message),
255 _gst_message_type, sizeof (GstMessage));
257 message->mini_object.copy = (GstMiniObjectCopyFunction) _gst_message_copy;
258 message->mini_object.free = (GstMiniObjectFreeFunction) _gst_message_free;
260 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
261 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
262 gst_message_type_get_name (type));
264 message->type = type;
267 gst_object_ref (src);
271 gst_structure_set_parent_refcount (structure,
272 &message->mini_object.refcount);
274 message->structure = structure;
276 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
277 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
283 * gst_message_get_seqnum:
284 * @message: A #GstMessage.
286 * Retrieve the sequence number of a message.
288 * Messages have ever-incrementing sequence numbers, which may also be set
289 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
290 * to indicate that a message corresponds to some other set of messages or
291 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
292 * is considered good practice to make this correspondence when possible, though
293 * it is not required.
295 * Note that events and messages share the same sequence number incrementor;
296 * two events or messages will never not have the same sequence number unless
297 * that correspondence was made explicitly.
299 * Returns: The message's sequence number.
306 gst_message_get_seqnum (GstMessage * message)
308 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
310 return GST_MESSAGE_SEQNUM (message);
314 * gst_message_set_seqnum:
315 * @message: A #GstMessage.
316 * @seqnum: A sequence number.
318 * Set the sequence number of a message.
320 * This function might be called by the creator of a message to indicate that
321 * the message relates to other messages or events. See gst_message_get_seqnum()
322 * for more information.
329 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
331 g_return_if_fail (GST_IS_MESSAGE (message));
333 GST_MESSAGE_SEQNUM (message) = seqnum;
337 * gst_message_new_eos:
338 * @src: (transfer none): The object originating the message.
340 * Create a new eos message. This message is generated and posted in
341 * the sink elements of a GstBin. The bin will only forward the EOS
342 * message to the application if all sinks have posted an EOS message.
344 * Returns: (transfer full): The new eos message.
349 gst_message_new_eos (GstObject * src)
353 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
359 * gst_message_new_error:
360 * @src: (transfer none): The object originating the message.
361 * @error: (transfer none): The GError for this message.
362 * @debug: A debugging string.
364 * Create a new error message. The message will copy @error and
365 * @debug. This message is posted by element when a fatal event
366 * occured. The pipeline will probably (partially) stop. The application
367 * receiving this message should stop the pipeline.
369 * Returns: (transfer full): the new error message.
374 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
377 GstStructure *structure;
379 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ERROR),
380 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
381 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
382 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
388 * gst_message_new_warning:
389 * @src: (transfer none): The object originating the message.
390 * @error: (transfer none): The GError for this message.
391 * @debug: A debugging string.
393 * Create a new warning message. The message will make copies of @error and
396 * Returns: (transfer full): The new warning message.
401 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
404 GstStructure *structure;
406 structure = gst_structure_id_new (GST_QUARK (MESSAGE_WARNING),
407 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
408 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
409 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
415 * gst_message_new_info:
416 * @src: (transfer none): The object originating the message.
417 * @error: (transfer none): The GError for this message.
418 * @debug: A debugging string.
420 * Create a new info message. The message will make copies of @error and
425 * Returns: (transfer full): the new info message.
430 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
433 GstStructure *structure;
435 structure = gst_structure_id_new (GST_QUARK (MESSAGE_INFO),
436 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
437 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
438 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
444 * gst_message_new_tag:
445 * @src: (transfer none): The object originating the message.
446 * @tag_list: (transfer full): the tag list for the message.
448 * Create a new tag message. The message will take ownership of the tag list.
449 * The message is posted by elements that discovered a new taglist.
451 * Returns: (transfer full): the new tag message.
456 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
460 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
463 gst_message_new_custom (GST_MESSAGE_TAG, src, (GstStructure *) tag_list);
469 * gst_message_new_tag_full:
470 * @src: (transfer none): the object originating the message.
471 * @pad: (transfer none): the originating pad for the tag.
472 * @tag_list: (transfer full): the tag list for the message.
474 * Create a new tag message. The message will take ownership of the tag list.
475 * The message is posted by elements that discovered a new taglist.
479 * Returns: (transfer full): the new tag message.
484 gst_message_new_tag_full (GstObject * src, GstPad * pad, GstTagList * tag_list)
489 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
490 g_return_val_if_fail (pad == NULL || GST_IS_PAD (pad), NULL);
492 s = (GstStructure *) tag_list;
494 gst_structure_set (s, "source-pad", GST_TYPE_PAD, pad, NULL);
496 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
502 * gst_message_new_buffering:
503 * @src: (transfer none): The object originating the message.
504 * @percent: The buffering percent
506 * Create a new buffering message. This message can be posted by an element that
507 * needs to buffer data before it can continue processing. @percent should be a
508 * value between 0 and 100. A value of 100 means that the buffering completed.
510 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
511 * @percent is 100, the application can set the pipeline (back) to PLAYING.
512 * The application must be prepared to receive BUFFERING messages in the
513 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
514 * message with @percent set to 100, which can happen after the pipeline
515 * completed prerolling.
519 * Returns: (transfer full): The new buffering message.
524 gst_message_new_buffering (GstObject * src, gint percent)
527 GstStructure *structure;
529 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
531 structure = gst_structure_id_new (GST_QUARK (MESSAGE_BUFFERING),
532 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
533 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
534 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
535 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
536 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
537 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
538 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
544 * gst_message_new_state_changed:
545 * @src: (transfer none): the object originating the message
546 * @oldstate: the previous state
547 * @newstate: the new (current) state
548 * @pending: the pending (target) state
550 * Create a state change message. This message is posted whenever an element
553 * Returns: (transfer full): the new state change message.
558 gst_message_new_state_changed (GstObject * src,
559 GstState oldstate, GstState newstate, GstState pending)
562 GstStructure *structure;
564 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STATE),
565 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
566 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
567 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
568 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
574 * gst_message_new_state_dirty:
575 * @src: (transfer none): the object originating the message
577 * Create a state dirty message. This message is posted whenever an element
578 * changed its state asynchronously and is used internally to update the
579 * states of container objects.
581 * Returns: (transfer full): the new state dirty message.
586 gst_message_new_state_dirty (GstObject * src)
590 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
596 * gst_message_new_clock_provide:
597 * @src: (transfer none): the object originating the message.
598 * @clock: (transfer none): the clock it provides
599 * @ready: TRUE if the sender can provide a clock
601 * Create a clock provide message. This message is posted whenever an
602 * element is ready to provide a clock or lost its ability to provide
603 * a clock (maybe because it paused or became EOS).
605 * This message is mainly used internally to manage the clock
608 * Returns: (transfer full): the new provide clock message.
613 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
617 GstStructure *structure;
619 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
620 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
621 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
622 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
628 * gst_message_new_clock_lost:
629 * @src: (transfer none): the object originating the message.
630 * @clock: (transfer none): the clock that was lost
632 * Create a clock lost message. This message is posted whenever the
633 * clock is not valid anymore.
635 * If this message is posted by the pipeline, the pipeline will
636 * select a new clock again when it goes to PLAYING. It might therefore
637 * be needed to set the pipeline to PAUSED and PLAYING again.
639 * Returns: (transfer full): The new clock lost message.
644 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
647 GstStructure *structure;
649 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_LOST),
650 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
651 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
657 * gst_message_new_new_clock:
658 * @src: (transfer none): The object originating the message.
659 * @clock: (transfer none): the new selected clock
661 * Create a new clock message. This message is posted whenever the
662 * pipeline selectes a new clock for the pipeline.
664 * Returns: (transfer full): The new new clock message.
669 gst_message_new_new_clock (GstObject * src, GstClock * clock)
672 GstStructure *structure;
674 structure = gst_structure_id_new (GST_QUARK (MESSAGE_NEW_CLOCK),
675 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
676 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
682 * gst_message_new_structure_change:
683 * @src: (transfer none): The object originating the message.
684 * @type: The change type.
685 * @owner: (transfer none): The owner element of @src.
686 * @busy: Whether the structure change is busy.
688 * Create a new structure change message. This message is posted when the
689 * structure of a pipeline is in the process of being changed, for example
690 * when pads are linked or unlinked.
692 * @src should be the sinkpad that unlinked or linked.
694 * Returns: (transfer full): the new structure change message.
701 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
702 GstElement * owner, gboolean busy)
705 GstStructure *structure;
707 g_return_val_if_fail (GST_IS_PAD (src), NULL);
708 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
709 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
711 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
712 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
713 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
714 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
716 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
723 * gst_message_new_segment_start:
724 * @src: (transfer none): The object originating the message.
725 * @format: The format of the position being played
726 * @position: The position of the segment being played
728 * Create a new segment message. This message is posted by elements that
729 * start playback of a segment as a result of a segment seek. This message
730 * is not received by the application but is used for maintenance reasons in
731 * container elements.
733 * Returns: (transfer full): the new segment start message.
738 gst_message_new_segment_start (GstObject * src, GstFormat format,
742 GstStructure *structure;
744 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_START),
745 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
746 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
747 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
753 * gst_message_new_segment_done:
754 * @src: (transfer none): the object originating the message.
755 * @format: The format of the position being done
756 * @position: The position of the segment being done
758 * Create a new segment done message. This message is posted by elements that
759 * finish playback of a segment as a result of a segment seek. This message
760 * is received by the application after all elements that posted a segment_start
761 * have posted the segment_done.
763 * Returns: (transfer full): the new segment done message.
768 gst_message_new_segment_done (GstObject * src, GstFormat format,
772 GstStructure *structure;
774 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_DONE),
775 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
776 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
777 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
783 * gst_message_new_application:
784 * @src: (transfer none): the object originating the message.
785 * @structure: (transfer full): the structure for the message. The message
786 * will take ownership of the structure.
788 * Create a new application-typed message. GStreamer will never create these
789 * messages; they are a gift from us to you. Enjoy.
791 * Returns: (transfer full): The new application message.
796 gst_message_new_application (GstObject * src, GstStructure * structure)
798 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
802 * gst_message_new_element:
803 * @src: (transfer none): The object originating the message.
804 * @structure: (transfer full): The structure for the message. The message
805 * will take ownership of the structure.
807 * Create a new element-specific message. This is meant as a generic way of
808 * allowing one-way communication from an element to an application, for example
809 * "the firewire cable was unplugged". The format of the message should be
810 * documented in the element's documentation. The structure field can be NULL.
812 * Returns: (transfer full): The new element message.
817 gst_message_new_element (GstObject * src, GstStructure * structure)
819 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
823 * gst_message_new_duration:
824 * @src: (transfer none): The object originating the message.
825 * @format: The format of the duration
826 * @duration: The new duration
828 * Create a new duration message. This message is posted by elements that
829 * know the duration of a stream in a specific format. This message
830 * is received by bins and is used to calculate the total duration of a
831 * pipeline. Elements may post a duration message with a duration of
832 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
833 * cached duration should be discarded. The new duration can then be
834 * retrieved via a query.
836 * Returns: (transfer full): The new duration message.
841 gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration)
844 GstStructure *structure;
846 structure = gst_structure_id_new (GST_QUARK (MESSAGE_DURATION),
847 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
848 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
849 message = gst_message_new_custom (GST_MESSAGE_DURATION, src, structure);
855 * gst_message_new_async_start:
856 * @src: (transfer none): The object originating the message.
857 * @new_base_time: if a new base_time should be set on the element
859 * This message is posted by elements when they start an ASYNC state change.
860 * @new_base_time is set to TRUE when the element lost its state when it was
863 * Returns: (transfer full): The new async_start message.
870 gst_message_new_async_start (GstObject * src, gboolean new_base_time)
873 GstStructure *structure;
875 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ASYNC_START),
876 GST_QUARK (NEW_BASE_TIME), G_TYPE_BOOLEAN, new_base_time, NULL);
877 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, structure);
883 * gst_message_new_async_done:
884 * @src: (transfer none): The object originating the message.
886 * The message is posted when elements completed an ASYNC state change.
888 * Returns: (transfer full): The new async_done message.
895 gst_message_new_async_done (GstObject * src)
899 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, NULL);
905 * gst_message_new_latency:
906 * @src: (transfer none): The object originating the message.
908 * This message can be posted by elements when their latency requirements have
911 * Returns: (transfer full): The new latency message.
918 gst_message_new_latency (GstObject * src)
922 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
928 * gst_message_new_request_state:
929 * @src: (transfer none): the object originating the message.
930 * @state: The new requested state
932 * This message can be posted by elements when they want to have their state
933 * changed. A typical use case would be an audio server that wants to pause the
934 * pipeline because a higher priority stream is being played.
936 * Returns: (transfer full): the new requst state message.
943 gst_message_new_request_state (GstObject * src, GstState state)
946 GstStructure *structure;
948 structure = gst_structure_id_new (GST_QUARK (MESSAGE_REQUEST_STATE),
949 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
950 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
956 * gst_message_get_structure:
957 * @message: The #GstMessage.
959 * Access the structure of the message.
961 * Returns: (transfer none): The structure of the message. The structure is
962 * still owned by the message, which means that you should not free it and
963 * that the pointer becomes invalid when you free the message.
968 gst_message_get_structure (GstMessage * message)
970 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
972 return message->structure;
976 * gst_message_parse_tag:
977 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
978 * @tag_list: (out callee-allocates): return location for the tag-list.
980 * Extracts the tag list from the GstMessage. The tag list returned in the
981 * output argument is a copy; the caller must free it when done.
983 * Typical usage of this function might be:
986 * switch (GST_MESSAGE_TYPE (msg)) {
987 * case GST_MESSAGE_TAG: {
988 * GstTagList *tags = NULL;
990 * gst_message_parse_tag (msg, &tags);
991 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
992 * handle_tags (tags);
993 * gst_tag_list_free (tags);
1004 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1008 g_return_if_fail (GST_IS_MESSAGE (message));
1009 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1010 g_return_if_fail (tag_list != NULL);
1012 ret = gst_structure_copy (message->structure);
1013 gst_structure_remove_field (ret, "source-pad");
1015 *tag_list = (GstTagList *) ret;
1019 * gst_message_parse_tag_full:
1020 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1021 * @pad: (out callee-allocates): location where the originating pad is stored,
1023 * @tag_list: (out callee-allocates): return location for the tag-list.
1025 * Extracts the tag list from the GstMessage. The tag list returned in the
1026 * output argument is a copy; the caller must free it when done.
1033 gst_message_parse_tag_full (GstMessage * message, GstPad ** pad,
1034 GstTagList ** tag_list)
1038 g_return_if_fail (GST_IS_MESSAGE (message));
1039 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1040 g_return_if_fail (tag_list != NULL);
1042 ret = gst_structure_copy (message->structure);
1044 if (gst_structure_has_field (ret, "source-pad") && pad) {
1047 v = gst_structure_get_value (ret, "source-pad");
1048 if (v && G_VALUE_HOLDS (v, GST_TYPE_PAD))
1049 *pad = g_value_dup_object (v);
1055 gst_structure_remove_field (ret, "source-pad");
1057 *tag_list = (GstTagList *) ret;
1061 * gst_message_parse_buffering:
1062 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1063 * @percent: (out) (allow-none): Return location for the percent.
1065 * Extracts the buffering percent from the GstMessage. see also
1066 * gst_message_new_buffering().
1073 gst_message_parse_buffering (GstMessage * message, gint * percent)
1075 g_return_if_fail (GST_IS_MESSAGE (message));
1076 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1079 *percent = g_value_get_int (gst_structure_id_get_value (message->structure,
1080 GST_QUARK (BUFFER_PERCENT)));
1084 * gst_message_set_buffering_stats:
1085 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1086 * @mode: a buffering mode
1087 * @avg_in: the average input rate
1088 * @avg_out: the average output rate
1089 * @buffering_left: amount of buffering time left in milliseconds
1091 * Configures the buffering stats values in @message.
1096 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1097 gint avg_in, gint avg_out, gint64 buffering_left)
1099 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1101 gst_structure_id_set (message->structure,
1102 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1103 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1104 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1105 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1109 * gst_message_parse_buffering_stats:
1110 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1111 * @mode: (out) (allow-none): a buffering mode, or NULL
1112 * @avg_in: (out) (allow-none): the average input rate, or NULL
1113 * @avg_out: (out) (allow-none): the average output rate, or NULL
1114 * @buffering_left: (out) (allow-none): amount of buffering time left in
1115 * milliseconds, or NULL
1117 * Extracts the buffering stats values from @message.
1122 gst_message_parse_buffering_stats (GstMessage * message,
1123 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1124 gint64 * buffering_left)
1126 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1129 *mode = g_value_get_enum (gst_structure_id_get_value (message->structure,
1130 GST_QUARK (BUFFERING_MODE)));
1132 *avg_in = g_value_get_int (gst_structure_id_get_value (message->structure,
1133 GST_QUARK (AVG_IN_RATE)));
1135 *avg_out = g_value_get_int (gst_structure_id_get_value (message->structure,
1136 GST_QUARK (AVG_OUT_RATE)));
1139 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1140 GST_QUARK (BUFFERING_LEFT)));
1144 * gst_message_parse_state_changed:
1145 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1146 * @oldstate: (out) (allow-none): the previous state, or NULL
1147 * @newstate: (out) (allow-none): the new (current) state, or NULL
1148 * @pending: (out) (allow-none): the pending (target) state, or NULL
1150 * Extracts the old and new states from the GstMessage.
1152 * Typical usage of this function might be:
1155 * switch (GST_MESSAGE_TYPE (msg)) {
1156 * case GST_MESSAGE_STATE_CHANGED: {
1157 * GstState old_state, new_state;
1159 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1160 * g_print ("Element %s changed state from %s to %s.\n",
1161 * GST_OBJECT_NAME (msg->src),
1162 * gst_element_state_get_name (old_state),
1163 * gst_element_state_get_name (new_state));
1174 gst_message_parse_state_changed (GstMessage * message,
1175 GstState * oldstate, GstState * newstate, GstState * pending)
1177 g_return_if_fail (GST_IS_MESSAGE (message));
1178 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1182 g_value_get_enum (gst_structure_id_get_value (message->structure,
1183 GST_QUARK (OLD_STATE)));
1186 g_value_get_enum (gst_structure_id_get_value (message->structure,
1187 GST_QUARK (NEW_STATE)));
1189 *pending = g_value_get_enum (gst_structure_id_get_value (message->structure,
1190 GST_QUARK (PENDING_STATE)));
1194 * gst_message_parse_clock_provide:
1195 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1196 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1198 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1200 * Extracts the clock and ready flag from the GstMessage.
1201 * The clock object returned remains valid until the message is freed.
1206 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1209 const GValue *clock_gvalue;
1211 g_return_if_fail (GST_IS_MESSAGE (message));
1212 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1215 gst_structure_id_get_value (message->structure, GST_QUARK (CLOCK));
1216 g_return_if_fail (clock_gvalue != NULL);
1217 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1221 g_value_get_boolean (gst_structure_id_get_value (message->structure,
1222 GST_QUARK (READY)));
1224 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1228 * gst_message_parse_clock_lost:
1229 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1230 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1232 * Extracts the lost clock from the GstMessage.
1233 * The clock object returned remains valid until the message is freed.
1238 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1240 const GValue *clock_gvalue;
1242 g_return_if_fail (GST_IS_MESSAGE (message));
1243 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1246 gst_structure_id_get_value (message->structure, GST_QUARK (CLOCK));
1247 g_return_if_fail (clock_gvalue != NULL);
1248 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1251 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1255 * gst_message_parse_new_clock:
1256 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1257 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1260 * Extracts the new clock from the GstMessage.
1261 * The clock object returned remains valid until the message is freed.
1266 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1268 const GValue *clock_gvalue;
1270 g_return_if_fail (GST_IS_MESSAGE (message));
1271 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1274 gst_structure_id_get_value (message->structure, GST_QUARK (CLOCK));
1275 g_return_if_fail (clock_gvalue != NULL);
1276 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1279 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1283 * gst_message_parse_structure_change:
1284 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1285 * @type: (out): A pointer to hold the change type
1286 * @owner: (out) (allow-none) (transfer none): The owner element of the
1288 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1289 * progress or has been completed
1291 * Extracts the change type and completion status from the GstMessage.
1298 gst_message_parse_structure_change (GstMessage * message,
1299 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1301 const GValue *owner_gvalue;
1303 g_return_if_fail (GST_IS_MESSAGE (message));
1304 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1307 gst_structure_id_get_value (message->structure, GST_QUARK (OWNER));
1308 g_return_if_fail (owner_gvalue != NULL);
1309 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1312 *type = g_value_get_enum (gst_structure_id_get_value (message->structure,
1315 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1318 g_value_get_boolean (gst_structure_id_get_value (message->structure,
1323 * gst_message_parse_error:
1324 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1325 * @gerror: (out) (allow-none) (transfer full): location for the GError
1326 * @debug: (out) (allow-none) (transfer full): location for the debug message,
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.
1332 * Typical usage of this function might be:
1335 * switch (GST_MESSAGE_TYPE (msg)) {
1336 * case GST_MESSAGE_ERROR: {
1337 * GError *err = NULL;
1338 * gchar *dbg_info = NULL;
1340 * gst_message_parse_error (msg, &err, &dbg_info);
1341 * g_printerr ("ERROR from element %s: %s\n",
1342 * GST_OBJECT_NAME (msg->src), err->message);
1343 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1344 * g_error_free (err);
1345 * g_free (dbg_info);
1356 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1358 const GValue *error_gvalue;
1361 g_return_if_fail (GST_IS_MESSAGE (message));
1362 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1365 gst_structure_id_get_value (message->structure, GST_QUARK (GERROR));
1366 g_return_if_fail (error_gvalue != NULL);
1367 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1369 error_val = (GError *) g_value_get_boxed (error_gvalue);
1371 *gerror = g_error_copy (error_val);
1377 g_value_dup_string (gst_structure_id_get_value (message->structure,
1378 GST_QUARK (DEBUG)));
1382 * gst_message_parse_warning:
1383 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1384 * @gerror: (out) (allow-none) (transfer full): location for the GError
1385 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1388 * Extracts the GError and debug string from the GstMessage. The values returned
1389 * in the output arguments are copies; the caller must free them when done.
1394 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1397 const GValue *error_gvalue;
1400 g_return_if_fail (GST_IS_MESSAGE (message));
1401 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1404 gst_structure_id_get_value (message->structure, GST_QUARK (GERROR));
1405 g_return_if_fail (error_gvalue != NULL);
1406 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1408 error_val = (GError *) g_value_get_boxed (error_gvalue);
1410 *gerror = g_error_copy (error_val);
1416 g_value_dup_string (gst_structure_id_get_value (message->structure,
1417 GST_QUARK (DEBUG)));
1421 * gst_message_parse_info:
1422 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1423 * @gerror: (out) (allow-none) (transfer full): location for the GError
1424 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1427 * Extracts the GError and debug string from the GstMessage. The values returned
1428 * in the output arguments are copies; the caller must free them when done.
1435 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1437 const GValue *error_gvalue;
1440 g_return_if_fail (GST_IS_MESSAGE (message));
1441 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1444 gst_structure_id_get_value (message->structure, GST_QUARK (GERROR));
1445 g_return_if_fail (error_gvalue != NULL);
1446 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1448 error_val = (GError *) g_value_get_boxed (error_gvalue);
1450 *gerror = g_error_copy (error_val);
1456 g_value_dup_string (gst_structure_id_get_value (message->structure,
1457 GST_QUARK (DEBUG)));
1461 * gst_message_parse_segment_start:
1462 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1463 * @format: (out): Result location for the format, or NULL
1464 * @position: (out): Result location for the position, or NULL
1466 * Extracts the position and format from the segment start message.
1471 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1474 g_return_if_fail (GST_IS_MESSAGE (message));
1475 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1479 g_value_get_enum (gst_structure_id_get_value (message->structure,
1480 GST_QUARK (FORMAT)));
1483 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1484 GST_QUARK (POSITION)));
1488 * gst_message_parse_segment_done:
1489 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1490 * @format: (out): Result location for the format, or NULL
1491 * @position: (out): Result location for the position, or NULL
1493 * Extracts the position and format from the segment start message.
1498 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1501 g_return_if_fail (GST_IS_MESSAGE (message));
1502 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1506 g_value_get_enum (gst_structure_id_get_value (message->structure,
1507 GST_QUARK (FORMAT)));
1510 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1511 GST_QUARK (POSITION)));
1515 * gst_message_parse_duration:
1516 * @message: A valid #GstMessage of type GST_MESSAGE_DURATION.
1517 * @format: (out): Result location for the format, or NULL
1518 * @duration: (out): Result location for the duration, or NULL
1520 * Extracts the duration and format from the duration message. The duration
1521 * might be GST_CLOCK_TIME_NONE, which indicates that the duration has
1522 * changed. Applications should always use a query to retrieve the duration
1528 gst_message_parse_duration (GstMessage * message, GstFormat * format,
1531 g_return_if_fail (GST_IS_MESSAGE (message));
1532 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DURATION);
1536 g_value_get_enum (gst_structure_id_get_value (message->structure,
1537 GST_QUARK (FORMAT)));
1540 g_value_get_int64 (gst_structure_id_get_value (message->structure,
1541 GST_QUARK (DURATION)));
1545 * gst_message_parse_async_start:
1546 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1547 * @new_base_time: (out): Result location for the new_base_time or NULL
1549 * Extract the new_base_time from the async_start message.
1556 gst_message_parse_async_start (GstMessage * message, gboolean * new_base_time)
1558 g_return_if_fail (GST_IS_MESSAGE (message));
1559 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_START);
1563 g_value_get_boolean (gst_structure_id_get_value (message->structure,
1564 GST_QUARK (NEW_BASE_TIME)));
1568 * gst_message_parse_request_state:
1569 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1570 * @state: (out): Result location for the requested state or NULL
1572 * Extract the requested state from the request_state message.
1579 gst_message_parse_request_state (GstMessage * message, GstState * state)
1581 g_return_if_fail (GST_IS_MESSAGE (message));
1582 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1585 *state = g_value_get_enum (gst_structure_id_get_value (message->structure,
1586 GST_QUARK (NEW_STATE)));
1590 * gst_message_new_stream_status:
1591 * @src: The object originating the message.
1592 * @type: The stream status type.
1593 * @owner: (transfer none): the owner element of @src.
1595 * Create a new stream status message. This message is posted when a streaming
1596 * thread is created/destroyed or when the state changed.
1598 * Returns: (transfer full): the new stream status message.
1605 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1608 GstMessage *message;
1609 GstStructure *structure;
1611 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STREAM_STATUS),
1612 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1613 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1614 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1620 * gst_message_parse_stream_status:
1621 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1622 * @type: (out): A pointer to hold the status type
1623 * @owner: (out) (transfer none): The owner element of the message source
1625 * Extracts the stream status type and owner the GstMessage. The returned
1626 * owner remains valid for as long as the reference to @message is valid and
1627 * should thus not be unreffed.
1634 gst_message_parse_stream_status (GstMessage * message,
1635 GstStreamStatusType * type, GstElement ** owner)
1637 const GValue *owner_gvalue;
1639 g_return_if_fail (GST_IS_MESSAGE (message));
1640 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1643 gst_structure_id_get_value (message->structure, GST_QUARK (OWNER));
1644 g_return_if_fail (owner_gvalue != NULL);
1647 *type = g_value_get_enum (gst_structure_id_get_value (message->structure,
1650 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1654 * gst_message_set_stream_status_object:
1655 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1656 * @object: the object controlling the streaming
1658 * Configures the object handling the streaming thread. This is usually a
1659 * GstTask object but other objects might be added in the future.
1664 gst_message_set_stream_status_object (GstMessage * message,
1665 const GValue * object)
1667 g_return_if_fail (GST_IS_MESSAGE (message));
1668 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1670 gst_structure_id_set_value (message->structure, GST_QUARK (OBJECT), object);
1674 * gst_message_get_stream_status_object:
1675 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1677 * Extracts the object managing the streaming thread from @message.
1679 * Returns: a GValue containing the object that manages the streaming thread.
1680 * This object is usually of type GstTask but other types can be added in the
1681 * future. The object remains valid as long as @message is valid.
1686 gst_message_get_stream_status_object (GstMessage * message)
1688 const GValue *result;
1690 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1691 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1694 result = gst_structure_id_get_value (message->structure, GST_QUARK (OBJECT));
1700 * gst_message_new_step_done:
1701 * @src: The object originating the message.
1702 * @format: the format of @amount
1703 * @amount: the amount of stepped data
1704 * @rate: the rate of the stepped amount
1705 * @flush: is this an flushing step
1706 * @intermediate: is this an intermediate step
1707 * @duration: the duration of the data
1708 * @eos: the step caused EOS
1710 * This message is posted by elements when they complete a part, when @intermediate set
1711 * to TRUE, or a complete step operation.
1713 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1714 * @amount of media in format @format.
1716 * Returns: (transfer full): the new step_done message.
1723 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1724 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1727 GstMessage *message;
1728 GstStructure *structure;
1730 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_DONE),
1731 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1732 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1733 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1734 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1735 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1736 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1737 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1738 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1744 * gst_message_parse_step_done:
1745 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1746 * @format: (out) (allow-none): result location for the format
1747 * @amount: (out) (allow-none): result location for the amount
1748 * @rate: (out) (allow-none): result location for the rate
1749 * @flush: (out) (allow-none): result location for the flush flag
1750 * @intermediate: (out) (allow-none): result location for the intermediate flag
1751 * @duration: (out) (allow-none): result location for the duration
1752 * @eos: (out) (allow-none): result location for the EOS flag
1754 * Extract the values the step_done message.
1761 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1762 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1763 guint64 * duration, gboolean * eos)
1765 g_return_if_fail (GST_IS_MESSAGE (message));
1766 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1768 gst_structure_id_get (message->structure,
1769 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1770 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1771 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1772 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1773 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1774 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1775 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1779 * gst_message_new_step_start:
1780 * @src: The object originating the message.
1781 * @active: if the step is active or queued
1782 * @format: the format of @amount
1783 * @amount: the amount of stepped data
1784 * @rate: the rate of the stepped amount
1785 * @flush: is this an flushing step
1786 * @intermediate: is this an intermediate step
1788 * This message is posted by elements when they accept or activate a new step
1789 * event for @amount in @format.
1791 * @active is set to FALSE when the element accepted the new step event and has
1792 * queued it for execution in the streaming threads.
1794 * @active is set to TRUE when the element has activated the step operation and
1795 * is now ready to start executing the step in the streaming thread. After this
1796 * message is emited, the application can queue a new step operation in the
1799 * Returns: (transfer full): The new step_start message.
1806 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1807 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1809 GstMessage *message;
1810 GstStructure *structure;
1812 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_START),
1813 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1814 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1815 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1816 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1817 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1818 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1819 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1825 * gst_message_parse_step_start:
1826 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1827 * @active: (out) (allow-none): result location for the active flag
1828 * @format: (out) (allow-none): result location for the format
1829 * @amount: (out) (allow-none): result location for the amount
1830 * @rate: (out) (allow-none): result location for the rate
1831 * @flush: (out) (allow-none): result location for the flush flag
1832 * @intermediate: (out) (allow-none): result location for the intermediate flag
1834 * Extract the values from step_start message.
1841 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1842 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1843 gboolean * intermediate)
1845 g_return_if_fail (GST_IS_MESSAGE (message));
1846 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1848 gst_structure_id_get (message->structure,
1849 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1850 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1851 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1852 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1853 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1854 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1858 * gst_message_new_qos:
1859 * @src: The object originating the message.
1860 * @live: if the message was generated by a live element
1861 * @running_time: the running time of the buffer that generated the message
1862 * @stream_time: the stream time of the buffer that generated the message
1863 * @timestamp: the timestamps of the buffer that generated the message
1864 * @duration: the duration of the buffer that generated the message
1866 * A QOS message is posted on the bus whenever an element decides to drop a
1867 * buffer because of QoS reasons or whenever it changes its processing strategy
1868 * because of QoS reasons (quality adjustments such as processing at lower
1871 * This message can be posted by an element that performs synchronisation against the
1872 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1873 * events received from a downstream element (!live).
1875 * @running_time, @stream_time, @timestamp, @duration should be set to the
1876 * respective running-time, stream-time, timestamp and duration of the (dropped)
1877 * buffer that generated the QoS event. Values can be left to
1878 * GST_CLOCK_TIME_NONE when unknown.
1880 * Returns: (transfer full): The new qos message.
1887 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1888 guint64 stream_time, guint64 timestamp, guint64 duration)
1890 GstMessage *message;
1891 GstStructure *structure;
1893 structure = gst_structure_id_new (GST_QUARK (MESSAGE_QOS),
1894 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1895 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1896 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1897 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1898 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1899 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1900 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1901 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1902 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1903 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1904 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1905 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1911 * gst_message_set_qos_values:
1912 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1913 * @jitter: The difference of the running-time against the deadline.
1914 * @proportion: Long term prediction of the ideal rate relative to normal rate
1915 * to get optimal quality.
1916 * @quality: An element dependent integer value that specifies the current
1917 * quality level of the element. The default maximum quality is 1000000.
1919 * Set the QoS values that have been calculated/analysed from the QoS data
1926 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1927 gdouble proportion, gint quality)
1929 g_return_if_fail (GST_IS_MESSAGE (message));
1930 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1932 gst_structure_id_set (message->structure,
1933 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1934 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1935 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1939 * gst_message_set_qos_stats:
1940 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1941 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1942 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1943 * will likely use GST_FORMAT_DEFAULT (samples).
1944 * @processed: Total number of units correctly processed since the last state
1945 * change to READY or a flushing operation.
1946 * @dropped: Total number of units dropped since the last state change to READY
1947 * or a flushing operation.
1949 * Set the QoS stats representing the history of the current continuous pipeline
1952 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1953 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1960 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1961 guint64 processed, guint64 dropped)
1963 g_return_if_fail (GST_IS_MESSAGE (message));
1964 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1966 gst_structure_id_set (message->structure,
1967 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1968 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1969 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1973 * gst_message_parse_qos:
1974 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1975 * @live: (out) (allow-none): if the message was generated by a live element
1976 * @running_time: (out) (allow-none): the running time of the buffer that
1977 * generated the message
1978 * @stream_time: (out) (allow-none): the stream time of the buffer that
1979 * generated the message
1980 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1981 * generated the message
1982 * @duration: (out) (allow-none): the duration of the buffer that
1983 * generated the message
1985 * Extract the timestamps and live status from the QoS message.
1987 * The returned values give the running_time, stream_time, timestamp and
1988 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1996 gst_message_parse_qos (GstMessage * message, gboolean * live,
1997 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2000 g_return_if_fail (GST_IS_MESSAGE (message));
2001 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2003 gst_structure_id_get (message->structure,
2004 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2005 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2006 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2007 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2008 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2012 * gst_message_parse_qos_values:
2013 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2014 * @jitter: (out) (allow-none): The difference of the running-time against
2016 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2017 * relative to normal rate to get optimal quality.
2018 * @quality: (out) (allow-none): An element dependent integer value that
2019 * specifies the current quality level of the element. The default
2020 * maximum quality is 1000000.
2022 * Extract the QoS values that have been calculated/analysed from the QoS data
2029 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2030 gdouble * proportion, gint * quality)
2032 g_return_if_fail (GST_IS_MESSAGE (message));
2033 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2035 gst_structure_id_get (message->structure,
2036 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2037 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2038 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2042 * gst_message_parse_qos_stats:
2043 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2044 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2045 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2046 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2048 * @processed: (out) (allow-none): Total number of units correctly processed
2049 * since the last state change to READY or a flushing operation.
2050 * @dropped: (out) (allow-none): Total number of units dropped since the last
2051 * state change to READY or a flushing operation.
2053 * Extract the QoS stats representing the history of the current continuous
2054 * pipeline playback period.
2056 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2057 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2064 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2065 guint64 * processed, guint64 * dropped)
2067 g_return_if_fail (GST_IS_MESSAGE (message));
2068 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2070 gst_structure_id_get (message->structure,
2071 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2072 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2073 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2077 * gst_message_new_progress:
2078 * @src: The object originating the message.
2079 * @type: a #GstProgressType
2080 * @code: a progress code
2081 * @text: free, user visible text describing the progress
2083 * Progress messages are posted by elements when they use an asynchronous task
2084 * to perform actions triggered by a state change.
2086 * @code contains a well defined string describing the action.
2087 * @test should contain a user visible string detailing the current action.
2089 * Returns: (transfer full): The new qos message.
2094 gst_message_new_progress (GstObject * src, GstProgressType type,
2095 const gchar * code, const gchar * text)
2097 GstMessage *message;
2098 GstStructure *structure;
2099 gint percent = 100, timeout = -1;
2101 g_return_val_if_fail (code != NULL, NULL);
2102 g_return_val_if_fail (text != NULL, NULL);
2104 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2107 structure = gst_structure_id_new (GST_QUARK (MESSAGE_PROGRESS),
2108 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2109 GST_QUARK (CODE), G_TYPE_STRING, code,
2110 GST_QUARK (TEXT), G_TYPE_STRING, text,
2111 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2112 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2113 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2119 * gst_message_parse_progress:
2120 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2121 * @type: (out) (allow-none): location for the type
2122 * @code: (out) (allow-none) (transfer full): location for the code
2123 * @text: (out) (allow-none) (transfer full): location for the text
2125 * Parses the progress @type, @code and @text.
2130 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2131 gchar ** code, gchar ** text)
2133 g_return_if_fail (GST_IS_MESSAGE (message));
2134 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2136 gst_structure_id_get (message->structure,
2137 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2138 GST_QUARK (CODE), G_TYPE_STRING, code,
2139 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);