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 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
786 * gst_message_new_element:
787 * @src: (transfer none): The object originating the message.
788 * @structure: (transfer full): The structure for the
789 * message. The message will take ownership of the structure.
791 * Create a new element-specific message. This is meant as a generic way of
792 * allowing one-way communication from an element to an application, for example
793 * "the firewire cable was unplugged". The format of the message should be
794 * documented in the element's documentation. The structure field can be %NULL.
796 * Returns: (transfer full): The new element message.
801 gst_message_new_element (GstObject * src, GstStructure * structure)
803 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
807 * gst_message_new_duration_changed:
808 * @src: (transfer none): The object originating the message.
810 * Create a new duration changed message. This message is posted by elements
811 * that know the duration of a stream when the duration changes. This message
812 * is received by bins and is used to calculate the total duration of a
813 * pipeline. Elements may post a duration message with a duration of
814 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
815 * cached duration should be discarded. The new duration can then be
816 * retrieved via a query.
818 * Returns: (transfer full): The new duration-changed message.
823 gst_message_new_duration_changed (GstObject * src)
827 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
828 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
834 * gst_message_new_async_start:
835 * @src: (transfer none): The object originating the message.
837 * This message is posted by elements when they start an ASYNC state change.
839 * Returns: (transfer full): The new async_start message.
844 gst_message_new_async_start (GstObject * src)
848 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
854 * gst_message_new_async_done:
855 * @src: (transfer none): The object originating the message.
856 * @running_time: the desired running_time
858 * The message is posted when elements completed an ASYNC state change.
859 * @running_time contains the time of the desired running_time when this
860 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
861 * means that the element has no clock interaction and thus doesn't care about
862 * the running_time of the pipeline.
864 * Returns: (transfer full): The new async_done message.
869 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
872 GstStructure *structure;
874 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
875 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
876 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
882 * gst_message_new_latency:
883 * @src: (transfer none): The object originating the message.
885 * This message can be posted by elements when their latency requirements have
888 * Returns: (transfer full): The new latency message.
893 gst_message_new_latency (GstObject * src)
897 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
903 * gst_message_new_request_state:
904 * @src: (transfer none): the object originating the message.
905 * @state: The new requested state
907 * This message can be posted by elements when they want to have their state
908 * changed. A typical use case would be an audio server that wants to pause the
909 * pipeline because a higher priority stream is being played.
911 * Returns: (transfer full): the new request state message.
916 gst_message_new_request_state (GstObject * src, GstState state)
919 GstStructure *structure;
921 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
922 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
923 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
929 * gst_message_get_structure:
930 * @message: The #GstMessage.
932 * Access the structure of the message.
934 * Returns: (transfer none): The structure of the message. The structure is
935 * still owned by the message, which means that you should not free it and
936 * that the pointer becomes invalid when you free the message.
941 gst_message_get_structure (GstMessage * message)
943 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
945 return GST_MESSAGE_STRUCTURE (message);
949 * gst_message_has_name:
950 * @message: The #GstMessage.
951 * @name: name to check
953 * Checks if @message has the given @name. This function is usually used to
954 * check the name of a custom message.
956 * Returns: %TRUE if @name matches the name of the message structure.
959 gst_message_has_name (GstMessage * message, const gchar * name)
961 GstStructure *structure;
963 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
965 structure = GST_MESSAGE_STRUCTURE (message);
966 if (structure == NULL)
969 return gst_structure_has_name (structure, name);
973 * gst_message_parse_tag:
974 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
975 * @tag_list: (out callee-allocates): return location for the tag-list.
977 * Extracts the tag list from the GstMessage. The tag list returned in the
978 * output argument is a copy; the caller must free it when done.
980 * Typical usage of this function might be:
983 * switch (GST_MESSAGE_TYPE (msg)) {
984 * case GST_MESSAGE_TAG: {
985 * GstTagList *tags = NULL;
987 * gst_message_parse_tag (msg, &tags);
988 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
989 * handle_tags (tags);
990 * gst_tag_list_unref (tags);
1001 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1003 g_return_if_fail (GST_IS_MESSAGE (message));
1004 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1005 g_return_if_fail (tag_list != NULL);
1007 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1008 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1012 * gst_message_parse_buffering:
1013 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1014 * @percent: (out) (allow-none): Return location for the percent.
1016 * Extracts the buffering percent from the GstMessage. see also
1017 * gst_message_new_buffering().
1022 gst_message_parse_buffering (GstMessage * message, gint * percent)
1024 g_return_if_fail (GST_IS_MESSAGE (message));
1025 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1029 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1030 (message), GST_QUARK (BUFFER_PERCENT)));
1034 * gst_message_set_buffering_stats:
1035 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1036 * @mode: a buffering mode
1037 * @avg_in: the average input rate
1038 * @avg_out: the average output rate
1039 * @buffering_left: amount of buffering time left in milliseconds
1041 * Configures the buffering stats values in @message.
1044 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1045 gint avg_in, gint avg_out, gint64 buffering_left)
1047 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1049 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1050 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1051 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1052 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1053 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1057 * gst_message_parse_buffering_stats:
1058 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1059 * @mode: (out) (allow-none): a buffering mode, or %NULL
1060 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1061 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1062 * @buffering_left: (out) (allow-none): amount of buffering time left in
1063 * milliseconds, or %NULL
1065 * Extracts the buffering stats values from @message.
1068 gst_message_parse_buffering_stats (GstMessage * message,
1069 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1070 gint64 * buffering_left)
1072 GstStructure *structure;
1074 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1076 structure = GST_MESSAGE_STRUCTURE (message);
1078 *mode = (GstBufferingMode)
1079 g_value_get_enum (gst_structure_id_get_value (structure,
1080 GST_QUARK (BUFFERING_MODE)));
1082 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1083 GST_QUARK (AVG_IN_RATE)));
1085 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1086 GST_QUARK (AVG_OUT_RATE)));
1089 g_value_get_int64 (gst_structure_id_get_value (structure,
1090 GST_QUARK (BUFFERING_LEFT)));
1094 * gst_message_parse_state_changed:
1095 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1096 * @oldstate: (out) (allow-none): the previous state, or %NULL
1097 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1098 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1100 * Extracts the old and new states from the GstMessage.
1102 * Typical usage of this function might be:
1105 * switch (GST_MESSAGE_TYPE (msg)) {
1106 * case GST_MESSAGE_STATE_CHANGED: {
1107 * GstState old_state, new_state;
1109 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1110 * g_print ("Element %s changed state from %s to %s.\n",
1111 * GST_OBJECT_NAME (msg->src),
1112 * gst_element_state_get_name (old_state),
1113 * gst_element_state_get_name (new_state));
1124 gst_message_parse_state_changed (GstMessage * message,
1125 GstState * oldstate, GstState * newstate, GstState * pending)
1127 GstStructure *structure;
1129 g_return_if_fail (GST_IS_MESSAGE (message));
1130 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1132 structure = GST_MESSAGE_STRUCTURE (message);
1134 *oldstate = (GstState)
1135 g_value_get_enum (gst_structure_id_get_value (structure,
1136 GST_QUARK (OLD_STATE)));
1138 *newstate = (GstState)
1139 g_value_get_enum (gst_structure_id_get_value (structure,
1140 GST_QUARK (NEW_STATE)));
1142 *pending = (GstState)
1143 g_value_get_enum (gst_structure_id_get_value (structure,
1144 GST_QUARK (PENDING_STATE)));
1148 * gst_message_parse_clock_provide:
1149 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1150 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1152 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1154 * Extracts the clock and ready flag from the GstMessage.
1155 * The clock object returned remains valid until the message is freed.
1160 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1163 const GValue *clock_gvalue;
1164 GstStructure *structure;
1166 g_return_if_fail (GST_IS_MESSAGE (message));
1167 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1169 structure = GST_MESSAGE_STRUCTURE (message);
1170 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1171 g_return_if_fail (clock_gvalue != NULL);
1172 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1176 g_value_get_boolean (gst_structure_id_get_value (structure,
1177 GST_QUARK (READY)));
1179 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1183 * gst_message_parse_clock_lost:
1184 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1185 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1187 * Extracts the lost clock from the GstMessage.
1188 * The clock object returned remains valid until the message is freed.
1193 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1195 const GValue *clock_gvalue;
1196 GstStructure *structure;
1198 g_return_if_fail (GST_IS_MESSAGE (message));
1199 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1201 structure = GST_MESSAGE_STRUCTURE (message);
1202 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1203 g_return_if_fail (clock_gvalue != NULL);
1204 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1207 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1211 * gst_message_parse_new_clock:
1212 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1213 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1216 * Extracts the new clock from the GstMessage.
1217 * The clock object returned remains valid until the message is freed.
1222 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1224 const GValue *clock_gvalue;
1225 GstStructure *structure;
1227 g_return_if_fail (GST_IS_MESSAGE (message));
1228 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1230 structure = GST_MESSAGE_STRUCTURE (message);
1231 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1232 g_return_if_fail (clock_gvalue != NULL);
1233 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1236 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1240 * gst_message_parse_structure_change:
1241 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1242 * @type: (out): A pointer to hold the change type
1243 * @owner: (out) (allow-none) (transfer none): The owner element of the
1245 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1246 * progress or has been completed
1248 * Extracts the change type and completion status from the GstMessage.
1253 gst_message_parse_structure_change (GstMessage * message,
1254 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1256 const GValue *owner_gvalue;
1257 GstStructure *structure;
1259 g_return_if_fail (GST_IS_MESSAGE (message));
1260 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1262 structure = GST_MESSAGE_STRUCTURE (message);
1263 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1264 g_return_if_fail (owner_gvalue != NULL);
1265 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1268 *type = (GstStructureChangeType)
1269 g_value_get_enum (gst_structure_id_get_value (structure,
1272 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1275 g_value_get_boolean (gst_structure_id_get_value (structure,
1280 * gst_message_parse_error:
1281 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1282 * @gerror: (out) (allow-none) (transfer full): location for the GError
1283 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1286 * Extracts the GError and debug string from the GstMessage. The values returned
1287 * in the output arguments are copies; the caller must free them when done.
1289 * Typical usage of this function might be:
1292 * switch (GST_MESSAGE_TYPE (msg)) {
1293 * case GST_MESSAGE_ERROR: {
1294 * GError *err = NULL;
1295 * gchar *dbg_info = NULL;
1297 * gst_message_parse_error (msg, &err, &dbg_info);
1298 * g_printerr ("ERROR from element %s: %s\n",
1299 * GST_OBJECT_NAME (msg->src), err->message);
1300 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1301 * g_error_free (err);
1302 * g_free (dbg_info);
1313 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1315 g_return_if_fail (GST_IS_MESSAGE (message));
1316 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1318 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1319 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1320 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1324 * gst_message_parse_warning:
1325 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1326 * @gerror: (out) (allow-none) (transfer full): location for the GError
1327 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1330 * Extracts the GError and debug string from the GstMessage. The values returned
1331 * in the output arguments are copies; the caller must free them when done.
1336 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1339 g_return_if_fail (GST_IS_MESSAGE (message));
1340 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1342 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1343 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1344 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1348 * gst_message_parse_info:
1349 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1350 * @gerror: (out) (allow-none) (transfer full): location for the GError
1351 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1354 * Extracts the GError and debug string from the GstMessage. The values returned
1355 * in the output arguments are copies; the caller must free them when done.
1360 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1362 g_return_if_fail (GST_IS_MESSAGE (message));
1363 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1365 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1366 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1367 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1371 * gst_message_parse_segment_start:
1372 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1373 * @format: (out) (allow-none): Result location for the format, or %NULL
1374 * @position: (out) (allow-none): Result location for the position, or %NULL
1376 * Extracts the position and format from the segment start message.
1381 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1384 GstStructure *structure;
1386 g_return_if_fail (GST_IS_MESSAGE (message));
1387 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1389 structure = GST_MESSAGE_STRUCTURE (message);
1391 *format = (GstFormat)
1392 g_value_get_enum (gst_structure_id_get_value (structure,
1393 GST_QUARK (FORMAT)));
1396 g_value_get_int64 (gst_structure_id_get_value (structure,
1397 GST_QUARK (POSITION)));
1401 * gst_message_parse_segment_done:
1402 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1403 * @format: (out) (allow-none): Result location for the format, or %NULL
1404 * @position: (out) (allow-none): Result location for the position, or %NULL
1406 * Extracts the position and format from the segment done message.
1411 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1414 GstStructure *structure;
1416 g_return_if_fail (GST_IS_MESSAGE (message));
1417 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1419 structure = GST_MESSAGE_STRUCTURE (message);
1421 *format = (GstFormat)
1422 g_value_get_enum (gst_structure_id_get_value (structure,
1423 GST_QUARK (FORMAT)));
1426 g_value_get_int64 (gst_structure_id_get_value (structure,
1427 GST_QUARK (POSITION)));
1431 * gst_message_parse_async_done:
1432 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1433 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1435 * Extract the running_time from the async_done message.
1440 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1442 GstStructure *structure;
1444 g_return_if_fail (GST_IS_MESSAGE (message));
1445 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1447 structure = GST_MESSAGE_STRUCTURE (message);
1450 g_value_get_uint64 (gst_structure_id_get_value (structure,
1451 GST_QUARK (RUNNING_TIME)));
1455 * gst_message_parse_request_state:
1456 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1457 * @state: (out) (allow-none): Result location for the requested state or %NULL
1459 * Extract the requested state from the request_state message.
1464 gst_message_parse_request_state (GstMessage * message, GstState * state)
1466 GstStructure *structure;
1468 g_return_if_fail (GST_IS_MESSAGE (message));
1469 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1471 structure = GST_MESSAGE_STRUCTURE (message);
1474 g_value_get_enum (gst_structure_id_get_value (structure,
1475 GST_QUARK (NEW_STATE)));
1479 * gst_message_new_stream_status:
1480 * @src: The object originating the message.
1481 * @type: The stream status type.
1482 * @owner: (transfer none): the owner element of @src.
1484 * Create a new stream status message. This message is posted when a streaming
1485 * thread is created/destroyed or when the state changed.
1487 * Returns: (transfer full): the new stream status message.
1492 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1495 GstMessage *message;
1496 GstStructure *structure;
1498 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1499 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1500 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1501 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1507 * gst_message_parse_stream_status:
1508 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1509 * @type: (out): A pointer to hold the status type
1510 * @owner: (out) (transfer none): The owner element of the message source
1512 * Extracts the stream status type and owner the GstMessage. The returned
1513 * owner remains valid for as long as the reference to @message is valid and
1514 * should thus not be unreffed.
1519 gst_message_parse_stream_status (GstMessage * message,
1520 GstStreamStatusType * type, GstElement ** owner)
1522 const GValue *owner_gvalue;
1523 GstStructure *structure;
1525 g_return_if_fail (GST_IS_MESSAGE (message));
1526 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1528 structure = GST_MESSAGE_STRUCTURE (message);
1529 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1530 g_return_if_fail (owner_gvalue != NULL);
1533 *type = (GstStreamStatusType)
1534 g_value_get_enum (gst_structure_id_get_value (structure,
1537 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1541 * gst_message_set_stream_status_object:
1542 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1543 * @object: the object controlling the streaming
1545 * Configures the object handling the streaming thread. This is usually a
1546 * GstTask object but other objects might be added in the future.
1549 gst_message_set_stream_status_object (GstMessage * message,
1550 const GValue * object)
1552 GstStructure *structure;
1554 g_return_if_fail (GST_IS_MESSAGE (message));
1555 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1557 structure = GST_MESSAGE_STRUCTURE (message);
1558 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1562 * gst_message_get_stream_status_object:
1563 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1565 * Extracts the object managing the streaming thread from @message.
1567 * Returns: a GValue containing the object that manages the streaming thread.
1568 * This object is usually of type GstTask but other types can be added in the
1569 * future. The object remains valid as long as @message is valid.
1572 gst_message_get_stream_status_object (GstMessage * message)
1574 const GValue *result;
1575 GstStructure *structure;
1577 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1578 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1581 structure = GST_MESSAGE_STRUCTURE (message);
1582 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1588 * gst_message_new_step_done:
1589 * @src: The object originating the message.
1590 * @format: the format of @amount
1591 * @amount: the amount of stepped data
1592 * @rate: the rate of the stepped amount
1593 * @flush: is this an flushing step
1594 * @intermediate: is this an intermediate step
1595 * @duration: the duration of the data
1596 * @eos: the step caused EOS
1598 * This message is posted by elements when they complete a part, when @intermediate set
1599 * to %TRUE, or a complete step operation.
1601 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1602 * @amount of media in format @format.
1604 * Returns: (transfer full): the new step_done message.
1609 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1610 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1613 GstMessage *message;
1614 GstStructure *structure;
1616 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1617 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1618 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1619 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1620 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1621 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1622 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1623 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1624 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1630 * gst_message_parse_step_done:
1631 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1632 * @format: (out) (allow-none): result location for the format
1633 * @amount: (out) (allow-none): result location for the amount
1634 * @rate: (out) (allow-none): result location for the rate
1635 * @flush: (out) (allow-none): result location for the flush flag
1636 * @intermediate: (out) (allow-none): result location for the intermediate flag
1637 * @duration: (out) (allow-none): result location for the duration
1638 * @eos: (out) (allow-none): result location for the EOS flag
1640 * Extract the values the step_done message.
1645 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1646 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1647 guint64 * duration, gboolean * eos)
1649 GstStructure *structure;
1651 g_return_if_fail (GST_IS_MESSAGE (message));
1652 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1654 structure = GST_MESSAGE_STRUCTURE (message);
1655 gst_structure_id_get (structure,
1656 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1657 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1658 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1659 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1660 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1661 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1662 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1666 * gst_message_new_step_start:
1667 * @src: The object originating the message.
1668 * @active: if the step is active or queued
1669 * @format: the format of @amount
1670 * @amount: the amount of stepped data
1671 * @rate: the rate of the stepped amount
1672 * @flush: is this an flushing step
1673 * @intermediate: is this an intermediate step
1675 * This message is posted by elements when they accept or activate a new step
1676 * event for @amount in @format.
1678 * @active is set to %FALSE when the element accepted the new step event and has
1679 * queued it for execution in the streaming threads.
1681 * @active is set to %TRUE when the element has activated the step operation and
1682 * is now ready to start executing the step in the streaming thread. After this
1683 * message is emitted, the application can queue a new step operation in the
1686 * Returns: (transfer full): The new step_start message.
1691 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1692 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1694 GstMessage *message;
1695 GstStructure *structure;
1697 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1698 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1699 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1700 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1701 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1702 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1703 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1704 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1710 * gst_message_parse_step_start:
1711 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1712 * @active: (out) (allow-none): result location for the active flag
1713 * @format: (out) (allow-none): result location for the format
1714 * @amount: (out) (allow-none): result location for the amount
1715 * @rate: (out) (allow-none): result location for the rate
1716 * @flush: (out) (allow-none): result location for the flush flag
1717 * @intermediate: (out) (allow-none): result location for the intermediate flag
1719 * Extract the values from step_start message.
1724 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1725 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1726 gboolean * intermediate)
1728 GstStructure *structure;
1730 g_return_if_fail (GST_IS_MESSAGE (message));
1731 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1733 structure = GST_MESSAGE_STRUCTURE (message);
1734 gst_structure_id_get (structure,
1735 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1736 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1737 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1738 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1739 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1740 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1744 * gst_message_new_qos:
1745 * @src: The object originating the message.
1746 * @live: if the message was generated by a live element
1747 * @running_time: the running time of the buffer that generated the message
1748 * @stream_time: the stream time of the buffer that generated the message
1749 * @timestamp: the timestamps of the buffer that generated the message
1750 * @duration: the duration of the buffer that generated the message
1752 * A QOS message is posted on the bus whenever an element decides to drop a
1753 * buffer because of QoS reasons or whenever it changes its processing strategy
1754 * because of QoS reasons (quality adjustments such as processing at lower
1757 * This message can be posted by an element that performs synchronisation against the
1758 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1759 * events received from a downstream element (!live).
1761 * @running_time, @stream_time, @timestamp, @duration should be set to the
1762 * respective running-time, stream-time, timestamp and duration of the (dropped)
1763 * buffer that generated the QoS event. Values can be left to
1764 * GST_CLOCK_TIME_NONE when unknown.
1766 * Returns: (transfer full): The new qos message.
1771 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1772 guint64 stream_time, guint64 timestamp, guint64 duration)
1774 GstMessage *message;
1775 GstStructure *structure;
1777 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1778 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1779 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1780 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1781 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1782 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1783 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1784 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1785 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1786 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1787 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1788 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1789 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1795 * gst_message_set_qos_values:
1796 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1797 * @jitter: The difference of the running-time against the deadline.
1798 * @proportion: Long term prediction of the ideal rate relative to normal rate
1799 * to get optimal quality.
1800 * @quality: An element dependent integer value that specifies the current
1801 * quality level of the element. The default maximum quality is 1000000.
1803 * Set the QoS values that have been calculated/analysed from the QoS data
1808 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1809 gdouble proportion, gint quality)
1811 GstStructure *structure;
1813 g_return_if_fail (GST_IS_MESSAGE (message));
1814 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1816 structure = GST_MESSAGE_STRUCTURE (message);
1817 gst_structure_id_set (structure,
1818 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1819 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1820 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1824 * gst_message_set_qos_stats:
1825 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1826 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1827 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1828 * will likely use GST_FORMAT_DEFAULT (samples).
1829 * @processed: Total number of units correctly processed since the last state
1830 * change to READY or a flushing operation.
1831 * @dropped: Total number of units dropped since the last state change to READY
1832 * or a flushing operation.
1834 * Set the QoS stats representing the history of the current continuous pipeline
1837 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1838 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1843 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1844 guint64 processed, guint64 dropped)
1846 GstStructure *structure;
1848 g_return_if_fail (GST_IS_MESSAGE (message));
1849 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1851 structure = GST_MESSAGE_STRUCTURE (message);
1852 gst_structure_id_set (structure,
1853 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1854 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1855 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1859 * gst_message_parse_qos:
1860 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1861 * @live: (out) (allow-none): if the message was generated by a live element
1862 * @running_time: (out) (allow-none): the running time of the buffer that
1863 * generated the message
1864 * @stream_time: (out) (allow-none): the stream time of the buffer that
1865 * generated the message
1866 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1867 * generated the message
1868 * @duration: (out) (allow-none): the duration of the buffer that
1869 * generated the message
1871 * Extract the timestamps and live status from the QoS message.
1873 * The returned values give the running_time, stream_time, timestamp and
1874 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1880 gst_message_parse_qos (GstMessage * message, gboolean * live,
1881 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1884 GstStructure *structure;
1886 g_return_if_fail (GST_IS_MESSAGE (message));
1887 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1889 structure = GST_MESSAGE_STRUCTURE (message);
1890 gst_structure_id_get (structure,
1891 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1892 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1893 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1894 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1895 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1899 * gst_message_parse_qos_values:
1900 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1901 * @jitter: (out) (allow-none): The difference of the running-time against
1903 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1904 * relative to normal rate to get optimal quality.
1905 * @quality: (out) (allow-none): An element dependent integer value that
1906 * specifies the current quality level of the element. The default
1907 * maximum quality is 1000000.
1909 * Extract the QoS values that have been calculated/analysed from the QoS data
1914 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1915 gdouble * proportion, gint * quality)
1917 GstStructure *structure;
1919 g_return_if_fail (GST_IS_MESSAGE (message));
1920 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1922 structure = GST_MESSAGE_STRUCTURE (message);
1923 gst_structure_id_get (structure,
1924 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1925 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1926 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1930 * gst_message_parse_qos_stats:
1931 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1932 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1933 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1934 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1936 * @processed: (out) (allow-none): Total number of units correctly processed
1937 * since the last state change to READY or a flushing operation.
1938 * @dropped: (out) (allow-none): Total number of units dropped since the last
1939 * state change to READY or a flushing operation.
1941 * Extract the QoS stats representing the history of the current continuous
1942 * pipeline playback period.
1944 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1945 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1950 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1951 guint64 * processed, guint64 * dropped)
1953 GstStructure *structure;
1955 g_return_if_fail (GST_IS_MESSAGE (message));
1956 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1958 structure = GST_MESSAGE_STRUCTURE (message);
1959 gst_structure_id_get (structure,
1960 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1961 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1962 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1966 * gst_message_new_progress:
1967 * @src: The object originating the message.
1968 * @type: a #GstProgressType
1969 * @code: a progress code
1970 * @text: free, user visible text describing the progress
1972 * Progress messages are posted by elements when they use an asynchronous task
1973 * to perform actions triggered by a state change.
1975 * @code contains a well defined string describing the action.
1976 * @test should contain a user visible string detailing the current action.
1978 * Returns: (transfer full): The new qos message.
1981 gst_message_new_progress (GstObject * src, GstProgressType type,
1982 const gchar * code, const gchar * text)
1984 GstMessage *message;
1985 GstStructure *structure;
1986 gint percent = 100, timeout = -1;
1988 g_return_val_if_fail (code != NULL, NULL);
1989 g_return_val_if_fail (text != NULL, NULL);
1991 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
1994 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
1995 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
1996 GST_QUARK (CODE), G_TYPE_STRING, code,
1997 GST_QUARK (TEXT), G_TYPE_STRING, text,
1998 GST_QUARK (PERCENT), G_TYPE_INT, percent,
1999 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2000 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2006 * gst_message_parse_progress:
2007 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2008 * @type: (out) (allow-none): location for the type
2009 * @code: (out) (allow-none) (transfer full): location for the code
2010 * @text: (out) (allow-none) (transfer full): location for the text
2012 * Parses the progress @type, @code and @text.
2015 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2016 gchar ** code, gchar ** text)
2018 GstStructure *structure;
2020 g_return_if_fail (GST_IS_MESSAGE (message));
2021 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2023 structure = GST_MESSAGE_STRUCTURE (message);
2024 gst_structure_id_get (structure,
2025 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2026 GST_QUARK (CODE), G_TYPE_STRING, code,
2027 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2031 * gst_message_new_toc:
2032 * @src: the object originating the message.
2033 * @toc: (transfer none): #GstToc structure for the message.
2034 * @updated: whether TOC was updated or not.
2036 * Create a new TOC message. The message is posted by elements
2037 * that discovered or updated a TOC.
2039 * Returns: (transfer full): a new TOC message.
2044 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2046 GstStructure *toc_struct;
2048 g_return_val_if_fail (toc != NULL, NULL);
2050 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2051 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2052 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2054 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2058 * gst_message_parse_toc:
2059 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2060 * @toc: (out) (transfer full): return location for the TOC.
2061 * @updated: (out): return location for the updated flag.
2063 * Extract the TOC from the #GstMessage. The TOC returned in the
2064 * output argument is a copy; the caller must free it with
2065 * gst_toc_unref() when done.
2070 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2072 g_return_if_fail (GST_IS_MESSAGE (message));
2073 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2074 g_return_if_fail (toc != NULL);
2076 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2077 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2078 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2082 * gst_message_new_reset_time:
2083 * @src: (transfer none): The object originating the message.
2084 * @running_time: the requested running-time
2086 * This message is posted when the pipeline running-time should be reset to
2087 * @running_time, like after a flushing seek.
2089 * Returns: (transfer full): The new reset_time message.
2094 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2096 GstMessage *message;
2097 GstStructure *structure;
2099 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2100 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2101 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2107 * gst_message_parse_reset_time:
2108 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2109 * @running_time: (out) (allow-none): Result location for the running_time or
2112 * Extract the running-time from the RESET_TIME message.
2117 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2119 GstStructure *structure;
2121 g_return_if_fail (GST_IS_MESSAGE (message));
2122 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2124 structure = GST_MESSAGE_STRUCTURE (message);
2127 g_value_get_uint64 (gst_structure_id_get_value (structure,
2128 GST_QUARK (RUNNING_TIME)));
2132 * gst_message_new_stream_start:
2133 * @src: (transfer none): The object originating the message.
2135 * Create a new stream_start message. This message is generated and posted in
2136 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2137 * message to the application if all sinks have posted an STREAM_START message.
2139 * Returns: (transfer full): The new stream_start message.
2144 gst_message_new_stream_start (GstObject * src)
2146 GstMessage *message;
2149 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2150 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2157 * gst_message_set_group_id:
2158 * @message: the message
2159 * @group_id: the group id
2161 * Sets the group id on the stream-start message.
2163 * All streams that have the same group id are supposed to be played
2164 * together, i.e. all streams inside a container file should have the
2165 * same group id but different stream ids. The group id should change
2166 * each time the stream is started, resulting in different group ids
2167 * each time a file is played for example.
2174 gst_message_set_group_id (GstMessage * message, guint group_id)
2176 GstStructure *structure;
2178 g_return_if_fail (GST_IS_MESSAGE (message));
2179 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2180 g_return_if_fail (gst_message_is_writable (message));
2182 structure = GST_MESSAGE_STRUCTURE (message);
2183 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2188 * gst_message_parse_group_id:
2189 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2190 * @group_id: (out) (allow-none): Result location for the group id or
2193 * Extract the group from the STREAM_START message.
2195 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2202 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2204 GstStructure *structure;
2207 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2208 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2214 structure = GST_MESSAGE_STRUCTURE (message);
2216 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2220 *group_id = g_value_get_uint (v);
2225 * gst_message_new_need_context:
2226 * @src: (transfer none): The object originating the message.
2227 * @context_type: The context type that is needed
2229 * This message is posted when an element needs a specific #GstContext.
2231 * Returns: (transfer full): The new need-context message.
2238 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2240 GstMessage *message;
2241 GstStructure *structure;
2243 g_return_val_if_fail (context_type != NULL, NULL);
2245 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2246 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2247 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2253 * gst_message_parse_context_type:
2254 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2255 * @context_type: (out) (allow-none): the context type, or %NULL
2257 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2259 * Returns: a #gboolean indicating if the parsing succeeded.
2264 gst_message_parse_context_type (GstMessage * message,
2265 const gchar ** context_type)
2267 GstStructure *structure;
2268 const GValue *value;
2270 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2273 structure = GST_MESSAGE_STRUCTURE (message);
2276 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2277 *context_type = g_value_get_string (value);
2284 * gst_message_new_have_context:
2285 * @src: (transfer none): The object originating the message.
2286 * @context: (transfer full): the context
2288 * This message is posted when an element has a new local #GstContext.
2290 * Returns: (transfer full): The new have-context message.
2297 gst_message_new_have_context (GstObject * src, GstContext * context)
2299 GstMessage *message;
2300 GstStructure *structure;
2302 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2303 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2304 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2305 gst_context_unref (context);
2311 * gst_message_parse_have_context:
2312 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2313 * @context: (out) (transfer full) (allow-none): Result location for the
2316 * Extract the context from the HAVE_CONTEXT message.
2323 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2325 g_return_if_fail (GST_IS_MESSAGE (message));
2326 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2329 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2330 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2334 * gst_message_new_device_added:
2335 * @src: The #GstObject that created the message
2336 * @device: (transfer none): The new #GstDevice
2338 * Creates a new device-added message. The device-added message is produced by
2339 * #GstDeviceMonitor or a #GstGlobalDeviceMonitor. They announce the appearance
2340 * of monitored devices.
2342 * Returns: a newly allocated #GstMessage
2347 gst_message_new_device_added (GstObject * src, GstDevice * device)
2349 GstMessage *message;
2350 GstStructure *structure;
2352 g_return_val_if_fail (device != NULL, NULL);
2353 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2355 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2356 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2357 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2363 * gst_message_parse_device_added:
2364 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2365 * @device: (out) (allow-none) (transfer none): A location where to store a
2366 * pointer to the new #GstDevice, or %NULL
2368 * Parses a device-added message. The device-added message is produced by
2369 * #GstDeviceMonitor or a #GstGlobalDeviceMonitor. It announces the appearance
2370 * of monitored devices.
2375 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2377 g_return_if_fail (GST_IS_MESSAGE (message));
2378 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2381 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2382 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2386 * gst_message_new_device_removed:
2387 * @src: The #GstObject that created the message
2388 * @device: (transfer none): The removed #GstDevice
2390 * Creates a new device-removed message. The device-removed message is produced
2391 * by #GstDeviceMonitor or a #GstGlobalDeviceMonitor. They announce the
2392 * disappearance of monitored devices.
2394 * Returns: a newly allocated #GstMessage
2399 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2401 GstMessage *message;
2402 GstStructure *structure;
2404 g_return_val_if_fail (device != NULL, NULL);
2405 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2407 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2408 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2409 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2415 * gst_message_parse_device_removed:
2416 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2417 * @device: (out) (allow-none) (transfer none): A location where to store a
2418 * pointer to the removed #GstDevice, or %NULL
2420 * Parses a device-removed message. The device-removed message is produced by
2421 * #GstDeviceMonitor or a #GstGlobalDeviceMonitor. It announces the
2422 * disappearance of monitored devices.
2427 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2429 g_return_if_fail (GST_IS_MESSAGE (message));
2430 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2433 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2434 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);