2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
4 * gstmessage.c: GstMessage subsystem
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
24 * @short_description: Lightweight objects to signal the application of
26 * @see_also: #GstBus, #GstMiniObject, #GstElement
28 * Messages are implemented as a subclass of #GstMiniObject with a generic
29 * #GstStructure as the content. This allows for writing custom messages without
30 * requiring an API change while allowing a wide range of different types
33 * Messages are posted by objects in the pipeline and are passed to the
34 * application using the #GstBus.
36 * The basic use pattern of posting a message on a #GstBus is as follows:
37 * |[<!-- language="C" -->
38 * gst_bus_post (bus, gst_message_new_eos());
41 * A #GstElement usually posts messages on the bus provided by the parent
42 * container using gst_element_post_message().
46 #include "gst_private.h"
47 #include <string.h> /* memcpy */
49 #include "gstenumtypes.h"
51 #include "gstmessage.h"
52 #include "gsttaglist.h"
62 GstStructure *structure;
65 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
74 static GstMessageQuarks message_quarks[] = {
75 {GST_MESSAGE_UNKNOWN, "unknown", 0},
76 {GST_MESSAGE_EOS, "eos", 0},
77 {GST_MESSAGE_ERROR, "error", 0},
78 {GST_MESSAGE_WARNING, "warning", 0},
79 {GST_MESSAGE_INFO, "info", 0},
80 {GST_MESSAGE_TAG, "tag", 0},
81 {GST_MESSAGE_BUFFERING, "buffering", 0},
82 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
83 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
84 {GST_MESSAGE_STEP_DONE, "step-done", 0},
85 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
86 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
87 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
88 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
89 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
90 {GST_MESSAGE_APPLICATION, "application", 0},
91 {GST_MESSAGE_ELEMENT, "element", 0},
92 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
93 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
94 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
95 {GST_MESSAGE_LATENCY, "latency", 0},
96 {GST_MESSAGE_ASYNC_START, "async-start", 0},
97 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
98 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
99 {GST_MESSAGE_STEP_START, "step-start", 0},
100 {GST_MESSAGE_QOS, "qos", 0},
101 {GST_MESSAGE_PROGRESS, "progress", 0},
102 {GST_MESSAGE_TOC, "toc", 0},
103 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
104 {GST_MESSAGE_STREAM_START, "stream-start", 0},
105 {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
106 {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
107 {GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
108 {GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
109 {GST_MESSAGE_PROPERTY_NOTIFY, "property-notify", 0},
110 {GST_MESSAGE_STREAM_COLLECTION, "stream-collection", 0},
111 {GST_MESSAGE_STREAMS_SELECTED, "streams-selected", 0},
112 {GST_MESSAGE_REDIRECT, "redirect", 0},
116 static GQuark details_quark = 0;
118 GType _gst_message_type = 0;
119 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
122 _priv_gst_message_initialize (void)
126 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
128 for (i = 0; message_quarks[i].name; i++) {
129 message_quarks[i].quark =
130 g_quark_from_static_string (message_quarks[i].name);
132 details_quark = g_quark_from_static_string ("details");
134 _gst_message_type = gst_message_get_type ();
138 * gst_message_type_get_name:
139 * @type: the message type
141 * Get a printable name for the given message type. Do not modify or free.
143 * Returns: a reference to the static name of the message.
146 gst_message_type_get_name (GstMessageType type)
150 for (i = 0; message_quarks[i].name; i++) {
151 if (type == message_quarks[i].type)
152 return message_quarks[i].name;
158 * gst_message_type_to_quark:
159 * @type: the message type
161 * Get the unique quark for the given message type.
163 * Returns: the quark associated with the message type
166 gst_message_type_to_quark (GstMessageType type)
170 for (i = 0; message_quarks[i].name; i++) {
171 if (type == message_quarks[i].type)
172 return message_quarks[i].quark;
178 _gst_message_dispose (GstMessage * message)
180 gboolean do_free = TRUE;
182 if (GST_MINI_OBJECT_FLAG_IS_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY)) {
183 /* revive message, so bus can finish with it and clean it up */
184 gst_message_ref (message);
186 GST_INFO ("[msg %p] signalling async free", message);
188 GST_MESSAGE_LOCK (message);
189 GST_MESSAGE_SIGNAL (message);
190 GST_MESSAGE_UNLOCK (message);
192 /* don't free it yet, let bus finish with it first */
200 _gst_message_free (GstMessage * message)
202 GstStructure *structure;
204 g_return_if_fail (message != NULL);
206 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
207 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
209 if (GST_MESSAGE_SRC (message)) {
210 gst_object_unref (GST_MESSAGE_SRC (message));
211 GST_MESSAGE_SRC (message) = NULL;
214 structure = GST_MESSAGE_STRUCTURE (message);
216 gst_structure_set_parent_refcount (structure, NULL);
217 gst_structure_free (structure);
220 g_slice_free1 (sizeof (GstMessageImpl), message);
224 gst_message_init (GstMessageImpl * message, GstMessageType type,
228 _gst_message_copy (GstMessage * message)
230 GstMessageImpl *copy;
231 GstStructure *structure;
233 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
234 GST_MESSAGE_TYPE_NAME (message),
235 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
237 copy = g_slice_new0 (GstMessageImpl);
239 gst_message_init (copy, GST_MESSAGE_TYPE (message),
240 GST_MESSAGE_SRC (message));
242 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
243 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
245 structure = GST_MESSAGE_STRUCTURE (message);
247 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
248 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
249 ©->message.mini_object.refcount);
251 GST_MESSAGE_STRUCTURE (copy) = NULL;
254 return GST_MESSAGE_CAST (copy);
258 gst_message_init (GstMessageImpl * message, GstMessageType type,
261 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
262 (GstMiniObjectCopyFunction) _gst_message_copy,
263 (GstMiniObjectDisposeFunction) _gst_message_dispose,
264 (GstMiniObjectFreeFunction) _gst_message_free);
266 GST_MESSAGE_TYPE (message) = type;
268 gst_object_ref (src);
269 GST_MESSAGE_SRC (message) = src;
270 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
271 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
276 * gst_message_new_custom:
277 * @type: The #GstMessageType to distinguish messages
278 * @src: (transfer none) (allow-none): The object originating the message.
279 * @structure: (transfer full) (allow-none): the structure for the
280 * message. The message will take ownership of the structure.
282 * Create a new custom-typed message. This can be used for anything not
283 * handled by other message-specific functions to pass a message to the
284 * app. The structure field can be %NULL.
286 * Returns: (transfer full): The new message.
291 gst_message_new_custom (GstMessageType type, GstObject * src,
292 GstStructure * structure)
294 GstMessageImpl *message;
296 message = g_slice_new0 (GstMessageImpl);
298 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
299 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
300 gst_message_type_get_name (type));
303 /* structure must not have a parent */
304 if (!gst_structure_set_parent_refcount (structure,
305 &message->message.mini_object.refcount))
308 gst_message_init (message, type, src);
310 GST_MESSAGE_STRUCTURE (message) = structure;
312 return GST_MESSAGE_CAST (message);
317 g_slice_free1 (sizeof (GstMessageImpl), message);
318 g_warning ("structure is already owned by another object");
324 * gst_message_get_seqnum:
325 * @message: A #GstMessage.
327 * Retrieve the sequence number of a message.
329 * Messages have ever-incrementing sequence numbers, which may also be set
330 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
331 * to indicate that a message corresponds to some other set of messages or
332 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
333 * is considered good practice to make this correspondence when possible, though
334 * it is not required.
336 * Note that events and messages share the same sequence number incrementor;
337 * two events or messages will never have the same sequence number unless
338 * that correspondence was made explicitly.
340 * Returns: The message's sequence number.
345 gst_message_get_seqnum (GstMessage * message)
347 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
349 return GST_MESSAGE_SEQNUM (message);
353 * gst_message_set_seqnum:
354 * @message: A #GstMessage.
355 * @seqnum: A sequence number.
357 * Set the sequence number of a message.
359 * This function might be called by the creator of a message to indicate that
360 * the message relates to other messages or events. See gst_message_get_seqnum()
361 * for more information.
366 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
368 g_return_if_fail (GST_IS_MESSAGE (message));
370 GST_MESSAGE_SEQNUM (message) = seqnum;
374 * gst_message_new_eos:
375 * @src: (transfer none) (allow-none): The object originating the message.
377 * Create a new eos message. This message is generated and posted in
378 * the sink elements of a GstBin. The bin will only forward the EOS
379 * message to the application if all sinks have posted an EOS message.
381 * Returns: (transfer full): The new eos message.
386 gst_message_new_eos (GstObject * src)
390 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
396 * gst_message_new_error_with_details:
397 * @src: (transfer none) (allow-none): The object originating the message.
398 * @error: (transfer none): The GError for this message.
399 * @debug: A debugging string.
400 * @details: (transfer full): (allow-none): A GstStructure with details
402 * Create a new error message. The message will copy @error and
403 * @debug. This message is posted by element when a fatal event
404 * occurred. The pipeline will probably (partially) stop. The application
405 * receiving this message should stop the pipeline.
407 * Returns: (transfer full): the new error message.
412 gst_message_new_error_with_details (GstObject * src, GError * error,
413 const gchar * debug, GstStructure * details)
416 GstStructure *structure;
418 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
419 GST_QUARK (GERROR), G_TYPE_ERROR, error,
420 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
421 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
423 GValue v = G_VALUE_INIT;
425 g_value_init (&v, GST_TYPE_STRUCTURE);
426 g_value_take_boxed (&v, details);
427 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
435 * gst_message_new_error:
436 * @src: (transfer none) (allow-none): The object originating the message.
437 * @error: (transfer none): The GError for this message.
438 * @debug: A debugging string.
440 * Create a new error message. The message will copy @error and
441 * @debug. This message is posted by element when a fatal event
442 * occurred. The pipeline will probably (partially) stop. The application
443 * receiving this message should stop the pipeline.
445 * Returns: (transfer full): the new error message.
450 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
452 return gst_message_new_error_with_details (src, error, debug, NULL);
456 * gst_message_parse_error_details:
457 * @message: The message object
458 * @structure: (out): A pointer to the returned details
460 * Returns the optional details structure, may be NULL if none.
461 * The returned structure must not be freed.
466 gst_message_parse_error_details (GstMessage * message,
467 const GstStructure ** structure)
471 g_return_if_fail (GST_IS_MESSAGE (message));
472 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
473 g_return_if_fail (structure != NULL);
476 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
479 *structure = g_value_get_boxed (v);
484 * gst_message_new_warning_with_details:
485 * @src: (transfer none) (allow-none): The object originating the message.
486 * @error: (transfer none): The GError for this message.
487 * @debug: A debugging string.
488 * @details: (transfer full): (allow-none): A GstStructure with details
490 * Create a new warning message. The message will make copies of @error and
493 * Returns: (transfer full): the new warning message.
498 gst_message_new_warning_with_details (GstObject * src, GError * error,
499 const gchar * debug, GstStructure * details)
502 GstStructure *structure;
504 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
505 GST_QUARK (GERROR), G_TYPE_ERROR, error,
506 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
507 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
509 GValue v = G_VALUE_INIT;
511 g_value_init (&v, GST_TYPE_STRUCTURE);
512 g_value_take_boxed (&v, details);
513 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
521 * gst_message_new_warning:
522 * @src: (transfer none) (allow-none): The object originating the message.
523 * @error: (transfer none): The GError for this message.
524 * @debug: A debugging string.
526 * Create a new warning message. The message will make copies of @error and
529 * Returns: (transfer full): the new warning message.
534 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
536 return gst_message_new_warning_with_details (src, error, debug, NULL);
540 * gst_message_parse_warning_details:
541 * @message: The message object
542 * @structure: (out): A pointer to the returned details structure
544 * Returns the optional details structure, may be NULL if none
545 * The returned structure must not be freed.
550 gst_message_parse_warning_details (GstMessage * message,
551 const GstStructure ** structure)
555 g_return_if_fail (GST_IS_MESSAGE (message));
556 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
557 g_return_if_fail (structure != NULL);
560 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
563 *structure = g_value_get_boxed (v);
568 * gst_message_new_info_with_details:
569 * @src: (transfer none) (allow-none): The object originating the message.
570 * @error: (transfer none): The GError for this message.
571 * @debug: A debugging string.
572 * @details: (transfer full): (allow-none): A GstStructure with details
574 * Create a new info message. The message will make copies of @error and
577 * Returns: (transfer full): the new warning message.
582 gst_message_new_info_with_details (GstObject * src, GError * error,
583 const gchar * debug, GstStructure * details)
586 GstStructure *structure;
588 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
589 GST_QUARK (GERROR), G_TYPE_ERROR, error,
590 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
591 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
593 GValue v = G_VALUE_INIT;
595 g_value_init (&v, GST_TYPE_STRUCTURE);
596 g_value_take_boxed (&v, details);
597 gst_structure_id_take_value (GST_MESSAGE_STRUCTURE (message), details_quark,
605 * gst_message_new_info:
606 * @src: (transfer none) (allow-none): The object originating the message.
607 * @error: (transfer none): The GError for this message.
608 * @debug: A debugging string.
610 * Create a new info message. The message will make copies of @error and
613 * Returns: (transfer full): the new info message.
618 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
620 return gst_message_new_info_with_details (src, error, debug, NULL);
624 * gst_message_parse_info_details:
625 * @message: The message object
626 * @structure: (out): A pointer to the returned details structure
628 * Returns the optional details structure, may be NULL if none
629 * The returned structure must not be freed.
634 gst_message_parse_info_details (GstMessage * message,
635 const GstStructure ** structure)
639 g_return_if_fail (GST_IS_MESSAGE (message));
640 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
641 g_return_if_fail (structure != NULL);
644 v = gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (message),
647 *structure = g_value_get_boxed (v);
652 * gst_message_new_tag:
653 * @src: (transfer none) (allow-none): The object originating the message.
654 * @tag_list: (transfer full): the tag list for the message.
656 * Create a new tag message. The message will take ownership of the tag list.
657 * The message is posted by elements that discovered a new taglist.
659 * Returns: (transfer full): the new tag message.
664 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
668 GValue val = G_VALUE_INIT;
670 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
672 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
673 g_value_init (&val, GST_TYPE_TAG_LIST);
674 g_value_take_boxed (&val, tag_list);
675 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
676 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
681 * gst_message_new_buffering:
682 * @src: (transfer none) (allow-none): The object originating the message.
683 * @percent: The buffering percent
685 * Create a new buffering message. This message can be posted by an element that
686 * needs to buffer data before it can continue processing. @percent should be a
687 * value between 0 and 100. A value of 100 means that the buffering completed.
689 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
690 * @percent is 100, the application can set the pipeline (back) to PLAYING.
691 * The application must be prepared to receive BUFFERING messages in the
692 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
693 * message with @percent set to 100, which can happen after the pipeline
694 * completed prerolling.
698 * Returns: (transfer full): The new buffering message.
701 gst_message_new_buffering (GstObject * src, gint percent)
704 GstStructure *structure;
705 gint64 buffering_left;
707 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
709 buffering_left = (percent == 100 ? 0 : -1);
711 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
712 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
713 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
714 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
715 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
716 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
717 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
723 * gst_message_new_state_changed:
724 * @src: (transfer none) (allow-none): The object originating the message.
725 * @oldstate: the previous state
726 * @newstate: the new (current) state
727 * @pending: the pending (target) state
729 * Create a state change message. This message is posted whenever an element
732 * Returns: (transfer full): the new state change message.
737 gst_message_new_state_changed (GstObject * src,
738 GstState oldstate, GstState newstate, GstState pending)
741 GstStructure *structure;
743 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
744 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
745 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
746 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
747 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
753 * gst_message_new_state_dirty:
754 * @src: (transfer none) (allow-none): The object originating the message
756 * Create a state dirty message. This message is posted whenever an element
757 * changed its state asynchronously and is used internally to update the
758 * states of container objects.
760 * Returns: (transfer full): the new state dirty message.
765 gst_message_new_state_dirty (GstObject * src)
769 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
775 * gst_message_new_clock_provide:
776 * @src: (transfer none) (allow-none): The object originating the message.
777 * @clock: (transfer none): the clock it provides
778 * @ready: %TRUE if the sender can provide a clock
780 * Create a clock provide message. This message is posted whenever an
781 * element is ready to provide a clock or lost its ability to provide
782 * a clock (maybe because it paused or became EOS).
784 * This message is mainly used internally to manage the clock
787 * Returns: (transfer full): the new provide clock message.
792 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
796 GstStructure *structure;
798 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
799 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
800 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
801 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
807 * gst_message_new_clock_lost:
808 * @src: (transfer none) (allow-none): The object originating the message.
809 * @clock: (transfer none): the clock that was lost
811 * Create a clock lost message. This message is posted whenever the
812 * clock is not valid anymore.
814 * If this message is posted by the pipeline, the pipeline will
815 * select a new clock again when it goes to PLAYING. It might therefore
816 * be needed to set the pipeline to PAUSED and PLAYING again.
818 * Returns: (transfer full): The new clock lost message.
823 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
826 GstStructure *structure;
828 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
829 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
830 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
836 * gst_message_new_new_clock:
837 * @src: (transfer none) (allow-none): The object originating the message.
838 * @clock: (transfer none): the new selected clock
840 * Create a new clock message. This message is posted whenever the
841 * pipeline selects a new clock for the pipeline.
843 * Returns: (transfer full): The new new clock message.
848 gst_message_new_new_clock (GstObject * src, GstClock * clock)
851 GstStructure *structure;
853 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
854 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
855 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
861 * gst_message_new_structure_change:
862 * @src: (transfer none) (allow-none): The object originating the message.
863 * @type: The change type.
864 * @owner: (transfer none): The owner element of @src.
865 * @busy: Whether the structure change is busy.
867 * Create a new structure change message. This message is posted when the
868 * structure of a pipeline is in the process of being changed, for example
869 * when pads are linked or unlinked.
871 * @src should be the sinkpad that unlinked or linked.
873 * Returns: (transfer full): the new structure change message.
878 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
879 GstElement * owner, gboolean busy)
882 GstStructure *structure;
884 g_return_val_if_fail (GST_IS_PAD (src), NULL);
885 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
886 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
888 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
889 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
890 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
891 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
893 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
900 * gst_message_new_segment_start:
901 * @src: (transfer none) (allow-none): The object originating the message.
902 * @format: The format of the position being played
903 * @position: The position of the segment being played
905 * Create a new segment message. This message is posted by elements that
906 * start playback of a segment as a result of a segment seek. This message
907 * is not received by the application but is used for maintenance reasons in
908 * container elements.
910 * Returns: (transfer full): the new segment start message.
915 gst_message_new_segment_start (GstObject * src, GstFormat format,
919 GstStructure *structure;
921 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
922 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
923 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
924 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
930 * gst_message_new_segment_done:
931 * @src: (transfer none) (allow-none): The object originating the message.
932 * @format: The format of the position being done
933 * @position: The position of the segment being done
935 * Create a new segment done message. This message is posted by elements that
936 * finish playback of a segment as a result of a segment seek. This message
937 * is received by the application after all elements that posted a segment_start
938 * have posted the segment_done.
940 * Returns: (transfer full): the new segment done message.
945 gst_message_new_segment_done (GstObject * src, GstFormat format,
949 GstStructure *structure;
951 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
952 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
953 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
954 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
960 * gst_message_new_application:
961 * @src: (transfer none) (allow-none): The object originating the message.
962 * @structure: (transfer full): the structure for the message. The message
963 * will take ownership of the structure.
965 * Create a new application-typed message. GStreamer will never create these
966 * messages; they are a gift from us to you. Enjoy.
968 * Returns: (transfer full): The new application message.
973 gst_message_new_application (GstObject * src, GstStructure * structure)
975 g_return_val_if_fail (structure != NULL, NULL);
977 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
981 * gst_message_new_element:
982 * @src: (transfer none) (allow-none): The object originating the message.
983 * @structure: (transfer full): The structure for the
984 * message. The message will take ownership of the structure.
986 * Create a new element-specific message. This is meant as a generic way of
987 * allowing one-way communication from an element to an application, for example
988 * "the firewire cable was unplugged". The format of the message should be
989 * documented in the element's documentation. The structure field can be %NULL.
991 * Returns: (transfer full): The new element message.
996 gst_message_new_element (GstObject * src, GstStructure * structure)
998 g_return_val_if_fail (structure != NULL, NULL);
1000 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
1004 * gst_message_new_duration_changed:
1005 * @src: (transfer none) (allow-none): The object originating the message.
1007 * Create a new duration changed message. This message is posted by elements
1008 * that know the duration of a stream when the duration changes. This message
1009 * is received by bins and is used to calculate the total duration of a
1012 * Returns: (transfer full): The new duration-changed message.
1017 gst_message_new_duration_changed (GstObject * src)
1019 GstMessage *message;
1021 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
1022 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
1028 * gst_message_new_async_start:
1029 * @src: (transfer none) (allow-none): The object originating the message.
1031 * This message is posted by elements when they start an ASYNC state change.
1033 * Returns: (transfer full): The new async_start message.
1038 gst_message_new_async_start (GstObject * src)
1040 GstMessage *message;
1042 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
1048 * gst_message_new_async_done:
1049 * @src: (transfer none) (allow-none): The object originating the message.
1050 * @running_time: the desired running_time
1052 * The message is posted when elements completed an ASYNC state change.
1053 * @running_time contains the time of the desired running_time when this
1054 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
1055 * means that the element has no clock interaction and thus doesn't care about
1056 * the running_time of the pipeline.
1058 * Returns: (transfer full): The new async_done message.
1063 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
1065 GstMessage *message;
1066 GstStructure *structure;
1068 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
1069 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
1070 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
1076 * gst_message_new_latency:
1077 * @src: (transfer none) (allow-none): The object originating the message.
1079 * This message can be posted by elements when their latency requirements have
1082 * Returns: (transfer full): The new latency message.
1087 gst_message_new_latency (GstObject * src)
1089 GstMessage *message;
1091 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
1097 * gst_message_new_request_state:
1098 * @src: (transfer none) (allow-none): The object originating the message.
1099 * @state: The new requested state
1101 * This message can be posted by elements when they want to have their state
1102 * changed. A typical use case would be an audio server that wants to pause the
1103 * pipeline because a higher priority stream is being played.
1105 * Returns: (transfer full): the new request state message.
1110 gst_message_new_request_state (GstObject * src, GstState state)
1112 GstMessage *message;
1113 GstStructure *structure;
1115 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
1116 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
1117 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
1123 * gst_message_get_structure:
1124 * @message: The #GstMessage.
1126 * Access the structure of the message.
1128 * Returns: (transfer none): The structure of the message. The structure is
1129 * still owned by the message, which means that you should not free it and
1130 * that the pointer becomes invalid when you free the message.
1134 const GstStructure *
1135 gst_message_get_structure (GstMessage * message)
1137 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1139 return GST_MESSAGE_STRUCTURE (message);
1143 * gst_message_has_name:
1144 * @message: The #GstMessage.
1145 * @name: name to check
1147 * Checks if @message has the given @name. This function is usually used to
1148 * check the name of a custom message.
1150 * Returns: %TRUE if @name matches the name of the message structure.
1153 gst_message_has_name (GstMessage * message, const gchar * name)
1155 GstStructure *structure;
1157 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
1159 structure = GST_MESSAGE_STRUCTURE (message);
1160 if (structure == NULL)
1163 return gst_structure_has_name (structure, name);
1167 * gst_message_parse_tag:
1168 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
1169 * @tag_list: (out callee-allocates): return location for the tag-list.
1171 * Extracts the tag list from the GstMessage. The tag list returned in the
1172 * output argument is a copy; the caller must free it when done.
1174 * Typical usage of this function might be:
1175 * |[<!-- language="C" -->
1177 * switch (GST_MESSAGE_TYPE (msg)) {
1178 * case GST_MESSAGE_TAG: {
1179 * GstTagList *tags = NULL;
1181 * gst_message_parse_tag (msg, &tags);
1182 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1183 * handle_tags (tags);
1184 * gst_tag_list_unref (tags);
1195 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1197 g_return_if_fail (GST_IS_MESSAGE (message));
1198 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1199 g_return_if_fail (tag_list != NULL);
1201 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1202 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1206 * gst_message_parse_buffering:
1207 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1208 * @percent: (out) (allow-none): Return location for the percent.
1210 * Extracts the buffering percent from the GstMessage. see also
1211 * gst_message_new_buffering().
1216 gst_message_parse_buffering (GstMessage * message, gint * percent)
1218 g_return_if_fail (GST_IS_MESSAGE (message));
1219 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1223 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1224 (message), GST_QUARK (BUFFER_PERCENT)));
1228 * gst_message_set_buffering_stats:
1229 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1230 * @mode: a buffering mode
1231 * @avg_in: the average input rate
1232 * @avg_out: the average output rate
1233 * @buffering_left: amount of buffering time left in milliseconds
1235 * Configures the buffering stats values in @message.
1238 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1239 gint avg_in, gint avg_out, gint64 buffering_left)
1241 g_return_if_fail (GST_IS_MESSAGE (message));
1242 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1244 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1245 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1246 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1247 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1248 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1252 * gst_message_parse_buffering_stats:
1253 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1254 * @mode: (out) (allow-none): a buffering mode, or %NULL
1255 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1256 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1257 * @buffering_left: (out) (allow-none): amount of buffering time left in
1258 * milliseconds, or %NULL
1260 * Extracts the buffering stats values from @message.
1263 gst_message_parse_buffering_stats (GstMessage * message,
1264 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1265 gint64 * buffering_left)
1267 GstStructure *structure;
1269 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1271 structure = GST_MESSAGE_STRUCTURE (message);
1273 *mode = (GstBufferingMode)
1274 g_value_get_enum (gst_structure_id_get_value (structure,
1275 GST_QUARK (BUFFERING_MODE)));
1277 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1278 GST_QUARK (AVG_IN_RATE)));
1280 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1281 GST_QUARK (AVG_OUT_RATE)));
1284 g_value_get_int64 (gst_structure_id_get_value (structure,
1285 GST_QUARK (BUFFERING_LEFT)));
1289 * gst_message_parse_state_changed:
1290 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1291 * @oldstate: (out) (allow-none): the previous state, or %NULL
1292 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1293 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1295 * Extracts the old and new states from the GstMessage.
1297 * Typical usage of this function might be:
1298 * |[<!-- language="C" -->
1300 * switch (GST_MESSAGE_TYPE (msg)) {
1301 * case GST_MESSAGE_STATE_CHANGED: {
1302 * GstState old_state, new_state;
1304 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1305 * g_print ("Element %s changed state from %s to %s.\n",
1306 * GST_OBJECT_NAME (msg->src),
1307 * gst_element_state_get_name (old_state),
1308 * gst_element_state_get_name (new_state));
1319 gst_message_parse_state_changed (GstMessage * message,
1320 GstState * oldstate, GstState * newstate, GstState * pending)
1322 GstStructure *structure;
1324 g_return_if_fail (GST_IS_MESSAGE (message));
1325 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1327 structure = GST_MESSAGE_STRUCTURE (message);
1329 *oldstate = (GstState)
1330 g_value_get_enum (gst_structure_id_get_value (structure,
1331 GST_QUARK (OLD_STATE)));
1333 *newstate = (GstState)
1334 g_value_get_enum (gst_structure_id_get_value (structure,
1335 GST_QUARK (NEW_STATE)));
1337 *pending = (GstState)
1338 g_value_get_enum (gst_structure_id_get_value (structure,
1339 GST_QUARK (PENDING_STATE)));
1343 * gst_message_parse_clock_provide:
1344 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1345 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1347 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1349 * Extracts the clock and ready flag from the GstMessage.
1350 * The clock object returned remains valid until the message is freed.
1355 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1358 const GValue *clock_gvalue;
1359 GstStructure *structure;
1361 g_return_if_fail (GST_IS_MESSAGE (message));
1362 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1364 structure = GST_MESSAGE_STRUCTURE (message);
1365 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1366 g_return_if_fail (clock_gvalue != NULL);
1367 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1371 g_value_get_boolean (gst_structure_id_get_value (structure,
1372 GST_QUARK (READY)));
1374 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1378 * gst_message_parse_clock_lost:
1379 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1380 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1382 * Extracts the lost clock from the GstMessage.
1383 * The clock object returned remains valid until the message is freed.
1388 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1390 const GValue *clock_gvalue;
1391 GstStructure *structure;
1393 g_return_if_fail (GST_IS_MESSAGE (message));
1394 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1396 structure = GST_MESSAGE_STRUCTURE (message);
1397 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1398 g_return_if_fail (clock_gvalue != NULL);
1399 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1402 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1406 * gst_message_parse_new_clock:
1407 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1408 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1411 * Extracts the new clock from the GstMessage.
1412 * The clock object returned remains valid until the message is freed.
1417 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1419 const GValue *clock_gvalue;
1420 GstStructure *structure;
1422 g_return_if_fail (GST_IS_MESSAGE (message));
1423 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1425 structure = GST_MESSAGE_STRUCTURE (message);
1426 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1427 g_return_if_fail (clock_gvalue != NULL);
1428 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1431 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1435 * gst_message_parse_structure_change:
1436 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1437 * @type: (out): A pointer to hold the change type
1438 * @owner: (out) (allow-none) (transfer none): The owner element of the
1440 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1441 * progress or has been completed
1443 * Extracts the change type and completion status from the GstMessage.
1448 gst_message_parse_structure_change (GstMessage * message,
1449 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1451 const GValue *owner_gvalue;
1452 GstStructure *structure;
1454 g_return_if_fail (GST_IS_MESSAGE (message));
1455 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1457 structure = GST_MESSAGE_STRUCTURE (message);
1458 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1459 g_return_if_fail (owner_gvalue != NULL);
1460 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1463 *type = (GstStructureChangeType)
1464 g_value_get_enum (gst_structure_id_get_value (structure,
1467 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1470 g_value_get_boolean (gst_structure_id_get_value (structure,
1475 * gst_message_parse_error:
1476 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1477 * @gerror: (out) (allow-none) (transfer full): location for the GError
1478 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1481 * Extracts the GError and debug string from the GstMessage. The values returned
1482 * in the output arguments are copies; the caller must free them when done.
1484 * Typical usage of this function might be:
1485 * |[<!-- language="C" -->
1487 * switch (GST_MESSAGE_TYPE (msg)) {
1488 * case GST_MESSAGE_ERROR: {
1489 * GError *err = NULL;
1490 * gchar *dbg_info = NULL;
1492 * gst_message_parse_error (msg, &err, &dbg_info);
1493 * g_printerr ("ERROR from element %s: %s\n",
1494 * GST_OBJECT_NAME (msg->src), err->message);
1495 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1496 * g_error_free (err);
1497 * g_free (dbg_info);
1508 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1510 g_return_if_fail (GST_IS_MESSAGE (message));
1511 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1513 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1514 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1515 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1519 * gst_message_parse_warning:
1520 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1521 * @gerror: (out) (allow-none) (transfer full): location for the GError
1522 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1525 * Extracts the GError and debug string from the GstMessage. The values returned
1526 * in the output arguments are copies; the caller must free them when done.
1531 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1534 g_return_if_fail (GST_IS_MESSAGE (message));
1535 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1537 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1538 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1539 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1543 * gst_message_parse_info:
1544 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1545 * @gerror: (out) (allow-none) (transfer full): location for the GError
1546 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1549 * Extracts the GError and debug string from the GstMessage. The values returned
1550 * in the output arguments are copies; the caller must free them when done.
1555 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1557 g_return_if_fail (GST_IS_MESSAGE (message));
1558 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1560 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1561 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1562 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1566 * gst_message_parse_segment_start:
1567 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1568 * @format: (out) (allow-none): Result location for the format, or %NULL
1569 * @position: (out) (allow-none): Result location for the position, or %NULL
1571 * Extracts the position and format from the segment start message.
1576 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1579 GstStructure *structure;
1581 g_return_if_fail (GST_IS_MESSAGE (message));
1582 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1584 structure = GST_MESSAGE_STRUCTURE (message);
1586 *format = (GstFormat)
1587 g_value_get_enum (gst_structure_id_get_value (structure,
1588 GST_QUARK (FORMAT)));
1591 g_value_get_int64 (gst_structure_id_get_value (structure,
1592 GST_QUARK (POSITION)));
1596 * gst_message_parse_segment_done:
1597 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1598 * @format: (out) (allow-none): Result location for the format, or %NULL
1599 * @position: (out) (allow-none): Result location for the position, or %NULL
1601 * Extracts the position and format from the segment done message.
1606 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1609 GstStructure *structure;
1611 g_return_if_fail (GST_IS_MESSAGE (message));
1612 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1614 structure = GST_MESSAGE_STRUCTURE (message);
1616 *format = (GstFormat)
1617 g_value_get_enum (gst_structure_id_get_value (structure,
1618 GST_QUARK (FORMAT)));
1621 g_value_get_int64 (gst_structure_id_get_value (structure,
1622 GST_QUARK (POSITION)));
1626 * gst_message_parse_async_done:
1627 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1628 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1630 * Extract the running_time from the async_done message.
1635 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1637 GstStructure *structure;
1639 g_return_if_fail (GST_IS_MESSAGE (message));
1640 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1642 structure = GST_MESSAGE_STRUCTURE (message);
1645 g_value_get_uint64 (gst_structure_id_get_value (structure,
1646 GST_QUARK (RUNNING_TIME)));
1650 * gst_message_parse_request_state:
1651 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1652 * @state: (out) (allow-none): Result location for the requested state or %NULL
1654 * Extract the requested state from the request_state message.
1659 gst_message_parse_request_state (GstMessage * message, GstState * state)
1661 GstStructure *structure;
1663 g_return_if_fail (GST_IS_MESSAGE (message));
1664 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1666 structure = GST_MESSAGE_STRUCTURE (message);
1669 g_value_get_enum (gst_structure_id_get_value (structure,
1670 GST_QUARK (NEW_STATE)));
1674 * gst_message_new_stream_status:
1675 * @src: The object originating the message.
1676 * @type: The stream status type.
1677 * @owner: (transfer none): the owner element of @src.
1679 * Create a new stream status message. This message is posted when a streaming
1680 * thread is created/destroyed or when the state changed.
1682 * Returns: (transfer full): the new stream status message.
1687 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1690 GstMessage *message;
1691 GstStructure *structure;
1693 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1694 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1695 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1696 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1702 * gst_message_parse_stream_status:
1703 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1704 * @type: (out): A pointer to hold the status type
1705 * @owner: (out) (transfer none): The owner element of the message source
1707 * Extracts the stream status type and owner the GstMessage. The returned
1708 * owner remains valid for as long as the reference to @message is valid and
1709 * should thus not be unreffed.
1714 gst_message_parse_stream_status (GstMessage * message,
1715 GstStreamStatusType * type, GstElement ** owner)
1717 const GValue *owner_gvalue;
1718 GstStructure *structure;
1720 g_return_if_fail (GST_IS_MESSAGE (message));
1721 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1723 structure = GST_MESSAGE_STRUCTURE (message);
1724 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1725 g_return_if_fail (owner_gvalue != NULL);
1728 *type = (GstStreamStatusType)
1729 g_value_get_enum (gst_structure_id_get_value (structure,
1732 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1736 * gst_message_set_stream_status_object:
1737 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1738 * @object: the object controlling the streaming
1740 * Configures the object handling the streaming thread. This is usually a
1741 * GstTask object but other objects might be added in the future.
1744 gst_message_set_stream_status_object (GstMessage * message,
1745 const GValue * object)
1747 GstStructure *structure;
1749 g_return_if_fail (GST_IS_MESSAGE (message));
1750 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1752 structure = GST_MESSAGE_STRUCTURE (message);
1753 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1757 * gst_message_get_stream_status_object:
1758 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1760 * Extracts the object managing the streaming thread from @message.
1762 * Returns: a GValue containing the object that manages the streaming thread.
1763 * This object is usually of type GstTask but other types can be added in the
1764 * future. The object remains valid as long as @message is valid.
1767 gst_message_get_stream_status_object (GstMessage * message)
1769 const GValue *result;
1770 GstStructure *structure;
1772 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1773 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1776 structure = GST_MESSAGE_STRUCTURE (message);
1777 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1783 * gst_message_new_step_done:
1784 * @src: The object originating the message.
1785 * @format: the format of @amount
1786 * @amount: the amount of stepped data
1787 * @rate: the rate of the stepped amount
1788 * @flush: is this an flushing step
1789 * @intermediate: is this an intermediate step
1790 * @duration: the duration of the data
1791 * @eos: the step caused EOS
1793 * This message is posted by elements when they complete a part, when @intermediate set
1794 * to %TRUE, or a complete step operation.
1796 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1797 * @amount of media in format @format.
1799 * Returns: (transfer full): the new step_done message.
1804 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1805 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1808 GstMessage *message;
1809 GstStructure *structure;
1811 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1812 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1813 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1814 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1815 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1816 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1817 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1818 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1819 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1825 * gst_message_parse_step_done:
1826 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1827 * @format: (out) (allow-none): result location for the format
1828 * @amount: (out) (allow-none): result location for the amount
1829 * @rate: (out) (allow-none): result location for the rate
1830 * @flush: (out) (allow-none): result location for the flush flag
1831 * @intermediate: (out) (allow-none): result location for the intermediate flag
1832 * @duration: (out) (allow-none): result location for the duration
1833 * @eos: (out) (allow-none): result location for the EOS flag
1835 * Extract the values the step_done message.
1840 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1841 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1842 guint64 * duration, gboolean * eos)
1844 GstStructure *structure;
1846 g_return_if_fail (GST_IS_MESSAGE (message));
1847 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1849 structure = GST_MESSAGE_STRUCTURE (message);
1850 gst_structure_id_get (structure,
1851 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1852 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1853 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1854 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1855 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1856 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1857 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1861 * gst_message_new_step_start:
1862 * @src: The object originating the message.
1863 * @active: if the step is active or queued
1864 * @format: the format of @amount
1865 * @amount: the amount of stepped data
1866 * @rate: the rate of the stepped amount
1867 * @flush: is this an flushing step
1868 * @intermediate: is this an intermediate step
1870 * This message is posted by elements when they accept or activate a new step
1871 * event for @amount in @format.
1873 * @active is set to %FALSE when the element accepted the new step event and has
1874 * queued it for execution in the streaming threads.
1876 * @active is set to %TRUE when the element has activated the step operation and
1877 * is now ready to start executing the step in the streaming thread. After this
1878 * message is emitted, the application can queue a new step operation in the
1881 * Returns: (transfer full): The new step_start message.
1886 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1887 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1889 GstMessage *message;
1890 GstStructure *structure;
1892 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1893 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1894 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1895 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1896 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1897 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1898 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1899 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1905 * gst_message_parse_step_start:
1906 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1907 * @active: (out) (allow-none): result location for the active flag
1908 * @format: (out) (allow-none): result location for the format
1909 * @amount: (out) (allow-none): result location for the amount
1910 * @rate: (out) (allow-none): result location for the rate
1911 * @flush: (out) (allow-none): result location for the flush flag
1912 * @intermediate: (out) (allow-none): result location for the intermediate flag
1914 * Extract the values from step_start message.
1919 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1920 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1921 gboolean * intermediate)
1923 GstStructure *structure;
1925 g_return_if_fail (GST_IS_MESSAGE (message));
1926 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1928 structure = GST_MESSAGE_STRUCTURE (message);
1929 gst_structure_id_get (structure,
1930 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1931 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1932 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1933 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1934 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1935 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1939 * gst_message_new_qos:
1940 * @src: The object originating the message.
1941 * @live: if the message was generated by a live element
1942 * @running_time: the running time of the buffer that generated the message
1943 * @stream_time: the stream time of the buffer that generated the message
1944 * @timestamp: the timestamps of the buffer that generated the message
1945 * @duration: the duration of the buffer that generated the message
1947 * A QOS message is posted on the bus whenever an element decides to drop a
1948 * buffer because of QoS reasons or whenever it changes its processing strategy
1949 * because of QoS reasons (quality adjustments such as processing at lower
1952 * This message can be posted by an element that performs synchronisation against the
1953 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1954 * events received from a downstream element (!live).
1956 * @running_time, @stream_time, @timestamp, @duration should be set to the
1957 * respective running-time, stream-time, timestamp and duration of the (dropped)
1958 * buffer that generated the QoS event. Values can be left to
1959 * GST_CLOCK_TIME_NONE when unknown.
1961 * Returns: (transfer full): The new qos message.
1966 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1967 guint64 stream_time, guint64 timestamp, guint64 duration)
1969 GstMessage *message;
1970 GstStructure *structure;
1972 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1973 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1974 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1975 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1976 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1977 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1978 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1979 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1980 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1981 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1982 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1983 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1984 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1990 * gst_message_set_qos_values:
1991 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1992 * @jitter: The difference of the running-time against the deadline.
1993 * @proportion: Long term prediction of the ideal rate relative to normal rate
1994 * to get optimal quality.
1995 * @quality: An element dependent integer value that specifies the current
1996 * quality level of the element. The default maximum quality is 1000000.
1998 * Set the QoS values that have been calculated/analysed from the QoS data
2003 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
2004 gdouble proportion, gint quality)
2006 GstStructure *structure;
2008 g_return_if_fail (GST_IS_MESSAGE (message));
2009 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2011 structure = GST_MESSAGE_STRUCTURE (message);
2012 gst_structure_id_set (structure,
2013 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2014 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2015 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2019 * gst_message_set_qos_stats:
2020 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2021 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
2022 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
2023 * will likely use GST_FORMAT_DEFAULT (samples).
2024 * @processed: Total number of units correctly processed since the last state
2025 * change to READY or a flushing operation.
2026 * @dropped: Total number of units dropped since the last state change to READY
2027 * or a flushing operation.
2029 * Set the QoS stats representing the history of the current continuous pipeline
2032 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2033 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2038 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
2039 guint64 processed, guint64 dropped)
2041 GstStructure *structure;
2043 g_return_if_fail (GST_IS_MESSAGE (message));
2044 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2046 structure = GST_MESSAGE_STRUCTURE (message);
2047 gst_structure_id_set (structure,
2048 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2049 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2050 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2054 * gst_message_parse_qos:
2055 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2056 * @live: (out) (allow-none): if the message was generated by a live element
2057 * @running_time: (out) (allow-none): the running time of the buffer that
2058 * generated the message
2059 * @stream_time: (out) (allow-none): the stream time of the buffer that
2060 * generated the message
2061 * @timestamp: (out) (allow-none): the timestamps of the buffer that
2062 * generated the message
2063 * @duration: (out) (allow-none): the duration of the buffer that
2064 * generated the message
2066 * Extract the timestamps and live status from the QoS message.
2068 * The returned values give the running_time, stream_time, timestamp and
2069 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
2075 gst_message_parse_qos (GstMessage * message, gboolean * live,
2076 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
2079 GstStructure *structure;
2081 g_return_if_fail (GST_IS_MESSAGE (message));
2082 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2084 structure = GST_MESSAGE_STRUCTURE (message);
2085 gst_structure_id_get (structure,
2086 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
2087 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
2088 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
2089 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
2090 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
2094 * gst_message_parse_qos_values:
2095 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2096 * @jitter: (out) (allow-none): The difference of the running-time against
2098 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
2099 * relative to normal rate to get optimal quality.
2100 * @quality: (out) (allow-none): An element dependent integer value that
2101 * specifies the current quality level of the element. The default
2102 * maximum quality is 1000000.
2104 * Extract the QoS values that have been calculated/analysed from the QoS data
2109 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
2110 gdouble * proportion, gint * quality)
2112 GstStructure *structure;
2114 g_return_if_fail (GST_IS_MESSAGE (message));
2115 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2117 structure = GST_MESSAGE_STRUCTURE (message);
2118 gst_structure_id_get (structure,
2119 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
2120 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
2121 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
2125 * gst_message_parse_qos_stats:
2126 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
2127 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
2128 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
2129 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
2131 * @processed: (out) (allow-none): Total number of units correctly processed
2132 * since the last state change to READY or a flushing operation.
2133 * @dropped: (out) (allow-none): Total number of units dropped since the last
2134 * state change to READY or a flushing operation.
2136 * Extract the QoS stats representing the history of the current continuous
2137 * pipeline playback period.
2139 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
2140 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
2145 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
2146 guint64 * processed, guint64 * dropped)
2148 GstStructure *structure;
2150 g_return_if_fail (GST_IS_MESSAGE (message));
2151 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
2153 structure = GST_MESSAGE_STRUCTURE (message);
2154 gst_structure_id_get (structure,
2155 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
2156 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
2157 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
2161 * gst_message_new_progress:
2162 * @src: The object originating the message.
2163 * @type: a #GstProgressType
2164 * @code: a progress code
2165 * @text: free, user visible text describing the progress
2167 * Progress messages are posted by elements when they use an asynchronous task
2168 * to perform actions triggered by a state change.
2170 * @code contains a well defined string describing the action.
2171 * @test should contain a user visible string detailing the current action.
2173 * Returns: (transfer full): The new qos message.
2176 gst_message_new_progress (GstObject * src, GstProgressType type,
2177 const gchar * code, const gchar * text)
2179 GstMessage *message;
2180 GstStructure *structure;
2181 gint percent = 100, timeout = -1;
2183 g_return_val_if_fail (code != NULL, NULL);
2184 g_return_val_if_fail (text != NULL, NULL);
2186 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2189 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2190 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2191 GST_QUARK (CODE), G_TYPE_STRING, code,
2192 GST_QUARK (TEXT), G_TYPE_STRING, text,
2193 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2194 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2195 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2201 * gst_message_parse_progress:
2202 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2203 * @type: (out) (allow-none): location for the type
2204 * @code: (out) (allow-none) (transfer full): location for the code
2205 * @text: (out) (allow-none) (transfer full): location for the text
2207 * Parses the progress @type, @code and @text.
2210 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2211 gchar ** code, gchar ** text)
2213 GstStructure *structure;
2215 g_return_if_fail (GST_IS_MESSAGE (message));
2216 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2218 structure = GST_MESSAGE_STRUCTURE (message);
2219 gst_structure_id_get (structure,
2220 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2221 GST_QUARK (CODE), G_TYPE_STRING, code,
2222 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2226 * gst_message_new_toc:
2227 * @src: the object originating the message.
2228 * @toc: (transfer none): #GstToc structure for the message.
2229 * @updated: whether TOC was updated or not.
2231 * Create a new TOC message. The message is posted by elements
2232 * that discovered or updated a TOC.
2234 * Returns: (transfer full): a new TOC message.
2239 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2241 GstStructure *toc_struct;
2243 g_return_val_if_fail (toc != NULL, NULL);
2245 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2246 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2247 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2249 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2253 * gst_message_parse_toc:
2254 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2255 * @toc: (out) (transfer full): return location for the TOC.
2256 * @updated: (out): return location for the updated flag.
2258 * Extract the TOC from the #GstMessage. The TOC returned in the
2259 * output argument is a copy; the caller must free it with
2260 * gst_toc_unref() when done.
2265 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2267 g_return_if_fail (GST_IS_MESSAGE (message));
2268 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2269 g_return_if_fail (toc != NULL);
2271 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2272 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2273 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2277 * gst_message_new_reset_time:
2278 * @src: (transfer none) (allow-none): The object originating the message.
2279 * @running_time: the requested running-time
2281 * This message is posted when the pipeline running-time should be reset to
2282 * @running_time, like after a flushing seek.
2284 * Returns: (transfer full): The new reset_time message.
2289 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2291 GstMessage *message;
2292 GstStructure *structure;
2294 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2295 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2296 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2302 * gst_message_parse_reset_time:
2303 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2304 * @running_time: (out) (allow-none): Result location for the running_time or
2307 * Extract the running-time from the RESET_TIME message.
2312 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2314 GstStructure *structure;
2316 g_return_if_fail (GST_IS_MESSAGE (message));
2317 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2319 structure = GST_MESSAGE_STRUCTURE (message);
2322 g_value_get_uint64 (gst_structure_id_get_value (structure,
2323 GST_QUARK (RUNNING_TIME)));
2327 * gst_message_new_stream_start:
2328 * @src: (transfer none) (allow-none): The object originating the message.
2330 * Create a new stream_start message. This message is generated and posted in
2331 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2332 * message to the application if all sinks have posted an STREAM_START message.
2334 * Returns: (transfer full): The new stream_start message.
2339 gst_message_new_stream_start (GstObject * src)
2341 GstMessage *message;
2344 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2345 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2352 * gst_message_set_group_id:
2353 * @message: the message
2354 * @group_id: the group id
2356 * Sets the group id on the stream-start message.
2358 * All streams that have the same group id are supposed to be played
2359 * together, i.e. all streams inside a container file should have the
2360 * same group id but different stream ids. The group id should change
2361 * each time the stream is started, resulting in different group ids
2362 * each time a file is played for example.
2369 gst_message_set_group_id (GstMessage * message, guint group_id)
2371 GstStructure *structure;
2373 g_return_if_fail (GST_IS_MESSAGE (message));
2374 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2375 g_return_if_fail (gst_message_is_writable (message));
2377 structure = GST_MESSAGE_STRUCTURE (message);
2378 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2383 * gst_message_parse_group_id:
2384 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2385 * @group_id: (out) (allow-none): Result location for the group id or
2388 * Extract the group from the STREAM_START message.
2390 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2397 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2399 GstStructure *structure;
2402 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2403 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2409 structure = GST_MESSAGE_STRUCTURE (message);
2411 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2415 *group_id = g_value_get_uint (v);
2420 * gst_message_new_need_context:
2421 * @src: (transfer none) (allow-none): The object originating the message.
2422 * @context_type: The context type that is needed
2424 * This message is posted when an element needs a specific #GstContext.
2426 * Returns: (transfer full): The new need-context message.
2433 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2435 GstMessage *message;
2436 GstStructure *structure;
2438 g_return_val_if_fail (context_type != NULL, NULL);
2440 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2441 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2442 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2448 * gst_message_parse_context_type:
2449 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2450 * @context_type: (out) (allow-none): the context type, or %NULL
2452 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2454 * Returns: a #gboolean indicating if the parsing succeeded.
2459 gst_message_parse_context_type (GstMessage * message,
2460 const gchar ** context_type)
2462 GstStructure *structure;
2463 const GValue *value;
2465 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2468 structure = GST_MESSAGE_STRUCTURE (message);
2471 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2472 *context_type = g_value_get_string (value);
2479 * gst_message_new_have_context:
2480 * @src: (transfer none) (allow-none): The object originating the message.
2481 * @context: (transfer full): the context
2483 * This message is posted when an element has a new local #GstContext.
2485 * Returns: (transfer full): The new have-context message.
2492 gst_message_new_have_context (GstObject * src, GstContext * context)
2494 GstMessage *message;
2495 GstStructure *structure;
2497 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2498 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2499 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2500 gst_context_unref (context);
2506 * gst_message_parse_have_context:
2507 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2508 * @context: (out) (transfer full) (allow-none): Result location for the
2511 * Extract the context from the HAVE_CONTEXT message.
2518 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2520 g_return_if_fail (GST_IS_MESSAGE (message));
2521 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2524 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2525 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2529 * gst_message_new_device_added:
2530 * @src: The #GstObject that created the message
2531 * @device: (transfer none): The new #GstDevice
2533 * Creates a new device-added message. The device-added message is produced by
2534 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2535 * of monitored devices.
2537 * Returns: a newly allocated #GstMessage
2542 gst_message_new_device_added (GstObject * src, GstDevice * device)
2544 GstMessage *message;
2545 GstStructure *structure;
2547 g_return_val_if_fail (device != NULL, NULL);
2548 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2550 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2551 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2552 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2558 * gst_message_parse_device_added:
2559 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2560 * @device: (out) (allow-none) (transfer full): A location where to store a
2561 * pointer to the new #GstDevice, or %NULL
2563 * Parses a device-added message. The device-added message is produced by
2564 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2565 * of monitored devices.
2570 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2572 g_return_if_fail (GST_IS_MESSAGE (message));
2573 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2576 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2577 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2581 * gst_message_new_device_removed:
2582 * @src: The #GstObject that created the message
2583 * @device: (transfer none): The removed #GstDevice
2585 * Creates a new device-removed message. The device-removed message is produced
2586 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2587 * disappearance of monitored devices.
2589 * Returns: a newly allocated #GstMessage
2594 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2596 GstMessage *message;
2597 GstStructure *structure;
2599 g_return_val_if_fail (device != NULL, NULL);
2600 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2602 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2603 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2604 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2610 * gst_message_parse_device_removed:
2611 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2612 * @device: (out) (allow-none) (transfer full): A location where to store a
2613 * pointer to the removed #GstDevice, or %NULL
2615 * Parses a device-removed message. The device-removed message is produced by
2616 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2617 * disappearance of monitored devices.
2622 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2624 g_return_if_fail (GST_IS_MESSAGE (message));
2625 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2628 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2629 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2633 * gst_message_new_property_notify:
2634 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2635 * @property_name: name of the property that changed
2636 * @val: (allow-none) (transfer full): new property value, or %NULL
2638 * Returns: a newly allocated #GstMessage
2643 gst_message_new_property_notify (GstObject * src, const gchar * property_name,
2646 GstStructure *structure;
2647 GValue name_val = G_VALUE_INIT;
2649 g_return_val_if_fail (property_name != NULL, NULL);
2651 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
2652 g_value_init (&name_val, G_TYPE_STRING);
2653 /* should already be interned, but let's make sure */
2654 g_value_set_static_string (&name_val, g_intern_string (property_name));
2655 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
2657 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
2659 return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
2663 * gst_message_parse_property_notify:
2664 * @message: a #GstMessage of type %GST_MESSAGE_PROPERTY_NOTIFY
2665 * @object: (out) (allow-none) (transfer none): location where to store a
2666 * pointer to the object whose property got changed, or %NULL
2667 * @property_name: (out) (allow-none): return location for the name of the
2668 * property that got changed, or %NULL
2669 * @property_value: (out) (allow-none): return location for the new value of
2670 * the property that got changed, or %NULL. This will only be set if the
2671 * property notify watch was told to include the value when it was set up
2673 * Parses a property-notify message. These will be posted on the bus only
2674 * when set up with gst_element_add_property_notify_watch() or
2675 * gst_element_add_property_deep_notify_watch().
2680 gst_message_parse_property_notify (GstMessage * message, GstObject ** object,
2681 const gchar ** property_name, const GValue ** property_value)
2683 const GstStructure *s = GST_MESSAGE_STRUCTURE (message);
2685 g_return_if_fail (GST_IS_MESSAGE (message));
2686 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROPERTY_NOTIFY);
2689 *object = GST_MESSAGE_SRC (message);
2691 if (property_name) {
2692 const GValue *name_value;
2694 name_value = gst_structure_id_get_value (s, GST_QUARK (PROPERTY_NAME));
2695 *property_name = g_value_get_string (name_value);
2700 gst_structure_id_get_value (s, GST_QUARK (PROPERTY_VALUE));
2704 * gst_message_new_stream_collection:
2705 * @src: The #GstObject that created the message
2706 * @collection: (transfer none): The #GstStreamCollection
2708 * Creates a new stream-collection message. The message is used to announce new
2709 * #GstStreamCollection
2711 * Returns: a newly allocated #GstMessage
2716 gst_message_new_stream_collection (GstObject * src,
2717 GstStreamCollection * collection)
2719 GstMessage *message;
2720 GstStructure *structure;
2722 g_return_val_if_fail (collection != NULL, NULL);
2723 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2726 gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_COLLECTION),
2727 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2729 gst_message_new_custom (GST_MESSAGE_STREAM_COLLECTION, src, structure);
2735 * gst_message_parse_stream_collection:
2736 * @message: a #GstMessage of type %GST_MESSAGE_STREAM_COLLECTION
2737 * @collection: (out) (allow-none) (transfer full): A location where to store a
2738 * pointer to the #GstStreamCollection, or %NULL
2740 * Parses a stream-collection message.
2745 gst_message_parse_stream_collection (GstMessage * message,
2746 GstStreamCollection ** collection)
2748 g_return_if_fail (GST_IS_MESSAGE (message));
2749 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
2750 GST_MESSAGE_STREAM_COLLECTION);
2753 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2754 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2758 * gst_message_new_streams_selected:
2759 * @src: The #GstObject that created the message
2760 * @collection: (transfer none): The #GstStreamCollection
2762 * Creates a new steams-selected message. The message is used to announce
2763 * that an array of streams has been selected. This is generally in response
2764 * to a #GST_EVENT_SELECT_STREAMS event, or when an element (such as decodebin3)
2765 * makes an initial selection of streams.
2767 * The message also contains the #GstStreamCollection to which the various streams
2770 * Users of gst_message_new_streams_selected() can add the selected streams with
2771 * gst_message_streams_selected_add().
2773 * Returns: a newly allocated #GstMessage
2778 gst_message_new_streams_selected (GstObject * src,
2779 GstStreamCollection * collection)
2781 GstMessage *message;
2782 GstStructure *structure;
2783 GValue val = G_VALUE_INIT;
2785 g_return_val_if_fail (collection != NULL, NULL);
2786 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2789 gst_structure_new_id (GST_QUARK (MESSAGE_STREAMS_SELECTED),
2790 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2791 g_value_init (&val, GST_TYPE_ARRAY);
2792 gst_structure_id_take_value (structure, GST_QUARK (STREAMS), &val);
2794 gst_message_new_custom (GST_MESSAGE_STREAMS_SELECTED, src, structure);
2800 * gst_message_streams_selected_get_size:
2801 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2803 * Returns the number of streams contained in the @message.
2805 * Returns: The number of streams contained within.
2810 gst_message_streams_selected_get_size (GstMessage * msg)
2814 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
2815 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2819 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2820 GST_QUARK (STREAMS));
2821 return gst_value_array_get_size (val);
2825 * gst_message_streams_selected_add:
2826 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2827 * @stream: (transfer none): a #GstStream to add to @message
2829 * Adds the @stream to the @message.
2834 gst_message_streams_selected_add (GstMessage * msg, GstStream * stream)
2837 GValue to_add = G_VALUE_INIT;
2839 g_return_if_fail (GST_IS_MESSAGE (msg));
2840 g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED);
2841 g_return_if_fail (GST_IS_STREAM (stream));
2844 (GValue *) gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2845 GST_QUARK (STREAMS));
2846 g_value_init (&to_add, GST_TYPE_STREAM);
2847 g_value_set_object (&to_add, stream);
2848 gst_value_array_append_and_take_value (val, &to_add);
2852 * gst_message_streams_selected_get_stream:
2853 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2854 * @idx: Index of the stream to retrieve
2856 * Retrieves the #GstStream with index @index from the @message.
2858 * Returns: (transfer full): A #GstStream
2863 gst_message_streams_selected_get_stream (GstMessage * msg, guint idx)
2865 const GValue *streams, *val;
2867 g_return_val_if_fail (GST_IS_MESSAGE (msg), NULL);
2868 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2872 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2873 GST_QUARK (STREAMS));
2874 val = gst_value_array_get_value (streams, idx);
2876 return (GstStream *) g_value_dup_object (val);
2883 * gst_message_parse_streams_selected:
2884 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2885 * @collection: (out) (allow-none) (transfer full): A location where to store a
2886 * pointer to the #GstStreamCollection, or %NULL
2888 * Parses a streams-selected message.
2893 gst_message_parse_streams_selected (GstMessage * message,
2894 GstStreamCollection ** collection)
2896 g_return_if_fail (GST_IS_MESSAGE (message));
2897 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAMS_SELECTED);
2900 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2901 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2905 * gst_message_new_redirect:
2906 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2907 * @location: (transfer none): location string for the new entry
2908 * @tag_list: (transfer full) (allow-none): tag list for the new entry
2909 * @entry_struct: (transfer full) (allow-none): structure for the new entry
2911 * Creates a new redirect message and adds a new entry to it. Redirect messages
2912 * are posted when an element detects that the actual data has to be retrieved
2913 * from a different location. This is useful if such a redirection cannot be
2914 * handled inside a source element, for example when HTTP 302/303 redirects
2915 * return a non-HTTP URL.
2917 * The redirect message can hold multiple entries. The first one is added
2918 * when the redirect message is created, with the given location, tag_list,
2919 * entry_struct arguments. Use gst_message_add_redirect_entry() to add more
2922 * Each entry has a location, a tag list, and a structure. All of these are
2923 * optional. The tag list and structure are useful for additional metadata,
2924 * such as bitrate statistics for the given location.
2926 * By default, message recipients should treat entries in the order they are
2927 * stored. The recipient should therefore try entry #0 first, and if this
2928 * entry is not acceptable or working, try entry #1 etc. Senders must make
2929 * sure that they add entries in this order. However, recipients are free to
2930 * ignore the order and pick an entry that is "best" for them. One example
2931 * would be a recipient that scans the entries for the one with the highest
2934 * The specified location string is copied. However, ownership over the tag
2935 * list and structure are transferred to the message.
2937 * Returns: a newly allocated #GstMessage
2942 gst_message_new_redirect (GstObject * src, const gchar * location,
2943 GstTagList * tag_list, const GstStructure * entry_struct)
2945 GstStructure *structure;
2946 GstMessage *message;
2947 GValue entry_locations_gvalue = G_VALUE_INIT;
2948 GValue entry_taglists_gvalue = G_VALUE_INIT;
2949 GValue entry_structures_gvalue = G_VALUE_INIT;
2951 g_return_val_if_fail (location != NULL, NULL);
2953 g_value_init (&entry_locations_gvalue, GST_TYPE_LIST);
2954 g_value_init (&entry_taglists_gvalue, GST_TYPE_LIST);
2955 g_value_init (&entry_structures_gvalue, GST_TYPE_LIST);
2957 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_REDIRECT));
2958 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_LOCATIONS),
2959 &entry_locations_gvalue);
2960 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_TAGLISTS),
2961 &entry_taglists_gvalue);
2962 gst_structure_id_take_value (structure, GST_QUARK (REDIRECT_ENTRY_STRUCTURES),
2963 &entry_structures_gvalue);
2965 message = gst_message_new_custom (GST_MESSAGE_REDIRECT, src, structure);
2966 g_assert (message != NULL);
2968 gst_message_add_redirect_entry (message, location, tag_list, entry_struct);
2974 * gst_message_add_redirect_entry:
2975 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
2976 * @location: (transfer none): location string for the new entry
2977 * @tag_list: (transfer full) (allow-none): tag list for the new entry
2978 * @entry_struct: (transfer full) (allow-none): structure for the new entry
2980 * Creates and appends a new entry.
2982 * The specified location string is copied. However, ownership over the tag
2983 * list and structure are transferred to the message.
2988 gst_message_add_redirect_entry (GstMessage * message, const gchar * location,
2989 GstTagList * tag_list, const GstStructure * entry_struct)
2991 GValue val = G_VALUE_INIT;
2992 GstStructure *structure;
2993 GValue *entry_locations_gvalue;
2994 GValue *entry_taglists_gvalue;
2995 GValue *entry_structures_gvalue;
2997 g_return_if_fail (location != NULL);
2998 g_return_if_fail (GST_IS_MESSAGE (message));
2999 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3001 structure = GST_MESSAGE_STRUCTURE (message);
3003 entry_locations_gvalue =
3004 (GValue *) gst_structure_id_get_value (structure,
3005 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3006 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3007 entry_taglists_gvalue =
3008 (GValue *) gst_structure_id_get_value (structure,
3009 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3010 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3011 entry_structures_gvalue =
3012 (GValue *) gst_structure_id_get_value (structure,
3013 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3014 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3016 g_value_init (&val, G_TYPE_STRING);
3018 g_value_set_string (&val, location);
3019 gst_value_list_append_and_take_value (entry_locations_gvalue, &val);
3021 g_value_init (&val, GST_TYPE_TAG_LIST);
3023 g_value_take_boxed (&val, tag_list);
3024 gst_value_list_append_and_take_value (entry_taglists_gvalue, &val);
3026 g_value_init (&val, GST_TYPE_STRUCTURE);
3028 g_value_take_boxed (&val, entry_struct);
3029 gst_value_list_append_and_take_value (entry_structures_gvalue, &val);
3033 * gst_message_parse_redirect_entry:
3034 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3035 * @entry_index: index of the entry to parse
3036 * @location: (out) (transfer none) (allow-none): return location for
3037 * the pointer to the entry's location string, or %NULL
3038 * @tag_list: (out) (transfer none) (allow-none): return location for
3039 * the pointer to the entry's tag list, or %NULL
3040 * @entry_struct: (out) (transfer none) (allow-none): return location
3041 * for the pointer to the entry's structure, or %NULL
3043 * Parses the location and/or structure from the entry with the given index.
3044 * The index must be between 0 and gst_message_get_num_redirect_entries() - 1.
3045 * Returned pointers are valid for as long as this message exists.
3050 gst_message_parse_redirect_entry (GstMessage * message, gsize entry_index,
3051 const gchar ** location, GstTagList ** tag_list,
3052 const GstStructure ** entry_struct)
3055 GstStructure *structure;
3056 const GValue *entry_locations_gvalue;
3057 const GValue *entry_taglists_gvalue;
3058 const GValue *entry_structures_gvalue;
3060 g_return_if_fail (GST_IS_MESSAGE (message));
3061 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT);
3063 if (G_UNLIKELY (!location && !tag_list && !entry_struct))
3066 structure = GST_MESSAGE_STRUCTURE (message);
3068 entry_locations_gvalue =
3069 gst_structure_id_get_value (structure,
3070 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3071 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue));
3072 entry_taglists_gvalue =
3073 gst_structure_id_get_value (structure,
3074 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3075 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue));
3076 entry_structures_gvalue =
3077 gst_structure_id_get_value (structure,
3078 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3079 g_return_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue));
3082 val = gst_value_list_get_value (entry_locations_gvalue, entry_index);
3083 g_return_if_fail (val != NULL);
3084 *location = g_value_get_string (val);
3088 val = gst_value_list_get_value (entry_taglists_gvalue, entry_index);
3089 g_return_if_fail (val != NULL);
3090 *tag_list = (GstTagList *) g_value_get_boxed (val);
3094 val = gst_value_list_get_value (entry_structures_gvalue, entry_index);
3095 g_return_if_fail (val != NULL);
3096 *entry_struct = (const GstStructure *) g_value_get_boxed (val);
3101 * gst_message_get_num_redirect_entries:
3102 * @message: a #GstMessage of type %GST_MESSAGE_REDIRECT
3104 * Returns: the number of entries stored in the message
3109 gst_message_get_num_redirect_entries (GstMessage * message)
3111 GstStructure *structure;
3112 const GValue *entry_locations_gvalue;
3113 const GValue *entry_taglists_gvalue;
3114 const GValue *entry_structures_gvalue;
3117 g_return_val_if_fail (GST_IS_MESSAGE (message), 0);
3118 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REDIRECT, 0);
3120 structure = GST_MESSAGE_STRUCTURE (message);
3122 entry_locations_gvalue =
3123 gst_structure_id_get_value (structure,
3124 GST_QUARK (REDIRECT_ENTRY_LOCATIONS));
3125 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_locations_gvalue), 0);
3126 entry_taglists_gvalue =
3127 gst_structure_id_get_value (structure,
3128 GST_QUARK (REDIRECT_ENTRY_TAGLISTS));
3129 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_taglists_gvalue), 0);
3130 entry_structures_gvalue =
3131 gst_structure_id_get_value (structure,
3132 GST_QUARK (REDIRECT_ENTRY_STRUCTURES));
3133 g_return_val_if_fail (GST_VALUE_HOLDS_LIST (entry_structures_gvalue), 0);
3135 size = gst_value_list_get_size (entry_locations_gvalue);
3137 g_return_val_if_fail ((size ==
3138 gst_value_list_get_size (entry_structures_gvalue))
3139 && (size == gst_value_list_get_size (entry_taglists_gvalue)), 0);