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_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1065 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1066 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1067 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1068 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1069 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1073 * gst_message_parse_buffering_stats:
1074 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1075 * @mode: (out) (allow-none): a buffering mode, or %NULL
1076 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1077 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1078 * @buffering_left: (out) (allow-none): amount of buffering time left in
1079 * milliseconds, or %NULL
1081 * Extracts the buffering stats values from @message.
1084 gst_message_parse_buffering_stats (GstMessage * message,
1085 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1086 gint64 * buffering_left)
1088 GstStructure *structure;
1090 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1092 structure = GST_MESSAGE_STRUCTURE (message);
1094 *mode = (GstBufferingMode)
1095 g_value_get_enum (gst_structure_id_get_value (structure,
1096 GST_QUARK (BUFFERING_MODE)));
1098 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1099 GST_QUARK (AVG_IN_RATE)));
1101 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1102 GST_QUARK (AVG_OUT_RATE)));
1105 g_value_get_int64 (gst_structure_id_get_value (structure,
1106 GST_QUARK (BUFFERING_LEFT)));
1110 * gst_message_parse_state_changed:
1111 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1112 * @oldstate: (out) (allow-none): the previous state, or %NULL
1113 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1114 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1116 * Extracts the old and new states from the GstMessage.
1118 * Typical usage of this function might be:
1121 * switch (GST_MESSAGE_TYPE (msg)) {
1122 * case GST_MESSAGE_STATE_CHANGED: {
1123 * GstState old_state, new_state;
1125 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1126 * g_print ("Element %s changed state from %s to %s.\n",
1127 * GST_OBJECT_NAME (msg->src),
1128 * gst_element_state_get_name (old_state),
1129 * gst_element_state_get_name (new_state));
1140 gst_message_parse_state_changed (GstMessage * message,
1141 GstState * oldstate, GstState * newstate, GstState * pending)
1143 GstStructure *structure;
1145 g_return_if_fail (GST_IS_MESSAGE (message));
1146 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1148 structure = GST_MESSAGE_STRUCTURE (message);
1150 *oldstate = (GstState)
1151 g_value_get_enum (gst_structure_id_get_value (structure,
1152 GST_QUARK (OLD_STATE)));
1154 *newstate = (GstState)
1155 g_value_get_enum (gst_structure_id_get_value (structure,
1156 GST_QUARK (NEW_STATE)));
1158 *pending = (GstState)
1159 g_value_get_enum (gst_structure_id_get_value (structure,
1160 GST_QUARK (PENDING_STATE)));
1164 * gst_message_parse_clock_provide:
1165 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1166 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1168 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1170 * Extracts the clock and ready flag from the GstMessage.
1171 * The clock object returned remains valid until the message is freed.
1176 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1179 const GValue *clock_gvalue;
1180 GstStructure *structure;
1182 g_return_if_fail (GST_IS_MESSAGE (message));
1183 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1185 structure = GST_MESSAGE_STRUCTURE (message);
1186 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1187 g_return_if_fail (clock_gvalue != NULL);
1188 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1192 g_value_get_boolean (gst_structure_id_get_value (structure,
1193 GST_QUARK (READY)));
1195 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1199 * gst_message_parse_clock_lost:
1200 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1201 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1203 * Extracts the lost clock from the GstMessage.
1204 * The clock object returned remains valid until the message is freed.
1209 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1211 const GValue *clock_gvalue;
1212 GstStructure *structure;
1214 g_return_if_fail (GST_IS_MESSAGE (message));
1215 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1217 structure = GST_MESSAGE_STRUCTURE (message);
1218 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1219 g_return_if_fail (clock_gvalue != NULL);
1220 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1223 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1227 * gst_message_parse_new_clock:
1228 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1229 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1232 * Extracts the new clock from the GstMessage.
1233 * The clock object returned remains valid until the message is freed.
1238 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1240 const GValue *clock_gvalue;
1241 GstStructure *structure;
1243 g_return_if_fail (GST_IS_MESSAGE (message));
1244 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1246 structure = GST_MESSAGE_STRUCTURE (message);
1247 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1248 g_return_if_fail (clock_gvalue != NULL);
1249 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1252 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1256 * gst_message_parse_structure_change:
1257 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1258 * @type: (out): A pointer to hold the change type
1259 * @owner: (out) (allow-none) (transfer none): The owner element of the
1261 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1262 * progress or has been completed
1264 * Extracts the change type and completion status from the GstMessage.
1269 gst_message_parse_structure_change (GstMessage * message,
1270 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1272 const GValue *owner_gvalue;
1273 GstStructure *structure;
1275 g_return_if_fail (GST_IS_MESSAGE (message));
1276 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1278 structure = GST_MESSAGE_STRUCTURE (message);
1279 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1280 g_return_if_fail (owner_gvalue != NULL);
1281 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1284 *type = (GstStructureChangeType)
1285 g_value_get_enum (gst_structure_id_get_value (structure,
1288 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1291 g_value_get_boolean (gst_structure_id_get_value (structure,
1296 * gst_message_parse_error:
1297 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1298 * @gerror: (out) (allow-none) (transfer full): location for the GError
1299 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1302 * Extracts the GError and debug string from the GstMessage. The values returned
1303 * in the output arguments are copies; the caller must free them when done.
1305 * Typical usage of this function might be:
1308 * switch (GST_MESSAGE_TYPE (msg)) {
1309 * case GST_MESSAGE_ERROR: {
1310 * GError *err = NULL;
1311 * gchar *dbg_info = NULL;
1313 * gst_message_parse_error (msg, &err, &dbg_info);
1314 * g_printerr ("ERROR from element %s: %s\n",
1315 * GST_OBJECT_NAME (msg->src), err->message);
1316 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1317 * g_error_free (err);
1318 * g_free (dbg_info);
1329 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1331 g_return_if_fail (GST_IS_MESSAGE (message));
1332 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1334 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1335 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1336 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1340 * gst_message_parse_warning:
1341 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1342 * @gerror: (out) (allow-none) (transfer full): location for the GError
1343 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1346 * Extracts the GError and debug string from the GstMessage. The values returned
1347 * in the output arguments are copies; the caller must free them when done.
1352 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1355 g_return_if_fail (GST_IS_MESSAGE (message));
1356 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1358 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1359 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1360 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1364 * gst_message_parse_info:
1365 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1366 * @gerror: (out) (allow-none) (transfer full): location for the GError
1367 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1370 * Extracts the GError and debug string from the GstMessage. The values returned
1371 * in the output arguments are copies; the caller must free them when done.
1376 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1378 g_return_if_fail (GST_IS_MESSAGE (message));
1379 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1381 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1382 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1383 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1387 * gst_message_parse_segment_start:
1388 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1389 * @format: (out) (allow-none): Result location for the format, or %NULL
1390 * @position: (out) (allow-none): Result location for the position, or %NULL
1392 * Extracts the position and format from the segment start message.
1397 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1400 GstStructure *structure;
1402 g_return_if_fail (GST_IS_MESSAGE (message));
1403 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1405 structure = GST_MESSAGE_STRUCTURE (message);
1407 *format = (GstFormat)
1408 g_value_get_enum (gst_structure_id_get_value (structure,
1409 GST_QUARK (FORMAT)));
1412 g_value_get_int64 (gst_structure_id_get_value (structure,
1413 GST_QUARK (POSITION)));
1417 * gst_message_parse_segment_done:
1418 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1419 * @format: (out) (allow-none): Result location for the format, or %NULL
1420 * @position: (out) (allow-none): Result location for the position, or %NULL
1422 * Extracts the position and format from the segment done message.
1427 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1430 GstStructure *structure;
1432 g_return_if_fail (GST_IS_MESSAGE (message));
1433 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1435 structure = GST_MESSAGE_STRUCTURE (message);
1437 *format = (GstFormat)
1438 g_value_get_enum (gst_structure_id_get_value (structure,
1439 GST_QUARK (FORMAT)));
1442 g_value_get_int64 (gst_structure_id_get_value (structure,
1443 GST_QUARK (POSITION)));
1447 * gst_message_parse_async_done:
1448 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1449 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1451 * Extract the running_time from the async_done message.
1456 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1458 GstStructure *structure;
1460 g_return_if_fail (GST_IS_MESSAGE (message));
1461 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1463 structure = GST_MESSAGE_STRUCTURE (message);
1466 g_value_get_uint64 (gst_structure_id_get_value (structure,
1467 GST_QUARK (RUNNING_TIME)));
1471 * gst_message_parse_request_state:
1472 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1473 * @state: (out) (allow-none): Result location for the requested state or %NULL
1475 * Extract the requested state from the request_state message.
1480 gst_message_parse_request_state (GstMessage * message, GstState * state)
1482 GstStructure *structure;
1484 g_return_if_fail (GST_IS_MESSAGE (message));
1485 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1487 structure = GST_MESSAGE_STRUCTURE (message);
1490 g_value_get_enum (gst_structure_id_get_value (structure,
1491 GST_QUARK (NEW_STATE)));
1495 * gst_message_new_stream_status:
1496 * @src: The object originating the message.
1497 * @type: The stream status type.
1498 * @owner: (transfer none): the owner element of @src.
1500 * Create a new stream status message. This message is posted when a streaming
1501 * thread is created/destroyed or when the state changed.
1503 * Returns: (transfer full): the new stream status message.
1508 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1511 GstMessage *message;
1512 GstStructure *structure;
1514 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1515 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1516 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1517 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1523 * gst_message_parse_stream_status:
1524 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1525 * @type: (out): A pointer to hold the status type
1526 * @owner: (out) (transfer none): The owner element of the message source
1528 * Extracts the stream status type and owner the GstMessage. The returned
1529 * owner remains valid for as long as the reference to @message is valid and
1530 * should thus not be unreffed.
1535 gst_message_parse_stream_status (GstMessage * message,
1536 GstStreamStatusType * type, GstElement ** owner)
1538 const GValue *owner_gvalue;
1539 GstStructure *structure;
1541 g_return_if_fail (GST_IS_MESSAGE (message));
1542 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1544 structure = GST_MESSAGE_STRUCTURE (message);
1545 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1546 g_return_if_fail (owner_gvalue != NULL);
1549 *type = (GstStreamStatusType)
1550 g_value_get_enum (gst_structure_id_get_value (structure,
1553 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1557 * gst_message_set_stream_status_object:
1558 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1559 * @object: the object controlling the streaming
1561 * Configures the object handling the streaming thread. This is usually a
1562 * GstTask object but other objects might be added in the future.
1565 gst_message_set_stream_status_object (GstMessage * message,
1566 const GValue * object)
1568 GstStructure *structure;
1570 g_return_if_fail (GST_IS_MESSAGE (message));
1571 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1573 structure = GST_MESSAGE_STRUCTURE (message);
1574 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1578 * gst_message_get_stream_status_object:
1579 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1581 * Extracts the object managing the streaming thread from @message.
1583 * Returns: a GValue containing the object that manages the streaming thread.
1584 * This object is usually of type GstTask but other types can be added in the
1585 * future. The object remains valid as long as @message is valid.
1588 gst_message_get_stream_status_object (GstMessage * message)
1590 const GValue *result;
1591 GstStructure *structure;
1593 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1594 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1597 structure = GST_MESSAGE_STRUCTURE (message);
1598 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1604 * gst_message_new_step_done:
1605 * @src: The object originating the message.
1606 * @format: the format of @amount
1607 * @amount: the amount of stepped data
1608 * @rate: the rate of the stepped amount
1609 * @flush: is this an flushing step
1610 * @intermediate: is this an intermediate step
1611 * @duration: the duration of the data
1612 * @eos: the step caused EOS
1614 * This message is posted by elements when they complete a part, when @intermediate set
1615 * to %TRUE, or a complete step operation.
1617 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1618 * @amount of media in format @format.
1620 * Returns: (transfer full): the new step_done message.
1625 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1626 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1629 GstMessage *message;
1630 GstStructure *structure;
1632 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1633 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1634 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1635 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1636 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1637 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1638 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1639 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1640 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1646 * gst_message_parse_step_done:
1647 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1648 * @format: (out) (allow-none): result location for the format
1649 * @amount: (out) (allow-none): result location for the amount
1650 * @rate: (out) (allow-none): result location for the rate
1651 * @flush: (out) (allow-none): result location for the flush flag
1652 * @intermediate: (out) (allow-none): result location for the intermediate flag
1653 * @duration: (out) (allow-none): result location for the duration
1654 * @eos: (out) (allow-none): result location for the EOS flag
1656 * Extract the values the step_done message.
1661 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1662 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1663 guint64 * duration, gboolean * eos)
1665 GstStructure *structure;
1667 g_return_if_fail (GST_IS_MESSAGE (message));
1668 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1670 structure = GST_MESSAGE_STRUCTURE (message);
1671 gst_structure_id_get (structure,
1672 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1673 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1674 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1675 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1676 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1677 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1678 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1682 * gst_message_new_step_start:
1683 * @src: The object originating the message.
1684 * @active: if the step is active or queued
1685 * @format: the format of @amount
1686 * @amount: the amount of stepped data
1687 * @rate: the rate of the stepped amount
1688 * @flush: is this an flushing step
1689 * @intermediate: is this an intermediate step
1691 * This message is posted by elements when they accept or activate a new step
1692 * event for @amount in @format.
1694 * @active is set to %FALSE when the element accepted the new step event and has
1695 * queued it for execution in the streaming threads.
1697 * @active is set to %TRUE when the element has activated the step operation and
1698 * is now ready to start executing the step in the streaming thread. After this
1699 * message is emitted, the application can queue a new step operation in the
1702 * Returns: (transfer full): The new step_start message.
1707 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1708 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1710 GstMessage *message;
1711 GstStructure *structure;
1713 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1714 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1715 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1716 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1717 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1718 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1719 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1720 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1726 * gst_message_parse_step_start:
1727 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1728 * @active: (out) (allow-none): result location for the active flag
1729 * @format: (out) (allow-none): result location for the format
1730 * @amount: (out) (allow-none): result location for the amount
1731 * @rate: (out) (allow-none): result location for the rate
1732 * @flush: (out) (allow-none): result location for the flush flag
1733 * @intermediate: (out) (allow-none): result location for the intermediate flag
1735 * Extract the values from step_start message.
1740 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1741 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1742 gboolean * intermediate)
1744 GstStructure *structure;
1746 g_return_if_fail (GST_IS_MESSAGE (message));
1747 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1749 structure = GST_MESSAGE_STRUCTURE (message);
1750 gst_structure_id_get (structure,
1751 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1752 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1753 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1754 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1755 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1756 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1760 * gst_message_new_qos:
1761 * @src: The object originating the message.
1762 * @live: if the message was generated by a live element
1763 * @running_time: the running time of the buffer that generated the message
1764 * @stream_time: the stream time of the buffer that generated the message
1765 * @timestamp: the timestamps of the buffer that generated the message
1766 * @duration: the duration of the buffer that generated the message
1768 * A QOS message is posted on the bus whenever an element decides to drop a
1769 * buffer because of QoS reasons or whenever it changes its processing strategy
1770 * because of QoS reasons (quality adjustments such as processing at lower
1773 * This message can be posted by an element that performs synchronisation against the
1774 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1775 * events received from a downstream element (!live).
1777 * @running_time, @stream_time, @timestamp, @duration should be set to the
1778 * respective running-time, stream-time, timestamp and duration of the (dropped)
1779 * buffer that generated the QoS event. Values can be left to
1780 * GST_CLOCK_TIME_NONE when unknown.
1782 * Returns: (transfer full): The new qos message.
1787 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1788 guint64 stream_time, guint64 timestamp, guint64 duration)
1790 GstMessage *message;
1791 GstStructure *structure;
1793 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1794 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1795 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1796 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1797 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1798 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1799 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1800 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1801 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1802 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1803 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1804 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1805 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1811 * gst_message_set_qos_values:
1812 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1813 * @jitter: The difference of the running-time against the deadline.
1814 * @proportion: Long term prediction of the ideal rate relative to normal rate
1815 * to get optimal quality.
1816 * @quality: An element dependent integer value that specifies the current
1817 * quality level of the element. The default maximum quality is 1000000.
1819 * Set the QoS values that have been calculated/analysed from the QoS data
1824 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1825 gdouble proportion, gint quality)
1827 GstStructure *structure;
1829 g_return_if_fail (GST_IS_MESSAGE (message));
1830 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1832 structure = GST_MESSAGE_STRUCTURE (message);
1833 gst_structure_id_set (structure,
1834 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1835 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1836 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1840 * gst_message_set_qos_stats:
1841 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1842 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1843 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1844 * will likely use GST_FORMAT_DEFAULT (samples).
1845 * @processed: Total number of units correctly processed since the last state
1846 * change to READY or a flushing operation.
1847 * @dropped: Total number of units dropped since the last state change to READY
1848 * or a flushing operation.
1850 * Set the QoS stats representing the history of the current continuous pipeline
1853 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1854 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1859 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1860 guint64 processed, guint64 dropped)
1862 GstStructure *structure;
1864 g_return_if_fail (GST_IS_MESSAGE (message));
1865 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1867 structure = GST_MESSAGE_STRUCTURE (message);
1868 gst_structure_id_set (structure,
1869 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1870 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1871 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1875 * gst_message_parse_qos:
1876 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1877 * @live: (out) (allow-none): if the message was generated by a live element
1878 * @running_time: (out) (allow-none): the running time of the buffer that
1879 * generated the message
1880 * @stream_time: (out) (allow-none): the stream time of the buffer that
1881 * generated the message
1882 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1883 * generated the message
1884 * @duration: (out) (allow-none): the duration of the buffer that
1885 * generated the message
1887 * Extract the timestamps and live status from the QoS message.
1889 * The returned values give the running_time, stream_time, timestamp and
1890 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1896 gst_message_parse_qos (GstMessage * message, gboolean * live,
1897 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1900 GstStructure *structure;
1902 g_return_if_fail (GST_IS_MESSAGE (message));
1903 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1905 structure = GST_MESSAGE_STRUCTURE (message);
1906 gst_structure_id_get (structure,
1907 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1908 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1909 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1910 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1911 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1915 * gst_message_parse_qos_values:
1916 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1917 * @jitter: (out) (allow-none): The difference of the running-time against
1919 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1920 * relative to normal rate to get optimal quality.
1921 * @quality: (out) (allow-none): An element dependent integer value that
1922 * specifies the current quality level of the element. The default
1923 * maximum quality is 1000000.
1925 * Extract the QoS values that have been calculated/analysed from the QoS data
1930 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1931 gdouble * proportion, gint * quality)
1933 GstStructure *structure;
1935 g_return_if_fail (GST_IS_MESSAGE (message));
1936 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1938 structure = GST_MESSAGE_STRUCTURE (message);
1939 gst_structure_id_get (structure,
1940 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1941 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1942 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1946 * gst_message_parse_qos_stats:
1947 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1948 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1949 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1950 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1952 * @processed: (out) (allow-none): Total number of units correctly processed
1953 * since the last state change to READY or a flushing operation.
1954 * @dropped: (out) (allow-none): Total number of units dropped since the last
1955 * state change to READY or a flushing operation.
1957 * Extract the QoS stats representing the history of the current continuous
1958 * pipeline playback period.
1960 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1961 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1966 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1967 guint64 * processed, guint64 * dropped)
1969 GstStructure *structure;
1971 g_return_if_fail (GST_IS_MESSAGE (message));
1972 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1974 structure = GST_MESSAGE_STRUCTURE (message);
1975 gst_structure_id_get (structure,
1976 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1977 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1978 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1982 * gst_message_new_progress:
1983 * @src: The object originating the message.
1984 * @type: a #GstProgressType
1985 * @code: a progress code
1986 * @text: free, user visible text describing the progress
1988 * Progress messages are posted by elements when they use an asynchronous task
1989 * to perform actions triggered by a state change.
1991 * @code contains a well defined string describing the action.
1992 * @test should contain a user visible string detailing the current action.
1994 * Returns: (transfer full): The new qos message.
1997 gst_message_new_progress (GstObject * src, GstProgressType type,
1998 const gchar * code, const gchar * text)
2000 GstMessage *message;
2001 GstStructure *structure;
2002 gint percent = 100, timeout = -1;
2004 g_return_val_if_fail (code != NULL, NULL);
2005 g_return_val_if_fail (text != NULL, NULL);
2007 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2010 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2011 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2012 GST_QUARK (CODE), G_TYPE_STRING, code,
2013 GST_QUARK (TEXT), G_TYPE_STRING, text,
2014 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2015 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2016 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2022 * gst_message_parse_progress:
2023 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2024 * @type: (out) (allow-none): location for the type
2025 * @code: (out) (allow-none) (transfer full): location for the code
2026 * @text: (out) (allow-none) (transfer full): location for the text
2028 * Parses the progress @type, @code and @text.
2031 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2032 gchar ** code, gchar ** text)
2034 GstStructure *structure;
2036 g_return_if_fail (GST_IS_MESSAGE (message));
2037 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2039 structure = GST_MESSAGE_STRUCTURE (message);
2040 gst_structure_id_get (structure,
2041 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2042 GST_QUARK (CODE), G_TYPE_STRING, code,
2043 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2047 * gst_message_new_toc:
2048 * @src: the object originating the message.
2049 * @toc: (transfer none): #GstToc structure for the message.
2050 * @updated: whether TOC was updated or not.
2052 * Create a new TOC message. The message is posted by elements
2053 * that discovered or updated a TOC.
2055 * Returns: (transfer full): a new TOC message.
2060 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2062 GstStructure *toc_struct;
2064 g_return_val_if_fail (toc != NULL, NULL);
2066 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2067 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2068 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2070 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2074 * gst_message_parse_toc:
2075 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2076 * @toc: (out) (transfer full): return location for the TOC.
2077 * @updated: (out): return location for the updated flag.
2079 * Extract the TOC from the #GstMessage. The TOC returned in the
2080 * output argument is a copy; the caller must free it with
2081 * gst_toc_unref() when done.
2086 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2088 g_return_if_fail (GST_IS_MESSAGE (message));
2089 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2090 g_return_if_fail (toc != NULL);
2092 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2093 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2094 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2098 * gst_message_new_reset_time:
2099 * @src: (transfer none) (allow-none): The object originating the message.
2100 * @running_time: the requested running-time
2102 * This message is posted when the pipeline running-time should be reset to
2103 * @running_time, like after a flushing seek.
2105 * Returns: (transfer full): The new reset_time message.
2110 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2112 GstMessage *message;
2113 GstStructure *structure;
2115 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2116 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2117 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2123 * gst_message_parse_reset_time:
2124 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2125 * @running_time: (out) (allow-none): Result location for the running_time or
2128 * Extract the running-time from the RESET_TIME message.
2133 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2135 GstStructure *structure;
2137 g_return_if_fail (GST_IS_MESSAGE (message));
2138 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2140 structure = GST_MESSAGE_STRUCTURE (message);
2143 g_value_get_uint64 (gst_structure_id_get_value (structure,
2144 GST_QUARK (RUNNING_TIME)));
2148 * gst_message_new_stream_start:
2149 * @src: (transfer none) (allow-none): The object originating the message.
2151 * Create a new stream_start message. This message is generated and posted in
2152 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2153 * message to the application if all sinks have posted an STREAM_START message.
2155 * Returns: (transfer full): The new stream_start message.
2160 gst_message_new_stream_start (GstObject * src)
2162 GstMessage *message;
2165 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2166 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2173 * gst_message_set_group_id:
2174 * @message: the message
2175 * @group_id: the group id
2177 * Sets the group id on the stream-start message.
2179 * All streams that have the same group id are supposed to be played
2180 * together, i.e. all streams inside a container file should have the
2181 * same group id but different stream ids. The group id should change
2182 * each time the stream is started, resulting in different group ids
2183 * each time a file is played for example.
2190 gst_message_set_group_id (GstMessage * message, guint group_id)
2192 GstStructure *structure;
2194 g_return_if_fail (GST_IS_MESSAGE (message));
2195 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2196 g_return_if_fail (gst_message_is_writable (message));
2198 structure = GST_MESSAGE_STRUCTURE (message);
2199 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2204 * gst_message_parse_group_id:
2205 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2206 * @group_id: (out) (allow-none): Result location for the group id or
2209 * Extract the group from the STREAM_START message.
2211 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2218 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2220 GstStructure *structure;
2223 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2224 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2230 structure = GST_MESSAGE_STRUCTURE (message);
2232 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2236 *group_id = g_value_get_uint (v);
2241 * gst_message_new_need_context:
2242 * @src: (transfer none) (allow-none): The object originating the message.
2243 * @context_type: The context type that is needed
2245 * This message is posted when an element needs a specific #GstContext.
2247 * Returns: (transfer full): The new need-context message.
2254 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2256 GstMessage *message;
2257 GstStructure *structure;
2259 g_return_val_if_fail (context_type != NULL, NULL);
2261 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2262 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2263 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2269 * gst_message_parse_context_type:
2270 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2271 * @context_type: (out) (allow-none): the context type, or %NULL
2273 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2275 * Returns: a #gboolean indicating if the parsing succeeded.
2280 gst_message_parse_context_type (GstMessage * message,
2281 const gchar ** context_type)
2283 GstStructure *structure;
2284 const GValue *value;
2286 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2289 structure = GST_MESSAGE_STRUCTURE (message);
2292 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2293 *context_type = g_value_get_string (value);
2300 * gst_message_new_have_context:
2301 * @src: (transfer none) (allow-none): The object originating the message.
2302 * @context: (transfer full): the context
2304 * This message is posted when an element has a new local #GstContext.
2306 * Returns: (transfer full): The new have-context message.
2313 gst_message_new_have_context (GstObject * src, GstContext * context)
2315 GstMessage *message;
2316 GstStructure *structure;
2318 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2319 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2320 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2321 gst_context_unref (context);
2327 * gst_message_parse_have_context:
2328 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2329 * @context: (out) (transfer full) (allow-none): Result location for the
2332 * Extract the context from the HAVE_CONTEXT message.
2339 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2341 g_return_if_fail (GST_IS_MESSAGE (message));
2342 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2345 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2346 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2350 * gst_message_new_device_added:
2351 * @src: The #GstObject that created the message
2352 * @device: (transfer none): The new #GstDevice
2354 * Creates a new device-added message. The device-added message is produced by
2355 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2356 * of monitored devices.
2358 * Returns: a newly allocated #GstMessage
2363 gst_message_new_device_added (GstObject * src, GstDevice * device)
2365 GstMessage *message;
2366 GstStructure *structure;
2368 g_return_val_if_fail (device != NULL, NULL);
2369 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2371 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2372 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2373 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2379 * gst_message_parse_device_added:
2380 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2381 * @device: (out) (allow-none) (transfer none): A location where to store a
2382 * pointer to the new #GstDevice, or %NULL
2384 * Parses a device-added message. The device-added message is produced by
2385 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2386 * of monitored devices.
2391 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2393 g_return_if_fail (GST_IS_MESSAGE (message));
2394 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2397 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2398 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2402 * gst_message_new_device_removed:
2403 * @src: The #GstObject that created the message
2404 * @device: (transfer none): The removed #GstDevice
2406 * Creates a new device-removed message. The device-removed message is produced
2407 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2408 * disappearance of monitored devices.
2410 * Returns: a newly allocated #GstMessage
2415 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2417 GstMessage *message;
2418 GstStructure *structure;
2420 g_return_val_if_fail (device != NULL, NULL);
2421 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2423 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2424 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2425 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2431 * gst_message_parse_device_removed:
2432 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2433 * @device: (out) (allow-none) (transfer none): A location where to store a
2434 * pointer to the removed #GstDevice, or %NULL
2436 * Parses a device-removed message. The device-removed message is produced by
2437 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2438 * disappearance of monitored devices.
2443 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2445 g_return_if_fail (GST_IS_MESSAGE (message));
2446 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2449 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2450 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);