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.
25 * @short_description: Lightweight objects to signal the application of
27 * @see_also: #GstBus, #GstMiniObject, #GstElement
29 * Messages are implemented as a subclass of #GstMiniObject with a generic
30 * #GstStructure as the content. This allows for writing custom messages without
31 * requiring an API change while allowing a wide range of different types
34 * Messages are posted by objects in the pipeline and are passed to the
35 * application using the #GstBus.
37 * The basic use pattern of posting a message on a #GstBus is as follows:
38 * |[<!-- language="C" -->
39 * gst_bus_post (bus, gst_message_new_eos());
42 * A #GstElement usually posts messages on the bus provided by the parent
43 * container using gst_element_post_message().
46 #define GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS
47 #include "gst_private.h"
48 #include <string.h> /* memcpy */
50 #include "gstenumtypes.h"
52 #include "gstmessage.h"
53 #include "gsttaglist.h"
63 GstStructure *structure;
66 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
75 static GstMessageQuarks message_quarks[] = {
76 {GST_MESSAGE_UNKNOWN, "unknown", 0},
77 {GST_MESSAGE_EOS, "eos", 0},
78 {GST_MESSAGE_ERROR, "error", 0},
79 {GST_MESSAGE_WARNING, "warning", 0},
80 {GST_MESSAGE_INFO, "info", 0},
81 {GST_MESSAGE_TAG, "tag", 0},
82 {GST_MESSAGE_BUFFERING, "buffering", 0},
83 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
84 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
85 {GST_MESSAGE_STEP_DONE, "step-done", 0},
86 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
87 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
88 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
89 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
90 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
91 {GST_MESSAGE_APPLICATION, "application", 0},
92 {GST_MESSAGE_ELEMENT, "element", 0},
93 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
94 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
95 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
96 {GST_MESSAGE_LATENCY, "latency", 0},
97 {GST_MESSAGE_ASYNC_START, "async-start", 0},
98 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
99 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
100 {GST_MESSAGE_STEP_START, "step-start", 0},
101 {GST_MESSAGE_QOS, "qos", 0},
102 {GST_MESSAGE_PROGRESS, "progress", 0},
103 {GST_MESSAGE_TOC, "toc", 0},
104 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
105 {GST_MESSAGE_STREAM_START, "stream-start", 0},
106 {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
107 {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
108 {GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
109 {GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
110 {GST_MESSAGE_DEVICE_CHANGED, "device-changed", 0},
111 {GST_MESSAGE_PROPERTY_NOTIFY, "property-notify", 0},
112 {GST_MESSAGE_STREAM_COLLECTION, "stream-collection", 0},
113 {GST_MESSAGE_STREAMS_SELECTED, "streams-selected", 0},
114 {GST_MESSAGE_REDIRECT, "redirect", 0},
115 {GST_MESSAGE_INSTANT_RATE_REQUEST, "instant-rate-request", 0},
119 static GQuark details_quark = 0;
121 GType _gst_message_type = 0;
122 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
125 _priv_gst_message_initialize (void)
129 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
131 for (i = 0; message_quarks[i].name; i++) {
132 message_quarks[i].quark =
133 g_quark_from_static_string (message_quarks[i].name);
135 details_quark = g_quark_from_static_string ("details");
137 _gst_message_type = gst_message_get_type ();
141 * gst_message_type_get_name:
142 * @type: the message type
144 * Get a printable name for the given message type. Do not modify or free.
146 * Returns: a reference to the static name of the message.
149 gst_message_type_get_name (GstMessageType type)
153 for (i = 0; message_quarks[i].name; i++) {
154 if (type == message_quarks[i].type)
155 return message_quarks[i].name;
161 * gst_message_type_to_quark:
162 * @type: the message type
164 * Get the unique quark for the given message type.
166 * Returns: the quark associated with the message type
169 gst_message_type_to_quark (GstMessageType type)
173 for (i = 0; message_quarks[i].name; i++) {
174 if (type == message_quarks[i].type)
175 return message_quarks[i].quark;
181 _gst_message_dispose (GstMessage * message)
183 gboolean do_free = TRUE;
185 if (GST_MINI_OBJECT_FLAG_IS_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY)) {
186 /* revive message, so bus can finish with it and clean it up */
187 gst_message_ref (message);
189 GST_INFO ("[msg %p] signalling async free", message);
191 GST_MESSAGE_LOCK (message);
192 GST_MESSAGE_SIGNAL (message);
193 GST_MESSAGE_UNLOCK (message);
195 /* don't free it yet, let bus finish with it first */
203 _gst_message_free (GstMessage * message)
205 GstStructure *structure;
207 g_return_if_fail (message != NULL);
209 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
210 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
212 if (GST_MESSAGE_SRC (message)) {
213 gst_object_unref (GST_MESSAGE_SRC (message));
214 GST_MESSAGE_SRC (message) = NULL;
217 structure = GST_MESSAGE_STRUCTURE (message);
219 gst_structure_set_parent_refcount (structure, NULL);
220 gst_structure_free (structure);
223 memset (message, 0xff, sizeof (GstMessageImpl));
226 g_slice_free1 (sizeof (GstMessageImpl), message);
230 gst_message_init (GstMessageImpl * message, GstMessageType type,
234 _gst_message_copy (GstMessage * message)
236 GstMessageImpl *copy;
237 GstStructure *structure;
239 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
240 GST_MESSAGE_TYPE_NAME (message),
241 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
243 copy = g_slice_new0 (GstMessageImpl);
245 gst_message_init (copy, GST_MESSAGE_TYPE (message),
246 GST_MESSAGE_SRC (message));
248 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
249 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
251 structure = GST_MESSAGE_STRUCTURE (message);
253 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
254 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
255 ©->message.mini_object.refcount);
257 GST_MESSAGE_STRUCTURE (copy) = NULL;
260 return GST_MESSAGE_CAST (copy);
264 gst_message_init (GstMessageImpl * message, GstMessageType type,
267 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
268 (GstMiniObjectCopyFunction) _gst_message_copy,
269 (GstMiniObjectDisposeFunction) _gst_message_dispose,
270 (GstMiniObjectFreeFunction) _gst_message_free);
272 GST_MESSAGE_TYPE (message) = type;
274 gst_object_ref (src);
275 GST_MESSAGE_SRC (message) = src;
276 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
277 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
282 * gst_message_new_custom:
283 * @type: The #GstMessageType to distinguish messages
284 * @src: (transfer none) (allow-none): The object originating the message.
285 * @structure: (transfer full) (allow-none): the structure for the
286 * message. The message will take ownership of the structure.
288 * Create a new custom-typed message. This can be used for anything not
289 * handled by other message-specific functions to pass a message to the
290 * app. The structure field can be %NULL.
292 * Returns: (transfer full) (nullable): The new message.
297 gst_message_new_custom (GstMessageType type, GstObject * src,
298 GstStructure * structure)
300 GstMessageImpl *message;
302 message = g_slice_new0 (GstMessageImpl);
304 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
305 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
306 gst_message_type_get_name (type));
309 /* structure must not have a parent */
310 if (!gst_structure_set_parent_refcount (structure,
311 &message->message.mini_object.refcount))
314 gst_message_init (message, type, src);
316 GST_MESSAGE_STRUCTURE (message) = structure;
318 return GST_MESSAGE_CAST (message);
323 g_slice_free1 (sizeof (GstMessageImpl), message);
324 g_warning ("structure is already owned by another object");
330 * gst_message_get_seqnum:
331 * @message: A #GstMessage.
333 * Retrieve the sequence number of a message.
335 * Messages have ever-incrementing sequence numbers, which may also be set
336 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
337 * to indicate that a message corresponds to some other set of messages or
338 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
339 * is considered good practice to make this correspondence when possible, though
340 * it is not required.
342 * Note that events and messages share the same sequence number incrementor;
343 * two events or messages will never have the same sequence number unless
344 * that correspondence was made explicitly.
346 * Returns: The message's sequence number.
351 gst_message_get_seqnum (GstMessage * message)
353 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
355 return GST_MESSAGE_SEQNUM (message);
359 * gst_message_set_seqnum:
360 * @message: A #GstMessage.
361 * @seqnum: A sequence number.
363 * Set the sequence number of a message.
365 * This function might be called by the creator of a message to indicate that
366 * the message relates to other messages or events. See gst_message_get_seqnum()
367 * for more information.
372 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
374 g_return_if_fail (GST_IS_MESSAGE (message));
375 g_return_if_fail (seqnum != GST_SEQNUM_INVALID);
377 GST_MESSAGE_SEQNUM (message) = seqnum;
381 * gst_message_new_eos:
382 * @src: (transfer none) (allow-none): The object originating the message.
384 * Create a new eos message. This message is generated and posted in
385 * the sink elements of a GstBin. The bin will only forward the EOS
386 * message to the application if all sinks have posted an EOS message.
388 * Returns: (transfer full): The new eos message.
393 gst_message_new_eos (GstObject * src)
397 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
403 * gst_message_new_error_with_details:
404 * @src: (transfer none) (allow-none): The object originating the message.
405 * @error: (transfer none): The GError for this message.
406 * @debug: A debugging string.
407 * @details: (transfer full) (allow-none): A GstStructure with details
409 * Create a new error message. The message will copy @error and
410 * @debug. This message is posted by element when a fatal event
411 * occurred. The pipeline will probably (partially) stop. The application
412 * receiving this message should stop the pipeline.
414 * Returns: (transfer full) (nullable): the new error message.
419 gst_message_new_error_with_details (GstObject * src, GError * error,
420 const gchar * debug, GstStructure * details)
423 GstStructure *structure;
425 if (debug && !g_utf8_validate (debug, -1, NULL)) {
427 g_warning ("Trying to set debug field of error message, but "
428 "string is not valid UTF-8. Please file a bug.");
431 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
432 GST_QUARK (GERROR), G_TYPE_ERROR, error,
433 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
434 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
436 GValue v = G_VALUE_INIT;
438 g_value_init (&v, GST_TYPE_STRUCTURE);
439 g_value_take_boxed (&v, details);
440 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
448 * gst_message_new_error:
449 * @src: (transfer none) (allow-none): The object originating the message.
450 * @error: (transfer none): The GError for this message.
451 * @debug: A debugging string.
453 * Create a new error message. The message will copy @error and
454 * @debug. This message is posted by element when a fatal event
455 * occurred. The pipeline will probably (partially) stop. The application
456 * receiving this message should stop the pipeline.
458 * Returns: (transfer full): the new error message.
463 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
465 return gst_message_new_error_with_details (src, error, debug, NULL);
469 * gst_message_parse_error_details:
470 * @message: The message object
471 * @structure: (transfer none) (out): A pointer to the returned details
473 * Returns the optional details structure, may be NULL if none.
474 * The returned structure must not be freed.
479 gst_message_parse_error_details (GstMessage * message,
480 const GstStructure ** structure)
484 g_return_if_fail (GST_IS_MESSAGE (message));
485 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
486 g_return_if_fail (structure != NULL);
489 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
492 *structure = g_value_get_boxed (v);
497 * gst_message_new_warning_with_details:
498 * @src: (transfer none) (allow-none): The object originating the message.
499 * @error: (transfer none): The GError for this message.
500 * @debug: A debugging string.
501 * @details: (transfer full) (allow-none): A GstStructure with details
503 * Create a new warning message. The message will make copies of @error and
506 * Returns: (transfer full) (nullable): the new warning message.
511 gst_message_new_warning_with_details (GstObject * src, GError * error,
512 const gchar * debug, GstStructure * details)
515 GstStructure *structure;
517 if (debug && !g_utf8_validate (debug, -1, NULL)) {
519 g_warning ("Trying to set debug field of warning message, but "
520 "string is not valid UTF-8. Please file a bug.");
523 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
524 GST_QUARK (GERROR), G_TYPE_ERROR, error,
525 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
526 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
528 GValue v = G_VALUE_INIT;
530 g_value_init (&v, GST_TYPE_STRUCTURE);
531 g_value_take_boxed (&v, details);
532 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
540 * gst_message_new_warning:
541 * @src: (transfer none) (allow-none): The object originating the message.
542 * @error: (transfer none): The GError for this message.
543 * @debug: A debugging string.
545 * Create a new warning message. The message will make copies of @error and
548 * Returns: (transfer full): the new warning message.
553 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
555 return gst_message_new_warning_with_details (src, error, debug, NULL);
559 * gst_message_parse_warning_details:
560 * @message: The message object
561 * @structure: (transfer none) (out): A pointer to the returned details structure
563 * Returns the optional details structure, may be NULL if none
564 * The returned structure must not be freed.
569 gst_message_parse_warning_details (GstMessage * message,
570 const GstStructure ** structure)
574 g_return_if_fail (GST_IS_MESSAGE (message));
575 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
576 g_return_if_fail (structure != NULL);
579 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
582 *structure = g_value_get_boxed (v);
587 * gst_message_new_info_with_details:
588 * @src: (transfer none) (allow-none): The object originating the message.
589 * @error: (transfer none): The GError for this message.
590 * @debug: A debugging string.
591 * @details: (transfer full) (allow-none): A GstStructure with details
593 * Create a new info message. The message will make copies of @error and
596 * Returns: (transfer full) (nullable): the new warning message.
601 gst_message_new_info_with_details (GstObject * src, GError * error,
602 const gchar * debug, GstStructure * details)
605 GstStructure *structure;
607 if (debug && !g_utf8_validate (debug, -1, NULL)) {
609 g_warning ("Trying to set debug field of info message, but "
610 "string is not valid UTF-8. Please file a bug.");
613 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
614 GST_QUARK (GERROR), G_TYPE_ERROR, error,
615 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
616 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
618 GValue v = G_VALUE_INIT;
620 g_value_init (&v, GST_TYPE_STRUCTURE);
621 g_value_take_boxed (&v, details);
622 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
630 * gst_message_new_info:
631 * @src: (transfer none) (allow-none): The object originating the message.
632 * @error: (transfer none): The GError for this message.
633 * @debug: A debugging string.
635 * Create a new info message. The message will make copies of @error and
638 * Returns: (transfer full): the new info message.
643 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
645 return gst_message_new_info_with_details (src, error, debug, NULL);
649 * gst_message_parse_info_details:
650 * @message: The message object
651 * @structure: (transfer none) (out): A pointer to the returned details structure
653 * Returns the optional details structure, may be NULL if none
654 * The returned structure must not be freed.
659 gst_message_parse_info_details (GstMessage * message,
660 const GstStructure ** structure)
664 g_return_if_fail (GST_IS_MESSAGE (message));
665 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
666 g_return_if_fail (structure != NULL);
669 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
672 *structure = g_value_get_boxed (v);
677 * gst_message_new_tag:
678 * @src: (transfer none) (allow-none): The object originating the message.
679 * @tag_list: (transfer full): the tag list for the message.
681 * Create a new tag message. The message will take ownership of the tag list.
682 * The message is posted by elements that discovered a new taglist.
684 * Returns: (transfer full): the new tag message.
689 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
693 GValue val = G_VALUE_INIT;
695 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
697 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
698 g_value_init (&val, GST_TYPE_TAG_LIST);
699 g_value_take_boxed (&val, tag_list);
700 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
701 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
706 * gst_message_new_buffering:
707 * @src: (transfer none) (allow-none): The object originating the message.
708 * @percent: The buffering percent
710 * Create a new buffering message. This message can be posted by an element that
711 * needs to buffer data before it can continue processing. @percent should be a
712 * value between 0 and 100. A value of 100 means that the buffering completed.
714 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
715 * @percent is 100, the application can set the pipeline (back) to PLAYING.
716 * The application must be prepared to receive BUFFERING messages in the
717 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
718 * message with @percent set to 100, which can happen after the pipeline
719 * completed prerolling.
723 * Returns: (transfer full) (nullable): The new buffering message.
726 gst_message_new_buffering (GstObject * src, gint percent)
729 GstStructure *structure;
730 gint64 buffering_left;
732 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
734 buffering_left = (percent == 100 ? 0 : -1);
736 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
737 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
738 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
739 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
740 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
741 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
742 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
748 * gst_message_new_state_changed:
749 * @src: (transfer none) (allow-none): The object originating the message.
750 * @oldstate: the previous state
751 * @newstate: the new (current) state
752 * @pending: the pending (target) state
754 * Create a state change message. This message is posted whenever an element
757 * Returns: (transfer full): the new state change message.
762 gst_message_new_state_changed (GstObject * src,
763 GstState oldstate, GstState newstate, GstState pending)
766 GstStructure *structure;
768 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
769 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
770 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
771 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
772 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
778 * gst_message_new_state_dirty:
779 * @src: (transfer none) (allow-none): The object originating the message
781 * Create a state dirty message. This message is posted whenever an element
782 * changed its state asynchronously and is used internally to update the
783 * states of container objects.
785 * Returns: (transfer full): the new state dirty message.
790 gst_message_new_state_dirty (GstObject * src)
794 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
800 * gst_message_new_clock_provide:
801 * @src: (transfer none) (allow-none): The object originating the message.
802 * @clock: (transfer none): the clock it provides
803 * @ready: %TRUE if the sender can provide a clock
805 * Create a clock provide message. This message is posted whenever an
806 * element is ready to provide a clock or lost its ability to provide
807 * a clock (maybe because it paused or became EOS).
809 * This message is mainly used internally to manage the clock
812 * Returns: (transfer full): the new provide clock message.
817 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
821 GstStructure *structure;
823 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
824 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
825 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
826 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
832 * gst_message_new_clock_lost:
833 * @src: (transfer none) (allow-none): The object originating the message.
834 * @clock: (transfer none): the clock that was lost
836 * Create a clock lost message. This message is posted whenever the
837 * clock is not valid anymore.
839 * If this message is posted by the pipeline, the pipeline will
840 * select a new clock again when it goes to PLAYING. It might therefore
841 * be needed to set the pipeline to PAUSED and PLAYING again.
843 * Returns: (transfer full): The new clock lost message.
848 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
851 GstStructure *structure;
853 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
854 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
855 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
861 * gst_message_new_new_clock:
862 * @src: (transfer none) (allow-none): The object originating the message.
863 * @clock: (transfer none): the new selected clock
865 * Create a new clock message. This message is posted whenever the
866 * pipeline selects a new clock for the pipeline.
868 * Returns: (transfer full): The new new clock message.
873 gst_message_new_new_clock (GstObject * src, GstClock * clock)
876 GstStructure *structure;
878 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
879 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
880 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
886 * gst_message_new_structure_change:
887 * @src: (transfer none) (allow-none): The object originating the message.
888 * @type: The change type.
889 * @owner: (transfer none): The owner element of @src.
890 * @busy: Whether the structure change is busy.
892 * Create a new structure change message. This message is posted when the
893 * structure of a pipeline is in the process of being changed, for example
894 * when pads are linked or unlinked.
896 * @src should be the sinkpad that unlinked or linked.
898 * Returns: (transfer full): the new structure change message.
903 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
904 GstElement * owner, gboolean busy)
907 GstStructure *structure;
909 g_return_val_if_fail (GST_IS_PAD (src), NULL);
910 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
911 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
913 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
914 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
915 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
916 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
918 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
925 * gst_message_new_segment_start:
926 * @src: (transfer none) (allow-none): The object originating the message.
927 * @format: The format of the position being played
928 * @position: The position of the segment being played
930 * Create a new segment message. This message is posted by elements that
931 * start playback of a segment as a result of a segment seek. This message
932 * is not received by the application but is used for maintenance reasons in
933 * container elements.
935 * Returns: (transfer full): the new segment start message.
940 gst_message_new_segment_start (GstObject * src, GstFormat format,
944 GstStructure *structure;
946 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
947 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
948 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
949 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
955 * gst_message_new_segment_done:
956 * @src: (transfer none) (allow-none): The object originating the message.
957 * @format: The format of the position being done
958 * @position: The position of the segment being done
960 * Create a new segment done message. This message is posted by elements that
961 * finish playback of a segment as a result of a segment seek. This message
962 * is received by the application after all elements that posted a segment_start
963 * have posted the segment_done.
965 * Returns: (transfer full): the new segment done message.
970 gst_message_new_segment_done (GstObject * src, GstFormat format,
974 GstStructure *structure;
976 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
977 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
978 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
979 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
985 * gst_message_new_application:
986 * @src: (transfer none) (allow-none): The object originating the message.
987 * @structure: (transfer full): the structure for the message. The message
988 * will take ownership of the structure.
990 * Create a new application-typed message. GStreamer will never create these
991 * messages; they are a gift from us to you. Enjoy.
993 * Returns: (transfer full) (nullable): The new application message.
998 gst_message_new_application (GstObject * src, GstStructure * structure)
1000 g_return_val_if_fail (structure != NULL, NULL);
1002 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
1006 * gst_message_new_element:
1007 * @src: (transfer none) (allow-none): The object originating the message.
1008 * @structure: (transfer full): The structure for the
1009 * message. The message will take ownership of the structure.
1011 * Create a new element-specific message. This is meant as a generic way of
1012 * allowing one-way communication from an element to an application, for example
1013 * "the firewire cable was unplugged". The format of the message should be
1014 * documented in the element's documentation. The structure field can be %NULL.
1016 * Returns: (transfer full) (nullable): The new element message.
1021 gst_message_new_element (GstObject * src, GstStructure * structure)
1023 g_return_val_if_fail (structure != NULL, NULL);
1025 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
1029 * gst_message_new_duration_changed:
1030 * @src: (transfer none) (allow-none): The object originating the message.
1032 * Create a new duration changed message. This message is posted by elements
1033 * that know the duration of a stream when the duration changes. This message
1034 * is received by bins and is used to calculate the total duration of a
1037 * Returns: (transfer full): The new duration-changed message.
1042 gst_message_new_duration_changed (GstObject * src)
1044 GstMessage *message;
1046 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
1047 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
1053 * gst_message_new_async_start:
1054 * @src: (transfer none) (allow-none): The object originating the message.
1056 * This message is posted by elements when they start an ASYNC state change.
1058 * Returns: (transfer full): The new async_start message.
1063 gst_message_new_async_start (GstObject * src)
1065 GstMessage *message;
1067 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
1073 * gst_message_new_async_done:
1074 * @src: (transfer none) (allow-none): The object originating the message.
1075 * @running_time: the desired running_time
1077 * The message is posted when elements completed an ASYNC state change.
1078 * @running_time contains the time of the desired running_time when this
1079 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
1080 * means that the element has no clock interaction and thus doesn't care about
1081 * the running_time of the pipeline.
1083 * Returns: (transfer full): The new async_done message.
1088 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
1090 GstMessage *message;
1091 GstStructure *structure;
1093 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
1094 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
1095 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
1101 * gst_message_new_latency:
1102 * @src: (transfer none) (allow-none): The object originating the message.
1104 * This message can be posted by elements when their latency requirements have
1107 * Returns: (transfer full): The new latency message.
1112 gst_message_new_latency (GstObject * src)
1114 GstMessage *message;
1116 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
1122 * gst_message_new_request_state:
1123 * @src: (transfer none) (allow-none): The object originating the message.
1124 * @state: The new requested state
1126 * This message can be posted by elements when they want to have their state
1127 * changed. A typical use case would be an audio server that wants to pause the
1128 * pipeline because a higher priority stream is being played.
1130 * Returns: (transfer full): the new request state message.
1135 gst_message_new_request_state (GstObject * src, GstState state)
1137 GstMessage *message;
1138 GstStructure *structure;
1140 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
1141 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
1142 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
1148 * gst_message_get_structure:
1149 * @message: The #GstMessage.
1151 * Access the structure of the message.
1153 * Returns: (transfer none) (nullable): The structure of the message. The
1154 * structure is still owned by the message, which means that you should not
1155 * free it and that the pointer becomes invalid when you free the message.
1159 const GstStructure *
1160 gst_message_get_structure (GstMessage * message)
1162 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1164 return GST_MESSAGE_STRUCTURE (message);
1168 * gst_message_writable_structure:
1169 * @message: A writable #GstMessage.
1171 * Get a writable version of the structure.
1173 * Returns: (transfer none): The structure of the message. The structure
1174 * is still owned by the message, which means that you should not free
1175 * it and that the pointer becomes invalid when you free the message.
1176 * This function ensures that @message is writable, and if so, will
1177 * never return %NULL.
1184 gst_message_writable_structure (GstMessage * message)
1186 GstStructure *structure;
1188 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1189 g_return_val_if_fail (gst_message_is_writable (message), NULL);
1191 structure = GST_MESSAGE_STRUCTURE (message);
1193 if (structure == NULL) {
1195 gst_structure_new_id_empty (gst_message_type_to_quark (GST_MESSAGE_TYPE
1197 gst_structure_set_parent_refcount (structure,
1198 &message->mini_object.refcount);
1199 GST_MESSAGE_STRUCTURE (message) = structure;
1205 * gst_message_has_name:
1206 * @message: The #GstMessage.
1207 * @name: name to check
1209 * Checks if @message has the given @name. This function is usually used to
1210 * check the name of a custom message.
1212 * Returns: %TRUE if @name matches the name of the message structure.
1215 gst_message_has_name (GstMessage * message, const gchar * name)
1217 GstStructure *structure;
1219 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
1221 structure = GST_MESSAGE_STRUCTURE (message);
1222 if (structure == NULL)
1225 return gst_structure_has_name (structure, name);
1229 * gst_message_parse_tag:
1230 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1231 * @tag_list: (out callee-allocates): return location for the tag-list.
1233 * Extracts the tag list from the GstMessage. The tag list returned in the
1234 * output argument is a copy; the caller must free it when done.
1236 * Typical usage of this function might be:
1237 * |[<!-- language="C" -->
1239 * switch (GST_MESSAGE_TYPE (msg)) {
1240 * case GST_MESSAGE_TAG: {
1241 * GstTagList *tags = NULL;
1243 * gst_message_parse_tag (msg, &tags);
1244 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1245 * handle_tags (tags);
1246 * gst_tag_list_unref (tags);
1257 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1259 g_return_if_fail (GST_IS_MESSAGE (message));
1260 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1261 g_return_if_fail (tag_list != NULL);
1263 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1264 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1268 * gst_message_parse_buffering:
1269 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1270 * @percent: (out) (allow-none): Return location for the percent.
1272 * Extracts the buffering percent from the GstMessage. see also
1273 * gst_message_new_buffering().
1278 gst_message_parse_buffering (GstMessage * message, gint * percent)
1280 g_return_if_fail (GST_IS_MESSAGE (message));
1281 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1285 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1286 (message), GST_QUARK (BUFFER_PERCENT)));
1290 * gst_message_set_buffering_stats:
1291 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1292 * @mode: a buffering mode
1293 * @avg_in: the average input rate
1294 * @avg_out: the average output rate
1295 * @buffering_left: amount of buffering time left in milliseconds
1297 * Configures the buffering stats values in @message.
1300 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1301 gint avg_in, gint avg_out, gint64 buffering_left)
1303 g_return_if_fail (GST_IS_MESSAGE (message));
1304 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1306 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1307 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1308 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1309 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1310 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1314 * gst_message_parse_buffering_stats:
1315 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1316 * @mode: (out) (allow-none): a buffering mode, or %NULL
1317 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1318 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1319 * @buffering_left: (out) (allow-none): amount of buffering time left in
1320 * milliseconds, or %NULL
1322 * Extracts the buffering stats values from @message.
1325 gst_message_parse_buffering_stats (GstMessage * message,
1326 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1327 gint64 * buffering_left)
1329 GstStructure *structure;
1331 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1333 structure = GST_MESSAGE_STRUCTURE (message);
1335 *mode = (GstBufferingMode)
1336 g_value_get_enum (gst_structure_id_get_value (structure,
1337 GST_QUARK (BUFFERING_MODE)));
1339 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1340 GST_QUARK (AVG_IN_RATE)));
1342 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1343 GST_QUARK (AVG_OUT_RATE)));
1346 g_value_get_int64 (gst_structure_id_get_value (structure,
1347 GST_QUARK (BUFFERING_LEFT)));
1351 * gst_message_parse_state_changed:
1352 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1353 * @oldstate: (out) (allow-none): the previous state, or %NULL
1354 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1355 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1357 * Extracts the old and new states from the GstMessage.
1359 * Typical usage of this function might be:
1360 * |[<!-- language="C" -->
1362 * switch (GST_MESSAGE_TYPE (msg)) {
1363 * case GST_MESSAGE_STATE_CHANGED: {
1364 * GstState old_state, new_state;
1366 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1367 * g_print ("Element %s changed state from %s to %s.\n",
1368 * GST_OBJECT_NAME (msg->src),
1369 * gst_element_state_get_name (old_state),
1370 * gst_element_state_get_name (new_state));
1381 gst_message_parse_state_changed (GstMessage * message,
1382 GstState * oldstate, GstState * newstate, GstState * pending)
1384 GstStructure *structure;
1386 g_return_if_fail (GST_IS_MESSAGE (message));
1387 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1389 structure = GST_MESSAGE_STRUCTURE (message);
1391 *oldstate = (GstState)
1392 g_value_get_enum (gst_structure_id_get_value (structure,
1393 GST_QUARK (OLD_STATE)));
1395 *newstate = (GstState)
1396 g_value_get_enum (gst_structure_id_get_value (structure,
1397 GST_QUARK (NEW_STATE)));
1399 *pending = (GstState)
1400 g_value_get_enum (gst_structure_id_get_value (structure,
1401 GST_QUARK (PENDING_STATE)));
1405 * gst_message_parse_clock_provide:
1406 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1407 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1409 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1411 * Extracts the clock and ready flag from the GstMessage.
1412 * The clock object returned remains valid until the message is freed.
1417 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1420 const GValue *clock_gvalue;
1421 GstStructure *structure;
1423 g_return_if_fail (GST_IS_MESSAGE (message));
1424 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1426 structure = GST_MESSAGE_STRUCTURE (message);
1427 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1428 g_return_if_fail (clock_gvalue != NULL);
1429 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1433 g_value_get_boolean (gst_structure_id_get_value (structure,
1434 GST_QUARK (READY)));
1436 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1440 * gst_message_parse_clock_lost:
1441 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1442 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1444 * Extracts the lost clock from the GstMessage.
1445 * The clock object returned remains valid until the message is freed.
1450 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1452 const GValue *clock_gvalue;
1453 GstStructure *structure;
1455 g_return_if_fail (GST_IS_MESSAGE (message));
1456 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1458 structure = GST_MESSAGE_STRUCTURE (message);
1459 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1460 g_return_if_fail (clock_gvalue != NULL);
1461 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1464 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1468 * gst_message_parse_new_clock:
1469 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1470 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1473 * Extracts the new clock from the GstMessage.
1474 * The clock object returned remains valid until the message is freed.
1479 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1481 const GValue *clock_gvalue;
1482 GstStructure *structure;
1484 g_return_if_fail (GST_IS_MESSAGE (message));
1485 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1487 structure = GST_MESSAGE_STRUCTURE (message);
1488 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1489 g_return_if_fail (clock_gvalue != NULL);
1490 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1493 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1497 * gst_message_parse_structure_change:
1498 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1499 * @type: (out): A pointer to hold the change type
1500 * @owner: (out) (allow-none) (transfer none): The owner element of the
1502 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1503 * progress or has been completed
1505 * Extracts the change type and completion status from the GstMessage.
1510 gst_message_parse_structure_change (GstMessage * message,
1511 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1513 const GValue *owner_gvalue;
1514 GstStructure *structure;
1516 g_return_if_fail (GST_IS_MESSAGE (message));
1517 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1519 structure = GST_MESSAGE_STRUCTURE (message);
1520 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1521 g_return_if_fail (owner_gvalue != NULL);
1522 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1525 *type = (GstStructureChangeType)
1526 g_value_get_enum (gst_structure_id_get_value (structure,
1529 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1532 g_value_get_boolean (gst_structure_id_get_value (structure,
1537 * gst_message_parse_error:
1538 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1539 * @gerror: (out) (allow-none) (transfer full): location for the GError
1540 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1543 * Extracts the GError and debug string from the GstMessage. The values returned
1544 * in the output arguments are copies; the caller must free them when done.
1546 * Typical usage of this function might be:
1547 * |[<!-- language="C" -->
1549 * switch (GST_MESSAGE_TYPE (msg)) {
1550 * case GST_MESSAGE_ERROR: {
1551 * GError *err = NULL;
1552 * gchar *dbg_info = NULL;
1554 * gst_message_parse_error (msg, &err, &dbg_info);
1555 * g_printerr ("ERROR from element %s: %s\n",
1556 * GST_OBJECT_NAME (msg->src), err->message);
1557 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1558 * g_error_free (err);
1559 * g_free (dbg_info);
1570 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1572 g_return_if_fail (GST_IS_MESSAGE (message));
1573 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1575 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1576 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1577 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1581 * gst_message_parse_warning:
1582 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1583 * @gerror: (out) (allow-none) (transfer full): location for the GError
1584 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1587 * Extracts the GError and debug string from the GstMessage. The values returned
1588 * in the output arguments are copies; the caller must free them when done.
1593 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1596 g_return_if_fail (GST_IS_MESSAGE (message));
1597 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1599 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1600 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1601 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1605 * gst_message_parse_info:
1606 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1607 * @gerror: (out) (allow-none) (transfer full): location for the GError
1608 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1611 * Extracts the GError and debug string from the GstMessage. The values returned
1612 * in the output arguments are copies; the caller must free them when done.
1617 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1619 g_return_if_fail (GST_IS_MESSAGE (message));
1620 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1622 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1623 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1624 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1628 * gst_message_parse_segment_start:
1629 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1630 * @format: (out) (allow-none): Result location for the format, or %NULL
1631 * @position: (out) (allow-none): Result location for the position, or %NULL
1633 * Extracts the position and format from the segment start message.
1638 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1641 GstStructure *structure;
1643 g_return_if_fail (GST_IS_MESSAGE (message));
1644 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1646 structure = GST_MESSAGE_STRUCTURE (message);
1648 *format = (GstFormat)
1649 g_value_get_enum (gst_structure_id_get_value (structure,
1650 GST_QUARK (FORMAT)));
1653 g_value_get_int64 (gst_structure_id_get_value (structure,
1654 GST_QUARK (POSITION)));
1658 * gst_message_parse_segment_done:
1659 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1660 * @format: (out) (allow-none): Result location for the format, or %NULL
1661 * @position: (out) (allow-none): Result location for the position, or %NULL
1663 * Extracts the position and format from the segment done message.
1668 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1671 GstStructure *structure;
1673 g_return_if_fail (GST_IS_MESSAGE (message));
1674 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1676 structure = GST_MESSAGE_STRUCTURE (message);
1678 *format = (GstFormat)
1679 g_value_get_enum (gst_structure_id_get_value (structure,
1680 GST_QUARK (FORMAT)));
1683 g_value_get_int64 (gst_structure_id_get_value (structure,
1684 GST_QUARK (POSITION)));
1688 * gst_message_parse_async_done:
1689 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1690 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1692 * Extract the running_time from the async_done message.
1697 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1699 GstStructure *structure;
1701 g_return_if_fail (GST_IS_MESSAGE (message));
1702 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1704 structure = GST_MESSAGE_STRUCTURE (message);
1707 g_value_get_uint64 (gst_structure_id_get_value (structure,
1708 GST_QUARK (RUNNING_TIME)));
1712 * gst_message_parse_request_state:
1713 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1714 * @state: (out) (allow-none): Result location for the requested state or %NULL
1716 * Extract the requested state from the request_state message.
1721 gst_message_parse_request_state (GstMessage * message, GstState * state)
1723 GstStructure *structure;
1725 g_return_if_fail (GST_IS_MESSAGE (message));
1726 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1728 structure = GST_MESSAGE_STRUCTURE (message);
1731 g_value_get_enum (gst_structure_id_get_value (structure,
1732 GST_QUARK (NEW_STATE)));
1736 * gst_message_new_stream_status:
1737 * @src: The object originating the message.
1738 * @type: The stream status type.
1739 * @owner: (transfer none): the owner element of @src.
1741 * Create a new stream status message. This message is posted when a streaming
1742 * thread is created/destroyed or when the state changed.
1744 * Returns: (transfer full): the new stream status message.
1749 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1752 GstMessage *message;
1753 GstStructure *structure;
1755 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1756 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1757 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1758 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1764 * gst_message_parse_stream_status:
1765 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1766 * @type: (out): A pointer to hold the status type
1767 * @owner: (out) (transfer none): The owner element of the message source
1769 * Extracts the stream status type and owner the GstMessage. The returned
1770 * owner remains valid for as long as the reference to @message is valid and
1771 * should thus not be unreffed.
1776 gst_message_parse_stream_status (GstMessage * message,
1777 GstStreamStatusType * type, GstElement ** owner)
1779 const GValue *owner_gvalue;
1780 GstStructure *structure;
1782 g_return_if_fail (GST_IS_MESSAGE (message));
1783 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1785 structure = GST_MESSAGE_STRUCTURE (message);
1786 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1787 g_return_if_fail (owner_gvalue != NULL);
1790 *type = (GstStreamStatusType)
1791 g_value_get_enum (gst_structure_id_get_value (structure,
1794 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1798 * gst_message_set_stream_status_object:
1799 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1800 * @object: the object controlling the streaming
1802 * Configures the object handling the streaming thread. This is usually a
1803 * GstTask object but other objects might be added in the future.
1806 gst_message_set_stream_status_object (GstMessage * message,
1807 const GValue * object)
1809 GstStructure *structure;
1811 g_return_if_fail (GST_IS_MESSAGE (message));
1812 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1814 structure = GST_MESSAGE_STRUCTURE (message);
1815 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1819 * gst_message_get_stream_status_object:
1820 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1822 * Extracts the object managing the streaming thread from @message.
1824 * Returns: (nullable): a GValue containing the object that manages the
1825 * streaming thread. This object is usually of type GstTask but other types can
1826 * be added in the future. The object remains valid as long as @message is
1830 gst_message_get_stream_status_object (GstMessage * message)
1832 const GValue *result;
1833 GstStructure *structure;
1835 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1836 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1839 structure = GST_MESSAGE_STRUCTURE (message);
1840 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1846 * gst_message_new_step_done:
1847 * @src: The object originating the message.
1848 * @format: the format of @amount
1849 * @amount: the amount of stepped data
1850 * @rate: the rate of the stepped amount
1851 * @flush: is this an flushing step
1852 * @intermediate: is this an intermediate step
1853 * @duration: the duration of the data
1854 * @eos: the step caused EOS
1856 * This message is posted by elements when they complete a part, when @intermediate set
1857 * to %TRUE, or a complete step operation.
1859 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1860 * @amount of media in format @format.
1862 * Returns: (transfer full): the new step_done message.
1867 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1868 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1871 GstMessage *message;
1872 GstStructure *structure;
1874 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1875 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1876 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1877 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1878 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1879 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1880 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1881 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1882 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1888 * gst_message_parse_step_done:
1889 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1890 * @format: (out) (allow-none): result location for the format
1891 * @amount: (out) (allow-none): result location for the amount
1892 * @rate: (out) (allow-none): result location for the rate
1893 * @flush: (out) (allow-none): result location for the flush flag
1894 * @intermediate: (out) (allow-none): result location for the intermediate flag
1895 * @duration: (out) (allow-none): result location for the duration
1896 * @eos: (out) (allow-none): result location for the EOS flag
1898 * Extract the values the step_done message.
1903 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1904 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1905 guint64 * duration, gboolean * eos)
1907 GstStructure *structure;
1909 g_return_if_fail (GST_IS_MESSAGE (message));
1910 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1912 structure = GST_MESSAGE_STRUCTURE (message);
1913 gst_structure_id_get (structure,
1914 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1915 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1916 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1917 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1918 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1919 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1920 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1924 * gst_message_new_step_start:
1925 * @src: The object originating the message.
1926 * @active: if the step is active or queued
1927 * @format: the format of @amount
1928 * @amount: the amount of stepped data
1929 * @rate: the rate of the stepped amount
1930 * @flush: is this an flushing step
1931 * @intermediate: is this an intermediate step
1933 * This message is posted by elements when they accept or activate a new step
1934 * event for @amount in @format.
1936 * @active is set to %FALSE when the element accepted the new step event and has
1937 * queued it for execution in the streaming threads.
1939 * @active is set to %TRUE when the element has activated the step operation and
1940 * is now ready to start executing the step in the streaming thread. After this
1941 * message is emitted, the application can queue a new step operation in the
1944 * Returns: (transfer full): The new step_start message.
1949 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1950 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1952 GstMessage *message;
1953 GstStructure *structure;
1955 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1956 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1957 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1958 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1959 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1960 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1961 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1962 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1968 * gst_message_parse_step_start:
1969 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1970 * @active: (out) (allow-none): result location for the active flag
1971 * @format: (out) (allow-none): result location for the format
1972 * @amount: (out) (allow-none): result location for the amount
1973 * @rate: (out) (allow-none): result location for the rate
1974 * @flush: (out) (allow-none): result location for the flush flag
1975 * @intermediate: (out) (allow-none): result location for the intermediate flag
1977 * Extract the values from step_start message.
1982 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1983 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1984 gboolean * intermediate)
1986 GstStructure *structure;
1988 g_return_if_fail (GST_IS_MESSAGE (message));
1989 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1991 structure = GST_MESSAGE_STRUCTURE (message);
1992 gst_structure_id_get (structure,
1993 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1994 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1995 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1996 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1997 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1998 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
2002 * gst_message_new_qos:
2003 * @src: The object originating the message.
2004 * @live: if the message was generated by a live element
2005 * @running_time: the running time of the buffer that generated the message
2006 * @stream_time: the stream time of the buffer that generated the message
2007 * @timestamp: the timestamps of the buffer that generated the message
2008 * @duration: the duration of the buffer that generated the message
2010 * A QOS message is posted on the bus whenever an element decides to drop a
2011 * buffer because of QoS reasons or whenever it changes its processing strategy
2012 * because of QoS reasons (quality adjustments such as processing at lower
2015 * This message can be posted by an element that performs synchronisation against the
2016 * clock (live) or it could be dropped by an element that performs QoS because of QOS
2017 * events received from a downstream element (!live).
2019 * @running_time, @stream_time, @timestamp, @duration should be set to the
2020 * respective running-time, stream-time, timestamp and duration of the (dropped)
2021 * buffer that generated the QoS event. Values can be left to
2022 * GST_CLOCK_TIME_NONE when unknown.
2024 * Returns: (transfer full): The new qos message.
2029 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
2030 guint64 stream_time, guint64 timestamp, guint64 duration)
2032 GstMessage *message;
2033 GstStructure *structure;
2035 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
2036 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2037 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2038 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2039 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2040 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
2041 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
2042 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
2043 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
2044 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
2045 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
2046 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
2047 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
2053 * gst_message_set_qos_values:
2054 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2055 * @jitter: The difference of the running-time against the deadline.
2056 * @proportion: Long term prediction of the ideal rate relative to normal rate
2057 * to get optimal quality.
2058 * @quality: An element dependent integer value that specifies the current
2059 * quality level of the element. The default maximum quality is 1000000.
2061 * Set the QoS values that have been calculated/analysed from the QoS data
2066 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
2067 gdouble proportion, gint quality)
2069 GstStructure *structure;
2071 g_return_if_fail (GST_IS_MESSAGE (message));
2072 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2074 structure = GST_MESSAGE_STRUCTURE (message);
2075 gst_structure_id_set (structure,
2076 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2077 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2078 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2082 * gst_message_set_qos_stats:
2083 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2084 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
2085 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
2086 * will likely use GST_FORMAT_DEFAULT (samples).
2087 * @processed: Total number of units correctly processed since the last state
2088 * change to READY or a flushing operation.
2089 * @dropped: Total number of units dropped since the last state change to READY
2090 * or a flushing operation.
2092 * Set the QoS stats representing the history of the current continuous pipeline
2095 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2096 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2101 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
2102 guint64 processed, guint64 dropped)
2104 GstStructure *structure;
2106 g_return_if_fail (GST_IS_MESSAGE (message));
2107 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2109 structure = GST_MESSAGE_STRUCTURE (message);
2110 gst_structure_id_set (structure,
2111 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2112 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2113 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2117 * gst_message_parse_qos:
2118 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2119 * @live: (out) (allow-none): if the message was generated by a live element
2120 * @running_time: (out) (allow-none): the running time of the buffer that
2121 * generated the message
2122 * @stream_time: (out) (allow-none): the stream time of the buffer that
2123 * generated the message
2124 * @timestamp: (out) (allow-none): the timestamps of the buffer that
2125 * generated the message
2126 * @duration: (out) (allow-none): the duration of the buffer that
2127 * generated the message
2129 * Extract the timestamps and live status from the QoS message.
2131 * The returned values give the running_time, stream_time, timestamp and
2132 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2138 gst_message_parse_qos (GstMessage * message, gboolean * live,
2139 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2142 GstStructure *structure;
2144 g_return_if_fail (GST_IS_MESSAGE (message));
2145 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2147 structure = GST_MESSAGE_STRUCTURE (message);
2148 gst_structure_id_get (structure,
2149 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2150 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2151 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2152 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2153 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2157 * gst_message_parse_qos_values:
2158 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2159 * @jitter: (out) (allow-none): The difference of the running-time against
2161 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2162 * relative to normal rate to get optimal quality.
2163 * @quality: (out) (allow-none): An element dependent integer value that
2164 * specifies the current quality level of the element. The default
2165 * maximum quality is 1000000.
2167 * Extract the QoS values that have been calculated/analysed from the QoS data
2172 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2173 gdouble * proportion, gint * quality)
2175 GstStructure *structure;
2177 g_return_if_fail (GST_IS_MESSAGE (message));
2178 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2180 structure = GST_MESSAGE_STRUCTURE (message);
2181 gst_structure_id_get (structure,
2182 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2183 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2184 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2188 * gst_message_parse_qos_stats:
2189 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2190 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2191 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2192 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2194 * @processed: (out) (allow-none): Total number of units correctly processed
2195 * since the last state change to READY or a flushing operation.
2196 * @dropped: (out) (allow-none): Total number of units dropped since the last
2197 * state change to READY or a flushing operation.
2199 * Extract the QoS stats representing the history of the current continuous
2200 * pipeline playback period.
2202 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2203 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2208 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2209 guint64 * processed, guint64 * dropped)
2211 GstStructure *structure;
2213 g_return_if_fail (GST_IS_MESSAGE (message));
2214 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2216 structure = GST_MESSAGE_STRUCTURE (message);
2217 gst_structure_id_get (structure,
2218 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2219 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2220 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2224 * gst_message_new_progress:
2225 * @src: The object originating the message.
2226 * @type: a #GstProgressType
2227 * @code: a progress code
2228 * @text: free, user visible text describing the progress
2230 * Progress messages are posted by elements when they use an asynchronous task
2231 * to perform actions triggered by a state change.
2233 * @code contains a well defined string describing the action.
2234 * @text should contain a user visible string detailing the current action.
2236 * Returns: (transfer full) (nullable): The new qos message.
2239 gst_message_new_progress (GstObject * src, GstProgressType type,
2240 const gchar * code, const gchar * text)
2242 GstMessage *message;
2243 GstStructure *structure;
2244 gint percent = 100, timeout = -1;
2246 g_return_val_if_fail (code != NULL, NULL);
2247 g_return_val_if_fail (text != NULL, NULL);
2249 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2252 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2253 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2254 GST_QUARK (CODE), G_TYPE_STRING, code,
2255 GST_QUARK (TEXT), G_TYPE_STRING, text,
2256 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2257 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2258 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2264 * gst_message_parse_progress:
2265 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2266 * @type: (out) (allow-none): location for the type
2267 * @code: (out) (allow-none) (transfer full): location for the code
2268 * @text: (out) (allow-none) (transfer full): location for the text
2270 * Parses the progress @type, @code and @text.
2273 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2274 gchar ** code, gchar ** text)
2276 GstStructure *structure;
2278 g_return_if_fail (GST_IS_MESSAGE (message));
2279 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2281 structure = GST_MESSAGE_STRUCTURE (message);
2282 gst_structure_id_get (structure,
2283 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2284 GST_QUARK (CODE), G_TYPE_STRING, code,
2285 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2289 * gst_message_new_toc:
2290 * @src: the object originating the message.
2291 * @toc: (transfer none): #GstToc structure for the message.
2292 * @updated: whether TOC was updated or not.
2294 * Create a new TOC message. The message is posted by elements
2295 * that discovered or updated a TOC.
2297 * Returns: (transfer full): a new TOC message.
2302 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2304 GstStructure *toc_struct;
2306 g_return_val_if_fail (toc != NULL, NULL);
2308 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2309 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2310 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2312 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2316 * gst_message_parse_toc:
2317 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2318 * @toc: (out) (transfer full): return location for the TOC.
2319 * @updated: (out): return location for the updated flag.
2321 * Extract the TOC from the #GstMessage. The TOC returned in the
2322 * output argument is a copy; the caller must free it with
2323 * gst_toc_unref() when done.
2328 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2330 g_return_if_fail (GST_IS_MESSAGE (message));
2331 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2332 g_return_if_fail (toc != NULL);
2334 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2335 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2336 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2340 * gst_message_new_reset_time:
2341 * @src: (transfer none) (allow-none): The object originating the message.
2342 * @running_time: the requested running-time
2344 * This message is posted when the pipeline running-time should be reset to
2345 * @running_time, like after a flushing seek.
2347 * Returns: (transfer full): The new reset_time message.
2352 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2354 GstMessage *message;
2355 GstStructure *structure;
2357 g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (running_time), NULL);
2359 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2360 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2361 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2367 * gst_message_parse_reset_time:
2368 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2369 * @running_time: (out) (allow-none): Result location for the running_time or
2372 * Extract the running-time from the RESET_TIME message.
2377 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2379 GstStructure *structure;
2381 g_return_if_fail (GST_IS_MESSAGE (message));
2382 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2384 structure = GST_MESSAGE_STRUCTURE (message);
2387 g_value_get_uint64 (gst_structure_id_get_value (structure,
2388 GST_QUARK (RUNNING_TIME)));
2392 * gst_message_new_stream_start:
2393 * @src: (transfer none) (allow-none): The object originating the message.
2395 * Create a new stream_start message. This message is generated and posted in
2396 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2397 * message to the application if all sinks have posted an STREAM_START message.
2399 * Returns: (transfer full): The new stream_start message.
2404 gst_message_new_stream_start (GstObject * src)
2406 GstMessage *message;
2409 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2410 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2417 * gst_message_set_group_id:
2418 * @message: the message
2419 * @group_id: the group id
2421 * Sets the group id on the stream-start message.
2423 * All streams that have the same group id are supposed to be played
2424 * together, i.e. all streams inside a container file should have the
2425 * same group id but different stream ids. The group id should change
2426 * each time the stream is started, resulting in different group ids
2427 * each time a file is played for example.
2434 gst_message_set_group_id (GstMessage * message, guint group_id)
2436 GstStructure *structure;
2438 g_return_if_fail (GST_IS_MESSAGE (message));
2439 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2440 g_return_if_fail (gst_message_is_writable (message));
2441 g_return_if_fail (group_id != GST_GROUP_ID_INVALID);
2443 structure = GST_MESSAGE_STRUCTURE (message);
2444 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2449 * gst_message_parse_group_id:
2450 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2451 * @group_id: (out) (allow-none): Result location for the group id or
2454 * Extract the group from the STREAM_START message.
2456 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2463 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2465 GstStructure *structure;
2468 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2469 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2477 structure = GST_MESSAGE_STRUCTURE (message);
2479 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2483 *group_id = g_value_get_uint (v);
2488 * gst_message_new_need_context:
2489 * @src: (transfer none) (allow-none): The object originating the message.
2490 * @context_type: The context type that is needed
2492 * This message is posted when an element needs a specific #GstContext.
2494 * Returns: (transfer full): The new need-context message.
2501 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2503 GstMessage *message;
2504 GstStructure *structure;
2506 g_return_val_if_fail (context_type != NULL, NULL);
2508 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2509 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2510 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2516 * gst_message_parse_context_type:
2517 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2518 * @context_type: (out) (transfer none) (allow-none): the context type, or %NULL
2520 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2522 * Returns: a #gboolean indicating if the parsing succeeded.
2527 gst_message_parse_context_type (GstMessage * message,
2528 const gchar ** context_type)
2530 GstStructure *structure;
2531 const GValue *value;
2533 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2536 structure = GST_MESSAGE_STRUCTURE (message);
2539 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2540 *context_type = g_value_get_string (value);
2547 * gst_message_new_have_context:
2548 * @src: (transfer none) (allow-none): The object originating the message.
2549 * @context: (transfer full): the context
2551 * This message is posted when an element has a new local #GstContext.
2553 * Returns: (transfer full): The new have-context message.
2560 gst_message_new_have_context (GstObject * src, GstContext * context)
2562 GstMessage *message;
2563 GstStructure *structure;
2565 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2566 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2567 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2568 gst_context_unref (context);
2574 * gst_message_parse_have_context:
2575 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2576 * @context: (out) (transfer full) (allow-none): Result location for the
2579 * Extract the context from the HAVE_CONTEXT message.
2586 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2588 g_return_if_fail (GST_IS_MESSAGE (message));
2589 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2592 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2593 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2597 * gst_message_new_device_added:
2598 * @src: The #GstObject that created the message
2599 * @device: (transfer none): The new #GstDevice
2601 * Creates a new device-added message. The device-added message is produced by
2602 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2603 * of monitored devices.
2605 * Returns: a newly allocated #GstMessage
2610 gst_message_new_device_added (GstObject * src, GstDevice * device)
2612 GstMessage *message;
2613 GstStructure *structure;
2615 g_return_val_if_fail (device != NULL, NULL);
2616 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2618 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2619 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2620 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2626 * gst_message_parse_device_added:
2627 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2628 * @device: (out) (allow-none) (transfer full): A location where to store a
2629 * pointer to the new #GstDevice, or %NULL
2631 * Parses a device-added message. The device-added message is produced by
2632 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2633 * of monitored devices.
2638 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2640 g_return_if_fail (GST_IS_MESSAGE (message));
2641 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2644 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2645 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2649 * gst_message_new_device_removed:
2650 * @src: The #GstObject that created the message
2651 * @device: (transfer none): The removed #GstDevice
2653 * Creates a new device-removed message. The device-removed message is produced
2654 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2655 * disappearance of monitored devices.
2657 * Returns: a newly allocated #GstMessage
2662 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2664 GstMessage *message;
2665 GstStructure *structure;
2667 g_return_val_if_fail (device != NULL, NULL);
2668 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2670 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2671 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2672 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2678 * gst_message_parse_device_removed:
2679 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2680 * @device: (out) (allow-none) (transfer full): A location where to store a
2681 * pointer to the removed #GstDevice, or %NULL
2683 * Parses a device-removed message. The device-removed message is produced by
2684 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2685 * disappearance of monitored devices.
2690 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2692 g_return_if_fail (GST_IS_MESSAGE (message));
2693 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2696 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2697 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2701 * gst_message_new_device_changed:
2702 * @src: The #GstObject that created the message
2703 * @device: (transfer none): The newly created device representing @replaced_device
2704 * with its new configuration.
2706 * Creates a new device-changed message. The device-changed message is produced
2707 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce that a device
2708 * properties has changed and @device represent the new modified version of @changed_device.
2710 * Returns: a newly allocated #GstMessage
2715 gst_message_new_device_changed (GstObject * src, GstDevice * device,
2716 GstDevice * changed_device)
2718 GstMessage *message;
2719 GstStructure *structure;
2721 g_return_val_if_fail (device != NULL, NULL);
2722 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2724 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_CHANGED),
2725 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device,
2726 GST_QUARK (DEVICE_CHANGED), GST_TYPE_DEVICE, changed_device, NULL);
2727 message = gst_message_new_custom (GST_MESSAGE_DEVICE_CHANGED, src, structure);
2733 * gst_message_parse_device_changed:
2734 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_CHANGED
2735 * @device: (out) (allow-none) (transfer full): A location where to store a
2736 * pointer to the updated version of the #GstDevice, or %NULL
2737 * @changed_device: (out) (allow-none) (transfer full): A location where to store a
2738 * pointer to the old version of the #GstDevice, or %NULL
2740 * Parses a device-changed message. The device-changed message is produced by
2741 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2742 * disappearance of monitored devices. * It announce that a device properties has
2743 * changed and @device represents the new modified version of @changed_device.
2748 gst_message_parse_device_changed (GstMessage * message, GstDevice ** device,
2749 GstDevice ** changed_device)
2751 g_return_if_fail (GST_IS_MESSAGE (message));
2752 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_CHANGED);
2755 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2756 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2759 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2760 GST_QUARK (DEVICE_CHANGED), GST_TYPE_DEVICE, changed_device, NULL);
2764 * gst_message_new_property_notify:
2765 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2766 * @property_name: name of the property that changed
2767 * @val: (allow-none) (transfer full): new property value, or %NULL
2769 * Returns: a newly allocated #GstMessage
2774 gst_message_new_property_notify (GstObject * src, const gchar * property_name,
2777 GstStructure *structure;
2778 GValue name_val = G_VALUE_INIT;
2780 g_return_val_if_fail (property_name != NULL, NULL);
2782 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
2783 g_value_init (&name_val, G_TYPE_STRING);
2784 /* should already be interned, but let's make sure */
2785 g_value_set_static_string (&name_val, g_intern_string (property_name));
2786 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
2788 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
2790 return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
2794 * gst_message_parse_property_notify:
2795 * @message: a #GstMessage of type %GST_MESSAGE_PROPERTY_NOTIFY
2796 * @object: (out) (allow-none) (transfer none): location where to store a
2797 * pointer to the object whose property got changed, or %NULL
2798 * @property_name: (out) (transfer none) (allow-none): return location for
2799 * the name of the property that got changed, or %NULL
2800 * @property_value: (out) (transfer none) (allow-none): return location for
2801 * the new value of the property that got changed, or %NULL. This will
2802 * only be set if the property notify watch was told to include the value
2803 * when it was set up
2805 * Parses a property-notify message. These will be posted on the bus only
2806 * when set up with gst_element_add_property_notify_watch() or
2807 * gst_element_add_property_deep_notify_watch().
2812 gst_message_parse_property_notify (GstMessage * message, GstObject ** object,
2813 const gchar ** property_name, const GValue ** property_value)
2815 const GstStructure *s = GST_MESSAGE_STRUCTURE (message);
2817 g_return_if_fail (GST_IS_MESSAGE (message));
2818 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROPERTY_NOTIFY);
2821 *object = GST_MESSAGE_SRC (message);
2823 if (property_name) {
2824 const GValue *name_value;
2826 name_value = gst_structure_id_get_value (s, GST_QUARK (PROPERTY_NAME));
2827 *property_name = g_value_get_string (name_value);
2832 gst_structure_id_get_value (s, GST_QUARK (PROPERTY_VALUE));
2836 * gst_message_new_stream_collection:
2837 * @src: The #GstObject that created the message
2838 * @collection: (transfer none): The #GstStreamCollection
2840 * Creates a new stream-collection message. The message is used to announce new
2841 * #GstStreamCollection
2843 * Returns: a newly allocated #GstMessage
2848 gst_message_new_stream_collection (GstObject * src,
2849 GstStreamCollection * collection)
2851 GstMessage *message;
2852 GstStructure *structure;
2854 g_return_val_if_fail (collection != NULL, NULL);
2855 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2858 gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_COLLECTION),
2859 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2861 gst_message_new_custom (GST_MESSAGE_STREAM_COLLECTION, src, structure);
2867 * gst_message_parse_stream_collection:
2868 * @message: a #GstMessage of type %GST_MESSAGE_STREAM_COLLECTION
2869 * @collection: (out) (allow-none) (transfer full): A location where to store a
2870 * pointer to the #GstStreamCollection, or %NULL
2872 * Parses a stream-collection message.
2877 gst_message_parse_stream_collection (GstMessage * message,
2878 GstStreamCollection ** collection)
2880 g_return_if_fail (GST_IS_MESSAGE (message));
2881 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
2882 GST_MESSAGE_STREAM_COLLECTION);
2885 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2886 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2890 * gst_message_new_streams_selected:
2891 * @src: The #GstObject that created the message
2892 * @collection: (transfer none): The #GstStreamCollection
2894 * Creates a new steams-selected message. The message is used to announce
2895 * that an array of streams has been selected. This is generally in response
2896 * to a #GST_EVENT_SELECT_STREAMS event, or when an element (such as decodebin3)
2897 * makes an initial selection of streams.
2899 * The message also contains the #GstStreamCollection to which the various streams
2902 * Users of gst_message_new_streams_selected() can add the selected streams with
2903 * gst_message_streams_selected_add().
2905 * Returns: a newly allocated #GstMessage
2910 gst_message_new_streams_selected (GstObject * src,
2911 GstStreamCollection * collection)
2913 GstMessage *message;
2914 GstStructure *structure;
2915 GValue val = G_VALUE_INIT;
2917 g_return_val_if_fail (collection != NULL, NULL);
2918 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2921 gst_structure_new_id (GST_QUARK (MESSAGE_STREAMS_SELECTED),
2922 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2923 g_value_init (&val, GST_TYPE_ARRAY);
2924 gst_structure_id_take_value (structure, GST_QUARK (STREAMS), &val);
2926 gst_message_new_custom (GST_MESSAGE_STREAMS_SELECTED, src, structure);
2932 * gst_message_streams_selected_get_size:
2933 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2935 * Returns the number of streams contained in the @message.
2937 * Returns: The number of streams contained within.
2942 gst_message_streams_selected_get_size (GstMessage * msg)
2946 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
2947 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2951 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2952 GST_QUARK (STREAMS));
2953 return gst_value_array_get_size (val);
2957 * gst_message_streams_selected_add:
2958 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2959 * @stream: (transfer none): a #GstStream to add to @message
2961 * Adds the @stream to the @message.
2966 gst_message_streams_selected_add (GstMessage * msg, GstStream * stream)
2969 GValue to_add = G_VALUE_INIT;
2971 g_return_if_fail (GST_IS_MESSAGE (msg));
2972 g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED);
2973 g_return_if_fail (GST_IS_STREAM (stream));
2976 (GValue *) gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2977 GST_QUARK (STREAMS));
2978 g_value_init (&to_add, GST_TYPE_STREAM);
2979 g_value_set_object (&to_add, stream);
2980 gst_value_array_append_and_take_value (val, &to_add);
2984 * gst_message_streams_selected_get_stream:
2985 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2986 * @idx: Index of the stream to retrieve
2988 * Retrieves the #GstStream with index @index from the @message.
2990 * Returns: (transfer full) (nullable): A #GstStream
2995 gst_message_streams_selected_get_stream (GstMessage * msg, guint idx)
2997 const GValue *streams, *val;
2999 g_return_val_if_fail (GST_IS_MESSAGE (msg), NULL);
3000 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
3004 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
3005 GST_QUARK (STREAMS));
3006 val = gst_value_array_get_value (streams, idx);
3008 return (GstStream *) g_value_dup_object (val);
3015 * gst_message_parse_streams_selected:
3016 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
3017 * @collection: (out) (allow-none) (transfer full): A location where to store a
3018 * pointer to the #GstStreamCollection, or %NULL
3020 * Parses a streams-selected message.
3025 gst_message_parse_streams_selected (GstMessage * message,
3026 GstStreamCollection ** collection)
3028 g_return_if_fail (GST_IS_MESSAGE (message));
3029 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAMS_SELECTED);
3032 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
3033 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
3037 * gst_message_new_redirect:
3038 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
3039 * @location: (transfer none): location string for the new entry
3040 * @tag_list: (transfer full) (allow-none): tag list for the new entry
3041 * @entry_struct: (transfer full) (allow-none): structure for the new entry
3043 * Creates a new redirect message and adds a new entry to it. Redirect messages
3044 * are posted when an element detects that the actual data has to be retrieved
3045 * from a different location. This is useful if such a redirection cannot be
3046 * handled inside a source element, for example when HTTP 302/303 redirects
3047 * return a non-HTTP URL.
3049 * The redirect message can hold multiple entries. The first one is added
3050 * when the redirect message is created, with the given location, tag_list,
3051 * entry_struct arguments. Use gst_message_add_redirect_entry() to add more
3054 * Each entry has a location, a tag list, and a structure. All of these are
3055 * optional. The tag list and structure are useful for additional metadata,
3056 * such as bitrate statistics for the given location.
3058 * By default, message recipients should treat entries in the order they are
3059 * stored. The recipient should therefore try entry \#0 first, and if this
3060 * entry is not acceptable or working, try entry \#1 etc. Senders must make
3061 * sure that they add entries in this order. However, recipients are free to
3062 * ignore the order and pick an entry that is "best" for them. One example
3063 * would be a recipient that scans the entries for the one with the highest
3066 * The specified location string is copied. However, ownership over the tag
3067 * list and structure are transferred to the message.
3069 * Returns: a newly allocated #GstMessage
3074 gst_message_new_redirect (GstObject * src, const gchar * location,
3075 GstTagList * tag_list, const GstStructure * entry_struct)
3077 GstStructure *structure;
3078 GstMessage *message;
3079 GValue entry_locations_gvalue = G_VALUE_INIT;
3080 GValue entry_taglists_gvalue = G_VALUE_INIT;
3081 GValue entry_structures_gvalue = G_VALUE_INIT;
3083 g_return_val_if_fail (location != NULL, NULL);
3085 g_value_init (&entry_locations_gvalue, GST_TYPE_LIST);
3086 g_value_init (&entry_taglists_gvalue, GST_TYPE_LIST);
3087 g_value_init (&entry_structures_gvalue, GST_TYPE_LIST);
3089 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_REDIRECT));
3090 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_LOCATIONS),
3091 &entry_locations_gvalue);
3092 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_TAGLISTS),
3093 &entry_taglists_gvalue);
3094 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_STRUCTURES),
3095 &entry_structures_gvalue);
3097 message = gst_message_new_custom (GST_MESSAGE_REDIRECT, src, structure);
3098 g_assert (message != NULL);
3100 gst_message_add_redirect_entry (message, location, tag_list, entry_struct);
3106 * gst_message_add_redirect_entry:
3107 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3108 * @location: (transfer none): location string for the new entry
3109 * @tag_list: (transfer full) (allow-none): tag list for the new entry
3110 * @entry_struct: (transfer full) (allow-none): structure for the new entry
3112 * Creates and appends a new entry.
3114 * The specified location string is copied. However, ownership over the tag
3115 * list and structure are transferred to the message.
3120 gst_message_add_redirect_entry (GstMessage * message, const gchar * location,
3121 GstTagList * tag_list, const GstStructure * entry_struct)
3123 GValue val = G_VALUE_INIT;
3124 GstStructure *structure;
3125 GValue *entry_locations_gvalue;
3126 GValue *entry_taglists_gvalue;
3127 GValue *entry_structures_gvalue;
3129 g_return_if_fail (location != NULL);
3130 g_return_if_fail (GST_IS_MESSAGE (message));
3131 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3133 structure = GST_MESSAGE_STRUCTURE (message);
3135 entry_locations_gvalue =
3136 (GValue *) gst_structure_id_get_value (structure,
3137 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3138 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3139 entry_taglists_gvalue =
3140 (GValue *) gst_structure_id_get_value (structure,
3141 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3142 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3143 entry_structures_gvalue =
3144 (GValue *) gst_structure_id_get_value (structure,
3145 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3146 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3148 g_value_init (&val, G_TYPE_STRING);
3150 g_value_set_string (&val, location);
3151 gst_value_list_append_and_take_value (entry_locations_gvalue, &val);
3153 g_value_init (&val, GST_TYPE_TAG_LIST);
3155 g_value_take_boxed (&val, tag_list);
3156 gst_value_list_append_and_take_value (entry_taglists_gvalue, &val);
3158 g_value_init (&val, GST_TYPE_STRUCTURE);
3160 g_value_take_boxed (&val, entry_struct);
3161 gst_value_list_append_and_take_value (entry_structures_gvalue, &val);
3165 * gst_message_parse_redirect_entry:
3166 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3167 * @entry_index: index of the entry to parse
3168 * @location: (out) (transfer none) (allow-none): return location for
3169 * the pointer to the entry's location string, or %NULL
3170 * @tag_list: (out) (transfer none) (allow-none): return location for
3171 * the pointer to the entry's tag list, or %NULL
3172 * @entry_struct: (out) (transfer none) (allow-none): return location
3173 * for the pointer to the entry's structure, or %NULL
3175 * Parses the location and/or structure from the entry with the given index.
3176 * The index must be between 0 and gst_message_get_num_redirect_entries() - 1.
3177 * Returned pointers are valid for as long as this message exists.
3182 gst_message_parse_redirect_entry (GstMessage * message, gsize entry_index,
3183 const gchar ** location, GstTagList ** tag_list,
3184 const GstStructure ** entry_struct)
3187 GstStructure *structure;
3188 const GValue *entry_locations_gvalue;
3189 const GValue *entry_taglists_gvalue;
3190 const GValue *entry_structures_gvalue;
3192 g_return_if_fail (GST_IS_MESSAGE (message));
3193 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3195 if (G_UNLIKELY (!location && !tag_list && !entry_struct))
3198 structure = GST_MESSAGE_STRUCTURE (message);
3200 entry_locations_gvalue =
3201 gst_structure_id_get_value (structure,
3202 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3203 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3204 entry_taglists_gvalue =
3205 gst_structure_id_get_value (structure,
3206 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3207 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3208 entry_structures_gvalue =
3209 gst_structure_id_get_value (structure,
3210 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3211 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3214 val = gst_value_list_get_value (entry_locations_gvalue, entry_index);
3215 g_return_if_fail (val != NULL);
3216 *location = g_value_get_string (val);
3220 val = gst_value_list_get_value (entry_taglists_gvalue, entry_index);
3221 g_return_if_fail (val != NULL);
3222 *tag_list = (GstTagList *) g_value_get_boxed (val);
3226 val = gst_value_list_get_value (entry_structures_gvalue, entry_index);
3227 g_return_if_fail (val != NULL);
3228 *entry_struct = (const GstStructure *) g_value_get_boxed (val);
3233 * gst_message_get_num_redirect_entries:
3234 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3236 * Returns: the number of entries stored in the message
3241 gst_message_get_num_redirect_entries (GstMessage * message)
3243 GstStructure *structure;
3244 const GValue *entry_locations_gvalue;
3245 const GValue *entry_taglists_gvalue;
3246 const GValue *entry_structures_gvalue;
3249 g_return_val_if_fail (GST_IS_MESSAGE (message), 0);
3250 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT, 0);
3252 structure = GST_MESSAGE_STRUCTURE (message);
3254 entry_locations_gvalue =
3255 gst_structure_id_get_value (structure,
3256 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3257 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue), 0);
3258 entry_taglists_gvalue =
3259 gst_structure_id_get_value (structure,
3260 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3261 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue), 0);
3262 entry_structures_gvalue =
3263 gst_structure_id_get_value (structure,
3264 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3265 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue), 0);
3267 size = gst_value_list_get_size (entry_locations_gvalue);
3269 g_return_val_if_fail ((size ==
3270 gst_value_list_get_size (entry_structures_gvalue))
3271 && (size == gst_value_list_get_size (entry_taglists_gvalue)), 0);
3277 * gst_message_new_instant_rate_request:
3278 * @src: The #GstObject that posted the message
3279 * @rate_multiplier: the rate multiplier factor that should be applied
3281 * Creates a new instant-rate-request message. Elements handling the
3282 * instant-rate-change event must post this message. The message is
3283 * handled at the pipeline, and allows the pipeline to select the
3284 * running time when the rate change should happen and to send an
3285 * @GST_EVENT_INSTANT_RATE_SYNC_TIME event to notify the elements
3288 * Returns: a newly allocated #GstMessage
3293 gst_message_new_instant_rate_request (GstObject * src, gdouble rate_multiplier)
3295 GstStructure *structure;
3296 GstMessage *message;
3298 g_return_val_if_fail (rate_multiplier != 0.0, NULL);
3300 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INSTANT_RATE_REQUEST),
3301 GST_QUARK (RATE), G_TYPE_DOUBLE, rate_multiplier, NULL);
3303 gst_message_new_custom (GST_MESSAGE_INSTANT_RATE_REQUEST, src, structure);
3309 * gst_message_parse_instant_rate_request:
3310 * @message: a #GstMessage of type %GST_MESSAGE_INSTANT_RATE_REQUEST
3311 * @rate_multiplier: (out) (allow-none): return location for the rate, or %NULL
3313 * Parses the rate_multiplier from the instant-rate-request message.
3318 gst_message_parse_instant_rate_request (GstMessage * message,
3319 gdouble * rate_multiplier)
3321 GstStructure *structure;
3323 g_return_if_fail (GST_IS_MESSAGE (message));
3324 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
3325 GST_MESSAGE_INSTANT_RATE_REQUEST);
3327 structure = GST_MESSAGE_STRUCTURE (message);
3328 gst_structure_id_get (structure, GST_QUARK (RATE), G_TYPE_DOUBLE,
3329 rate_multiplier, NULL);
3333 * gst_message_ref: (skip)
3334 * @msg: the message to ref
3336 * Convenience macro to increase the reference count of the message.
3338 * Returns: @msg (for convenience when doing assignments)
3341 gst_message_ref (GstMessage * msg)
3343 return (GstMessage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (msg));
3347 * gst_message_unref: (skip)
3348 * @msg: the message to unref
3350 * Convenience macro to decrease the reference count of the message, possibly
3354 gst_message_unref (GstMessage * msg)
3356 gst_mini_object_unref (GST_MINI_OBJECT_CAST (msg));
3360 * gst_clear_message: (skip)
3361 * @msg_ptr: a pointer to a #GstMessage reference
3363 * Clears a reference to a #GstMessage.
3365 * @msg_ptr must not be %NULL.
3367 * If the reference is %NULL then this function does nothing. Otherwise, the
3368 * reference count of the message is decreased and the pointer is set to %NULL.
3373 gst_clear_message (GstMessage ** msg_ptr)
3375 gst_clear_mini_object ((GstMiniObject **) msg_ptr);
3379 * gst_message_copy: (skip)
3380 * @msg: the message to copy
3382 * Creates a copy of the message. Returns a copy of the message.
3384 * Returns: (transfer full): a new copy of @msg.
3389 gst_message_copy (const GstMessage * msg)
3392 GST_MESSAGE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST
3397 * gst_message_replace: (skip)
3398 * @old_message: (inout) (transfer full) (nullable): pointer to a
3399 * pointer to a #GstMessage to be replaced.
3400 * @new_message: (allow-none) (transfer none): pointer to a #GstMessage that will
3401 * replace the message pointed to by @old_message.
3403 * Modifies a pointer to a #GstMessage to point to a different #GstMessage. The
3404 * modification is done atomically (so this is useful for ensuring thread safety
3405 * in some cases), and the reference counts are updated appropriately (the old
3406 * message is unreffed, the new one is reffed).
3408 * Either @new_message or the #GstMessage pointed to by @old_message may be %NULL.
3410 * Returns: %TRUE if @new_message was different from @old_message
3413 gst_message_replace (GstMessage ** old_message, GstMessage * new_message)
3415 return gst_mini_object_replace ((GstMiniObject **) old_message,
3416 (GstMiniObject *) new_message);
3421 * @old_message: (inout) (transfer full): pointer to a pointer to a #GstMessage
3423 * @new_message: (transfer full) (allow-none): pointer to a #GstMessage that
3424 * will replace the message pointed to by @old_message.
3426 * Modifies a pointer to a #GstMessage to point to a different #GstMessage. This
3427 * function is similar to gst_message_replace() except that it takes ownership
3430 * Returns: %TRUE if @new_message was different from @old_message
3435 gst_message_take (GstMessage ** old_message, GstMessage * new_message)
3437 return gst_mini_object_take ((GstMiniObject **) old_message,
3438 (GstMiniObject *) new_message);