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:
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"
61 GstStructure *structure;
64 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
73 static GstMessageQuarks message_quarks[] = {
74 {GST_MESSAGE_UNKNOWN, "unknown", 0},
75 {GST_MESSAGE_EOS, "eos", 0},
76 {GST_MESSAGE_ERROR, "error", 0},
77 {GST_MESSAGE_WARNING, "warning", 0},
78 {GST_MESSAGE_INFO, "info", 0},
79 {GST_MESSAGE_TAG, "tag", 0},
80 {GST_MESSAGE_BUFFERING, "buffering", 0},
81 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
82 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
83 {GST_MESSAGE_STEP_DONE, "step-done", 0},
84 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
85 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
86 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
87 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
88 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
89 {GST_MESSAGE_APPLICATION, "application", 0},
90 {GST_MESSAGE_ELEMENT, "element", 0},
91 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
92 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
93 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
94 {GST_MESSAGE_LATENCY, "latency", 0},
95 {GST_MESSAGE_ASYNC_START, "async-start", 0},
96 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
97 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
98 {GST_MESSAGE_STEP_START, "step-start", 0},
99 {GST_MESSAGE_QOS, "qos", 0},
100 {GST_MESSAGE_PROGRESS, "progress", 0},
101 {GST_MESSAGE_TOC, "toc", 0},
102 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
103 {GST_MESSAGE_STREAM_START, "stream-start", 0},
104 {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
105 {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
106 {GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
107 {GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
111 GType _gst_message_type = 0;
112 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
115 _priv_gst_message_initialize (void)
119 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
121 for (i = 0; message_quarks[i].name; i++) {
122 message_quarks[i].quark =
123 g_quark_from_static_string (message_quarks[i].name);
126 _gst_message_type = gst_message_get_type ();
130 * gst_message_type_get_name:
131 * @type: the message type
133 * Get a printable name for the given message type. Do not modify or free.
135 * Returns: a reference to the static name of the message.
138 gst_message_type_get_name (GstMessageType type)
142 for (i = 0; message_quarks[i].name; i++) {
143 if (type == message_quarks[i].type)
144 return message_quarks[i].name;
150 * gst_message_type_to_quark:
151 * @type: the message type
153 * Get the unique quark for the given message type.
155 * Returns: the quark associated with the message type
158 gst_message_type_to_quark (GstMessageType type)
162 for (i = 0; message_quarks[i].name; i++) {
163 if (type == message_quarks[i].type)
164 return message_quarks[i].quark;
170 _gst_message_dispose (GstMessage * message)
172 gboolean do_free = TRUE;
174 if (GST_MINI_OBJECT_FLAG_IS_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY)) {
175 /* revive message, so bus can finish with it and clean it up */
176 gst_message_ref (message);
178 GST_INFO ("[msg %p] signalling async free", message);
180 GST_MESSAGE_LOCK (message);
181 GST_MESSAGE_SIGNAL (message);
182 GST_MESSAGE_UNLOCK (message);
184 /* don't free it yet, let bus finish with it first */
192 _gst_message_free (GstMessage * message)
194 GstStructure *structure;
196 g_return_if_fail (message != NULL);
198 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
199 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
201 if (GST_MESSAGE_SRC (message)) {
202 gst_object_unref (GST_MESSAGE_SRC (message));
203 GST_MESSAGE_SRC (message) = NULL;
206 structure = GST_MESSAGE_STRUCTURE (message);
208 gst_structure_set_parent_refcount (structure, NULL);
209 gst_structure_free (structure);
212 g_slice_free1 (sizeof (GstMessageImpl), message);
216 gst_message_init (GstMessageImpl * message, GstMessageType type,
220 _gst_message_copy (GstMessage * message)
222 GstMessageImpl *copy;
223 GstStructure *structure;
225 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
226 GST_MESSAGE_TYPE_NAME (message),
227 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
229 copy = g_slice_new0 (GstMessageImpl);
231 gst_message_init (copy, GST_MESSAGE_TYPE (message),
232 GST_MESSAGE_SRC (message));
234 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
235 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
237 structure = GST_MESSAGE_STRUCTURE (message);
239 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
240 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
241 ©->message.mini_object.refcount);
243 GST_MESSAGE_STRUCTURE (copy) = NULL;
246 return GST_MESSAGE_CAST (copy);
250 gst_message_init (GstMessageImpl * message, GstMessageType type,
253 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
254 (GstMiniObjectCopyFunction) _gst_message_copy,
255 (GstMiniObjectDisposeFunction) _gst_message_dispose,
256 (GstMiniObjectFreeFunction) _gst_message_free);
258 GST_MESSAGE_TYPE (message) = type;
260 gst_object_ref (src);
261 GST_MESSAGE_SRC (message) = src;
262 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
263 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
268 * gst_message_new_custom:
269 * @type: The #GstMessageType to distinguish messages
270 * @src: (transfer none) (allow-none): The object originating the message.
271 * @structure: (transfer full) (allow-none): the structure for the
272 * message. The message will take ownership of the structure.
274 * Create a new custom-typed message. This can be used for anything not
275 * handled by other message-specific functions to pass a message to the
276 * app. The structure field can be %NULL.
278 * Returns: (transfer full): The new message.
283 gst_message_new_custom (GstMessageType type, GstObject * src,
284 GstStructure * structure)
286 GstMessageImpl *message;
288 message = g_slice_new0 (GstMessageImpl);
290 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
291 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
292 gst_message_type_get_name (type));
295 /* structure must not have a parent */
296 if (!gst_structure_set_parent_refcount (structure,
297 &message->message.mini_object.refcount))
300 gst_message_init (message, type, src);
302 GST_MESSAGE_STRUCTURE (message) = structure;
304 return GST_MESSAGE_CAST (message);
309 g_slice_free1 (sizeof (GstMessageImpl), message);
310 g_warning ("structure is already owned by another object");
316 * gst_message_get_seqnum:
317 * @message: A #GstMessage.
319 * Retrieve the sequence number of a message.
321 * Messages have ever-incrementing sequence numbers, which may also be set
322 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
323 * to indicate that a message corresponds to some other set of messages or
324 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
325 * is considered good practice to make this correspondence when possible, though
326 * it is not required.
328 * Note that events and messages share the same sequence number incrementor;
329 * two events or messages will never have the same sequence number unless
330 * that correspondence was made explicitly.
332 * Returns: The message's sequence number.
337 gst_message_get_seqnum (GstMessage * message)
339 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
341 return GST_MESSAGE_SEQNUM (message);
345 * gst_message_set_seqnum:
346 * @message: A #GstMessage.
347 * @seqnum: A sequence number.
349 * Set the sequence number of a message.
351 * This function might be called by the creator of a message to indicate that
352 * the message relates to other messages or events. See gst_message_get_seqnum()
353 * for more information.
358 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
360 g_return_if_fail (GST_IS_MESSAGE (message));
362 GST_MESSAGE_SEQNUM (message) = seqnum;
366 * gst_message_new_eos:
367 * @src: (transfer none) (allow-none): The object originating the message.
369 * Create a new eos message. This message is generated and posted in
370 * the sink elements of a GstBin. The bin will only forward the EOS
371 * message to the application if all sinks have posted an EOS message.
373 * Returns: (transfer full): The new eos message.
378 gst_message_new_eos (GstObject * src)
382 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
388 * gst_message_new_error:
389 * @src: (transfer none) (allow-none): The object originating the message.
390 * @error: (transfer none): The GError for this message.
391 * @debug: A debugging string.
393 * Create a new error message. The message will copy @error and
394 * @debug. This message is posted by element when a fatal event
395 * occurred. The pipeline will probably (partially) stop. The application
396 * receiving this message should stop the pipeline.
398 * Returns: (transfer full): the new error message.
403 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
406 GstStructure *structure;
408 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
409 GST_QUARK (GERROR), G_TYPE_ERROR, error,
410 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
411 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
417 * gst_message_new_warning:
418 * @src: (transfer none) (allow-none): The object originating the message.
419 * @error: (transfer none): The GError for this message.
420 * @debug: A debugging string.
422 * Create a new warning message. The message will make copies of @error and
425 * Returns: (transfer full): The new warning message.
430 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
433 GstStructure *structure;
435 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
436 GST_QUARK (GERROR), G_TYPE_ERROR, error,
437 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
438 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
444 * gst_message_new_info:
445 * @src: (transfer none) (allow-none): The object originating the message.
446 * @error: (transfer none): The GError for this message.
447 * @debug: A debugging string.
449 * Create a new info message. The message will make copies of @error and
454 * Returns: (transfer full): the new info message.
457 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
460 GstStructure *structure;
462 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
463 GST_QUARK (GERROR), G_TYPE_ERROR, error,
464 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
465 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
471 * gst_message_new_tag:
472 * @src: (transfer none) (allow-none): The object originating the message.
473 * @tag_list: (transfer full): the tag list for the message.
475 * Create a new tag message. The message will take ownership of the tag list.
476 * The message is posted by elements that discovered a new taglist.
478 * Returns: (transfer full): the new tag message.
483 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
487 GValue val = G_VALUE_INIT;
489 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
491 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
492 g_value_init (&val, GST_TYPE_TAG_LIST);
493 g_value_take_boxed (&val, tag_list);
494 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
495 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
500 * gst_message_new_buffering:
501 * @src: (transfer none) (allow-none): The object originating the message.
502 * @percent: The buffering percent
504 * Create a new buffering message. This message can be posted by an element that
505 * needs to buffer data before it can continue processing. @percent should be a
506 * value between 0 and 100. A value of 100 means that the buffering completed.
508 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
509 * @percent is 100, the application can set the pipeline (back) to PLAYING.
510 * The application must be prepared to receive BUFFERING messages in the
511 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
512 * message with @percent set to 100, which can happen after the pipeline
513 * completed prerolling.
517 * Returns: (transfer full): The new buffering message.
520 gst_message_new_buffering (GstObject * src, gint percent)
523 GstStructure *structure;
524 gint64 buffering_left;
526 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
528 buffering_left = (percent == 100 ? 0 : -1);
530 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
531 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
532 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
533 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
534 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
535 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
536 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
542 * gst_message_new_state_changed:
543 * @src: (transfer none) (allow-none): The object originating the message.
544 * @oldstate: the previous state
545 * @newstate: the new (current) state
546 * @pending: the pending (target) state
548 * Create a state change message. This message is posted whenever an element
551 * Returns: (transfer full): the new state change message.
556 gst_message_new_state_changed (GstObject * src,
557 GstState oldstate, GstState newstate, GstState pending)
560 GstStructure *structure;
562 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
563 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
564 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
565 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
566 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
572 * gst_message_new_state_dirty:
573 * @src: (transfer none) (allow-none): The object originating the message
575 * Create a state dirty message. This message is posted whenever an element
576 * changed its state asynchronously and is used internally to update the
577 * states of container objects.
579 * Returns: (transfer full): the new state dirty message.
584 gst_message_new_state_dirty (GstObject * src)
588 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
594 * gst_message_new_clock_provide:
595 * @src: (transfer none) (allow-none): The object originating the message.
596 * @clock: (transfer none): the clock it provides
597 * @ready: %TRUE if the sender can provide a clock
599 * Create a clock provide message. This message is posted whenever an
600 * element is ready to provide a clock or lost its ability to provide
601 * a clock (maybe because it paused or became EOS).
603 * This message is mainly used internally to manage the clock
606 * Returns: (transfer full): the new provide clock message.
611 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
615 GstStructure *structure;
617 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
618 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
619 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
620 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
626 * gst_message_new_clock_lost:
627 * @src: (transfer none) (allow-none): The object originating the message.
628 * @clock: (transfer none): the clock that was lost
630 * Create a clock lost message. This message is posted whenever the
631 * clock is not valid anymore.
633 * If this message is posted by the pipeline, the pipeline will
634 * select a new clock again when it goes to PLAYING. It might therefore
635 * be needed to set the pipeline to PAUSED and PLAYING again.
637 * Returns: (transfer full): The new clock lost message.
642 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
645 GstStructure *structure;
647 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
648 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
649 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
655 * gst_message_new_new_clock:
656 * @src: (transfer none) (allow-none): The object originating the message.
657 * @clock: (transfer none): the new selected clock
659 * Create a new clock message. This message is posted whenever the
660 * pipeline selects a new clock for the pipeline.
662 * Returns: (transfer full): The new new clock message.
667 gst_message_new_new_clock (GstObject * src, GstClock * clock)
670 GstStructure *structure;
672 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
673 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
674 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
680 * gst_message_new_structure_change:
681 * @src: (transfer none) (allow-none): The object originating the message.
682 * @type: The change type.
683 * @owner: (transfer none): The owner element of @src.
684 * @busy: Whether the structure change is busy.
686 * Create a new structure change message. This message is posted when the
687 * structure of a pipeline is in the process of being changed, for example
688 * when pads are linked or unlinked.
690 * @src should be the sinkpad that unlinked or linked.
692 * Returns: (transfer full): the new structure change message.
697 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
698 GstElement * owner, gboolean busy)
701 GstStructure *structure;
703 g_return_val_if_fail (GST_IS_PAD (src), NULL);
704 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
705 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
707 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
708 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
709 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
710 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
712 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
719 * gst_message_new_segment_start:
720 * @src: (transfer none) (allow-none): The object originating the message.
721 * @format: The format of the position being played
722 * @position: The position of the segment being played
724 * Create a new segment message. This message is posted by elements that
725 * start playback of a segment as a result of a segment seek. This message
726 * is not received by the application but is used for maintenance reasons in
727 * container elements.
729 * Returns: (transfer full): the new segment start message.
734 gst_message_new_segment_start (GstObject * src, GstFormat format,
738 GstStructure *structure;
740 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
741 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
742 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
743 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
749 * gst_message_new_segment_done:
750 * @src: (transfer none) (allow-none): The object originating the message.
751 * @format: The format of the position being done
752 * @position: The position of the segment being done
754 * Create a new segment done message. This message is posted by elements that
755 * finish playback of a segment as a result of a segment seek. This message
756 * is received by the application after all elements that posted a segment_start
757 * have posted the segment_done.
759 * Returns: (transfer full): the new segment done message.
764 gst_message_new_segment_done (GstObject * src, GstFormat format,
768 GstStructure *structure;
770 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
771 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
772 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
773 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
779 * gst_message_new_application:
780 * @src: (transfer none) (allow-none): The object originating the message.
781 * @structure: (transfer full): the structure for the message. The message
782 * will take ownership of the structure.
784 * Create a new application-typed message. GStreamer will never create these
785 * messages; they are a gift from us to you. Enjoy.
787 * Returns: (transfer full): The new application message.
792 gst_message_new_application (GstObject * src, GstStructure * structure)
794 g_return_val_if_fail (structure != NULL, NULL);
796 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
800 * gst_message_new_element:
801 * @src: (transfer none) (allow-none): The object originating the message.
802 * @structure: (transfer full): The structure for the
803 * message. The message will take ownership of the structure.
805 * Create a new element-specific message. This is meant as a generic way of
806 * allowing one-way communication from an element to an application, for example
807 * "the firewire cable was unplugged". The format of the message should be
808 * documented in the element's documentation. The structure field can be %NULL.
810 * Returns: (transfer full): The new element message.
815 gst_message_new_element (GstObject * src, GstStructure * structure)
817 g_return_val_if_fail (structure != NULL, NULL);
819 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
823 * gst_message_new_duration_changed:
824 * @src: (transfer none) (allow-none): The object originating the message.
826 * Create a new duration changed message. This message is posted by elements
827 * that know the duration of a stream when the duration changes. This message
828 * is received by bins and is used to calculate the total duration of a
829 * pipeline. Elements may post a duration message with a duration of
830 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
831 * cached duration should be discarded. The new duration can then be
832 * retrieved via a query.
834 * Returns: (transfer full): The new duration-changed message.
839 gst_message_new_duration_changed (GstObject * src)
843 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
844 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
850 * gst_message_new_async_start:
851 * @src: (transfer none) (allow-none): The object originating the message.
853 * This message is posted by elements when they start an ASYNC state change.
855 * Returns: (transfer full): The new async_start message.
860 gst_message_new_async_start (GstObject * src)
864 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
870 * gst_message_new_async_done:
871 * @src: (transfer none) (allow-none): The object originating the message.
872 * @running_time: the desired running_time
874 * The message is posted when elements completed an ASYNC state change.
875 * @running_time contains the time of the desired running_time when this
876 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
877 * means that the element has no clock interaction and thus doesn't care about
878 * the running_time of the pipeline.
880 * Returns: (transfer full): The new async_done message.
885 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
888 GstStructure *structure;
890 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
891 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
892 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
898 * gst_message_new_latency:
899 * @src: (transfer none) (allow-none): The object originating the message.
901 * This message can be posted by elements when their latency requirements have
904 * Returns: (transfer full): The new latency message.
909 gst_message_new_latency (GstObject * src)
913 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
919 * gst_message_new_request_state:
920 * @src: (transfer none) (allow-none): The object originating the message.
921 * @state: The new requested state
923 * This message can be posted by elements when they want to have their state
924 * changed. A typical use case would be an audio server that wants to pause the
925 * pipeline because a higher priority stream is being played.
927 * Returns: (transfer full): the new request state message.
932 gst_message_new_request_state (GstObject * src, GstState state)
935 GstStructure *structure;
937 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
938 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
939 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
945 * gst_message_get_structure:
946 * @message: The #GstMessage.
948 * Access the structure of the message.
950 * Returns: (transfer none): The structure of the message. The structure is
951 * still owned by the message, which means that you should not free it and
952 * that the pointer becomes invalid when you free the message.
957 gst_message_get_structure (GstMessage * message)
959 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
961 return GST_MESSAGE_STRUCTURE (message);
965 * gst_message_has_name:
966 * @message: The #GstMessage.
967 * @name: name to check
969 * Checks if @message has the given @name. This function is usually used to
970 * check the name of a custom message.
972 * Returns: %TRUE if @name matches the name of the message structure.
975 gst_message_has_name (GstMessage * message, const gchar * name)
977 GstStructure *structure;
979 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
981 structure = GST_MESSAGE_STRUCTURE (message);
982 if (structure == NULL)
985 return gst_structure_has_name (structure, name);
989 * gst_message_parse_tag:
990 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
991 * @tag_list: (out callee-allocates): return location for the tag-list.
993 * Extracts the tag list from the GstMessage. The tag list returned in the
994 * output argument is a copy; the caller must free it when done.
996 * Typical usage of this function might be:
999 * switch (GST_MESSAGE_TYPE (msg)) {
1000 * case GST_MESSAGE_TAG: {
1001 * GstTagList *tags = NULL;
1003 * gst_message_parse_tag (msg, &tags);
1004 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1005 * handle_tags (tags);
1006 * gst_tag_list_unref (tags);
1017 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1019 g_return_if_fail (GST_IS_MESSAGE (message));
1020 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1021 g_return_if_fail (tag_list != NULL);
1023 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1024 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1028 * gst_message_parse_buffering:
1029 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1030 * @percent: (out) (allow-none): Return location for the percent.
1032 * Extracts the buffering percent from the GstMessage. see also
1033 * gst_message_new_buffering().
1038 gst_message_parse_buffering (GstMessage * message, gint * percent)
1040 g_return_if_fail (GST_IS_MESSAGE (message));
1041 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1045 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1046 (message), GST_QUARK (BUFFER_PERCENT)));
1050 * gst_message_set_buffering_stats:
1051 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1052 * @mode: a buffering mode
1053 * @avg_in: the average input rate
1054 * @avg_out: the average output rate
1055 * @buffering_left: amount of buffering time left in milliseconds
1057 * Configures the buffering stats values in @message.
1060 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1061 gint avg_in, gint avg_out, gint64 buffering_left)
1063 g_return_if_fail (GST_IS_MESSAGE (message));
1064 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1066 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1067 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1068 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1069 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1070 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1074 * gst_message_parse_buffering_stats:
1075 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1076 * @mode: (out) (allow-none): a buffering mode, or %NULL
1077 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1078 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1079 * @buffering_left: (out) (allow-none): amount of buffering time left in
1080 * milliseconds, or %NULL
1082 * Extracts the buffering stats values from @message.
1085 gst_message_parse_buffering_stats (GstMessage * message,
1086 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1087 gint64 * buffering_left)
1089 GstStructure *structure;
1091 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1093 structure = GST_MESSAGE_STRUCTURE (message);
1095 *mode = (GstBufferingMode)
1096 g_value_get_enum (gst_structure_id_get_value (structure,
1097 GST_QUARK (BUFFERING_MODE)));
1099 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1100 GST_QUARK (AVG_IN_RATE)));
1102 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1103 GST_QUARK (AVG_OUT_RATE)));
1106 g_value_get_int64 (gst_structure_id_get_value (structure,
1107 GST_QUARK (BUFFERING_LEFT)));
1111 * gst_message_parse_state_changed:
1112 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1113 * @oldstate: (out) (allow-none): the previous state, or %NULL
1114 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1115 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1117 * Extracts the old and new states from the GstMessage.
1119 * Typical usage of this function might be:
1122 * switch (GST_MESSAGE_TYPE (msg)) {
1123 * case GST_MESSAGE_STATE_CHANGED: {
1124 * GstState old_state, new_state;
1126 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1127 * g_print ("Element %s changed state from %s to %s.\n",
1128 * GST_OBJECT_NAME (msg->src),
1129 * gst_element_state_get_name (old_state),
1130 * gst_element_state_get_name (new_state));
1141 gst_message_parse_state_changed (GstMessage * message,
1142 GstState * oldstate, GstState * newstate, GstState * pending)
1144 GstStructure *structure;
1146 g_return_if_fail (GST_IS_MESSAGE (message));
1147 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1149 structure = GST_MESSAGE_STRUCTURE (message);
1151 *oldstate = (GstState)
1152 g_value_get_enum (gst_structure_id_get_value (structure,
1153 GST_QUARK (OLD_STATE)));
1155 *newstate = (GstState)
1156 g_value_get_enum (gst_structure_id_get_value (structure,
1157 GST_QUARK (NEW_STATE)));
1159 *pending = (GstState)
1160 g_value_get_enum (gst_structure_id_get_value (structure,
1161 GST_QUARK (PENDING_STATE)));
1165 * gst_message_parse_clock_provide:
1166 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1167 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1169 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1171 * Extracts the clock and ready flag from the GstMessage.
1172 * The clock object returned remains valid until the message is freed.
1177 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1180 const GValue *clock_gvalue;
1181 GstStructure *structure;
1183 g_return_if_fail (GST_IS_MESSAGE (message));
1184 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1186 structure = GST_MESSAGE_STRUCTURE (message);
1187 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1188 g_return_if_fail (clock_gvalue != NULL);
1189 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1193 g_value_get_boolean (gst_structure_id_get_value (structure,
1194 GST_QUARK (READY)));
1196 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1200 * gst_message_parse_clock_lost:
1201 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1202 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1204 * Extracts the lost clock from the GstMessage.
1205 * The clock object returned remains valid until the message is freed.
1210 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1212 const GValue *clock_gvalue;
1213 GstStructure *structure;
1215 g_return_if_fail (GST_IS_MESSAGE (message));
1216 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1218 structure = GST_MESSAGE_STRUCTURE (message);
1219 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1220 g_return_if_fail (clock_gvalue != NULL);
1221 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1224 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1228 * gst_message_parse_new_clock:
1229 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1230 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1233 * Extracts the new clock from the GstMessage.
1234 * The clock object returned remains valid until the message is freed.
1239 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1241 const GValue *clock_gvalue;
1242 GstStructure *structure;
1244 g_return_if_fail (GST_IS_MESSAGE (message));
1245 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1247 structure = GST_MESSAGE_STRUCTURE (message);
1248 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1249 g_return_if_fail (clock_gvalue != NULL);
1250 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1253 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1257 * gst_message_parse_structure_change:
1258 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1259 * @type: (out): A pointer to hold the change type
1260 * @owner: (out) (allow-none) (transfer none): The owner element of the
1262 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1263 * progress or has been completed
1265 * Extracts the change type and completion status from the GstMessage.
1270 gst_message_parse_structure_change (GstMessage * message,
1271 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1273 const GValue *owner_gvalue;
1274 GstStructure *structure;
1276 g_return_if_fail (GST_IS_MESSAGE (message));
1277 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1279 structure = GST_MESSAGE_STRUCTURE (message);
1280 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1281 g_return_if_fail (owner_gvalue != NULL);
1282 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1285 *type = (GstStructureChangeType)
1286 g_value_get_enum (gst_structure_id_get_value (structure,
1289 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1292 g_value_get_boolean (gst_structure_id_get_value (structure,
1297 * gst_message_parse_error:
1298 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1299 * @gerror: (out) (allow-none) (transfer full): location for the GError
1300 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1303 * Extracts the GError and debug string from the GstMessage. The values returned
1304 * in the output arguments are copies; the caller must free them when done.
1306 * Typical usage of this function might be:
1309 * switch (GST_MESSAGE_TYPE (msg)) {
1310 * case GST_MESSAGE_ERROR: {
1311 * GError *err = NULL;
1312 * gchar *dbg_info = NULL;
1314 * gst_message_parse_error (msg, &err, &dbg_info);
1315 * g_printerr ("ERROR from element %s: %s\n",
1316 * GST_OBJECT_NAME (msg->src), err->message);
1317 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1318 * g_error_free (err);
1319 * g_free (dbg_info);
1330 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1332 g_return_if_fail (GST_IS_MESSAGE (message));
1333 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1335 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1336 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1337 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1341 * gst_message_parse_warning:
1342 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1343 * @gerror: (out) (allow-none) (transfer full): location for the GError
1344 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1347 * Extracts the GError and debug string from the GstMessage. The values returned
1348 * in the output arguments are copies; the caller must free them when done.
1353 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1356 g_return_if_fail (GST_IS_MESSAGE (message));
1357 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1359 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1360 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1361 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1365 * gst_message_parse_info:
1366 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1367 * @gerror: (out) (allow-none) (transfer full): location for the GError
1368 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1371 * Extracts the GError and debug string from the GstMessage. The values returned
1372 * in the output arguments are copies; the caller must free them when done.
1377 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1379 g_return_if_fail (GST_IS_MESSAGE (message));
1380 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1382 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1383 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1384 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1388 * gst_message_parse_segment_start:
1389 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1390 * @format: (out) (allow-none): Result location for the format, or %NULL
1391 * @position: (out) (allow-none): Result location for the position, or %NULL
1393 * Extracts the position and format from the segment start message.
1398 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1401 GstStructure *structure;
1403 g_return_if_fail (GST_IS_MESSAGE (message));
1404 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1406 structure = GST_MESSAGE_STRUCTURE (message);
1408 *format = (GstFormat)
1409 g_value_get_enum (gst_structure_id_get_value (structure,
1410 GST_QUARK (FORMAT)));
1413 g_value_get_int64 (gst_structure_id_get_value (structure,
1414 GST_QUARK (POSITION)));
1418 * gst_message_parse_segment_done:
1419 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1420 * @format: (out) (allow-none): Result location for the format, or %NULL
1421 * @position: (out) (allow-none): Result location for the position, or %NULL
1423 * Extracts the position and format from the segment done message.
1428 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1431 GstStructure *structure;
1433 g_return_if_fail (GST_IS_MESSAGE (message));
1434 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1436 structure = GST_MESSAGE_STRUCTURE (message);
1438 *format = (GstFormat)
1439 g_value_get_enum (gst_structure_id_get_value (structure,
1440 GST_QUARK (FORMAT)));
1443 g_value_get_int64 (gst_structure_id_get_value (structure,
1444 GST_QUARK (POSITION)));
1448 * gst_message_parse_async_done:
1449 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1450 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1452 * Extract the running_time from the async_done message.
1457 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1459 GstStructure *structure;
1461 g_return_if_fail (GST_IS_MESSAGE (message));
1462 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1464 structure = GST_MESSAGE_STRUCTURE (message);
1467 g_value_get_uint64 (gst_structure_id_get_value (structure,
1468 GST_QUARK (RUNNING_TIME)));
1472 * gst_message_parse_request_state:
1473 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1474 * @state: (out) (allow-none): Result location for the requested state or %NULL
1476 * Extract the requested state from the request_state message.
1481 gst_message_parse_request_state (GstMessage * message, GstState * state)
1483 GstStructure *structure;
1485 g_return_if_fail (GST_IS_MESSAGE (message));
1486 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1488 structure = GST_MESSAGE_STRUCTURE (message);
1491 g_value_get_enum (gst_structure_id_get_value (structure,
1492 GST_QUARK (NEW_STATE)));
1496 * gst_message_new_stream_status:
1497 * @src: The object originating the message.
1498 * @type: The stream status type.
1499 * @owner: (transfer none): the owner element of @src.
1501 * Create a new stream status message. This message is posted when a streaming
1502 * thread is created/destroyed or when the state changed.
1504 * Returns: (transfer full): the new stream status message.
1509 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1512 GstMessage *message;
1513 GstStructure *structure;
1515 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1516 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1517 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1518 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1524 * gst_message_parse_stream_status:
1525 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1526 * @type: (out): A pointer to hold the status type
1527 * @owner: (out) (transfer none): The owner element of the message source
1529 * Extracts the stream status type and owner the GstMessage. The returned
1530 * owner remains valid for as long as the reference to @message is valid and
1531 * should thus not be unreffed.
1536 gst_message_parse_stream_status (GstMessage * message,
1537 GstStreamStatusType * type, GstElement ** owner)
1539 const GValue *owner_gvalue;
1540 GstStructure *structure;
1542 g_return_if_fail (GST_IS_MESSAGE (message));
1543 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1545 structure = GST_MESSAGE_STRUCTURE (message);
1546 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1547 g_return_if_fail (owner_gvalue != NULL);
1550 *type = (GstStreamStatusType)
1551 g_value_get_enum (gst_structure_id_get_value (structure,
1554 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1558 * gst_message_set_stream_status_object:
1559 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1560 * @object: the object controlling the streaming
1562 * Configures the object handling the streaming thread. This is usually a
1563 * GstTask object but other objects might be added in the future.
1566 gst_message_set_stream_status_object (GstMessage * message,
1567 const GValue * object)
1569 GstStructure *structure;
1571 g_return_if_fail (GST_IS_MESSAGE (message));
1572 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1574 structure = GST_MESSAGE_STRUCTURE (message);
1575 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1579 * gst_message_get_stream_status_object:
1580 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1582 * Extracts the object managing the streaming thread from @message.
1584 * Returns: a GValue containing the object that manages the streaming thread.
1585 * This object is usually of type GstTask but other types can be added in the
1586 * future. The object remains valid as long as @message is valid.
1589 gst_message_get_stream_status_object (GstMessage * message)
1591 const GValue *result;
1592 GstStructure *structure;
1594 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1595 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1598 structure = GST_MESSAGE_STRUCTURE (message);
1599 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1605 * gst_message_new_step_done:
1606 * @src: The object originating the message.
1607 * @format: the format of @amount
1608 * @amount: the amount of stepped data
1609 * @rate: the rate of the stepped amount
1610 * @flush: is this an flushing step
1611 * @intermediate: is this an intermediate step
1612 * @duration: the duration of the data
1613 * @eos: the step caused EOS
1615 * This message is posted by elements when they complete a part, when @intermediate set
1616 * to %TRUE, or a complete step operation.
1618 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1619 * @amount of media in format @format.
1621 * Returns: (transfer full): the new step_done message.
1626 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1627 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1630 GstMessage *message;
1631 GstStructure *structure;
1633 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1634 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1635 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1636 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1637 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1638 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1639 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1640 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1641 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1647 * gst_message_parse_step_done:
1648 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1649 * @format: (out) (allow-none): result location for the format
1650 * @amount: (out) (allow-none): result location for the amount
1651 * @rate: (out) (allow-none): result location for the rate
1652 * @flush: (out) (allow-none): result location for the flush flag
1653 * @intermediate: (out) (allow-none): result location for the intermediate flag
1654 * @duration: (out) (allow-none): result location for the duration
1655 * @eos: (out) (allow-none): result location for the EOS flag
1657 * Extract the values the step_done message.
1662 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1663 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1664 guint64 * duration, gboolean * eos)
1666 GstStructure *structure;
1668 g_return_if_fail (GST_IS_MESSAGE (message));
1669 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1671 structure = GST_MESSAGE_STRUCTURE (message);
1672 gst_structure_id_get (structure,
1673 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1674 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1675 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1676 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1677 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1678 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1679 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1683 * gst_message_new_step_start:
1684 * @src: The object originating the message.
1685 * @active: if the step is active or queued
1686 * @format: the format of @amount
1687 * @amount: the amount of stepped data
1688 * @rate: the rate of the stepped amount
1689 * @flush: is this an flushing step
1690 * @intermediate: is this an intermediate step
1692 * This message is posted by elements when they accept or activate a new step
1693 * event for @amount in @format.
1695 * @active is set to %FALSE when the element accepted the new step event and has
1696 * queued it for execution in the streaming threads.
1698 * @active is set to %TRUE when the element has activated the step operation and
1699 * is now ready to start executing the step in the streaming thread. After this
1700 * message is emitted, the application can queue a new step operation in the
1703 * Returns: (transfer full): The new step_start message.
1708 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1709 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1711 GstMessage *message;
1712 GstStructure *structure;
1714 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1715 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1716 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1717 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1718 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1719 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1720 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1721 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1727 * gst_message_parse_step_start:
1728 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1729 * @active: (out) (allow-none): result location for the active flag
1730 * @format: (out) (allow-none): result location for the format
1731 * @amount: (out) (allow-none): result location for the amount
1732 * @rate: (out) (allow-none): result location for the rate
1733 * @flush: (out) (allow-none): result location for the flush flag
1734 * @intermediate: (out) (allow-none): result location for the intermediate flag
1736 * Extract the values from step_start message.
1741 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1742 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1743 gboolean * intermediate)
1745 GstStructure *structure;
1747 g_return_if_fail (GST_IS_MESSAGE (message));
1748 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1750 structure = GST_MESSAGE_STRUCTURE (message);
1751 gst_structure_id_get (structure,
1752 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1753 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1754 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1755 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1756 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1757 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1761 * gst_message_new_qos:
1762 * @src: The object originating the message.
1763 * @live: if the message was generated by a live element
1764 * @running_time: the running time of the buffer that generated the message
1765 * @stream_time: the stream time of the buffer that generated the message
1766 * @timestamp: the timestamps of the buffer that generated the message
1767 * @duration: the duration of the buffer that generated the message
1769 * A QOS message is posted on the bus whenever an element decides to drop a
1770 * buffer because of QoS reasons or whenever it changes its processing strategy
1771 * because of QoS reasons (quality adjustments such as processing at lower
1774 * This message can be posted by an element that performs synchronisation against the
1775 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1776 * events received from a downstream element (!live).
1778 * @running_time, @stream_time, @timestamp, @duration should be set to the
1779 * respective running-time, stream-time, timestamp and duration of the (dropped)
1780 * buffer that generated the QoS event. Values can be left to
1781 * GST_CLOCK_TIME_NONE when unknown.
1783 * Returns: (transfer full): The new qos message.
1788 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1789 guint64 stream_time, guint64 timestamp, guint64 duration)
1791 GstMessage *message;
1792 GstStructure *structure;
1794 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1795 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1796 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1797 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1798 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1799 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1800 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1801 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1802 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1803 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1804 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1805 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1806 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1812 * gst_message_set_qos_values:
1813 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1814 * @jitter: The difference of the running-time against the deadline.
1815 * @proportion: Long term prediction of the ideal rate relative to normal rate
1816 * to get optimal quality.
1817 * @quality: An element dependent integer value that specifies the current
1818 * quality level of the element. The default maximum quality is 1000000.
1820 * Set the QoS values that have been calculated/analysed from the QoS data
1825 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1826 gdouble proportion, gint quality)
1828 GstStructure *structure;
1830 g_return_if_fail (GST_IS_MESSAGE (message));
1831 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1833 structure = GST_MESSAGE_STRUCTURE (message);
1834 gst_structure_id_set (structure,
1835 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1836 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1837 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1841 * gst_message_set_qos_stats:
1842 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1843 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1844 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1845 * will likely use GST_FORMAT_DEFAULT (samples).
1846 * @processed: Total number of units correctly processed since the last state
1847 * change to READY or a flushing operation.
1848 * @dropped: Total number of units dropped since the last state change to READY
1849 * or a flushing operation.
1851 * Set the QoS stats representing the history of the current continuous pipeline
1854 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1855 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1860 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1861 guint64 processed, guint64 dropped)
1863 GstStructure *structure;
1865 g_return_if_fail (GST_IS_MESSAGE (message));
1866 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1868 structure = GST_MESSAGE_STRUCTURE (message);
1869 gst_structure_id_set (structure,
1870 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1871 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1872 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1876 * gst_message_parse_qos:
1877 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1878 * @live: (out) (allow-none): if the message was generated by a live element
1879 * @running_time: (out) (allow-none): the running time of the buffer that
1880 * generated the message
1881 * @stream_time: (out) (allow-none): the stream time of the buffer that
1882 * generated the message
1883 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1884 * generated the message
1885 * @duration: (out) (allow-none): the duration of the buffer that
1886 * generated the message
1888 * Extract the timestamps and live status from the QoS message.
1890 * The returned values give the running_time, stream_time, timestamp and
1891 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1897 gst_message_parse_qos (GstMessage * message, gboolean * live,
1898 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1901 GstStructure *structure;
1903 g_return_if_fail (GST_IS_MESSAGE (message));
1904 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1906 structure = GST_MESSAGE_STRUCTURE (message);
1907 gst_structure_id_get (structure,
1908 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1909 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1910 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1911 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1912 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1916 * gst_message_parse_qos_values:
1917 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1918 * @jitter: (out) (allow-none): The difference of the running-time against
1920 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1921 * relative to normal rate to get optimal quality.
1922 * @quality: (out) (allow-none): An element dependent integer value that
1923 * specifies the current quality level of the element. The default
1924 * maximum quality is 1000000.
1926 * Extract the QoS values that have been calculated/analysed from the QoS data
1931 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1932 gdouble * proportion, gint * quality)
1934 GstStructure *structure;
1936 g_return_if_fail (GST_IS_MESSAGE (message));
1937 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1939 structure = GST_MESSAGE_STRUCTURE (message);
1940 gst_structure_id_get (structure,
1941 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1942 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1943 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1947 * gst_message_parse_qos_stats:
1948 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1949 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1950 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1951 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1953 * @processed: (out) (allow-none): Total number of units correctly processed
1954 * since the last state change to READY or a flushing operation.
1955 * @dropped: (out) (allow-none): Total number of units dropped since the last
1956 * state change to READY or a flushing operation.
1958 * Extract the QoS stats representing the history of the current continuous
1959 * pipeline playback period.
1961 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1962 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1967 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1968 guint64 * processed, guint64 * dropped)
1970 GstStructure *structure;
1972 g_return_if_fail (GST_IS_MESSAGE (message));
1973 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1975 structure = GST_MESSAGE_STRUCTURE (message);
1976 gst_structure_id_get (structure,
1977 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1978 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1979 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1983 * gst_message_new_progress:
1984 * @src: The object originating the message.
1985 * @type: a #GstProgressType
1986 * @code: a progress code
1987 * @text: free, user visible text describing the progress
1989 * Progress messages are posted by elements when they use an asynchronous task
1990 * to perform actions triggered by a state change.
1992 * @code contains a well defined string describing the action.
1993 * @test should contain a user visible string detailing the current action.
1995 * Returns: (transfer full): The new qos message.
1998 gst_message_new_progress (GstObject * src, GstProgressType type,
1999 const gchar * code, const gchar * text)
2001 GstMessage *message;
2002 GstStructure *structure;
2003 gint percent = 100, timeout = -1;
2005 g_return_val_if_fail (code != NULL, NULL);
2006 g_return_val_if_fail (text != NULL, NULL);
2008 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2011 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2012 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2013 GST_QUARK (CODE), G_TYPE_STRING, code,
2014 GST_QUARK (TEXT), G_TYPE_STRING, text,
2015 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2016 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2017 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2023 * gst_message_parse_progress:
2024 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2025 * @type: (out) (allow-none): location for the type
2026 * @code: (out) (allow-none) (transfer full): location for the code
2027 * @text: (out) (allow-none) (transfer full): location for the text
2029 * Parses the progress @type, @code and @text.
2032 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2033 gchar ** code, gchar ** text)
2035 GstStructure *structure;
2037 g_return_if_fail (GST_IS_MESSAGE (message));
2038 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2040 structure = GST_MESSAGE_STRUCTURE (message);
2041 gst_structure_id_get (structure,
2042 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2043 GST_QUARK (CODE), G_TYPE_STRING, code,
2044 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2048 * gst_message_new_toc:
2049 * @src: the object originating the message.
2050 * @toc: (transfer none): #GstToc structure for the message.
2051 * @updated: whether TOC was updated or not.
2053 * Create a new TOC message. The message is posted by elements
2054 * that discovered or updated a TOC.
2056 * Returns: (transfer full): a new TOC message.
2061 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2063 GstStructure *toc_struct;
2065 g_return_val_if_fail (toc != NULL, NULL);
2067 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2068 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2069 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2071 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2075 * gst_message_parse_toc:
2076 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2077 * @toc: (out) (transfer full): return location for the TOC.
2078 * @updated: (out): return location for the updated flag.
2080 * Extract the TOC from the #GstMessage. The TOC returned in the
2081 * output argument is a copy; the caller must free it with
2082 * gst_toc_unref() when done.
2087 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2089 g_return_if_fail (GST_IS_MESSAGE (message));
2090 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2091 g_return_if_fail (toc != NULL);
2093 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2094 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2095 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2099 * gst_message_new_reset_time:
2100 * @src: (transfer none) (allow-none): The object originating the message.
2101 * @running_time: the requested running-time
2103 * This message is posted when the pipeline running-time should be reset to
2104 * @running_time, like after a flushing seek.
2106 * Returns: (transfer full): The new reset_time message.
2111 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2113 GstMessage *message;
2114 GstStructure *structure;
2116 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2117 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2118 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2124 * gst_message_parse_reset_time:
2125 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2126 * @running_time: (out) (allow-none): Result location for the running_time or
2129 * Extract the running-time from the RESET_TIME message.
2134 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2136 GstStructure *structure;
2138 g_return_if_fail (GST_IS_MESSAGE (message));
2139 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2141 structure = GST_MESSAGE_STRUCTURE (message);
2144 g_value_get_uint64 (gst_structure_id_get_value (structure,
2145 GST_QUARK (RUNNING_TIME)));
2149 * gst_message_new_stream_start:
2150 * @src: (transfer none) (allow-none): The object originating the message.
2152 * Create a new stream_start message. This message is generated and posted in
2153 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2154 * message to the application if all sinks have posted an STREAM_START message.
2156 * Returns: (transfer full): The new stream_start message.
2161 gst_message_new_stream_start (GstObject * src)
2163 GstMessage *message;
2166 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2167 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2174 * gst_message_set_group_id:
2175 * @message: the message
2176 * @group_id: the group id
2178 * Sets the group id on the stream-start message.
2180 * All streams that have the same group id are supposed to be played
2181 * together, i.e. all streams inside a container file should have the
2182 * same group id but different stream ids. The group id should change
2183 * each time the stream is started, resulting in different group ids
2184 * each time a file is played for example.
2191 gst_message_set_group_id (GstMessage * message, guint group_id)
2193 GstStructure *structure;
2195 g_return_if_fail (GST_IS_MESSAGE (message));
2196 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2197 g_return_if_fail (gst_message_is_writable (message));
2199 structure = GST_MESSAGE_STRUCTURE (message);
2200 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2205 * gst_message_parse_group_id:
2206 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2207 * @group_id: (out) (allow-none): Result location for the group id or
2210 * Extract the group from the STREAM_START message.
2212 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2219 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2221 GstStructure *structure;
2224 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2225 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2231 structure = GST_MESSAGE_STRUCTURE (message);
2233 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2237 *group_id = g_value_get_uint (v);
2242 * gst_message_new_need_context:
2243 * @src: (transfer none) (allow-none): The object originating the message.
2244 * @context_type: The context type that is needed
2246 * This message is posted when an element needs a specific #GstContext.
2248 * Returns: (transfer full): The new need-context message.
2255 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2257 GstMessage *message;
2258 GstStructure *structure;
2260 g_return_val_if_fail (context_type != NULL, NULL);
2262 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2263 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2264 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2270 * gst_message_parse_context_type:
2271 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2272 * @context_type: (out) (allow-none): the context type, or %NULL
2274 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2276 * Returns: a #gboolean indicating if the parsing succeeded.
2281 gst_message_parse_context_type (GstMessage * message,
2282 const gchar ** context_type)
2284 GstStructure *structure;
2285 const GValue *value;
2287 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2290 structure = GST_MESSAGE_STRUCTURE (message);
2293 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2294 *context_type = g_value_get_string (value);
2301 * gst_message_new_have_context:
2302 * @src: (transfer none) (allow-none): The object originating the message.
2303 * @context: (transfer full): the context
2305 * This message is posted when an element has a new local #GstContext.
2307 * Returns: (transfer full): The new have-context message.
2314 gst_message_new_have_context (GstObject * src, GstContext * context)
2316 GstMessage *message;
2317 GstStructure *structure;
2319 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2320 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2321 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2322 gst_context_unref (context);
2328 * gst_message_parse_have_context:
2329 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2330 * @context: (out) (transfer full) (allow-none): Result location for the
2333 * Extract the context from the HAVE_CONTEXT message.
2340 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2342 g_return_if_fail (GST_IS_MESSAGE (message));
2343 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2346 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2347 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2351 * gst_message_new_device_added:
2352 * @src: The #GstObject that created the message
2353 * @device: (transfer none): The new #GstDevice
2355 * Creates a new device-added message. The device-added message is produced by
2356 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2357 * of monitored devices.
2359 * Returns: a newly allocated #GstMessage
2364 gst_message_new_device_added (GstObject * src, GstDevice * device)
2366 GstMessage *message;
2367 GstStructure *structure;
2369 g_return_val_if_fail (device != NULL, NULL);
2370 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2372 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2373 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2374 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2380 * gst_message_parse_device_added:
2381 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2382 * @device: (out) (allow-none) (transfer none): A location where to store a
2383 * pointer to the new #GstDevice, or %NULL
2385 * Parses a device-added message. The device-added message is produced by
2386 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2387 * of monitored devices.
2392 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2394 g_return_if_fail (GST_IS_MESSAGE (message));
2395 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2398 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2399 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2403 * gst_message_new_device_removed:
2404 * @src: The #GstObject that created the message
2405 * @device: (transfer none): The removed #GstDevice
2407 * Creates a new device-removed message. The device-removed message is produced
2408 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2409 * disappearance of monitored devices.
2411 * Returns: a newly allocated #GstMessage
2416 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2418 GstMessage *message;
2419 GstStructure *structure;
2421 g_return_val_if_fail (device != NULL, NULL);
2422 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2424 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2425 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2426 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2432 * gst_message_parse_device_removed:
2433 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2434 * @device: (out) (allow-none) (transfer none): A location where to store a
2435 * pointer to the removed #GstDevice, or %NULL
2437 * Parses a device-removed message. The device-removed message is produced by
2438 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2439 * disappearance of monitored devices.
2444 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2446 g_return_if_fail (GST_IS_MESSAGE (message));
2447 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2450 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2451 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);