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;
188 if (message->lock.p) {
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_init (GstMessageImpl * message, gsize size, GstMessageType type,
208 _gst_message_copy (GstMessage * message)
210 GstMessageImpl *copy;
211 GstStructure *structure;
213 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
214 GST_MESSAGE_TYPE_NAME (message),
215 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
217 copy = g_slice_new0 (GstMessageImpl);
219 gst_message_init (copy, sizeof (GstMessageImpl), GST_MESSAGE_TYPE (message),
220 GST_MESSAGE_SRC (message));
222 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
223 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
225 structure = GST_MESSAGE_STRUCTURE (message);
227 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
228 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
229 ©->message.mini_object.refcount);
231 GST_MESSAGE_STRUCTURE (copy) = NULL;
234 return GST_MESSAGE_CAST (copy);
238 gst_message_init (GstMessageImpl * message, gsize size, GstMessageType type,
241 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), _gst_message_type,
244 message->message.mini_object.copy =
245 (GstMiniObjectCopyFunction) _gst_message_copy;
246 message->message.mini_object.free =
247 (GstMiniObjectFreeFunction) _gst_message_free;
249 GST_MESSAGE_TYPE (message) = type;
251 gst_object_ref (src);
252 GST_MESSAGE_SRC (message) = src;
253 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
254 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
259 * gst_message_new_custom:
260 * @type: The #GstMessageType to distinguish messages
261 * @src: The object originating the message.
262 * @structure: (transfer full): the structure for the message. The message
263 * will take ownership of the structure.
265 * Create a new custom-typed message. This can be used for anything not
266 * handled by other message-specific functions to pass a message to the
267 * app. The structure field can be NULL.
269 * Returns: (transfer full): The new message.
274 gst_message_new_custom (GstMessageType type, GstObject * src,
275 GstStructure * structure)
277 GstMessageImpl *message;
279 message = g_slice_new0 (GstMessageImpl);
281 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
282 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
283 gst_message_type_get_name (type));
286 /* structure must not have a parent */
287 if (!gst_structure_set_parent_refcount (structure,
288 &message->message.mini_object.refcount))
291 gst_message_init (message, sizeof (GstMessageImpl), type, src);
293 GST_MESSAGE_STRUCTURE (message) = structure;
295 return GST_MESSAGE_CAST (message);
300 g_slice_free1 (GST_MINI_OBJECT_SIZE (message), message);
301 g_warning ("structure is already owned by another object");
307 * gst_message_get_seqnum:
308 * @message: A #GstMessage.
310 * Retrieve the sequence number of a message.
312 * Messages have ever-incrementing sequence numbers, which may also be set
313 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
314 * to indicate that a message corresponds to some other set of messages or
315 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
316 * is considered good practice to make this correspondence when possible, though
317 * it is not required.
319 * Note that events and messages share the same sequence number incrementor;
320 * two events or messages will never have the same sequence number unless
321 * that correspondence was made explicitly.
323 * Returns: The message's sequence number.
330 gst_message_get_seqnum (GstMessage * message)
332 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
334 return GST_MESSAGE_SEQNUM (message);
338 * gst_message_set_seqnum:
339 * @message: A #GstMessage.
340 * @seqnum: A sequence number.
342 * Set the sequence number of a message.
344 * This function might be called by the creator of a message to indicate that
345 * the message relates to other messages or events. See gst_message_get_seqnum()
346 * for more information.
353 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
355 g_return_if_fail (GST_IS_MESSAGE (message));
357 GST_MESSAGE_SEQNUM (message) = seqnum;
361 * gst_message_new_eos:
362 * @src: (transfer none): The object originating the message.
364 * Create a new eos message. This message is generated and posted in
365 * the sink elements of a GstBin. The bin will only forward the EOS
366 * message to the application if all sinks have posted an EOS message.
368 * Returns: (transfer full): The new eos message.
373 gst_message_new_eos (GstObject * src)
377 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
383 * gst_message_new_error:
384 * @src: (transfer none): The object originating the message.
385 * @error: (transfer none): The GError for this message.
386 * @debug: A debugging string.
388 * Create a new error message. The message will copy @error and
389 * @debug. This message is posted by element when a fatal event
390 * occured. The pipeline will probably (partially) stop. The application
391 * receiving this message should stop the pipeline.
393 * Returns: (transfer full): the new error message.
398 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
401 GstStructure *structure;
403 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
404 GST_QUARK (GERROR), G_TYPE_ERROR, error,
405 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
406 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
412 * gst_message_new_warning:
413 * @src: (transfer none): The object originating the message.
414 * @error: (transfer none): The GError for this message.
415 * @debug: A debugging string.
417 * Create a new warning message. The message will make copies of @error and
420 * Returns: (transfer full): The new warning message.
425 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
428 GstStructure *structure;
430 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
431 GST_QUARK (GERROR), G_TYPE_ERROR, error,
432 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
433 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
439 * gst_message_new_info:
440 * @src: (transfer none): The object originating the message.
441 * @error: (transfer none): The GError for this message.
442 * @debug: A debugging string.
444 * Create a new info message. The message will make copies of @error and
449 * Returns: (transfer full): the new info message.
454 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
457 GstStructure *structure;
459 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
460 GST_QUARK (GERROR), G_TYPE_ERROR, error,
461 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
462 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
468 * gst_message_new_tag:
469 * @src: (transfer none): The object originating the message.
470 * @tag_list: (transfer full): the tag list for the message.
472 * Create a new tag message. The message will take ownership of the tag list.
473 * The message is posted by elements that discovered a new taglist.
475 * Returns: (transfer full): the new tag message.
480 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
484 g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
487 gst_message_new_custom (GST_MESSAGE_TAG, src, (GstStructure *) tag_list);
493 * gst_message_new_buffering:
494 * @src: (transfer none): The object originating the message.
495 * @percent: The buffering percent
497 * Create a new buffering message. This message can be posted by an element that
498 * needs to buffer data before it can continue processing. @percent should be a
499 * value between 0 and 100. A value of 100 means that the buffering completed.
501 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
502 * @percent is 100, the application can set the pipeline (back) to PLAYING.
503 * The application must be prepared to receive BUFFERING messages in the
504 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
505 * message with @percent set to 100, which can happen after the pipeline
506 * completed prerolling.
510 * Returns: (transfer full): The new buffering message.
515 gst_message_new_buffering (GstObject * src, gint percent)
518 GstStructure *structure;
520 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
522 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
523 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
524 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
525 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
526 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
527 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, G_GINT64_CONSTANT (-1),
528 GST_QUARK (ESTIMATED_TOTAL), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
529 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
535 * gst_message_new_state_changed:
536 * @src: (transfer none): the object originating the message
537 * @oldstate: the previous state
538 * @newstate: the new (current) state
539 * @pending: the pending (target) state
541 * Create a state change message. This message is posted whenever an element
544 * Returns: (transfer full): the new state change message.
549 gst_message_new_state_changed (GstObject * src,
550 GstState oldstate, GstState newstate, GstState pending)
553 GstStructure *structure;
555 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE),
556 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
557 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
558 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
559 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
565 * gst_message_new_state_dirty:
566 * @src: (transfer none): the object originating the message
568 * Create a state dirty message. This message is posted whenever an element
569 * changed its state asynchronously and is used internally to update the
570 * states of container objects.
572 * Returns: (transfer full): the new state dirty message.
577 gst_message_new_state_dirty (GstObject * src)
581 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
587 * gst_message_new_clock_provide:
588 * @src: (transfer none): the object originating the message.
589 * @clock: (transfer none): the clock it provides
590 * @ready: TRUE if the sender can provide a clock
592 * Create a clock provide message. This message is posted whenever an
593 * element is ready to provide a clock or lost its ability to provide
594 * a clock (maybe because it paused or became EOS).
596 * This message is mainly used internally to manage the clock
599 * Returns: (transfer full): the new provide clock message.
604 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
608 GstStructure *structure;
610 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
611 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
612 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
613 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
619 * gst_message_new_clock_lost:
620 * @src: (transfer none): the object originating the message.
621 * @clock: (transfer none): the clock that was lost
623 * Create a clock lost message. This message is posted whenever the
624 * clock is not valid anymore.
626 * If this message is posted by the pipeline, the pipeline will
627 * select a new clock again when it goes to PLAYING. It might therefore
628 * be needed to set the pipeline to PAUSED and PLAYING again.
630 * Returns: (transfer full): The new clock lost message.
635 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
638 GstStructure *structure;
640 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
641 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
642 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
648 * gst_message_new_new_clock:
649 * @src: (transfer none): The object originating the message.
650 * @clock: (transfer none): the new selected clock
652 * Create a new clock message. This message is posted whenever the
653 * pipeline selectes a new clock for the pipeline.
655 * Returns: (transfer full): The new new clock message.
660 gst_message_new_new_clock (GstObject * src, GstClock * clock)
663 GstStructure *structure;
665 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
666 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
667 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
673 * gst_message_new_structure_change:
674 * @src: (transfer none): The object originating the message.
675 * @type: The change type.
676 * @owner: (transfer none): The owner element of @src.
677 * @busy: Whether the structure change is busy.
679 * Create a new structure change message. This message is posted when the
680 * structure of a pipeline is in the process of being changed, for example
681 * when pads are linked or unlinked.
683 * @src should be the sinkpad that unlinked or linked.
685 * Returns: (transfer full): the new structure change message.
692 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
693 GstElement * owner, gboolean busy)
696 GstStructure *structure;
698 g_return_val_if_fail (GST_IS_PAD (src), NULL);
699 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
700 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
702 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
703 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
704 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
705 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
707 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
714 * gst_message_new_segment_start:
715 * @src: (transfer none): The object originating the message.
716 * @format: The format of the position being played
717 * @position: The position of the segment being played
719 * Create a new segment message. This message is posted by elements that
720 * start playback of a segment as a result of a segment seek. This message
721 * is not received by the application but is used for maintenance reasons in
722 * container elements.
724 * Returns: (transfer full): the new segment start message.
729 gst_message_new_segment_start (GstObject * src, GstFormat format,
733 GstStructure *structure;
735 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
736 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
737 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
738 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
744 * gst_message_new_segment_done:
745 * @src: (transfer none): the object originating the message.
746 * @format: The format of the position being done
747 * @position: The position of the segment being done
749 * Create a new segment done message. This message is posted by elements that
750 * finish playback of a segment as a result of a segment seek. This message
751 * is received by the application after all elements that posted a segment_start
752 * have posted the segment_done.
754 * Returns: (transfer full): the new segment done message.
759 gst_message_new_segment_done (GstObject * src, GstFormat format,
763 GstStructure *structure;
765 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
766 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
767 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
768 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
774 * gst_message_new_application:
775 * @src: (transfer none): the object originating the message.
776 * @structure: (transfer full): the structure for the message. The message
777 * will take ownership of the structure.
779 * Create a new application-typed message. GStreamer will never create these
780 * messages; they are a gift from us to you. Enjoy.
782 * Returns: (transfer full): The new application message.
787 gst_message_new_application (GstObject * src, GstStructure * structure)
789 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
793 * gst_message_new_element:
794 * @src: (transfer none): The object originating the message.
795 * @structure: (transfer full): The structure for the message. The message
796 * will take ownership of the structure.
798 * Create a new element-specific message. This is meant as a generic way of
799 * allowing one-way communication from an element to an application, for example
800 * "the firewire cable was unplugged". The format of the message should be
801 * documented in the element's documentation. The structure field can be NULL.
803 * Returns: (transfer full): The new element message.
808 gst_message_new_element (GstObject * src, GstStructure * structure)
810 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
814 * gst_message_new_duration:
815 * @src: (transfer none): The object originating the message.
816 * @format: The format of the duration
817 * @duration: The new duration
819 * Create a new duration message. This message is posted by elements that
820 * know the duration of a stream in a specific format. This message
821 * is received by bins and is used to calculate the total duration of a
822 * pipeline. Elements may post a duration message with a duration of
823 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
824 * cached duration should be discarded. The new duration can then be
825 * retrieved via a query.
827 * Returns: (transfer full): The new duration message.
832 gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration)
835 GstStructure *structure;
837 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DURATION),
838 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
839 GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
840 message = gst_message_new_custom (GST_MESSAGE_DURATION, src, structure);
846 * gst_message_new_async_start:
847 * @src: (transfer none): The object originating the message.
849 * This message is posted by elements when they start an ASYNC state change.
851 * Returns: (transfer full): The new async_start message.
856 gst_message_new_async_start (GstObject * src)
860 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
866 * gst_message_new_async_done:
867 * @src: (transfer none): The object originating the message.
868 * @reset_time: if the running_time should be reset
870 * The message is posted when elements completed an ASYNC state change.
871 * @reset_time is set to TRUE when the element requests a new running_time
872 * before going to PLAYING.
874 * Returns: (transfer full): The new async_done message.
879 gst_message_new_async_done (GstObject * src, gboolean reset_time)
882 GstStructure *structure;
884 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
885 GST_QUARK (RESET_TIME), G_TYPE_BOOLEAN, reset_time, NULL);
886 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
892 * gst_message_new_latency:
893 * @src: (transfer none): The object originating the message.
895 * This message can be posted by elements when their latency requirements have
898 * Returns: (transfer full): The new latency message.
905 gst_message_new_latency (GstObject * src)
909 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
915 * gst_message_new_request_state:
916 * @src: (transfer none): the object originating the message.
917 * @state: The new requested state
919 * This message can be posted by elements when they want to have their state
920 * changed. A typical use case would be an audio server that wants to pause the
921 * pipeline because a higher priority stream is being played.
923 * Returns: (transfer full): the new requst state message.
930 gst_message_new_request_state (GstObject * src, GstState state)
933 GstStructure *structure;
935 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
936 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
937 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
943 * gst_message_get_structure:
944 * @message: The #GstMessage.
946 * Access the structure of the message.
948 * Returns: (transfer none): The structure of the message. The structure is
949 * still owned by the message, which means that you should not free it and
950 * that the pointer becomes invalid when you free the message.
955 gst_message_get_structure (GstMessage * message)
957 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
959 return GST_MESSAGE_STRUCTURE (message);
963 * gst_message_has_name:
964 * @message: The #GstMessage.
965 * @name: name to check
967 * Checks if @message has the given @name. This function is usually used to
968 * check the name of a custom message.
970 * Returns: %TRUE if @name matches the name of the message structure.
975 gst_message_has_name (GstMessage * message, const gchar * name)
977 GstStructure *structure;
979 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
981 structure = GST_MESSAGE_STRUCTURE (message);
982 if (structure == NULL)
985 return gst_structure_has_name (structure, name);
989 * gst_message_parse_tag:
990 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
991 * @tag_list: (out callee-allocates): return location for the tag-list.
993 * Extracts the tag list from the GstMessage. The tag list returned in the
994 * output argument is a copy; the caller must free it when done.
996 * Typical usage of this function might be:
999 * switch (GST_MESSAGE_TYPE (msg)) {
1000 * case GST_MESSAGE_TAG: {
1001 * GstTagList *tags = NULL;
1003 * gst_message_parse_tag (msg, &tags);
1004 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1005 * handle_tags (tags);
1006 * gst_tag_list_free (tags);
1017 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1021 g_return_if_fail (GST_IS_MESSAGE (message));
1022 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1023 g_return_if_fail (tag_list != NULL);
1025 ret = gst_structure_copy (GST_MESSAGE_STRUCTURE (message));
1026 gst_structure_remove_field (ret, "source-pad");
1028 *tag_list = (GstTagList *) ret;
1032 * gst_message_parse_buffering:
1033 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1034 * @percent: (out) (allow-none): Return location for the percent.
1036 * Extracts the buffering percent from the GstMessage. see also
1037 * gst_message_new_buffering().
1044 gst_message_parse_buffering (GstMessage * message, gint * percent)
1046 g_return_if_fail (GST_IS_MESSAGE (message));
1047 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1051 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1052 (message), GST_QUARK (BUFFER_PERCENT)));
1056 * gst_message_set_buffering_stats:
1057 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1058 * @mode: a buffering mode
1059 * @avg_in: the average input rate
1060 * @avg_out: the average output rate
1061 * @buffering_left: amount of buffering time left in milliseconds
1063 * Configures the buffering stats values in @message.
1068 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1069 gint avg_in, gint avg_out, gint64 buffering_left)
1071 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1073 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1074 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1075 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1076 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1077 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1081 * gst_message_parse_buffering_stats:
1082 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1083 * @mode: (out) (allow-none): a buffering mode, or NULL
1084 * @avg_in: (out) (allow-none): the average input rate, or NULL
1085 * @avg_out: (out) (allow-none): the average output rate, or NULL
1086 * @buffering_left: (out) (allow-none): amount of buffering time left in
1087 * milliseconds, or NULL
1089 * Extracts the buffering stats values from @message.
1094 gst_message_parse_buffering_stats (GstMessage * message,
1095 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1096 gint64 * buffering_left)
1098 GstStructure *structure;
1100 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1102 structure = GST_MESSAGE_STRUCTURE (message);
1104 *mode = (GstBufferingMode)
1105 g_value_get_enum (gst_structure_id_get_value (structure,
1106 GST_QUARK (BUFFERING_MODE)));
1108 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1109 GST_QUARK (AVG_IN_RATE)));
1111 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1112 GST_QUARK (AVG_OUT_RATE)));
1115 g_value_get_int64 (gst_structure_id_get_value (structure,
1116 GST_QUARK (BUFFERING_LEFT)));
1120 * gst_message_parse_state_changed:
1121 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1122 * @oldstate: (out) (allow-none): the previous state, or NULL
1123 * @newstate: (out) (allow-none): the new (current) state, or NULL
1124 * @pending: (out) (allow-none): the pending (target) state, or NULL
1126 * Extracts the old and new states from the GstMessage.
1128 * Typical usage of this function might be:
1131 * switch (GST_MESSAGE_TYPE (msg)) {
1132 * case GST_MESSAGE_STATE_CHANGED: {
1133 * GstState old_state, new_state;
1135 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1136 * g_print ("Element %s changed state from %s to %s.\n",
1137 * GST_OBJECT_NAME (msg->src),
1138 * gst_element_state_get_name (old_state),
1139 * gst_element_state_get_name (new_state));
1150 gst_message_parse_state_changed (GstMessage * message,
1151 GstState * oldstate, GstState * newstate, GstState * pending)
1153 GstStructure *structure;
1155 g_return_if_fail (GST_IS_MESSAGE (message));
1156 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1158 structure = GST_MESSAGE_STRUCTURE (message);
1160 *oldstate = (GstState)
1161 g_value_get_enum (gst_structure_id_get_value (structure,
1162 GST_QUARK (OLD_STATE)));
1164 *newstate = (GstState)
1165 g_value_get_enum (gst_structure_id_get_value (structure,
1166 GST_QUARK (NEW_STATE)));
1168 *pending = (GstState)
1169 g_value_get_enum (gst_structure_id_get_value (structure,
1170 GST_QUARK (PENDING_STATE)));
1174 * gst_message_parse_clock_provide:
1175 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1176 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1178 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1180 * Extracts the clock and ready flag from the GstMessage.
1181 * The clock object returned remains valid until the message is freed.
1186 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1189 const GValue *clock_gvalue;
1190 GstStructure *structure;
1192 g_return_if_fail (GST_IS_MESSAGE (message));
1193 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1195 structure = GST_MESSAGE_STRUCTURE (message);
1196 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1197 g_return_if_fail (clock_gvalue != NULL);
1198 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1202 g_value_get_boolean (gst_structure_id_get_value (structure,
1203 GST_QUARK (READY)));
1205 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1209 * gst_message_parse_clock_lost:
1210 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1211 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1213 * Extracts the lost clock from the GstMessage.
1214 * The clock object returned remains valid until the message is freed.
1219 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1221 const GValue *clock_gvalue;
1222 GstStructure *structure;
1224 g_return_if_fail (GST_IS_MESSAGE (message));
1225 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1227 structure = GST_MESSAGE_STRUCTURE (message);
1228 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1229 g_return_if_fail (clock_gvalue != NULL);
1230 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1233 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1237 * gst_message_parse_new_clock:
1238 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1239 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1242 * Extracts the new clock from the GstMessage.
1243 * The clock object returned remains valid until the message is freed.
1248 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1250 const GValue *clock_gvalue;
1251 GstStructure *structure;
1253 g_return_if_fail (GST_IS_MESSAGE (message));
1254 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1256 structure = GST_MESSAGE_STRUCTURE (message);
1257 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1258 g_return_if_fail (clock_gvalue != NULL);
1259 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1262 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1266 * gst_message_parse_structure_change:
1267 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1268 * @type: (out): A pointer to hold the change type
1269 * @owner: (out) (allow-none) (transfer none): The owner element of the
1271 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1272 * progress or has been completed
1274 * Extracts the change type and completion status from the GstMessage.
1281 gst_message_parse_structure_change (GstMessage * message,
1282 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1284 const GValue *owner_gvalue;
1285 GstStructure *structure;
1287 g_return_if_fail (GST_IS_MESSAGE (message));
1288 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1290 structure = GST_MESSAGE_STRUCTURE (message);
1291 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1292 g_return_if_fail (owner_gvalue != NULL);
1293 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1296 *type = (GstStructureChangeType)
1297 g_value_get_enum (gst_structure_id_get_value (structure,
1300 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1303 g_value_get_boolean (gst_structure_id_get_value (structure,
1308 * gst_message_parse_error:
1309 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1310 * @gerror: (out) (allow-none) (transfer full): location for the GError
1311 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1314 * Extracts the GError and debug string from the GstMessage. The values returned
1315 * in the output arguments are copies; the caller must free them when done.
1317 * Typical usage of this function might be:
1320 * switch (GST_MESSAGE_TYPE (msg)) {
1321 * case GST_MESSAGE_ERROR: {
1322 * GError *err = NULL;
1323 * gchar *dbg_info = NULL;
1325 * gst_message_parse_error (msg, &err, &dbg_info);
1326 * g_printerr ("ERROR from element %s: %s\n",
1327 * GST_OBJECT_NAME (msg->src), err->message);
1328 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1329 * g_error_free (err);
1330 * g_free (dbg_info);
1341 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1343 const GValue *error_gvalue;
1345 GstStructure *structure;
1347 g_return_if_fail (GST_IS_MESSAGE (message));
1348 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1350 structure = GST_MESSAGE_STRUCTURE (message);
1351 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1352 g_return_if_fail (error_gvalue != NULL);
1353 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR);
1355 error_val = (GError *) g_value_get_boxed (error_gvalue);
1357 *gerror = g_error_copy (error_val);
1363 g_value_dup_string (gst_structure_id_get_value (structure,
1364 GST_QUARK (DEBUG)));
1368 * gst_message_parse_warning:
1369 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1370 * @gerror: (out) (allow-none) (transfer full): location for the GError
1371 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1374 * Extracts the GError and debug string from the GstMessage. The values returned
1375 * in the output arguments are copies; the caller must free them when done.
1380 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1383 const GValue *error_gvalue;
1385 GstStructure *structure;
1387 g_return_if_fail (GST_IS_MESSAGE (message));
1388 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1390 structure = GST_MESSAGE_STRUCTURE (message);
1391 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1392 g_return_if_fail (error_gvalue != NULL);
1393 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR);
1395 error_val = (GError *) g_value_get_boxed (error_gvalue);
1397 *gerror = g_error_copy (error_val);
1403 g_value_dup_string (gst_structure_id_get_value (structure,
1404 GST_QUARK (DEBUG)));
1408 * gst_message_parse_info:
1409 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1410 * @gerror: (out) (allow-none) (transfer full): location for the GError
1411 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1414 * Extracts the GError and debug string from the GstMessage. The values returned
1415 * in the output arguments are copies; the caller must free them when done.
1422 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1424 const GValue *error_gvalue;
1426 GstStructure *structure;
1428 g_return_if_fail (GST_IS_MESSAGE (message));
1429 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1431 structure = GST_MESSAGE_STRUCTURE (message);
1432 error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR));
1433 g_return_if_fail (error_gvalue != NULL);
1434 g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR);
1436 error_val = (GError *) g_value_get_boxed (error_gvalue);
1438 *gerror = g_error_copy (error_val);
1444 g_value_dup_string (gst_structure_id_get_value (structure,
1445 GST_QUARK (DEBUG)));
1449 * gst_message_parse_segment_start:
1450 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1451 * @format: (out): Result location for the format, or NULL
1452 * @position: (out): Result location for the position, or NULL
1454 * Extracts the position and format from the segment start message.
1459 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1462 GstStructure *structure;
1464 g_return_if_fail (GST_IS_MESSAGE (message));
1465 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1467 structure = GST_MESSAGE_STRUCTURE (message);
1469 *format = (GstFormat)
1470 g_value_get_enum (gst_structure_id_get_value (structure,
1471 GST_QUARK (FORMAT)));
1474 g_value_get_int64 (gst_structure_id_get_value (structure,
1475 GST_QUARK (POSITION)));
1479 * gst_message_parse_segment_done:
1480 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1481 * @format: (out): Result location for the format, or NULL
1482 * @position: (out): Result location for the position, or NULL
1484 * Extracts the position and format from the segment start message.
1489 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1492 GstStructure *structure;
1494 g_return_if_fail (GST_IS_MESSAGE (message));
1495 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1497 structure = GST_MESSAGE_STRUCTURE (message);
1499 *format = (GstFormat)
1500 g_value_get_enum (gst_structure_id_get_value (structure,
1501 GST_QUARK (FORMAT)));
1504 g_value_get_int64 (gst_structure_id_get_value (structure,
1505 GST_QUARK (POSITION)));
1509 * gst_message_parse_duration:
1510 * @message: A valid #GstMessage of type GST_MESSAGE_DURATION.
1511 * @format: (out): Result location for the format, or NULL
1512 * @duration: (out): Result location for the duration, or NULL
1514 * Extracts the duration and format from the duration message. The duration
1515 * might be GST_CLOCK_TIME_NONE, which indicates that the duration has
1516 * changed. Applications should always use a query to retrieve the duration
1522 gst_message_parse_duration (GstMessage * message, GstFormat * format,
1525 GstStructure *structure;
1527 g_return_if_fail (GST_IS_MESSAGE (message));
1528 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DURATION);
1530 structure = GST_MESSAGE_STRUCTURE (message);
1532 *format = (GstFormat)
1533 g_value_get_enum (gst_structure_id_get_value (structure,
1534 GST_QUARK (FORMAT)));
1537 g_value_get_int64 (gst_structure_id_get_value (structure,
1538 GST_QUARK (DURATION)));
1542 * gst_message_parse_async_done:
1543 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1544 * @reset_time: (out): Result location for the reset_time or NULL
1546 * Extract the reset_time from the async_done message.
1551 gst_message_parse_async_done (GstMessage * message, gboolean * reset_time)
1553 GstStructure *structure;
1555 g_return_if_fail (GST_IS_MESSAGE (message));
1556 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1558 structure = GST_MESSAGE_STRUCTURE (message);
1561 g_value_get_boolean (gst_structure_id_get_value (structure,
1562 GST_QUARK (RESET_TIME)));
1566 * gst_message_parse_request_state:
1567 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1568 * @state: (out): Result location for the requested state or NULL
1570 * Extract the requested state from the request_state message.
1577 gst_message_parse_request_state (GstMessage * message, GstState * state)
1579 GstStructure *structure;
1581 g_return_if_fail (GST_IS_MESSAGE (message));
1582 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1584 structure = GST_MESSAGE_STRUCTURE (message);
1587 g_value_get_enum (gst_structure_id_get_value (structure,
1588 GST_QUARK (NEW_STATE)));
1592 * gst_message_new_stream_status:
1593 * @src: The object originating the message.
1594 * @type: The stream status type.
1595 * @owner: (transfer none): the owner element of @src.
1597 * Create a new stream status message. This message is posted when a streaming
1598 * thread is created/destroyed or when the state changed.
1600 * Returns: (transfer full): the new stream status message.
1607 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1610 GstMessage *message;
1611 GstStructure *structure;
1613 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1614 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1615 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1616 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1622 * gst_message_parse_stream_status:
1623 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1624 * @type: (out): A pointer to hold the status type
1625 * @owner: (out) (transfer none): The owner element of the message source
1627 * Extracts the stream status type and owner the GstMessage. The returned
1628 * owner remains valid for as long as the reference to @message is valid and
1629 * should thus not be unreffed.
1636 gst_message_parse_stream_status (GstMessage * message,
1637 GstStreamStatusType * type, GstElement ** owner)
1639 const GValue *owner_gvalue;
1640 GstStructure *structure;
1642 g_return_if_fail (GST_IS_MESSAGE (message));
1643 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1645 structure = GST_MESSAGE_STRUCTURE (message);
1646 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1647 g_return_if_fail (owner_gvalue != NULL);
1650 *type = (GstStreamStatusType)
1651 g_value_get_enum (gst_structure_id_get_value (structure,
1654 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1658 * gst_message_set_stream_status_object:
1659 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1660 * @object: the object controlling the streaming
1662 * Configures the object handling the streaming thread. This is usually a
1663 * GstTask object but other objects might be added in the future.
1668 gst_message_set_stream_status_object (GstMessage * message,
1669 const GValue * object)
1671 GstStructure *structure;
1673 g_return_if_fail (GST_IS_MESSAGE (message));
1674 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1676 structure = GST_MESSAGE_STRUCTURE (message);
1677 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1681 * gst_message_get_stream_status_object:
1682 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1684 * Extracts the object managing the streaming thread from @message.
1686 * Returns: a GValue containing the object that manages the streaming thread.
1687 * This object is usually of type GstTask but other types can be added in the
1688 * future. The object remains valid as long as @message is valid.
1693 gst_message_get_stream_status_object (GstMessage * message)
1695 const GValue *result;
1696 GstStructure *structure;
1698 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1699 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1702 structure = GST_MESSAGE_STRUCTURE (message);
1703 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1709 * gst_message_new_step_done:
1710 * @src: The object originating the message.
1711 * @format: the format of @amount
1712 * @amount: the amount of stepped data
1713 * @rate: the rate of the stepped amount
1714 * @flush: is this an flushing step
1715 * @intermediate: is this an intermediate step
1716 * @duration: the duration of the data
1717 * @eos: the step caused EOS
1719 * This message is posted by elements when they complete a part, when @intermediate set
1720 * to TRUE, or a complete step operation.
1722 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1723 * @amount of media in format @format.
1725 * Returns: (transfer full): the new step_done message.
1732 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1733 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1736 GstMessage *message;
1737 GstStructure *structure;
1739 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1740 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1741 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1742 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1743 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1744 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1745 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1746 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1747 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1753 * gst_message_parse_step_done:
1754 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1755 * @format: (out) (allow-none): result location for the format
1756 * @amount: (out) (allow-none): result location for the amount
1757 * @rate: (out) (allow-none): result location for the rate
1758 * @flush: (out) (allow-none): result location for the flush flag
1759 * @intermediate: (out) (allow-none): result location for the intermediate flag
1760 * @duration: (out) (allow-none): result location for the duration
1761 * @eos: (out) (allow-none): result location for the EOS flag
1763 * Extract the values the step_done message.
1770 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1771 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1772 guint64 * duration, gboolean * eos)
1774 GstStructure *structure;
1776 g_return_if_fail (GST_IS_MESSAGE (message));
1777 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1779 structure = GST_MESSAGE_STRUCTURE (message);
1780 gst_structure_id_get (structure,
1781 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1782 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1783 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1784 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1785 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1786 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1787 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1791 * gst_message_new_step_start:
1792 * @src: The object originating the message.
1793 * @active: if the step is active or queued
1794 * @format: the format of @amount
1795 * @amount: the amount of stepped data
1796 * @rate: the rate of the stepped amount
1797 * @flush: is this an flushing step
1798 * @intermediate: is this an intermediate step
1800 * This message is posted by elements when they accept or activate a new step
1801 * event for @amount in @format.
1803 * @active is set to FALSE when the element accepted the new step event and has
1804 * queued it for execution in the streaming threads.
1806 * @active is set to TRUE when the element has activated the step operation and
1807 * is now ready to start executing the step in the streaming thread. After this
1808 * message is emited, the application can queue a new step operation in the
1811 * Returns: (transfer full): The new step_start message.
1818 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1819 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1821 GstMessage *message;
1822 GstStructure *structure;
1824 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1825 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1826 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1827 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1828 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1829 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1830 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1831 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1837 * gst_message_parse_step_start:
1838 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1839 * @active: (out) (allow-none): result location for the active flag
1840 * @format: (out) (allow-none): result location for the format
1841 * @amount: (out) (allow-none): result location for the amount
1842 * @rate: (out) (allow-none): result location for the rate
1843 * @flush: (out) (allow-none): result location for the flush flag
1844 * @intermediate: (out) (allow-none): result location for the intermediate flag
1846 * Extract the values from step_start message.
1853 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1854 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1855 gboolean * intermediate)
1857 GstStructure *structure;
1859 g_return_if_fail (GST_IS_MESSAGE (message));
1860 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1862 structure = GST_MESSAGE_STRUCTURE (message);
1863 gst_structure_id_get (structure,
1864 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1865 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1866 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1867 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1868 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1869 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1873 * gst_message_new_qos:
1874 * @src: The object originating the message.
1875 * @live: if the message was generated by a live element
1876 * @running_time: the running time of the buffer that generated the message
1877 * @stream_time: the stream time of the buffer that generated the message
1878 * @timestamp: the timestamps of the buffer that generated the message
1879 * @duration: the duration of the buffer that generated the message
1881 * A QOS message is posted on the bus whenever an element decides to drop a
1882 * buffer because of QoS reasons or whenever it changes its processing strategy
1883 * because of QoS reasons (quality adjustments such as processing at lower
1886 * This message can be posted by an element that performs synchronisation against the
1887 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1888 * events received from a downstream element (!live).
1890 * @running_time, @stream_time, @timestamp, @duration should be set to the
1891 * respective running-time, stream-time, timestamp and duration of the (dropped)
1892 * buffer that generated the QoS event. Values can be left to
1893 * GST_CLOCK_TIME_NONE when unknown.
1895 * Returns: (transfer full): The new qos message.
1902 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1903 guint64 stream_time, guint64 timestamp, guint64 duration)
1905 GstMessage *message;
1906 GstStructure *structure;
1908 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1909 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1910 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1911 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1912 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1913 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1914 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1915 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1916 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1917 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1918 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1919 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1920 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1926 * gst_message_set_qos_values:
1927 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1928 * @jitter: The difference of the running-time against the deadline.
1929 * @proportion: Long term prediction of the ideal rate relative to normal rate
1930 * to get optimal quality.
1931 * @quality: An element dependent integer value that specifies the current
1932 * quality level of the element. The default maximum quality is 1000000.
1934 * Set the QoS values that have been calculated/analysed from the QoS data
1941 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1942 gdouble proportion, gint quality)
1944 GstStructure *structure;
1946 g_return_if_fail (GST_IS_MESSAGE (message));
1947 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1949 structure = GST_MESSAGE_STRUCTURE (message);
1950 gst_structure_id_set (structure,
1951 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1952 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1953 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1957 * gst_message_set_qos_stats:
1958 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1959 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1960 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1961 * will likely use GST_FORMAT_DEFAULT (samples).
1962 * @processed: Total number of units correctly processed since the last state
1963 * change to READY or a flushing operation.
1964 * @dropped: Total number of units dropped since the last state change to READY
1965 * or a flushing operation.
1967 * Set the QoS stats representing the history of the current continuous pipeline
1970 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1971 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1978 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1979 guint64 processed, guint64 dropped)
1981 GstStructure *structure;
1983 g_return_if_fail (GST_IS_MESSAGE (message));
1984 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1986 structure = GST_MESSAGE_STRUCTURE (message);
1987 gst_structure_id_set (structure,
1988 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1989 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1990 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1994 * gst_message_parse_qos:
1995 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1996 * @live: (out) (allow-none): if the message was generated by a live element
1997 * @running_time: (out) (allow-none): the running time of the buffer that
1998 * generated the message
1999 * @stream_time: (out) (allow-none): the stream time of the buffer that
2000 * generated the message
2001 * @timestamp: (out) (allow-none): the timestamps of the buffer that
2002 * generated the message
2003 * @duration: (out) (allow-none): the duration of the buffer that
2004 * generated the message
2006 * Extract the timestamps and live status from the QoS message.
2008 * The returned values give the running_time, stream_time, timestamp and
2009 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2017 gst_message_parse_qos (GstMessage * message, gboolean * live,
2018 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2021 GstStructure *structure;
2023 g_return_if_fail (GST_IS_MESSAGE (message));
2024 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2026 structure = GST_MESSAGE_STRUCTURE (message);
2027 gst_structure_id_get (structure,
2028 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2029 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2030 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2031 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2032 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2036 * gst_message_parse_qos_values:
2037 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2038 * @jitter: (out) (allow-none): The difference of the running-time against
2040 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2041 * relative to normal rate to get optimal quality.
2042 * @quality: (out) (allow-none): An element dependent integer value that
2043 * specifies the current quality level of the element. The default
2044 * maximum quality is 1000000.
2046 * Extract the QoS values that have been calculated/analysed from the QoS data
2053 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2054 gdouble * proportion, gint * quality)
2056 GstStructure *structure;
2058 g_return_if_fail (GST_IS_MESSAGE (message));
2059 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2061 structure = GST_MESSAGE_STRUCTURE (message);
2062 gst_structure_id_get (structure,
2063 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2064 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2065 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2069 * gst_message_parse_qos_stats:
2070 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2071 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2072 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2073 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2075 * @processed: (out) (allow-none): Total number of units correctly processed
2076 * since the last state change to READY or a flushing operation.
2077 * @dropped: (out) (allow-none): Total number of units dropped since the last
2078 * state change to READY or a flushing operation.
2080 * Extract the QoS stats representing the history of the current continuous
2081 * pipeline playback period.
2083 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2084 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2091 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2092 guint64 * processed, guint64 * dropped)
2094 GstStructure *structure;
2096 g_return_if_fail (GST_IS_MESSAGE (message));
2097 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2099 structure = GST_MESSAGE_STRUCTURE (message);
2100 gst_structure_id_get (structure,
2101 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2102 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2103 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2107 * gst_message_new_progress:
2108 * @src: The object originating the message.
2109 * @type: a #GstProgressType
2110 * @code: a progress code
2111 * @text: free, user visible text describing the progress
2113 * Progress messages are posted by elements when they use an asynchronous task
2114 * to perform actions triggered by a state change.
2116 * @code contains a well defined string describing the action.
2117 * @test should contain a user visible string detailing the current action.
2119 * Returns: (transfer full): The new qos message.
2124 gst_message_new_progress (GstObject * src, GstProgressType type,
2125 const gchar * code, const gchar * text)
2127 GstMessage *message;
2128 GstStructure *structure;
2129 gint percent = 100, timeout = -1;
2131 g_return_val_if_fail (code != NULL, NULL);
2132 g_return_val_if_fail (text != NULL, NULL);
2134 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2137 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2138 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2139 GST_QUARK (CODE), G_TYPE_STRING, code,
2140 GST_QUARK (TEXT), G_TYPE_STRING, text,
2141 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2142 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2143 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2149 * gst_message_parse_progress:
2150 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2151 * @type: (out) (allow-none): location for the type
2152 * @code: (out) (allow-none) (transfer full): location for the code
2153 * @text: (out) (allow-none) (transfer full): location for the text
2155 * Parses the progress @type, @code and @text.
2160 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2161 gchar ** code, gchar ** text)
2163 GstStructure *structure;
2165 g_return_if_fail (GST_IS_MESSAGE (message));
2166 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2168 structure = GST_MESSAGE_STRUCTURE (message);
2169 gst_structure_id_get (structure,
2170 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2171 GST_QUARK (CODE), G_TYPE_STRING, code,
2172 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);