2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
4 * gstmessage.c: GstMessage subsystem
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
24 * @short_description: Lightweight objects to signal the application of
26 * @see_also: #GstBus, #GstMiniObject, #GstElement
28 * Messages are implemented as a subclass of #GstMiniObject with a generic
29 * #GstStructure as the content. This allows for writing custom messages without
30 * requiring an API change while allowing a wide range of different types
33 * Messages are posted by objects in the pipeline and are passed to the
34 * application using the #GstBus.
36 * The basic use pattern of posting a message on a #GstBus is as follows:
39 * <title>Posting a #GstMessage</title>
41 * gst_bus_post (bus, gst_message_new_eos());
45 * A #GstElement usually posts messages on the bus provided by the parent
46 * container using gst_element_post_message().
48 * Last reviewed on 2005-11-09 (0.9.4)
52 #include "gst_private.h"
53 #include <string.h> /* memcpy */
55 #include "gstenumtypes.h"
57 #include "gstmessage.h"
58 #include "gsttaglist.h"
67 GstStructure *structure;
70 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
79 static GstMessageQuarks message_quarks[] = {
80 {GST_MESSAGE_UNKNOWN, "unknown", 0},
81 {GST_MESSAGE_EOS, "eos", 0},
82 {GST_MESSAGE_ERROR, "error", 0},
83 {GST_MESSAGE_WARNING, "warning", 0},
84 {GST_MESSAGE_INFO, "info", 0},
85 {GST_MESSAGE_TAG, "tag", 0},
86 {GST_MESSAGE_BUFFERING, "buffering", 0},
87 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
88 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
89 {GST_MESSAGE_STEP_DONE, "step-done", 0},
90 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
91 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
92 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
93 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
94 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
95 {GST_MESSAGE_APPLICATION, "application", 0},
96 {GST_MESSAGE_ELEMENT, "element", 0},
97 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
98 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
99 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
100 {GST_MESSAGE_LATENCY, "latency", 0},
101 {GST_MESSAGE_ASYNC_START, "async-start", 0},
102 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
103 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
104 {GST_MESSAGE_STEP_START, "step-start", 0},
105 {GST_MESSAGE_QOS, "qos", 0},
106 {GST_MESSAGE_PROGRESS, "progress", 0},
107 {GST_MESSAGE_TOC, "toc", 0},
108 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
109 {GST_MESSAGE_STREAM_START, "stream-start", 0},
113 static GType _gst_message_type = 0;
114 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
117 _priv_gst_message_initialize (void)
121 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
123 /* the GstMiniObject types need to be class_ref'd once before it can be
124 * done from multiple threads;
125 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
126 gst_message_get_type ();
128 for (i = 0; message_quarks[i].name; i++) {
129 message_quarks[i].quark =
130 g_quark_from_static_string (message_quarks[i].name);
133 _gst_message_type = gst_message_get_type ();
137 * gst_message_type_get_name:
138 * @type: the message type
140 * Get a printable name for the given message type. Do not modify or free.
142 * Returns: a reference to the static name of the message.
145 gst_message_type_get_name (GstMessageType type)
149 for (i = 0; message_quarks[i].name; i++) {
150 if (type == message_quarks[i].type)
151 return message_quarks[i].name;
157 * gst_message_type_to_quark:
158 * @type: the message type
160 * Get the unique quark for the given message type.
162 * Returns: the quark associated with the message type
165 gst_message_type_to_quark (GstMessageType type)
169 for (i = 0; message_quarks[i].name; i++) {
170 if (type == message_quarks[i].type)
171 return message_quarks[i].quark;
177 _gst_message_free (GstMessage * message)
179 GstStructure *structure;
181 g_return_if_fail (message != NULL);
183 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
184 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
186 if (GST_MESSAGE_SRC (message)) {
187 gst_object_unref (GST_MESSAGE_SRC (message));
188 GST_MESSAGE_SRC (message) = NULL;
191 if (message->lock.p) {
192 GST_MESSAGE_LOCK (message);
193 GST_MESSAGE_SIGNAL (message);
194 GST_MESSAGE_UNLOCK (message);
197 structure = GST_MESSAGE_STRUCTURE (message);
199 gst_structure_set_parent_refcount (structure, NULL);
200 gst_structure_free (structure);
203 g_slice_free1 (sizeof (GstMessageImpl), message);
207 gst_message_init (GstMessageImpl * message, GstMessageType type,
211 _gst_message_copy (GstMessage * message)
213 GstMessageImpl *copy;
214 GstStructure *structure;
216 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
217 GST_MESSAGE_TYPE_NAME (message),
218 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
220 copy = g_slice_new0 (GstMessageImpl);
222 gst_message_init (copy, GST_MESSAGE_TYPE (message),
223 GST_MESSAGE_SRC (message));
225 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
226 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
228 structure = GST_MESSAGE_STRUCTURE (message);
230 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
231 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
232 ©->message.mini_object.refcount);
234 GST_MESSAGE_STRUCTURE (copy) = NULL;
237 return GST_MESSAGE_CAST (copy);
241 gst_message_init (GstMessageImpl * message, GstMessageType type,
244 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
245 (GstMiniObjectCopyFunction) _gst_message_copy, NULL,
246 (GstMiniObjectFreeFunction) _gst_message_free);
248 GST_MESSAGE_TYPE (message) = type;
250 gst_object_ref (src);
251 GST_MESSAGE_SRC (message) = src;
252 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
253 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
258 * gst_message_new_custom:
259 * @type: The #GstMessageType to distinguish messages
260 * @src: The object originating the message.
261 * @structure: (transfer full): the structure for the message. The message
262 * will take ownership of the structure.
264 * Create a new custom-typed message. This can be used for anything not
265 * handled by other message-specific functions to pass a message to the
266 * app. The structure field can be NULL.
268 * Returns: (transfer full): The new message.
273 gst_message_new_custom (GstMessageType type, GstObject * src,
274 GstStructure * structure)
276 GstMessageImpl *message;
278 message = g_slice_new0 (GstMessageImpl);
280 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
281 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
282 gst_message_type_get_name (type));
285 /* structure must not have a parent */
286 if (!gst_structure_set_parent_refcount (structure,
287 &message->message.mini_object.refcount))
290 gst_message_init (message, type, src);
292 GST_MESSAGE_STRUCTURE (message) = structure;
294 return GST_MESSAGE_CAST (message);
299 g_slice_free1 (sizeof (GstMessageImpl), message);
300 g_warning ("structure is already owned by another object");
306 * gst_message_get_seqnum:
307 * @message: A #GstMessage.
309 * Retrieve the sequence number of a message.
311 * Messages have ever-incrementing sequence numbers, which may also be set
312 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
313 * to indicate that a message corresponds to some other set of messages or
314 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
315 * is considered good practice to make this correspondence when possible, though
316 * it is not required.
318 * Note that events and messages share the same sequence number incrementor;
319 * two events or messages will never have the same sequence number unless
320 * that correspondence was made explicitly.
322 * Returns: The message's sequence number.
327 gst_message_get_seqnum (GstMessage * message)
329 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
331 return GST_MESSAGE_SEQNUM (message);
335 * gst_message_set_seqnum:
336 * @message: A #GstMessage.
337 * @seqnum: A sequence number.
339 * Set the sequence number of a message.
341 * This function might be called by the creator of a message to indicate that
342 * the message relates to other messages or events. See gst_message_get_seqnum()
343 * for more information.
348 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
350 g_return_if_fail (GST_IS_MESSAGE (message));
352 GST_MESSAGE_SEQNUM (message) = seqnum;
356 * gst_message_new_eos:
357 * @src: (transfer none): The object originating the message.
359 * Create a new eos message. This message is generated and posted in
360 * the sink elements of a GstBin. The bin will only forward the EOS
361 * message to the application if all sinks have posted an EOS message.
363 * Returns: (transfer full): The new eos message.
368 gst_message_new_eos (GstObject * src)
372 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
378 * gst_message_new_error:
379 * @src: (transfer none): The object originating the message.
380 * @error: (transfer none): The GError for this message.
381 * @debug: A debugging string.
383 * Create a new error message. The message will copy @error and
384 * @debug. This message is posted by element when a fatal event
385 * occured. The pipeline will probably (partially) stop. The application
386 * receiving this message should stop the pipeline.
388 * Returns: (transfer full): the new error message.
393 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
396 GstStructure *structure;
398 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
399 GST_QUARK (GERROR), G_TYPE_ERROR, error,
400 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
401 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
407 * gst_message_new_warning:
408 * @src: (transfer none): The object originating the message.
409 * @error: (transfer none): The GError for this message.
410 * @debug: A debugging string.
412 * Create a new warning message. The message will make copies of @error and
415 * Returns: (transfer full): The new warning message.
420 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
423 GstStructure *structure;
425 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
426 GST_QUARK (GERROR), G_TYPE_ERROR, error,
427 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
428 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
434 * gst_message_new_info:
435 * @src: (transfer none): The object originating the message.
436 * @error: (transfer none): The GError for this message.
437 * @debug: A debugging string.
439 * Create a new info message. The message will make copies of @error and
444 * Returns: (transfer full): the new info message.
447 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
450 GstStructure *structure;
452 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
453 GST_QUARK (GERROR), G_TYPE_ERROR, error,
454 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
455 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
461 * gst_message_new_tag:
462 * @src: (transfer none): The object originating the message.
463 * @tag_list: (transfer full): the tag list for the message.
465 * Create a new tag message. The message will take ownership of the tag list.
466 * The message is posted by elements that discovered a new taglist.
468 * Returns: (transfer full): the new tag message.
473 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
477 GValue val = G_VALUE_INIT;
479 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
481 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
482 g_value_init (&val, GST_TYPE_TAG_LIST);
483 g_value_take_boxed (&val, tag_list);
484 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
485 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
490 * gst_message_new_buffering:
491 * @src: (transfer none): The object originating the message.
492 * @percent: The buffering percent
494 * Create a new buffering message. This message can be posted by an element that
495 * needs to buffer data before it can continue processing. @percent should be a
496 * value between 0 and 100. A value of 100 means that the buffering completed.
498 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
499 * @percent is 100, the application can set the pipeline (back) to PLAYING.
500 * The application must be prepared to receive BUFFERING messages in the
501 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
502 * message with @percent set to 100, which can happen after the pipeline
503 * completed prerolling.
507 * Returns: (transfer full): The new buffering message.
510 gst_message_new_buffering (GstObject * src, gint percent)
513 GstStructure *structure;
514 gint64 buffering_left;
516 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
518 buffering_left = (percent == 100 ? 0 : -1);
520 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
521 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
522 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
523 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
524 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
525 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
526 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
532 * gst_message_new_state_changed:
533 * @src: (transfer none): the object originating the message
534 * @oldstate: the previous state
535 * @newstate: the new (current) state
536 * @pending: the pending (target) state
538 * Create a state change message. This message is posted whenever an element
541 * Returns: (transfer full): the new state change message.
546 gst_message_new_state_changed (GstObject * src,
547 GstState oldstate, GstState newstate, GstState pending)
550 GstStructure *structure;
552 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
553 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
554 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
555 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
556 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
562 * gst_message_new_state_dirty:
563 * @src: (transfer none): the object originating the message
565 * Create a state dirty message. This message is posted whenever an element
566 * changed its state asynchronously and is used internally to update the
567 * states of container objects.
569 * Returns: (transfer full): the new state dirty message.
574 gst_message_new_state_dirty (GstObject * src)
578 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
584 * gst_message_new_clock_provide:
585 * @src: (transfer none): the object originating the message.
586 * @clock: (transfer none): the clock it provides
587 * @ready: TRUE if the sender can provide a clock
589 * Create a clock provide message. This message is posted whenever an
590 * element is ready to provide a clock or lost its ability to provide
591 * a clock (maybe because it paused or became EOS).
593 * This message is mainly used internally to manage the clock
596 * Returns: (transfer full): the new provide clock message.
601 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
605 GstStructure *structure;
607 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
608 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
609 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
610 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
616 * gst_message_new_clock_lost:
617 * @src: (transfer none): the object originating the message.
618 * @clock: (transfer none): the clock that was lost
620 * Create a clock lost message. This message is posted whenever the
621 * clock is not valid anymore.
623 * If this message is posted by the pipeline, the pipeline will
624 * select a new clock again when it goes to PLAYING. It might therefore
625 * be needed to set the pipeline to PAUSED and PLAYING again.
627 * Returns: (transfer full): The new clock lost message.
632 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
635 GstStructure *structure;
637 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
638 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
639 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
645 * gst_message_new_new_clock:
646 * @src: (transfer none): The object originating the message.
647 * @clock: (transfer none): the new selected clock
649 * Create a new clock message. This message is posted whenever the
650 * pipeline selectes a new clock for the pipeline.
652 * Returns: (transfer full): The new new clock message.
657 gst_message_new_new_clock (GstObject * src, GstClock * clock)
660 GstStructure *structure;
662 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
663 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
664 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
670 * gst_message_new_structure_change:
671 * @src: (transfer none): The object originating the message.
672 * @type: The change type.
673 * @owner: (transfer none): The owner element of @src.
674 * @busy: Whether the structure change is busy.
676 * Create a new structure change message. This message is posted when the
677 * structure of a pipeline is in the process of being changed, for example
678 * when pads are linked or unlinked.
680 * @src should be the sinkpad that unlinked or linked.
682 * Returns: (transfer full): the new structure change message.
687 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
688 GstElement * owner, gboolean busy)
691 GstStructure *structure;
693 g_return_val_if_fail (GST_IS_PAD (src), NULL);
694 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
695 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
697 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
698 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
699 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
700 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
702 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
709 * gst_message_new_segment_start:
710 * @src: (transfer none): The object originating the message.
711 * @format: The format of the position being played
712 * @position: The position of the segment being played
714 * Create a new segment message. This message is posted by elements that
715 * start playback of a segment as a result of a segment seek. This message
716 * is not received by the application but is used for maintenance reasons in
717 * container elements.
719 * Returns: (transfer full): the new segment start message.
724 gst_message_new_segment_start (GstObject * src, GstFormat format,
728 GstStructure *structure;
730 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
731 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
732 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
733 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
739 * gst_message_new_segment_done:
740 * @src: (transfer none): the object originating the message.
741 * @format: The format of the position being done
742 * @position: The position of the segment being done
744 * Create a new segment done message. This message is posted by elements that
745 * finish playback of a segment as a result of a segment seek. This message
746 * is received by the application after all elements that posted a segment_start
747 * have posted the segment_done.
749 * Returns: (transfer full): the new segment done message.
754 gst_message_new_segment_done (GstObject * src, GstFormat format,
758 GstStructure *structure;
760 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
761 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
762 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
763 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
769 * gst_message_new_application:
770 * @src: (transfer none): the object originating the message.
771 * @structure: (transfer full): the structure for the message. The message
772 * will take ownership of the structure.
774 * Create a new application-typed message. GStreamer will never create these
775 * messages; they are a gift from us to you. Enjoy.
777 * Returns: (transfer full): The new application message.
782 gst_message_new_application (GstObject * src, GstStructure * structure)
784 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
788 * gst_message_new_element:
789 * @src: (transfer none): The object originating the message.
790 * @structure: (transfer full): The structure for the message. The message
791 * will take ownership of the structure.
793 * Create a new element-specific message. This is meant as a generic way of
794 * allowing one-way communication from an element to an application, for example
795 * "the firewire cable was unplugged". The format of the message should be
796 * documented in the element's documentation. The structure field can be NULL.
798 * Returns: (transfer full): The new element message.
803 gst_message_new_element (GstObject * src, GstStructure * structure)
805 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
809 * gst_message_new_duration_changed:
810 * @src: (transfer none): The object originating the message.
812 * Create a new duration changed message. This message is posted by elements
813 * that know the duration of a stream when the duration changes. This message
814 * is received by bins and is used to calculate the total duration of a
815 * pipeline. Elements may post a duration message with a duration of
816 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
817 * cached duration should be discarded. The new duration can then be
818 * retrieved via a query.
820 * Returns: (transfer full): The new duration-changed message.
825 gst_message_new_duration_changed (GstObject * src)
829 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
830 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
836 * gst_message_new_async_start:
837 * @src: (transfer none): The object originating the message.
839 * This message is posted by elements when they start an ASYNC state change.
841 * Returns: (transfer full): The new async_start message.
846 gst_message_new_async_start (GstObject * src)
850 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
856 * gst_message_new_async_done:
857 * @src: (transfer none): The object originating the message.
858 * @running_time: the desired running_time
860 * The message is posted when elements completed an ASYNC state change.
861 * @running_time contains the time of the desired running_time when this
862 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
863 * means that the element has no clock interaction and thus doesn't care about
864 * the running_time of the pipeline.
866 * Returns: (transfer full): The new async_done message.
871 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
874 GstStructure *structure;
876 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
877 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
878 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
884 * gst_message_new_latency:
885 * @src: (transfer none): The object originating the message.
887 * This message can be posted by elements when their latency requirements have
890 * Returns: (transfer full): The new latency message.
895 gst_message_new_latency (GstObject * src)
899 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
905 * gst_message_new_request_state:
906 * @src: (transfer none): the object originating the message.
907 * @state: The new requested state
909 * This message can be posted by elements when they want to have their state
910 * changed. A typical use case would be an audio server that wants to pause the
911 * pipeline because a higher priority stream is being played.
913 * Returns: (transfer full): the new requst state message.
918 gst_message_new_request_state (GstObject * src, GstState state)
921 GstStructure *structure;
923 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
924 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
925 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
931 * gst_message_get_structure:
932 * @message: The #GstMessage.
934 * Access the structure of the message.
936 * Returns: (transfer none): The structure of the message. The structure is
937 * still owned by the message, which means that you should not free it and
938 * that the pointer becomes invalid when you free the message.
943 gst_message_get_structure (GstMessage * message)
945 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
947 return GST_MESSAGE_STRUCTURE (message);
951 * gst_message_has_name:
952 * @message: The #GstMessage.
953 * @name: name to check
955 * Checks if @message has the given @name. This function is usually used to
956 * check the name of a custom message.
958 * Returns: %TRUE if @name matches the name of the message structure.
961 gst_message_has_name (GstMessage * message, const gchar * name)
963 GstStructure *structure;
965 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
967 structure = GST_MESSAGE_STRUCTURE (message);
968 if (structure == NULL)
971 return gst_structure_has_name (structure, name);
975 * gst_message_parse_tag:
976 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
977 * @tag_list: (out callee-allocates): return location for the tag-list.
979 * Extracts the tag list from the GstMessage. The tag list returned in the
980 * output argument is a copy; the caller must free it when done.
982 * Typical usage of this function might be:
985 * switch (GST_MESSAGE_TYPE (msg)) {
986 * case GST_MESSAGE_TAG: {
987 * GstTagList *tags = NULL;
989 * gst_message_parse_tag (msg, &tags);
990 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
991 * handle_tags (tags);
992 * gst_tag_list_unref (tags);
1003 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1005 g_return_if_fail (GST_IS_MESSAGE (message));
1006 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1007 g_return_if_fail (tag_list != NULL);
1009 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1010 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1014 * gst_message_parse_buffering:
1015 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1016 * @percent: (out) (allow-none): Return location for the percent.
1018 * Extracts the buffering percent from the GstMessage. see also
1019 * gst_message_new_buffering().
1024 gst_message_parse_buffering (GstMessage * message, gint * percent)
1026 g_return_if_fail (GST_IS_MESSAGE (message));
1027 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1031 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1032 (message), GST_QUARK (BUFFER_PERCENT)));
1036 * gst_message_set_buffering_stats:
1037 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1038 * @mode: a buffering mode
1039 * @avg_in: the average input rate
1040 * @avg_out: the average output rate
1041 * @buffering_left: amount of buffering time left in milliseconds
1043 * Configures the buffering stats values in @message.
1046 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1047 gint avg_in, gint avg_out, gint64 buffering_left)
1049 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1051 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1052 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1053 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1054 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1055 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1059 * gst_message_parse_buffering_stats:
1060 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1061 * @mode: (out) (allow-none): a buffering mode, or NULL
1062 * @avg_in: (out) (allow-none): the average input rate, or NULL
1063 * @avg_out: (out) (allow-none): the average output rate, or NULL
1064 * @buffering_left: (out) (allow-none): amount of buffering time left in
1065 * milliseconds, or NULL
1067 * Extracts the buffering stats values from @message.
1070 gst_message_parse_buffering_stats (GstMessage * message,
1071 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1072 gint64 * buffering_left)
1074 GstStructure *structure;
1076 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1078 structure = GST_MESSAGE_STRUCTURE (message);
1080 *mode = (GstBufferingMode)
1081 g_value_get_enum (gst_structure_id_get_value (structure,
1082 GST_QUARK (BUFFERING_MODE)));
1084 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1085 GST_QUARK (AVG_IN_RATE)));
1087 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1088 GST_QUARK (AVG_OUT_RATE)));
1091 g_value_get_int64 (gst_structure_id_get_value (structure,
1092 GST_QUARK (BUFFERING_LEFT)));
1096 * gst_message_parse_state_changed:
1097 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1098 * @oldstate: (out) (allow-none): the previous state, or NULL
1099 * @newstate: (out) (allow-none): the new (current) state, or NULL
1100 * @pending: (out) (allow-none): the pending (target) state, or NULL
1102 * Extracts the old and new states from the GstMessage.
1104 * Typical usage of this function might be:
1107 * switch (GST_MESSAGE_TYPE (msg)) {
1108 * case GST_MESSAGE_STATE_CHANGED: {
1109 * GstState old_state, new_state;
1111 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1112 * g_print ("Element %s changed state from %s to %s.\n",
1113 * GST_OBJECT_NAME (msg->src),
1114 * gst_element_state_get_name (old_state),
1115 * gst_element_state_get_name (new_state));
1126 gst_message_parse_state_changed (GstMessage * message,
1127 GstState * oldstate, GstState * newstate, GstState * pending)
1129 GstStructure *structure;
1131 g_return_if_fail (GST_IS_MESSAGE (message));
1132 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1134 structure = GST_MESSAGE_STRUCTURE (message);
1136 *oldstate = (GstState)
1137 g_value_get_enum (gst_structure_id_get_value (structure,
1138 GST_QUARK (OLD_STATE)));
1140 *newstate = (GstState)
1141 g_value_get_enum (gst_structure_id_get_value (structure,
1142 GST_QUARK (NEW_STATE)));
1144 *pending = (GstState)
1145 g_value_get_enum (gst_structure_id_get_value (structure,
1146 GST_QUARK (PENDING_STATE)));
1150 * gst_message_parse_clock_provide:
1151 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1152 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1154 * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
1156 * Extracts the clock and ready flag from the GstMessage.
1157 * The clock object returned remains valid until the message is freed.
1162 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1165 const GValue *clock_gvalue;
1166 GstStructure *structure;
1168 g_return_if_fail (GST_IS_MESSAGE (message));
1169 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1171 structure = GST_MESSAGE_STRUCTURE (message);
1172 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1173 g_return_if_fail (clock_gvalue != NULL);
1174 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1178 g_value_get_boolean (gst_structure_id_get_value (structure,
1179 GST_QUARK (READY)));
1181 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1185 * gst_message_parse_clock_lost:
1186 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1187 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1189 * Extracts the lost clock from the GstMessage.
1190 * The clock object returned remains valid until the message is freed.
1195 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1197 const GValue *clock_gvalue;
1198 GstStructure *structure;
1200 g_return_if_fail (GST_IS_MESSAGE (message));
1201 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1203 structure = GST_MESSAGE_STRUCTURE (message);
1204 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1205 g_return_if_fail (clock_gvalue != NULL);
1206 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1209 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1213 * gst_message_parse_new_clock:
1214 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1215 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1218 * Extracts the new clock from the GstMessage.
1219 * The clock object returned remains valid until the message is freed.
1224 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1226 const GValue *clock_gvalue;
1227 GstStructure *structure;
1229 g_return_if_fail (GST_IS_MESSAGE (message));
1230 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1232 structure = GST_MESSAGE_STRUCTURE (message);
1233 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1234 g_return_if_fail (clock_gvalue != NULL);
1235 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1238 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1242 * gst_message_parse_structure_change:
1243 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1244 * @type: (out): A pointer to hold the change type
1245 * @owner: (out) (allow-none) (transfer none): The owner element of the
1247 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1248 * progress or has been completed
1250 * Extracts the change type and completion status from the GstMessage.
1255 gst_message_parse_structure_change (GstMessage * message,
1256 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1258 const GValue *owner_gvalue;
1259 GstStructure *structure;
1261 g_return_if_fail (GST_IS_MESSAGE (message));
1262 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1264 structure = GST_MESSAGE_STRUCTURE (message);
1265 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1266 g_return_if_fail (owner_gvalue != NULL);
1267 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1270 *type = (GstStructureChangeType)
1271 g_value_get_enum (gst_structure_id_get_value (structure,
1274 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1277 g_value_get_boolean (gst_structure_id_get_value (structure,
1282 * gst_message_parse_error:
1283 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1284 * @gerror: (out) (allow-none) (transfer full): location for the GError
1285 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1288 * Extracts the GError and debug string from the GstMessage. The values returned
1289 * in the output arguments are copies; the caller must free them when done.
1291 * Typical usage of this function might be:
1294 * switch (GST_MESSAGE_TYPE (msg)) {
1295 * case GST_MESSAGE_ERROR: {
1296 * GError *err = NULL;
1297 * gchar *dbg_info = NULL;
1299 * gst_message_parse_error (msg, &err, &dbg_info);
1300 * g_printerr ("ERROR from element %s: %s\n",
1301 * GST_OBJECT_NAME (msg->src), err->message);
1302 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1303 * g_error_free (err);
1304 * g_free (dbg_info);
1315 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1317 g_return_if_fail (GST_IS_MESSAGE (message));
1318 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1320 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1321 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1322 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1326 * gst_message_parse_warning:
1327 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1328 * @gerror: (out) (allow-none) (transfer full): location for the GError
1329 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1332 * Extracts the GError and debug string from the GstMessage. The values returned
1333 * in the output arguments are copies; the caller must free them when done.
1338 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1341 g_return_if_fail (GST_IS_MESSAGE (message));
1342 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1344 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1345 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1346 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1350 * gst_message_parse_info:
1351 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1352 * @gerror: (out) (allow-none) (transfer full): location for the GError
1353 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1356 * Extracts the GError and debug string from the GstMessage. The values returned
1357 * in the output arguments are copies; the caller must free them when done.
1362 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1364 g_return_if_fail (GST_IS_MESSAGE (message));
1365 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1367 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1368 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1369 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1373 * gst_message_parse_segment_start:
1374 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1375 * @format: (out) (allow-none): Result location for the format, or NULL
1376 * @position: (out) (allow-none): Result location for the position, or NULL
1378 * Extracts the position and format from the segment start message.
1383 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1386 GstStructure *structure;
1388 g_return_if_fail (GST_IS_MESSAGE (message));
1389 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1391 structure = GST_MESSAGE_STRUCTURE (message);
1393 *format = (GstFormat)
1394 g_value_get_enum (gst_structure_id_get_value (structure,
1395 GST_QUARK (FORMAT)));
1398 g_value_get_int64 (gst_structure_id_get_value (structure,
1399 GST_QUARK (POSITION)));
1403 * gst_message_parse_segment_done:
1404 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1405 * @format: (out) (allow-none): Result location for the format, or NULL
1406 * @position: (out) (allow-none): Result location for the position, or NULL
1408 * Extracts the position and format from the segment done message.
1413 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1416 GstStructure *structure;
1418 g_return_if_fail (GST_IS_MESSAGE (message));
1419 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1421 structure = GST_MESSAGE_STRUCTURE (message);
1423 *format = (GstFormat)
1424 g_value_get_enum (gst_structure_id_get_value (structure,
1425 GST_QUARK (FORMAT)));
1428 g_value_get_int64 (gst_structure_id_get_value (structure,
1429 GST_QUARK (POSITION)));
1433 * gst_message_parse_async_done:
1434 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1435 * @running_time: (out) (allow-none): Result location for the running_time or NULL
1437 * Extract the running_time from the async_done message.
1442 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1444 GstStructure *structure;
1446 g_return_if_fail (GST_IS_MESSAGE (message));
1447 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1449 structure = GST_MESSAGE_STRUCTURE (message);
1452 g_value_get_uint64 (gst_structure_id_get_value (structure,
1453 GST_QUARK (RUNNING_TIME)));
1457 * gst_message_parse_request_state:
1458 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1459 * @state: (out) (allow-none): Result location for the requested state or NULL
1461 * Extract the requested state from the request_state message.
1466 gst_message_parse_request_state (GstMessage * message, GstState * state)
1468 GstStructure *structure;
1470 g_return_if_fail (GST_IS_MESSAGE (message));
1471 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1473 structure = GST_MESSAGE_STRUCTURE (message);
1476 g_value_get_enum (gst_structure_id_get_value (structure,
1477 GST_QUARK (NEW_STATE)));
1481 * gst_message_new_stream_status:
1482 * @src: The object originating the message.
1483 * @type: The stream status type.
1484 * @owner: (transfer none): the owner element of @src.
1486 * Create a new stream status message. This message is posted when a streaming
1487 * thread is created/destroyed or when the state changed.
1489 * Returns: (transfer full): the new stream status message.
1494 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1497 GstMessage *message;
1498 GstStructure *structure;
1500 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1501 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1502 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1503 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1509 * gst_message_parse_stream_status:
1510 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1511 * @type: (out): A pointer to hold the status type
1512 * @owner: (out) (transfer none): The owner element of the message source
1514 * Extracts the stream status type and owner the GstMessage. The returned
1515 * owner remains valid for as long as the reference to @message is valid and
1516 * should thus not be unreffed.
1521 gst_message_parse_stream_status (GstMessage * message,
1522 GstStreamStatusType * type, GstElement ** owner)
1524 const GValue *owner_gvalue;
1525 GstStructure *structure;
1527 g_return_if_fail (GST_IS_MESSAGE (message));
1528 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1530 structure = GST_MESSAGE_STRUCTURE (message);
1531 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1532 g_return_if_fail (owner_gvalue != NULL);
1535 *type = (GstStreamStatusType)
1536 g_value_get_enum (gst_structure_id_get_value (structure,
1539 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1543 * gst_message_set_stream_status_object:
1544 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1545 * @object: the object controlling the streaming
1547 * Configures the object handling the streaming thread. This is usually a
1548 * GstTask object but other objects might be added in the future.
1551 gst_message_set_stream_status_object (GstMessage * message,
1552 const GValue * object)
1554 GstStructure *structure;
1556 g_return_if_fail (GST_IS_MESSAGE (message));
1557 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1559 structure = GST_MESSAGE_STRUCTURE (message);
1560 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1564 * gst_message_get_stream_status_object:
1565 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1567 * Extracts the object managing the streaming thread from @message.
1569 * Returns: a GValue containing the object that manages the streaming thread.
1570 * This object is usually of type GstTask but other types can be added in the
1571 * future. The object remains valid as long as @message is valid.
1574 gst_message_get_stream_status_object (GstMessage * message)
1576 const GValue *result;
1577 GstStructure *structure;
1579 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1580 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1583 structure = GST_MESSAGE_STRUCTURE (message);
1584 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1590 * gst_message_new_step_done:
1591 * @src: The object originating the message.
1592 * @format: the format of @amount
1593 * @amount: the amount of stepped data
1594 * @rate: the rate of the stepped amount
1595 * @flush: is this an flushing step
1596 * @intermediate: is this an intermediate step
1597 * @duration: the duration of the data
1598 * @eos: the step caused EOS
1600 * This message is posted by elements when they complete a part, when @intermediate set
1601 * to TRUE, or a complete step operation.
1603 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1604 * @amount of media in format @format.
1606 * Returns: (transfer full): the new step_done message.
1611 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1612 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1615 GstMessage *message;
1616 GstStructure *structure;
1618 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1619 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1620 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1621 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1622 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1623 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1624 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1625 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1626 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1632 * gst_message_parse_step_done:
1633 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1634 * @format: (out) (allow-none): result location for the format
1635 * @amount: (out) (allow-none): result location for the amount
1636 * @rate: (out) (allow-none): result location for the rate
1637 * @flush: (out) (allow-none): result location for the flush flag
1638 * @intermediate: (out) (allow-none): result location for the intermediate flag
1639 * @duration: (out) (allow-none): result location for the duration
1640 * @eos: (out) (allow-none): result location for the EOS flag
1642 * Extract the values the step_done message.
1647 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1648 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1649 guint64 * duration, gboolean * eos)
1651 GstStructure *structure;
1653 g_return_if_fail (GST_IS_MESSAGE (message));
1654 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1656 structure = GST_MESSAGE_STRUCTURE (message);
1657 gst_structure_id_get (structure,
1658 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1659 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1660 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1661 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1662 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1663 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1664 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1668 * gst_message_new_step_start:
1669 * @src: The object originating the message.
1670 * @active: if the step is active or queued
1671 * @format: the format of @amount
1672 * @amount: the amount of stepped data
1673 * @rate: the rate of the stepped amount
1674 * @flush: is this an flushing step
1675 * @intermediate: is this an intermediate step
1677 * This message is posted by elements when they accept or activate a new step
1678 * event for @amount in @format.
1680 * @active is set to FALSE when the element accepted the new step event and has
1681 * queued it for execution in the streaming threads.
1683 * @active is set to TRUE when the element has activated the step operation and
1684 * is now ready to start executing the step in the streaming thread. After this
1685 * message is emited, the application can queue a new step operation in the
1688 * Returns: (transfer full): The new step_start message.
1693 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1694 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1696 GstMessage *message;
1697 GstStructure *structure;
1699 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1700 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1701 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1702 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1703 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1704 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1705 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1706 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1712 * gst_message_parse_step_start:
1713 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1714 * @active: (out) (allow-none): result location for the active flag
1715 * @format: (out) (allow-none): result location for the format
1716 * @amount: (out) (allow-none): result location for the amount
1717 * @rate: (out) (allow-none): result location for the rate
1718 * @flush: (out) (allow-none): result location for the flush flag
1719 * @intermediate: (out) (allow-none): result location for the intermediate flag
1721 * Extract the values from step_start message.
1726 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1727 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1728 gboolean * intermediate)
1730 GstStructure *structure;
1732 g_return_if_fail (GST_IS_MESSAGE (message));
1733 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1735 structure = GST_MESSAGE_STRUCTURE (message);
1736 gst_structure_id_get (structure,
1737 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1738 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1739 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1740 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1741 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1742 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1746 * gst_message_new_qos:
1747 * @src: The object originating the message.
1748 * @live: if the message was generated by a live element
1749 * @running_time: the running time of the buffer that generated the message
1750 * @stream_time: the stream time of the buffer that generated the message
1751 * @timestamp: the timestamps of the buffer that generated the message
1752 * @duration: the duration of the buffer that generated the message
1754 * A QOS message is posted on the bus whenever an element decides to drop a
1755 * buffer because of QoS reasons or whenever it changes its processing strategy
1756 * because of QoS reasons (quality adjustments such as processing at lower
1759 * This message can be posted by an element that performs synchronisation against the
1760 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1761 * events received from a downstream element (!live).
1763 * @running_time, @stream_time, @timestamp, @duration should be set to the
1764 * respective running-time, stream-time, timestamp and duration of the (dropped)
1765 * buffer that generated the QoS event. Values can be left to
1766 * GST_CLOCK_TIME_NONE when unknown.
1768 * Returns: (transfer full): The new qos message.
1773 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1774 guint64 stream_time, guint64 timestamp, guint64 duration)
1776 GstMessage *message;
1777 GstStructure *structure;
1779 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1780 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1781 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1782 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1783 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1784 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1785 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1786 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1787 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1788 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1789 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1790 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1791 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1797 * gst_message_set_qos_values:
1798 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1799 * @jitter: The difference of the running-time against the deadline.
1800 * @proportion: Long term prediction of the ideal rate relative to normal rate
1801 * to get optimal quality.
1802 * @quality: An element dependent integer value that specifies the current
1803 * quality level of the element. The default maximum quality is 1000000.
1805 * Set the QoS values that have been calculated/analysed from the QoS data
1810 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1811 gdouble proportion, gint quality)
1813 GstStructure *structure;
1815 g_return_if_fail (GST_IS_MESSAGE (message));
1816 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1818 structure = GST_MESSAGE_STRUCTURE (message);
1819 gst_structure_id_set (structure,
1820 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1821 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1822 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1826 * gst_message_set_qos_stats:
1827 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1828 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1829 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1830 * will likely use GST_FORMAT_DEFAULT (samples).
1831 * @processed: Total number of units correctly processed since the last state
1832 * change to READY or a flushing operation.
1833 * @dropped: Total number of units dropped since the last state change to READY
1834 * or a flushing operation.
1836 * Set the QoS stats representing the history of the current continuous pipeline
1839 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1840 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1845 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1846 guint64 processed, guint64 dropped)
1848 GstStructure *structure;
1850 g_return_if_fail (GST_IS_MESSAGE (message));
1851 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1853 structure = GST_MESSAGE_STRUCTURE (message);
1854 gst_structure_id_set (structure,
1855 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1856 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1857 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1861 * gst_message_parse_qos:
1862 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1863 * @live: (out) (allow-none): if the message was generated by a live element
1864 * @running_time: (out) (allow-none): the running time of the buffer that
1865 * generated the message
1866 * @stream_time: (out) (allow-none): the stream time of the buffer that
1867 * generated the message
1868 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1869 * generated the message
1870 * @duration: (out) (allow-none): the duration of the buffer that
1871 * generated the message
1873 * Extract the timestamps and live status from the QoS message.
1875 * The returned values give the running_time, stream_time, timestamp and
1876 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1882 gst_message_parse_qos (GstMessage * message, gboolean * live,
1883 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1886 GstStructure *structure;
1888 g_return_if_fail (GST_IS_MESSAGE (message));
1889 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1891 structure = GST_MESSAGE_STRUCTURE (message);
1892 gst_structure_id_get (structure,
1893 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1894 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1895 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1896 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1897 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1901 * gst_message_parse_qos_values:
1902 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1903 * @jitter: (out) (allow-none): The difference of the running-time against
1905 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1906 * relative to normal rate to get optimal quality.
1907 * @quality: (out) (allow-none): An element dependent integer value that
1908 * specifies the current quality level of the element. The default
1909 * maximum quality is 1000000.
1911 * Extract the QoS values that have been calculated/analysed from the QoS data
1916 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1917 gdouble * proportion, gint * quality)
1919 GstStructure *structure;
1921 g_return_if_fail (GST_IS_MESSAGE (message));
1922 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1924 structure = GST_MESSAGE_STRUCTURE (message);
1925 gst_structure_id_get (structure,
1926 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1927 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1928 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1932 * gst_message_parse_qos_stats:
1933 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1934 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1935 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1936 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1938 * @processed: (out) (allow-none): Total number of units correctly processed
1939 * since the last state change to READY or a flushing operation.
1940 * @dropped: (out) (allow-none): Total number of units dropped since the last
1941 * state change to READY or a flushing operation.
1943 * Extract the QoS stats representing the history of the current continuous
1944 * pipeline playback period.
1946 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1947 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1952 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1953 guint64 * processed, guint64 * dropped)
1955 GstStructure *structure;
1957 g_return_if_fail (GST_IS_MESSAGE (message));
1958 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1960 structure = GST_MESSAGE_STRUCTURE (message);
1961 gst_structure_id_get (structure,
1962 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1963 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1964 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1968 * gst_message_new_progress:
1969 * @src: The object originating the message.
1970 * @type: a #GstProgressType
1971 * @code: a progress code
1972 * @text: free, user visible text describing the progress
1974 * Progress messages are posted by elements when they use an asynchronous task
1975 * to perform actions triggered by a state change.
1977 * @code contains a well defined string describing the action.
1978 * @test should contain a user visible string detailing the current action.
1980 * Returns: (transfer full): The new qos message.
1983 gst_message_new_progress (GstObject * src, GstProgressType type,
1984 const gchar * code, const gchar * text)
1986 GstMessage *message;
1987 GstStructure *structure;
1988 gint percent = 100, timeout = -1;
1990 g_return_val_if_fail (code != NULL, NULL);
1991 g_return_val_if_fail (text != NULL, NULL);
1993 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
1996 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
1997 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
1998 GST_QUARK (CODE), G_TYPE_STRING, code,
1999 GST_QUARK (TEXT), G_TYPE_STRING, text,
2000 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2001 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2002 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2008 * gst_message_parse_progress:
2009 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2010 * @type: (out) (allow-none): location for the type
2011 * @code: (out) (allow-none) (transfer full): location for the code
2012 * @text: (out) (allow-none) (transfer full): location for the text
2014 * Parses the progress @type, @code and @text.
2017 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2018 gchar ** code, gchar ** text)
2020 GstStructure *structure;
2022 g_return_if_fail (GST_IS_MESSAGE (message));
2023 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2025 structure = GST_MESSAGE_STRUCTURE (message);
2026 gst_structure_id_get (structure,
2027 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2028 GST_QUARK (CODE), G_TYPE_STRING, code,
2029 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2033 * gst_message_new_toc:
2034 * @src: the object originating the message.
2035 * @toc: (transfer none): #GstToc structure for the message.
2036 * @updated: whether TOC was updated or not.
2038 * Create a new TOC message. The message is posted by elements
2039 * that discovered or updated a TOC.
2041 * Returns: (transfer full): a new TOC message.
2046 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2048 GstStructure *toc_struct;
2050 g_return_val_if_fail (toc != NULL, NULL);
2052 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2053 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2054 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2056 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2060 * gst_message_parse_toc:
2061 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2062 * @toc: (out) (transfer full): return location for the TOC.
2063 * @updated: (out): return location for the updated flag.
2065 * Extract thef TOC from the #GstMessage. The TOC returned in the
2066 * output argument is a copy; the caller must free it with
2067 * gst_toc_unref() when done.
2072 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2074 g_return_if_fail (GST_IS_MESSAGE (message));
2075 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2076 g_return_if_fail (toc != NULL);
2078 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2079 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2080 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2084 * gst_message_new_reset_time:
2085 * @src: (transfer none): The object originating the message.
2086 * @running_time: the requested running-time
2088 * This message is posted when the pipeline running-time should be reset to
2089 * @running_time, like after a flushing seek.
2091 * Returns: (transfer full): The new reset_time message.
2096 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2098 GstMessage *message;
2099 GstStructure *structure;
2101 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2102 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2103 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2109 * gst_message_parse_reset_time:
2110 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2111 * @running_time: (out) (allow-none): Result location for the running_time or
2114 * Extract the running-time from the RESET_TIME message.
2119 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2121 GstStructure *structure;
2123 g_return_if_fail (GST_IS_MESSAGE (message));
2124 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2126 structure = GST_MESSAGE_STRUCTURE (message);
2129 g_value_get_uint64 (gst_structure_id_get_value (structure,
2130 GST_QUARK (RUNNING_TIME)));
2134 * gst_message_new_stream_start:
2135 * @src: (transfer none): The object originating the message.
2137 * Create a new stream_start message. This message is generated and posted in
2138 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2139 * message to the application if all sinks have posted an STREAM_START message.
2141 * Returns: (transfer full): The new stream_start message.
2146 gst_message_new_stream_start (GstObject * src)
2148 GstMessage *message;
2151 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2152 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2159 * gst_message_set_group_id:
2160 * @message: the message
2161 * @group_id: the group id
2163 * Sets the group id on the stream-start message.
2165 * All streams that have the same group id are supposed to be played
2166 * together, i.e. all streams inside a container file should have the
2167 * same group id but different stream ids. The group id should change
2168 * each time the stream is started, resulting in different group ids
2169 * each time a file is played for example.
2176 gst_message_set_group_id (GstMessage * message, guint group_id)
2178 GstStructure *structure;
2180 g_return_if_fail (GST_IS_MESSAGE (message));
2181 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2182 g_return_if_fail (gst_message_is_writable (message));
2184 structure = GST_MESSAGE_STRUCTURE (message);
2185 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2190 * gst_message_parse_group_id:
2191 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2192 * @group_id: (out) (allow-none): Result location for the group id or
2195 * Extract the group from the STREAM_START message.
2197 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2204 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2206 GstStructure *structure;
2209 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2210 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2216 structure = GST_MESSAGE_STRUCTURE (message);
2218 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2222 *group_id = g_value_get_uint (v);
2227 * gst_message_new_need_context:
2228 * @src: (transfer none): The object originating the message.
2229 * @context_type: The context type that is needed
2231 * This message is posted when an element needs a specific #GstContext.
2233 * Returns: (transfer full): The new need-context message.
2240 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2242 GstMessage *message;
2243 GstStructure *structure;
2245 g_return_val_if_fail (context_type != NULL, NULL);
2247 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2248 GST_QUARK (CONTEXT_TYPE), context_type, NULL);
2249 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2255 * gst_message_parse_context_type:
2256 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2257 * @context_type: (out) (allow-none): the context type, or NULL
2259 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2261 * Returns: a #gboolean indicating if the parsing succeeded.
2266 gst_message_parse_context_type (GstMessage * message,
2267 const gchar ** context_type)
2269 GstStructure *structure;
2270 const GValue *value;
2272 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2275 structure = GST_MESSAGE_STRUCTURE (message);
2278 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2279 *context_type = g_value_get_string (value);
2286 * gst_message_new_have_context:
2287 * @src: (transfer none): The object originating the message.
2288 * @context: (transfer full): the context
2290 * This message is posted when an element has a new local #GstContext.
2292 * Returns: (transfer full): The new have-context message.
2299 gst_message_new_have_context (GstObject * src, GstContext * context)
2301 GstMessage *message;
2302 GstStructure *structure;
2304 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2305 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2306 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2307 gst_context_unref (context);
2313 * gst_message_parse_have_context:
2314 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2315 * @context: (out) (transfer full) (allow-none): Result location for the
2318 * Extract the context from the HAVE_CONTEXT message.
2325 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2327 g_return_if_fail (GST_IS_MESSAGE (message));
2328 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2331 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2332 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);