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"
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, "duration", 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},
110 static GType _gst_message_type = 0;
111 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
114 _priv_gst_message_initialize (void)
118 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
120 /* the GstMiniObject types need to be class_ref'd once before it can be
121 * done from multiple threads;
122 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
123 gst_message_get_type ();
125 for (i = 0; message_quarks[i].name; i++) {
126 message_quarks[i].quark =
127 g_quark_from_static_string (message_quarks[i].name);
130 _gst_message_type = gst_message_get_type ();
134 * gst_message_type_get_name:
135 * @type: the message type
137 * Get a printable name for the given message type. Do not modify or free.
139 * Returns: a reference to the static name of the message.
142 gst_message_type_get_name (GstMessageType type)
146 for (i = 0; message_quarks[i].name; i++) {
147 if (type == message_quarks[i].type)
148 return message_quarks[i].name;
154 * gst_message_type_to_quark:
155 * @type: the message type
157 * Get the unique quark for the given message type.
159 * Returns: the quark associated with the message type
162 gst_message_type_to_quark (GstMessageType type)
166 for (i = 0; message_quarks[i].name; i++) {
167 if (type == message_quarks[i].type)
168 return message_quarks[i].quark;
174 _gst_message_free (GstMessage * message)
176 GstStructure *structure;
178 g_return_if_fail (message != NULL);
180 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
181 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
183 if (GST_MESSAGE_SRC (message)) {
184 gst_object_unref (GST_MESSAGE_SRC (message));
185 GST_MESSAGE_SRC (message) = NULL;
189 GST_MESSAGE_LOCK (message);
190 GST_MESSAGE_SIGNAL (message);
191 GST_MESSAGE_UNLOCK (message);
194 structure = GST_MESSAGE_STRUCTURE (message);
196 gst_structure_set_parent_refcount (structure, NULL);
197 gst_structure_free (structure);
200 g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
204 _gst_message_copy (GstMessage * message)
206 GstMessageImpl *copy;
207 GstStructure *structure;
209 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
210 GST_MESSAGE_TYPE_NAME (message),
211 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
213 copy = g_slice_new0 (GstMessageImpl);
215 gst_mini_object_init (GST_MINI_OBJECT_CAST (copy),
216 _gst_message_type, sizeof (GstMessageImpl));
218 copy->message.mini_object.copy =
219 (GstMiniObjectCopyFunction) _gst_message_copy;
220 copy->message.mini_object.free =
221 (GstMiniObjectFreeFunction) _gst_message_free;
223 GST_MESSAGE_TYPE (copy) = GST_MESSAGE_TYPE (message);
224 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
225 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
226 if (GST_MESSAGE_SRC (message)) {
227 GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
230 GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message);
231 GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message);
233 structure = GST_MESSAGE_STRUCTURE (message);
235 copy->structure = gst_structure_copy (structure);
236 gst_structure_set_parent_refcount (copy->structure,
237 ©->message.mini_object.refcount);
240 return GST_MESSAGE_CAST (copy);
244 * gst_message_new_custom:
245 * @type: The #GstMessageType to distinguish messages
246 * @src: The object originating the message.
247 * @structure: (transfer full): the structure for the message. The message
248 * will take ownership of the structure.
250 * Create a new custom-typed message. This can be used for anything not
251 * handled by other message-specific functions to pass a message to the
252 * app. The structure field can be NULL.
254 * Returns: (transfer full): The new message.
259 gst_message_new_custom (GstMessageType type, GstObject * src,
260 GstStructure * structure)
262 GstMessageImpl *message;
264 message = g_slice_new0 (GstMessageImpl);
266 gst_mini_object_init (GST_MINI_OBJECT_CAST (message),
267 _gst_message_type, sizeof (GstMessageImpl));
269 message->message.mini_object.copy =
270 (GstMiniObjectCopyFunction) _gst_message_copy;
271 message->message.mini_object.free =
272 (GstMiniObjectFreeFunction) _gst_message_free;
274 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
275 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
276 gst_message_type_get_name (type));
278 GST_MESSAGE_TYPE (message) = type;
280 gst_object_ref (src);
281 GST_MESSAGE_SRC (message) = src;
282 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
283 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
286 gst_structure_set_parent_refcount (structure,
287 &message->message.mini_object.refcount);
289 message->structure = structure;
291 return GST_MESSAGE_CAST (message);
295 * gst_message_get_seqnum:
296 * @message: A #GstMessage.
298 * Retrieve the sequence number of a message.
300 * Messages have ever-incrementing sequence numbers, which may also be set
301 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
302 * to indicate that a message corresponds to some other set of messages or
303 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
304 * is considered good practice to make this correspondence when possible, though
305 * it is not required.
307 * Note that events and messages share the same sequence number incrementor;
308 * two events or messages will never have the same sequence number unless
309 * that correspondence was made explicitly.
311 * Returns: The message's sequence number.
318 gst_message_get_seqnum (GstMessage * message)
320 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
322 return GST_MESSAGE_SEQNUM (message);
326 * gst_message_set_seqnum:
327 * @message: A #GstMessage.
328 * @seqnum: A sequence number.
330 * Set the sequence number of a message.
332 * This function might be called by the creator of a message to indicate that
333 * the message relates to other messages or events. See gst_message_get_seqnum()
334 * for more information.
341 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
343 g_return_if_fail (GST_IS_MESSAGE (message));
345 GST_MESSAGE_SEQNUM (message) = seqnum;
349 * gst_message_new_eos:
350 * @src: (transfer none): The object originating the message.
352 * Create a new eos message. This message is generated and posted in
353 * the sink elements of a GstBin. The bin will only forward the EOS
354 * message to the application if all sinks have posted an EOS message.
356 * Returns: (transfer full): The new eos message.
361 gst_message_new_eos (GstObject * src)
365 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
371 * gst_message_new_error:
372 * @src: (transfer none): The object originating the message.
373 * @error: (transfer none): The GError for this message.
374 * @debug: A debugging string.
376 * Create a new error message. The message will copy @error and
377 * @debug. This message is posted by element when a fatal event
378 * occured. The pipeline will probably (partially) stop. The application
379 * receiving this message should stop the pipeline.
381 * Returns: (transfer full): the new error message.
386 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
389 GstStructure *structure;
391 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ERROR),
392 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
393 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
394 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
400 * gst_message_new_warning:
401 * @src: (transfer none): The object originating the message.
402 * @error: (transfer none): The GError for this message.
403 * @debug: A debugging string.
405 * Create a new warning message. The message will make copies of @error and
408 * Returns: (transfer full): The new warning message.
413 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
416 GstStructure *structure;
418 structure = gst_structure_id_new (GST_QUARK (MESSAGE_WARNING),
419 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
420 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
421 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
427 * gst_message_new_info:
428 * @src: (transfer none): The object originating the message.
429 * @error: (transfer none): The GError for this message.
430 * @debug: A debugging string.
432 * Create a new info message. The message will make copies of @error and
437 * Returns: (transfer full): the new info message.
442 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
445 GstStructure *structure;
447 structure = gst_structure_id_new (GST_QUARK (MESSAGE_INFO),
448 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
449 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
450 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
456 * gst_message_new_tag:
457 * @src: (transfer none): The object originating the message.
458 * @tag_list: (transfer full): the tag list for the message.
460 * Create a new tag message. The message will take ownership of the tag list.
461 * The message is posted by elements that discovered a new taglist.
463 * Returns: (transfer full): the new tag message.
468 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
472 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
475 gst_message_new_custom (GST_MESSAGE_TAG, src, (GstStructure *) tag_list);
481 * gst_message_new_buffering:
482 * @src: (transfer none): The object originating the message.
483 * @percent: The buffering percent
485 * Create a new buffering message. This message can be posted by an element that
486 * needs to buffer data before it can continue processing. @percent should be a
487 * value between 0 and 100. A value of 100 means that the buffering completed.
489 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
490 * @percent is 100, the application can set the pipeline (back) to PLAYING.
491 * The application must be prepared to receive BUFFERING messages in the
492 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
493 * message with @percent set to 100, which can happen after the pipeline
494 * completed prerolling.
498 * Returns: (transfer full): The new buffering message.
503 gst_message_new_buffering (GstObject * src, gint percent)
506 GstStructure *structure;
508 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
510 structure = gst_structure_id_new (GST_QUARK (MESSAGE_BUFFERING),
511 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
512 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
513 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
514 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
515 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
516 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
517 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
523 * gst_message_new_state_changed:
524 * @src: (transfer none): the object originating the message
525 * @oldstate: the previous state
526 * @newstate: the new (current) state
527 * @pending: the pending (target) state
529 * Create a state change message. This message is posted whenever an element
532 * Returns: (transfer full): the new state change message.
537 gst_message_new_state_changed (GstObject * src,
538 GstState oldstate, GstState newstate, GstState pending)
541 GstStructure *structure;
543 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STATE),
544 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
545 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
546 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
547 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
553 * gst_message_new_state_dirty:
554 * @src: (transfer none): the object originating the message
556 * Create a state dirty message. This message is posted whenever an element
557 * changed its state asynchronously and is used internally to update the
558 * states of container objects.
560 * Returns: (transfer full): the new state dirty message.
565 gst_message_new_state_dirty (GstObject * src)
569 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
575 * gst_message_new_clock_provide:
576 * @src: (transfer none): the object originating the message.
577 * @clock: (transfer none): the clock it provides
578 * @ready: TRUE if the sender can provide a clock
580 * Create a clock provide message. This message is posted whenever an
581 * element is ready to provide a clock or lost its ability to provide
582 * a clock (maybe because it paused or became EOS).
584 * This message is mainly used internally to manage the clock
587 * Returns: (transfer full): the new provide clock message.
592 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
596 GstStructure *structure;
598 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
599 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
600 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
601 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
607 * gst_message_new_clock_lost:
608 * @src: (transfer none): the object originating the message.
609 * @clock: (transfer none): the clock that was lost
611 * Create a clock lost message. This message is posted whenever the
612 * clock is not valid anymore.
614 * If this message is posted by the pipeline, the pipeline will
615 * select a new clock again when it goes to PLAYING. It might therefore
616 * be needed to set the pipeline to PAUSED and PLAYING again.
618 * Returns: (transfer full): The new clock lost message.
623 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
626 GstStructure *structure;
628 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_LOST),
629 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
630 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
636 * gst_message_new_new_clock:
637 * @src: (transfer none): The object originating the message.
638 * @clock: (transfer none): the new selected clock
640 * Create a new clock message. This message is posted whenever the
641 * pipeline selectes a new clock for the pipeline.
643 * Returns: (transfer full): The new new clock message.
648 gst_message_new_new_clock (GstObject * src, GstClock * clock)
651 GstStructure *structure;
653 structure = gst_structure_id_new (GST_QUARK (MESSAGE_NEW_CLOCK),
654 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
655 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
661 * gst_message_new_structure_change:
662 * @src: (transfer none): The object originating the message.
663 * @type: The change type.
664 * @owner: (transfer none): The owner element of @src.
665 * @busy: Whether the structure change is busy.
667 * Create a new structure change message. This message is posted when the
668 * structure of a pipeline is in the process of being changed, for example
669 * when pads are linked or unlinked.
671 * @src should be the sinkpad that unlinked or linked.
673 * Returns: (transfer full): the new structure change message.
680 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
681 GstElement * owner, gboolean busy)
684 GstStructure *structure;
686 g_return_val_if_fail (GST_IS_PAD (src), NULL);
687 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
688 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
690 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
691 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
692 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
693 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
695 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
702 * gst_message_new_segment_start:
703 * @src: (transfer none): The object originating the message.
704 * @format: The format of the position being played
705 * @position: The position of the segment being played
707 * Create a new segment message. This message is posted by elements that
708 * start playback of a segment as a result of a segment seek. This message
709 * is not received by the application but is used for maintenance reasons in
710 * container elements.
712 * Returns: (transfer full): the new segment start message.
717 gst_message_new_segment_start (GstObject * src, GstFormat format,
721 GstStructure *structure;
723 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_START),
724 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
725 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
726 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
732 * gst_message_new_segment_done:
733 * @src: (transfer none): the object originating the message.
734 * @format: The format of the position being done
735 * @position: The position of the segment being done
737 * Create a new segment done message. This message is posted by elements that
738 * finish playback of a segment as a result of a segment seek. This message
739 * is received by the application after all elements that posted a segment_start
740 * have posted the segment_done.
742 * Returns: (transfer full): the new segment done message.
747 gst_message_new_segment_done (GstObject * src, GstFormat format,
751 GstStructure *structure;
753 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_DONE),
754 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
755 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
756 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
762 * gst_message_new_application:
763 * @src: (transfer none): the object originating the message.
764 * @structure: (transfer full): the structure for the message. The message
765 * will take ownership of the structure.
767 * Create a new application-typed message. GStreamer will never create these
768 * messages; they are a gift from us to you. Enjoy.
770 * Returns: (transfer full): The new application message.
775 gst_message_new_application (GstObject * src, GstStructure * structure)
777 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
781 * gst_message_new_element:
782 * @src: (transfer none): The object originating the message.
783 * @structure: (transfer full): The structure for the message. The message
784 * will take ownership of the structure.
786 * Create a new element-specific message. This is meant as a generic way of
787 * allowing one-way communication from an element to an application, for example
788 * "the firewire cable was unplugged". The format of the message should be
789 * documented in the element's documentation. The structure field can be NULL.
791 * Returns: (transfer full): The new element message.
796 gst_message_new_element (GstObject * src, GstStructure * structure)
798 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
802 * gst_message_new_duration:
803 * @src: (transfer none): The object originating the message.
804 * @format: The format of the duration
805 * @duration: The new duration
807 * Create a new duration message. This message is posted by elements that
808 * know the duration of a stream in a specific format. This message
809 * is received by bins and is used to calculate the total duration of a
810 * pipeline. Elements may post a duration message with a duration of
811 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
812 * cached duration should be discarded. The new duration can then be
813 * retrieved via a query.
815 * Returns: (transfer full): The new duration message.
820 gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration)
823 GstStructure *structure;
825 structure = gst_structure_id_new (GST_QUARK (MESSAGE_DURATION),
826 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
827 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
828 message = gst_message_new_custom (GST_MESSAGE_DURATION, src, structure);
834 * gst_message_new_async_start:
835 * @src: (transfer none): The object originating the message.
837 * This message is posted by elements when they start an ASYNC state change.
839 * Returns: (transfer full): The new async_start message.
844 gst_message_new_async_start (GstObject * src)
848 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
854 * gst_message_new_async_done:
855 * @src: (transfer none): The object originating the message.
856 * @reset_time: if the running_time should be reset
858 * The message is posted when elements completed an ASYNC state change.
859 * @reset_time is set to TRUE when the element requests a new running_time
860 * before going to PLAYING.
862 * Returns: (transfer full): The new async_done message.
867 gst_message_new_async_done (GstObject * src, gboolean reset_time)
870 GstStructure *structure;
872 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ASYNC_DONE),
873 GST_QUARK (RESET_TIME), G_TYPE_BOOLEAN, reset_time, NULL);
874 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
880 * gst_message_new_latency:
881 * @src: (transfer none): The object originating the message.
883 * This message can be posted by elements when their latency requirements have
886 * Returns: (transfer full): The new latency message.
893 gst_message_new_latency (GstObject * src)
897 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
903 * gst_message_new_request_state:
904 * @src: (transfer none): the object originating the message.
905 * @state: The new requested state
907 * This message can be posted by elements when they want to have their state
908 * changed. A typical use case would be an audio server that wants to pause the
909 * pipeline because a higher priority stream is being played.
911 * 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_id_new (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.
963 gst_message_has_name (GstMessage * message, const gchar * name)
965 GstStructure *structure;
967 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
969 structure = GST_MESSAGE_STRUCTURE (message);
970 if (structure == NULL)
973 return gst_structure_has_name (structure, name);
977 * gst_message_parse_tag:
978 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
979 * @tag_list: (out callee-allocates): return location for the tag-list.
981 * Extracts the tag list from the GstMessage. The tag list returned in the
982 * output argument is a copy; the caller must free it when done.
984 * Typical usage of this function might be:
987 * switch (GST_MESSAGE_TYPE (msg)) {
988 * case GST_MESSAGE_TAG: {
989 * GstTagList *tags = NULL;
991 * gst_message_parse_tag (msg, &tags);
992 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
993 * handle_tags (tags);
994 * gst_tag_list_free (tags);
1005 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1009 g_return_if_fail (GST_IS_MESSAGE (message));
1010 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1011 g_return_if_fail (tag_list != NULL);
1013 ret = gst_structure_copy (GST_MESSAGE_STRUCTURE (message));
1014 gst_structure_remove_field (ret, "source-pad");
1016 *tag_list = (GstTagList *) ret;
1020 * gst_message_parse_buffering:
1021 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1022 * @percent: (out) (allow-none): Return location for the percent.
1024 * Extracts the buffering percent from the GstMessage. see also
1025 * gst_message_new_buffering().
1032 gst_message_parse_buffering (GstMessage * message, gint * percent)
1034 g_return_if_fail (GST_IS_MESSAGE (message));
1035 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1039 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1040 (message), GST_QUARK (BUFFER_PERCENT)));
1044 * gst_message_set_buffering_stats:
1045 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1046 * @mode: a buffering mode
1047 * @avg_in: the average input rate
1048 * @avg_out: the average output rate
1049 * @buffering_left: amount of buffering time left in milliseconds
1051 * Configures the buffering stats values in @message.
1056 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1057 gint avg_in, gint avg_out, gint64 buffering_left)
1059 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1061 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1062 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1063 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1064 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1065 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1069 * gst_message_parse_buffering_stats:
1070 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1071 * @mode: (out) (allow-none): a buffering mode, or NULL
1072 * @avg_in: (out) (allow-none): the average input rate, or NULL
1073 * @avg_out: (out) (allow-none): the average output rate, or NULL
1074 * @buffering_left: (out) (allow-none): amount of buffering time left in
1075 * milliseconds, or NULL
1077 * Extracts the buffering stats values from @message.
1082 gst_message_parse_buffering_stats (GstMessage * message,
1083 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1084 gint64 * buffering_left)
1086 GstStructure *structure;
1088 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1090 structure = GST_MESSAGE_STRUCTURE (message);
1092 *mode = (GstBufferingMode)
1093 g_value_get_enum (gst_structure_id_get_value (structure,
1094 GST_QUARK (BUFFERING_MODE)));
1096 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1097 GST_QUARK (AVG_IN_RATE)));
1099 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1100 GST_QUARK (AVG_OUT_RATE)));
1103 g_value_get_int64 (gst_structure_id_get_value (structure,
1104 GST_QUARK (BUFFERING_LEFT)));
1108 * gst_message_parse_state_changed:
1109 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1110 * @oldstate: (out) (allow-none): the previous state, or NULL
1111 * @newstate: (out) (allow-none): the new (current) state, or NULL
1112 * @pending: (out) (allow-none): the pending (target) state, or NULL
1114 * Extracts the old and new states from the GstMessage.
1116 * Typical usage of this function might be:
1119 * switch (GST_MESSAGE_TYPE (msg)) {
1120 * case GST_MESSAGE_STATE_CHANGED: {
1121 * GstState old_state, new_state;
1123 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1124 * g_print ("Element %s changed state from %s to %s.\n",
1125 * GST_OBJECT_NAME (msg->src),
1126 * gst_element_state_get_name (old_state),
1127 * gst_element_state_get_name (new_state));
1138 gst_message_parse_state_changed (GstMessage * message,
1139 GstState * oldstate, GstState * newstate, GstState * pending)
1141 GstStructure *structure;
1143 g_return_if_fail (GST_IS_MESSAGE (message));
1144 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1146 structure = GST_MESSAGE_STRUCTURE (message);
1148 *oldstate = (GstState)
1149 g_value_get_enum (gst_structure_id_get_value (structure,
1150 GST_QUARK (OLD_STATE)));
1152 *newstate = (GstState)
1153 g_value_get_enum (gst_structure_id_get_value (structure,
1154 GST_QUARK (NEW_STATE)));
1156 *pending = (GstState)
1157 g_value_get_enum (gst_structure_id_get_value (structure,
1158 GST_QUARK (PENDING_STATE)));
1162 * gst_message_parse_clock_provide:
1163 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1164 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1166 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1168 * Extracts the clock and ready flag from the GstMessage.
1169 * The clock object returned remains valid until the message is freed.
1174 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1177 const GValue *clock_gvalue;
1178 GstStructure *structure;
1180 g_return_if_fail (GST_IS_MESSAGE (message));
1181 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1183 structure = GST_MESSAGE_STRUCTURE (message);
1184 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1185 g_return_if_fail (clock_gvalue != NULL);
1186 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1190 g_value_get_boolean (gst_structure_id_get_value (structure,
1191 GST_QUARK (READY)));
1193 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1197 * gst_message_parse_clock_lost:
1198 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1199 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1201 * Extracts the lost clock from the GstMessage.
1202 * The clock object returned remains valid until the message is freed.
1207 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1209 const GValue *clock_gvalue;
1210 GstStructure *structure;
1212 g_return_if_fail (GST_IS_MESSAGE (message));
1213 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1215 structure = GST_MESSAGE_STRUCTURE (message);
1216 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1217 g_return_if_fail (clock_gvalue != NULL);
1218 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1221 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1225 * gst_message_parse_new_clock:
1226 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1227 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1230 * Extracts the new clock from the GstMessage.
1231 * The clock object returned remains valid until the message is freed.
1236 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1238 const GValue *clock_gvalue;
1239 GstStructure *structure;
1241 g_return_if_fail (GST_IS_MESSAGE (message));
1242 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1244 structure = GST_MESSAGE_STRUCTURE (message);
1245 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1246 g_return_if_fail (clock_gvalue != NULL);
1247 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1250 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1254 * gst_message_parse_structure_change:
1255 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1256 * @type: (out): A pointer to hold the change type
1257 * @owner: (out) (allow-none) (transfer none): The owner element of the
1259 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1260 * progress or has been completed
1262 * Extracts the change type and completion status from the GstMessage.
1269 gst_message_parse_structure_change (GstMessage * message,
1270 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1272 const GValue *owner_gvalue;
1273 GstStructure *structure;
1275 g_return_if_fail (GST_IS_MESSAGE (message));
1276 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1278 structure = GST_MESSAGE_STRUCTURE (message);
1279 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1280 g_return_if_fail (owner_gvalue != NULL);
1281 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1284 *type = (GstStructureChangeType)
1285 g_value_get_enum (gst_structure_id_get_value (structure,
1288 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1291 g_value_get_boolean (gst_structure_id_get_value (structure,
1296 * gst_message_parse_error:
1297 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1298 * @gerror: (out) (allow-none) (transfer full): location for the GError
1299 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1302 * Extracts the GError and debug string from the GstMessage. The values returned
1303 * in the output arguments are copies; the caller must free them when done.
1305 * Typical usage of this function might be:
1308 * switch (GST_MESSAGE_TYPE (msg)) {
1309 * case GST_MESSAGE_ERROR: {
1310 * GError *err = NULL;
1311 * gchar *dbg_info = NULL;
1313 * gst_message_parse_error (msg, &err, &dbg_info);
1314 * g_printerr ("ERROR from element %s: %s\n",
1315 * GST_OBJECT_NAME (msg->src), err->message);
1316 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1317 * g_error_free (err);
1318 * g_free (dbg_info);
1329 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1331 const GValue *error_gvalue;
1333 GstStructure *structure;
1335 g_return_if_fail (GST_IS_MESSAGE (message));
1336 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1338 structure = GST_MESSAGE_STRUCTURE (message);
1339 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1340 g_return_if_fail (error_gvalue != NULL);
1341 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1343 error_val = (GError *) g_value_get_boxed (error_gvalue);
1345 *gerror = g_error_copy (error_val);
1351 g_value_dup_string (gst_structure_id_get_value (structure,
1352 GST_QUARK (DEBUG)));
1356 * gst_message_parse_warning:
1357 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1358 * @gerror: (out) (allow-none) (transfer full): location for the GError
1359 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1362 * Extracts the GError and debug string from the GstMessage. The values returned
1363 * in the output arguments are copies; the caller must free them when done.
1368 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1371 const GValue *error_gvalue;
1373 GstStructure *structure;
1375 g_return_if_fail (GST_IS_MESSAGE (message));
1376 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1378 structure = GST_MESSAGE_STRUCTURE (message);
1379 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1380 g_return_if_fail (error_gvalue != NULL);
1381 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1383 error_val = (GError *) g_value_get_boxed (error_gvalue);
1385 *gerror = g_error_copy (error_val);
1391 g_value_dup_string (gst_structure_id_get_value (structure,
1392 GST_QUARK (DEBUG)));
1396 * gst_message_parse_info:
1397 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1398 * @gerror: (out) (allow-none) (transfer full): location for the GError
1399 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1402 * Extracts the GError and debug string from the GstMessage. The values returned
1403 * in the output arguments are copies; the caller must free them when done.
1410 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1412 const GValue *error_gvalue;
1414 GstStructure *structure;
1416 g_return_if_fail (GST_IS_MESSAGE (message));
1417 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1419 structure = GST_MESSAGE_STRUCTURE (message);
1420 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1421 g_return_if_fail (error_gvalue != NULL);
1422 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1424 error_val = (GError *) g_value_get_boxed (error_gvalue);
1426 *gerror = g_error_copy (error_val);
1432 g_value_dup_string (gst_structure_id_get_value (structure,
1433 GST_QUARK (DEBUG)));
1437 * gst_message_parse_segment_start:
1438 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1439 * @format: (out): Result location for the format, or NULL
1440 * @position: (out): Result location for the position, or NULL
1442 * Extracts the position and format from the segment start message.
1447 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1450 GstStructure *structure;
1452 g_return_if_fail (GST_IS_MESSAGE (message));
1453 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1455 structure = GST_MESSAGE_STRUCTURE (message);
1457 *format = (GstFormat)
1458 g_value_get_enum (gst_structure_id_get_value (structure,
1459 GST_QUARK (FORMAT)));
1462 g_value_get_int64 (gst_structure_id_get_value (structure,
1463 GST_QUARK (POSITION)));
1467 * gst_message_parse_segment_done:
1468 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1469 * @format: (out): Result location for the format, or NULL
1470 * @position: (out): Result location for the position, or NULL
1472 * Extracts the position and format from the segment start message.
1477 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1480 GstStructure *structure;
1482 g_return_if_fail (GST_IS_MESSAGE (message));
1483 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1485 structure = GST_MESSAGE_STRUCTURE (message);
1487 *format = (GstFormat)
1488 g_value_get_enum (gst_structure_id_get_value (structure,
1489 GST_QUARK (FORMAT)));
1492 g_value_get_int64 (gst_structure_id_get_value (structure,
1493 GST_QUARK (POSITION)));
1497 * gst_message_parse_duration:
1498 * @message: A valid #GstMessage of type GST_MESSAGE_DURATION.
1499 * @format: (out): Result location for the format, or NULL
1500 * @duration: (out): Result location for the duration, or NULL
1502 * Extracts the duration and format from the duration message. The duration
1503 * might be GST_CLOCK_TIME_NONE, which indicates that the duration has
1504 * changed. Applications should always use a query to retrieve the duration
1510 gst_message_parse_duration (GstMessage * message, GstFormat * format,
1513 GstStructure *structure;
1515 g_return_if_fail (GST_IS_MESSAGE (message));
1516 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DURATION);
1518 structure = GST_MESSAGE_STRUCTURE (message);
1520 *format = (GstFormat)
1521 g_value_get_enum (gst_structure_id_get_value (structure,
1522 GST_QUARK (FORMAT)));
1525 g_value_get_int64 (gst_structure_id_get_value (structure,
1526 GST_QUARK (DURATION)));
1530 * gst_message_parse_async_done:
1531 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1532 * @reset_time: (out): Result location for the reset_time or NULL
1534 * Extract the reset_time from the async_done message.
1539 gst_message_parse_async_done (GstMessage * message, gboolean * reset_time)
1541 GstStructure *structure;
1543 g_return_if_fail (GST_IS_MESSAGE (message));
1544 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1546 structure = GST_MESSAGE_STRUCTURE (message);
1549 g_value_get_boolean (gst_structure_id_get_value (structure,
1550 GST_QUARK (RESET_TIME)));
1554 * gst_message_parse_request_state:
1555 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1556 * @state: (out): Result location for the requested state or NULL
1558 * Extract the requested state from the request_state message.
1565 gst_message_parse_request_state (GstMessage * message, GstState * state)
1567 GstStructure *structure;
1569 g_return_if_fail (GST_IS_MESSAGE (message));
1570 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1572 structure = GST_MESSAGE_STRUCTURE (message);
1575 g_value_get_enum (gst_structure_id_get_value (structure,
1576 GST_QUARK (NEW_STATE)));
1580 * gst_message_new_stream_status:
1581 * @src: The object originating the message.
1582 * @type: The stream status type.
1583 * @owner: (transfer none): the owner element of @src.
1585 * Create a new stream status message. This message is posted when a streaming
1586 * thread is created/destroyed or when the state changed.
1588 * Returns: (transfer full): the new stream status message.
1595 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1598 GstMessage *message;
1599 GstStructure *structure;
1601 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STREAM_STATUS),
1602 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1603 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1604 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1610 * gst_message_parse_stream_status:
1611 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1612 * @type: (out): A pointer to hold the status type
1613 * @owner: (out) (transfer none): The owner element of the message source
1615 * Extracts the stream status type and owner the GstMessage. The returned
1616 * owner remains valid for as long as the reference to @message is valid and
1617 * should thus not be unreffed.
1624 gst_message_parse_stream_status (GstMessage * message,
1625 GstStreamStatusType * type, GstElement ** owner)
1627 const GValue *owner_gvalue;
1628 GstStructure *structure;
1630 g_return_if_fail (GST_IS_MESSAGE (message));
1631 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1633 structure = GST_MESSAGE_STRUCTURE (message);
1634 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1635 g_return_if_fail (owner_gvalue != NULL);
1638 *type = (GstStreamStatusType)
1639 g_value_get_enum (gst_structure_id_get_value (structure,
1642 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1646 * gst_message_set_stream_status_object:
1647 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1648 * @object: the object controlling the streaming
1650 * Configures the object handling the streaming thread. This is usually a
1651 * GstTask object but other objects might be added in the future.
1656 gst_message_set_stream_status_object (GstMessage * message,
1657 const GValue * object)
1659 GstStructure *structure;
1661 g_return_if_fail (GST_IS_MESSAGE (message));
1662 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1664 structure = GST_MESSAGE_STRUCTURE (message);
1665 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1669 * gst_message_get_stream_status_object:
1670 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1672 * Extracts the object managing the streaming thread from @message.
1674 * Returns: a GValue containing the object that manages the streaming thread.
1675 * This object is usually of type GstTask but other types can be added in the
1676 * future. The object remains valid as long as @message is valid.
1681 gst_message_get_stream_status_object (GstMessage * message)
1683 const GValue *result;
1684 GstStructure *structure;
1686 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1687 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1690 structure = GST_MESSAGE_STRUCTURE (message);
1691 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1697 * gst_message_new_step_done:
1698 * @src: The object originating the message.
1699 * @format: the format of @amount
1700 * @amount: the amount of stepped data
1701 * @rate: the rate of the stepped amount
1702 * @flush: is this an flushing step
1703 * @intermediate: is this an intermediate step
1704 * @duration: the duration of the data
1705 * @eos: the step caused EOS
1707 * This message is posted by elements when they complete a part, when @intermediate set
1708 * to TRUE, or a complete step operation.
1710 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1711 * @amount of media in format @format.
1713 * Returns: (transfer full): the new step_done message.
1720 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1721 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1724 GstMessage *message;
1725 GstStructure *structure;
1727 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_DONE),
1728 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1729 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1730 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1731 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1732 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1733 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1734 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1735 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1741 * gst_message_parse_step_done:
1742 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1743 * @format: (out) (allow-none): result location for the format
1744 * @amount: (out) (allow-none): result location for the amount
1745 * @rate: (out) (allow-none): result location for the rate
1746 * @flush: (out) (allow-none): result location for the flush flag
1747 * @intermediate: (out) (allow-none): result location for the intermediate flag
1748 * @duration: (out) (allow-none): result location for the duration
1749 * @eos: (out) (allow-none): result location for the EOS flag
1751 * Extract the values the step_done message.
1758 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1759 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1760 guint64 * duration, gboolean * eos)
1762 GstStructure *structure;
1764 g_return_if_fail (GST_IS_MESSAGE (message));
1765 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1767 structure = GST_MESSAGE_STRUCTURE (message);
1768 gst_structure_id_get (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 GstStructure *structure;
1847 g_return_if_fail (GST_IS_MESSAGE (message));
1848 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1850 structure = GST_MESSAGE_STRUCTURE (message);
1851 gst_structure_id_get (structure,
1852 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1853 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1854 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1855 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1856 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1857 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1861 * gst_message_new_qos:
1862 * @src: The object originating the message.
1863 * @live: if the message was generated by a live element
1864 * @running_time: the running time of the buffer that generated the message
1865 * @stream_time: the stream time of the buffer that generated the message
1866 * @timestamp: the timestamps of the buffer that generated the message
1867 * @duration: the duration of the buffer that generated the message
1869 * A QOS message is posted on the bus whenever an element decides to drop a
1870 * buffer because of QoS reasons or whenever it changes its processing strategy
1871 * because of QoS reasons (quality adjustments such as processing at lower
1874 * This message can be posted by an element that performs synchronisation against the
1875 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1876 * events received from a downstream element (!live).
1878 * @running_time, @stream_time, @timestamp, @duration should be set to the
1879 * respective running-time, stream-time, timestamp and duration of the (dropped)
1880 * buffer that generated the QoS event. Values can be left to
1881 * GST_CLOCK_TIME_NONE when unknown.
1883 * Returns: (transfer full): The new qos message.
1890 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1891 guint64 stream_time, guint64 timestamp, guint64 duration)
1893 GstMessage *message;
1894 GstStructure *structure;
1896 structure = gst_structure_id_new (GST_QUARK (MESSAGE_QOS),
1897 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1898 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1899 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1900 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1901 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1902 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1903 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1904 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1905 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1906 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1907 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1908 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1914 * gst_message_set_qos_values:
1915 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1916 * @jitter: The difference of the running-time against the deadline.
1917 * @proportion: Long term prediction of the ideal rate relative to normal rate
1918 * to get optimal quality.
1919 * @quality: An element dependent integer value that specifies the current
1920 * quality level of the element. The default maximum quality is 1000000.
1922 * Set the QoS values that have been calculated/analysed from the QoS data
1929 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1930 gdouble proportion, gint quality)
1932 GstStructure *structure;
1934 g_return_if_fail (GST_IS_MESSAGE (message));
1935 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1937 structure = GST_MESSAGE_STRUCTURE (message);
1938 gst_structure_id_set (structure,
1939 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1940 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1941 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1945 * gst_message_set_qos_stats:
1946 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1947 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1948 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1949 * will likely use GST_FORMAT_DEFAULT (samples).
1950 * @processed: Total number of units correctly processed since the last state
1951 * change to READY or a flushing operation.
1952 * @dropped: Total number of units dropped since the last state change to READY
1953 * or a flushing operation.
1955 * Set the QoS stats representing the history of the current continuous pipeline
1958 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1959 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1966 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1967 guint64 processed, guint64 dropped)
1969 GstStructure *structure;
1971 g_return_if_fail (GST_IS_MESSAGE (message));
1972 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1974 structure = GST_MESSAGE_STRUCTURE (message);
1975 gst_structure_id_set (structure,
1976 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1977 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1978 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1982 * gst_message_parse_qos:
1983 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1984 * @live: (out) (allow-none): if the message was generated by a live element
1985 * @running_time: (out) (allow-none): the running time of the buffer that
1986 * generated the message
1987 * @stream_time: (out) (allow-none): the stream time of the buffer that
1988 * generated the message
1989 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1990 * generated the message
1991 * @duration: (out) (allow-none): the duration of the buffer that
1992 * generated the message
1994 * Extract the timestamps and live status from the QoS message.
1996 * The returned values give the running_time, stream_time, timestamp and
1997 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2005 gst_message_parse_qos (GstMessage * message, gboolean * live,
2006 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2009 GstStructure *structure;
2011 g_return_if_fail (GST_IS_MESSAGE (message));
2012 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2014 structure = GST_MESSAGE_STRUCTURE (message);
2015 gst_structure_id_get (structure,
2016 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2017 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2018 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2019 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2020 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2024 * gst_message_parse_qos_values:
2025 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2026 * @jitter: (out) (allow-none): The difference of the running-time against
2028 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2029 * relative to normal rate to get optimal quality.
2030 * @quality: (out) (allow-none): An element dependent integer value that
2031 * specifies the current quality level of the element. The default
2032 * maximum quality is 1000000.
2034 * Extract the QoS values that have been calculated/analysed from the QoS data
2041 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2042 gdouble * proportion, gint * quality)
2044 GstStructure *structure;
2046 g_return_if_fail (GST_IS_MESSAGE (message));
2047 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2049 structure = GST_MESSAGE_STRUCTURE (message);
2050 gst_structure_id_get (structure,
2051 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2052 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2053 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2057 * gst_message_parse_qos_stats:
2058 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2059 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2060 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2061 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2063 * @processed: (out) (allow-none): Total number of units correctly processed
2064 * since the last state change to READY or a flushing operation.
2065 * @dropped: (out) (allow-none): Total number of units dropped since the last
2066 * state change to READY or a flushing operation.
2068 * Extract the QoS stats representing the history of the current continuous
2069 * pipeline playback period.
2071 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2072 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2079 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2080 guint64 * processed, guint64 * dropped)
2082 GstStructure *structure;
2084 g_return_if_fail (GST_IS_MESSAGE (message));
2085 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2087 structure = GST_MESSAGE_STRUCTURE (message);
2088 gst_structure_id_get (structure,
2089 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2090 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2091 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2095 * gst_message_new_progress:
2096 * @src: The object originating the message.
2097 * @type: a #GstProgressType
2098 * @code: a progress code
2099 * @text: free, user visible text describing the progress
2101 * Progress messages are posted by elements when they use an asynchronous task
2102 * to perform actions triggered by a state change.
2104 * @code contains a well defined string describing the action.
2105 * @test should contain a user visible string detailing the current action.
2107 * Returns: (transfer full): The new qos message.
2112 gst_message_new_progress (GstObject * src, GstProgressType type,
2113 const gchar * code, const gchar * text)
2115 GstMessage *message;
2116 GstStructure *structure;
2117 gint percent = 100, timeout = -1;
2119 g_return_val_if_fail (code != NULL, NULL);
2120 g_return_val_if_fail (text != NULL, NULL);
2122 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2125 structure = gst_structure_id_new (GST_QUARK (MESSAGE_PROGRESS),
2126 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2127 GST_QUARK (CODE), G_TYPE_STRING, code,
2128 GST_QUARK (TEXT), G_TYPE_STRING, text,
2129 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2130 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2131 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2137 * gst_message_parse_progress:
2138 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2139 * @type: (out) (allow-none): location for the type
2140 * @code: (out) (allow-none) (transfer full): location for the code
2141 * @text: (out) (allow-none) (transfer full): location for the text
2143 * Parses the progress @type, @code and @text.
2148 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2149 gchar ** code, gchar ** text)
2151 GstStructure *structure;
2153 g_return_if_fail (GST_IS_MESSAGE (message));
2154 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2156 structure = GST_MESSAGE_STRUCTURE (message);
2157 gst_structure_id_get (structure,
2158 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2159 GST_QUARK (CODE), G_TYPE_STRING, code,
2160 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);