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:
38 * gst_bus_post (bus, gst_message_new_eos());
41 * A #GstElement usually posts messages on the bus provided by the parent
42 * container using gst_element_post_message().
46 #include "gst_private.h"
47 #include <string.h> /* memcpy */
49 #include "gstenumtypes.h"
51 #include "gstmessage.h"
52 #include "gsttaglist.h"
61 GstStructure *structure;
64 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
73 static GstMessageQuarks message_quarks[] = {
74 {GST_MESSAGE_UNKNOWN, "unknown", 0},
75 {GST_MESSAGE_EOS, "eos", 0},
76 {GST_MESSAGE_ERROR, "error", 0},
77 {GST_MESSAGE_WARNING, "warning", 0},
78 {GST_MESSAGE_INFO, "info", 0},
79 {GST_MESSAGE_TAG, "tag", 0},
80 {GST_MESSAGE_BUFFERING, "buffering", 0},
81 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
82 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
83 {GST_MESSAGE_STEP_DONE, "step-done", 0},
84 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
85 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
86 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
87 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
88 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
89 {GST_MESSAGE_APPLICATION, "application", 0},
90 {GST_MESSAGE_ELEMENT, "element", 0},
91 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
92 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
93 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
94 {GST_MESSAGE_LATENCY, "latency", 0},
95 {GST_MESSAGE_ASYNC_START, "async-start", 0},
96 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
97 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
98 {GST_MESSAGE_STEP_START, "step-start", 0},
99 {GST_MESSAGE_QOS, "qos", 0},
100 {GST_MESSAGE_PROGRESS, "progress", 0},
101 {GST_MESSAGE_TOC, "toc", 0},
102 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
103 {GST_MESSAGE_STREAM_START, "stream-start", 0},
104 {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
105 {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
106 {GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
107 {GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
111 GType _gst_message_type = 0;
112 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
115 _priv_gst_message_initialize (void)
119 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
121 /* the GstMiniObject types need to be class_ref'd once before it can be
122 * done from multiple threads;
123 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */
124 gst_message_get_type ();
126 for (i = 0; message_quarks[i].name; i++) {
127 message_quarks[i].quark =
128 g_quark_from_static_string (message_quarks[i].name);
131 _gst_message_type = gst_message_get_type ();
135 * gst_message_type_get_name:
136 * @type: the message type
138 * Get a printable name for the given message type. Do not modify or free.
140 * Returns: a reference to the static name of the message.
143 gst_message_type_get_name (GstMessageType type)
147 for (i = 0; message_quarks[i].name; i++) {
148 if (type == message_quarks[i].type)
149 return message_quarks[i].name;
155 * gst_message_type_to_quark:
156 * @type: the message type
158 * Get the unique quark for the given message type.
160 * Returns: the quark associated with the message type
163 gst_message_type_to_quark (GstMessageType type)
167 for (i = 0; message_quarks[i].name; i++) {
168 if (type == message_quarks[i].type)
169 return message_quarks[i].quark;
175 _gst_message_free (GstMessage * message)
177 GstStructure *structure;
179 g_return_if_fail (message != NULL);
181 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
182 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
184 if (GST_MESSAGE_SRC (message)) {
185 gst_object_unref (GST_MESSAGE_SRC (message));
186 GST_MESSAGE_SRC (message) = NULL;
189 if (message->lock.p) {
190 GST_MESSAGE_LOCK (message);
191 GST_MESSAGE_SIGNAL (message);
192 GST_MESSAGE_UNLOCK (message);
195 structure = GST_MESSAGE_STRUCTURE (message);
197 gst_structure_set_parent_refcount (structure, NULL);
198 gst_structure_free (structure);
201 g_slice_free1 (sizeof (GstMessageImpl), message);
205 gst_message_init (GstMessageImpl * message, GstMessageType type,
209 _gst_message_copy (GstMessage * message)
211 GstMessageImpl *copy;
212 GstStructure *structure;
214 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
215 GST_MESSAGE_TYPE_NAME (message),
216 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
218 copy = g_slice_new0 (GstMessageImpl);
220 gst_message_init (copy, GST_MESSAGE_TYPE (message),
221 GST_MESSAGE_SRC (message));
223 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
224 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
226 structure = GST_MESSAGE_STRUCTURE (message);
228 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
229 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
230 ©->message.mini_object.refcount);
232 GST_MESSAGE_STRUCTURE (copy) = NULL;
235 return GST_MESSAGE_CAST (copy);
239 gst_message_init (GstMessageImpl * message, GstMessageType type,
242 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
243 (GstMiniObjectCopyFunction) _gst_message_copy, NULL,
244 (GstMiniObjectFreeFunction) _gst_message_free);
246 GST_MESSAGE_TYPE (message) = type;
248 gst_object_ref (src);
249 GST_MESSAGE_SRC (message) = src;
250 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
251 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
256 * gst_message_new_custom:
257 * @type: The #GstMessageType to distinguish messages
258 * @src: The object originating the message.
259 * @structure: (transfer full) (allow-none): the structure for the
260 * message. The message will take ownership of the structure.
262 * Create a new custom-typed message. This can be used for anything not
263 * handled by other message-specific functions to pass a message to the
264 * app. The structure field can be %NULL.
266 * Returns: (transfer full): The new message.
271 gst_message_new_custom (GstMessageType type, GstObject * src,
272 GstStructure * structure)
274 GstMessageImpl *message;
276 message = g_slice_new0 (GstMessageImpl);
278 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
279 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
280 gst_message_type_get_name (type));
283 /* structure must not have a parent */
284 if (!gst_structure_set_parent_refcount (structure,
285 &message->message.mini_object.refcount))
288 gst_message_init (message, type, src);
290 GST_MESSAGE_STRUCTURE (message) = structure;
292 return GST_MESSAGE_CAST (message);
297 g_slice_free1 (sizeof (GstMessageImpl), message);
298 g_warning ("structure is already owned by another object");
304 * gst_message_get_seqnum:
305 * @message: A #GstMessage.
307 * Retrieve the sequence number of a message.
309 * Messages have ever-incrementing sequence numbers, which may also be set
310 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
311 * to indicate that a message corresponds to some other set of messages or
312 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
313 * is considered good practice to make this correspondence when possible, though
314 * it is not required.
316 * Note that events and messages share the same sequence number incrementor;
317 * two events or messages will never have the same sequence number unless
318 * that correspondence was made explicitly.
320 * Returns: The message's sequence number.
325 gst_message_get_seqnum (GstMessage * message)
327 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
329 return GST_MESSAGE_SEQNUM (message);
333 * gst_message_set_seqnum:
334 * @message: A #GstMessage.
335 * @seqnum: A sequence number.
337 * Set the sequence number of a message.
339 * This function might be called by the creator of a message to indicate that
340 * the message relates to other messages or events. See gst_message_get_seqnum()
341 * for more information.
346 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
348 g_return_if_fail (GST_IS_MESSAGE (message));
350 GST_MESSAGE_SEQNUM (message) = seqnum;
354 * gst_message_new_eos:
355 * @src: (transfer none): The object originating the message.
357 * Create a new eos message. This message is generated and posted in
358 * the sink elements of a GstBin. The bin will only forward the EOS
359 * message to the application if all sinks have posted an EOS message.
361 * Returns: (transfer full): The new eos message.
366 gst_message_new_eos (GstObject * src)
370 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
376 * gst_message_new_error:
377 * @src: (transfer none): The object originating the message.
378 * @error: (transfer none): The GError for this message.
379 * @debug: A debugging string.
381 * Create a new error message. The message will copy @error and
382 * @debug. This message is posted by element when a fatal event
383 * occurred. The pipeline will probably (partially) stop. The application
384 * receiving this message should stop the pipeline.
386 * Returns: (transfer full): the new error message.
391 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
394 GstStructure *structure;
396 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
397 GST_QUARK (GERROR), G_TYPE_ERROR, error,
398 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
399 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
405 * gst_message_new_warning:
406 * @src: (transfer none): The object originating the message.
407 * @error: (transfer none): The GError for this message.
408 * @debug: A debugging string.
410 * Create a new warning message. The message will make copies of @error and
413 * Returns: (transfer full): The new warning message.
418 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
421 GstStructure *structure;
423 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
424 GST_QUARK (GERROR), G_TYPE_ERROR, error,
425 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
426 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
432 * gst_message_new_info:
433 * @src: (transfer none): The object originating the message.
434 * @error: (transfer none): The GError for this message.
435 * @debug: A debugging string.
437 * Create a new info message. The message will make copies of @error and
442 * Returns: (transfer full): the new info message.
445 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
448 GstStructure *structure;
450 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
451 GST_QUARK (GERROR), G_TYPE_ERROR, error,
452 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
453 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
459 * gst_message_new_tag:
460 * @src: (transfer none): The object originating the message.
461 * @tag_list: (transfer full): the tag list for the message.
463 * Create a new tag message. The message will take ownership of the tag list.
464 * The message is posted by elements that discovered a new taglist.
466 * Returns: (transfer full): the new tag message.
471 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
475 GValue val = G_VALUE_INIT;
477 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
479 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
480 g_value_init (&val, GST_TYPE_TAG_LIST);
481 g_value_take_boxed (&val, tag_list);
482 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
483 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
488 * gst_message_new_buffering:
489 * @src: (transfer none): The object originating the message.
490 * @percent: The buffering percent
492 * Create a new buffering message. This message can be posted by an element that
493 * needs to buffer data before it can continue processing. @percent should be a
494 * value between 0 and 100. A value of 100 means that the buffering completed.
496 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
497 * @percent is 100, the application can set the pipeline (back) to PLAYING.
498 * The application must be prepared to receive BUFFERING messages in the
499 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
500 * message with @percent set to 100, which can happen after the pipeline
501 * completed prerolling.
505 * Returns: (transfer full): The new buffering message.
508 gst_message_new_buffering (GstObject * src, gint percent)
511 GstStructure *structure;
512 gint64 buffering_left;
514 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
516 buffering_left = (percent == 100 ? 0 : -1);
518 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
519 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
520 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
521 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
522 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
523 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
524 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
530 * gst_message_new_state_changed:
531 * @src: (transfer none): the object originating the message
532 * @oldstate: the previous state
533 * @newstate: the new (current) state
534 * @pending: the pending (target) state
536 * Create a state change message. This message is posted whenever an element
539 * Returns: (transfer full): the new state change message.
544 gst_message_new_state_changed (GstObject * src,
545 GstState oldstate, GstState newstate, GstState pending)
548 GstStructure *structure;
550 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
551 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
552 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
553 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
554 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
560 * gst_message_new_state_dirty:
561 * @src: (transfer none): the object originating the message
563 * Create a state dirty message. This message is posted whenever an element
564 * changed its state asynchronously and is used internally to update the
565 * states of container objects.
567 * Returns: (transfer full): the new state dirty message.
572 gst_message_new_state_dirty (GstObject * src)
576 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
582 * gst_message_new_clock_provide:
583 * @src: (transfer none): the object originating the message.
584 * @clock: (transfer none): the clock it provides
585 * @ready: %TRUE if the sender can provide a clock
587 * Create a clock provide message. This message is posted whenever an
588 * element is ready to provide a clock or lost its ability to provide
589 * a clock (maybe because it paused or became EOS).
591 * This message is mainly used internally to manage the clock
594 * Returns: (transfer full): the new provide clock message.
599 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
603 GstStructure *structure;
605 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
606 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
607 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
608 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
614 * gst_message_new_clock_lost:
615 * @src: (transfer none): the object originating the message.
616 * @clock: (transfer none): the clock that was lost
618 * Create a clock lost message. This message is posted whenever the
619 * clock is not valid anymore.
621 * If this message is posted by the pipeline, the pipeline will
622 * select a new clock again when it goes to PLAYING. It might therefore
623 * be needed to set the pipeline to PAUSED and PLAYING again.
625 * Returns: (transfer full): The new clock lost message.
630 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
633 GstStructure *structure;
635 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
636 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
637 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
643 * gst_message_new_new_clock:
644 * @src: (transfer none): The object originating the message.
645 * @clock: (transfer none): the new selected clock
647 * Create a new clock message. This message is posted whenever the
648 * pipeline selects a new clock for the pipeline.
650 * Returns: (transfer full): The new new clock message.
655 gst_message_new_new_clock (GstObject * src, GstClock * clock)
658 GstStructure *structure;
660 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
661 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
662 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
668 * gst_message_new_structure_change:
669 * @src: (transfer none): The object originating the message.
670 * @type: The change type.
671 * @owner: (transfer none): The owner element of @src.
672 * @busy: Whether the structure change is busy.
674 * Create a new structure change message. This message is posted when the
675 * structure of a pipeline is in the process of being changed, for example
676 * when pads are linked or unlinked.
678 * @src should be the sinkpad that unlinked or linked.
680 * Returns: (transfer full): the new structure change message.
685 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
686 GstElement * owner, gboolean busy)
689 GstStructure *structure;
691 g_return_val_if_fail (GST_IS_PAD (src), NULL);
692 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
693 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
695 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
696 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
697 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
698 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
700 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
707 * gst_message_new_segment_start:
708 * @src: (transfer none): The object originating the message.
709 * @format: The format of the position being played
710 * @position: The position of the segment being played
712 * Create a new segment message. This message is posted by elements that
713 * start playback of a segment as a result of a segment seek. This message
714 * is not received by the application but is used for maintenance reasons in
715 * container elements.
717 * Returns: (transfer full): the new segment start message.
722 gst_message_new_segment_start (GstObject * src, GstFormat format,
726 GstStructure *structure;
728 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
729 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
730 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
731 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
737 * gst_message_new_segment_done:
738 * @src: (transfer none): the object originating the message.
739 * @format: The format of the position being done
740 * @position: The position of the segment being done
742 * Create a new segment done message. This message is posted by elements that
743 * finish playback of a segment as a result of a segment seek. This message
744 * is received by the application after all elements that posted a segment_start
745 * have posted the segment_done.
747 * Returns: (transfer full): the new segment done message.
752 gst_message_new_segment_done (GstObject * src, GstFormat format,
756 GstStructure *structure;
758 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
759 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
760 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
761 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
767 * gst_message_new_application:
768 * @src: (transfer none): the object originating the message.
769 * @structure: (transfer full): the structure for the message. The message
770 * will take ownership of the structure.
772 * Create a new application-typed message. GStreamer will never create these
773 * messages; they are a gift from us to you. Enjoy.
775 * Returns: (transfer full): The new application message.
780 gst_message_new_application (GstObject * src, GstStructure * structure)
782 g_return_val_if_fail (structure != NULL, NULL);
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
791 * message. The message 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 g_return_val_if_fail (structure != NULL, NULL);
807 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
811 * gst_message_new_duration_changed:
812 * @src: (transfer none): The object originating the message.
814 * Create a new duration changed message. This message is posted by elements
815 * that know the duration of a stream when the duration changes. This message
816 * is received by bins and is used to calculate the total duration of a
817 * pipeline. Elements may post a duration message with a duration of
818 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
819 * cached duration should be discarded. The new duration can then be
820 * retrieved via a query.
822 * Returns: (transfer full): The new duration-changed message.
827 gst_message_new_duration_changed (GstObject * src)
831 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
832 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
838 * gst_message_new_async_start:
839 * @src: (transfer none): The object originating the message.
841 * This message is posted by elements when they start an ASYNC state change.
843 * Returns: (transfer full): The new async_start message.
848 gst_message_new_async_start (GstObject * src)
852 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
858 * gst_message_new_async_done:
859 * @src: (transfer none): The object originating the message.
860 * @running_time: the desired running_time
862 * The message is posted when elements completed an ASYNC state change.
863 * @running_time contains the time of the desired running_time when this
864 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
865 * means that the element has no clock interaction and thus doesn't care about
866 * the running_time of the pipeline.
868 * Returns: (transfer full): The new async_done message.
873 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
876 GstStructure *structure;
878 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
879 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
880 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
886 * gst_message_new_latency:
887 * @src: (transfer none): The object originating the message.
889 * This message can be posted by elements when their latency requirements have
892 * Returns: (transfer full): The new latency message.
897 gst_message_new_latency (GstObject * src)
901 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
907 * gst_message_new_request_state:
908 * @src: (transfer none): the object originating the message.
909 * @state: The new requested state
911 * This message can be posted by elements when they want to have their state
912 * changed. A typical use case would be an audio server that wants to pause the
913 * pipeline because a higher priority stream is being played.
915 * Returns: (transfer full): the new request state message.
920 gst_message_new_request_state (GstObject * src, GstState state)
923 GstStructure *structure;
925 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
926 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
927 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
933 * gst_message_get_structure:
934 * @message: The #GstMessage.
936 * Access the structure of the message.
938 * Returns: (transfer none): The structure of the message. The structure is
939 * still owned by the message, which means that you should not free it and
940 * that the pointer becomes invalid when you free the message.
945 gst_message_get_structure (GstMessage * message)
947 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
949 return GST_MESSAGE_STRUCTURE (message);
953 * gst_message_has_name:
954 * @message: The #GstMessage.
955 * @name: name to check
957 * Checks if @message has the given @name. This function is usually used to
958 * check the name of a custom message.
960 * Returns: %TRUE if @name matches the name of the message structure.
963 gst_message_has_name (GstMessage * message, const gchar * name)
965 GstStructure *structure;
967 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
969 structure = GST_MESSAGE_STRUCTURE (message);
970 if (structure == NULL)
973 return gst_structure_has_name (structure, name);
977 * gst_message_parse_tag:
978 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
979 * @tag_list: (out callee-allocates): return location for the tag-list.
981 * Extracts the tag list from the GstMessage. The tag list returned in the
982 * output argument is a copy; the caller must free it when done.
984 * Typical usage of this function might be:
987 * switch (GST_MESSAGE_TYPE (msg)) {
988 * case GST_MESSAGE_TAG: {
989 * GstTagList *tags = NULL;
991 * gst_message_parse_tag (msg, &tags);
992 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
993 * handle_tags (tags);
994 * gst_tag_list_unref (tags);
1005 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1007 g_return_if_fail (GST_IS_MESSAGE (message));
1008 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1009 g_return_if_fail (tag_list != NULL);
1011 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1012 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1016 * gst_message_parse_buffering:
1017 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1018 * @percent: (out) (allow-none): Return location for the percent.
1020 * Extracts the buffering percent from the GstMessage. see also
1021 * gst_message_new_buffering().
1026 gst_message_parse_buffering (GstMessage * message, gint * percent)
1028 g_return_if_fail (GST_IS_MESSAGE (message));
1029 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1033 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1034 (message), GST_QUARK (BUFFER_PERCENT)));
1038 * gst_message_set_buffering_stats:
1039 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1040 * @mode: a buffering mode
1041 * @avg_in: the average input rate
1042 * @avg_out: the average output rate
1043 * @buffering_left: amount of buffering time left in milliseconds
1045 * Configures the buffering stats values in @message.
1048 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1049 gint avg_in, gint avg_out, gint64 buffering_left)
1051 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1053 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1054 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1055 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1056 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1057 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1061 * gst_message_parse_buffering_stats:
1062 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1063 * @mode: (out) (allow-none): a buffering mode, or %NULL
1064 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1065 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1066 * @buffering_left: (out) (allow-none): amount of buffering time left in
1067 * milliseconds, or %NULL
1069 * Extracts the buffering stats values from @message.
1072 gst_message_parse_buffering_stats (GstMessage * message,
1073 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1074 gint64 * buffering_left)
1076 GstStructure *structure;
1078 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1080 structure = GST_MESSAGE_STRUCTURE (message);
1082 *mode = (GstBufferingMode)
1083 g_value_get_enum (gst_structure_id_get_value (structure,
1084 GST_QUARK (BUFFERING_MODE)));
1086 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1087 GST_QUARK (AVG_IN_RATE)));
1089 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1090 GST_QUARK (AVG_OUT_RATE)));
1093 g_value_get_int64 (gst_structure_id_get_value (structure,
1094 GST_QUARK (BUFFERING_LEFT)));
1098 * gst_message_parse_state_changed:
1099 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1100 * @oldstate: (out) (allow-none): the previous state, or %NULL
1101 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1102 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1104 * Extracts the old and new states from the GstMessage.
1106 * Typical usage of this function might be:
1109 * switch (GST_MESSAGE_TYPE (msg)) {
1110 * case GST_MESSAGE_STATE_CHANGED: {
1111 * GstState old_state, new_state;
1113 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1114 * g_print ("Element %s changed state from %s to %s.\n",
1115 * GST_OBJECT_NAME (msg->src),
1116 * gst_element_state_get_name (old_state),
1117 * gst_element_state_get_name (new_state));
1128 gst_message_parse_state_changed (GstMessage * message,
1129 GstState * oldstate, GstState * newstate, GstState * pending)
1131 GstStructure *structure;
1133 g_return_if_fail (GST_IS_MESSAGE (message));
1134 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1136 structure = GST_MESSAGE_STRUCTURE (message);
1138 *oldstate = (GstState)
1139 g_value_get_enum (gst_structure_id_get_value (structure,
1140 GST_QUARK (OLD_STATE)));
1142 *newstate = (GstState)
1143 g_value_get_enum (gst_structure_id_get_value (structure,
1144 GST_QUARK (NEW_STATE)));
1146 *pending = (GstState)
1147 g_value_get_enum (gst_structure_id_get_value (structure,
1148 GST_QUARK (PENDING_STATE)));
1152 * gst_message_parse_clock_provide:
1153 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1154 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1156 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1158 * Extracts the clock and ready flag from the GstMessage.
1159 * The clock object returned remains valid until the message is freed.
1164 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1167 const GValue *clock_gvalue;
1168 GstStructure *structure;
1170 g_return_if_fail (GST_IS_MESSAGE (message));
1171 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1173 structure = GST_MESSAGE_STRUCTURE (message);
1174 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1175 g_return_if_fail (clock_gvalue != NULL);
1176 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1180 g_value_get_boolean (gst_structure_id_get_value (structure,
1181 GST_QUARK (READY)));
1183 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1187 * gst_message_parse_clock_lost:
1188 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1189 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1191 * Extracts the lost clock from the GstMessage.
1192 * The clock object returned remains valid until the message is freed.
1197 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1199 const GValue *clock_gvalue;
1200 GstStructure *structure;
1202 g_return_if_fail (GST_IS_MESSAGE (message));
1203 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1205 structure = GST_MESSAGE_STRUCTURE (message);
1206 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1207 g_return_if_fail (clock_gvalue != NULL);
1208 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1211 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1215 * gst_message_parse_new_clock:
1216 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1217 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1220 * Extracts the new clock from the GstMessage.
1221 * The clock object returned remains valid until the message is freed.
1226 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1228 const GValue *clock_gvalue;
1229 GstStructure *structure;
1231 g_return_if_fail (GST_IS_MESSAGE (message));
1232 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1234 structure = GST_MESSAGE_STRUCTURE (message);
1235 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1236 g_return_if_fail (clock_gvalue != NULL);
1237 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1240 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1244 * gst_message_parse_structure_change:
1245 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1246 * @type: (out): A pointer to hold the change type
1247 * @owner: (out) (allow-none) (transfer none): The owner element of the
1249 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1250 * progress or has been completed
1252 * Extracts the change type and completion status from the GstMessage.
1257 gst_message_parse_structure_change (GstMessage * message,
1258 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1260 const GValue *owner_gvalue;
1261 GstStructure *structure;
1263 g_return_if_fail (GST_IS_MESSAGE (message));
1264 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1266 structure = GST_MESSAGE_STRUCTURE (message);
1267 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1268 g_return_if_fail (owner_gvalue != NULL);
1269 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1272 *type = (GstStructureChangeType)
1273 g_value_get_enum (gst_structure_id_get_value (structure,
1276 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1279 g_value_get_boolean (gst_structure_id_get_value (structure,
1284 * gst_message_parse_error:
1285 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1286 * @gerror: (out) (allow-none) (transfer full): location for the GError
1287 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1290 * Extracts the GError and debug string from the GstMessage. The values returned
1291 * in the output arguments are copies; the caller must free them when done.
1293 * Typical usage of this function might be:
1296 * switch (GST_MESSAGE_TYPE (msg)) {
1297 * case GST_MESSAGE_ERROR: {
1298 * GError *err = NULL;
1299 * gchar *dbg_info = NULL;
1301 * gst_message_parse_error (msg, &err, &dbg_info);
1302 * g_printerr ("ERROR from element %s: %s\n",
1303 * GST_OBJECT_NAME (msg->src), err->message);
1304 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1305 * g_error_free (err);
1306 * g_free (dbg_info);
1317 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1319 g_return_if_fail (GST_IS_MESSAGE (message));
1320 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1322 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1323 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1324 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1328 * gst_message_parse_warning:
1329 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1330 * @gerror: (out) (allow-none) (transfer full): location for the GError
1331 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1334 * Extracts the GError and debug string from the GstMessage. The values returned
1335 * in the output arguments are copies; the caller must free them when done.
1340 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1343 g_return_if_fail (GST_IS_MESSAGE (message));
1344 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1346 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1347 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1348 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1352 * gst_message_parse_info:
1353 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1354 * @gerror: (out) (allow-none) (transfer full): location for the GError
1355 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1358 * Extracts the GError and debug string from the GstMessage. The values returned
1359 * in the output arguments are copies; the caller must free them when done.
1364 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1366 g_return_if_fail (GST_IS_MESSAGE (message));
1367 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1369 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1370 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1371 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1375 * gst_message_parse_segment_start:
1376 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1377 * @format: (out) (allow-none): Result location for the format, or %NULL
1378 * @position: (out) (allow-none): Result location for the position, or %NULL
1380 * Extracts the position and format from the segment start message.
1385 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1388 GstStructure *structure;
1390 g_return_if_fail (GST_IS_MESSAGE (message));
1391 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1393 structure = GST_MESSAGE_STRUCTURE (message);
1395 *format = (GstFormat)
1396 g_value_get_enum (gst_structure_id_get_value (structure,
1397 GST_QUARK (FORMAT)));
1400 g_value_get_int64 (gst_structure_id_get_value (structure,
1401 GST_QUARK (POSITION)));
1405 * gst_message_parse_segment_done:
1406 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1407 * @format: (out) (allow-none): Result location for the format, or %NULL
1408 * @position: (out) (allow-none): Result location for the position, or %NULL
1410 * Extracts the position and format from the segment done message.
1415 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1418 GstStructure *structure;
1420 g_return_if_fail (GST_IS_MESSAGE (message));
1421 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1423 structure = GST_MESSAGE_STRUCTURE (message);
1425 *format = (GstFormat)
1426 g_value_get_enum (gst_structure_id_get_value (structure,
1427 GST_QUARK (FORMAT)));
1430 g_value_get_int64 (gst_structure_id_get_value (structure,
1431 GST_QUARK (POSITION)));
1435 * gst_message_parse_async_done:
1436 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1437 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1439 * Extract the running_time from the async_done message.
1444 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1446 GstStructure *structure;
1448 g_return_if_fail (GST_IS_MESSAGE (message));
1449 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1451 structure = GST_MESSAGE_STRUCTURE (message);
1454 g_value_get_uint64 (gst_structure_id_get_value (structure,
1455 GST_QUARK (RUNNING_TIME)));
1459 * gst_message_parse_request_state:
1460 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1461 * @state: (out) (allow-none): Result location for the requested state or %NULL
1463 * Extract the requested state from the request_state message.
1468 gst_message_parse_request_state (GstMessage * message, GstState * state)
1470 GstStructure *structure;
1472 g_return_if_fail (GST_IS_MESSAGE (message));
1473 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1475 structure = GST_MESSAGE_STRUCTURE (message);
1478 g_value_get_enum (gst_structure_id_get_value (structure,
1479 GST_QUARK (NEW_STATE)));
1483 * gst_message_new_stream_status:
1484 * @src: The object originating the message.
1485 * @type: The stream status type.
1486 * @owner: (transfer none): the owner element of @src.
1488 * Create a new stream status message. This message is posted when a streaming
1489 * thread is created/destroyed or when the state changed.
1491 * Returns: (transfer full): the new stream status message.
1496 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1499 GstMessage *message;
1500 GstStructure *structure;
1502 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1503 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1504 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1505 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1511 * gst_message_parse_stream_status:
1512 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1513 * @type: (out): A pointer to hold the status type
1514 * @owner: (out) (transfer none): The owner element of the message source
1516 * Extracts the stream status type and owner the GstMessage. The returned
1517 * owner remains valid for as long as the reference to @message is valid and
1518 * should thus not be unreffed.
1523 gst_message_parse_stream_status (GstMessage * message,
1524 GstStreamStatusType * type, GstElement ** owner)
1526 const GValue *owner_gvalue;
1527 GstStructure *structure;
1529 g_return_if_fail (GST_IS_MESSAGE (message));
1530 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1532 structure = GST_MESSAGE_STRUCTURE (message);
1533 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1534 g_return_if_fail (owner_gvalue != NULL);
1537 *type = (GstStreamStatusType)
1538 g_value_get_enum (gst_structure_id_get_value (structure,
1541 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1545 * gst_message_set_stream_status_object:
1546 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1547 * @object: the object controlling the streaming
1549 * Configures the object handling the streaming thread. This is usually a
1550 * GstTask object but other objects might be added in the future.
1553 gst_message_set_stream_status_object (GstMessage * message,
1554 const GValue * object)
1556 GstStructure *structure;
1558 g_return_if_fail (GST_IS_MESSAGE (message));
1559 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1561 structure = GST_MESSAGE_STRUCTURE (message);
1562 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1566 * gst_message_get_stream_status_object:
1567 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1569 * Extracts the object managing the streaming thread from @message.
1571 * Returns: a GValue containing the object that manages the streaming thread.
1572 * This object is usually of type GstTask but other types can be added in the
1573 * future. The object remains valid as long as @message is valid.
1576 gst_message_get_stream_status_object (GstMessage * message)
1578 const GValue *result;
1579 GstStructure *structure;
1581 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1582 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1585 structure = GST_MESSAGE_STRUCTURE (message);
1586 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1592 * gst_message_new_step_done:
1593 * @src: The object originating the message.
1594 * @format: the format of @amount
1595 * @amount: the amount of stepped data
1596 * @rate: the rate of the stepped amount
1597 * @flush: is this an flushing step
1598 * @intermediate: is this an intermediate step
1599 * @duration: the duration of the data
1600 * @eos: the step caused EOS
1602 * This message is posted by elements when they complete a part, when @intermediate set
1603 * to %TRUE, or a complete step operation.
1605 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1606 * @amount of media in format @format.
1608 * Returns: (transfer full): the new step_done message.
1613 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1614 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1617 GstMessage *message;
1618 GstStructure *structure;
1620 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1621 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1622 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1623 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1624 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1625 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1626 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1627 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1628 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1634 * gst_message_parse_step_done:
1635 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1636 * @format: (out) (allow-none): result location for the format
1637 * @amount: (out) (allow-none): result location for the amount
1638 * @rate: (out) (allow-none): result location for the rate
1639 * @flush: (out) (allow-none): result location for the flush flag
1640 * @intermediate: (out) (allow-none): result location for the intermediate flag
1641 * @duration: (out) (allow-none): result location for the duration
1642 * @eos: (out) (allow-none): result location for the EOS flag
1644 * Extract the values the step_done message.
1649 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1650 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1651 guint64 * duration, gboolean * eos)
1653 GstStructure *structure;
1655 g_return_if_fail (GST_IS_MESSAGE (message));
1656 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1658 structure = GST_MESSAGE_STRUCTURE (message);
1659 gst_structure_id_get (structure,
1660 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1661 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1662 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1663 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1664 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1665 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1666 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1670 * gst_message_new_step_start:
1671 * @src: The object originating the message.
1672 * @active: if the step is active or queued
1673 * @format: the format of @amount
1674 * @amount: the amount of stepped data
1675 * @rate: the rate of the stepped amount
1676 * @flush: is this an flushing step
1677 * @intermediate: is this an intermediate step
1679 * This message is posted by elements when they accept or activate a new step
1680 * event for @amount in @format.
1682 * @active is set to %FALSE when the element accepted the new step event and has
1683 * queued it for execution in the streaming threads.
1685 * @active is set to %TRUE when the element has activated the step operation and
1686 * is now ready to start executing the step in the streaming thread. After this
1687 * message is emitted, the application can queue a new step operation in the
1690 * Returns: (transfer full): The new step_start message.
1695 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1696 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1698 GstMessage *message;
1699 GstStructure *structure;
1701 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1702 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1703 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1704 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1705 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1706 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1707 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1708 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1714 * gst_message_parse_step_start:
1715 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1716 * @active: (out) (allow-none): result location for the active flag
1717 * @format: (out) (allow-none): result location for the format
1718 * @amount: (out) (allow-none): result location for the amount
1719 * @rate: (out) (allow-none): result location for the rate
1720 * @flush: (out) (allow-none): result location for the flush flag
1721 * @intermediate: (out) (allow-none): result location for the intermediate flag
1723 * Extract the values from step_start message.
1728 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1729 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1730 gboolean * intermediate)
1732 GstStructure *structure;
1734 g_return_if_fail (GST_IS_MESSAGE (message));
1735 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1737 structure = GST_MESSAGE_STRUCTURE (message);
1738 gst_structure_id_get (structure,
1739 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
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, NULL);
1748 * gst_message_new_qos:
1749 * @src: The object originating the message.
1750 * @live: if the message was generated by a live element
1751 * @running_time: the running time of the buffer that generated the message
1752 * @stream_time: the stream time of the buffer that generated the message
1753 * @timestamp: the timestamps of the buffer that generated the message
1754 * @duration: the duration of the buffer that generated the message
1756 * A QOS message is posted on the bus whenever an element decides to drop a
1757 * buffer because of QoS reasons or whenever it changes its processing strategy
1758 * because of QoS reasons (quality adjustments such as processing at lower
1761 * This message can be posted by an element that performs synchronisation against the
1762 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1763 * events received from a downstream element (!live).
1765 * @running_time, @stream_time, @timestamp, @duration should be set to the
1766 * respective running-time, stream-time, timestamp and duration of the (dropped)
1767 * buffer that generated the QoS event. Values can be left to
1768 * GST_CLOCK_TIME_NONE when unknown.
1770 * Returns: (transfer full): The new qos message.
1775 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1776 guint64 stream_time, guint64 timestamp, guint64 duration)
1778 GstMessage *message;
1779 GstStructure *structure;
1781 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1782 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1783 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1784 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1785 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1786 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1787 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1788 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1789 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1790 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1791 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1792 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1793 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1799 * gst_message_set_qos_values:
1800 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1801 * @jitter: The difference of the running-time against the deadline.
1802 * @proportion: Long term prediction of the ideal rate relative to normal rate
1803 * to get optimal quality.
1804 * @quality: An element dependent integer value that specifies the current
1805 * quality level of the element. The default maximum quality is 1000000.
1807 * Set the QoS values that have been calculated/analysed from the QoS data
1812 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1813 gdouble proportion, gint quality)
1815 GstStructure *structure;
1817 g_return_if_fail (GST_IS_MESSAGE (message));
1818 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1820 structure = GST_MESSAGE_STRUCTURE (message);
1821 gst_structure_id_set (structure,
1822 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1823 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1824 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1828 * gst_message_set_qos_stats:
1829 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1830 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1831 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1832 * will likely use GST_FORMAT_DEFAULT (samples).
1833 * @processed: Total number of units correctly processed since the last state
1834 * change to READY or a flushing operation.
1835 * @dropped: Total number of units dropped since the last state change to READY
1836 * or a flushing operation.
1838 * Set the QoS stats representing the history of the current continuous pipeline
1841 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1842 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1847 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1848 guint64 processed, guint64 dropped)
1850 GstStructure *structure;
1852 g_return_if_fail (GST_IS_MESSAGE (message));
1853 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1855 structure = GST_MESSAGE_STRUCTURE (message);
1856 gst_structure_id_set (structure,
1857 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1858 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1859 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1863 * gst_message_parse_qos:
1864 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1865 * @live: (out) (allow-none): if the message was generated by a live element
1866 * @running_time: (out) (allow-none): the running time of the buffer that
1867 * generated the message
1868 * @stream_time: (out) (allow-none): the stream time of the buffer that
1869 * generated the message
1870 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1871 * generated the message
1872 * @duration: (out) (allow-none): the duration of the buffer that
1873 * generated the message
1875 * Extract the timestamps and live status from the QoS message.
1877 * The returned values give the running_time, stream_time, timestamp and
1878 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1884 gst_message_parse_qos (GstMessage * message, gboolean * live,
1885 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1888 GstStructure *structure;
1890 g_return_if_fail (GST_IS_MESSAGE (message));
1891 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1893 structure = GST_MESSAGE_STRUCTURE (message);
1894 gst_structure_id_get (structure,
1895 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1896 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1897 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1898 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1899 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1903 * gst_message_parse_qos_values:
1904 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1905 * @jitter: (out) (allow-none): The difference of the running-time against
1907 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1908 * relative to normal rate to get optimal quality.
1909 * @quality: (out) (allow-none): An element dependent integer value that
1910 * specifies the current quality level of the element. The default
1911 * maximum quality is 1000000.
1913 * Extract the QoS values that have been calculated/analysed from the QoS data
1918 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1919 gdouble * proportion, gint * quality)
1921 GstStructure *structure;
1923 g_return_if_fail (GST_IS_MESSAGE (message));
1924 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1926 structure = GST_MESSAGE_STRUCTURE (message);
1927 gst_structure_id_get (structure,
1928 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1929 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1930 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1934 * gst_message_parse_qos_stats:
1935 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1936 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1937 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1938 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1940 * @processed: (out) (allow-none): Total number of units correctly processed
1941 * since the last state change to READY or a flushing operation.
1942 * @dropped: (out) (allow-none): Total number of units dropped since the last
1943 * state change to READY or a flushing operation.
1945 * Extract the QoS stats representing the history of the current continuous
1946 * pipeline playback period.
1948 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1949 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1954 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1955 guint64 * processed, guint64 * dropped)
1957 GstStructure *structure;
1959 g_return_if_fail (GST_IS_MESSAGE (message));
1960 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1962 structure = GST_MESSAGE_STRUCTURE (message);
1963 gst_structure_id_get (structure,
1964 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1965 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1966 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1970 * gst_message_new_progress:
1971 * @src: The object originating the message.
1972 * @type: a #GstProgressType
1973 * @code: a progress code
1974 * @text: free, user visible text describing the progress
1976 * Progress messages are posted by elements when they use an asynchronous task
1977 * to perform actions triggered by a state change.
1979 * @code contains a well defined string describing the action.
1980 * @test should contain a user visible string detailing the current action.
1982 * Returns: (transfer full): The new qos message.
1985 gst_message_new_progress (GstObject * src, GstProgressType type,
1986 const gchar * code, const gchar * text)
1988 GstMessage *message;
1989 GstStructure *structure;
1990 gint percent = 100, timeout = -1;
1992 g_return_val_if_fail (code != NULL, NULL);
1993 g_return_val_if_fail (text != NULL, NULL);
1995 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
1998 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
1999 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2000 GST_QUARK (CODE), G_TYPE_STRING, code,
2001 GST_QUARK (TEXT), G_TYPE_STRING, text,
2002 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2003 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2004 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2010 * gst_message_parse_progress:
2011 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2012 * @type: (out) (allow-none): location for the type
2013 * @code: (out) (allow-none) (transfer full): location for the code
2014 * @text: (out) (allow-none) (transfer full): location for the text
2016 * Parses the progress @type, @code and @text.
2019 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2020 gchar ** code, gchar ** text)
2022 GstStructure *structure;
2024 g_return_if_fail (GST_IS_MESSAGE (message));
2025 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2027 structure = GST_MESSAGE_STRUCTURE (message);
2028 gst_structure_id_get (structure,
2029 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2030 GST_QUARK (CODE), G_TYPE_STRING, code,
2031 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2035 * gst_message_new_toc:
2036 * @src: the object originating the message.
2037 * @toc: (transfer none): #GstToc structure for the message.
2038 * @updated: whether TOC was updated or not.
2040 * Create a new TOC message. The message is posted by elements
2041 * that discovered or updated a TOC.
2043 * Returns: (transfer full): a new TOC message.
2048 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2050 GstStructure *toc_struct;
2052 g_return_val_if_fail (toc != NULL, NULL);
2054 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2055 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2056 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2058 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2062 * gst_message_parse_toc:
2063 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2064 * @toc: (out) (transfer full): return location for the TOC.
2065 * @updated: (out): return location for the updated flag.
2067 * Extract the TOC from the #GstMessage. The TOC returned in the
2068 * output argument is a copy; the caller must free it with
2069 * gst_toc_unref() when done.
2074 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2076 g_return_if_fail (GST_IS_MESSAGE (message));
2077 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2078 g_return_if_fail (toc != NULL);
2080 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2081 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2082 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2086 * gst_message_new_reset_time:
2087 * @src: (transfer none): The object originating the message.
2088 * @running_time: the requested running-time
2090 * This message is posted when the pipeline running-time should be reset to
2091 * @running_time, like after a flushing seek.
2093 * Returns: (transfer full): The new reset_time message.
2098 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2100 GstMessage *message;
2101 GstStructure *structure;
2103 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2104 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2105 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2111 * gst_message_parse_reset_time:
2112 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2113 * @running_time: (out) (allow-none): Result location for the running_time or
2116 * Extract the running-time from the RESET_TIME message.
2121 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2123 GstStructure *structure;
2125 g_return_if_fail (GST_IS_MESSAGE (message));
2126 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2128 structure = GST_MESSAGE_STRUCTURE (message);
2131 g_value_get_uint64 (gst_structure_id_get_value (structure,
2132 GST_QUARK (RUNNING_TIME)));
2136 * gst_message_new_stream_start:
2137 * @src: (transfer none): The object originating the message.
2139 * Create a new stream_start message. This message is generated and posted in
2140 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2141 * message to the application if all sinks have posted an STREAM_START message.
2143 * Returns: (transfer full): The new stream_start message.
2148 gst_message_new_stream_start (GstObject * src)
2150 GstMessage *message;
2153 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2154 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2161 * gst_message_set_group_id:
2162 * @message: the message
2163 * @group_id: the group id
2165 * Sets the group id on the stream-start message.
2167 * All streams that have the same group id are supposed to be played
2168 * together, i.e. all streams inside a container file should have the
2169 * same group id but different stream ids. The group id should change
2170 * each time the stream is started, resulting in different group ids
2171 * each time a file is played for example.
2178 gst_message_set_group_id (GstMessage * message, guint group_id)
2180 GstStructure *structure;
2182 g_return_if_fail (GST_IS_MESSAGE (message));
2183 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2184 g_return_if_fail (gst_message_is_writable (message));
2186 structure = GST_MESSAGE_STRUCTURE (message);
2187 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2192 * gst_message_parse_group_id:
2193 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2194 * @group_id: (out) (allow-none): Result location for the group id or
2197 * Extract the group from the STREAM_START message.
2199 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2206 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2208 GstStructure *structure;
2211 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2212 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2218 structure = GST_MESSAGE_STRUCTURE (message);
2220 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2224 *group_id = g_value_get_uint (v);
2229 * gst_message_new_need_context:
2230 * @src: (transfer none): The object originating the message.
2231 * @context_type: The context type that is needed
2233 * This message is posted when an element needs a specific #GstContext.
2235 * Returns: (transfer full): The new need-context message.
2242 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2244 GstMessage *message;
2245 GstStructure *structure;
2247 g_return_val_if_fail (context_type != NULL, NULL);
2249 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2250 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2251 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2257 * gst_message_parse_context_type:
2258 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2259 * @context_type: (out) (allow-none): the context type, or %NULL
2261 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2263 * Returns: a #gboolean indicating if the parsing succeeded.
2268 gst_message_parse_context_type (GstMessage * message,
2269 const gchar ** context_type)
2271 GstStructure *structure;
2272 const GValue *value;
2274 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2277 structure = GST_MESSAGE_STRUCTURE (message);
2280 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2281 *context_type = g_value_get_string (value);
2288 * gst_message_new_have_context:
2289 * @src: (transfer none): The object originating the message.
2290 * @context: (transfer full): the context
2292 * This message is posted when an element has a new local #GstContext.
2294 * Returns: (transfer full): The new have-context message.
2301 gst_message_new_have_context (GstObject * src, GstContext * context)
2303 GstMessage *message;
2304 GstStructure *structure;
2306 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2307 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2308 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2309 gst_context_unref (context);
2315 * gst_message_parse_have_context:
2316 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2317 * @context: (out) (transfer full) (allow-none): Result location for the
2320 * Extract the context from the HAVE_CONTEXT message.
2327 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2329 g_return_if_fail (GST_IS_MESSAGE (message));
2330 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2333 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2334 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2338 * gst_message_new_device_added:
2339 * @src: The #GstObject that created the message
2340 * @device: (transfer none): The new #GstDevice
2342 * Creates a new device-added message. The device-added message is produced by
2343 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2344 * of monitored devices.
2346 * Returns: a newly allocated #GstMessage
2351 gst_message_new_device_added (GstObject * src, GstDevice * device)
2353 GstMessage *message;
2354 GstStructure *structure;
2356 g_return_val_if_fail (device != NULL, NULL);
2357 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2359 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2360 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2361 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2367 * gst_message_parse_device_added:
2368 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2369 * @device: (out) (allow-none) (transfer none): A location where to store a
2370 * pointer to the new #GstDevice, or %NULL
2372 * Parses a device-added message. The device-added message is produced by
2373 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2374 * of monitored devices.
2379 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2381 g_return_if_fail (GST_IS_MESSAGE (message));
2382 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2385 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2386 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2390 * gst_message_new_device_removed:
2391 * @src: The #GstObject that created the message
2392 * @device: (transfer none): The removed #GstDevice
2394 * Creates a new device-removed message. The device-removed message is produced
2395 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2396 * disappearance of monitored devices.
2398 * Returns: a newly allocated #GstMessage
2403 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2405 GstMessage *message;
2406 GstStructure *structure;
2408 g_return_val_if_fail (device != NULL, NULL);
2409 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2411 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2412 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2413 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2419 * gst_message_parse_device_removed:
2420 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2421 * @device: (out) (allow-none) (transfer none): A location where to store a
2422 * pointer to the removed #GstDevice, or %NULL
2424 * Parses a device-removed message. The device-removed message is produced by
2425 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2426 * disappearance of monitored devices.
2431 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2433 g_return_if_fail (GST_IS_MESSAGE (message));
2434 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2437 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2438 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);