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_writable_structure:
1163 * @message: The #GstMessage.
1165 * Get a writable version of the structure.
1167 * Returns: (transfer none): The structure of the message. The structure
1168 * is still owned by the message, which means that you should not free
1169 * it and that the pointer becomes invalid when you free the message.
1170 * This function checks if @message is writable and will never return
1178 gst_message_writable_structure (GstMessage * message)
1180 GstStructure *structure;
1182 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1183 g_return_val_if_fail (gst_message_is_writable (message), NULL);
1185 structure = GST_MESSAGE_STRUCTURE (message);
1187 if (structure == NULL) {
1189 gst_structure_new_id_empty (gst_message_type_to_quark (GST_MESSAGE_TYPE
1191 gst_structure_set_parent_refcount (structure,
1192 &message->mini_object.refcount);
1193 GST_MESSAGE_STRUCTURE (message) = structure;
1199 * gst_message_has_name:
1200 * @message: The #GstMessage.
1201 * @name: name to check
1203 * Checks if @message has the given @name. This function is usually used to
1204 * check the name of a custom message.
1206 * Returns: %TRUE if @name matches the name of the message structure.
1209 gst_message_has_name (GstMessage * message, const gchar * name)
1211 GstStructure *structure;
1213 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
1215 structure = GST_MESSAGE_STRUCTURE (message);
1216 if (structure == NULL)
1219 return gst_structure_has_name (structure, name);
1223 * gst_message_parse_tag:
1224 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1225 * @tag_list: (out callee-allocates): return location for the tag-list.
1227 * Extracts the tag list from the GstMessage. The tag list returned in the
1228 * output argument is a copy; the caller must free it when done.
1230 * Typical usage of this function might be:
1231 * |[<!-- language="C" -->
1233 * switch (GST_MESSAGE_TYPE (msg)) {
1234 * case GST_MESSAGE_TAG: {
1235 * GstTagList *tags = NULL;
1237 * gst_message_parse_tag (msg, &tags);
1238 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1239 * handle_tags (tags);
1240 * gst_tag_list_unref (tags);
1251 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1253 g_return_if_fail (GST_IS_MESSAGE (message));
1254 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1255 g_return_if_fail (tag_list != NULL);
1257 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1258 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1262 * gst_message_parse_buffering:
1263 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1264 * @percent: (out) (allow-none): Return location for the percent.
1266 * Extracts the buffering percent from the GstMessage. see also
1267 * gst_message_new_buffering().
1272 gst_message_parse_buffering (GstMessage * message, gint * percent)
1274 g_return_if_fail (GST_IS_MESSAGE (message));
1275 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1279 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1280 (message), GST_QUARK (BUFFER_PERCENT)));
1284 * gst_message_set_buffering_stats:
1285 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1286 * @mode: a buffering mode
1287 * @avg_in: the average input rate
1288 * @avg_out: the average output rate
1289 * @buffering_left: amount of buffering time left in milliseconds
1291 * Configures the buffering stats values in @message.
1294 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1295 gint avg_in, gint avg_out, gint64 buffering_left)
1297 g_return_if_fail (GST_IS_MESSAGE (message));
1298 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1300 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1301 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1302 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1303 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1304 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1308 * gst_message_parse_buffering_stats:
1309 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1310 * @mode: (out) (allow-none): a buffering mode, or %NULL
1311 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1312 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1313 * @buffering_left: (out) (allow-none): amount of buffering time left in
1314 * milliseconds, or %NULL
1316 * Extracts the buffering stats values from @message.
1319 gst_message_parse_buffering_stats (GstMessage * message,
1320 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1321 gint64 * buffering_left)
1323 GstStructure *structure;
1325 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1327 structure = GST_MESSAGE_STRUCTURE (message);
1329 *mode = (GstBufferingMode)
1330 g_value_get_enum (gst_structure_id_get_value (structure,
1331 GST_QUARK (BUFFERING_MODE)));
1333 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1334 GST_QUARK (AVG_IN_RATE)));
1336 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1337 GST_QUARK (AVG_OUT_RATE)));
1340 g_value_get_int64 (gst_structure_id_get_value (structure,
1341 GST_QUARK (BUFFERING_LEFT)));
1345 * gst_message_parse_state_changed:
1346 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1347 * @oldstate: (out) (allow-none): the previous state, or %NULL
1348 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1349 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1351 * Extracts the old and new states from the GstMessage.
1353 * Typical usage of this function might be:
1354 * |[<!-- language="C" -->
1356 * switch (GST_MESSAGE_TYPE (msg)) {
1357 * case GST_MESSAGE_STATE_CHANGED: {
1358 * GstState old_state, new_state;
1360 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1361 * g_print ("Element %s changed state from %s to %s.\n",
1362 * GST_OBJECT_NAME (msg->src),
1363 * gst_element_state_get_name (old_state),
1364 * gst_element_state_get_name (new_state));
1375 gst_message_parse_state_changed (GstMessage * message,
1376 GstState * oldstate, GstState * newstate, GstState * pending)
1378 GstStructure *structure;
1380 g_return_if_fail (GST_IS_MESSAGE (message));
1381 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1383 structure = GST_MESSAGE_STRUCTURE (message);
1385 *oldstate = (GstState)
1386 g_value_get_enum (gst_structure_id_get_value (structure,
1387 GST_QUARK (OLD_STATE)));
1389 *newstate = (GstState)
1390 g_value_get_enum (gst_structure_id_get_value (structure,
1391 GST_QUARK (NEW_STATE)));
1393 *pending = (GstState)
1394 g_value_get_enum (gst_structure_id_get_value (structure,
1395 GST_QUARK (PENDING_STATE)));
1399 * gst_message_parse_clock_provide:
1400 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1401 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1403 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1405 * Extracts the clock and ready flag from the GstMessage.
1406 * The clock object returned remains valid until the message is freed.
1411 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1414 const GValue *clock_gvalue;
1415 GstStructure *structure;
1417 g_return_if_fail (GST_IS_MESSAGE (message));
1418 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1420 structure = GST_MESSAGE_STRUCTURE (message);
1421 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1422 g_return_if_fail (clock_gvalue != NULL);
1423 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1427 g_value_get_boolean (gst_structure_id_get_value (structure,
1428 GST_QUARK (READY)));
1430 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1434 * gst_message_parse_clock_lost:
1435 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1436 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1438 * Extracts the lost clock from the GstMessage.
1439 * The clock object returned remains valid until the message is freed.
1444 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1446 const GValue *clock_gvalue;
1447 GstStructure *structure;
1449 g_return_if_fail (GST_IS_MESSAGE (message));
1450 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1452 structure = GST_MESSAGE_STRUCTURE (message);
1453 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1454 g_return_if_fail (clock_gvalue != NULL);
1455 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1458 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1462 * gst_message_parse_new_clock:
1463 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1464 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1467 * Extracts the new clock from the GstMessage.
1468 * The clock object returned remains valid until the message is freed.
1473 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1475 const GValue *clock_gvalue;
1476 GstStructure *structure;
1478 g_return_if_fail (GST_IS_MESSAGE (message));
1479 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1481 structure = GST_MESSAGE_STRUCTURE (message);
1482 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1483 g_return_if_fail (clock_gvalue != NULL);
1484 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1487 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1491 * gst_message_parse_structure_change:
1492 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1493 * @type: (out): A pointer to hold the change type
1494 * @owner: (out) (allow-none) (transfer none): The owner element of the
1496 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1497 * progress or has been completed
1499 * Extracts the change type and completion status from the GstMessage.
1504 gst_message_parse_structure_change (GstMessage * message,
1505 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1507 const GValue *owner_gvalue;
1508 GstStructure *structure;
1510 g_return_if_fail (GST_IS_MESSAGE (message));
1511 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1513 structure = GST_MESSAGE_STRUCTURE (message);
1514 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1515 g_return_if_fail (owner_gvalue != NULL);
1516 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1519 *type = (GstStructureChangeType)
1520 g_value_get_enum (gst_structure_id_get_value (structure,
1523 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1526 g_value_get_boolean (gst_structure_id_get_value (structure,
1531 * gst_message_parse_error:
1532 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1533 * @gerror: (out) (allow-none) (transfer full): location for the GError
1534 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1537 * Extracts the GError and debug string from the GstMessage. The values returned
1538 * in the output arguments are copies; the caller must free them when done.
1540 * Typical usage of this function might be:
1541 * |[<!-- language="C" -->
1543 * switch (GST_MESSAGE_TYPE (msg)) {
1544 * case GST_MESSAGE_ERROR: {
1545 * GError *err = NULL;
1546 * gchar *dbg_info = NULL;
1548 * gst_message_parse_error (msg, &err, &dbg_info);
1549 * g_printerr ("ERROR from element %s: %s\n",
1550 * GST_OBJECT_NAME (msg->src), err->message);
1551 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1552 * g_error_free (err);
1553 * g_free (dbg_info);
1564 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1566 g_return_if_fail (GST_IS_MESSAGE (message));
1567 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1569 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1570 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1571 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1575 * gst_message_parse_warning:
1576 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1577 * @gerror: (out) (allow-none) (transfer full): location for the GError
1578 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1581 * Extracts the GError and debug string from the GstMessage. The values returned
1582 * in the output arguments are copies; the caller must free them when done.
1587 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1590 g_return_if_fail (GST_IS_MESSAGE (message));
1591 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1593 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1594 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1595 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1599 * gst_message_parse_info:
1600 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1601 * @gerror: (out) (allow-none) (transfer full): location for the GError
1602 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1605 * Extracts the GError and debug string from the GstMessage. The values returned
1606 * in the output arguments are copies; the caller must free them when done.
1611 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1613 g_return_if_fail (GST_IS_MESSAGE (message));
1614 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1616 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1617 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1618 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1622 * gst_message_parse_segment_start:
1623 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1624 * @format: (out) (allow-none): Result location for the format, or %NULL
1625 * @position: (out) (allow-none): Result location for the position, or %NULL
1627 * Extracts the position and format from the segment start message.
1632 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1635 GstStructure *structure;
1637 g_return_if_fail (GST_IS_MESSAGE (message));
1638 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1640 structure = GST_MESSAGE_STRUCTURE (message);
1642 *format = (GstFormat)
1643 g_value_get_enum (gst_structure_id_get_value (structure,
1644 GST_QUARK (FORMAT)));
1647 g_value_get_int64 (gst_structure_id_get_value (structure,
1648 GST_QUARK (POSITION)));
1652 * gst_message_parse_segment_done:
1653 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1654 * @format: (out) (allow-none): Result location for the format, or %NULL
1655 * @position: (out) (allow-none): Result location for the position, or %NULL
1657 * Extracts the position and format from the segment done message.
1662 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1665 GstStructure *structure;
1667 g_return_if_fail (GST_IS_MESSAGE (message));
1668 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1670 structure = GST_MESSAGE_STRUCTURE (message);
1672 *format = (GstFormat)
1673 g_value_get_enum (gst_structure_id_get_value (structure,
1674 GST_QUARK (FORMAT)));
1677 g_value_get_int64 (gst_structure_id_get_value (structure,
1678 GST_QUARK (POSITION)));
1682 * gst_message_parse_async_done:
1683 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1684 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1686 * Extract the running_time from the async_done message.
1691 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1693 GstStructure *structure;
1695 g_return_if_fail (GST_IS_MESSAGE (message));
1696 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1698 structure = GST_MESSAGE_STRUCTURE (message);
1701 g_value_get_uint64 (gst_structure_id_get_value (structure,
1702 GST_QUARK (RUNNING_TIME)));
1706 * gst_message_parse_request_state:
1707 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1708 * @state: (out) (allow-none): Result location for the requested state or %NULL
1710 * Extract the requested state from the request_state message.
1715 gst_message_parse_request_state (GstMessage * message, GstState * state)
1717 GstStructure *structure;
1719 g_return_if_fail (GST_IS_MESSAGE (message));
1720 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1722 structure = GST_MESSAGE_STRUCTURE (message);
1725 g_value_get_enum (gst_structure_id_get_value (structure,
1726 GST_QUARK (NEW_STATE)));
1730 * gst_message_new_stream_status:
1731 * @src: The object originating the message.
1732 * @type: The stream status type.
1733 * @owner: (transfer none): the owner element of @src.
1735 * Create a new stream status message. This message is posted when a streaming
1736 * thread is created/destroyed or when the state changed.
1738 * Returns: (transfer full): the new stream status message.
1743 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1746 GstMessage *message;
1747 GstStructure *structure;
1749 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1750 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1751 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1752 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1758 * gst_message_parse_stream_status:
1759 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1760 * @type: (out): A pointer to hold the status type
1761 * @owner: (out) (transfer none): The owner element of the message source
1763 * Extracts the stream status type and owner the GstMessage. The returned
1764 * owner remains valid for as long as the reference to @message is valid and
1765 * should thus not be unreffed.
1770 gst_message_parse_stream_status (GstMessage * message,
1771 GstStreamStatusType * type, GstElement ** owner)
1773 const GValue *owner_gvalue;
1774 GstStructure *structure;
1776 g_return_if_fail (GST_IS_MESSAGE (message));
1777 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1779 structure = GST_MESSAGE_STRUCTURE (message);
1780 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1781 g_return_if_fail (owner_gvalue != NULL);
1784 *type = (GstStreamStatusType)
1785 g_value_get_enum (gst_structure_id_get_value (structure,
1788 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1792 * gst_message_set_stream_status_object:
1793 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1794 * @object: the object controlling the streaming
1796 * Configures the object handling the streaming thread. This is usually a
1797 * GstTask object but other objects might be added in the future.
1800 gst_message_set_stream_status_object (GstMessage * message,
1801 const GValue * object)
1803 GstStructure *structure;
1805 g_return_if_fail (GST_IS_MESSAGE (message));
1806 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1808 structure = GST_MESSAGE_STRUCTURE (message);
1809 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1813 * gst_message_get_stream_status_object:
1814 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1816 * Extracts the object managing the streaming thread from @message.
1818 * Returns: a GValue containing the object that manages the streaming thread.
1819 * This object is usually of type GstTask but other types can be added in the
1820 * future. The object remains valid as long as @message is valid.
1823 gst_message_get_stream_status_object (GstMessage * message)
1825 const GValue *result;
1826 GstStructure *structure;
1828 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1829 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1832 structure = GST_MESSAGE_STRUCTURE (message);
1833 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1839 * gst_message_new_step_done:
1840 * @src: The object originating the message.
1841 * @format: the format of @amount
1842 * @amount: the amount of stepped data
1843 * @rate: the rate of the stepped amount
1844 * @flush: is this an flushing step
1845 * @intermediate: is this an intermediate step
1846 * @duration: the duration of the data
1847 * @eos: the step caused EOS
1849 * This message is posted by elements when they complete a part, when @intermediate set
1850 * to %TRUE, or a complete step operation.
1852 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1853 * @amount of media in format @format.
1855 * Returns: (transfer full): the new step_done message.
1860 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1861 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1864 GstMessage *message;
1865 GstStructure *structure;
1867 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1868 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1869 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1870 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1871 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1872 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1873 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1874 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1875 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1881 * gst_message_parse_step_done:
1882 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1883 * @format: (out) (allow-none): result location for the format
1884 * @amount: (out) (allow-none): result location for the amount
1885 * @rate: (out) (allow-none): result location for the rate
1886 * @flush: (out) (allow-none): result location for the flush flag
1887 * @intermediate: (out) (allow-none): result location for the intermediate flag
1888 * @duration: (out) (allow-none): result location for the duration
1889 * @eos: (out) (allow-none): result location for the EOS flag
1891 * Extract the values the step_done message.
1896 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1897 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1898 guint64 * duration, gboolean * eos)
1900 GstStructure *structure;
1902 g_return_if_fail (GST_IS_MESSAGE (message));
1903 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1905 structure = GST_MESSAGE_STRUCTURE (message);
1906 gst_structure_id_get (structure,
1907 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1908 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1909 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1910 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1911 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1912 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1913 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1917 * gst_message_new_step_start:
1918 * @src: The object originating the message.
1919 * @active: if the step is active or queued
1920 * @format: the format of @amount
1921 * @amount: the amount of stepped data
1922 * @rate: the rate of the stepped amount
1923 * @flush: is this an flushing step
1924 * @intermediate: is this an intermediate step
1926 * This message is posted by elements when they accept or activate a new step
1927 * event for @amount in @format.
1929 * @active is set to %FALSE when the element accepted the new step event and has
1930 * queued it for execution in the streaming threads.
1932 * @active is set to %TRUE when the element has activated the step operation and
1933 * is now ready to start executing the step in the streaming thread. After this
1934 * message is emitted, the application can queue a new step operation in the
1937 * Returns: (transfer full): The new step_start message.
1942 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1943 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1945 GstMessage *message;
1946 GstStructure *structure;
1948 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
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);
1955 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1961 * gst_message_parse_step_start:
1962 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1963 * @active: (out) (allow-none): result location for the active flag
1964 * @format: (out) (allow-none): result location for the format
1965 * @amount: (out) (allow-none): result location for the amount
1966 * @rate: (out) (allow-none): result location for the rate
1967 * @flush: (out) (allow-none): result location for the flush flag
1968 * @intermediate: (out) (allow-none): result location for the intermediate flag
1970 * Extract the values from step_start message.
1975 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1976 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1977 gboolean * intermediate)
1979 GstStructure *structure;
1981 g_return_if_fail (GST_IS_MESSAGE (message));
1982 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1984 structure = GST_MESSAGE_STRUCTURE (message);
1985 gst_structure_id_get (structure,
1986 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1987 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1988 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1989 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1990 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1991 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1995 * gst_message_new_qos:
1996 * @src: The object originating the message.
1997 * @live: if the message was generated by a live element
1998 * @running_time: the running time of the buffer that generated the message
1999 * @stream_time: the stream time of the buffer that generated the message
2000 * @timestamp: the timestamps of the buffer that generated the message
2001 * @duration: the duration of the buffer that generated the message
2003 * A QOS message is posted on the bus whenever an element decides to drop a
2004 * buffer because of QoS reasons or whenever it changes its processing strategy
2005 * because of QoS reasons (quality adjustments such as processing at lower
2008 * This message can be posted by an element that performs synchronisation against the
2009 * clock (live) or it could be dropped by an element that performs QoS because of QOS
2010 * events received from a downstream element (!live).
2012 * @running_time, @stream_time, @timestamp, @duration should be set to the
2013 * respective running-time, stream-time, timestamp and duration of the (dropped)
2014 * buffer that generated the QoS event. Values can be left to
2015 * GST_CLOCK_TIME_NONE when unknown.
2017 * Returns: (transfer full): The new qos message.
2022 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
2023 guint64 stream_time, guint64 timestamp, guint64 duration)
2025 GstMessage *message;
2026 GstStructure *structure;
2028 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
2029 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2030 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2031 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2032 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2033 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
2034 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
2035 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
2036 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
2037 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
2038 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
2039 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
2040 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
2046 * gst_message_set_qos_values:
2047 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2048 * @jitter: The difference of the running-time against the deadline.
2049 * @proportion: Long term prediction of the ideal rate relative to normal rate
2050 * to get optimal quality.
2051 * @quality: An element dependent integer value that specifies the current
2052 * quality level of the element. The default maximum quality is 1000000.
2054 * Set the QoS values that have been calculated/analysed from the QoS data
2059 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
2060 gdouble proportion, gint quality)
2062 GstStructure *structure;
2064 g_return_if_fail (GST_IS_MESSAGE (message));
2065 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2067 structure = GST_MESSAGE_STRUCTURE (message);
2068 gst_structure_id_set (structure,
2069 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2070 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2071 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2075 * gst_message_set_qos_stats:
2076 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2077 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
2078 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
2079 * will likely use GST_FORMAT_DEFAULT (samples).
2080 * @processed: Total number of units correctly processed since the last state
2081 * change to READY or a flushing operation.
2082 * @dropped: Total number of units dropped since the last state change to READY
2083 * or a flushing operation.
2085 * Set the QoS stats representing the history of the current continuous pipeline
2088 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2089 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2094 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
2095 guint64 processed, guint64 dropped)
2097 GstStructure *structure;
2099 g_return_if_fail (GST_IS_MESSAGE (message));
2100 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2102 structure = GST_MESSAGE_STRUCTURE (message);
2103 gst_structure_id_set (structure,
2104 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2105 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2106 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2110 * gst_message_parse_qos:
2111 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2112 * @live: (out) (allow-none): if the message was generated by a live element
2113 * @running_time: (out) (allow-none): the running time of the buffer that
2114 * generated the message
2115 * @stream_time: (out) (allow-none): the stream time of the buffer that
2116 * generated the message
2117 * @timestamp: (out) (allow-none): the timestamps of the buffer that
2118 * generated the message
2119 * @duration: (out) (allow-none): the duration of the buffer that
2120 * generated the message
2122 * Extract the timestamps and live status from the QoS message.
2124 * The returned values give the running_time, stream_time, timestamp and
2125 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2131 gst_message_parse_qos (GstMessage * message, gboolean * live,
2132 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2135 GstStructure *structure;
2137 g_return_if_fail (GST_IS_MESSAGE (message));
2138 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2140 structure = GST_MESSAGE_STRUCTURE (message);
2141 gst_structure_id_get (structure,
2142 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2143 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2144 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2145 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2146 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2150 * gst_message_parse_qos_values:
2151 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2152 * @jitter: (out) (allow-none): The difference of the running-time against
2154 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2155 * relative to normal rate to get optimal quality.
2156 * @quality: (out) (allow-none): An element dependent integer value that
2157 * specifies the current quality level of the element. The default
2158 * maximum quality is 1000000.
2160 * Extract the QoS values that have been calculated/analysed from the QoS data
2165 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2166 gdouble * proportion, gint * quality)
2168 GstStructure *structure;
2170 g_return_if_fail (GST_IS_MESSAGE (message));
2171 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2173 structure = GST_MESSAGE_STRUCTURE (message);
2174 gst_structure_id_get (structure,
2175 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2176 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2177 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2181 * gst_message_parse_qos_stats:
2182 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2183 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2184 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2185 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2187 * @processed: (out) (allow-none): Total number of units correctly processed
2188 * since the last state change to READY or a flushing operation.
2189 * @dropped: (out) (allow-none): Total number of units dropped since the last
2190 * state change to READY or a flushing operation.
2192 * Extract the QoS stats representing the history of the current continuous
2193 * pipeline playback period.
2195 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2196 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2201 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2202 guint64 * processed, guint64 * dropped)
2204 GstStructure *structure;
2206 g_return_if_fail (GST_IS_MESSAGE (message));
2207 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2209 structure = GST_MESSAGE_STRUCTURE (message);
2210 gst_structure_id_get (structure,
2211 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2212 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2213 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2217 * gst_message_new_progress:
2218 * @src: The object originating the message.
2219 * @type: a #GstProgressType
2220 * @code: a progress code
2221 * @text: free, user visible text describing the progress
2223 * Progress messages are posted by elements when they use an asynchronous task
2224 * to perform actions triggered by a state change.
2226 * @code contains a well defined string describing the action.
2227 * @text should contain a user visible string detailing the current action.
2229 * Returns: (transfer full): The new qos message.
2232 gst_message_new_progress (GstObject * src, GstProgressType type,
2233 const gchar * code, const gchar * text)
2235 GstMessage *message;
2236 GstStructure *structure;
2237 gint percent = 100, timeout = -1;
2239 g_return_val_if_fail (code != NULL, NULL);
2240 g_return_val_if_fail (text != NULL, NULL);
2242 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2245 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2246 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2247 GST_QUARK (CODE), G_TYPE_STRING, code,
2248 GST_QUARK (TEXT), G_TYPE_STRING, text,
2249 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2250 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2251 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2257 * gst_message_parse_progress:
2258 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2259 * @type: (out) (allow-none): location for the type
2260 * @code: (out) (allow-none) (transfer full): location for the code
2261 * @text: (out) (allow-none) (transfer full): location for the text
2263 * Parses the progress @type, @code and @text.
2266 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2267 gchar ** code, gchar ** text)
2269 GstStructure *structure;
2271 g_return_if_fail (GST_IS_MESSAGE (message));
2272 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2274 structure = GST_MESSAGE_STRUCTURE (message);
2275 gst_structure_id_get (structure,
2276 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2277 GST_QUARK (CODE), G_TYPE_STRING, code,
2278 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2282 * gst_message_new_toc:
2283 * @src: the object originating the message.
2284 * @toc: (transfer none): #GstToc structure for the message.
2285 * @updated: whether TOC was updated or not.
2287 * Create a new TOC message. The message is posted by elements
2288 * that discovered or updated a TOC.
2290 * Returns: (transfer full): a new TOC message.
2295 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2297 GstStructure *toc_struct;
2299 g_return_val_if_fail (toc != NULL, NULL);
2301 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2302 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2303 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2305 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2309 * gst_message_parse_toc:
2310 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2311 * @toc: (out) (transfer full): return location for the TOC.
2312 * @updated: (out): return location for the updated flag.
2314 * Extract the TOC from the #GstMessage. The TOC returned in the
2315 * output argument is a copy; the caller must free it with
2316 * gst_toc_unref() when done.
2321 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2323 g_return_if_fail (GST_IS_MESSAGE (message));
2324 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2325 g_return_if_fail (toc != NULL);
2327 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2328 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2329 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2333 * gst_message_new_reset_time:
2334 * @src: (transfer none) (allow-none): The object originating the message.
2335 * @running_time: the requested running-time
2337 * This message is posted when the pipeline running-time should be reset to
2338 * @running_time, like after a flushing seek.
2340 * Returns: (transfer full): The new reset_time message.
2345 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2347 GstMessage *message;
2348 GstStructure *structure;
2350 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2351 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2352 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2358 * gst_message_parse_reset_time:
2359 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2360 * @running_time: (out) (allow-none): Result location for the running_time or
2363 * Extract the running-time from the RESET_TIME message.
2368 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2370 GstStructure *structure;
2372 g_return_if_fail (GST_IS_MESSAGE (message));
2373 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2375 structure = GST_MESSAGE_STRUCTURE (message);
2378 g_value_get_uint64 (gst_structure_id_get_value (structure,
2379 GST_QUARK (RUNNING_TIME)));
2383 * gst_message_new_stream_start:
2384 * @src: (transfer none) (allow-none): The object originating the message.
2386 * Create a new stream_start message. This message is generated and posted in
2387 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2388 * message to the application if all sinks have posted an STREAM_START message.
2390 * Returns: (transfer full): The new stream_start message.
2395 gst_message_new_stream_start (GstObject * src)
2397 GstMessage *message;
2400 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2401 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2408 * gst_message_set_group_id:
2409 * @message: the message
2410 * @group_id: the group id
2412 * Sets the group id on the stream-start message.
2414 * All streams that have the same group id are supposed to be played
2415 * together, i.e. all streams inside a container file should have the
2416 * same group id but different stream ids. The group id should change
2417 * each time the stream is started, resulting in different group ids
2418 * each time a file is played for example.
2425 gst_message_set_group_id (GstMessage * message, guint group_id)
2427 GstStructure *structure;
2429 g_return_if_fail (GST_IS_MESSAGE (message));
2430 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2431 g_return_if_fail (gst_message_is_writable (message));
2433 structure = GST_MESSAGE_STRUCTURE (message);
2434 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2439 * gst_message_parse_group_id:
2440 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2441 * @group_id: (out) (allow-none): Result location for the group id or
2444 * Extract the group from the STREAM_START message.
2446 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2453 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2455 GstStructure *structure;
2458 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2459 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2465 structure = GST_MESSAGE_STRUCTURE (message);
2467 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2471 *group_id = g_value_get_uint (v);
2476 * gst_message_new_need_context:
2477 * @src: (transfer none) (allow-none): The object originating the message.
2478 * @context_type: The context type that is needed
2480 * This message is posted when an element needs a specific #GstContext.
2482 * Returns: (transfer full): The new need-context message.
2489 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2491 GstMessage *message;
2492 GstStructure *structure;
2494 g_return_val_if_fail (context_type != NULL, NULL);
2496 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2497 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2498 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2504 * gst_message_parse_context_type:
2505 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2506 * @context_type: (out) (allow-none): the context type, or %NULL
2508 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2510 * Returns: a #gboolean indicating if the parsing succeeded.
2515 gst_message_parse_context_type (GstMessage * message,
2516 const gchar ** context_type)
2518 GstStructure *structure;
2519 const GValue *value;
2521 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2524 structure = GST_MESSAGE_STRUCTURE (message);
2527 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2528 *context_type = g_value_get_string (value);
2535 * gst_message_new_have_context:
2536 * @src: (transfer none) (allow-none): The object originating the message.
2537 * @context: (transfer full): the context
2539 * This message is posted when an element has a new local #GstContext.
2541 * Returns: (transfer full): The new have-context message.
2548 gst_message_new_have_context (GstObject * src, GstContext * context)
2550 GstMessage *message;
2551 GstStructure *structure;
2553 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2554 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2555 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2556 gst_context_unref (context);
2562 * gst_message_parse_have_context:
2563 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2564 * @context: (out) (transfer full) (allow-none): Result location for the
2567 * Extract the context from the HAVE_CONTEXT message.
2574 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2576 g_return_if_fail (GST_IS_MESSAGE (message));
2577 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2580 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2581 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2585 * gst_message_new_device_added:
2586 * @src: The #GstObject that created the message
2587 * @device: (transfer none): The new #GstDevice
2589 * Creates a new device-added message. The device-added message is produced by
2590 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2591 * of monitored devices.
2593 * Returns: a newly allocated #GstMessage
2598 gst_message_new_device_added (GstObject * src, GstDevice * device)
2600 GstMessage *message;
2601 GstStructure *structure;
2603 g_return_val_if_fail (device != NULL, NULL);
2604 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2606 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2607 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2608 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2614 * gst_message_parse_device_added:
2615 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2616 * @device: (out) (allow-none) (transfer full): A location where to store a
2617 * pointer to the new #GstDevice, or %NULL
2619 * Parses a device-added message. The device-added message is produced by
2620 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2621 * of monitored devices.
2626 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2628 g_return_if_fail (GST_IS_MESSAGE (message));
2629 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2632 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2633 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2637 * gst_message_new_device_removed:
2638 * @src: The #GstObject that created the message
2639 * @device: (transfer none): The removed #GstDevice
2641 * Creates a new device-removed message. The device-removed message is produced
2642 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2643 * disappearance of monitored devices.
2645 * Returns: a newly allocated #GstMessage
2650 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2652 GstMessage *message;
2653 GstStructure *structure;
2655 g_return_val_if_fail (device != NULL, NULL);
2656 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2658 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2659 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2660 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2666 * gst_message_parse_device_removed:
2667 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2668 * @device: (out) (allow-none) (transfer full): A location where to store a
2669 * pointer to the removed #GstDevice, or %NULL
2671 * Parses a device-removed message. The device-removed message is produced by
2672 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2673 * disappearance of monitored devices.
2678 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2680 g_return_if_fail (GST_IS_MESSAGE (message));
2681 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2684 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2685 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2689 * gst_message_new_property_notify:
2690 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2691 * @property_name: name of the property that changed
2692 * @val: (allow-none) (transfer full): new property value, or %NULL
2694 * Returns: a newly allocated #GstMessage
2699 gst_message_new_property_notify (GstObject * src, const gchar * property_name,
2702 GstStructure *structure;
2703 GValue name_val = G_VALUE_INIT;
2705 g_return_val_if_fail (property_name != NULL, NULL);
2707 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
2708 g_value_init (&name_val, G_TYPE_STRING);
2709 /* should already be interned, but let's make sure */
2710 g_value_set_static_string (&name_val, g_intern_string (property_name));
2711 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
2713 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
2715 return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
2719 * gst_message_parse_property_notify:
2720 * @message: a #GstMessage of type %GST_MESSAGE_PROPERTY_NOTIFY
2721 * @object: (out) (allow-none) (transfer none): location where to store a
2722 * pointer to the object whose property got changed, or %NULL
2723 * @property_name: (out) (allow-none): return location for the name of the
2724 * property that got changed, or %NULL
2725 * @property_value: (out) (allow-none): return location for the new value of
2726 * the property that got changed, or %NULL. This will only be set if the
2727 * property notify watch was told to include the value when it was set up
2729 * Parses a property-notify message. These will be posted on the bus only
2730 * when set up with gst_element_add_property_notify_watch() or
2731 * gst_element_add_property_deep_notify_watch().
2736 gst_message_parse_property_notify (GstMessage * message, GstObject ** object,
2737 const gchar ** property_name, const GValue ** property_value)
2739 const GstStructure *s = GST_MESSAGE_STRUCTURE (message);
2741 g_return_if_fail (GST_IS_MESSAGE (message));
2742 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROPERTY_NOTIFY);
2745 *object = GST_MESSAGE_SRC (message);
2747 if (property_name) {
2748 const GValue *name_value;
2750 name_value = gst_structure_id_get_value (s, GST_QUARK (PROPERTY_NAME));
2751 *property_name = g_value_get_string (name_value);
2756 gst_structure_id_get_value (s, GST_QUARK (PROPERTY_VALUE));
2760 * gst_message_new_stream_collection:
2761 * @src: The #GstObject that created the message
2762 * @collection: (transfer none): The #GstStreamCollection
2764 * Creates a new stream-collection message. The message is used to announce new
2765 * #GstStreamCollection
2767 * Returns: a newly allocated #GstMessage
2772 gst_message_new_stream_collection (GstObject * src,
2773 GstStreamCollection * collection)
2775 GstMessage *message;
2776 GstStructure *structure;
2778 g_return_val_if_fail (collection != NULL, NULL);
2779 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2782 gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_COLLECTION),
2783 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2785 gst_message_new_custom (GST_MESSAGE_STREAM_COLLECTION, src, structure);
2791 * gst_message_parse_stream_collection:
2792 * @message: a #GstMessage of type %GST_MESSAGE_STREAM_COLLECTION
2793 * @collection: (out) (allow-none) (transfer full): A location where to store a
2794 * pointer to the #GstStreamCollection, or %NULL
2796 * Parses a stream-collection message.
2801 gst_message_parse_stream_collection (GstMessage * message,
2802 GstStreamCollection ** collection)
2804 g_return_if_fail (GST_IS_MESSAGE (message));
2805 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
2806 GST_MESSAGE_STREAM_COLLECTION);
2809 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2810 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2814 * gst_message_new_streams_selected:
2815 * @src: The #GstObject that created the message
2816 * @collection: (transfer none): The #GstStreamCollection
2818 * Creates a new steams-selected message. The message is used to announce
2819 * that an array of streams has been selected. This is generally in response
2820 * to a #GST_EVENT_SELECT_STREAMS event, or when an element (such as decodebin3)
2821 * makes an initial selection of streams.
2823 * The message also contains the #GstStreamCollection to which the various streams
2826 * Users of gst_message_new_streams_selected() can add the selected streams with
2827 * gst_message_streams_selected_add().
2829 * Returns: a newly allocated #GstMessage
2834 gst_message_new_streams_selected (GstObject * src,
2835 GstStreamCollection * collection)
2837 GstMessage *message;
2838 GstStructure *structure;
2839 GValue val = G_VALUE_INIT;
2841 g_return_val_if_fail (collection != NULL, NULL);
2842 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2845 gst_structure_new_id (GST_QUARK (MESSAGE_STREAMS_SELECTED),
2846 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2847 g_value_init (&val, GST_TYPE_ARRAY);
2848 gst_structure_id_take_value (structure, GST_QUARK (STREAMS), &val);
2850 gst_message_new_custom (GST_MESSAGE_STREAMS_SELECTED, src, structure);
2856 * gst_message_streams_selected_get_size:
2857 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2859 * Returns the number of streams contained in the @message.
2861 * Returns: The number of streams contained within.
2866 gst_message_streams_selected_get_size (GstMessage * msg)
2870 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
2871 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2875 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2876 GST_QUARK (STREAMS));
2877 return gst_value_array_get_size (val);
2881 * gst_message_streams_selected_add:
2882 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2883 * @stream: (transfer none): a #GstStream to add to @message
2885 * Adds the @stream to the @message.
2890 gst_message_streams_selected_add (GstMessage * msg, GstStream * stream)
2893 GValue to_add = G_VALUE_INIT;
2895 g_return_if_fail (GST_IS_MESSAGE (msg));
2896 g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED);
2897 g_return_if_fail (GST_IS_STREAM (stream));
2900 (GValue *) gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2901 GST_QUARK (STREAMS));
2902 g_value_init (&to_add, GST_TYPE_STREAM);
2903 g_value_set_object (&to_add, stream);
2904 gst_value_array_append_and_take_value (val, &to_add);
2908 * gst_message_streams_selected_get_stream:
2909 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2910 * @idx: Index of the stream to retrieve
2912 * Retrieves the #GstStream with index @index from the @message.
2914 * Returns: (transfer full): A #GstStream
2919 gst_message_streams_selected_get_stream (GstMessage * msg, guint idx)
2921 const GValue *streams, *val;
2923 g_return_val_if_fail (GST_IS_MESSAGE (msg), NULL);
2924 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2928 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2929 GST_QUARK (STREAMS));
2930 val = gst_value_array_get_value (streams, idx);
2932 return (GstStream *) g_value_dup_object (val);
2939 * gst_message_parse_streams_selected:
2940 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2941 * @collection: (out) (allow-none) (transfer full): A location where to store a
2942 * pointer to the #GstStreamCollection, or %NULL
2944 * Parses a streams-selected message.
2949 gst_message_parse_streams_selected (GstMessage * message,
2950 GstStreamCollection ** collection)
2952 g_return_if_fail (GST_IS_MESSAGE (message));
2953 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAMS_SELECTED);
2956 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2957 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2961 * gst_message_new_redirect:
2962 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2963 * @location: (transfer none): location string for the new entry
2964 * @tag_list: (transfer full) (allow-none): tag list for the new entry
2965 * @entry_struct: (transfer full) (allow-none): structure for the new entry
2967 * Creates a new redirect message and adds a new entry to it. Redirect messages
2968 * are posted when an element detects that the actual data has to be retrieved
2969 * from a different location. This is useful if such a redirection cannot be
2970 * handled inside a source element, for example when HTTP 302/303 redirects
2971 * return a non-HTTP URL.
2973 * The redirect message can hold multiple entries. The first one is added
2974 * when the redirect message is created, with the given location, tag_list,
2975 * entry_struct arguments. Use gst_message_add_redirect_entry() to add more
2978 * Each entry has a location, a tag list, and a structure. All of these are
2979 * optional. The tag list and structure are useful for additional metadata,
2980 * such as bitrate statistics for the given location.
2982 * By default, message recipients should treat entries in the order they are
2983 * stored. The recipient should therefore try entry #0 first, and if this
2984 * entry is not acceptable or working, try entry #1 etc. Senders must make
2985 * sure that they add entries in this order. However, recipients are free to
2986 * ignore the order and pick an entry that is "best" for them. One example
2987 * would be a recipient that scans the entries for the one with the highest
2990 * The specified location string is copied. However, ownership over the tag
2991 * list and structure are transferred to the message.
2993 * Returns: a newly allocated #GstMessage
2998 gst_message_new_redirect (GstObject * src, const gchar * location,
2999 GstTagList * tag_list, const GstStructure * entry_struct)
3001 GstStructure *structure;
3002 GstMessage *message;
3003 GValue entry_locations_gvalue = G_VALUE_INIT;
3004 GValue entry_taglists_gvalue = G_VALUE_INIT;
3005 GValue entry_structures_gvalue = G_VALUE_INIT;
3007 g_return_val_if_fail (location != NULL, NULL);
3009 g_value_init (&entry_locations_gvalue, GST_TYPE_LIST);
3010 g_value_init (&entry_taglists_gvalue, GST_TYPE_LIST);
3011 g_value_init (&entry_structures_gvalue, GST_TYPE_LIST);
3013 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_REDIRECT));
3014 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_LOCATIONS),
3015 &entry_locations_gvalue);
3016 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_TAGLISTS),
3017 &entry_taglists_gvalue);
3018 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_STRUCTURES),
3019 &entry_structures_gvalue);
3021 message = gst_message_new_custom (GST_MESSAGE_REDIRECT, src, structure);
3022 g_assert (message != NULL);
3024 gst_message_add_redirect_entry (message, location, tag_list, entry_struct);
3030 * gst_message_add_redirect_entry:
3031 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3032 * @location: (transfer none): location string for the new entry
3033 * @tag_list: (transfer full) (allow-none): tag list for the new entry
3034 * @entry_struct: (transfer full) (allow-none): structure for the new entry
3036 * Creates and appends a new entry.
3038 * The specified location string is copied. However, ownership over the tag
3039 * list and structure are transferred to the message.
3044 gst_message_add_redirect_entry (GstMessage * message, const gchar * location,
3045 GstTagList * tag_list, const GstStructure * entry_struct)
3047 GValue val = G_VALUE_INIT;
3048 GstStructure *structure;
3049 GValue *entry_locations_gvalue;
3050 GValue *entry_taglists_gvalue;
3051 GValue *entry_structures_gvalue;
3053 g_return_if_fail (location != NULL);
3054 g_return_if_fail (GST_IS_MESSAGE (message));
3055 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3057 structure = GST_MESSAGE_STRUCTURE (message);
3059 entry_locations_gvalue =
3060 (GValue *) gst_structure_id_get_value (structure,
3061 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3062 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3063 entry_taglists_gvalue =
3064 (GValue *) gst_structure_id_get_value (structure,
3065 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3066 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3067 entry_structures_gvalue =
3068 (GValue *) gst_structure_id_get_value (structure,
3069 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3070 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3072 g_value_init (&val, G_TYPE_STRING);
3074 g_value_set_string (&val, location);
3075 gst_value_list_append_and_take_value (entry_locations_gvalue, &val);
3077 g_value_init (&val, GST_TYPE_TAG_LIST);
3079 g_value_take_boxed (&val, tag_list);
3080 gst_value_list_append_and_take_value (entry_taglists_gvalue, &val);
3082 g_value_init (&val, GST_TYPE_STRUCTURE);
3084 g_value_take_boxed (&val, entry_struct);
3085 gst_value_list_append_and_take_value (entry_structures_gvalue, &val);
3089 * gst_message_parse_redirect_entry:
3090 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3091 * @entry_index: index of the entry to parse
3092 * @location: (out) (transfer none) (allow-none): return location for
3093 * the pointer to the entry's location string, or %NULL
3094 * @tag_list: (out) (transfer none) (allow-none): return location for
3095 * the pointer to the entry's tag list, or %NULL
3096 * @entry_struct: (out) (transfer none) (allow-none): return location
3097 * for the pointer to the entry's structure, or %NULL
3099 * Parses the location and/or structure from the entry with the given index.
3100 * The index must be between 0 and gst_message_get_num_redirect_entries() - 1.
3101 * Returned pointers are valid for as long as this message exists.
3106 gst_message_parse_redirect_entry (GstMessage * message, gsize entry_index,
3107 const gchar ** location, GstTagList ** tag_list,
3108 const GstStructure ** entry_struct)
3111 GstStructure *structure;
3112 const GValue *entry_locations_gvalue;
3113 const GValue *entry_taglists_gvalue;
3114 const GValue *entry_structures_gvalue;
3116 g_return_if_fail (GST_IS_MESSAGE (message));
3117 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3119 if (G_UNLIKELY (!location && !tag_list && !entry_struct))
3122 structure = GST_MESSAGE_STRUCTURE (message);
3124 entry_locations_gvalue =
3125 gst_structure_id_get_value (structure,
3126 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3127 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3128 entry_taglists_gvalue =
3129 gst_structure_id_get_value (structure,
3130 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3131 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3132 entry_structures_gvalue =
3133 gst_structure_id_get_value (structure,
3134 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3135 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3138 val = gst_value_list_get_value (entry_locations_gvalue, entry_index);
3139 g_return_if_fail (val != NULL);
3140 *location = g_value_get_string (val);
3144 val = gst_value_list_get_value (entry_taglists_gvalue, entry_index);
3145 g_return_if_fail (val != NULL);
3146 *tag_list = (GstTagList *) g_value_get_boxed (val);
3150 val = gst_value_list_get_value (entry_structures_gvalue, entry_index);
3151 g_return_if_fail (val != NULL);
3152 *entry_struct = (const GstStructure *) g_value_get_boxed (val);
3157 * gst_message_get_num_redirect_entries:
3158 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3160 * Returns: the number of entries stored in the message
3165 gst_message_get_num_redirect_entries (GstMessage * message)
3167 GstStructure *structure;
3168 const GValue *entry_locations_gvalue;
3169 const GValue *entry_taglists_gvalue;
3170 const GValue *entry_structures_gvalue;
3173 g_return_val_if_fail (GST_IS_MESSAGE (message), 0);
3174 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT, 0);
3176 structure = GST_MESSAGE_STRUCTURE (message);
3178 entry_locations_gvalue =
3179 gst_structure_id_get_value (structure,
3180 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3181 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue), 0);
3182 entry_taglists_gvalue =
3183 gst_structure_id_get_value (structure,
3184 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3185 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue), 0);
3186 entry_structures_gvalue =
3187 gst_structure_id_get_value (structure,
3188 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3189 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue), 0);
3191 size = gst_value_list_get_size (entry_locations_gvalue);
3193 g_return_val_if_fail ((size ==
3194 gst_value_list_get_size (entry_structures_gvalue))
3195 && (size == gst_value_list_get_size (entry_taglists_gvalue)), 0);