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", message);
182 if (GST_MESSAGE_SRC (message)) {
183 gst_object_unref (GST_MESSAGE_SRC (message));
184 GST_MESSAGE_SRC (message) = NULL;
188 GST_MESSAGE_LOCK (message);
189 GST_MESSAGE_SIGNAL (message);
190 GST_MESSAGE_UNLOCK (message);
193 structure = GST_MESSAGE_STRUCTURE (message);
195 gst_structure_set_parent_refcount (structure, NULL);
196 gst_structure_free (structure);
199 g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
203 _gst_message_copy (GstMessage * message)
205 GstMessageImpl *copy;
206 GstStructure *structure;
208 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p", message);
210 copy = g_slice_new0 (GstMessageImpl);
212 gst_mini_object_init (GST_MINI_OBJECT_CAST (copy),
213 _gst_message_type, sizeof (GstMessageImpl));
215 copy->message.mini_object.copy =
216 (GstMiniObjectCopyFunction) _gst_message_copy;
217 copy->message.mini_object.free =
218 (GstMiniObjectFreeFunction) _gst_message_free;
220 GST_MESSAGE_TYPE (copy) = GST_MESSAGE_TYPE (message);
221 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
222 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
223 if (GST_MESSAGE_SRC (message)) {
224 GST_MESSAGE_SRC (copy) = gst_object_ref (GST_MESSAGE_SRC (message));
227 GST_MESSAGE_GET_LOCK (copy) = GST_MESSAGE_GET_LOCK (message);
228 GST_MESSAGE_COND (copy) = GST_MESSAGE_COND (message);
230 structure = GST_MESSAGE_STRUCTURE (message);
232 copy->structure = gst_structure_copy (structure);
233 gst_structure_set_parent_refcount (copy->structure,
234 ©->message.mini_object.refcount);
237 return GST_MESSAGE_CAST (copy);
241 * gst_message_new_custom:
242 * @type: The #GstMessageType to distinguish messages
243 * @src: The object originating the message.
244 * @structure: (transfer full): the structure for the message. The message
245 * will take ownership of the structure.
247 * Create a new custom-typed message. This can be used for anything not
248 * handled by other message-specific functions to pass a message to the
249 * app. The structure field can be NULL.
251 * Returns: (transfer full): The new message.
256 gst_message_new_custom (GstMessageType type, GstObject * src,
257 GstStructure * structure)
259 GstMessageImpl *message;
261 message = g_slice_new0 (GstMessageImpl);
263 gst_mini_object_init (GST_MINI_OBJECT_CAST (message),
264 _gst_message_type, sizeof (GstMessageImpl));
266 message->message.mini_object.copy =
267 (GstMiniObjectCopyFunction) _gst_message_copy;
268 message->message.mini_object.free =
269 (GstMiniObjectFreeFunction) _gst_message_free;
271 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
272 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
273 gst_message_type_get_name (type));
275 GST_MESSAGE_TYPE (message) = type;
277 gst_object_ref (src);
278 GST_MESSAGE_SRC (message) = src;
279 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
280 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
283 gst_structure_set_parent_refcount (structure,
284 &message->message.mini_object.refcount);
286 message->structure = structure;
288 return GST_MESSAGE_CAST (message);
292 * gst_message_get_seqnum:
293 * @message: A #GstMessage.
295 * Retrieve the sequence number of a message.
297 * Messages have ever-incrementing sequence numbers, which may also be set
298 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
299 * to indicate that a message corresponds to some other set of messages or
300 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
301 * is considered good practice to make this correspondence when possible, though
302 * it is not required.
304 * Note that events and messages share the same sequence number incrementor;
305 * two events or messages will never have the same sequence number unless
306 * that correspondence was made explicitly.
308 * Returns: The message's sequence number.
315 gst_message_get_seqnum (GstMessage * message)
317 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
319 return GST_MESSAGE_SEQNUM (message);
323 * gst_message_set_seqnum:
324 * @message: A #GstMessage.
325 * @seqnum: A sequence number.
327 * Set the sequence number of a message.
329 * This function might be called by the creator of a message to indicate that
330 * the message relates to other messages or events. See gst_message_get_seqnum()
331 * for more information.
338 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
340 g_return_if_fail (GST_IS_MESSAGE (message));
342 GST_MESSAGE_SEQNUM (message) = seqnum;
346 * gst_message_new_eos:
347 * @src: (transfer none): The object originating the message.
349 * Create a new eos message. This message is generated and posted in
350 * the sink elements of a GstBin. The bin will only forward the EOS
351 * message to the application if all sinks have posted an EOS message.
353 * Returns: (transfer full): The new eos message.
358 gst_message_new_eos (GstObject * src)
362 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
368 * gst_message_new_error:
369 * @src: (transfer none): The object originating the message.
370 * @error: (transfer none): The GError for this message.
371 * @debug: A debugging string.
373 * Create a new error message. The message will copy @error and
374 * @debug. This message is posted by element when a fatal event
375 * occured. The pipeline will probably (partially) stop. The application
376 * receiving this message should stop the pipeline.
378 * Returns: (transfer full): the new error message.
383 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
386 GstStructure *structure;
388 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ERROR),
389 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
390 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
391 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
397 * gst_message_new_warning:
398 * @src: (transfer none): The object originating the message.
399 * @error: (transfer none): The GError for this message.
400 * @debug: A debugging string.
402 * Create a new warning message. The message will make copies of @error and
405 * Returns: (transfer full): The new warning message.
410 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
413 GstStructure *structure;
415 structure = gst_structure_id_new (GST_QUARK (MESSAGE_WARNING),
416 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
417 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
418 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
424 * gst_message_new_info:
425 * @src: (transfer none): The object originating the message.
426 * @error: (transfer none): The GError for this message.
427 * @debug: A debugging string.
429 * Create a new info message. The message will make copies of @error and
434 * Returns: (transfer full): the new info message.
439 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
442 GstStructure *structure;
444 structure = gst_structure_id_new (GST_QUARK (MESSAGE_INFO),
445 GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
446 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
447 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
453 * gst_message_new_tag:
454 * @src: (transfer none): The object originating the message.
455 * @tag_list: (transfer full): the tag list for the message.
457 * Create a new tag message. The message will take ownership of the tag list.
458 * The message is posted by elements that discovered a new taglist.
460 * Returns: (transfer full): the new tag message.
465 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
469 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
472 gst_message_new_custom (GST_MESSAGE_TAG, src, (GstStructure *) tag_list);
478 * gst_message_new_buffering:
479 * @src: (transfer none): The object originating the message.
480 * @percent: The buffering percent
482 * Create a new buffering message. This message can be posted by an element that
483 * needs to buffer data before it can continue processing. @percent should be a
484 * value between 0 and 100. A value of 100 means that the buffering completed.
486 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
487 * @percent is 100, the application can set the pipeline (back) to PLAYING.
488 * The application must be prepared to receive BUFFERING messages in the
489 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
490 * message with @percent set to 100, which can happen after the pipeline
491 * completed prerolling.
495 * Returns: (transfer full): The new buffering message.
500 gst_message_new_buffering (GstObject * src, gint percent)
503 GstStructure *structure;
505 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
507 structure = gst_structure_id_new (GST_QUARK (MESSAGE_BUFFERING),
508 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
509 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
510 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
511 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
512 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
513 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
514 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
520 * gst_message_new_state_changed:
521 * @src: (transfer none): the object originating the message
522 * @oldstate: the previous state
523 * @newstate: the new (current) state
524 * @pending: the pending (target) state
526 * Create a state change message. This message is posted whenever an element
529 * Returns: (transfer full): the new state change message.
534 gst_message_new_state_changed (GstObject * src,
535 GstState oldstate, GstState newstate, GstState pending)
538 GstStructure *structure;
540 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STATE),
541 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
542 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
543 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
544 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
550 * gst_message_new_state_dirty:
551 * @src: (transfer none): the object originating the message
553 * Create a state dirty message. This message is posted whenever an element
554 * changed its state asynchronously and is used internally to update the
555 * states of container objects.
557 * Returns: (transfer full): the new state dirty message.
562 gst_message_new_state_dirty (GstObject * src)
566 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
572 * gst_message_new_clock_provide:
573 * @src: (transfer none): the object originating the message.
574 * @clock: (transfer none): the clock it provides
575 * @ready: TRUE if the sender can provide a clock
577 * Create a clock provide message. This message is posted whenever an
578 * element is ready to provide a clock or lost its ability to provide
579 * a clock (maybe because it paused or became EOS).
581 * This message is mainly used internally to manage the clock
584 * Returns: (transfer full): the new provide clock message.
589 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
593 GstStructure *structure;
595 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
596 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
597 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
598 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
604 * gst_message_new_clock_lost:
605 * @src: (transfer none): the object originating the message.
606 * @clock: (transfer none): the clock that was lost
608 * Create a clock lost message. This message is posted whenever the
609 * clock is not valid anymore.
611 * If this message is posted by the pipeline, the pipeline will
612 * select a new clock again when it goes to PLAYING. It might therefore
613 * be needed to set the pipeline to PAUSED and PLAYING again.
615 * Returns: (transfer full): The new clock lost message.
620 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
623 GstStructure *structure;
625 structure = gst_structure_id_new (GST_QUARK (MESSAGE_CLOCK_LOST),
626 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
627 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
633 * gst_message_new_new_clock:
634 * @src: (transfer none): The object originating the message.
635 * @clock: (transfer none): the new selected clock
637 * Create a new clock message. This message is posted whenever the
638 * pipeline selectes a new clock for the pipeline.
640 * Returns: (transfer full): The new new clock message.
645 gst_message_new_new_clock (GstObject * src, GstClock * clock)
648 GstStructure *structure;
650 structure = gst_structure_id_new (GST_QUARK (MESSAGE_NEW_CLOCK),
651 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
652 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
658 * gst_message_new_structure_change:
659 * @src: (transfer none): The object originating the message.
660 * @type: The change type.
661 * @owner: (transfer none): The owner element of @src.
662 * @busy: Whether the structure change is busy.
664 * Create a new structure change message. This message is posted when the
665 * structure of a pipeline is in the process of being changed, for example
666 * when pads are linked or unlinked.
668 * @src should be the sinkpad that unlinked or linked.
670 * Returns: (transfer full): the new structure change message.
677 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
678 GstElement * owner, gboolean busy)
681 GstStructure *structure;
683 g_return_val_if_fail (GST_IS_PAD (src), NULL);
684 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
685 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
687 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
688 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
689 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
690 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
692 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
699 * gst_message_new_segment_start:
700 * @src: (transfer none): The object originating the message.
701 * @format: The format of the position being played
702 * @position: The position of the segment being played
704 * Create a new segment message. This message is posted by elements that
705 * start playback of a segment as a result of a segment seek. This message
706 * is not received by the application but is used for maintenance reasons in
707 * container elements.
709 * Returns: (transfer full): the new segment start message.
714 gst_message_new_segment_start (GstObject * src, GstFormat format,
718 GstStructure *structure;
720 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_START),
721 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
722 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
723 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
729 * gst_message_new_segment_done:
730 * @src: (transfer none): the object originating the message.
731 * @format: The format of the position being done
732 * @position: The position of the segment being done
734 * Create a new segment done message. This message is posted by elements that
735 * finish playback of a segment as a result of a segment seek. This message
736 * is received by the application after all elements that posted a segment_start
737 * have posted the segment_done.
739 * Returns: (transfer full): the new segment done message.
744 gst_message_new_segment_done (GstObject * src, GstFormat format,
748 GstStructure *structure;
750 structure = gst_structure_id_new (GST_QUARK (MESSAGE_SEGMENT_DONE),
751 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
752 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
753 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
759 * gst_message_new_application:
760 * @src: (transfer none): the object originating the message.
761 * @structure: (transfer full): the structure for the message. The message
762 * will take ownership of the structure.
764 * Create a new application-typed message. GStreamer will never create these
765 * messages; they are a gift from us to you. Enjoy.
767 * Returns: (transfer full): The new application message.
772 gst_message_new_application (GstObject * src, GstStructure * structure)
774 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
778 * gst_message_new_element:
779 * @src: (transfer none): The object originating the message.
780 * @structure: (transfer full): The structure for the message. The message
781 * will take ownership of the structure.
783 * Create a new element-specific message. This is meant as a generic way of
784 * allowing one-way communication from an element to an application, for example
785 * "the firewire cable was unplugged". The format of the message should be
786 * documented in the element's documentation. The structure field can be NULL.
788 * Returns: (transfer full): The new element message.
793 gst_message_new_element (GstObject * src, GstStructure * structure)
795 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
799 * gst_message_new_duration:
800 * @src: (transfer none): The object originating the message.
801 * @format: The format of the duration
802 * @duration: The new duration
804 * Create a new duration message. This message is posted by elements that
805 * know the duration of a stream in a specific format. This message
806 * is received by bins and is used to calculate the total duration of a
807 * pipeline. Elements may post a duration message with a duration of
808 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
809 * cached duration should be discarded. The new duration can then be
810 * retrieved via a query.
812 * Returns: (transfer full): The new duration message.
817 gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration)
820 GstStructure *structure;
822 structure = gst_structure_id_new (GST_QUARK (MESSAGE_DURATION),
823 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
824 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
825 message = gst_message_new_custom (GST_MESSAGE_DURATION, src, structure);
831 * gst_message_new_async_start:
832 * @src: (transfer none): The object originating the message.
834 * This message is posted by elements when they start an ASYNC state change.
836 * Returns: (transfer full): The new async_start message.
841 gst_message_new_async_start (GstObject * src)
845 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
851 * gst_message_new_async_done:
852 * @src: (transfer none): The object originating the message.
853 * @reset_time: if the running_time should be reset
855 * The message is posted when elements completed an ASYNC state change.
856 * @reset_time is set to TRUE when the element requests a new running_time
857 * before going to PLAYING.
859 * Returns: (transfer full): The new async_done message.
864 gst_message_new_async_done (GstObject * src, gboolean reset_time)
867 GstStructure *structure;
869 structure = gst_structure_id_new (GST_QUARK (MESSAGE_ASYNC_DONE),
870 GST_QUARK (RESET_TIME), G_TYPE_BOOLEAN, reset_time, NULL);
871 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
877 * gst_message_new_latency:
878 * @src: (transfer none): The object originating the message.
880 * This message can be posted by elements when their latency requirements have
883 * Returns: (transfer full): The new latency message.
890 gst_message_new_latency (GstObject * src)
894 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
900 * gst_message_new_request_state:
901 * @src: (transfer none): the object originating the message.
902 * @state: The new requested state
904 * This message can be posted by elements when they want to have their state
905 * changed. A typical use case would be an audio server that wants to pause the
906 * pipeline because a higher priority stream is being played.
908 * Returns: (transfer full): the new requst state message.
915 gst_message_new_request_state (GstObject * src, GstState state)
918 GstStructure *structure;
920 structure = gst_structure_id_new (GST_QUARK (MESSAGE_REQUEST_STATE),
921 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
922 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
928 * gst_message_get_structure:
929 * @message: The #GstMessage.
931 * Access the structure of the message.
933 * Returns: (transfer none): The structure of the message. The structure is
934 * still owned by the message, which means that you should not free it and
935 * that the pointer becomes invalid when you free the message.
940 gst_message_get_structure (GstMessage * message)
942 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
944 return GST_MESSAGE_STRUCTURE (message);
948 * gst_message_has_name:
949 * @message: The #GstMessage.
950 * @name: name to check
952 * Checks if @message has the given @name. This function is usually used to
953 * check the name of a custom message.
955 * Returns: %TRUE if @name matches the name of the message structure.
960 gst_message_has_name (GstMessage * message, const gchar * name)
962 GstStructure *structure;
964 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
966 structure = GST_MESSAGE_STRUCTURE (message);
967 if (structure == NULL)
970 return gst_structure_has_name (structure, name);
974 * gst_message_parse_tag:
975 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
976 * @tag_list: (out callee-allocates): return location for the tag-list.
978 * Extracts the tag list from the GstMessage. The tag list returned in the
979 * output argument is a copy; the caller must free it when done.
981 * Typical usage of this function might be:
984 * switch (GST_MESSAGE_TYPE (msg)) {
985 * case GST_MESSAGE_TAG: {
986 * GstTagList *tags = NULL;
988 * gst_message_parse_tag (msg, &tags);
989 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
990 * handle_tags (tags);
991 * gst_tag_list_free (tags);
1002 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1006 g_return_if_fail (GST_IS_MESSAGE (message));
1007 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1008 g_return_if_fail (tag_list != NULL);
1010 ret = gst_structure_copy (GST_MESSAGE_STRUCTURE (message));
1011 gst_structure_remove_field (ret, "source-pad");
1013 *tag_list = (GstTagList *) ret;
1017 * gst_message_parse_buffering:
1018 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1019 * @percent: (out) (allow-none): Return location for the percent.
1021 * Extracts the buffering percent from the GstMessage. see also
1022 * gst_message_new_buffering().
1029 gst_message_parse_buffering (GstMessage * message, gint * percent)
1031 g_return_if_fail (GST_IS_MESSAGE (message));
1032 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1036 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1037 (message), GST_QUARK (BUFFER_PERCENT)));
1041 * gst_message_set_buffering_stats:
1042 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1043 * @mode: a buffering mode
1044 * @avg_in: the average input rate
1045 * @avg_out: the average output rate
1046 * @buffering_left: amount of buffering time left in milliseconds
1048 * Configures the buffering stats values in @message.
1053 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1054 gint avg_in, gint avg_out, gint64 buffering_left)
1056 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1058 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1059 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1060 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1061 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1062 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1066 * gst_message_parse_buffering_stats:
1067 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1068 * @mode: (out) (allow-none): a buffering mode, or NULL
1069 * @avg_in: (out) (allow-none): the average input rate, or NULL
1070 * @avg_out: (out) (allow-none): the average output rate, or NULL
1071 * @buffering_left: (out) (allow-none): amount of buffering time left in
1072 * milliseconds, or NULL
1074 * Extracts the buffering stats values from @message.
1079 gst_message_parse_buffering_stats (GstMessage * message,
1080 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1081 gint64 * buffering_left)
1083 GstStructure *structure;
1085 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1087 structure = GST_MESSAGE_STRUCTURE (message);
1089 *mode = (GstBufferingMode)
1090 g_value_get_enum (gst_structure_id_get_value (structure,
1091 GST_QUARK (BUFFERING_MODE)));
1093 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1094 GST_QUARK (AVG_IN_RATE)));
1096 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1097 GST_QUARK (AVG_OUT_RATE)));
1100 g_value_get_int64 (gst_structure_id_get_value (structure,
1101 GST_QUARK (BUFFERING_LEFT)));
1105 * gst_message_parse_state_changed:
1106 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1107 * @oldstate: (out) (allow-none): the previous state, or NULL
1108 * @newstate: (out) (allow-none): the new (current) state, or NULL
1109 * @pending: (out) (allow-none): the pending (target) state, or NULL
1111 * Extracts the old and new states from the GstMessage.
1113 * Typical usage of this function might be:
1116 * switch (GST_MESSAGE_TYPE (msg)) {
1117 * case GST_MESSAGE_STATE_CHANGED: {
1118 * GstState old_state, new_state;
1120 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1121 * g_print ("Element %s changed state from %s to %s.\n",
1122 * GST_OBJECT_NAME (msg->src),
1123 * gst_element_state_get_name (old_state),
1124 * gst_element_state_get_name (new_state));
1135 gst_message_parse_state_changed (GstMessage * message,
1136 GstState * oldstate, GstState * newstate, GstState * pending)
1138 GstStructure *structure;
1140 g_return_if_fail (GST_IS_MESSAGE (message));
1141 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1143 structure = GST_MESSAGE_STRUCTURE (message);
1145 *oldstate = (GstState)
1146 g_value_get_enum (gst_structure_id_get_value (structure,
1147 GST_QUARK (OLD_STATE)));
1149 *newstate = (GstState)
1150 g_value_get_enum (gst_structure_id_get_value (structure,
1151 GST_QUARK (NEW_STATE)));
1153 *pending = (GstState)
1154 g_value_get_enum (gst_structure_id_get_value (structure,
1155 GST_QUARK (PENDING_STATE)));
1159 * gst_message_parse_clock_provide:
1160 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1161 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1163 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1165 * Extracts the clock and ready flag from the GstMessage.
1166 * The clock object returned remains valid until the message is freed.
1171 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1174 const GValue *clock_gvalue;
1175 GstStructure *structure;
1177 g_return_if_fail (GST_IS_MESSAGE (message));
1178 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1180 structure = GST_MESSAGE_STRUCTURE (message);
1181 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1182 g_return_if_fail (clock_gvalue != NULL);
1183 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1187 g_value_get_boolean (gst_structure_id_get_value (structure,
1188 GST_QUARK (READY)));
1190 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1194 * gst_message_parse_clock_lost:
1195 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1196 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1198 * Extracts the lost clock from the GstMessage.
1199 * The clock object returned remains valid until the message is freed.
1204 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1206 const GValue *clock_gvalue;
1207 GstStructure *structure;
1209 g_return_if_fail (GST_IS_MESSAGE (message));
1210 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1212 structure = GST_MESSAGE_STRUCTURE (message);
1213 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1214 g_return_if_fail (clock_gvalue != NULL);
1215 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1218 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1222 * gst_message_parse_new_clock:
1223 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1224 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1227 * Extracts the new clock from the GstMessage.
1228 * The clock object returned remains valid until the message is freed.
1233 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1235 const GValue *clock_gvalue;
1236 GstStructure *structure;
1238 g_return_if_fail (GST_IS_MESSAGE (message));
1239 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1241 structure = GST_MESSAGE_STRUCTURE (message);
1242 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1243 g_return_if_fail (clock_gvalue != NULL);
1244 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1247 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1251 * gst_message_parse_structure_change:
1252 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1253 * @type: (out): A pointer to hold the change type
1254 * @owner: (out) (allow-none) (transfer none): The owner element of the
1256 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1257 * progress or has been completed
1259 * Extracts the change type and completion status from the GstMessage.
1266 gst_message_parse_structure_change (GstMessage * message,
1267 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1269 const GValue *owner_gvalue;
1270 GstStructure *structure;
1272 g_return_if_fail (GST_IS_MESSAGE (message));
1273 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1275 structure = GST_MESSAGE_STRUCTURE (message);
1276 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1277 g_return_if_fail (owner_gvalue != NULL);
1278 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1281 *type = (GstStructureChangeType)
1282 g_value_get_enum (gst_structure_id_get_value (structure,
1285 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1288 g_value_get_boolean (gst_structure_id_get_value (structure,
1293 * gst_message_parse_error:
1294 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1295 * @gerror: (out) (allow-none) (transfer full): location for the GError
1296 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1299 * Extracts the GError and debug string from the GstMessage. The values returned
1300 * in the output arguments are copies; the caller must free them when done.
1302 * Typical usage of this function might be:
1305 * switch (GST_MESSAGE_TYPE (msg)) {
1306 * case GST_MESSAGE_ERROR: {
1307 * GError *err = NULL;
1308 * gchar *dbg_info = NULL;
1310 * gst_message_parse_error (msg, &err, &dbg_info);
1311 * g_printerr ("ERROR from element %s: %s\n",
1312 * GST_OBJECT_NAME (msg->src), err->message);
1313 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1314 * g_error_free (err);
1315 * g_free (dbg_info);
1326 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1328 const GValue *error_gvalue;
1330 GstStructure *structure;
1332 g_return_if_fail (GST_IS_MESSAGE (message));
1333 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1335 structure = GST_MESSAGE_STRUCTURE (message);
1336 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1337 g_return_if_fail (error_gvalue != NULL);
1338 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1340 error_val = (GError *) g_value_get_boxed (error_gvalue);
1342 *gerror = g_error_copy (error_val);
1348 g_value_dup_string (gst_structure_id_get_value (structure,
1349 GST_QUARK (DEBUG)));
1353 * gst_message_parse_warning:
1354 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1355 * @gerror: (out) (allow-none) (transfer full): location for the GError
1356 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1359 * Extracts the GError and debug string from the GstMessage. The values returned
1360 * in the output arguments are copies; the caller must free them when done.
1365 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1368 const GValue *error_gvalue;
1370 GstStructure *structure;
1372 g_return_if_fail (GST_IS_MESSAGE (message));
1373 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1375 structure = GST_MESSAGE_STRUCTURE (message);
1376 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1377 g_return_if_fail (error_gvalue != NULL);
1378 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1380 error_val = (GError *) g_value_get_boxed (error_gvalue);
1382 *gerror = g_error_copy (error_val);
1388 g_value_dup_string (gst_structure_id_get_value (structure,
1389 GST_QUARK (DEBUG)));
1393 * gst_message_parse_info:
1394 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1395 * @gerror: (out) (allow-none) (transfer full): location for the GError
1396 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1399 * Extracts the GError and debug string from the GstMessage. The values returned
1400 * in the output arguments are copies; the caller must free them when done.
1407 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1409 const GValue *error_gvalue;
1411 GstStructure *structure;
1413 g_return_if_fail (GST_IS_MESSAGE (message));
1414 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1416 structure = GST_MESSAGE_STRUCTURE (message);
1417 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1418 g_return_if_fail (error_gvalue != NULL);
1419 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == GST_TYPE_G_ERROR);
1421 error_val = (GError *) g_value_get_boxed (error_gvalue);
1423 *gerror = g_error_copy (error_val);
1429 g_value_dup_string (gst_structure_id_get_value (structure,
1430 GST_QUARK (DEBUG)));
1434 * gst_message_parse_segment_start:
1435 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1436 * @format: (out): Result location for the format, or NULL
1437 * @position: (out): Result location for the position, or NULL
1439 * Extracts the position and format from the segment start message.
1444 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1447 GstStructure *structure;
1449 g_return_if_fail (GST_IS_MESSAGE (message));
1450 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1452 structure = GST_MESSAGE_STRUCTURE (message);
1454 *format = (GstFormat)
1455 g_value_get_enum (gst_structure_id_get_value (structure,
1456 GST_QUARK (FORMAT)));
1459 g_value_get_int64 (gst_structure_id_get_value (structure,
1460 GST_QUARK (POSITION)));
1464 * gst_message_parse_segment_done:
1465 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1466 * @format: (out): Result location for the format, or NULL
1467 * @position: (out): Result location for the position, or NULL
1469 * Extracts the position and format from the segment start message.
1474 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1477 GstStructure *structure;
1479 g_return_if_fail (GST_IS_MESSAGE (message));
1480 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1482 structure = GST_MESSAGE_STRUCTURE (message);
1484 *format = (GstFormat)
1485 g_value_get_enum (gst_structure_id_get_value (structure,
1486 GST_QUARK (FORMAT)));
1489 g_value_get_int64 (gst_structure_id_get_value (structure,
1490 GST_QUARK (POSITION)));
1494 * gst_message_parse_duration:
1495 * @message: A valid #GstMessage of type GST_MESSAGE_DURATION.
1496 * @format: (out): Result location for the format, or NULL
1497 * @duration: (out): Result location for the duration, or NULL
1499 * Extracts the duration and format from the duration message. The duration
1500 * might be GST_CLOCK_TIME_NONE, which indicates that the duration has
1501 * changed. Applications should always use a query to retrieve the duration
1507 gst_message_parse_duration (GstMessage * message, GstFormat * format,
1510 GstStructure *structure;
1512 g_return_if_fail (GST_IS_MESSAGE (message));
1513 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DURATION);
1515 structure = GST_MESSAGE_STRUCTURE (message);
1517 *format = (GstFormat)
1518 g_value_get_enum (gst_structure_id_get_value (structure,
1519 GST_QUARK (FORMAT)));
1522 g_value_get_int64 (gst_structure_id_get_value (structure,
1523 GST_QUARK (DURATION)));
1527 * gst_message_parse_async_done:
1528 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1529 * @reset_time: (out): Result location for the reset_time or NULL
1531 * Extract the reset_time from the async_done message.
1536 gst_message_parse_async_done (GstMessage * message, gboolean * reset_time)
1538 GstStructure *structure;
1540 g_return_if_fail (GST_IS_MESSAGE (message));
1541 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1543 structure = GST_MESSAGE_STRUCTURE (message);
1546 g_value_get_boolean (gst_structure_id_get_value (structure,
1547 GST_QUARK (RESET_TIME)));
1551 * gst_message_parse_request_state:
1552 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1553 * @state: (out): Result location for the requested state or NULL
1555 * Extract the requested state from the request_state message.
1562 gst_message_parse_request_state (GstMessage * message, GstState * state)
1564 GstStructure *structure;
1566 g_return_if_fail (GST_IS_MESSAGE (message));
1567 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1569 structure = GST_MESSAGE_STRUCTURE (message);
1572 g_value_get_enum (gst_structure_id_get_value (structure,
1573 GST_QUARK (NEW_STATE)));
1577 * gst_message_new_stream_status:
1578 * @src: The object originating the message.
1579 * @type: The stream status type.
1580 * @owner: (transfer none): the owner element of @src.
1582 * Create a new stream status message. This message is posted when a streaming
1583 * thread is created/destroyed or when the state changed.
1585 * Returns: (transfer full): the new stream status message.
1592 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1595 GstMessage *message;
1596 GstStructure *structure;
1598 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STREAM_STATUS),
1599 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1600 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1601 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1607 * gst_message_parse_stream_status:
1608 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1609 * @type: (out): A pointer to hold the status type
1610 * @owner: (out) (transfer none): The owner element of the message source
1612 * Extracts the stream status type and owner the GstMessage. The returned
1613 * owner remains valid for as long as the reference to @message is valid and
1614 * should thus not be unreffed.
1621 gst_message_parse_stream_status (GstMessage * message,
1622 GstStreamStatusType * type, GstElement ** owner)
1624 const GValue *owner_gvalue;
1625 GstStructure *structure;
1627 g_return_if_fail (GST_IS_MESSAGE (message));
1628 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1630 structure = GST_MESSAGE_STRUCTURE (message);
1631 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1632 g_return_if_fail (owner_gvalue != NULL);
1635 *type = (GstStreamStatusType)
1636 g_value_get_enum (gst_structure_id_get_value (structure,
1639 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1643 * gst_message_set_stream_status_object:
1644 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1645 * @object: the object controlling the streaming
1647 * Configures the object handling the streaming thread. This is usually a
1648 * GstTask object but other objects might be added in the future.
1653 gst_message_set_stream_status_object (GstMessage * message,
1654 const GValue * object)
1656 GstStructure *structure;
1658 g_return_if_fail (GST_IS_MESSAGE (message));
1659 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1661 structure = GST_MESSAGE_STRUCTURE (message);
1662 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1666 * gst_message_get_stream_status_object:
1667 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1669 * Extracts the object managing the streaming thread from @message.
1671 * Returns: a GValue containing the object that manages the streaming thread.
1672 * This object is usually of type GstTask but other types can be added in the
1673 * future. The object remains valid as long as @message is valid.
1678 gst_message_get_stream_status_object (GstMessage * message)
1680 const GValue *result;
1681 GstStructure *structure;
1683 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1684 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1687 structure = GST_MESSAGE_STRUCTURE (message);
1688 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1694 * gst_message_new_step_done:
1695 * @src: The object originating the message.
1696 * @format: the format of @amount
1697 * @amount: the amount of stepped data
1698 * @rate: the rate of the stepped amount
1699 * @flush: is this an flushing step
1700 * @intermediate: is this an intermediate step
1701 * @duration: the duration of the data
1702 * @eos: the step caused EOS
1704 * This message is posted by elements when they complete a part, when @intermediate set
1705 * to TRUE, or a complete step operation.
1707 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1708 * @amount of media in format @format.
1710 * Returns: (transfer full): the new step_done message.
1717 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1718 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1721 GstMessage *message;
1722 GstStructure *structure;
1724 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_DONE),
1725 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1726 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1727 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1728 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1729 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1730 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1731 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1732 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1738 * gst_message_parse_step_done:
1739 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1740 * @format: (out) (allow-none): result location for the format
1741 * @amount: (out) (allow-none): result location for the amount
1742 * @rate: (out) (allow-none): result location for the rate
1743 * @flush: (out) (allow-none): result location for the flush flag
1744 * @intermediate: (out) (allow-none): result location for the intermediate flag
1745 * @duration: (out) (allow-none): result location for the duration
1746 * @eos: (out) (allow-none): result location for the EOS flag
1748 * Extract the values the step_done message.
1755 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1756 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1757 guint64 * duration, gboolean * eos)
1759 GstStructure *structure;
1761 g_return_if_fail (GST_IS_MESSAGE (message));
1762 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1764 structure = GST_MESSAGE_STRUCTURE (message);
1765 gst_structure_id_get (structure,
1766 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1767 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1768 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1769 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1770 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1771 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1772 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1776 * gst_message_new_step_start:
1777 * @src: The object originating the message.
1778 * @active: if the step is active or queued
1779 * @format: the format of @amount
1780 * @amount: the amount of stepped data
1781 * @rate: the rate of the stepped amount
1782 * @flush: is this an flushing step
1783 * @intermediate: is this an intermediate step
1785 * This message is posted by elements when they accept or activate a new step
1786 * event for @amount in @format.
1788 * @active is set to FALSE when the element accepted the new step event and has
1789 * queued it for execution in the streaming threads.
1791 * @active is set to TRUE when the element has activated the step operation and
1792 * is now ready to start executing the step in the streaming thread. After this
1793 * message is emited, the application can queue a new step operation in the
1796 * Returns: (transfer full): The new step_start message.
1803 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1804 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1806 GstMessage *message;
1807 GstStructure *structure;
1809 structure = gst_structure_id_new (GST_QUARK (MESSAGE_STEP_START),
1810 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1811 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1812 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1813 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1814 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1815 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1816 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1822 * gst_message_parse_step_start:
1823 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1824 * @active: (out) (allow-none): result location for the active flag
1825 * @format: (out) (allow-none): result location for the format
1826 * @amount: (out) (allow-none): result location for the amount
1827 * @rate: (out) (allow-none): result location for the rate
1828 * @flush: (out) (allow-none): result location for the flush flag
1829 * @intermediate: (out) (allow-none): result location for the intermediate flag
1831 * Extract the values from step_start message.
1838 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1839 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1840 gboolean * intermediate)
1842 GstStructure *structure;
1844 g_return_if_fail (GST_IS_MESSAGE (message));
1845 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1847 structure = GST_MESSAGE_STRUCTURE (message);
1848 gst_structure_id_get (structure,
1849 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1850 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1851 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1852 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1853 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1854 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1858 * gst_message_new_qos:
1859 * @src: The object originating the message.
1860 * @live: if the message was generated by a live element
1861 * @running_time: the running time of the buffer that generated the message
1862 * @stream_time: the stream time of the buffer that generated the message
1863 * @timestamp: the timestamps of the buffer that generated the message
1864 * @duration: the duration of the buffer that generated the message
1866 * A QOS message is posted on the bus whenever an element decides to drop a
1867 * buffer because of QoS reasons or whenever it changes its processing strategy
1868 * because of QoS reasons (quality adjustments such as processing at lower
1871 * This message can be posted by an element that performs synchronisation against the
1872 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1873 * events received from a downstream element (!live).
1875 * @running_time, @stream_time, @timestamp, @duration should be set to the
1876 * respective running-time, stream-time, timestamp and duration of the (dropped)
1877 * buffer that generated the QoS event. Values can be left to
1878 * GST_CLOCK_TIME_NONE when unknown.
1880 * Returns: (transfer full): The new qos message.
1887 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1888 guint64 stream_time, guint64 timestamp, guint64 duration)
1890 GstMessage *message;
1891 GstStructure *structure;
1893 structure = gst_structure_id_new (GST_QUARK (MESSAGE_QOS),
1894 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1895 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1896 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1897 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1898 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1899 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1900 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1901 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1902 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1903 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1904 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1905 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1911 * gst_message_set_qos_values:
1912 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1913 * @jitter: The difference of the running-time against the deadline.
1914 * @proportion: Long term prediction of the ideal rate relative to normal rate
1915 * to get optimal quality.
1916 * @quality: An element dependent integer value that specifies the current
1917 * quality level of the element. The default maximum quality is 1000000.
1919 * Set the QoS values that have been calculated/analysed from the QoS data
1926 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1927 gdouble proportion, gint quality)
1929 GstStructure *structure;
1931 g_return_if_fail (GST_IS_MESSAGE (message));
1932 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1934 structure = GST_MESSAGE_STRUCTURE (message);
1935 gst_structure_id_set (structure,
1936 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1937 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1938 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1942 * gst_message_set_qos_stats:
1943 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1944 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1945 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1946 * will likely use GST_FORMAT_DEFAULT (samples).
1947 * @processed: Total number of units correctly processed since the last state
1948 * change to READY or a flushing operation.
1949 * @dropped: Total number of units dropped since the last state change to READY
1950 * or a flushing operation.
1952 * Set the QoS stats representing the history of the current continuous pipeline
1955 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1956 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1963 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1964 guint64 processed, guint64 dropped)
1966 GstStructure *structure;
1968 g_return_if_fail (GST_IS_MESSAGE (message));
1969 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1971 structure = GST_MESSAGE_STRUCTURE (message);
1972 gst_structure_id_set (structure,
1973 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1974 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1975 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1979 * gst_message_parse_qos:
1980 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1981 * @live: (out) (allow-none): if the message was generated by a live element
1982 * @running_time: (out) (allow-none): the running time of the buffer that
1983 * generated the message
1984 * @stream_time: (out) (allow-none): the stream time of the buffer that
1985 * generated the message
1986 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1987 * generated the message
1988 * @duration: (out) (allow-none): the duration of the buffer that
1989 * generated the message
1991 * Extract the timestamps and live status from the QoS message.
1993 * The returned values give the running_time, stream_time, timestamp and
1994 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2002 gst_message_parse_qos (GstMessage * message, gboolean * live,
2003 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2006 GstStructure *structure;
2008 g_return_if_fail (GST_IS_MESSAGE (message));
2009 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2011 structure = GST_MESSAGE_STRUCTURE (message);
2012 gst_structure_id_get (structure,
2013 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2014 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2015 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2016 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2017 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2021 * gst_message_parse_qos_values:
2022 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2023 * @jitter: (out) (allow-none): The difference of the running-time against
2025 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2026 * relative to normal rate to get optimal quality.
2027 * @quality: (out) (allow-none): An element dependent integer value that
2028 * specifies the current quality level of the element. The default
2029 * maximum quality is 1000000.
2031 * Extract the QoS values that have been calculated/analysed from the QoS data
2038 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2039 gdouble * proportion, gint * quality)
2041 GstStructure *structure;
2043 g_return_if_fail (GST_IS_MESSAGE (message));
2044 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2046 structure = GST_MESSAGE_STRUCTURE (message);
2047 gst_structure_id_get (structure,
2048 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2049 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2050 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2054 * gst_message_parse_qos_stats:
2055 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2056 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2057 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2058 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2060 * @processed: (out) (allow-none): Total number of units correctly processed
2061 * since the last state change to READY or a flushing operation.
2062 * @dropped: (out) (allow-none): Total number of units dropped since the last
2063 * state change to READY or a flushing operation.
2065 * Extract the QoS stats representing the history of the current continuous
2066 * pipeline playback period.
2068 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2069 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2076 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2077 guint64 * processed, guint64 * dropped)
2079 GstStructure *structure;
2081 g_return_if_fail (GST_IS_MESSAGE (message));
2082 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2084 structure = GST_MESSAGE_STRUCTURE (message);
2085 gst_structure_id_get (structure,
2086 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2087 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2088 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2092 * gst_message_new_progress:
2093 * @src: The object originating the message.
2094 * @type: a #GstProgressType
2095 * @code: a progress code
2096 * @text: free, user visible text describing the progress
2098 * Progress messages are posted by elements when they use an asynchronous task
2099 * to perform actions triggered by a state change.
2101 * @code contains a well defined string describing the action.
2102 * @test should contain a user visible string detailing the current action.
2104 * Returns: (transfer full): The new qos message.
2109 gst_message_new_progress (GstObject * src, GstProgressType type,
2110 const gchar * code, const gchar * text)
2112 GstMessage *message;
2113 GstStructure *structure;
2114 gint percent = 100, timeout = -1;
2116 g_return_val_if_fail (code != NULL, NULL);
2117 g_return_val_if_fail (text != NULL, NULL);
2119 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2122 structure = gst_structure_id_new (GST_QUARK (MESSAGE_PROGRESS),
2123 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2124 GST_QUARK (CODE), G_TYPE_STRING, code,
2125 GST_QUARK (TEXT), G_TYPE_STRING, text,
2126 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2127 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2128 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2134 * gst_message_parse_progress:
2135 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2136 * @type: (out) (allow-none): location for the type
2137 * @code: (out) (allow-none) (transfer full): location for the code
2138 * @text: (out) (allow-none) (transfer full): location for the text
2140 * Parses the progress @type, @code and @text.
2145 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2146 gchar ** code, gchar ** text)
2148 GstStructure *structure;
2150 g_return_if_fail (GST_IS_MESSAGE (message));
2151 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2153 structure = GST_MESSAGE_STRUCTURE (message);
2154 gst_structure_id_get (structure,
2155 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2156 GST_QUARK (CODE), G_TYPE_STRING, code,
2157 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);