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:
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"
67 GstStructure *structure;
70 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
79 static GstMessageQuarks message_quarks[] = {
80 {GST_MESSAGE_UNKNOWN, "unknown", 0},
81 {GST_MESSAGE_EOS, "eos", 0},
82 {GST_MESSAGE_ERROR, "error", 0},
83 {GST_MESSAGE_WARNING, "warning", 0},
84 {GST_MESSAGE_INFO, "info", 0},
85 {GST_MESSAGE_TAG, "tag", 0},
86 {GST_MESSAGE_BUFFERING, "buffering", 0},
87 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
88 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
89 {GST_MESSAGE_STEP_DONE, "step-done", 0},
90 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
91 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
92 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
93 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
94 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
95 {GST_MESSAGE_APPLICATION, "application", 0},
96 {GST_MESSAGE_ELEMENT, "element", 0},
97 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
98 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
99 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
100 {GST_MESSAGE_LATENCY, "latency", 0},
101 {GST_MESSAGE_ASYNC_START, "async-start", 0},
102 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
103 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
104 {GST_MESSAGE_STEP_START, "step-start", 0},
105 {GST_MESSAGE_QOS, "qos", 0},
106 {GST_MESSAGE_PROGRESS, "progress", 0},
107 {GST_MESSAGE_TOC, "toc", 0},
108 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
109 {GST_MESSAGE_STREAM_START, "stream-start", 0},
113 static GType _gst_message_type = 0;
114 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
117 _priv_gst_message_initialize (void)
121 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
123 /* the GstMiniObject types need to be class_ref'd once before it can be
124 * done from multiple threads;
125 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
126 gst_message_get_type ();
128 for (i = 0; message_quarks[i].name; i++) {
129 message_quarks[i].quark =
130 g_quark_from_static_string (message_quarks[i].name);
133 _gst_message_type = gst_message_get_type ();
137 * gst_message_type_get_name:
138 * @type: the message type
140 * Get a printable name for the given message type. Do not modify or free.
142 * Returns: a reference to the static name of the message.
145 gst_message_type_get_name (GstMessageType type)
149 for (i = 0; message_quarks[i].name; i++) {
150 if (type == message_quarks[i].type)
151 return message_quarks[i].name;
157 * gst_message_type_to_quark:
158 * @type: the message type
160 * Get the unique quark for the given message type.
162 * Returns: the quark associated with the message type
165 gst_message_type_to_quark (GstMessageType type)
169 for (i = 0; message_quarks[i].name; i++) {
170 if (type == message_quarks[i].type)
171 return message_quarks[i].quark;
177 _gst_message_free (GstMessage * message)
179 GstStructure *structure;
181 g_return_if_fail (message != NULL);
183 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
184 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
186 if (GST_MESSAGE_SRC (message)) {
187 gst_object_unref (GST_MESSAGE_SRC (message));
188 GST_MESSAGE_SRC (message) = NULL;
191 if (message->lock.p) {
192 GST_MESSAGE_LOCK (message);
193 GST_MESSAGE_SIGNAL (message);
194 GST_MESSAGE_UNLOCK (message);
197 structure = GST_MESSAGE_STRUCTURE (message);
199 gst_structure_set_parent_refcount (structure, NULL);
200 gst_structure_free (structure);
203 g_slice_free1 (sizeof (GstMessageImpl), message);
207 gst_message_init (GstMessageImpl * message, GstMessageType type,
211 _gst_message_copy (GstMessage * message)
213 GstMessageImpl *copy;
214 GstStructure *structure;
216 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
217 GST_MESSAGE_TYPE_NAME (message),
218 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
220 copy = g_slice_new0 (GstMessageImpl);
222 gst_message_init (copy, GST_MESSAGE_TYPE (message),
223 GST_MESSAGE_SRC (message));
225 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
226 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
228 structure = GST_MESSAGE_STRUCTURE (message);
230 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
231 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
232 ©->message.mini_object.refcount);
234 GST_MESSAGE_STRUCTURE (copy) = NULL;
237 return GST_MESSAGE_CAST (copy);
241 gst_message_init (GstMessageImpl * message, GstMessageType type,
244 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
245 (GstMiniObjectCopyFunction) _gst_message_copy, NULL,
246 (GstMiniObjectFreeFunction) _gst_message_free);
248 GST_MESSAGE_TYPE (message) = type;
250 gst_object_ref (src);
251 GST_MESSAGE_SRC (message) = src;
252 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
253 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
258 * gst_message_new_custom:
259 * @type: The #GstMessageType to distinguish messages
260 * @src: The object originating the message.
261 * @structure: (transfer full): the structure for the message. The message
262 * will take ownership of the structure.
264 * Create a new custom-typed message. This can be used for anything not
265 * handled by other message-specific functions to pass a message to the
266 * app. The structure field can be NULL.
268 * Returns: (transfer full): The new message.
273 gst_message_new_custom (GstMessageType type, GstObject * src,
274 GstStructure * structure)
276 GstMessageImpl *message;
278 message = g_slice_new0 (GstMessageImpl);
280 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
281 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
282 gst_message_type_get_name (type));
285 /* structure must not have a parent */
286 if (!gst_structure_set_parent_refcount (structure,
287 &message->message.mini_object.refcount))
290 gst_message_init (message, type, src);
292 GST_MESSAGE_STRUCTURE (message) = structure;
294 return GST_MESSAGE_CAST (message);
299 g_slice_free1 (sizeof (GstMessageImpl), message);
300 g_warning ("structure is already owned by another object");
306 * gst_message_get_seqnum:
307 * @message: A #GstMessage.
309 * Retrieve the sequence number of a message.
311 * Messages have ever-incrementing sequence numbers, which may also be set
312 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
313 * to indicate that a message corresponds to some other set of messages or
314 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
315 * is considered good practice to make this correspondence when possible, though
316 * it is not required.
318 * Note that events and messages share the same sequence number incrementor;
319 * two events or messages will never have the same sequence number unless
320 * that correspondence was made explicitly.
322 * Returns: The message's sequence number.
327 gst_message_get_seqnum (GstMessage * message)
329 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
331 return GST_MESSAGE_SEQNUM (message);
335 * gst_message_set_seqnum:
336 * @message: A #GstMessage.
337 * @seqnum: A sequence number.
339 * Set the sequence number of a message.
341 * This function might be called by the creator of a message to indicate that
342 * the message relates to other messages or events. See gst_message_get_seqnum()
343 * for more information.
348 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
350 g_return_if_fail (GST_IS_MESSAGE (message));
352 GST_MESSAGE_SEQNUM (message) = seqnum;
356 * gst_message_new_eos:
357 * @src: (transfer none): The object originating the message.
359 * Create a new eos message. This message is generated and posted in
360 * the sink elements of a GstBin. The bin will only forward the EOS
361 * message to the application if all sinks have posted an EOS message.
363 * Returns: (transfer full): The new eos message.
368 gst_message_new_eos (GstObject * src)
372 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
378 * gst_message_new_error:
379 * @src: (transfer none): The object originating the message.
380 * @error: (transfer none): The GError for this message.
381 * @debug: A debugging string.
383 * Create a new error message. The message will copy @error and
384 * @debug. This message is posted by element when a fatal event
385 * occured. The pipeline will probably (partially) stop. The application
386 * receiving this message should stop the pipeline.
388 * Returns: (transfer full): the new error message.
393 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
396 GstStructure *structure;
398 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
399 GST_QUARK (GERROR), G_TYPE_ERROR, error,
400 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
401 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
407 * gst_message_new_warning:
408 * @src: (transfer none): The object originating the message.
409 * @error: (transfer none): The GError for this message.
410 * @debug: A debugging string.
412 * Create a new warning message. The message will make copies of @error and
415 * Returns: (transfer full): The new warning message.
420 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
423 GstStructure *structure;
425 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
426 GST_QUARK (GERROR), G_TYPE_ERROR, error,
427 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
428 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
434 * gst_message_new_info:
435 * @src: (transfer none): The object originating the message.
436 * @error: (transfer none): The GError for this message.
437 * @debug: A debugging string.
439 * Create a new info message. The message will make copies of @error and
444 * Returns: (transfer full): the new info message.
447 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
450 GstStructure *structure;
452 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
453 GST_QUARK (GERROR), G_TYPE_ERROR, error,
454 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
455 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
461 * gst_message_new_tag:
462 * @src: (transfer none): The object originating the message.
463 * @tag_list: (transfer full): the tag list for the message.
465 * Create a new tag message. The message will take ownership of the tag list.
466 * The message is posted by elements that discovered a new taglist.
468 * Returns: (transfer full): the new tag message.
473 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
477 GValue val = G_VALUE_INIT;
479 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
481 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
482 g_value_init (&val, GST_TYPE_TAG_LIST);
483 g_value_take_boxed (&val, tag_list);
484 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
485 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
490 * gst_message_new_buffering:
491 * @src: (transfer none): The object originating the message.
492 * @percent: The buffering percent
494 * Create a new buffering message. This message can be posted by an element that
495 * needs to buffer data before it can continue processing. @percent should be a
496 * value between 0 and 100. A value of 100 means that the buffering completed.
498 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
499 * @percent is 100, the application can set the pipeline (back) to PLAYING.
500 * The application must be prepared to receive BUFFERING messages in the
501 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
502 * message with @percent set to 100, which can happen after the pipeline
503 * completed prerolling.
507 * Returns: (transfer full): The new buffering message.
510 gst_message_new_buffering (GstObject * src, gint percent)
513 GstStructure *structure;
514 gint64 buffering_left;
516 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
518 buffering_left = (percent == 100 ? 0 : -1);
520 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
521 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
522 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
523 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
524 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
525 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
526 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
532 * gst_message_new_state_changed:
533 * @src: (transfer none): the object originating the message
534 * @oldstate: the previous state
535 * @newstate: the new (current) state
536 * @pending: the pending (target) state
538 * Create a state change message. This message is posted whenever an element
541 * Returns: (transfer full): the new state change message.
546 gst_message_new_state_changed (GstObject * src,
547 GstState oldstate, GstState newstate, GstState pending)
550 GstStructure *structure;
552 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
553 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
554 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
555 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
556 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
562 * gst_message_new_state_dirty:
563 * @src: (transfer none): the object originating the message
565 * Create a state dirty message. This message is posted whenever an element
566 * changed its state asynchronously and is used internally to update the
567 * states of container objects.
569 * Returns: (transfer full): the new state dirty message.
574 gst_message_new_state_dirty (GstObject * src)
578 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
584 * gst_message_new_clock_provide:
585 * @src: (transfer none): the object originating the message.
586 * @clock: (transfer none): the clock it provides
587 * @ready: TRUE if the sender can provide a clock
589 * Create a clock provide message. This message is posted whenever an
590 * element is ready to provide a clock or lost its ability to provide
591 * a clock (maybe because it paused or became EOS).
593 * This message is mainly used internally to manage the clock
596 * Returns: (transfer full): the new provide clock message.
601 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
605 GstStructure *structure;
607 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
608 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
609 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
610 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
616 * gst_message_new_clock_lost:
617 * @src: (transfer none): the object originating the message.
618 * @clock: (transfer none): the clock that was lost
620 * Create a clock lost message. This message is posted whenever the
621 * clock is not valid anymore.
623 * If this message is posted by the pipeline, the pipeline will
624 * select a new clock again when it goes to PLAYING. It might therefore
625 * be needed to set the pipeline to PAUSED and PLAYING again.
627 * Returns: (transfer full): The new clock lost message.
632 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
635 GstStructure *structure;
637 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
638 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
639 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
645 * gst_message_new_new_clock:
646 * @src: (transfer none): The object originating the message.
647 * @clock: (transfer none): the new selected clock
649 * Create a new clock message. This message is posted whenever the
650 * pipeline selectes a new clock for the pipeline.
652 * Returns: (transfer full): The new new clock message.
657 gst_message_new_new_clock (GstObject * src, GstClock * clock)
660 GstStructure *structure;
662 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
663 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
664 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
670 * gst_message_new_structure_change:
671 * @src: (transfer none): The object originating the message.
672 * @type: The change type.
673 * @owner: (transfer none): The owner element of @src.
674 * @busy: Whether the structure change is busy.
676 * Create a new structure change message. This message is posted when the
677 * structure of a pipeline is in the process of being changed, for example
678 * when pads are linked or unlinked.
680 * @src should be the sinkpad that unlinked or linked.
682 * Returns: (transfer full): the new structure change message.
687 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
688 GstElement * owner, gboolean busy)
691 GstStructure *structure;
693 g_return_val_if_fail (GST_IS_PAD (src), NULL);
694 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
695 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
697 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
698 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
699 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
700 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
702 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
709 * gst_message_new_segment_start:
710 * @src: (transfer none): The object originating the message.
711 * @format: The format of the position being played
712 * @position: The position of the segment being played
714 * Create a new segment message. This message is posted by elements that
715 * start playback of a segment as a result of a segment seek. This message
716 * is not received by the application but is used for maintenance reasons in
717 * container elements.
719 * Returns: (transfer full): the new segment start message.
724 gst_message_new_segment_start (GstObject * src, GstFormat format,
728 GstStructure *structure;
730 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
731 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
732 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
733 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
739 * gst_message_new_segment_done:
740 * @src: (transfer none): the object originating the message.
741 * @format: The format of the position being done
742 * @position: The position of the segment being done
744 * Create a new segment done message. This message is posted by elements that
745 * finish playback of a segment as a result of a segment seek. This message
746 * is received by the application after all elements that posted a segment_start
747 * have posted the segment_done.
749 * Returns: (transfer full): the new segment done message.
754 gst_message_new_segment_done (GstObject * src, GstFormat format,
758 GstStructure *structure;
760 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
761 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
762 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
763 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
769 * gst_message_new_application:
770 * @src: (transfer none): the object originating the message.
771 * @structure: (transfer full): the structure for the message. The message
772 * will take ownership of the structure.
774 * Create a new application-typed message. GStreamer will never create these
775 * messages; they are a gift from us to you. Enjoy.
777 * Returns: (transfer full): The new application message.
782 gst_message_new_application (GstObject * src, GstStructure * structure)
784 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
788 * gst_message_new_element:
789 * @src: (transfer none): The object originating the message.
790 * @structure: (transfer full): The structure for the message. The message
791 * will take ownership of the structure.
793 * Create a new element-specific message. This is meant as a generic way of
794 * allowing one-way communication from an element to an application, for example
795 * "the firewire cable was unplugged". The format of the message should be
796 * documented in the element's documentation. The structure field can be NULL.
798 * Returns: (transfer full): The new element message.
803 gst_message_new_element (GstObject * src, GstStructure * structure)
805 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
809 * gst_message_new_duration_changed:
810 * @src: (transfer none): The object originating the message.
812 * Create a new duration changed message. This message is posted by elements
813 * that know the duration of a stream when the duration changes. This message
814 * is received by bins and is used to calculate the total duration of a
815 * pipeline. Elements may post a duration message with a duration of
816 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
817 * cached duration should be discarded. The new duration can then be
818 * retrieved via a query.
820 * Returns: (transfer full): The new duration-changed message.
825 gst_message_new_duration_changed (GstObject * src)
829 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
830 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
836 * gst_message_new_async_start:
837 * @src: (transfer none): The object originating the message.
839 * This message is posted by elements when they start an ASYNC state change.
841 * Returns: (transfer full): The new async_start message.
846 gst_message_new_async_start (GstObject * src)
850 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
856 * gst_message_new_async_done:
857 * @src: (transfer none): The object originating the message.
858 * @running_time: the desired running_time
860 * The message is posted when elements completed an ASYNC state change.
861 * @running_time contains the time of the desired running_time when this
862 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
863 * means that the element has no clock interaction and thus doesn't care about
864 * the running_time of the pipeline.
866 * Returns: (transfer full): The new async_done message.
871 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
874 GstStructure *structure;
876 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
877 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
878 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
884 * gst_message_new_latency:
885 * @src: (transfer none): The object originating the message.
887 * This message can be posted by elements when their latency requirements have
890 * Returns: (transfer full): The new latency message.
895 gst_message_new_latency (GstObject * src)
899 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
905 * gst_message_new_request_state:
906 * @src: (transfer none): the object originating the message.
907 * @state: The new requested state
909 * This message can be posted by elements when they want to have their state
910 * changed. A typical use case would be an audio server that wants to pause the
911 * pipeline because a higher priority stream is being played.
913 * Returns: (transfer full): the new requst state message.
918 gst_message_new_request_state (GstObject * src, GstState state)
921 GstStructure *structure;
923 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
924 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
925 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
931 * gst_message_get_structure:
932 * @message: The #GstMessage.
934 * Access the structure of the message.
936 * Returns: (transfer none): The structure of the message. The structure is
937 * still owned by the message, which means that you should not free it and
938 * that the pointer becomes invalid when you free the message.
943 gst_message_get_structure (GstMessage * message)
945 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
947 return GST_MESSAGE_STRUCTURE (message);
951 * gst_message_has_name:
952 * @message: The #GstMessage.
953 * @name: name to check
955 * Checks if @message has the given @name. This function is usually used to
956 * check the name of a custom message.
958 * Returns: %TRUE if @name matches the name of the message structure.
961 gst_message_has_name (GstMessage * message, const gchar * name)
963 GstStructure *structure;
965 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
967 structure = GST_MESSAGE_STRUCTURE (message);
968 if (structure == NULL)
971 return gst_structure_has_name (structure, name);
975 * gst_message_parse_tag:
976 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
977 * @tag_list: (out callee-allocates): return location for the tag-list.
979 * Extracts the tag list from the GstMessage. The tag list returned in the
980 * output argument is a copy; the caller must free it when done.
982 * Typical usage of this function might be:
985 * switch (GST_MESSAGE_TYPE (msg)) {
986 * case GST_MESSAGE_TAG: {
987 * GstTagList *tags = NULL;
989 * gst_message_parse_tag (msg, &tags);
990 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
991 * handle_tags (tags);
992 * gst_tag_list_unref (tags);
1003 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1005 g_return_if_fail (GST_IS_MESSAGE (message));
1006 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1007 g_return_if_fail (tag_list != NULL);
1009 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1010 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1014 * gst_message_parse_buffering:
1015 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1016 * @percent: (out) (allow-none): Return location for the percent.
1018 * Extracts the buffering percent from the GstMessage. see also
1019 * gst_message_new_buffering().
1024 gst_message_parse_buffering (GstMessage * message, gint * percent)
1026 g_return_if_fail (GST_IS_MESSAGE (message));
1027 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1031 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1032 (message), GST_QUARK (BUFFER_PERCENT)));
1036 * gst_message_set_buffering_stats:
1037 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1038 * @mode: a buffering mode
1039 * @avg_in: the average input rate
1040 * @avg_out: the average output rate
1041 * @buffering_left: amount of buffering time left in milliseconds
1043 * Configures the buffering stats values in @message.
1046 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1047 gint avg_in, gint avg_out, gint64 buffering_left)
1049 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1051 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1052 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1053 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1054 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1055 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1059 * gst_message_parse_buffering_stats:
1060 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1061 * @mode: (out) (allow-none): a buffering mode, or NULL
1062 * @avg_in: (out) (allow-none): the average input rate, or NULL
1063 * @avg_out: (out) (allow-none): the average output rate, or NULL
1064 * @buffering_left: (out) (allow-none): amount of buffering time left in
1065 * milliseconds, or NULL
1067 * Extracts the buffering stats values from @message.
1070 gst_message_parse_buffering_stats (GstMessage * message,
1071 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1072 gint64 * buffering_left)
1074 GstStructure *structure;
1076 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1078 structure = GST_MESSAGE_STRUCTURE (message);
1080 *mode = (GstBufferingMode)
1081 g_value_get_enum (gst_structure_id_get_value (structure,
1082 GST_QUARK (BUFFERING_MODE)));
1084 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1085 GST_QUARK (AVG_IN_RATE)));
1087 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1088 GST_QUARK (AVG_OUT_RATE)));
1091 g_value_get_int64 (gst_structure_id_get_value (structure,
1092 GST_QUARK (BUFFERING_LEFT)));
1096 * gst_message_parse_state_changed:
1097 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1098 * @oldstate: (out) (allow-none): the previous state, or NULL
1099 * @newstate: (out) (allow-none): the new (current) state, or NULL
1100 * @pending: (out) (allow-none): the pending (target) state, or NULL
1102 * Extracts the old and new states from the GstMessage.
1104 * Typical usage of this function might be:
1107 * switch (GST_MESSAGE_TYPE (msg)) {
1108 * case GST_MESSAGE_STATE_CHANGED: {
1109 * GstState old_state, new_state;
1111 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1112 * g_print ("Element %s changed state from %s to %s.\n",
1113 * GST_OBJECT_NAME (msg->src),
1114 * gst_element_state_get_name (old_state),
1115 * gst_element_state_get_name (new_state));
1126 gst_message_parse_state_changed (GstMessage * message,
1127 GstState * oldstate, GstState * newstate, GstState * pending)
1129 GstStructure *structure;
1131 g_return_if_fail (GST_IS_MESSAGE (message));
1132 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1134 structure = GST_MESSAGE_STRUCTURE (message);
1136 *oldstate = (GstState)
1137 g_value_get_enum (gst_structure_id_get_value (structure,
1138 GST_QUARK (OLD_STATE)));
1140 *newstate = (GstState)
1141 g_value_get_enum (gst_structure_id_get_value (structure,
1142 GST_QUARK (NEW_STATE)));
1144 *pending = (GstState)
1145 g_value_get_enum (gst_structure_id_get_value (structure,
1146 GST_QUARK (PENDING_STATE)));
1150 * gst_message_parse_clock_provide:
1151 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1152 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1154 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1156 * Extracts the clock and ready flag from the GstMessage.
1157 * The clock object returned remains valid until the message is freed.
1162 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1165 const GValue *clock_gvalue;
1166 GstStructure *structure;
1168 g_return_if_fail (GST_IS_MESSAGE (message));
1169 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1171 structure = GST_MESSAGE_STRUCTURE (message);
1172 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1173 g_return_if_fail (clock_gvalue != NULL);
1174 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1178 g_value_get_boolean (gst_structure_id_get_value (structure,
1179 GST_QUARK (READY)));
1181 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1185 * gst_message_parse_clock_lost:
1186 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1187 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1189 * Extracts the lost clock from the GstMessage.
1190 * The clock object returned remains valid until the message is freed.
1195 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1197 const GValue *clock_gvalue;
1198 GstStructure *structure;
1200 g_return_if_fail (GST_IS_MESSAGE (message));
1201 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1203 structure = GST_MESSAGE_STRUCTURE (message);
1204 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1205 g_return_if_fail (clock_gvalue != NULL);
1206 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1209 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1213 * gst_message_parse_new_clock:
1214 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1215 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1218 * Extracts the new clock from the GstMessage.
1219 * The clock object returned remains valid until the message is freed.
1224 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1226 const GValue *clock_gvalue;
1227 GstStructure *structure;
1229 g_return_if_fail (GST_IS_MESSAGE (message));
1230 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1232 structure = GST_MESSAGE_STRUCTURE (message);
1233 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1234 g_return_if_fail (clock_gvalue != NULL);
1235 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1238 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1242 * gst_message_parse_structure_change:
1243 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1244 * @type: (out): A pointer to hold the change type
1245 * @owner: (out) (allow-none) (transfer none): The owner element of the
1247 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1248 * progress or has been completed
1250 * Extracts the change type and completion status from the GstMessage.
1255 gst_message_parse_structure_change (GstMessage * message,
1256 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1258 const GValue *owner_gvalue;
1259 GstStructure *structure;
1261 g_return_if_fail (GST_IS_MESSAGE (message));
1262 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1264 structure = GST_MESSAGE_STRUCTURE (message);
1265 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1266 g_return_if_fail (owner_gvalue != NULL);
1267 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1270 *type = (GstStructureChangeType)
1271 g_value_get_enum (gst_structure_id_get_value (structure,
1274 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1277 g_value_get_boolean (gst_structure_id_get_value (structure,
1282 * gst_message_parse_error:
1283 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1284 * @gerror: (out) (allow-none) (transfer full): location for the GError
1285 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1288 * Extracts the GError and debug string from the GstMessage. The values returned
1289 * in the output arguments are copies; the caller must free them when done.
1291 * Typical usage of this function might be:
1294 * switch (GST_MESSAGE_TYPE (msg)) {
1295 * case GST_MESSAGE_ERROR: {
1296 * GError *err = NULL;
1297 * gchar *dbg_info = NULL;
1299 * gst_message_parse_error (msg, &err, &dbg_info);
1300 * g_printerr ("ERROR from element %s: %s\n",
1301 * GST_OBJECT_NAME (msg->src), err->message);
1302 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1303 * g_error_free (err);
1304 * g_free (dbg_info);
1315 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1317 const GValue *error_gvalue;
1319 GstStructure *structure;
1321 g_return_if_fail (GST_IS_MESSAGE (message));
1322 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1324 structure = GST_MESSAGE_STRUCTURE (message);
1325 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1326 g_return_if_fail (error_gvalue != NULL);
1327 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR);
1329 error_val = (GError *) g_value_get_boxed (error_gvalue);
1331 *gerror = g_error_copy (error_val);
1337 g_value_dup_string (gst_structure_id_get_value (structure,
1338 GST_QUARK (DEBUG)));
1342 * gst_message_parse_warning:
1343 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1344 * @gerror: (out) (allow-none) (transfer full): location for the GError
1345 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1348 * Extracts the GError and debug string from the GstMessage. The values returned
1349 * in the output arguments are copies; the caller must free them when done.
1354 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1357 const GValue *error_gvalue;
1359 GstStructure *structure;
1361 g_return_if_fail (GST_IS_MESSAGE (message));
1362 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1364 structure = GST_MESSAGE_STRUCTURE (message);
1365 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1366 g_return_if_fail (error_gvalue != NULL);
1367 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_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 (structure,
1378 GST_QUARK (DEBUG)));
1382 * gst_message_parse_info:
1383 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
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_info (GstMessage * message, GError ** gerror, gchar ** debug)
1396 const GValue *error_gvalue;
1398 GstStructure *structure;
1400 g_return_if_fail (GST_IS_MESSAGE (message));
1401 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1403 structure = GST_MESSAGE_STRUCTURE (message);
1404 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1405 g_return_if_fail (error_gvalue != NULL);
1406 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_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 (structure,
1417 GST_QUARK (DEBUG)));
1421 * gst_message_parse_segment_start:
1422 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1423 * @format: (out): Result location for the format, or NULL
1424 * @position: (out): Result location for the position, or NULL
1426 * Extracts the position and format from the segment start message.
1431 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1434 GstStructure *structure;
1436 g_return_if_fail (GST_IS_MESSAGE (message));
1437 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1439 structure = GST_MESSAGE_STRUCTURE (message);
1441 *format = (GstFormat)
1442 g_value_get_enum (gst_structure_id_get_value (structure,
1443 GST_QUARK (FORMAT)));
1446 g_value_get_int64 (gst_structure_id_get_value (structure,
1447 GST_QUARK (POSITION)));
1451 * gst_message_parse_segment_done:
1452 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1453 * @format: (out): Result location for the format, or NULL
1454 * @position: (out): Result location for the position, or NULL
1456 * Extracts the position and format from the segment start message.
1461 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1464 GstStructure *structure;
1466 g_return_if_fail (GST_IS_MESSAGE (message));
1467 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1469 structure = GST_MESSAGE_STRUCTURE (message);
1471 *format = (GstFormat)
1472 g_value_get_enum (gst_structure_id_get_value (structure,
1473 GST_QUARK (FORMAT)));
1476 g_value_get_int64 (gst_structure_id_get_value (structure,
1477 GST_QUARK (POSITION)));
1481 * gst_message_parse_async_done:
1482 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1483 * @running_time: (out): Result location for the running_time or NULL
1485 * Extract the running_time from the async_done message.
1490 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1492 GstStructure *structure;
1494 g_return_if_fail (GST_IS_MESSAGE (message));
1495 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1497 structure = GST_MESSAGE_STRUCTURE (message);
1500 g_value_get_uint64 (gst_structure_id_get_value (structure,
1501 GST_QUARK (RUNNING_TIME)));
1505 * gst_message_parse_request_state:
1506 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1507 * @state: (out): Result location for the requested state or NULL
1509 * Extract the requested state from the request_state message.
1514 gst_message_parse_request_state (GstMessage * message, GstState * state)
1516 GstStructure *structure;
1518 g_return_if_fail (GST_IS_MESSAGE (message));
1519 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1521 structure = GST_MESSAGE_STRUCTURE (message);
1524 g_value_get_enum (gst_structure_id_get_value (structure,
1525 GST_QUARK (NEW_STATE)));
1529 * gst_message_new_stream_status:
1530 * @src: The object originating the message.
1531 * @type: The stream status type.
1532 * @owner: (transfer none): the owner element of @src.
1534 * Create a new stream status message. This message is posted when a streaming
1535 * thread is created/destroyed or when the state changed.
1537 * Returns: (transfer full): the new stream status message.
1542 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1545 GstMessage *message;
1546 GstStructure *structure;
1548 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1549 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1550 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1551 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1557 * gst_message_parse_stream_status:
1558 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1559 * @type: (out): A pointer to hold the status type
1560 * @owner: (out) (transfer none): The owner element of the message source
1562 * Extracts the stream status type and owner the GstMessage. The returned
1563 * owner remains valid for as long as the reference to @message is valid and
1564 * should thus not be unreffed.
1569 gst_message_parse_stream_status (GstMessage * message,
1570 GstStreamStatusType * type, GstElement ** owner)
1572 const GValue *owner_gvalue;
1573 GstStructure *structure;
1575 g_return_if_fail (GST_IS_MESSAGE (message));
1576 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1578 structure = GST_MESSAGE_STRUCTURE (message);
1579 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1580 g_return_if_fail (owner_gvalue != NULL);
1583 *type = (GstStreamStatusType)
1584 g_value_get_enum (gst_structure_id_get_value (structure,
1587 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1591 * gst_message_set_stream_status_object:
1592 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1593 * @object: the object controlling the streaming
1595 * Configures the object handling the streaming thread. This is usually a
1596 * GstTask object but other objects might be added in the future.
1599 gst_message_set_stream_status_object (GstMessage * message,
1600 const GValue * object)
1602 GstStructure *structure;
1604 g_return_if_fail (GST_IS_MESSAGE (message));
1605 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1607 structure = GST_MESSAGE_STRUCTURE (message);
1608 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1612 * gst_message_get_stream_status_object:
1613 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1615 * Extracts the object managing the streaming thread from @message.
1617 * Returns: a GValue containing the object that manages the streaming thread.
1618 * This object is usually of type GstTask but other types can be added in the
1619 * future. The object remains valid as long as @message is valid.
1622 gst_message_get_stream_status_object (GstMessage * message)
1624 const GValue *result;
1625 GstStructure *structure;
1627 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1628 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1631 structure = GST_MESSAGE_STRUCTURE (message);
1632 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1638 * gst_message_new_step_done:
1639 * @src: The object originating the message.
1640 * @format: the format of @amount
1641 * @amount: the amount of stepped data
1642 * @rate: the rate of the stepped amount
1643 * @flush: is this an flushing step
1644 * @intermediate: is this an intermediate step
1645 * @duration: the duration of the data
1646 * @eos: the step caused EOS
1648 * This message is posted by elements when they complete a part, when @intermediate set
1649 * to TRUE, or a complete step operation.
1651 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1652 * @amount of media in format @format.
1654 * Returns: (transfer full): the new step_done message.
1659 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1660 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1663 GstMessage *message;
1664 GstStructure *structure;
1666 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1667 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1668 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1669 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1670 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1671 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1672 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1673 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1674 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1680 * gst_message_parse_step_done:
1681 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1682 * @format: (out) (allow-none): result location for the format
1683 * @amount: (out) (allow-none): result location for the amount
1684 * @rate: (out) (allow-none): result location for the rate
1685 * @flush: (out) (allow-none): result location for the flush flag
1686 * @intermediate: (out) (allow-none): result location for the intermediate flag
1687 * @duration: (out) (allow-none): result location for the duration
1688 * @eos: (out) (allow-none): result location for the EOS flag
1690 * Extract the values the step_done message.
1695 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1696 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1697 guint64 * duration, gboolean * eos)
1699 GstStructure *structure;
1701 g_return_if_fail (GST_IS_MESSAGE (message));
1702 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1704 structure = GST_MESSAGE_STRUCTURE (message);
1705 gst_structure_id_get (structure,
1706 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1707 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1708 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1709 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1710 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1711 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1712 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1716 * gst_message_new_step_start:
1717 * @src: The object originating the message.
1718 * @active: if the step is active or queued
1719 * @format: the format of @amount
1720 * @amount: the amount of stepped data
1721 * @rate: the rate of the stepped amount
1722 * @flush: is this an flushing step
1723 * @intermediate: is this an intermediate step
1725 * This message is posted by elements when they accept or activate a new step
1726 * event for @amount in @format.
1728 * @active is set to FALSE when the element accepted the new step event and has
1729 * queued it for execution in the streaming threads.
1731 * @active is set to TRUE when the element has activated the step operation and
1732 * is now ready to start executing the step in the streaming thread. After this
1733 * message is emited, the application can queue a new step operation in the
1736 * Returns: (transfer full): The new step_start message.
1741 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1742 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1744 GstMessage *message;
1745 GstStructure *structure;
1747 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1748 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1749 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1750 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1751 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1752 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1753 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1754 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1760 * gst_message_parse_step_start:
1761 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1762 * @active: (out) (allow-none): result location for the active flag
1763 * @format: (out) (allow-none): result location for the format
1764 * @amount: (out) (allow-none): result location for the amount
1765 * @rate: (out) (allow-none): result location for the rate
1766 * @flush: (out) (allow-none): result location for the flush flag
1767 * @intermediate: (out) (allow-none): result location for the intermediate flag
1769 * Extract the values from step_start message.
1774 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1775 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1776 gboolean * intermediate)
1778 GstStructure *structure;
1780 g_return_if_fail (GST_IS_MESSAGE (message));
1781 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1783 structure = GST_MESSAGE_STRUCTURE (message);
1784 gst_structure_id_get (structure,
1785 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1786 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1787 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1788 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1789 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1790 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1794 * gst_message_new_qos:
1795 * @src: The object originating the message.
1796 * @live: if the message was generated by a live element
1797 * @running_time: the running time of the buffer that generated the message
1798 * @stream_time: the stream time of the buffer that generated the message
1799 * @timestamp: the timestamps of the buffer that generated the message
1800 * @duration: the duration of the buffer that generated the message
1802 * A QOS message is posted on the bus whenever an element decides to drop a
1803 * buffer because of QoS reasons or whenever it changes its processing strategy
1804 * because of QoS reasons (quality adjustments such as processing at lower
1807 * This message can be posted by an element that performs synchronisation against the
1808 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1809 * events received from a downstream element (!live).
1811 * @running_time, @stream_time, @timestamp, @duration should be set to the
1812 * respective running-time, stream-time, timestamp and duration of the (dropped)
1813 * buffer that generated the QoS event. Values can be left to
1814 * GST_CLOCK_TIME_NONE when unknown.
1816 * Returns: (transfer full): The new qos message.
1821 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1822 guint64 stream_time, guint64 timestamp, guint64 duration)
1824 GstMessage *message;
1825 GstStructure *structure;
1827 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1828 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1829 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1830 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1831 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1832 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1833 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1834 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1835 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1836 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1837 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1838 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1839 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1845 * gst_message_set_qos_values:
1846 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1847 * @jitter: The difference of the running-time against the deadline.
1848 * @proportion: Long term prediction of the ideal rate relative to normal rate
1849 * to get optimal quality.
1850 * @quality: An element dependent integer value that specifies the current
1851 * quality level of the element. The default maximum quality is 1000000.
1853 * Set the QoS values that have been calculated/analysed from the QoS data
1858 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1859 gdouble proportion, gint quality)
1861 GstStructure *structure;
1863 g_return_if_fail (GST_IS_MESSAGE (message));
1864 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1866 structure = GST_MESSAGE_STRUCTURE (message);
1867 gst_structure_id_set (structure,
1868 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1869 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1870 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1874 * gst_message_set_qos_stats:
1875 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1876 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1877 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1878 * will likely use GST_FORMAT_DEFAULT (samples).
1879 * @processed: Total number of units correctly processed since the last state
1880 * change to READY or a flushing operation.
1881 * @dropped: Total number of units dropped since the last state change to READY
1882 * or a flushing operation.
1884 * Set the QoS stats representing the history of the current continuous pipeline
1887 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1888 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1893 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1894 guint64 processed, guint64 dropped)
1896 GstStructure *structure;
1898 g_return_if_fail (GST_IS_MESSAGE (message));
1899 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1901 structure = GST_MESSAGE_STRUCTURE (message);
1902 gst_structure_id_set (structure,
1903 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1904 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1905 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1909 * gst_message_parse_qos:
1910 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1911 * @live: (out) (allow-none): if the message was generated by a live element
1912 * @running_time: (out) (allow-none): the running time of the buffer that
1913 * generated the message
1914 * @stream_time: (out) (allow-none): the stream time of the buffer that
1915 * generated the message
1916 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1917 * generated the message
1918 * @duration: (out) (allow-none): the duration of the buffer that
1919 * generated the message
1921 * Extract the timestamps and live status from the QoS message.
1923 * The returned values give the running_time, stream_time, timestamp and
1924 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1930 gst_message_parse_qos (GstMessage * message, gboolean * live,
1931 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1934 GstStructure *structure;
1936 g_return_if_fail (GST_IS_MESSAGE (message));
1937 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1939 structure = GST_MESSAGE_STRUCTURE (message);
1940 gst_structure_id_get (structure,
1941 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1942 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1943 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1944 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1945 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1949 * gst_message_parse_qos_values:
1950 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1951 * @jitter: (out) (allow-none): The difference of the running-time against
1953 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1954 * relative to normal rate to get optimal quality.
1955 * @quality: (out) (allow-none): An element dependent integer value that
1956 * specifies the current quality level of the element. The default
1957 * maximum quality is 1000000.
1959 * Extract the QoS values that have been calculated/analysed from the QoS data
1964 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1965 gdouble * proportion, gint * quality)
1967 GstStructure *structure;
1969 g_return_if_fail (GST_IS_MESSAGE (message));
1970 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1972 structure = GST_MESSAGE_STRUCTURE (message);
1973 gst_structure_id_get (structure,
1974 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1975 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1976 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1980 * gst_message_parse_qos_stats:
1981 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1982 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1983 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1984 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1986 * @processed: (out) (allow-none): Total number of units correctly processed
1987 * since the last state change to READY or a flushing operation.
1988 * @dropped: (out) (allow-none): Total number of units dropped since the last
1989 * state change to READY or a flushing operation.
1991 * Extract the QoS stats representing the history of the current continuous
1992 * pipeline playback period.
1994 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1995 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2000 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2001 guint64 * processed, guint64 * dropped)
2003 GstStructure *structure;
2005 g_return_if_fail (GST_IS_MESSAGE (message));
2006 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2008 structure = GST_MESSAGE_STRUCTURE (message);
2009 gst_structure_id_get (structure,
2010 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2011 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2012 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2016 * gst_message_new_progress:
2017 * @src: The object originating the message.
2018 * @type: a #GstProgressType
2019 * @code: a progress code
2020 * @text: free, user visible text describing the progress
2022 * Progress messages are posted by elements when they use an asynchronous task
2023 * to perform actions triggered by a state change.
2025 * @code contains a well defined string describing the action.
2026 * @test should contain a user visible string detailing the current action.
2028 * Returns: (transfer full): The new qos message.
2031 gst_message_new_progress (GstObject * src, GstProgressType type,
2032 const gchar * code, const gchar * text)
2034 GstMessage *message;
2035 GstStructure *structure;
2036 gint percent = 100, timeout = -1;
2038 g_return_val_if_fail (code != NULL, NULL);
2039 g_return_val_if_fail (text != NULL, NULL);
2041 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2044 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2045 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2046 GST_QUARK (CODE), G_TYPE_STRING, code,
2047 GST_QUARK (TEXT), G_TYPE_STRING, text,
2048 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2049 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2050 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2056 * gst_message_parse_progress:
2057 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2058 * @type: (out) (allow-none): location for the type
2059 * @code: (out) (allow-none) (transfer full): location for the code
2060 * @text: (out) (allow-none) (transfer full): location for the text
2062 * Parses the progress @type, @code and @text.
2065 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2066 gchar ** code, gchar ** text)
2068 GstStructure *structure;
2070 g_return_if_fail (GST_IS_MESSAGE (message));
2071 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2073 structure = GST_MESSAGE_STRUCTURE (message);
2074 gst_structure_id_get (structure,
2075 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2076 GST_QUARK (CODE), G_TYPE_STRING, code,
2077 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2081 * gst_message_new_toc:
2082 * @src: the object originating the message.
2083 * @toc: (transfer none): #GstToc structure for the message.
2084 * @updated: whether TOC was updated or not.
2086 * Create a new TOC message. The message is posted by elements
2087 * that discovered or updated a TOC.
2089 * Returns: (transfer full): a new TOC message.
2094 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2096 GstStructure *toc_struct;
2098 g_return_val_if_fail (toc != NULL, NULL);
2100 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2101 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2102 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2104 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2108 * gst_message_parse_toc:
2109 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2110 * @toc: (out) (transfer full): return location for the TOC.
2111 * @updated: (out): return location for the updated flag.
2113 * Extract thef TOC from the #GstMessage. The TOC returned in the
2114 * output argument is a copy; the caller must free it with
2115 * gst_toc_unref() when done.
2120 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2122 g_return_if_fail (GST_IS_MESSAGE (message));
2123 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2124 g_return_if_fail (toc != NULL);
2126 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2127 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2128 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2132 * gst_message_new_reset_time:
2133 * @src: (transfer none): The object originating the message.
2134 * @running_time: the requested running-time
2136 * This message is posted when the pipeline running-time should be reset to
2137 * @running_time, like after a flushing seek.
2139 * Returns: (transfer full): The new reset_time message.
2144 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2146 GstMessage *message;
2147 GstStructure *structure;
2149 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2150 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2151 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2157 * gst_message_parse_reset_time:
2158 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2159 * @running_time: (out): Result location for the running_time or NULL
2161 * Extract the running-time from the RESET_TIME message.
2166 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2168 GstStructure *structure;
2170 g_return_if_fail (GST_IS_MESSAGE (message));
2171 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2173 structure = GST_MESSAGE_STRUCTURE (message);
2176 g_value_get_uint64 (gst_structure_id_get_value (structure,
2177 GST_QUARK (RUNNING_TIME)));
2181 * gst_message_new_stream_start:
2182 * @src: (transfer none): The object originating the message.
2184 * Create a new stream_start message. This message is generated and posted in
2185 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2186 * message to the application if all sinks have posted an STREAM_START message.
2188 * Returns: (transfer full): The new stream_start message.
2193 gst_message_new_stream_start (GstObject * src)
2195 GstMessage *message;
2197 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, NULL);