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): 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));
371 GST_MESSAGE_SEQNUM (message) = seqnum;
375 * gst_message_new_eos:
376 * @src: (transfer none) (allow-none): The object originating the message.
378 * Create a new eos message. This message is generated and posted in
379 * the sink elements of a GstBin. The bin will only forward the EOS
380 * message to the application if all sinks have posted an EOS message.
382 * Returns: (transfer full): The new eos message.
387 gst_message_new_eos (GstObject * src)
391 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
397 * gst_message_new_error_with_details:
398 * @src: (transfer none) (allow-none): The object originating the message.
399 * @error: (transfer none): The GError for this message.
400 * @debug: A debugging string.
401 * @details: (transfer full): (allow-none): A GstStructure with details
403 * Create a new error message. The message will copy @error and
404 * @debug. This message is posted by element when a fatal event
405 * occurred. The pipeline will probably (partially) stop. The application
406 * receiving this message should stop the pipeline.
408 * Returns: (transfer full): the new error message.
413 gst_message_new_error_with_details (GstObject * src, GError * error,
414 const gchar * debug, GstStructure * details)
417 GstStructure *structure;
419 if (debug && !g_utf8_validate (debug, -1, NULL)) {
421 g_warning ("Trying to set debug field of error message, but "
422 "string is not valid UTF-8. Please file a bug.");
425 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
426 GST_QUARK (GERROR), G_TYPE_ERROR, error,
427 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
428 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
430 GValue v = G_VALUE_INIT;
432 g_value_init (&v, GST_TYPE_STRUCTURE);
433 g_value_take_boxed (&v, details);
434 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
442 * gst_message_new_error:
443 * @src: (transfer none) (allow-none): The object originating the message.
444 * @error: (transfer none): The GError for this message.
445 * @debug: A debugging string.
447 * Create a new error message. The message will copy @error and
448 * @debug. This message is posted by element when a fatal event
449 * occurred. The pipeline will probably (partially) stop. The application
450 * receiving this message should stop the pipeline.
452 * Returns: (transfer full): the new error message.
457 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
459 return gst_message_new_error_with_details (src, error, debug, NULL);
463 * gst_message_parse_error_details:
464 * @message: The message object
465 * @structure: (out): A pointer to the returned details
467 * Returns the optional details structure, may be NULL if none.
468 * The returned structure must not be freed.
473 gst_message_parse_error_details (GstMessage * message,
474 const GstStructure ** structure)
478 g_return_if_fail (GST_IS_MESSAGE (message));
479 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
480 g_return_if_fail (structure != NULL);
483 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
486 *structure = g_value_get_boxed (v);
491 * gst_message_new_warning_with_details:
492 * @src: (transfer none) (allow-none): The object originating the message.
493 * @error: (transfer none): The GError for this message.
494 * @debug: A debugging string.
495 * @details: (transfer full): (allow-none): A GstStructure with details
497 * Create a new warning message. The message will make copies of @error and
500 * Returns: (transfer full): the new warning message.
505 gst_message_new_warning_with_details (GstObject * src, GError * error,
506 const gchar * debug, GstStructure * details)
509 GstStructure *structure;
511 if (debug && !g_utf8_validate (debug, -1, NULL)) {
513 g_warning ("Trying to set debug field of warning message, but "
514 "string is not valid UTF-8. Please file a bug.");
517 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
518 GST_QUARK (GERROR), G_TYPE_ERROR, error,
519 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
520 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
522 GValue v = G_VALUE_INIT;
524 g_value_init (&v, GST_TYPE_STRUCTURE);
525 g_value_take_boxed (&v, details);
526 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
534 * gst_message_new_warning:
535 * @src: (transfer none) (allow-none): The object originating the message.
536 * @error: (transfer none): The GError for this message.
537 * @debug: A debugging string.
539 * Create a new warning message. The message will make copies of @error and
542 * Returns: (transfer full): the new warning message.
547 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
549 return gst_message_new_warning_with_details (src, error, debug, NULL);
553 * gst_message_parse_warning_details:
554 * @message: The message object
555 * @structure: (out): A pointer to the returned details structure
557 * Returns the optional details structure, may be NULL if none
558 * The returned structure must not be freed.
563 gst_message_parse_warning_details (GstMessage * message,
564 const GstStructure ** structure)
568 g_return_if_fail (GST_IS_MESSAGE (message));
569 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
570 g_return_if_fail (structure != NULL);
573 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
576 *structure = g_value_get_boxed (v);
581 * gst_message_new_info_with_details:
582 * @src: (transfer none) (allow-none): The object originating the message.
583 * @error: (transfer none): The GError for this message.
584 * @debug: A debugging string.
585 * @details: (transfer full): (allow-none): A GstStructure with details
587 * Create a new info message. The message will make copies of @error and
590 * Returns: (transfer full): the new warning message.
595 gst_message_new_info_with_details (GstObject * src, GError * error,
596 const gchar * debug, GstStructure * details)
599 GstStructure *structure;
601 if (debug && !g_utf8_validate (debug, -1, NULL)) {
603 g_warning ("Trying to set debug field of info message, but "
604 "string is not valid UTF-8. Please file a bug.");
607 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
608 GST_QUARK (GERROR), G_TYPE_ERROR, error,
609 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
610 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
612 GValue v = G_VALUE_INIT;
614 g_value_init (&v, GST_TYPE_STRUCTURE);
615 g_value_take_boxed (&v, details);
616 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
624 * gst_message_new_info:
625 * @src: (transfer none) (allow-none): The object originating the message.
626 * @error: (transfer none): The GError for this message.
627 * @debug: A debugging string.
629 * Create a new info message. The message will make copies of @error and
632 * Returns: (transfer full): the new info message.
637 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
639 return gst_message_new_info_with_details (src, error, debug, NULL);
643 * gst_message_parse_info_details:
644 * @message: The message object
645 * @structure: (out): A pointer to the returned details structure
647 * Returns the optional details structure, may be NULL if none
648 * The returned structure must not be freed.
653 gst_message_parse_info_details (GstMessage * message,
654 const GstStructure ** structure)
658 g_return_if_fail (GST_IS_MESSAGE (message));
659 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
660 g_return_if_fail (structure != NULL);
663 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
666 *structure = g_value_get_boxed (v);
671 * gst_message_new_tag:
672 * @src: (transfer none) (allow-none): The object originating the message.
673 * @tag_list: (transfer full): the tag list for the message.
675 * Create a new tag message. The message will take ownership of the tag list.
676 * The message is posted by elements that discovered a new taglist.
678 * Returns: (transfer full): the new tag message.
683 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
687 GValue val = G_VALUE_INIT;
689 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
691 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
692 g_value_init (&val, GST_TYPE_TAG_LIST);
693 g_value_take_boxed (&val, tag_list);
694 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
695 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
700 * gst_message_new_buffering:
701 * @src: (transfer none) (allow-none): The object originating the message.
702 * @percent: The buffering percent
704 * Create a new buffering message. This message can be posted by an element that
705 * needs to buffer data before it can continue processing. @percent should be a
706 * value between 0 and 100. A value of 100 means that the buffering completed.
708 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
709 * @percent is 100, the application can set the pipeline (back) to PLAYING.
710 * The application must be prepared to receive BUFFERING messages in the
711 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
712 * message with @percent set to 100, which can happen after the pipeline
713 * completed prerolling.
717 * Returns: (transfer full): The new buffering message.
720 gst_message_new_buffering (GstObject * src, gint percent)
723 GstStructure *structure;
724 gint64 buffering_left;
726 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
728 buffering_left = (percent == 100 ? 0 : -1);
730 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
731 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
732 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
733 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
734 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
735 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
736 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
742 * gst_message_new_state_changed:
743 * @src: (transfer none) (allow-none): The object originating the message.
744 * @oldstate: the previous state
745 * @newstate: the new (current) state
746 * @pending: the pending (target) state
748 * Create a state change message. This message is posted whenever an element
751 * Returns: (transfer full): the new state change message.
756 gst_message_new_state_changed (GstObject * src,
757 GstState oldstate, GstState newstate, GstState pending)
760 GstStructure *structure;
762 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
763 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
764 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
765 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
766 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
772 * gst_message_new_state_dirty:
773 * @src: (transfer none) (allow-none): The object originating the message
775 * Create a state dirty message. This message is posted whenever an element
776 * changed its state asynchronously and is used internally to update the
777 * states of container objects.
779 * Returns: (transfer full): the new state dirty message.
784 gst_message_new_state_dirty (GstObject * src)
788 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
794 * gst_message_new_clock_provide:
795 * @src: (transfer none) (allow-none): The object originating the message.
796 * @clock: (transfer none): the clock it provides
797 * @ready: %TRUE if the sender can provide a clock
799 * Create a clock provide message. This message is posted whenever an
800 * element is ready to provide a clock or lost its ability to provide
801 * a clock (maybe because it paused or became EOS).
803 * This message is mainly used internally to manage the clock
806 * Returns: (transfer full): the new provide clock message.
811 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
815 GstStructure *structure;
817 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
818 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
819 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
820 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
826 * gst_message_new_clock_lost:
827 * @src: (transfer none) (allow-none): The object originating the message.
828 * @clock: (transfer none): the clock that was lost
830 * Create a clock lost message. This message is posted whenever the
831 * clock is not valid anymore.
833 * If this message is posted by the pipeline, the pipeline will
834 * select a new clock again when it goes to PLAYING. It might therefore
835 * be needed to set the pipeline to PAUSED and PLAYING again.
837 * Returns: (transfer full): The new clock lost message.
842 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
845 GstStructure *structure;
847 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
848 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
849 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
855 * gst_message_new_new_clock:
856 * @src: (transfer none) (allow-none): The object originating the message.
857 * @clock: (transfer none): the new selected clock
859 * Create a new clock message. This message is posted whenever the
860 * pipeline selects a new clock for the pipeline.
862 * Returns: (transfer full): The new new clock message.
867 gst_message_new_new_clock (GstObject * src, GstClock * clock)
870 GstStructure *structure;
872 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
873 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
874 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
880 * gst_message_new_structure_change:
881 * @src: (transfer none) (allow-none): The object originating the message.
882 * @type: The change type.
883 * @owner: (transfer none): The owner element of @src.
884 * @busy: Whether the structure change is busy.
886 * Create a new structure change message. This message is posted when the
887 * structure of a pipeline is in the process of being changed, for example
888 * when pads are linked or unlinked.
890 * @src should be the sinkpad that unlinked or linked.
892 * Returns: (transfer full): the new structure change message.
897 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
898 GstElement * owner, gboolean busy)
901 GstStructure *structure;
903 g_return_val_if_fail (GST_IS_PAD (src), NULL);
904 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
905 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
907 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
908 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
909 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
910 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
912 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
919 * gst_message_new_segment_start:
920 * @src: (transfer none) (allow-none): The object originating the message.
921 * @format: The format of the position being played
922 * @position: The position of the segment being played
924 * Create a new segment message. This message is posted by elements that
925 * start playback of a segment as a result of a segment seek. This message
926 * is not received by the application but is used for maintenance reasons in
927 * container elements.
929 * Returns: (transfer full): the new segment start message.
934 gst_message_new_segment_start (GstObject * src, GstFormat format,
938 GstStructure *structure;
940 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
941 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
942 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
943 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
949 * gst_message_new_segment_done:
950 * @src: (transfer none) (allow-none): The object originating the message.
951 * @format: The format of the position being done
952 * @position: The position of the segment being done
954 * Create a new segment done message. This message is posted by elements that
955 * finish playback of a segment as a result of a segment seek. This message
956 * is received by the application after all elements that posted a segment_start
957 * have posted the segment_done.
959 * Returns: (transfer full): the new segment done message.
964 gst_message_new_segment_done (GstObject * src, GstFormat format,
968 GstStructure *structure;
970 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
971 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
972 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
973 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
979 * gst_message_new_application:
980 * @src: (transfer none) (allow-none): The object originating the message.
981 * @structure: (transfer full): the structure for the message. The message
982 * will take ownership of the structure.
984 * Create a new application-typed message. GStreamer will never create these
985 * messages; they are a gift from us to you. Enjoy.
987 * Returns: (transfer full): The new application message.
992 gst_message_new_application (GstObject * src, GstStructure * structure)
994 g_return_val_if_fail (structure != NULL, NULL);
996 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
1000 * gst_message_new_element:
1001 * @src: (transfer none) (allow-none): The object originating the message.
1002 * @structure: (transfer full): The structure for the
1003 * message. The message will take ownership of the structure.
1005 * Create a new element-specific message. This is meant as a generic way of
1006 * allowing one-way communication from an element to an application, for example
1007 * "the firewire cable was unplugged". The format of the message should be
1008 * documented in the element's documentation. The structure field can be %NULL.
1010 * Returns: (transfer full): The new element message.
1015 gst_message_new_element (GstObject * src, GstStructure * structure)
1017 g_return_val_if_fail (structure != NULL, NULL);
1019 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
1023 * gst_message_new_duration_changed:
1024 * @src: (transfer none) (allow-none): The object originating the message.
1026 * Create a new duration changed message. This message is posted by elements
1027 * that know the duration of a stream when the duration changes. This message
1028 * is received by bins and is used to calculate the total duration of a
1031 * Returns: (transfer full): The new duration-changed message.
1036 gst_message_new_duration_changed (GstObject * src)
1038 GstMessage *message;
1040 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
1041 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
1047 * gst_message_new_async_start:
1048 * @src: (transfer none) (allow-none): The object originating the message.
1050 * This message is posted by elements when they start an ASYNC state change.
1052 * Returns: (transfer full): The new async_start message.
1057 gst_message_new_async_start (GstObject * src)
1059 GstMessage *message;
1061 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
1067 * gst_message_new_async_done:
1068 * @src: (transfer none) (allow-none): The object originating the message.
1069 * @running_time: the desired running_time
1071 * The message is posted when elements completed an ASYNC state change.
1072 * @running_time contains the time of the desired running_time when this
1073 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
1074 * means that the element has no clock interaction and thus doesn't care about
1075 * the running_time of the pipeline.
1077 * Returns: (transfer full): The new async_done message.
1082 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
1084 GstMessage *message;
1085 GstStructure *structure;
1087 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
1088 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
1089 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
1095 * gst_message_new_latency:
1096 * @src: (transfer none) (allow-none): The object originating the message.
1098 * This message can be posted by elements when their latency requirements have
1101 * Returns: (transfer full): The new latency message.
1106 gst_message_new_latency (GstObject * src)
1108 GstMessage *message;
1110 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
1116 * gst_message_new_request_state:
1117 * @src: (transfer none) (allow-none): The object originating the message.
1118 * @state: The new requested state
1120 * This message can be posted by elements when they want to have their state
1121 * changed. A typical use case would be an audio server that wants to pause the
1122 * pipeline because a higher priority stream is being played.
1124 * Returns: (transfer full): the new request state message.
1129 gst_message_new_request_state (GstObject * src, GstState state)
1131 GstMessage *message;
1132 GstStructure *structure;
1134 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
1135 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
1136 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
1142 * gst_message_get_structure:
1143 * @message: The #GstMessage.
1145 * Access the structure of the message.
1147 * Returns: (transfer none) (nullable): The structure of the message. The
1148 * structure is still owned by the message, which means that you should not
1149 * free it and that the pointer becomes invalid when you free the message.
1153 const GstStructure *
1154 gst_message_get_structure (GstMessage * message)
1156 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1158 return GST_MESSAGE_STRUCTURE (message);
1162 * gst_message_has_name:
1163 * @message: The #GstMessage.
1164 * @name: name to check
1166 * Checks if @message has the given @name. This function is usually used to
1167 * check the name of a custom message.
1169 * Returns: %TRUE if @name matches the name of the message structure.
1172 gst_message_has_name (GstMessage * message, const gchar * name)
1174 GstStructure *structure;
1176 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
1178 structure = GST_MESSAGE_STRUCTURE (message);
1179 if (structure == NULL)
1182 return gst_structure_has_name (structure, name);
1186 * gst_message_parse_tag:
1187 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1188 * @tag_list: (out callee-allocates): return location for the tag-list.
1190 * Extracts the tag list from the GstMessage. The tag list returned in the
1191 * output argument is a copy; the caller must free it when done.
1193 * Typical usage of this function might be:
1194 * |[<!-- language="C" -->
1196 * switch (GST_MESSAGE_TYPE (msg)) {
1197 * case GST_MESSAGE_TAG: {
1198 * GstTagList *tags = NULL;
1200 * gst_message_parse_tag (msg, &tags);
1201 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1202 * handle_tags (tags);
1203 * gst_tag_list_unref (tags);
1214 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1216 g_return_if_fail (GST_IS_MESSAGE (message));
1217 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1218 g_return_if_fail (tag_list != NULL);
1220 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1221 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1225 * gst_message_parse_buffering:
1226 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1227 * @percent: (out) (allow-none): Return location for the percent.
1229 * Extracts the buffering percent from the GstMessage. see also
1230 * gst_message_new_buffering().
1235 gst_message_parse_buffering (GstMessage * message, gint * percent)
1237 g_return_if_fail (GST_IS_MESSAGE (message));
1238 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1242 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1243 (message), GST_QUARK (BUFFER_PERCENT)));
1247 * gst_message_set_buffering_stats:
1248 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1249 * @mode: a buffering mode
1250 * @avg_in: the average input rate
1251 * @avg_out: the average output rate
1252 * @buffering_left: amount of buffering time left in milliseconds
1254 * Configures the buffering stats values in @message.
1257 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1258 gint avg_in, gint avg_out, gint64 buffering_left)
1260 g_return_if_fail (GST_IS_MESSAGE (message));
1261 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1263 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1264 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1265 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1266 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1267 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1271 * gst_message_parse_buffering_stats:
1272 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1273 * @mode: (out) (allow-none): a buffering mode, or %NULL
1274 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1275 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1276 * @buffering_left: (out) (allow-none): amount of buffering time left in
1277 * milliseconds, or %NULL
1279 * Extracts the buffering stats values from @message.
1282 gst_message_parse_buffering_stats (GstMessage * message,
1283 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1284 gint64 * buffering_left)
1286 GstStructure *structure;
1288 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1290 structure = GST_MESSAGE_STRUCTURE (message);
1292 *mode = (GstBufferingMode)
1293 g_value_get_enum (gst_structure_id_get_value (structure,
1294 GST_QUARK (BUFFERING_MODE)));
1296 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1297 GST_QUARK (AVG_IN_RATE)));
1299 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1300 GST_QUARK (AVG_OUT_RATE)));
1303 g_value_get_int64 (gst_structure_id_get_value (structure,
1304 GST_QUARK (BUFFERING_LEFT)));
1308 * gst_message_parse_state_changed:
1309 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1310 * @oldstate: (out) (allow-none): the previous state, or %NULL
1311 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1312 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1314 * Extracts the old and new states from the GstMessage.
1316 * Typical usage of this function might be:
1317 * |[<!-- language="C" -->
1319 * switch (GST_MESSAGE_TYPE (msg)) {
1320 * case GST_MESSAGE_STATE_CHANGED: {
1321 * GstState old_state, new_state;
1323 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1324 * g_print ("Element %s changed state from %s to %s.\n",
1325 * GST_OBJECT_NAME (msg->src),
1326 * gst_element_state_get_name (old_state),
1327 * gst_element_state_get_name (new_state));
1338 gst_message_parse_state_changed (GstMessage * message,
1339 GstState * oldstate, GstState * newstate, GstState * pending)
1341 GstStructure *structure;
1343 g_return_if_fail (GST_IS_MESSAGE (message));
1344 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1346 structure = GST_MESSAGE_STRUCTURE (message);
1348 *oldstate = (GstState)
1349 g_value_get_enum (gst_structure_id_get_value (structure,
1350 GST_QUARK (OLD_STATE)));
1352 *newstate = (GstState)
1353 g_value_get_enum (gst_structure_id_get_value (structure,
1354 GST_QUARK (NEW_STATE)));
1356 *pending = (GstState)
1357 g_value_get_enum (gst_structure_id_get_value (structure,
1358 GST_QUARK (PENDING_STATE)));
1362 * gst_message_parse_clock_provide:
1363 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1364 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1366 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1368 * Extracts the clock and ready flag from the GstMessage.
1369 * The clock object returned remains valid until the message is freed.
1374 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1377 const GValue *clock_gvalue;
1378 GstStructure *structure;
1380 g_return_if_fail (GST_IS_MESSAGE (message));
1381 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1383 structure = GST_MESSAGE_STRUCTURE (message);
1384 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1385 g_return_if_fail (clock_gvalue != NULL);
1386 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1390 g_value_get_boolean (gst_structure_id_get_value (structure,
1391 GST_QUARK (READY)));
1393 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1397 * gst_message_parse_clock_lost:
1398 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1399 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1401 * Extracts the lost clock from the GstMessage.
1402 * The clock object returned remains valid until the message is freed.
1407 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1409 const GValue *clock_gvalue;
1410 GstStructure *structure;
1412 g_return_if_fail (GST_IS_MESSAGE (message));
1413 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1415 structure = GST_MESSAGE_STRUCTURE (message);
1416 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1417 g_return_if_fail (clock_gvalue != NULL);
1418 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1421 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1425 * gst_message_parse_new_clock:
1426 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1427 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1430 * Extracts the new clock from the GstMessage.
1431 * The clock object returned remains valid until the message is freed.
1436 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1438 const GValue *clock_gvalue;
1439 GstStructure *structure;
1441 g_return_if_fail (GST_IS_MESSAGE (message));
1442 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1444 structure = GST_MESSAGE_STRUCTURE (message);
1445 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1446 g_return_if_fail (clock_gvalue != NULL);
1447 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1450 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1454 * gst_message_parse_structure_change:
1455 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1456 * @type: (out): A pointer to hold the change type
1457 * @owner: (out) (allow-none) (transfer none): The owner element of the
1459 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1460 * progress or has been completed
1462 * Extracts the change type and completion status from the GstMessage.
1467 gst_message_parse_structure_change (GstMessage * message,
1468 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1470 const GValue *owner_gvalue;
1471 GstStructure *structure;
1473 g_return_if_fail (GST_IS_MESSAGE (message));
1474 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1476 structure = GST_MESSAGE_STRUCTURE (message);
1477 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1478 g_return_if_fail (owner_gvalue != NULL);
1479 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1482 *type = (GstStructureChangeType)
1483 g_value_get_enum (gst_structure_id_get_value (structure,
1486 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1489 g_value_get_boolean (gst_structure_id_get_value (structure,
1494 * gst_message_parse_error:
1495 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1496 * @gerror: (out) (allow-none) (transfer full): location for the GError
1497 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1500 * Extracts the GError and debug string from the GstMessage. The values returned
1501 * in the output arguments are copies; the caller must free them when done.
1503 * Typical usage of this function might be:
1504 * |[<!-- language="C" -->
1506 * switch (GST_MESSAGE_TYPE (msg)) {
1507 * case GST_MESSAGE_ERROR: {
1508 * GError *err = NULL;
1509 * gchar *dbg_info = NULL;
1511 * gst_message_parse_error (msg, &err, &dbg_info);
1512 * g_printerr ("ERROR from element %s: %s\n",
1513 * GST_OBJECT_NAME (msg->src), err->message);
1514 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1515 * g_error_free (err);
1516 * g_free (dbg_info);
1527 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1529 g_return_if_fail (GST_IS_MESSAGE (message));
1530 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1532 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1533 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1534 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1538 * gst_message_parse_warning:
1539 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1540 * @gerror: (out) (allow-none) (transfer full): location for the GError
1541 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1544 * Extracts the GError and debug string from the GstMessage. The values returned
1545 * in the output arguments are copies; the caller must free them when done.
1550 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1553 g_return_if_fail (GST_IS_MESSAGE (message));
1554 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1556 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1557 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1558 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1562 * gst_message_parse_info:
1563 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1564 * @gerror: (out) (allow-none) (transfer full): location for the GError
1565 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1568 * Extracts the GError and debug string from the GstMessage. The values returned
1569 * in the output arguments are copies; the caller must free them when done.
1574 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1576 g_return_if_fail (GST_IS_MESSAGE (message));
1577 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1579 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1580 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1581 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1585 * gst_message_parse_segment_start:
1586 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1587 * @format: (out) (allow-none): Result location for the format, or %NULL
1588 * @position: (out) (allow-none): Result location for the position, or %NULL
1590 * Extracts the position and format from the segment start message.
1595 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1598 GstStructure *structure;
1600 g_return_if_fail (GST_IS_MESSAGE (message));
1601 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1603 structure = GST_MESSAGE_STRUCTURE (message);
1605 *format = (GstFormat)
1606 g_value_get_enum (gst_structure_id_get_value (structure,
1607 GST_QUARK (FORMAT)));
1610 g_value_get_int64 (gst_structure_id_get_value (structure,
1611 GST_QUARK (POSITION)));
1615 * gst_message_parse_segment_done:
1616 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1617 * @format: (out) (allow-none): Result location for the format, or %NULL
1618 * @position: (out) (allow-none): Result location for the position, or %NULL
1620 * Extracts the position and format from the segment done message.
1625 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1628 GstStructure *structure;
1630 g_return_if_fail (GST_IS_MESSAGE (message));
1631 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1633 structure = GST_MESSAGE_STRUCTURE (message);
1635 *format = (GstFormat)
1636 g_value_get_enum (gst_structure_id_get_value (structure,
1637 GST_QUARK (FORMAT)));
1640 g_value_get_int64 (gst_structure_id_get_value (structure,
1641 GST_QUARK (POSITION)));
1645 * gst_message_parse_async_done:
1646 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1647 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1649 * Extract the running_time from the async_done message.
1654 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1656 GstStructure *structure;
1658 g_return_if_fail (GST_IS_MESSAGE (message));
1659 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1661 structure = GST_MESSAGE_STRUCTURE (message);
1664 g_value_get_uint64 (gst_structure_id_get_value (structure,
1665 GST_QUARK (RUNNING_TIME)));
1669 * gst_message_parse_request_state:
1670 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1671 * @state: (out) (allow-none): Result location for the requested state or %NULL
1673 * Extract the requested state from the request_state message.
1678 gst_message_parse_request_state (GstMessage * message, GstState * state)
1680 GstStructure *structure;
1682 g_return_if_fail (GST_IS_MESSAGE (message));
1683 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1685 structure = GST_MESSAGE_STRUCTURE (message);
1688 g_value_get_enum (gst_structure_id_get_value (structure,
1689 GST_QUARK (NEW_STATE)));
1693 * gst_message_new_stream_status:
1694 * @src: The object originating the message.
1695 * @type: The stream status type.
1696 * @owner: (transfer none): the owner element of @src.
1698 * Create a new stream status message. This message is posted when a streaming
1699 * thread is created/destroyed or when the state changed.
1701 * Returns: (transfer full): the new stream status message.
1706 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1709 GstMessage *message;
1710 GstStructure *structure;
1712 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1713 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1714 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1715 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1721 * gst_message_parse_stream_status:
1722 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1723 * @type: (out): A pointer to hold the status type
1724 * @owner: (out) (transfer none): The owner element of the message source
1726 * Extracts the stream status type and owner the GstMessage. The returned
1727 * owner remains valid for as long as the reference to @message is valid and
1728 * should thus not be unreffed.
1733 gst_message_parse_stream_status (GstMessage * message,
1734 GstStreamStatusType * type, GstElement ** owner)
1736 const GValue *owner_gvalue;
1737 GstStructure *structure;
1739 g_return_if_fail (GST_IS_MESSAGE (message));
1740 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1742 structure = GST_MESSAGE_STRUCTURE (message);
1743 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1744 g_return_if_fail (owner_gvalue != NULL);
1747 *type = (GstStreamStatusType)
1748 g_value_get_enum (gst_structure_id_get_value (structure,
1751 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1755 * gst_message_set_stream_status_object:
1756 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1757 * @object: the object controlling the streaming
1759 * Configures the object handling the streaming thread. This is usually a
1760 * GstTask object but other objects might be added in the future.
1763 gst_message_set_stream_status_object (GstMessage * message,
1764 const GValue * object)
1766 GstStructure *structure;
1768 g_return_if_fail (GST_IS_MESSAGE (message));
1769 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1771 structure = GST_MESSAGE_STRUCTURE (message);
1772 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1776 * gst_message_get_stream_status_object:
1777 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1779 * Extracts the object managing the streaming thread from @message.
1781 * Returns: a GValue containing the object that manages the streaming thread.
1782 * This object is usually of type GstTask but other types can be added in the
1783 * future. The object remains valid as long as @message is valid.
1786 gst_message_get_stream_status_object (GstMessage * message)
1788 const GValue *result;
1789 GstStructure *structure;
1791 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1792 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1795 structure = GST_MESSAGE_STRUCTURE (message);
1796 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1802 * gst_message_new_step_done:
1803 * @src: The object originating the message.
1804 * @format: the format of @amount
1805 * @amount: the amount of stepped data
1806 * @rate: the rate of the stepped amount
1807 * @flush: is this an flushing step
1808 * @intermediate: is this an intermediate step
1809 * @duration: the duration of the data
1810 * @eos: the step caused EOS
1812 * This message is posted by elements when they complete a part, when @intermediate set
1813 * to %TRUE, or a complete step operation.
1815 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1816 * @amount of media in format @format.
1818 * Returns: (transfer full): the new step_done message.
1823 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1824 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1827 GstMessage *message;
1828 GstStructure *structure;
1830 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1831 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1832 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1833 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1834 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1835 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1836 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1837 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1838 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1844 * gst_message_parse_step_done:
1845 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1846 * @format: (out) (allow-none): result location for the format
1847 * @amount: (out) (allow-none): result location for the amount
1848 * @rate: (out) (allow-none): result location for the rate
1849 * @flush: (out) (allow-none): result location for the flush flag
1850 * @intermediate: (out) (allow-none): result location for the intermediate flag
1851 * @duration: (out) (allow-none): result location for the duration
1852 * @eos: (out) (allow-none): result location for the EOS flag
1854 * Extract the values the step_done message.
1859 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1860 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1861 guint64 * duration, gboolean * eos)
1863 GstStructure *structure;
1865 g_return_if_fail (GST_IS_MESSAGE (message));
1866 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1868 structure = GST_MESSAGE_STRUCTURE (message);
1869 gst_structure_id_get (structure,
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);
1880 * gst_message_new_step_start:
1881 * @src: The object originating the message.
1882 * @active: if the step is active or queued
1883 * @format: the format of @amount
1884 * @amount: the amount of stepped data
1885 * @rate: the rate of the stepped amount
1886 * @flush: is this an flushing step
1887 * @intermediate: is this an intermediate step
1889 * This message is posted by elements when they accept or activate a new step
1890 * event for @amount in @format.
1892 * @active is set to %FALSE when the element accepted the new step event and has
1893 * queued it for execution in the streaming threads.
1895 * @active is set to %TRUE when the element has activated the step operation and
1896 * is now ready to start executing the step in the streaming thread. After this
1897 * message is emitted, the application can queue a new step operation in the
1900 * Returns: (transfer full): The new step_start message.
1905 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1906 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1908 GstMessage *message;
1909 GstStructure *structure;
1911 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1912 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1913 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1914 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1915 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1916 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1917 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1918 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1924 * gst_message_parse_step_start:
1925 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1926 * @active: (out) (allow-none): result location for the active flag
1927 * @format: (out) (allow-none): result location for the format
1928 * @amount: (out) (allow-none): result location for the amount
1929 * @rate: (out) (allow-none): result location for the rate
1930 * @flush: (out) (allow-none): result location for the flush flag
1931 * @intermediate: (out) (allow-none): result location for the intermediate flag
1933 * Extract the values from step_start message.
1938 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1939 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1940 gboolean * intermediate)
1942 GstStructure *structure;
1944 g_return_if_fail (GST_IS_MESSAGE (message));
1945 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1947 structure = GST_MESSAGE_STRUCTURE (message);
1948 gst_structure_id_get (structure,
1949 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1950 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1951 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1952 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1953 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1954 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1958 * gst_message_new_qos:
1959 * @src: The object originating the message.
1960 * @live: if the message was generated by a live element
1961 * @running_time: the running time of the buffer that generated the message
1962 * @stream_time: the stream time of the buffer that generated the message
1963 * @timestamp: the timestamps of the buffer that generated the message
1964 * @duration: the duration of the buffer that generated the message
1966 * A QOS message is posted on the bus whenever an element decides to drop a
1967 * buffer because of QoS reasons or whenever it changes its processing strategy
1968 * because of QoS reasons (quality adjustments such as processing at lower
1971 * This message can be posted by an element that performs synchronisation against the
1972 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1973 * events received from a downstream element (!live).
1975 * @running_time, @stream_time, @timestamp, @duration should be set to the
1976 * respective running-time, stream-time, timestamp and duration of the (dropped)
1977 * buffer that generated the QoS event. Values can be left to
1978 * GST_CLOCK_TIME_NONE when unknown.
1980 * Returns: (transfer full): The new qos message.
1985 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1986 guint64 stream_time, guint64 timestamp, guint64 duration)
1988 GstMessage *message;
1989 GstStructure *structure;
1991 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1992 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1993 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1994 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1995 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1996 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1997 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1998 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1999 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
2000 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
2001 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
2002 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
2003 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
2009 * gst_message_set_qos_values:
2010 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2011 * @jitter: The difference of the running-time against the deadline.
2012 * @proportion: Long term prediction of the ideal rate relative to normal rate
2013 * to get optimal quality.
2014 * @quality: An element dependent integer value that specifies the current
2015 * quality level of the element. The default maximum quality is 1000000.
2017 * Set the QoS values that have been calculated/analysed from the QoS data
2022 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
2023 gdouble proportion, gint quality)
2025 GstStructure *structure;
2027 g_return_if_fail (GST_IS_MESSAGE (message));
2028 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2030 structure = GST_MESSAGE_STRUCTURE (message);
2031 gst_structure_id_set (structure,
2032 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2033 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2034 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2038 * gst_message_set_qos_stats:
2039 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2040 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
2041 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
2042 * will likely use GST_FORMAT_DEFAULT (samples).
2043 * @processed: Total number of units correctly processed since the last state
2044 * change to READY or a flushing operation.
2045 * @dropped: Total number of units dropped since the last state change to READY
2046 * or a flushing operation.
2048 * Set the QoS stats representing the history of the current continuous pipeline
2051 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2052 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2057 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
2058 guint64 processed, guint64 dropped)
2060 GstStructure *structure;
2062 g_return_if_fail (GST_IS_MESSAGE (message));
2063 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2065 structure = GST_MESSAGE_STRUCTURE (message);
2066 gst_structure_id_set (structure,
2067 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2068 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2069 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2073 * gst_message_parse_qos:
2074 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2075 * @live: (out) (allow-none): if the message was generated by a live element
2076 * @running_time: (out) (allow-none): the running time of the buffer that
2077 * generated the message
2078 * @stream_time: (out) (allow-none): the stream time of the buffer that
2079 * generated the message
2080 * @timestamp: (out) (allow-none): the timestamps of the buffer that
2081 * generated the message
2082 * @duration: (out) (allow-none): the duration of the buffer that
2083 * generated the message
2085 * Extract the timestamps and live status from the QoS message.
2087 * The returned values give the running_time, stream_time, timestamp and
2088 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2094 gst_message_parse_qos (GstMessage * message, gboolean * live,
2095 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2098 GstStructure *structure;
2100 g_return_if_fail (GST_IS_MESSAGE (message));
2101 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2103 structure = GST_MESSAGE_STRUCTURE (message);
2104 gst_structure_id_get (structure,
2105 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2106 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2107 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2108 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2109 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2113 * gst_message_parse_qos_values:
2114 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2115 * @jitter: (out) (allow-none): The difference of the running-time against
2117 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2118 * relative to normal rate to get optimal quality.
2119 * @quality: (out) (allow-none): An element dependent integer value that
2120 * specifies the current quality level of the element. The default
2121 * maximum quality is 1000000.
2123 * Extract the QoS values that have been calculated/analysed from the QoS data
2128 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2129 gdouble * proportion, gint * quality)
2131 GstStructure *structure;
2133 g_return_if_fail (GST_IS_MESSAGE (message));
2134 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2136 structure = GST_MESSAGE_STRUCTURE (message);
2137 gst_structure_id_get (structure,
2138 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2139 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2140 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2144 * gst_message_parse_qos_stats:
2145 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2146 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2147 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2148 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2150 * @processed: (out) (allow-none): Total number of units correctly processed
2151 * since the last state change to READY or a flushing operation.
2152 * @dropped: (out) (allow-none): Total number of units dropped since the last
2153 * state change to READY or a flushing operation.
2155 * Extract the QoS stats representing the history of the current continuous
2156 * pipeline playback period.
2158 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2159 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2164 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2165 guint64 * processed, guint64 * dropped)
2167 GstStructure *structure;
2169 g_return_if_fail (GST_IS_MESSAGE (message));
2170 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2172 structure = GST_MESSAGE_STRUCTURE (message);
2173 gst_structure_id_get (structure,
2174 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2175 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2176 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2180 * gst_message_new_progress:
2181 * @src: The object originating the message.
2182 * @type: a #GstProgressType
2183 * @code: a progress code
2184 * @text: free, user visible text describing the progress
2186 * Progress messages are posted by elements when they use an asynchronous task
2187 * to perform actions triggered by a state change.
2189 * @code contains a well defined string describing the action.
2190 * @text should contain a user visible string detailing the current action.
2192 * Returns: (transfer full): The new qos message.
2195 gst_message_new_progress (GstObject * src, GstProgressType type,
2196 const gchar * code, const gchar * text)
2198 GstMessage *message;
2199 GstStructure *structure;
2200 gint percent = 100, timeout = -1;
2202 g_return_val_if_fail (code != NULL, NULL);
2203 g_return_val_if_fail (text != NULL, NULL);
2205 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2208 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2209 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2210 GST_QUARK (CODE), G_TYPE_STRING, code,
2211 GST_QUARK (TEXT), G_TYPE_STRING, text,
2212 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2213 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2214 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2220 * gst_message_parse_progress:
2221 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2222 * @type: (out) (allow-none): location for the type
2223 * @code: (out) (allow-none) (transfer full): location for the code
2224 * @text: (out) (allow-none) (transfer full): location for the text
2226 * Parses the progress @type, @code and @text.
2229 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2230 gchar ** code, gchar ** text)
2232 GstStructure *structure;
2234 g_return_if_fail (GST_IS_MESSAGE (message));
2235 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2237 structure = GST_MESSAGE_STRUCTURE (message);
2238 gst_structure_id_get (structure,
2239 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2240 GST_QUARK (CODE), G_TYPE_STRING, code,
2241 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2245 * gst_message_new_toc:
2246 * @src: the object originating the message.
2247 * @toc: (transfer none): #GstToc structure for the message.
2248 * @updated: whether TOC was updated or not.
2250 * Create a new TOC message. The message is posted by elements
2251 * that discovered or updated a TOC.
2253 * Returns: (transfer full): a new TOC message.
2258 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2260 GstStructure *toc_struct;
2262 g_return_val_if_fail (toc != NULL, NULL);
2264 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2265 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2266 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2268 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2272 * gst_message_parse_toc:
2273 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2274 * @toc: (out) (transfer full): return location for the TOC.
2275 * @updated: (out): return location for the updated flag.
2277 * Extract the TOC from the #GstMessage. The TOC returned in the
2278 * output argument is a copy; the caller must free it with
2279 * gst_toc_unref() when done.
2284 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2286 g_return_if_fail (GST_IS_MESSAGE (message));
2287 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2288 g_return_if_fail (toc != NULL);
2290 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2291 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2292 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2296 * gst_message_new_reset_time:
2297 * @src: (transfer none) (allow-none): The object originating the message.
2298 * @running_time: the requested running-time
2300 * This message is posted when the pipeline running-time should be reset to
2301 * @running_time, like after a flushing seek.
2303 * Returns: (transfer full): The new reset_time message.
2308 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2310 GstMessage *message;
2311 GstStructure *structure;
2313 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2314 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2315 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2321 * gst_message_parse_reset_time:
2322 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2323 * @running_time: (out) (allow-none): Result location for the running_time or
2326 * Extract the running-time from the RESET_TIME message.
2331 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2333 GstStructure *structure;
2335 g_return_if_fail (GST_IS_MESSAGE (message));
2336 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2338 structure = GST_MESSAGE_STRUCTURE (message);
2341 g_value_get_uint64 (gst_structure_id_get_value (structure,
2342 GST_QUARK (RUNNING_TIME)));
2346 * gst_message_new_stream_start:
2347 * @src: (transfer none) (allow-none): The object originating the message.
2349 * Create a new stream_start message. This message is generated and posted in
2350 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2351 * message to the application if all sinks have posted an STREAM_START message.
2353 * Returns: (transfer full): The new stream_start message.
2358 gst_message_new_stream_start (GstObject * src)
2360 GstMessage *message;
2363 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2364 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2371 * gst_message_set_group_id:
2372 * @message: the message
2373 * @group_id: the group id
2375 * Sets the group id on the stream-start message.
2377 * All streams that have the same group id are supposed to be played
2378 * together, i.e. all streams inside a container file should have the
2379 * same group id but different stream ids. The group id should change
2380 * each time the stream is started, resulting in different group ids
2381 * each time a file is played for example.
2388 gst_message_set_group_id (GstMessage * message, guint group_id)
2390 GstStructure *structure;
2392 g_return_if_fail (GST_IS_MESSAGE (message));
2393 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2394 g_return_if_fail (gst_message_is_writable (message));
2396 structure = GST_MESSAGE_STRUCTURE (message);
2397 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2402 * gst_message_parse_group_id:
2403 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2404 * @group_id: (out) (allow-none): Result location for the group id or
2407 * Extract the group from the STREAM_START message.
2409 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2416 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2418 GstStructure *structure;
2421 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2422 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2428 structure = GST_MESSAGE_STRUCTURE (message);
2430 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2434 *group_id = g_value_get_uint (v);
2439 * gst_message_new_need_context:
2440 * @src: (transfer none) (allow-none): The object originating the message.
2441 * @context_type: The context type that is needed
2443 * This message is posted when an element needs a specific #GstContext.
2445 * Returns: (transfer full): The new need-context message.
2452 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2454 GstMessage *message;
2455 GstStructure *structure;
2457 g_return_val_if_fail (context_type != NULL, NULL);
2459 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2460 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2461 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2467 * gst_message_parse_context_type:
2468 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2469 * @context_type: (out) (allow-none): the context type, or %NULL
2471 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2473 * Returns: a #gboolean indicating if the parsing succeeded.
2478 gst_message_parse_context_type (GstMessage * message,
2479 const gchar ** context_type)
2481 GstStructure *structure;
2482 const GValue *value;
2484 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2487 structure = GST_MESSAGE_STRUCTURE (message);
2490 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2491 *context_type = g_value_get_string (value);
2498 * gst_message_new_have_context:
2499 * @src: (transfer none) (allow-none): The object originating the message.
2500 * @context: (transfer full): the context
2502 * This message is posted when an element has a new local #GstContext.
2504 * Returns: (transfer full): The new have-context message.
2511 gst_message_new_have_context (GstObject * src, GstContext * context)
2513 GstMessage *message;
2514 GstStructure *structure;
2516 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2517 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2518 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2519 gst_context_unref (context);
2525 * gst_message_parse_have_context:
2526 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2527 * @context: (out) (transfer full) (allow-none): Result location for the
2530 * Extract the context from the HAVE_CONTEXT message.
2537 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2539 g_return_if_fail (GST_IS_MESSAGE (message));
2540 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2543 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2544 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2548 * gst_message_new_device_added:
2549 * @src: The #GstObject that created the message
2550 * @device: (transfer none): The new #GstDevice
2552 * Creates a new device-added message. The device-added message is produced by
2553 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2554 * of monitored devices.
2556 * Returns: a newly allocated #GstMessage
2561 gst_message_new_device_added (GstObject * src, GstDevice * device)
2563 GstMessage *message;
2564 GstStructure *structure;
2566 g_return_val_if_fail (device != NULL, NULL);
2567 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2569 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2570 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2571 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2577 * gst_message_parse_device_added:
2578 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2579 * @device: (out) (allow-none) (transfer full): A location where to store a
2580 * pointer to the new #GstDevice, or %NULL
2582 * Parses a device-added message. The device-added message is produced by
2583 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2584 * of monitored devices.
2589 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2591 g_return_if_fail (GST_IS_MESSAGE (message));
2592 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2595 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2596 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2600 * gst_message_new_device_removed:
2601 * @src: The #GstObject that created the message
2602 * @device: (transfer none): The removed #GstDevice
2604 * Creates a new device-removed message. The device-removed message is produced
2605 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2606 * disappearance of monitored devices.
2608 * Returns: a newly allocated #GstMessage
2613 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2615 GstMessage *message;
2616 GstStructure *structure;
2618 g_return_val_if_fail (device != NULL, NULL);
2619 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2621 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2622 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2623 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2629 * gst_message_parse_device_removed:
2630 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2631 * @device: (out) (allow-none) (transfer full): A location where to store a
2632 * pointer to the removed #GstDevice, or %NULL
2634 * Parses a device-removed message. The device-removed message is produced by
2635 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2636 * disappearance of monitored devices.
2641 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2643 g_return_if_fail (GST_IS_MESSAGE (message));
2644 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2647 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2648 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2652 * gst_message_new_property_notify:
2653 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2654 * @property_name: name of the property that changed
2655 * @val: (allow-none) (transfer full): new property value, or %NULL
2657 * Returns: a newly allocated #GstMessage
2662 gst_message_new_property_notify (GstObject * src, const gchar * property_name,
2665 GstStructure *structure;
2666 GValue name_val = G_VALUE_INIT;
2668 g_return_val_if_fail (property_name != NULL, NULL);
2670 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
2671 g_value_init (&name_val, G_TYPE_STRING);
2672 /* should already be interned, but let's make sure */
2673 g_value_set_static_string (&name_val, g_intern_string (property_name));
2674 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
2676 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
2678 return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
2682 * gst_message_parse_property_notify:
2683 * @message: a #GstMessage of type %GST_MESSAGE_PROPERTY_NOTIFY
2684 * @object: (out) (allow-none) (transfer none): location where to store a
2685 * pointer to the object whose property got changed, or %NULL
2686 * @property_name: (out) (allow-none): return location for the name of the
2687 * property that got changed, or %NULL
2688 * @property_value: (out) (allow-none): return location for the new value of
2689 * the property that got changed, or %NULL. This will only be set if the
2690 * property notify watch was told to include the value when it was set up
2692 * Parses a property-notify message. These will be posted on the bus only
2693 * when set up with gst_element_add_property_notify_watch() or
2694 * gst_element_add_property_deep_notify_watch().
2699 gst_message_parse_property_notify (GstMessage * message, GstObject ** object,
2700 const gchar ** property_name, const GValue ** property_value)
2702 const GstStructure *s = GST_MESSAGE_STRUCTURE (message);
2704 g_return_if_fail (GST_IS_MESSAGE (message));
2705 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROPERTY_NOTIFY);
2708 *object = GST_MESSAGE_SRC (message);
2710 if (property_name) {
2711 const GValue *name_value;
2713 name_value = gst_structure_id_get_value (s, GST_QUARK (PROPERTY_NAME));
2714 *property_name = g_value_get_string (name_value);
2719 gst_structure_id_get_value (s, GST_QUARK (PROPERTY_VALUE));
2723 * gst_message_new_stream_collection:
2724 * @src: The #GstObject that created the message
2725 * @collection: (transfer none): The #GstStreamCollection
2727 * Creates a new stream-collection message. The message is used to announce new
2728 * #GstStreamCollection
2730 * Returns: a newly allocated #GstMessage
2735 gst_message_new_stream_collection (GstObject * src,
2736 GstStreamCollection * collection)
2738 GstMessage *message;
2739 GstStructure *structure;
2741 g_return_val_if_fail (collection != NULL, NULL);
2742 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2745 gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_COLLECTION),
2746 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2748 gst_message_new_custom (GST_MESSAGE_STREAM_COLLECTION, src, structure);
2754 * gst_message_parse_stream_collection:
2755 * @message: a #GstMessage of type %GST_MESSAGE_STREAM_COLLECTION
2756 * @collection: (out) (allow-none) (transfer full): A location where to store a
2757 * pointer to the #GstStreamCollection, or %NULL
2759 * Parses a stream-collection message.
2764 gst_message_parse_stream_collection (GstMessage * message,
2765 GstStreamCollection ** collection)
2767 g_return_if_fail (GST_IS_MESSAGE (message));
2768 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
2769 GST_MESSAGE_STREAM_COLLECTION);
2772 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2773 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2777 * gst_message_new_streams_selected:
2778 * @src: The #GstObject that created the message
2779 * @collection: (transfer none): The #GstStreamCollection
2781 * Creates a new steams-selected message. The message is used to announce
2782 * that an array of streams has been selected. This is generally in response
2783 * to a #GST_EVENT_SELECT_STREAMS event, or when an element (such as decodebin3)
2784 * makes an initial selection of streams.
2786 * The message also contains the #GstStreamCollection to which the various streams
2789 * Users of gst_message_new_streams_selected() can add the selected streams with
2790 * gst_message_streams_selected_add().
2792 * Returns: a newly allocated #GstMessage
2797 gst_message_new_streams_selected (GstObject * src,
2798 GstStreamCollection * collection)
2800 GstMessage *message;
2801 GstStructure *structure;
2802 GValue val = G_VALUE_INIT;
2804 g_return_val_if_fail (collection != NULL, NULL);
2805 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2808 gst_structure_new_id (GST_QUARK (MESSAGE_STREAMS_SELECTED),
2809 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2810 g_value_init (&val, GST_TYPE_ARRAY);
2811 gst_structure_id_take_value (structure, GST_QUARK (STREAMS), &val);
2813 gst_message_new_custom (GST_MESSAGE_STREAMS_SELECTED, src, structure);
2819 * gst_message_streams_selected_get_size:
2820 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2822 * Returns the number of streams contained in the @message.
2824 * Returns: The number of streams contained within.
2829 gst_message_streams_selected_get_size (GstMessage * msg)
2833 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
2834 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2838 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2839 GST_QUARK (STREAMS));
2840 return gst_value_array_get_size (val);
2844 * gst_message_streams_selected_add:
2845 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2846 * @stream: (transfer none): a #GstStream to add to @message
2848 * Adds the @stream to the @message.
2853 gst_message_streams_selected_add (GstMessage * msg, GstStream * stream)
2856 GValue to_add = G_VALUE_INIT;
2858 g_return_if_fail (GST_IS_MESSAGE (msg));
2859 g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED);
2860 g_return_if_fail (GST_IS_STREAM (stream));
2863 (GValue *) gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2864 GST_QUARK (STREAMS));
2865 g_value_init (&to_add, GST_TYPE_STREAM);
2866 g_value_set_object (&to_add, stream);
2867 gst_value_array_append_and_take_value (val, &to_add);
2871 * gst_message_streams_selected_get_stream:
2872 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2873 * @idx: Index of the stream to retrieve
2875 * Retrieves the #GstStream with index @index from the @message.
2877 * Returns: (transfer full): A #GstStream
2882 gst_message_streams_selected_get_stream (GstMessage * msg, guint idx)
2884 const GValue *streams, *val;
2886 g_return_val_if_fail (GST_IS_MESSAGE (msg), NULL);
2887 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2891 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2892 GST_QUARK (STREAMS));
2893 val = gst_value_array_get_value (streams, idx);
2895 return (GstStream *) g_value_dup_object (val);
2902 * gst_message_parse_streams_selected:
2903 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2904 * @collection: (out) (allow-none) (transfer full): A location where to store a
2905 * pointer to the #GstStreamCollection, or %NULL
2907 * Parses a streams-selected message.
2912 gst_message_parse_streams_selected (GstMessage * message,
2913 GstStreamCollection ** collection)
2915 g_return_if_fail (GST_IS_MESSAGE (message));
2916 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAMS_SELECTED);
2919 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2920 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2924 * gst_message_new_redirect:
2925 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2926 * @location: (transfer none): location string for the new entry
2927 * @tag_list: (transfer full) (allow-none): tag list for the new entry
2928 * @entry_struct: (transfer full) (allow-none): structure for the new entry
2930 * Creates a new redirect message and adds a new entry to it. Redirect messages
2931 * are posted when an element detects that the actual data has to be retrieved
2932 * from a different location. This is useful if such a redirection cannot be
2933 * handled inside a source element, for example when HTTP 302/303 redirects
2934 * return a non-HTTP URL.
2936 * The redirect message can hold multiple entries. The first one is added
2937 * when the redirect message is created, with the given location, tag_list,
2938 * entry_struct arguments. Use gst_message_add_redirect_entry() to add more
2941 * Each entry has a location, a tag list, and a structure. All of these are
2942 * optional. The tag list and structure are useful for additional metadata,
2943 * such as bitrate statistics for the given location.
2945 * By default, message recipients should treat entries in the order they are
2946 * stored. The recipient should therefore try entry #0 first, and if this
2947 * entry is not acceptable or working, try entry #1 etc. Senders must make
2948 * sure that they add entries in this order. However, recipients are free to
2949 * ignore the order and pick an entry that is "best" for them. One example
2950 * would be a recipient that scans the entries for the one with the highest
2953 * The specified location string is copied. However, ownership over the tag
2954 * list and structure are transferred to the message.
2956 * Returns: a newly allocated #GstMessage
2961 gst_message_new_redirect (GstObject * src, const gchar * location,
2962 GstTagList * tag_list, const GstStructure * entry_struct)
2964 GstStructure *structure;
2965 GstMessage *message;
2966 GValue entry_locations_gvalue = G_VALUE_INIT;
2967 GValue entry_taglists_gvalue = G_VALUE_INIT;
2968 GValue entry_structures_gvalue = G_VALUE_INIT;
2970 g_return_val_if_fail (location != NULL, NULL);
2972 g_value_init (&entry_locations_gvalue, GST_TYPE_LIST);
2973 g_value_init (&entry_taglists_gvalue, GST_TYPE_LIST);
2974 g_value_init (&entry_structures_gvalue, GST_TYPE_LIST);
2976 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_REDIRECT));
2977 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_LOCATIONS),
2978 &entry_locations_gvalue);
2979 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_TAGLISTS),
2980 &entry_taglists_gvalue);
2981 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_STRUCTURES),
2982 &entry_structures_gvalue);
2984 message = gst_message_new_custom (GST_MESSAGE_REDIRECT, src, structure);
2985 g_assert (message != NULL);
2987 gst_message_add_redirect_entry (message, location, tag_list, entry_struct);
2993 * gst_message_add_redirect_entry:
2994 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
2995 * @location: (transfer none): location string for the new entry
2996 * @tag_list: (transfer full) (allow-none): tag list for the new entry
2997 * @entry_struct: (transfer full) (allow-none): structure for the new entry
2999 * Creates and appends a new entry.
3001 * The specified location string is copied. However, ownership over the tag
3002 * list and structure are transferred to the message.
3007 gst_message_add_redirect_entry (GstMessage * message, const gchar * location,
3008 GstTagList * tag_list, const GstStructure * entry_struct)
3010 GValue val = G_VALUE_INIT;
3011 GstStructure *structure;
3012 GValue *entry_locations_gvalue;
3013 GValue *entry_taglists_gvalue;
3014 GValue *entry_structures_gvalue;
3016 g_return_if_fail (location != NULL);
3017 g_return_if_fail (GST_IS_MESSAGE (message));
3018 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3020 structure = GST_MESSAGE_STRUCTURE (message);
3022 entry_locations_gvalue =
3023 (GValue *) gst_structure_id_get_value (structure,
3024 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3025 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3026 entry_taglists_gvalue =
3027 (GValue *) gst_structure_id_get_value (structure,
3028 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3029 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3030 entry_structures_gvalue =
3031 (GValue *) gst_structure_id_get_value (structure,
3032 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3033 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3035 g_value_init (&val, G_TYPE_STRING);
3037 g_value_set_string (&val, location);
3038 gst_value_list_append_and_take_value (entry_locations_gvalue, &val);
3040 g_value_init (&val, GST_TYPE_TAG_LIST);
3042 g_value_take_boxed (&val, tag_list);
3043 gst_value_list_append_and_take_value (entry_taglists_gvalue, &val);
3045 g_value_init (&val, GST_TYPE_STRUCTURE);
3047 g_value_take_boxed (&val, entry_struct);
3048 gst_value_list_append_and_take_value (entry_structures_gvalue, &val);
3052 * gst_message_parse_redirect_entry:
3053 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3054 * @entry_index: index of the entry to parse
3055 * @location: (out) (transfer none) (allow-none): return location for
3056 * the pointer to the entry's location string, or %NULL
3057 * @tag_list: (out) (transfer none) (allow-none): return location for
3058 * the pointer to the entry's tag list, or %NULL
3059 * @entry_struct: (out) (transfer none) (allow-none): return location
3060 * for the pointer to the entry's structure, or %NULL
3062 * Parses the location and/or structure from the entry with the given index.
3063 * The index must be between 0 and gst_message_get_num_redirect_entries() - 1.
3064 * Returned pointers are valid for as long as this message exists.
3069 gst_message_parse_redirect_entry (GstMessage * message, gsize entry_index,
3070 const gchar ** location, GstTagList ** tag_list,
3071 const GstStructure ** entry_struct)
3074 GstStructure *structure;
3075 const GValue *entry_locations_gvalue;
3076 const GValue *entry_taglists_gvalue;
3077 const GValue *entry_structures_gvalue;
3079 g_return_if_fail (GST_IS_MESSAGE (message));
3080 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3082 if (G_UNLIKELY (!location && !tag_list && !entry_struct))
3085 structure = GST_MESSAGE_STRUCTURE (message);
3087 entry_locations_gvalue =
3088 gst_structure_id_get_value (structure,
3089 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3090 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3091 entry_taglists_gvalue =
3092 gst_structure_id_get_value (structure,
3093 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3094 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3095 entry_structures_gvalue =
3096 gst_structure_id_get_value (structure,
3097 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3098 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3101 val = gst_value_list_get_value (entry_locations_gvalue, entry_index);
3102 g_return_if_fail (val != NULL);
3103 *location = g_value_get_string (val);
3107 val = gst_value_list_get_value (entry_taglists_gvalue, entry_index);
3108 g_return_if_fail (val != NULL);
3109 *tag_list = (GstTagList *) g_value_get_boxed (val);
3113 val = gst_value_list_get_value (entry_structures_gvalue, entry_index);
3114 g_return_if_fail (val != NULL);
3115 *entry_struct = (const GstStructure *) g_value_get_boxed (val);
3120 * gst_message_get_num_redirect_entries:
3121 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3123 * Returns: the number of entries stored in the message
3128 gst_message_get_num_redirect_entries (GstMessage * message)
3130 GstStructure *structure;
3131 const GValue *entry_locations_gvalue;
3132 const GValue *entry_taglists_gvalue;
3133 const GValue *entry_structures_gvalue;
3136 g_return_val_if_fail (GST_IS_MESSAGE (message), 0);
3137 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT, 0);
3139 structure = GST_MESSAGE_STRUCTURE (message);
3141 entry_locations_gvalue =
3142 gst_structure_id_get_value (structure,
3143 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3144 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue), 0);
3145 entry_taglists_gvalue =
3146 gst_structure_id_get_value (structure,
3147 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3148 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue), 0);
3149 entry_structures_gvalue =
3150 gst_structure_id_get_value (structure,
3151 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3152 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue), 0);
3154 size = gst_value_list_get_size (entry_locations_gvalue);
3156 g_return_val_if_fail ((size ==
3157 gst_value_list_get_size (entry_structures_gvalue))
3158 && (size == gst_value_list_get_size (entry_taglists_gvalue)), 0);