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().
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_PROPERTY_NOTIFY, "property-notify", 0},
111 {GST_MESSAGE_STREAM_COLLECTION, "stream-collection", 0},
112 {GST_MESSAGE_STREAMS_SELECTED, "streams-selected", 0},
113 {GST_MESSAGE_REDIRECT, "redirect", 0},
117 static GQuark details_quark = 0;
119 GType _gst_message_type = 0;
120 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
123 _priv_gst_message_initialize (void)
127 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
129 for (i = 0; message_quarks[i].name; i++) {
130 message_quarks[i].quark =
131 g_quark_from_static_string (message_quarks[i].name);
133 details_quark = g_quark_from_static_string ("details");
135 _gst_message_type = gst_message_get_type ();
139 * gst_message_type_get_name:
140 * @type: the message type
142 * Get a printable name for the given message type. Do not modify or free.
144 * Returns: a reference to the static name of the message.
147 gst_message_type_get_name (GstMessageType type)
151 for (i = 0; message_quarks[i].name; i++) {
152 if (type == message_quarks[i].type)
153 return message_quarks[i].name;
159 * gst_message_type_to_quark:
160 * @type: the message type
162 * Get the unique quark for the given message type.
164 * Returns: the quark associated with the message type
167 gst_message_type_to_quark (GstMessageType type)
171 for (i = 0; message_quarks[i].name; i++) {
172 if (type == message_quarks[i].type)
173 return message_quarks[i].quark;
179 _gst_message_dispose (GstMessage * message)
181 gboolean do_free = TRUE;
183 if (GST_MINI_OBJECT_FLAG_IS_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY)) {
184 /* revive message, so bus can finish with it and clean it up */
185 gst_message_ref (message);
187 GST_INFO ("[msg %p] signalling async free", message);
189 GST_MESSAGE_LOCK (message);
190 GST_MESSAGE_SIGNAL (message);
191 GST_MESSAGE_UNLOCK (message);
193 /* don't free it yet, let bus finish with it first */
201 _gst_message_free (GstMessage * message)
203 GstStructure *structure;
205 g_return_if_fail (message != NULL);
207 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
208 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
210 if (GST_MESSAGE_SRC (message)) {
211 gst_object_unref (GST_MESSAGE_SRC (message));
212 GST_MESSAGE_SRC (message) = NULL;
215 structure = GST_MESSAGE_STRUCTURE (message);
217 gst_structure_set_parent_refcount (structure, NULL);
218 gst_structure_free (structure);
221 g_slice_free1 (sizeof (GstMessageImpl), message);
225 gst_message_init (GstMessageImpl * message, GstMessageType type,
229 _gst_message_copy (GstMessage * message)
231 GstMessageImpl *copy;
232 GstStructure *structure;
234 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
235 GST_MESSAGE_TYPE_NAME (message),
236 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
238 copy = g_slice_new0 (GstMessageImpl);
240 gst_message_init (copy, GST_MESSAGE_TYPE (message),
241 GST_MESSAGE_SRC (message));
243 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
244 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
246 structure = GST_MESSAGE_STRUCTURE (message);
248 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
249 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
250 ©->message.mini_object.refcount);
252 GST_MESSAGE_STRUCTURE (copy) = NULL;
255 return GST_MESSAGE_CAST (copy);
259 gst_message_init (GstMessageImpl * message, GstMessageType type,
262 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
263 (GstMiniObjectCopyFunction) _gst_message_copy,
264 (GstMiniObjectDisposeFunction) _gst_message_dispose,
265 (GstMiniObjectFreeFunction) _gst_message_free);
267 GST_MESSAGE_TYPE (message) = type;
269 gst_object_ref (src);
270 GST_MESSAGE_SRC (message) = src;
271 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
272 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
277 * gst_message_new_custom:
278 * @type: The #GstMessageType to distinguish messages
279 * @src: (transfer none) (allow-none): The object originating the message.
280 * @structure: (transfer full) (allow-none): the structure for the
281 * message. The message will take ownership of the structure.
283 * Create a new custom-typed message. This can be used for anything not
284 * handled by other message-specific functions to pass a message to the
285 * app. The structure field can be %NULL.
287 * Returns: (transfer full) (nullable): The new message.
292 gst_message_new_custom (GstMessageType type, GstObject * src,
293 GstStructure * structure)
295 GstMessageImpl *message;
297 message = g_slice_new0 (GstMessageImpl);
299 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
300 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
301 gst_message_type_get_name (type));
304 /* structure must not have a parent */
305 if (!gst_structure_set_parent_refcount (structure,
306 &message->message.mini_object.refcount))
309 gst_message_init (message, type, src);
311 GST_MESSAGE_STRUCTURE (message) = structure;
313 return GST_MESSAGE_CAST (message);
318 g_slice_free1 (sizeof (GstMessageImpl), message);
319 g_warning ("structure is already owned by another object");
325 * gst_message_get_seqnum:
326 * @message: A #GstMessage.
328 * Retrieve the sequence number of a message.
330 * Messages have ever-incrementing sequence numbers, which may also be set
331 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
332 * to indicate that a message corresponds to some other set of messages or
333 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
334 * is considered good practice to make this correspondence when possible, though
335 * it is not required.
337 * Note that events and messages share the same sequence number incrementor;
338 * two events or messages will never have the same sequence number unless
339 * that correspondence was made explicitly.
341 * Returns: The message's sequence number.
346 gst_message_get_seqnum (GstMessage * message)
348 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
350 return GST_MESSAGE_SEQNUM (message);
354 * gst_message_set_seqnum:
355 * @message: A #GstMessage.
356 * @seqnum: A sequence number.
358 * Set the sequence number of a message.
360 * This function might be called by the creator of a message to indicate that
361 * the message relates to other messages or events. See gst_message_get_seqnum()
362 * for more information.
367 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
369 g_return_if_fail (GST_IS_MESSAGE (message));
370 g_return_if_fail (seqnum != GST_SEQNUM_INVALID);
372 GST_MESSAGE_SEQNUM (message) = seqnum;
376 * gst_message_new_eos:
377 * @src: (transfer none) (allow-none): The object originating the message.
379 * Create a new eos message. This message is generated and posted in
380 * the sink elements of a GstBin. The bin will only forward the EOS
381 * message to the application if all sinks have posted an EOS message.
383 * Returns: (transfer full): The new eos message.
388 gst_message_new_eos (GstObject * src)
392 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
398 * gst_message_new_error_with_details:
399 * @src: (transfer none) (allow-none): The object originating the message.
400 * @error: (transfer none): The GError for this message.
401 * @debug: A debugging string.
402 * @details: (transfer full): (allow-none): A GstStructure with details
404 * Create a new error message. The message will copy @error and
405 * @debug. This message is posted by element when a fatal event
406 * occurred. The pipeline will probably (partially) stop. The application
407 * receiving this message should stop the pipeline.
409 * Returns: (transfer full) (nullable): the new error message.
414 gst_message_new_error_with_details (GstObject * src, GError * error,
415 const gchar * debug, GstStructure * details)
418 GstStructure *structure;
420 if (debug && !g_utf8_validate (debug, -1, NULL)) {
422 g_warning ("Trying to set debug field of error message, but "
423 "string is not valid UTF-8. Please file a bug.");
426 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
427 GST_QUARK (GERROR), G_TYPE_ERROR, error,
428 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
429 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
431 GValue v = G_VALUE_INIT;
433 g_value_init (&v, GST_TYPE_STRUCTURE);
434 g_value_take_boxed (&v, details);
435 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
443 * gst_message_new_error:
444 * @src: (transfer none) (allow-none): The object originating the message.
445 * @error: (transfer none): The GError for this message.
446 * @debug: A debugging string.
448 * Create a new error message. The message will copy @error and
449 * @debug. This message is posted by element when a fatal event
450 * occurred. The pipeline will probably (partially) stop. The application
451 * receiving this message should stop the pipeline.
453 * Returns: (transfer full): the new error message.
458 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
460 return gst_message_new_error_with_details (src, error, debug, NULL);
464 * gst_message_parse_error_details:
465 * @message: The message object
466 * @structure: (transfer none) (out): A pointer to the returned details
468 * Returns the optional details structure, may be NULL if none.
469 * The returned structure must not be freed.
474 gst_message_parse_error_details (GstMessage * message,
475 const GstStructure ** structure)
479 g_return_if_fail (GST_IS_MESSAGE (message));
480 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
481 g_return_if_fail (structure != NULL);
484 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
487 *structure = g_value_get_boxed (v);
492 * gst_message_new_warning_with_details:
493 * @src: (transfer none) (allow-none): The object originating the message.
494 * @error: (transfer none): The GError for this message.
495 * @debug: A debugging string.
496 * @details: (transfer full): (allow-none): A GstStructure with details
498 * Create a new warning message. The message will make copies of @error and
501 * Returns: (transfer full) (nullable): the new warning message.
506 gst_message_new_warning_with_details (GstObject * src, GError * error,
507 const gchar * debug, GstStructure * details)
510 GstStructure *structure;
512 if (debug && !g_utf8_validate (debug, -1, NULL)) {
514 g_warning ("Trying to set debug field of warning message, but "
515 "string is not valid UTF-8. Please file a bug.");
518 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
519 GST_QUARK (GERROR), G_TYPE_ERROR, error,
520 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
521 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
523 GValue v = G_VALUE_INIT;
525 g_value_init (&v, GST_TYPE_STRUCTURE);
526 g_value_take_boxed (&v, details);
527 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
535 * gst_message_new_warning:
536 * @src: (transfer none) (allow-none): The object originating the message.
537 * @error: (transfer none): The GError for this message.
538 * @debug: A debugging string.
540 * Create a new warning message. The message will make copies of @error and
543 * Returns: (transfer full): the new warning message.
548 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
550 return gst_message_new_warning_with_details (src, error, debug, NULL);
554 * gst_message_parse_warning_details:
555 * @message: The message object
556 * @structure: (transfer none) (out): A pointer to the returned details structure
558 * Returns the optional details structure, may be NULL if none
559 * The returned structure must not be freed.
564 gst_message_parse_warning_details (GstMessage * message,
565 const GstStructure ** structure)
569 g_return_if_fail (GST_IS_MESSAGE (message));
570 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
571 g_return_if_fail (structure != NULL);
574 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
577 *structure = g_value_get_boxed (v);
582 * gst_message_new_info_with_details:
583 * @src: (transfer none) (allow-none): The object originating the message.
584 * @error: (transfer none): The GError for this message.
585 * @debug: A debugging string.
586 * @details: (transfer full): (allow-none): A GstStructure with details
588 * Create a new info message. The message will make copies of @error and
591 * Returns: (transfer full) (nullable): the new warning message.
596 gst_message_new_info_with_details (GstObject * src, GError * error,
597 const gchar * debug, GstStructure * details)
600 GstStructure *structure;
602 if (debug && !g_utf8_validate (debug, -1, NULL)) {
604 g_warning ("Trying to set debug field of info message, but "
605 "string is not valid UTF-8. Please file a bug.");
608 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
609 GST_QUARK (GERROR), G_TYPE_ERROR, error,
610 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
611 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
613 GValue v = G_VALUE_INIT;
615 g_value_init (&v, GST_TYPE_STRUCTURE);
616 g_value_take_boxed (&v, details);
617 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
625 * gst_message_new_info:
626 * @src: (transfer none) (allow-none): The object originating the message.
627 * @error: (transfer none): The GError for this message.
628 * @debug: A debugging string.
630 * Create a new info message. The message will make copies of @error and
633 * Returns: (transfer full): the new info message.
638 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
640 return gst_message_new_info_with_details (src, error, debug, NULL);
644 * gst_message_parse_info_details:
645 * @message: The message object
646 * @structure: (transfer none) (out): A pointer to the returned details structure
648 * Returns the optional details structure, may be NULL if none
649 * The returned structure must not be freed.
654 gst_message_parse_info_details (GstMessage * message,
655 const GstStructure ** structure)
659 g_return_if_fail (GST_IS_MESSAGE (message));
660 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
661 g_return_if_fail (structure != NULL);
664 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
667 *structure = g_value_get_boxed (v);
672 * gst_message_new_tag:
673 * @src: (transfer none) (allow-none): The object originating the message.
674 * @tag_list: (transfer full): the tag list for the message.
676 * Create a new tag message. The message will take ownership of the tag list.
677 * The message is posted by elements that discovered a new taglist.
679 * Returns: (transfer full): the new tag message.
684 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
688 GValue val = G_VALUE_INIT;
690 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
692 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
693 g_value_init (&val, GST_TYPE_TAG_LIST);
694 g_value_take_boxed (&val, tag_list);
695 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
696 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
701 * gst_message_new_buffering:
702 * @src: (transfer none) (allow-none): The object originating the message.
703 * @percent: The buffering percent
705 * Create a new buffering message. This message can be posted by an element that
706 * needs to buffer data before it can continue processing. @percent should be a
707 * value between 0 and 100. A value of 100 means that the buffering completed.
709 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
710 * @percent is 100, the application can set the pipeline (back) to PLAYING.
711 * The application must be prepared to receive BUFFERING messages in the
712 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
713 * message with @percent set to 100, which can happen after the pipeline
714 * completed prerolling.
718 * Returns: (transfer full) (nullable): The new buffering message.
721 gst_message_new_buffering (GstObject * src, gint percent)
724 GstStructure *structure;
725 gint64 buffering_left;
727 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
729 buffering_left = (percent == 100 ? 0 : -1);
731 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
732 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
733 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
734 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
735 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
736 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
737 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
743 * gst_message_new_state_changed:
744 * @src: (transfer none) (allow-none): The object originating the message.
745 * @oldstate: the previous state
746 * @newstate: the new (current) state
747 * @pending: the pending (target) state
749 * Create a state change message. This message is posted whenever an element
752 * Returns: (transfer full): the new state change message.
757 gst_message_new_state_changed (GstObject * src,
758 GstState oldstate, GstState newstate, GstState pending)
761 GstStructure *structure;
763 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
764 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
765 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
766 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
767 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
773 * gst_message_new_state_dirty:
774 * @src: (transfer none) (allow-none): The object originating the message
776 * Create a state dirty message. This message is posted whenever an element
777 * changed its state asynchronously and is used internally to update the
778 * states of container objects.
780 * Returns: (transfer full): the new state dirty message.
785 gst_message_new_state_dirty (GstObject * src)
789 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
795 * gst_message_new_clock_provide:
796 * @src: (transfer none) (allow-none): The object originating the message.
797 * @clock: (transfer none): the clock it provides
798 * @ready: %TRUE if the sender can provide a clock
800 * Create a clock provide message. This message is posted whenever an
801 * element is ready to provide a clock or lost its ability to provide
802 * a clock (maybe because it paused or became EOS).
804 * This message is mainly used internally to manage the clock
807 * Returns: (transfer full): the new provide clock message.
812 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
816 GstStructure *structure;
818 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
819 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
820 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
821 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
827 * gst_message_new_clock_lost:
828 * @src: (transfer none) (allow-none): The object originating the message.
829 * @clock: (transfer none): the clock that was lost
831 * Create a clock lost message. This message is posted whenever the
832 * clock is not valid anymore.
834 * If this message is posted by the pipeline, the pipeline will
835 * select a new clock again when it goes to PLAYING. It might therefore
836 * be needed to set the pipeline to PAUSED and PLAYING again.
838 * Returns: (transfer full): The new clock lost message.
843 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
846 GstStructure *structure;
848 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
849 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
850 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
856 * gst_message_new_new_clock:
857 * @src: (transfer none) (allow-none): The object originating the message.
858 * @clock: (transfer none): the new selected clock
860 * Create a new clock message. This message is posted whenever the
861 * pipeline selects a new clock for the pipeline.
863 * Returns: (transfer full): The new new clock message.
868 gst_message_new_new_clock (GstObject * src, GstClock * clock)
871 GstStructure *structure;
873 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
874 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
875 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
881 * gst_message_new_structure_change:
882 * @src: (transfer none) (allow-none): The object originating the message.
883 * @type: The change type.
884 * @owner: (transfer none): The owner element of @src.
885 * @busy: Whether the structure change is busy.
887 * Create a new structure change message. This message is posted when the
888 * structure of a pipeline is in the process of being changed, for example
889 * when pads are linked or unlinked.
891 * @src should be the sinkpad that unlinked or linked.
893 * Returns: (transfer full): the new structure change message.
898 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
899 GstElement * owner, gboolean busy)
902 GstStructure *structure;
904 g_return_val_if_fail (GST_IS_PAD (src), NULL);
905 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
906 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
908 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
909 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
910 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
911 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
913 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
920 * gst_message_new_segment_start:
921 * @src: (transfer none) (allow-none): The object originating the message.
922 * @format: The format of the position being played
923 * @position: The position of the segment being played
925 * Create a new segment message. This message is posted by elements that
926 * start playback of a segment as a result of a segment seek. This message
927 * is not received by the application but is used for maintenance reasons in
928 * container elements.
930 * Returns: (transfer full): the new segment start message.
935 gst_message_new_segment_start (GstObject * src, GstFormat format,
939 GstStructure *structure;
941 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
942 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
943 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
944 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
950 * gst_message_new_segment_done:
951 * @src: (transfer none) (allow-none): The object originating the message.
952 * @format: The format of the position being done
953 * @position: The position of the segment being done
955 * Create a new segment done message. This message is posted by elements that
956 * finish playback of a segment as a result of a segment seek. This message
957 * is received by the application after all elements that posted a segment_start
958 * have posted the segment_done.
960 * Returns: (transfer full): the new segment done message.
965 gst_message_new_segment_done (GstObject * src, GstFormat format,
969 GstStructure *structure;
971 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
972 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
973 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
974 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
980 * gst_message_new_application:
981 * @src: (transfer none) (allow-none): The object originating the message.
982 * @structure: (transfer full): the structure for the message. The message
983 * will take ownership of the structure.
985 * Create a new application-typed message. GStreamer will never create these
986 * messages; they are a gift from us to you. Enjoy.
988 * Returns: (transfer full) (nullable): The new application message.
993 gst_message_new_application (GstObject * src, GstStructure * structure)
995 g_return_val_if_fail (structure != NULL, NULL);
997 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
1001 * gst_message_new_element:
1002 * @src: (transfer none) (allow-none): The object originating the message.
1003 * @structure: (transfer full): The structure for the
1004 * message. The message will take ownership of the structure.
1006 * Create a new element-specific message. This is meant as a generic way of
1007 * allowing one-way communication from an element to an application, for example
1008 * "the firewire cable was unplugged". The format of the message should be
1009 * documented in the element's documentation. The structure field can be %NULL.
1011 * Returns: (transfer full) (nullable): The new element message.
1016 gst_message_new_element (GstObject * src, GstStructure * structure)
1018 g_return_val_if_fail (structure != NULL, NULL);
1020 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
1024 * gst_message_new_duration_changed:
1025 * @src: (transfer none) (allow-none): The object originating the message.
1027 * Create a new duration changed message. This message is posted by elements
1028 * that know the duration of a stream when the duration changes. This message
1029 * is received by bins and is used to calculate the total duration of a
1032 * Returns: (transfer full): The new duration-changed message.
1037 gst_message_new_duration_changed (GstObject * src)
1039 GstMessage *message;
1041 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
1042 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
1048 * gst_message_new_async_start:
1049 * @src: (transfer none) (allow-none): The object originating the message.
1051 * This message is posted by elements when they start an ASYNC state change.
1053 * Returns: (transfer full): The new async_start message.
1058 gst_message_new_async_start (GstObject * src)
1060 GstMessage *message;
1062 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
1068 * gst_message_new_async_done:
1069 * @src: (transfer none) (allow-none): The object originating the message.
1070 * @running_time: the desired running_time
1072 * The message is posted when elements completed an ASYNC state change.
1073 * @running_time contains the time of the desired running_time when this
1074 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
1075 * means that the element has no clock interaction and thus doesn't care about
1076 * the running_time of the pipeline.
1078 * Returns: (transfer full): The new async_done message.
1083 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
1085 GstMessage *message;
1086 GstStructure *structure;
1088 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
1089 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
1090 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
1096 * gst_message_new_latency:
1097 * @src: (transfer none) (allow-none): The object originating the message.
1099 * This message can be posted by elements when their latency requirements have
1102 * Returns: (transfer full): The new latency message.
1107 gst_message_new_latency (GstObject * src)
1109 GstMessage *message;
1111 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
1117 * gst_message_new_request_state:
1118 * @src: (transfer none) (allow-none): The object originating the message.
1119 * @state: The new requested state
1121 * This message can be posted by elements when they want to have their state
1122 * changed. A typical use case would be an audio server that wants to pause the
1123 * pipeline because a higher priority stream is being played.
1125 * Returns: (transfer full): the new request state message.
1130 gst_message_new_request_state (GstObject * src, GstState state)
1132 GstMessage *message;
1133 GstStructure *structure;
1135 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
1136 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
1137 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
1143 * gst_message_get_structure:
1144 * @message: The #GstMessage.
1146 * Access the structure of the message.
1148 * Returns: (transfer none) (nullable): The structure of the message. The
1149 * structure is still owned by the message, which means that you should not
1150 * free it and that the pointer becomes invalid when you free the message.
1154 const GstStructure *
1155 gst_message_get_structure (GstMessage * message)
1157 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1159 return GST_MESSAGE_STRUCTURE (message);
1163 * gst_message_writable_structure:
1164 * @message: The #GstMessage.
1166 * Get a writable version of the structure.
1168 * Returns: (transfer none): The structure of the message. The structure
1169 * is still owned by the message, which means that you should not free
1170 * it and that the pointer becomes invalid when you free the message.
1171 * This function checks if @message is writable and will never return
1179 gst_message_writable_structure (GstMessage * message)
1181 GstStructure *structure;
1183 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1184 g_return_val_if_fail (gst_message_is_writable (message), NULL);
1186 structure = GST_MESSAGE_STRUCTURE (message);
1188 if (structure == NULL) {
1190 gst_structure_new_id_empty (gst_message_type_to_quark (GST_MESSAGE_TYPE
1192 gst_structure_set_parent_refcount (structure,
1193 &message->mini_object.refcount);
1194 GST_MESSAGE_STRUCTURE (message) = structure;
1200 * gst_message_has_name:
1201 * @message: The #GstMessage.
1202 * @name: name to check
1204 * Checks if @message has the given @name. This function is usually used to
1205 * check the name of a custom message.
1207 * Returns: %TRUE if @name matches the name of the message structure.
1210 gst_message_has_name (GstMessage * message, const gchar * name)
1212 GstStructure *structure;
1214 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
1216 structure = GST_MESSAGE_STRUCTURE (message);
1217 if (structure == NULL)
1220 return gst_structure_has_name (structure, name);
1224 * gst_message_parse_tag:
1225 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1226 * @tag_list: (out callee-allocates): return location for the tag-list.
1228 * Extracts the tag list from the GstMessage. The tag list returned in the
1229 * output argument is a copy; the caller must free it when done.
1231 * Typical usage of this function might be:
1232 * |[<!-- language="C" -->
1234 * switch (GST_MESSAGE_TYPE (msg)) {
1235 * case GST_MESSAGE_TAG: {
1236 * GstTagList *tags = NULL;
1238 * gst_message_parse_tag (msg, &tags);
1239 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1240 * handle_tags (tags);
1241 * gst_tag_list_unref (tags);
1252 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1254 g_return_if_fail (GST_IS_MESSAGE (message));
1255 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1256 g_return_if_fail (tag_list != NULL);
1258 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1259 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1263 * gst_message_parse_buffering:
1264 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1265 * @percent: (out) (allow-none): Return location for the percent.
1267 * Extracts the buffering percent from the GstMessage. see also
1268 * gst_message_new_buffering().
1273 gst_message_parse_buffering (GstMessage * message, gint * percent)
1275 g_return_if_fail (GST_IS_MESSAGE (message));
1276 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1280 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1281 (message), GST_QUARK (BUFFER_PERCENT)));
1285 * gst_message_set_buffering_stats:
1286 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1287 * @mode: a buffering mode
1288 * @avg_in: the average input rate
1289 * @avg_out: the average output rate
1290 * @buffering_left: amount of buffering time left in milliseconds
1292 * Configures the buffering stats values in @message.
1295 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1296 gint avg_in, gint avg_out, gint64 buffering_left)
1298 g_return_if_fail (GST_IS_MESSAGE (message));
1299 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1301 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1302 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1303 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1304 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1305 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1309 * gst_message_parse_buffering_stats:
1310 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1311 * @mode: (out) (allow-none): a buffering mode, or %NULL
1312 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1313 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1314 * @buffering_left: (out) (allow-none): amount of buffering time left in
1315 * milliseconds, or %NULL
1317 * Extracts the buffering stats values from @message.
1320 gst_message_parse_buffering_stats (GstMessage * message,
1321 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1322 gint64 * buffering_left)
1324 GstStructure *structure;
1326 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1328 structure = GST_MESSAGE_STRUCTURE (message);
1330 *mode = (GstBufferingMode)
1331 g_value_get_enum (gst_structure_id_get_value (structure,
1332 GST_QUARK (BUFFERING_MODE)));
1334 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1335 GST_QUARK (AVG_IN_RATE)));
1337 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1338 GST_QUARK (AVG_OUT_RATE)));
1341 g_value_get_int64 (gst_structure_id_get_value (structure,
1342 GST_QUARK (BUFFERING_LEFT)));
1346 * gst_message_parse_state_changed:
1347 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1348 * @oldstate: (out) (allow-none): the previous state, or %NULL
1349 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1350 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1352 * Extracts the old and new states from the GstMessage.
1354 * Typical usage of this function might be:
1355 * |[<!-- language="C" -->
1357 * switch (GST_MESSAGE_TYPE (msg)) {
1358 * case GST_MESSAGE_STATE_CHANGED: {
1359 * GstState old_state, new_state;
1361 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1362 * g_print ("Element %s changed state from %s to %s.\n",
1363 * GST_OBJECT_NAME (msg->src),
1364 * gst_element_state_get_name (old_state),
1365 * gst_element_state_get_name (new_state));
1376 gst_message_parse_state_changed (GstMessage * message,
1377 GstState * oldstate, GstState * newstate, GstState * pending)
1379 GstStructure *structure;
1381 g_return_if_fail (GST_IS_MESSAGE (message));
1382 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1384 structure = GST_MESSAGE_STRUCTURE (message);
1386 *oldstate = (GstState)
1387 g_value_get_enum (gst_structure_id_get_value (structure,
1388 GST_QUARK (OLD_STATE)));
1390 *newstate = (GstState)
1391 g_value_get_enum (gst_structure_id_get_value (structure,
1392 GST_QUARK (NEW_STATE)));
1394 *pending = (GstState)
1395 g_value_get_enum (gst_structure_id_get_value (structure,
1396 GST_QUARK (PENDING_STATE)));
1400 * gst_message_parse_clock_provide:
1401 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1402 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1404 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1406 * Extracts the clock and ready flag from the GstMessage.
1407 * The clock object returned remains valid until the message is freed.
1412 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1415 const GValue *clock_gvalue;
1416 GstStructure *structure;
1418 g_return_if_fail (GST_IS_MESSAGE (message));
1419 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1421 structure = GST_MESSAGE_STRUCTURE (message);
1422 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1423 g_return_if_fail (clock_gvalue != NULL);
1424 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1428 g_value_get_boolean (gst_structure_id_get_value (structure,
1429 GST_QUARK (READY)));
1431 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1435 * gst_message_parse_clock_lost:
1436 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1437 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1439 * Extracts the lost clock from the GstMessage.
1440 * The clock object returned remains valid until the message is freed.
1445 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1447 const GValue *clock_gvalue;
1448 GstStructure *structure;
1450 g_return_if_fail (GST_IS_MESSAGE (message));
1451 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1453 structure = GST_MESSAGE_STRUCTURE (message);
1454 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1455 g_return_if_fail (clock_gvalue != NULL);
1456 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1459 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1463 * gst_message_parse_new_clock:
1464 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1465 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1468 * Extracts the new clock from the GstMessage.
1469 * The clock object returned remains valid until the message is freed.
1474 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1476 const GValue *clock_gvalue;
1477 GstStructure *structure;
1479 g_return_if_fail (GST_IS_MESSAGE (message));
1480 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1482 structure = GST_MESSAGE_STRUCTURE (message);
1483 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1484 g_return_if_fail (clock_gvalue != NULL);
1485 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1488 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1492 * gst_message_parse_structure_change:
1493 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1494 * @type: (out): A pointer to hold the change type
1495 * @owner: (out) (allow-none) (transfer none): The owner element of the
1497 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1498 * progress or has been completed
1500 * Extracts the change type and completion status from the GstMessage.
1505 gst_message_parse_structure_change (GstMessage * message,
1506 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1508 const GValue *owner_gvalue;
1509 GstStructure *structure;
1511 g_return_if_fail (GST_IS_MESSAGE (message));
1512 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1514 structure = GST_MESSAGE_STRUCTURE (message);
1515 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1516 g_return_if_fail (owner_gvalue != NULL);
1517 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1520 *type = (GstStructureChangeType)
1521 g_value_get_enum (gst_structure_id_get_value (structure,
1524 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1527 g_value_get_boolean (gst_structure_id_get_value (structure,
1532 * gst_message_parse_error:
1533 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1534 * @gerror: (out) (allow-none) (transfer full): location for the GError
1535 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1538 * Extracts the GError and debug string from the GstMessage. The values returned
1539 * in the output arguments are copies; the caller must free them when done.
1541 * Typical usage of this function might be:
1542 * |[<!-- language="C" -->
1544 * switch (GST_MESSAGE_TYPE (msg)) {
1545 * case GST_MESSAGE_ERROR: {
1546 * GError *err = NULL;
1547 * gchar *dbg_info = NULL;
1549 * gst_message_parse_error (msg, &err, &dbg_info);
1550 * g_printerr ("ERROR from element %s: %s\n",
1551 * GST_OBJECT_NAME (msg->src), err->message);
1552 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1553 * g_error_free (err);
1554 * g_free (dbg_info);
1565 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1567 g_return_if_fail (GST_IS_MESSAGE (message));
1568 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1570 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1571 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1572 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1576 * gst_message_parse_warning:
1577 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1578 * @gerror: (out) (allow-none) (transfer full): location for the GError
1579 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1582 * Extracts the GError and debug string from the GstMessage. The values returned
1583 * in the output arguments are copies; the caller must free them when done.
1588 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1591 g_return_if_fail (GST_IS_MESSAGE (message));
1592 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1594 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1595 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1596 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1600 * gst_message_parse_info:
1601 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1602 * @gerror: (out) (allow-none) (transfer full): location for the GError
1603 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1606 * Extracts the GError and debug string from the GstMessage. The values returned
1607 * in the output arguments are copies; the caller must free them when done.
1612 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1614 g_return_if_fail (GST_IS_MESSAGE (message));
1615 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1617 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1618 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1619 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1623 * gst_message_parse_segment_start:
1624 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1625 * @format: (out) (allow-none): Result location for the format, or %NULL
1626 * @position: (out) (allow-none): Result location for the position, or %NULL
1628 * Extracts the position and format from the segment start message.
1633 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1636 GstStructure *structure;
1638 g_return_if_fail (GST_IS_MESSAGE (message));
1639 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1641 structure = GST_MESSAGE_STRUCTURE (message);
1643 *format = (GstFormat)
1644 g_value_get_enum (gst_structure_id_get_value (structure,
1645 GST_QUARK (FORMAT)));
1648 g_value_get_int64 (gst_structure_id_get_value (structure,
1649 GST_QUARK (POSITION)));
1653 * gst_message_parse_segment_done:
1654 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1655 * @format: (out) (allow-none): Result location for the format, or %NULL
1656 * @position: (out) (allow-none): Result location for the position, or %NULL
1658 * Extracts the position and format from the segment done message.
1663 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1666 GstStructure *structure;
1668 g_return_if_fail (GST_IS_MESSAGE (message));
1669 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1671 structure = GST_MESSAGE_STRUCTURE (message);
1673 *format = (GstFormat)
1674 g_value_get_enum (gst_structure_id_get_value (structure,
1675 GST_QUARK (FORMAT)));
1678 g_value_get_int64 (gst_structure_id_get_value (structure,
1679 GST_QUARK (POSITION)));
1683 * gst_message_parse_async_done:
1684 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1685 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1687 * Extract the running_time from the async_done message.
1692 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1694 GstStructure *structure;
1696 g_return_if_fail (GST_IS_MESSAGE (message));
1697 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1699 structure = GST_MESSAGE_STRUCTURE (message);
1702 g_value_get_uint64 (gst_structure_id_get_value (structure,
1703 GST_QUARK (RUNNING_TIME)));
1707 * gst_message_parse_request_state:
1708 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1709 * @state: (out) (allow-none): Result location for the requested state or %NULL
1711 * Extract the requested state from the request_state message.
1716 gst_message_parse_request_state (GstMessage * message, GstState * state)
1718 GstStructure *structure;
1720 g_return_if_fail (GST_IS_MESSAGE (message));
1721 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1723 structure = GST_MESSAGE_STRUCTURE (message);
1726 g_value_get_enum (gst_structure_id_get_value (structure,
1727 GST_QUARK (NEW_STATE)));
1731 * gst_message_new_stream_status:
1732 * @src: The object originating the message.
1733 * @type: The stream status type.
1734 * @owner: (transfer none): the owner element of @src.
1736 * Create a new stream status message. This message is posted when a streaming
1737 * thread is created/destroyed or when the state changed.
1739 * Returns: (transfer full): the new stream status message.
1744 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1747 GstMessage *message;
1748 GstStructure *structure;
1750 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1751 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1752 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1753 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1759 * gst_message_parse_stream_status:
1760 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1761 * @type: (out): A pointer to hold the status type
1762 * @owner: (out) (transfer none): The owner element of the message source
1764 * Extracts the stream status type and owner the GstMessage. The returned
1765 * owner remains valid for as long as the reference to @message is valid and
1766 * should thus not be unreffed.
1771 gst_message_parse_stream_status (GstMessage * message,
1772 GstStreamStatusType * type, GstElement ** owner)
1774 const GValue *owner_gvalue;
1775 GstStructure *structure;
1777 g_return_if_fail (GST_IS_MESSAGE (message));
1778 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1780 structure = GST_MESSAGE_STRUCTURE (message);
1781 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1782 g_return_if_fail (owner_gvalue != NULL);
1785 *type = (GstStreamStatusType)
1786 g_value_get_enum (gst_structure_id_get_value (structure,
1789 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1793 * gst_message_set_stream_status_object:
1794 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1795 * @object: the object controlling the streaming
1797 * Configures the object handling the streaming thread. This is usually a
1798 * GstTask object but other objects might be added in the future.
1801 gst_message_set_stream_status_object (GstMessage * message,
1802 const GValue * object)
1804 GstStructure *structure;
1806 g_return_if_fail (GST_IS_MESSAGE (message));
1807 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1809 structure = GST_MESSAGE_STRUCTURE (message);
1810 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1814 * gst_message_get_stream_status_object:
1815 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1817 * Extracts the object managing the streaming thread from @message.
1819 * Returns: (nullable): a GValue containing the object that manages the
1820 * streaming thread. This object is usually of type GstTask but other types can
1821 * be added in the future. The object remains valid as long as @message is
1825 gst_message_get_stream_status_object (GstMessage * message)
1827 const GValue *result;
1828 GstStructure *structure;
1830 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1831 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1834 structure = GST_MESSAGE_STRUCTURE (message);
1835 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1841 * gst_message_new_step_done:
1842 * @src: The object originating the message.
1843 * @format: the format of @amount
1844 * @amount: the amount of stepped data
1845 * @rate: the rate of the stepped amount
1846 * @flush: is this an flushing step
1847 * @intermediate: is this an intermediate step
1848 * @duration: the duration of the data
1849 * @eos: the step caused EOS
1851 * This message is posted by elements when they complete a part, when @intermediate set
1852 * to %TRUE, or a complete step operation.
1854 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1855 * @amount of media in format @format.
1857 * Returns: (transfer full): the new step_done message.
1862 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1863 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1866 GstMessage *message;
1867 GstStructure *structure;
1869 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1870 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1871 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1872 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1873 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1874 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1875 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1876 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1877 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1883 * gst_message_parse_step_done:
1884 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1885 * @format: (out) (allow-none): result location for the format
1886 * @amount: (out) (allow-none): result location for the amount
1887 * @rate: (out) (allow-none): result location for the rate
1888 * @flush: (out) (allow-none): result location for the flush flag
1889 * @intermediate: (out) (allow-none): result location for the intermediate flag
1890 * @duration: (out) (allow-none): result location for the duration
1891 * @eos: (out) (allow-none): result location for the EOS flag
1893 * Extract the values the step_done message.
1898 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1899 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1900 guint64 * duration, gboolean * eos)
1902 GstStructure *structure;
1904 g_return_if_fail (GST_IS_MESSAGE (message));
1905 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1907 structure = GST_MESSAGE_STRUCTURE (message);
1908 gst_structure_id_get (structure,
1909 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1910 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1911 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1912 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1913 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1914 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1915 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1919 * gst_message_new_step_start:
1920 * @src: The object originating the message.
1921 * @active: if the step is active or queued
1922 * @format: the format of @amount
1923 * @amount: the amount of stepped data
1924 * @rate: the rate of the stepped amount
1925 * @flush: is this an flushing step
1926 * @intermediate: is this an intermediate step
1928 * This message is posted by elements when they accept or activate a new step
1929 * event for @amount in @format.
1931 * @active is set to %FALSE when the element accepted the new step event and has
1932 * queued it for execution in the streaming threads.
1934 * @active is set to %TRUE when the element has activated the step operation and
1935 * is now ready to start executing the step in the streaming thread. After this
1936 * message is emitted, the application can queue a new step operation in the
1939 * Returns: (transfer full): The new step_start message.
1944 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1945 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1947 GstMessage *message;
1948 GstStructure *structure;
1950 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1951 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1952 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1953 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1954 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1955 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1956 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1957 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1963 * gst_message_parse_step_start:
1964 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1965 * @active: (out) (allow-none): result location for the active flag
1966 * @format: (out) (allow-none): result location for the format
1967 * @amount: (out) (allow-none): result location for the amount
1968 * @rate: (out) (allow-none): result location for the rate
1969 * @flush: (out) (allow-none): result location for the flush flag
1970 * @intermediate: (out) (allow-none): result location for the intermediate flag
1972 * Extract the values from step_start message.
1977 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1978 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1979 gboolean * intermediate)
1981 GstStructure *structure;
1983 g_return_if_fail (GST_IS_MESSAGE (message));
1984 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1986 structure = GST_MESSAGE_STRUCTURE (message);
1987 gst_structure_id_get (structure,
1988 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1989 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1990 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1991 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1992 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1993 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1997 * gst_message_new_qos:
1998 * @src: The object originating the message.
1999 * @live: if the message was generated by a live element
2000 * @running_time: the running time of the buffer that generated the message
2001 * @stream_time: the stream time of the buffer that generated the message
2002 * @timestamp: the timestamps of the buffer that generated the message
2003 * @duration: the duration of the buffer that generated the message
2005 * A QOS message is posted on the bus whenever an element decides to drop a
2006 * buffer because of QoS reasons or whenever it changes its processing strategy
2007 * because of QoS reasons (quality adjustments such as processing at lower
2010 * This message can be posted by an element that performs synchronisation against the
2011 * clock (live) or it could be dropped by an element that performs QoS because of QOS
2012 * events received from a downstream element (!live).
2014 * @running_time, @stream_time, @timestamp, @duration should be set to the
2015 * respective running-time, stream-time, timestamp and duration of the (dropped)
2016 * buffer that generated the QoS event. Values can be left to
2017 * GST_CLOCK_TIME_NONE when unknown.
2019 * Returns: (transfer full): The new qos message.
2024 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
2025 guint64 stream_time, guint64 timestamp, guint64 duration)
2027 GstMessage *message;
2028 GstStructure *structure;
2030 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
2031 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2032 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2033 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2034 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2035 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
2036 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
2037 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
2038 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
2039 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
2040 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
2041 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
2042 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
2048 * gst_message_set_qos_values:
2049 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2050 * @jitter: The difference of the running-time against the deadline.
2051 * @proportion: Long term prediction of the ideal rate relative to normal rate
2052 * to get optimal quality.
2053 * @quality: An element dependent integer value that specifies the current
2054 * quality level of the element. The default maximum quality is 1000000.
2056 * Set the QoS values that have been calculated/analysed from the QoS data
2061 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
2062 gdouble proportion, gint quality)
2064 GstStructure *structure;
2066 g_return_if_fail (GST_IS_MESSAGE (message));
2067 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2069 structure = GST_MESSAGE_STRUCTURE (message);
2070 gst_structure_id_set (structure,
2071 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2072 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2073 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2077 * gst_message_set_qos_stats:
2078 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2079 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
2080 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
2081 * will likely use GST_FORMAT_DEFAULT (samples).
2082 * @processed: Total number of units correctly processed since the last state
2083 * change to READY or a flushing operation.
2084 * @dropped: Total number of units dropped since the last state change to READY
2085 * or a flushing operation.
2087 * Set the QoS stats representing the history of the current continuous pipeline
2090 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2091 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2096 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
2097 guint64 processed, guint64 dropped)
2099 GstStructure *structure;
2101 g_return_if_fail (GST_IS_MESSAGE (message));
2102 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2104 structure = GST_MESSAGE_STRUCTURE (message);
2105 gst_structure_id_set (structure,
2106 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2107 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2108 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2112 * gst_message_parse_qos:
2113 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2114 * @live: (out) (allow-none): if the message was generated by a live element
2115 * @running_time: (out) (allow-none): the running time of the buffer that
2116 * generated the message
2117 * @stream_time: (out) (allow-none): the stream time of the buffer that
2118 * generated the message
2119 * @timestamp: (out) (allow-none): the timestamps of the buffer that
2120 * generated the message
2121 * @duration: (out) (allow-none): the duration of the buffer that
2122 * generated the message
2124 * Extract the timestamps and live status from the QoS message.
2126 * The returned values give the running_time, stream_time, timestamp and
2127 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2133 gst_message_parse_qos (GstMessage * message, gboolean * live,
2134 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2137 GstStructure *structure;
2139 g_return_if_fail (GST_IS_MESSAGE (message));
2140 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2142 structure = GST_MESSAGE_STRUCTURE (message);
2143 gst_structure_id_get (structure,
2144 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2145 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2146 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2147 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2148 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2152 * gst_message_parse_qos_values:
2153 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2154 * @jitter: (out) (allow-none): The difference of the running-time against
2156 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2157 * relative to normal rate to get optimal quality.
2158 * @quality: (out) (allow-none): An element dependent integer value that
2159 * specifies the current quality level of the element. The default
2160 * maximum quality is 1000000.
2162 * Extract the QoS values that have been calculated/analysed from the QoS data
2167 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2168 gdouble * proportion, gint * quality)
2170 GstStructure *structure;
2172 g_return_if_fail (GST_IS_MESSAGE (message));
2173 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2175 structure = GST_MESSAGE_STRUCTURE (message);
2176 gst_structure_id_get (structure,
2177 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2178 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2179 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2183 * gst_message_parse_qos_stats:
2184 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2185 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2186 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2187 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2189 * @processed: (out) (allow-none): Total number of units correctly processed
2190 * since the last state change to READY or a flushing operation.
2191 * @dropped: (out) (allow-none): Total number of units dropped since the last
2192 * state change to READY or a flushing operation.
2194 * Extract the QoS stats representing the history of the current continuous
2195 * pipeline playback period.
2197 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2198 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2203 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2204 guint64 * processed, guint64 * dropped)
2206 GstStructure *structure;
2208 g_return_if_fail (GST_IS_MESSAGE (message));
2209 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2211 structure = GST_MESSAGE_STRUCTURE (message);
2212 gst_structure_id_get (structure,
2213 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2214 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2215 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2219 * gst_message_new_progress:
2220 * @src: The object originating the message.
2221 * @type: a #GstProgressType
2222 * @code: a progress code
2223 * @text: free, user visible text describing the progress
2225 * Progress messages are posted by elements when they use an asynchronous task
2226 * to perform actions triggered by a state change.
2228 * @code contains a well defined string describing the action.
2229 * @text should contain a user visible string detailing the current action.
2231 * Returns: (transfer full) (nullable): The new qos message.
2234 gst_message_new_progress (GstObject * src, GstProgressType type,
2235 const gchar * code, const gchar * text)
2237 GstMessage *message;
2238 GstStructure *structure;
2239 gint percent = 100, timeout = -1;
2241 g_return_val_if_fail (code != NULL, NULL);
2242 g_return_val_if_fail (text != NULL, NULL);
2244 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2247 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2248 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2249 GST_QUARK (CODE), G_TYPE_STRING, code,
2250 GST_QUARK (TEXT), G_TYPE_STRING, text,
2251 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2252 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2253 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2259 * gst_message_parse_progress:
2260 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2261 * @type: (out) (allow-none): location for the type
2262 * @code: (out) (allow-none) (transfer full): location for the code
2263 * @text: (out) (allow-none) (transfer full): location for the text
2265 * Parses the progress @type, @code and @text.
2268 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2269 gchar ** code, gchar ** text)
2271 GstStructure *structure;
2273 g_return_if_fail (GST_IS_MESSAGE (message));
2274 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2276 structure = GST_MESSAGE_STRUCTURE (message);
2277 gst_structure_id_get (structure,
2278 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2279 GST_QUARK (CODE), G_TYPE_STRING, code,
2280 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2284 * gst_message_new_toc:
2285 * @src: the object originating the message.
2286 * @toc: (transfer none): #GstToc structure for the message.
2287 * @updated: whether TOC was updated or not.
2289 * Create a new TOC message. The message is posted by elements
2290 * that discovered or updated a TOC.
2292 * Returns: (transfer full): a new TOC message.
2297 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2299 GstStructure *toc_struct;
2301 g_return_val_if_fail (toc != NULL, NULL);
2303 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2304 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2305 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2307 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2311 * gst_message_parse_toc:
2312 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2313 * @toc: (out) (transfer full): return location for the TOC.
2314 * @updated: (out): return location for the updated flag.
2316 * Extract the TOC from the #GstMessage. The TOC returned in the
2317 * output argument is a copy; the caller must free it with
2318 * gst_toc_unref() when done.
2323 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2325 g_return_if_fail (GST_IS_MESSAGE (message));
2326 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2327 g_return_if_fail (toc != NULL);
2329 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2330 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2331 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2335 * gst_message_new_reset_time:
2336 * @src: (transfer none) (allow-none): The object originating the message.
2337 * @running_time: the requested running-time
2339 * This message is posted when the pipeline running-time should be reset to
2340 * @running_time, like after a flushing seek.
2342 * Returns: (transfer full): The new reset_time message.
2347 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2349 GstMessage *message;
2350 GstStructure *structure;
2352 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2353 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2354 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2360 * gst_message_parse_reset_time:
2361 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2362 * @running_time: (out) (allow-none): Result location for the running_time or
2365 * Extract the running-time from the RESET_TIME message.
2370 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2372 GstStructure *structure;
2374 g_return_if_fail (GST_IS_MESSAGE (message));
2375 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2377 structure = GST_MESSAGE_STRUCTURE (message);
2380 g_value_get_uint64 (gst_structure_id_get_value (structure,
2381 GST_QUARK (RUNNING_TIME)));
2385 * gst_message_new_stream_start:
2386 * @src: (transfer none) (allow-none): The object originating the message.
2388 * Create a new stream_start message. This message is generated and posted in
2389 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2390 * message to the application if all sinks have posted an STREAM_START message.
2392 * Returns: (transfer full): The new stream_start message.
2397 gst_message_new_stream_start (GstObject * src)
2399 GstMessage *message;
2402 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2403 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2410 * gst_message_set_group_id:
2411 * @message: the message
2412 * @group_id: the group id
2414 * Sets the group id on the stream-start message.
2416 * All streams that have the same group id are supposed to be played
2417 * together, i.e. all streams inside a container file should have the
2418 * same group id but different stream ids. The group id should change
2419 * each time the stream is started, resulting in different group ids
2420 * each time a file is played for example.
2427 gst_message_set_group_id (GstMessage * message, guint group_id)
2429 GstStructure *structure;
2431 g_return_if_fail (GST_IS_MESSAGE (message));
2432 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2433 g_return_if_fail (gst_message_is_writable (message));
2435 structure = GST_MESSAGE_STRUCTURE (message);
2436 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2441 * gst_message_parse_group_id:
2442 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2443 * @group_id: (out) (allow-none): Result location for the group id or
2446 * Extract the group from the STREAM_START message.
2448 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2455 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2457 GstStructure *structure;
2460 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2461 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2467 structure = GST_MESSAGE_STRUCTURE (message);
2469 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2473 *group_id = g_value_get_uint (v);
2478 * gst_message_new_need_context:
2479 * @src: (transfer none) (allow-none): The object originating the message.
2480 * @context_type: The context type that is needed
2482 * This message is posted when an element needs a specific #GstContext.
2484 * Returns: (transfer full): The new need-context message.
2491 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2493 GstMessage *message;
2494 GstStructure *structure;
2496 g_return_val_if_fail (context_type != NULL, NULL);
2498 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2499 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2500 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2506 * gst_message_parse_context_type:
2507 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2508 * @context_type: (out) (transfer none) (allow-none): the context type, or %NULL
2510 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2512 * Returns: a #gboolean indicating if the parsing succeeded.
2517 gst_message_parse_context_type (GstMessage * message,
2518 const gchar ** context_type)
2520 GstStructure *structure;
2521 const GValue *value;
2523 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2526 structure = GST_MESSAGE_STRUCTURE (message);
2529 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2530 *context_type = g_value_get_string (value);
2537 * gst_message_new_have_context:
2538 * @src: (transfer none) (allow-none): The object originating the message.
2539 * @context: (transfer full): the context
2541 * This message is posted when an element has a new local #GstContext.
2543 * Returns: (transfer full): The new have-context message.
2550 gst_message_new_have_context (GstObject * src, GstContext * context)
2552 GstMessage *message;
2553 GstStructure *structure;
2555 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2556 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2557 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2558 gst_context_unref (context);
2564 * gst_message_parse_have_context:
2565 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2566 * @context: (out) (transfer full) (allow-none): Result location for the
2569 * Extract the context from the HAVE_CONTEXT message.
2576 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2578 g_return_if_fail (GST_IS_MESSAGE (message));
2579 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2582 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2583 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2587 * gst_message_new_device_added:
2588 * @src: The #GstObject that created the message
2589 * @device: (transfer none): The new #GstDevice
2591 * Creates a new device-added message. The device-added message is produced by
2592 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2593 * of monitored devices.
2595 * Returns: a newly allocated #GstMessage
2600 gst_message_new_device_added (GstObject * src, GstDevice * device)
2602 GstMessage *message;
2603 GstStructure *structure;
2605 g_return_val_if_fail (device != NULL, NULL);
2606 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2608 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2609 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2610 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2616 * gst_message_parse_device_added:
2617 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2618 * @device: (out) (allow-none) (transfer full): A location where to store a
2619 * pointer to the new #GstDevice, or %NULL
2621 * Parses a device-added message. The device-added message is produced by
2622 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2623 * of monitored devices.
2628 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2630 g_return_if_fail (GST_IS_MESSAGE (message));
2631 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2634 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2635 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2639 * gst_message_new_device_removed:
2640 * @src: The #GstObject that created the message
2641 * @device: (transfer none): The removed #GstDevice
2643 * Creates a new device-removed message. The device-removed message is produced
2644 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2645 * disappearance of monitored devices.
2647 * Returns: a newly allocated #GstMessage
2652 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2654 GstMessage *message;
2655 GstStructure *structure;
2657 g_return_val_if_fail (device != NULL, NULL);
2658 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2660 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2661 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2662 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2668 * gst_message_parse_device_removed:
2669 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2670 * @device: (out) (allow-none) (transfer full): A location where to store a
2671 * pointer to the removed #GstDevice, or %NULL
2673 * Parses a device-removed message. The device-removed message is produced by
2674 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2675 * disappearance of monitored devices.
2680 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2682 g_return_if_fail (GST_IS_MESSAGE (message));
2683 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2686 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2687 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2691 * gst_message_new_property_notify:
2692 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2693 * @property_name: name of the property that changed
2694 * @val: (allow-none) (transfer full): new property value, or %NULL
2696 * Returns: a newly allocated #GstMessage
2701 gst_message_new_property_notify (GstObject * src, const gchar * property_name,
2704 GstStructure *structure;
2705 GValue name_val = G_VALUE_INIT;
2707 g_return_val_if_fail (property_name != NULL, NULL);
2709 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
2710 g_value_init (&name_val, G_TYPE_STRING);
2711 /* should already be interned, but let's make sure */
2712 g_value_set_static_string (&name_val, g_intern_string (property_name));
2713 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
2715 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
2717 return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
2721 * gst_message_parse_property_notify:
2722 * @message: a #GstMessage of type %GST_MESSAGE_PROPERTY_NOTIFY
2723 * @object: (out) (allow-none) (transfer none): location where to store a
2724 * pointer to the object whose property got changed, or %NULL
2725 * @property_name: (out) (transfer none) (allow-none): return location for
2726 * the name of the property that got changed, or %NULL
2727 * @property_value: (out) (transfer none) (allow-none): return location for
2728 * the new value of the property that got changed, or %NULL. This will
2729 * only be set if the property notify watch was told to include the value
2730 * when it was set up
2732 * Parses a property-notify message. These will be posted on the bus only
2733 * when set up with gst_element_add_property_notify_watch() or
2734 * gst_element_add_property_deep_notify_watch().
2739 gst_message_parse_property_notify (GstMessage * message, GstObject ** object,
2740 const gchar ** property_name, const GValue ** property_value)
2742 const GstStructure *s = GST_MESSAGE_STRUCTURE (message);
2744 g_return_if_fail (GST_IS_MESSAGE (message));
2745 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROPERTY_NOTIFY);
2748 *object = GST_MESSAGE_SRC (message);
2750 if (property_name) {
2751 const GValue *name_value;
2753 name_value = gst_structure_id_get_value (s, GST_QUARK (PROPERTY_NAME));
2754 *property_name = g_value_get_string (name_value);
2759 gst_structure_id_get_value (s, GST_QUARK (PROPERTY_VALUE));
2763 * gst_message_new_stream_collection:
2764 * @src: The #GstObject that created the message
2765 * @collection: (transfer none): The #GstStreamCollection
2767 * Creates a new stream-collection message. The message is used to announce new
2768 * #GstStreamCollection
2770 * Returns: a newly allocated #GstMessage
2775 gst_message_new_stream_collection (GstObject * src,
2776 GstStreamCollection * collection)
2778 GstMessage *message;
2779 GstStructure *structure;
2781 g_return_val_if_fail (collection != NULL, NULL);
2782 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2785 gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_COLLECTION),
2786 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2788 gst_message_new_custom (GST_MESSAGE_STREAM_COLLECTION, src, structure);
2794 * gst_message_parse_stream_collection:
2795 * @message: a #GstMessage of type %GST_MESSAGE_STREAM_COLLECTION
2796 * @collection: (out) (allow-none) (transfer full): A location where to store a
2797 * pointer to the #GstStreamCollection, or %NULL
2799 * Parses a stream-collection message.
2804 gst_message_parse_stream_collection (GstMessage * message,
2805 GstStreamCollection ** collection)
2807 g_return_if_fail (GST_IS_MESSAGE (message));
2808 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
2809 GST_MESSAGE_STREAM_COLLECTION);
2812 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2813 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2817 * gst_message_new_streams_selected:
2818 * @src: The #GstObject that created the message
2819 * @collection: (transfer none): The #GstStreamCollection
2821 * Creates a new steams-selected message. The message is used to announce
2822 * that an array of streams has been selected. This is generally in response
2823 * to a #GST_EVENT_SELECT_STREAMS event, or when an element (such as decodebin3)
2824 * makes an initial selection of streams.
2826 * The message also contains the #GstStreamCollection to which the various streams
2829 * Users of gst_message_new_streams_selected() can add the selected streams with
2830 * gst_message_streams_selected_add().
2832 * Returns: a newly allocated #GstMessage
2837 gst_message_new_streams_selected (GstObject * src,
2838 GstStreamCollection * collection)
2840 GstMessage *message;
2841 GstStructure *structure;
2842 GValue val = G_VALUE_INIT;
2844 g_return_val_if_fail (collection != NULL, NULL);
2845 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2848 gst_structure_new_id (GST_QUARK (MESSAGE_STREAMS_SELECTED),
2849 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2850 g_value_init (&val, GST_TYPE_ARRAY);
2851 gst_structure_id_take_value (structure, GST_QUARK (STREAMS), &val);
2853 gst_message_new_custom (GST_MESSAGE_STREAMS_SELECTED, src, structure);
2859 * gst_message_streams_selected_get_size:
2860 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2862 * Returns the number of streams contained in the @message.
2864 * Returns: The number of streams contained within.
2869 gst_message_streams_selected_get_size (GstMessage * msg)
2873 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
2874 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2878 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2879 GST_QUARK (STREAMS));
2880 return gst_value_array_get_size (val);
2884 * gst_message_streams_selected_add:
2885 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2886 * @stream: (transfer none): a #GstStream to add to @message
2888 * Adds the @stream to the @message.
2893 gst_message_streams_selected_add (GstMessage * msg, GstStream * stream)
2896 GValue to_add = G_VALUE_INIT;
2898 g_return_if_fail (GST_IS_MESSAGE (msg));
2899 g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED);
2900 g_return_if_fail (GST_IS_STREAM (stream));
2903 (GValue *) gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2904 GST_QUARK (STREAMS));
2905 g_value_init (&to_add, GST_TYPE_STREAM);
2906 g_value_set_object (&to_add, stream);
2907 gst_value_array_append_and_take_value (val, &to_add);
2911 * gst_message_streams_selected_get_stream:
2912 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2913 * @idx: Index of the stream to retrieve
2915 * Retrieves the #GstStream with index @index from the @message.
2917 * Returns: (transfer full) (nullable): A #GstStream
2922 gst_message_streams_selected_get_stream (GstMessage * msg, guint idx)
2924 const GValue *streams, *val;
2926 g_return_val_if_fail (GST_IS_MESSAGE (msg), NULL);
2927 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2931 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2932 GST_QUARK (STREAMS));
2933 val = gst_value_array_get_value (streams, idx);
2935 return (GstStream *) g_value_dup_object (val);
2942 * gst_message_parse_streams_selected:
2943 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2944 * @collection: (out) (allow-none) (transfer full): A location where to store a
2945 * pointer to the #GstStreamCollection, or %NULL
2947 * Parses a streams-selected message.
2952 gst_message_parse_streams_selected (GstMessage * message,
2953 GstStreamCollection ** collection)
2955 g_return_if_fail (GST_IS_MESSAGE (message));
2956 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAMS_SELECTED);
2959 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2960 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2964 * gst_message_new_redirect:
2965 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2966 * @location: (transfer none): location string for the new entry
2967 * @tag_list: (transfer full) (allow-none): tag list for the new entry
2968 * @entry_struct: (transfer full) (allow-none): structure for the new entry
2970 * Creates a new redirect message and adds a new entry to it. Redirect messages
2971 * are posted when an element detects that the actual data has to be retrieved
2972 * from a different location. This is useful if such a redirection cannot be
2973 * handled inside a source element, for example when HTTP 302/303 redirects
2974 * return a non-HTTP URL.
2976 * The redirect message can hold multiple entries. The first one is added
2977 * when the redirect message is created, with the given location, tag_list,
2978 * entry_struct arguments. Use gst_message_add_redirect_entry() to add more
2981 * Each entry has a location, a tag list, and a structure. All of these are
2982 * optional. The tag list and structure are useful for additional metadata,
2983 * such as bitrate statistics for the given location.
2985 * By default, message recipients should treat entries in the order they are
2986 * stored. The recipient should therefore try entry #0 first, and if this
2987 * entry is not acceptable or working, try entry #1 etc. Senders must make
2988 * sure that they add entries in this order. However, recipients are free to
2989 * ignore the order and pick an entry that is "best" for them. One example
2990 * would be a recipient that scans the entries for the one with the highest
2993 * The specified location string is copied. However, ownership over the tag
2994 * list and structure are transferred to the message.
2996 * Returns: a newly allocated #GstMessage
3001 gst_message_new_redirect (GstObject * src, const gchar * location,
3002 GstTagList * tag_list, const GstStructure * entry_struct)
3004 GstStructure *structure;
3005 GstMessage *message;
3006 GValue entry_locations_gvalue = G_VALUE_INIT;
3007 GValue entry_taglists_gvalue = G_VALUE_INIT;
3008 GValue entry_structures_gvalue = G_VALUE_INIT;
3010 g_return_val_if_fail (location != NULL, NULL);
3012 g_value_init (&entry_locations_gvalue, GST_TYPE_LIST);
3013 g_value_init (&entry_taglists_gvalue, GST_TYPE_LIST);
3014 g_value_init (&entry_structures_gvalue, GST_TYPE_LIST);
3016 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_REDIRECT));
3017 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_LOCATIONS),
3018 &entry_locations_gvalue);
3019 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_TAGLISTS),
3020 &entry_taglists_gvalue);
3021 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_STRUCTURES),
3022 &entry_structures_gvalue);
3024 message = gst_message_new_custom (GST_MESSAGE_REDIRECT, src, structure);
3025 g_assert (message != NULL);
3027 gst_message_add_redirect_entry (message, location, tag_list, entry_struct);
3033 * gst_message_add_redirect_entry:
3034 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3035 * @location: (transfer none): location string for the new entry
3036 * @tag_list: (transfer full) (allow-none): tag list for the new entry
3037 * @entry_struct: (transfer full) (allow-none): structure for the new entry
3039 * Creates and appends a new entry.
3041 * The specified location string is copied. However, ownership over the tag
3042 * list and structure are transferred to the message.
3047 gst_message_add_redirect_entry (GstMessage * message, const gchar * location,
3048 GstTagList * tag_list, const GstStructure * entry_struct)
3050 GValue val = G_VALUE_INIT;
3051 GstStructure *structure;
3052 GValue *entry_locations_gvalue;
3053 GValue *entry_taglists_gvalue;
3054 GValue *entry_structures_gvalue;
3056 g_return_if_fail (location != NULL);
3057 g_return_if_fail (GST_IS_MESSAGE (message));
3058 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3060 structure = GST_MESSAGE_STRUCTURE (message);
3062 entry_locations_gvalue =
3063 (GValue *) gst_structure_id_get_value (structure,
3064 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3065 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3066 entry_taglists_gvalue =
3067 (GValue *) gst_structure_id_get_value (structure,
3068 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3069 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3070 entry_structures_gvalue =
3071 (GValue *) gst_structure_id_get_value (structure,
3072 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3073 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3075 g_value_init (&val, G_TYPE_STRING);
3077 g_value_set_string (&val, location);
3078 gst_value_list_append_and_take_value (entry_locations_gvalue, &val);
3080 g_value_init (&val, GST_TYPE_TAG_LIST);
3082 g_value_take_boxed (&val, tag_list);
3083 gst_value_list_append_and_take_value (entry_taglists_gvalue, &val);
3085 g_value_init (&val, GST_TYPE_STRUCTURE);
3087 g_value_take_boxed (&val, entry_struct);
3088 gst_value_list_append_and_take_value (entry_structures_gvalue, &val);
3092 * gst_message_parse_redirect_entry:
3093 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3094 * @entry_index: index of the entry to parse
3095 * @location: (out) (transfer none) (allow-none): return location for
3096 * the pointer to the entry's location string, or %NULL
3097 * @tag_list: (out) (transfer none) (allow-none): return location for
3098 * the pointer to the entry's tag list, or %NULL
3099 * @entry_struct: (out) (transfer none) (allow-none): return location
3100 * for the pointer to the entry's structure, or %NULL
3102 * Parses the location and/or structure from the entry with the given index.
3103 * The index must be between 0 and gst_message_get_num_redirect_entries() - 1.
3104 * Returned pointers are valid for as long as this message exists.
3109 gst_message_parse_redirect_entry (GstMessage * message, gsize entry_index,
3110 const gchar ** location, GstTagList ** tag_list,
3111 const GstStructure ** entry_struct)
3114 GstStructure *structure;
3115 const GValue *entry_locations_gvalue;
3116 const GValue *entry_taglists_gvalue;
3117 const GValue *entry_structures_gvalue;
3119 g_return_if_fail (GST_IS_MESSAGE (message));
3120 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3122 if (G_UNLIKELY (!location && !tag_list && !entry_struct))
3125 structure = GST_MESSAGE_STRUCTURE (message);
3127 entry_locations_gvalue =
3128 gst_structure_id_get_value (structure,
3129 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3130 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3131 entry_taglists_gvalue =
3132 gst_structure_id_get_value (structure,
3133 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3134 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3135 entry_structures_gvalue =
3136 gst_structure_id_get_value (structure,
3137 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3138 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3141 val = gst_value_list_get_value (entry_locations_gvalue, entry_index);
3142 g_return_if_fail (val != NULL);
3143 *location = g_value_get_string (val);
3147 val = gst_value_list_get_value (entry_taglists_gvalue, entry_index);
3148 g_return_if_fail (val != NULL);
3149 *tag_list = (GstTagList *) g_value_get_boxed (val);
3153 val = gst_value_list_get_value (entry_structures_gvalue, entry_index);
3154 g_return_if_fail (val != NULL);
3155 *entry_struct = (const GstStructure *) g_value_get_boxed (val);
3160 * gst_message_get_num_redirect_entries:
3161 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3163 * Returns: the number of entries stored in the message
3168 gst_message_get_num_redirect_entries (GstMessage * message)
3170 GstStructure *structure;
3171 const GValue *entry_locations_gvalue;
3172 const GValue *entry_taglists_gvalue;
3173 const GValue *entry_structures_gvalue;
3176 g_return_val_if_fail (GST_IS_MESSAGE (message), 0);
3177 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT, 0);
3179 structure = GST_MESSAGE_STRUCTURE (message);
3181 entry_locations_gvalue =
3182 gst_structure_id_get_value (structure,
3183 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3184 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue), 0);
3185 entry_taglists_gvalue =
3186 gst_structure_id_get_value (structure,
3187 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3188 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue), 0);
3189 entry_structures_gvalue =
3190 gst_structure_id_get_value (structure,
3191 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3192 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue), 0);
3194 size = gst_value_list_get_size (entry_locations_gvalue);
3196 g_return_val_if_fail ((size ==
3197 gst_value_list_get_size (entry_structures_gvalue))
3198 && (size == gst_value_list_get_size (entry_taglists_gvalue)), 0);