2 * Copyright (C) 2004 Wim Taymans <wim@fluendo.com>
4 * gstmessage.c: GstMessage subsystem
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
24 * @short_description: Lightweight objects to signal the application of
26 * @see_also: #GstBus, #GstMiniObject, #GstElement
28 * Messages are implemented as a subclass of #GstMiniObject with a generic
29 * #GstStructure as the content. This allows for writing custom messages without
30 * requiring an API change while allowing a wide range of different types
33 * Messages are posted by objects in the pipeline and are passed to the
34 * application using the #GstBus.
36 * The basic use pattern of posting a message on a #GstBus is as follows:
37 * |[<!-- language="C" -->
38 * gst_bus_post (bus, gst_message_new_eos());
41 * A #GstElement usually posts messages on the bus provided by the parent
42 * container using gst_element_post_message().
46 #include "gst_private.h"
47 #include <string.h> /* memcpy */
49 #include "gstenumtypes.h"
51 #include "gstmessage.h"
52 #include "gsttaglist.h"
62 GstStructure *structure;
65 #define GST_MESSAGE_STRUCTURE(m) (((GstMessageImpl *)(m))->structure)
74 static GstMessageQuarks message_quarks[] = {
75 {GST_MESSAGE_UNKNOWN, "unknown", 0},
76 {GST_MESSAGE_EOS, "eos", 0},
77 {GST_MESSAGE_ERROR, "error", 0},
78 {GST_MESSAGE_WARNING, "warning", 0},
79 {GST_MESSAGE_INFO, "info", 0},
80 {GST_MESSAGE_TAG, "tag", 0},
81 {GST_MESSAGE_BUFFERING, "buffering", 0},
82 {GST_MESSAGE_STATE_CHANGED, "state-changed", 0},
83 {GST_MESSAGE_STATE_DIRTY, "state-dirty", 0},
84 {GST_MESSAGE_STEP_DONE, "step-done", 0},
85 {GST_MESSAGE_CLOCK_PROVIDE, "clock-provide", 0},
86 {GST_MESSAGE_CLOCK_LOST, "clock-lost", 0},
87 {GST_MESSAGE_NEW_CLOCK, "new-clock", 0},
88 {GST_MESSAGE_STRUCTURE_CHANGE, "structure-change", 0},
89 {GST_MESSAGE_STREAM_STATUS, "stream-status", 0},
90 {GST_MESSAGE_APPLICATION, "application", 0},
91 {GST_MESSAGE_ELEMENT, "element", 0},
92 {GST_MESSAGE_SEGMENT_START, "segment-start", 0},
93 {GST_MESSAGE_SEGMENT_DONE, "segment-done", 0},
94 {GST_MESSAGE_DURATION_CHANGED, "duration-changed", 0},
95 {GST_MESSAGE_LATENCY, "latency", 0},
96 {GST_MESSAGE_ASYNC_START, "async-start", 0},
97 {GST_MESSAGE_ASYNC_DONE, "async-done", 0},
98 {GST_MESSAGE_REQUEST_STATE, "request-state", 0},
99 {GST_MESSAGE_STEP_START, "step-start", 0},
100 {GST_MESSAGE_QOS, "qos", 0},
101 {GST_MESSAGE_PROGRESS, "progress", 0},
102 {GST_MESSAGE_TOC, "toc", 0},
103 {GST_MESSAGE_RESET_TIME, "reset-time", 0},
104 {GST_MESSAGE_STREAM_START, "stream-start", 0},
105 {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
106 {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
107 {GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
108 {GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
109 {GST_MESSAGE_PROPERTY_NOTIFY, "property-notify", 0},
110 {GST_MESSAGE_STREAM_COLLECTION, "stream-collection", 0},
111 {GST_MESSAGE_STREAMS_SELECTED, "streams-selected", 0},
115 GType _gst_message_type = 0;
116 GST_DEFINE_MINI_OBJECT_TYPE (GstMessage, gst_message);
119 _priv_gst_message_initialize (void)
123 GST_CAT_INFO (GST_CAT_GST_INIT, "init messages");
125 for (i = 0; message_quarks[i].name; i++) {
126 message_quarks[i].quark =
127 g_quark_from_static_string (message_quarks[i].name);
130 _gst_message_type = gst_message_get_type ();
134 * gst_message_type_get_name:
135 * @type: the message type
137 * Get a printable name for the given message type. Do not modify or free.
139 * Returns: a reference to the static name of the message.
142 gst_message_type_get_name (GstMessageType type)
146 for (i = 0; message_quarks[i].name; i++) {
147 if (type == message_quarks[i].type)
148 return message_quarks[i].name;
154 * gst_message_type_to_quark:
155 * @type: the message type
157 * Get the unique quark for the given message type.
159 * Returns: the quark associated with the message type
162 gst_message_type_to_quark (GstMessageType type)
166 for (i = 0; message_quarks[i].name; i++) {
167 if (type == message_quarks[i].type)
168 return message_quarks[i].quark;
174 _gst_message_dispose (GstMessage * message)
176 gboolean do_free = TRUE;
178 if (GST_MINI_OBJECT_FLAG_IS_SET (message, GST_MESSAGE_FLAG_ASYNC_DELIVERY)) {
179 /* revive message, so bus can finish with it and clean it up */
180 gst_message_ref (message);
182 GST_INFO ("[msg %p] signalling async free", message);
184 GST_MESSAGE_LOCK (message);
185 GST_MESSAGE_SIGNAL (message);
186 GST_MESSAGE_UNLOCK (message);
188 /* don't free it yet, let bus finish with it first */
196 _gst_message_free (GstMessage * message)
198 GstStructure *structure;
200 g_return_if_fail (message != NULL);
202 GST_CAT_LOG (GST_CAT_MESSAGE, "finalize message %p, %s from %s", message,
203 GST_MESSAGE_TYPE_NAME (message), GST_MESSAGE_SRC_NAME (message));
205 if (GST_MESSAGE_SRC (message)) {
206 gst_object_unref (GST_MESSAGE_SRC (message));
207 GST_MESSAGE_SRC (message) = NULL;
210 structure = GST_MESSAGE_STRUCTURE (message);
212 gst_structure_set_parent_refcount (structure, NULL);
213 gst_structure_free (structure);
216 g_slice_free1 (sizeof (GstMessageImpl), message);
220 gst_message_init (GstMessageImpl * message, GstMessageType type,
224 _gst_message_copy (GstMessage * message)
226 GstMessageImpl *copy;
227 GstStructure *structure;
229 GST_CAT_LOG (GST_CAT_MESSAGE, "copy message %p, %s from %s", message,
230 GST_MESSAGE_TYPE_NAME (message),
231 GST_OBJECT_NAME (GST_MESSAGE_SRC (message)));
233 copy = g_slice_new0 (GstMessageImpl);
235 gst_message_init (copy, GST_MESSAGE_TYPE (message),
236 GST_MESSAGE_SRC (message));
238 GST_MESSAGE_TIMESTAMP (copy) = GST_MESSAGE_TIMESTAMP (message);
239 GST_MESSAGE_SEQNUM (copy) = GST_MESSAGE_SEQNUM (message);
241 structure = GST_MESSAGE_STRUCTURE (message);
243 GST_MESSAGE_STRUCTURE (copy) = gst_structure_copy (structure);
244 gst_structure_set_parent_refcount (GST_MESSAGE_STRUCTURE (copy),
245 ©->message.mini_object.refcount);
247 GST_MESSAGE_STRUCTURE (copy) = NULL;
250 return GST_MESSAGE_CAST (copy);
254 gst_message_init (GstMessageImpl * message, GstMessageType type,
257 gst_mini_object_init (GST_MINI_OBJECT_CAST (message), 0, _gst_message_type,
258 (GstMiniObjectCopyFunction) _gst_message_copy,
259 (GstMiniObjectDisposeFunction) _gst_message_dispose,
260 (GstMiniObjectFreeFunction) _gst_message_free);
262 GST_MESSAGE_TYPE (message) = type;
264 gst_object_ref (src);
265 GST_MESSAGE_SRC (message) = src;
266 GST_MESSAGE_TIMESTAMP (message) = GST_CLOCK_TIME_NONE;
267 GST_MESSAGE_SEQNUM (message) = gst_util_seqnum_next ();
272 * gst_message_new_custom:
273 * @type: The #GstMessageType to distinguish messages
274 * @src: (transfer none) (allow-none): The object originating the message.
275 * @structure: (transfer full) (allow-none): the structure for the
276 * message. The message will take ownership of the structure.
278 * Create a new custom-typed message. This can be used for anything not
279 * handled by other message-specific functions to pass a message to the
280 * app. The structure field can be %NULL.
282 * Returns: (transfer full): The new message.
287 gst_message_new_custom (GstMessageType type, GstObject * src,
288 GstStructure * structure)
290 GstMessageImpl *message;
292 message = g_slice_new0 (GstMessageImpl);
294 GST_CAT_LOG (GST_CAT_MESSAGE, "source %s: creating new message %p %s",
295 (src ? GST_OBJECT_NAME (src) : "NULL"), message,
296 gst_message_type_get_name (type));
299 /* structure must not have a parent */
300 if (!gst_structure_set_parent_refcount (structure,
301 &message->message.mini_object.refcount))
304 gst_message_init (message, type, src);
306 GST_MESSAGE_STRUCTURE (message) = structure;
308 return GST_MESSAGE_CAST (message);
313 g_slice_free1 (sizeof (GstMessageImpl), message);
314 g_warning ("structure is already owned by another object");
320 * gst_message_get_seqnum:
321 * @message: A #GstMessage.
323 * Retrieve the sequence number of a message.
325 * Messages have ever-incrementing sequence numbers, which may also be set
326 * explicitly via gst_message_set_seqnum(). Sequence numbers are typically used
327 * to indicate that a message corresponds to some other set of messages or
328 * events, for example a SEGMENT_DONE message corresponding to a SEEK event. It
329 * is considered good practice to make this correspondence when possible, though
330 * it is not required.
332 * Note that events and messages share the same sequence number incrementor;
333 * two events or messages will never have the same sequence number unless
334 * that correspondence was made explicitly.
336 * Returns: The message's sequence number.
341 gst_message_get_seqnum (GstMessage * message)
343 g_return_val_if_fail (GST_IS_MESSAGE (message), -1);
345 return GST_MESSAGE_SEQNUM (message);
349 * gst_message_set_seqnum:
350 * @message: A #GstMessage.
351 * @seqnum: A sequence number.
353 * Set the sequence number of a message.
355 * This function might be called by the creator of a message to indicate that
356 * the message relates to other messages or events. See gst_message_get_seqnum()
357 * for more information.
362 gst_message_set_seqnum (GstMessage * message, guint32 seqnum)
364 g_return_if_fail (GST_IS_MESSAGE (message));
366 GST_MESSAGE_SEQNUM (message) = seqnum;
370 * gst_message_new_eos:
371 * @src: (transfer none) (allow-none): The object originating the message.
373 * Create a new eos message. This message is generated and posted in
374 * the sink elements of a GstBin. The bin will only forward the EOS
375 * message to the application if all sinks have posted an EOS message.
377 * Returns: (transfer full): The new eos message.
382 gst_message_new_eos (GstObject * src)
386 message = gst_message_new_custom (GST_MESSAGE_EOS, src, NULL);
392 * gst_message_new_error:
393 * @src: (transfer none) (allow-none): The object originating the message.
394 * @error: (transfer none): The GError for this message.
395 * @debug: A debugging string.
397 * Create a new error message. The message will copy @error and
398 * @debug. This message is posted by element when a fatal event
399 * occurred. The pipeline will probably (partially) stop. The application
400 * receiving this message should stop the pipeline.
402 * Returns: (transfer full): the new error message.
407 gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
410 GstStructure *structure;
412 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ERROR),
413 GST_QUARK (GERROR), G_TYPE_ERROR, error,
414 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
415 message = gst_message_new_custom (GST_MESSAGE_ERROR, src, structure);
421 * gst_message_new_warning:
422 * @src: (transfer none) (allow-none): The object originating the message.
423 * @error: (transfer none): The GError for this message.
424 * @debug: A debugging string.
426 * Create a new warning message. The message will make copies of @error and
429 * Returns: (transfer full): The new warning message.
434 gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
437 GstStructure *structure;
439 structure = gst_structure_new_id (GST_QUARK (MESSAGE_WARNING),
440 GST_QUARK (GERROR), G_TYPE_ERROR, error,
441 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
442 message = gst_message_new_custom (GST_MESSAGE_WARNING, src, structure);
448 * gst_message_new_info:
449 * @src: (transfer none) (allow-none): The object originating the message.
450 * @error: (transfer none): The GError for this message.
451 * @debug: A debugging string.
453 * Create a new info message. The message will make copies of @error and
458 * Returns: (transfer full): the new info message.
461 gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
464 GstStructure *structure;
466 structure = gst_structure_new_id (GST_QUARK (MESSAGE_INFO),
467 GST_QUARK (GERROR), G_TYPE_ERROR, error,
468 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
469 message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
475 * gst_message_new_tag:
476 * @src: (transfer none) (allow-none): The object originating the message.
477 * @tag_list: (transfer full): the tag list for the message.
479 * Create a new tag message. The message will take ownership of the tag list.
480 * The message is posted by elements that discovered a new taglist.
482 * Returns: (transfer full): the new tag message.
487 gst_message_new_tag (GstObject * src, GstTagList * tag_list)
491 GValue val = G_VALUE_INIT;
493 g_return_val_if_fail (GST_IS_TAG_LIST (tag_list), NULL);
495 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_TAG));
496 g_value_init (&val, GST_TYPE_TAG_LIST);
497 g_value_take_boxed (&val, tag_list);
498 gst_structure_id_take_value (s, GST_QUARK (TAGLIST), &val);
499 message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
504 * gst_message_new_buffering:
505 * @src: (transfer none) (allow-none): The object originating the message.
506 * @percent: The buffering percent
508 * Create a new buffering message. This message can be posted by an element that
509 * needs to buffer data before it can continue processing. @percent should be a
510 * value between 0 and 100. A value of 100 means that the buffering completed.
512 * When @percent is < 100 the application should PAUSE a PLAYING pipeline. When
513 * @percent is 100, the application can set the pipeline (back) to PLAYING.
514 * The application must be prepared to receive BUFFERING messages in the
515 * PREROLLING state and may only set the pipeline to PLAYING after receiving a
516 * message with @percent set to 100, which can happen after the pipeline
517 * completed prerolling.
521 * Returns: (transfer full): The new buffering message.
524 gst_message_new_buffering (GstObject * src, gint percent)
527 GstStructure *structure;
528 gint64 buffering_left;
530 g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
532 buffering_left = (percent == 100 ? 0 : -1);
534 structure = gst_structure_new_id (GST_QUARK (MESSAGE_BUFFERING),
535 GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
536 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
537 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, -1,
538 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, -1,
539 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
540 message = gst_message_new_custom (GST_MESSAGE_BUFFERING, src, structure);
546 * gst_message_new_state_changed:
547 * @src: (transfer none) (allow-none): The object originating the message.
548 * @oldstate: the previous state
549 * @newstate: the new (current) state
550 * @pending: the pending (target) state
552 * Create a state change message. This message is posted whenever an element
555 * Returns: (transfer full): the new state change message.
560 gst_message_new_state_changed (GstObject * src,
561 GstState oldstate, GstState newstate, GstState pending)
564 GstStructure *structure;
566 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STATE_CHANGED),
567 GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
568 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
569 GST_QUARK (PENDING_STATE), GST_TYPE_STATE, (gint) pending, NULL);
570 message = gst_message_new_custom (GST_MESSAGE_STATE_CHANGED, src, structure);
576 * gst_message_new_state_dirty:
577 * @src: (transfer none) (allow-none): The object originating the message
579 * Create a state dirty message. This message is posted whenever an element
580 * changed its state asynchronously and is used internally to update the
581 * states of container objects.
583 * Returns: (transfer full): the new state dirty message.
588 gst_message_new_state_dirty (GstObject * src)
592 message = gst_message_new_custom (GST_MESSAGE_STATE_DIRTY, src, NULL);
598 * gst_message_new_clock_provide:
599 * @src: (transfer none) (allow-none): The object originating the message.
600 * @clock: (transfer none): the clock it provides
601 * @ready: %TRUE if the sender can provide a clock
603 * Create a clock provide message. This message is posted whenever an
604 * element is ready to provide a clock or lost its ability to provide
605 * a clock (maybe because it paused or became EOS).
607 * This message is mainly used internally to manage the clock
610 * Returns: (transfer full): the new provide clock message.
615 gst_message_new_clock_provide (GstObject * src, GstClock * clock,
619 GstStructure *structure;
621 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_PROVIDE),
622 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
623 GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
624 message = gst_message_new_custom (GST_MESSAGE_CLOCK_PROVIDE, src, structure);
630 * gst_message_new_clock_lost:
631 * @src: (transfer none) (allow-none): The object originating the message.
632 * @clock: (transfer none): the clock that was lost
634 * Create a clock lost message. This message is posted whenever the
635 * clock is not valid anymore.
637 * If this message is posted by the pipeline, the pipeline will
638 * select a new clock again when it goes to PLAYING. It might therefore
639 * be needed to set the pipeline to PAUSED and PLAYING again.
641 * Returns: (transfer full): The new clock lost message.
646 gst_message_new_clock_lost (GstObject * src, GstClock * clock)
649 GstStructure *structure;
651 structure = gst_structure_new_id (GST_QUARK (MESSAGE_CLOCK_LOST),
652 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
653 message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
659 * gst_message_new_new_clock:
660 * @src: (transfer none) (allow-none): The object originating the message.
661 * @clock: (transfer none): the new selected clock
663 * Create a new clock message. This message is posted whenever the
664 * pipeline selects a new clock for the pipeline.
666 * Returns: (transfer full): The new new clock message.
671 gst_message_new_new_clock (GstObject * src, GstClock * clock)
674 GstStructure *structure;
676 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEW_CLOCK),
677 GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
678 message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
684 * gst_message_new_structure_change:
685 * @src: (transfer none) (allow-none): The object originating the message.
686 * @type: The change type.
687 * @owner: (transfer none): The owner element of @src.
688 * @busy: Whether the structure change is busy.
690 * Create a new structure change message. This message is posted when the
691 * structure of a pipeline is in the process of being changed, for example
692 * when pads are linked or unlinked.
694 * @src should be the sinkpad that unlinked or linked.
696 * Returns: (transfer full): the new structure change message.
701 gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
702 GstElement * owner, gboolean busy)
705 GstStructure *structure;
707 g_return_val_if_fail (GST_IS_PAD (src), NULL);
708 /* g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SINK, NULL); */
709 g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
711 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STRUCTURE_CHANGE),
712 GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
713 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
714 GST_QUARK (BUSY), G_TYPE_BOOLEAN, busy, NULL);
716 message = gst_message_new_custom (GST_MESSAGE_STRUCTURE_CHANGE, src,
723 * gst_message_new_segment_start:
724 * @src: (transfer none) (allow-none): The object originating the message.
725 * @format: The format of the position being played
726 * @position: The position of the segment being played
728 * Create a new segment message. This message is posted by elements that
729 * start playback of a segment as a result of a segment seek. This message
730 * is not received by the application but is used for maintenance reasons in
731 * container elements.
733 * Returns: (transfer full): the new segment start message.
738 gst_message_new_segment_start (GstObject * src, GstFormat format,
742 GstStructure *structure;
744 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_START),
745 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
746 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
747 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_START, src, structure);
753 * gst_message_new_segment_done:
754 * @src: (transfer none) (allow-none): The object originating the message.
755 * @format: The format of the position being done
756 * @position: The position of the segment being done
758 * Create a new segment done message. This message is posted by elements that
759 * finish playback of a segment as a result of a segment seek. This message
760 * is received by the application after all elements that posted a segment_start
761 * have posted the segment_done.
763 * Returns: (transfer full): the new segment done message.
768 gst_message_new_segment_done (GstObject * src, GstFormat format,
772 GstStructure *structure;
774 structure = gst_structure_new_id (GST_QUARK (MESSAGE_SEGMENT_DONE),
775 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
776 GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
777 message = gst_message_new_custom (GST_MESSAGE_SEGMENT_DONE, src, structure);
783 * gst_message_new_application:
784 * @src: (transfer none) (allow-none): The object originating the message.
785 * @structure: (transfer full): the structure for the message. The message
786 * will take ownership of the structure.
788 * Create a new application-typed message. GStreamer will never create these
789 * messages; they are a gift from us to you. Enjoy.
791 * Returns: (transfer full): The new application message.
796 gst_message_new_application (GstObject * src, GstStructure * structure)
798 g_return_val_if_fail (structure != NULL, NULL);
800 return gst_message_new_custom (GST_MESSAGE_APPLICATION, src, structure);
804 * gst_message_new_element:
805 * @src: (transfer none) (allow-none): The object originating the message.
806 * @structure: (transfer full): The structure for the
807 * message. The message will take ownership of the structure.
809 * Create a new element-specific message. This is meant as a generic way of
810 * allowing one-way communication from an element to an application, for example
811 * "the firewire cable was unplugged". The format of the message should be
812 * documented in the element's documentation. The structure field can be %NULL.
814 * Returns: (transfer full): The new element message.
819 gst_message_new_element (GstObject * src, GstStructure * structure)
821 g_return_val_if_fail (structure != NULL, NULL);
823 return gst_message_new_custom (GST_MESSAGE_ELEMENT, src, structure);
827 * gst_message_new_duration_changed:
828 * @src: (transfer none) (allow-none): The object originating the message.
830 * Create a new duration changed message. This message is posted by elements
831 * that know the duration of a stream when the duration changes. This message
832 * is received by bins and is used to calculate the total duration of a
833 * pipeline. Elements may post a duration message with a duration of
834 * GST_CLOCK_TIME_NONE to indicate that the duration has changed and the
835 * cached duration should be discarded. The new duration can then be
836 * retrieved via a query.
838 * Returns: (transfer full): The new duration-changed message.
843 gst_message_new_duration_changed (GstObject * src)
847 message = gst_message_new_custom (GST_MESSAGE_DURATION_CHANGED, src,
848 gst_structure_new_id_empty (GST_QUARK (MESSAGE_DURATION_CHANGED)));
854 * gst_message_new_async_start:
855 * @src: (transfer none) (allow-none): The object originating the message.
857 * This message is posted by elements when they start an ASYNC state change.
859 * Returns: (transfer full): The new async_start message.
864 gst_message_new_async_start (GstObject * src)
868 message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, NULL);
874 * gst_message_new_async_done:
875 * @src: (transfer none) (allow-none): The object originating the message.
876 * @running_time: the desired running_time
878 * The message is posted when elements completed an ASYNC state change.
879 * @running_time contains the time of the desired running_time when this
880 * elements goes to PLAYING. A value of #GST_CLOCK_TIME_NONE for @running_time
881 * means that the element has no clock interaction and thus doesn't care about
882 * the running_time of the pipeline.
884 * Returns: (transfer full): The new async_done message.
889 gst_message_new_async_done (GstObject * src, GstClockTime running_time)
892 GstStructure *structure;
894 structure = gst_structure_new_id (GST_QUARK (MESSAGE_ASYNC_DONE),
895 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
896 message = gst_message_new_custom (GST_MESSAGE_ASYNC_DONE, src, structure);
902 * gst_message_new_latency:
903 * @src: (transfer none) (allow-none): The object originating the message.
905 * This message can be posted by elements when their latency requirements have
908 * Returns: (transfer full): The new latency message.
913 gst_message_new_latency (GstObject * src)
917 message = gst_message_new_custom (GST_MESSAGE_LATENCY, src, NULL);
923 * gst_message_new_request_state:
924 * @src: (transfer none) (allow-none): The object originating the message.
925 * @state: The new requested state
927 * This message can be posted by elements when they want to have their state
928 * changed. A typical use case would be an audio server that wants to pause the
929 * pipeline because a higher priority stream is being played.
931 * Returns: (transfer full): the new request state message.
936 gst_message_new_request_state (GstObject * src, GstState state)
939 GstStructure *structure;
941 structure = gst_structure_new_id (GST_QUARK (MESSAGE_REQUEST_STATE),
942 GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
943 message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
949 * gst_message_get_structure:
950 * @message: The #GstMessage.
952 * Access the structure of the message.
954 * Returns: (transfer none): The structure of the message. The structure is
955 * still owned by the message, which means that you should not free it and
956 * that the pointer becomes invalid when you free the message.
961 gst_message_get_structure (GstMessage * message)
963 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
965 return GST_MESSAGE_STRUCTURE (message);
969 * gst_message_has_name:
970 * @message: The #GstMessage.
971 * @name: name to check
973 * Checks if @message has the given @name. This function is usually used to
974 * check the name of a custom message.
976 * Returns: %TRUE if @name matches the name of the message structure.
979 gst_message_has_name (GstMessage * message, const gchar * name)
981 GstStructure *structure;
983 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
985 structure = GST_MESSAGE_STRUCTURE (message);
986 if (structure == NULL)
989 return gst_structure_has_name (structure, name);
993 * gst_message_parse_tag:
994 * @message: A valid #GstMessage of type GST_MESSAGE_TAG.
995 * @tag_list: (out callee-allocates): return location for the tag-list.
997 * Extracts the tag list from the GstMessage. The tag list returned in the
998 * output argument is a copy; the caller must free it when done.
1000 * Typical usage of this function might be:
1001 * |[<!-- language="C" -->
1003 * switch (GST_MESSAGE_TYPE (msg)) {
1004 * case GST_MESSAGE_TAG: {
1005 * GstTagList *tags = NULL;
1007 * gst_message_parse_tag (msg, &tags);
1008 * g_print ("Got tags from element %s\n", GST_OBJECT_NAME (msg->src));
1009 * handle_tags (tags);
1010 * gst_tag_list_unref (tags);
1021 gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
1023 g_return_if_fail (GST_IS_MESSAGE (message));
1024 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
1025 g_return_if_fail (tag_list != NULL);
1027 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1028 GST_QUARK (TAGLIST), GST_TYPE_TAG_LIST, tag_list, NULL);
1032 * gst_message_parse_buffering:
1033 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1034 * @percent: (out) (allow-none): Return location for the percent.
1036 * Extracts the buffering percent from the GstMessage. see also
1037 * gst_message_new_buffering().
1042 gst_message_parse_buffering (GstMessage * message, gint * percent)
1044 g_return_if_fail (GST_IS_MESSAGE (message));
1045 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1049 g_value_get_int (gst_structure_id_get_value (GST_MESSAGE_STRUCTURE
1050 (message), GST_QUARK (BUFFER_PERCENT)));
1054 * gst_message_set_buffering_stats:
1055 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1056 * @mode: a buffering mode
1057 * @avg_in: the average input rate
1058 * @avg_out: the average output rate
1059 * @buffering_left: amount of buffering time left in milliseconds
1061 * Configures the buffering stats values in @message.
1064 gst_message_set_buffering_stats (GstMessage * message, GstBufferingMode mode,
1065 gint avg_in, gint avg_out, gint64 buffering_left)
1067 g_return_if_fail (GST_IS_MESSAGE (message));
1068 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1070 gst_structure_id_set (GST_MESSAGE_STRUCTURE (message),
1071 GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, mode,
1072 GST_QUARK (AVG_IN_RATE), G_TYPE_INT, avg_in,
1073 GST_QUARK (AVG_OUT_RATE), G_TYPE_INT, avg_out,
1074 GST_QUARK (BUFFERING_LEFT), G_TYPE_INT64, buffering_left, NULL);
1078 * gst_message_parse_buffering_stats:
1079 * @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
1080 * @mode: (out) (allow-none): a buffering mode, or %NULL
1081 * @avg_in: (out) (allow-none): the average input rate, or %NULL
1082 * @avg_out: (out) (allow-none): the average output rate, or %NULL
1083 * @buffering_left: (out) (allow-none): amount of buffering time left in
1084 * milliseconds, or %NULL
1086 * Extracts the buffering stats values from @message.
1089 gst_message_parse_buffering_stats (GstMessage * message,
1090 GstBufferingMode * mode, gint * avg_in, gint * avg_out,
1091 gint64 * buffering_left)
1093 GstStructure *structure;
1095 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_BUFFERING);
1097 structure = GST_MESSAGE_STRUCTURE (message);
1099 *mode = (GstBufferingMode)
1100 g_value_get_enum (gst_structure_id_get_value (structure,
1101 GST_QUARK (BUFFERING_MODE)));
1103 *avg_in = g_value_get_int (gst_structure_id_get_value (structure,
1104 GST_QUARK (AVG_IN_RATE)));
1106 *avg_out = g_value_get_int (gst_structure_id_get_value (structure,
1107 GST_QUARK (AVG_OUT_RATE)));
1110 g_value_get_int64 (gst_structure_id_get_value (structure,
1111 GST_QUARK (BUFFERING_LEFT)));
1115 * gst_message_parse_state_changed:
1116 * @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
1117 * @oldstate: (out) (allow-none): the previous state, or %NULL
1118 * @newstate: (out) (allow-none): the new (current) state, or %NULL
1119 * @pending: (out) (allow-none): the pending (target) state, or %NULL
1121 * Extracts the old and new states from the GstMessage.
1123 * Typical usage of this function might be:
1124 * |[<!-- language="C" -->
1126 * switch (GST_MESSAGE_TYPE (msg)) {
1127 * case GST_MESSAGE_STATE_CHANGED: {
1128 * GstState old_state, new_state;
1130 * gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
1131 * g_print ("Element %s changed state from %s to %s.\n",
1132 * GST_OBJECT_NAME (msg->src),
1133 * gst_element_state_get_name (old_state),
1134 * gst_element_state_get_name (new_state));
1145 gst_message_parse_state_changed (GstMessage * message,
1146 GstState * oldstate, GstState * newstate, GstState * pending)
1148 GstStructure *structure;
1150 g_return_if_fail (GST_IS_MESSAGE (message));
1151 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
1153 structure = GST_MESSAGE_STRUCTURE (message);
1155 *oldstate = (GstState)
1156 g_value_get_enum (gst_structure_id_get_value (structure,
1157 GST_QUARK (OLD_STATE)));
1159 *newstate = (GstState)
1160 g_value_get_enum (gst_structure_id_get_value (structure,
1161 GST_QUARK (NEW_STATE)));
1163 *pending = (GstState)
1164 g_value_get_enum (gst_structure_id_get_value (structure,
1165 GST_QUARK (PENDING_STATE)));
1169 * gst_message_parse_clock_provide:
1170 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
1171 * @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
1173 * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
1175 * Extracts the clock and ready flag from the GstMessage.
1176 * The clock object returned remains valid until the message is freed.
1181 gst_message_parse_clock_provide (GstMessage * message, GstClock ** clock,
1184 const GValue *clock_gvalue;
1185 GstStructure *structure;
1187 g_return_if_fail (GST_IS_MESSAGE (message));
1188 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_PROVIDE);
1190 structure = GST_MESSAGE_STRUCTURE (message);
1191 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1192 g_return_if_fail (clock_gvalue != NULL);
1193 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1197 g_value_get_boolean (gst_structure_id_get_value (structure,
1198 GST_QUARK (READY)));
1200 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1204 * gst_message_parse_clock_lost:
1205 * @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_LOST.
1206 * @clock: (out) (allow-none) (transfer none): a pointer to hold the lost clock
1208 * Extracts the lost clock from the GstMessage.
1209 * The clock object returned remains valid until the message is freed.
1214 gst_message_parse_clock_lost (GstMessage * message, GstClock ** clock)
1216 const GValue *clock_gvalue;
1217 GstStructure *structure;
1219 g_return_if_fail (GST_IS_MESSAGE (message));
1220 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_CLOCK_LOST);
1222 structure = GST_MESSAGE_STRUCTURE (message);
1223 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1224 g_return_if_fail (clock_gvalue != NULL);
1225 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1228 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1232 * gst_message_parse_new_clock:
1233 * @message: A valid #GstMessage of type GST_MESSAGE_NEW_CLOCK.
1234 * @clock: (out) (allow-none) (transfer none): a pointer to hold the selected
1237 * Extracts the new clock from the GstMessage.
1238 * The clock object returned remains valid until the message is freed.
1243 gst_message_parse_new_clock (GstMessage * message, GstClock ** clock)
1245 const GValue *clock_gvalue;
1246 GstStructure *structure;
1248 g_return_if_fail (GST_IS_MESSAGE (message));
1249 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEW_CLOCK);
1251 structure = GST_MESSAGE_STRUCTURE (message);
1252 clock_gvalue = gst_structure_id_get_value (structure, GST_QUARK (CLOCK));
1253 g_return_if_fail (clock_gvalue != NULL);
1254 g_return_if_fail (G_VALUE_TYPE (clock_gvalue) == GST_TYPE_CLOCK);
1257 *clock = (GstClock *) g_value_get_object (clock_gvalue);
1261 * gst_message_parse_structure_change:
1262 * @message: A valid #GstMessage of type GST_MESSAGE_STRUCTURE_CHANGE.
1263 * @type: (out): A pointer to hold the change type
1264 * @owner: (out) (allow-none) (transfer none): The owner element of the
1266 * @busy: (out) (allow-none): a pointer to hold whether the change is in
1267 * progress or has been completed
1269 * Extracts the change type and completion status from the GstMessage.
1274 gst_message_parse_structure_change (GstMessage * message,
1275 GstStructureChangeType * type, GstElement ** owner, gboolean * busy)
1277 const GValue *owner_gvalue;
1278 GstStructure *structure;
1280 g_return_if_fail (GST_IS_MESSAGE (message));
1281 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STRUCTURE_CHANGE);
1283 structure = GST_MESSAGE_STRUCTURE (message);
1284 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1285 g_return_if_fail (owner_gvalue != NULL);
1286 g_return_if_fail (G_VALUE_TYPE (owner_gvalue) == GST_TYPE_ELEMENT);
1289 *type = (GstStructureChangeType)
1290 g_value_get_enum (gst_structure_id_get_value (structure,
1293 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1296 g_value_get_boolean (gst_structure_id_get_value (structure,
1301 * gst_message_parse_error:
1302 * @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
1303 * @gerror: (out) (allow-none) (transfer full): location for the GError
1304 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1307 * Extracts the GError and debug string from the GstMessage. The values returned
1308 * in the output arguments are copies; the caller must free them when done.
1310 * Typical usage of this function might be:
1311 * |[<!-- language="C" -->
1313 * switch (GST_MESSAGE_TYPE (msg)) {
1314 * case GST_MESSAGE_ERROR: {
1315 * GError *err = NULL;
1316 * gchar *dbg_info = NULL;
1318 * gst_message_parse_error (msg, &err, &dbg_info);
1319 * g_printerr ("ERROR from element %s: %s\n",
1320 * GST_OBJECT_NAME (msg->src), err->message);
1321 * g_printerr ("Debugging info: %s\n", (dbg_info) ? dbg_info : "none");
1322 * g_error_free (err);
1323 * g_free (dbg_info);
1334 gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug)
1336 g_return_if_fail (GST_IS_MESSAGE (message));
1337 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR);
1339 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1340 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1341 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1345 * gst_message_parse_warning:
1346 * @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
1347 * @gerror: (out) (allow-none) (transfer full): location for the GError
1348 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1351 * Extracts the GError and debug string from the GstMessage. The values returned
1352 * in the output arguments are copies; the caller must free them when done.
1357 gst_message_parse_warning (GstMessage * message, GError ** gerror,
1360 g_return_if_fail (GST_IS_MESSAGE (message));
1361 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING);
1363 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1364 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1365 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1369 * gst_message_parse_info:
1370 * @message: A valid #GstMessage of type GST_MESSAGE_INFO.
1371 * @gerror: (out) (allow-none) (transfer full): location for the GError
1372 * @debug: (out) (allow-none) (transfer full): location for the debug message,
1375 * Extracts the GError and debug string from the GstMessage. The values returned
1376 * in the output arguments are copies; the caller must free them when done.
1381 gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug)
1383 g_return_if_fail (GST_IS_MESSAGE (message));
1384 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO);
1386 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
1387 GST_QUARK (GERROR), G_TYPE_ERROR, gerror,
1388 GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
1392 * gst_message_parse_segment_start:
1393 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
1394 * @format: (out) (allow-none): Result location for the format, or %NULL
1395 * @position: (out) (allow-none): Result location for the position, or %NULL
1397 * Extracts the position and format from the segment start message.
1402 gst_message_parse_segment_start (GstMessage * message, GstFormat * format,
1405 GstStructure *structure;
1407 g_return_if_fail (GST_IS_MESSAGE (message));
1408 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_START);
1410 structure = GST_MESSAGE_STRUCTURE (message);
1412 *format = (GstFormat)
1413 g_value_get_enum (gst_structure_id_get_value (structure,
1414 GST_QUARK (FORMAT)));
1417 g_value_get_int64 (gst_structure_id_get_value (structure,
1418 GST_QUARK (POSITION)));
1422 * gst_message_parse_segment_done:
1423 * @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
1424 * @format: (out) (allow-none): Result location for the format, or %NULL
1425 * @position: (out) (allow-none): Result location for the position, or %NULL
1427 * Extracts the position and format from the segment done message.
1432 gst_message_parse_segment_done (GstMessage * message, GstFormat * format,
1435 GstStructure *structure;
1437 g_return_if_fail (GST_IS_MESSAGE (message));
1438 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_SEGMENT_DONE);
1440 structure = GST_MESSAGE_STRUCTURE (message);
1442 *format = (GstFormat)
1443 g_value_get_enum (gst_structure_id_get_value (structure,
1444 GST_QUARK (FORMAT)));
1447 g_value_get_int64 (gst_structure_id_get_value (structure,
1448 GST_QUARK (POSITION)));
1452 * gst_message_parse_async_done:
1453 * @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
1454 * @running_time: (out) (allow-none): Result location for the running_time or %NULL
1456 * Extract the running_time from the async_done message.
1461 gst_message_parse_async_done (GstMessage * message, GstClockTime * running_time)
1463 GstStructure *structure;
1465 g_return_if_fail (GST_IS_MESSAGE (message));
1466 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ASYNC_DONE);
1468 structure = GST_MESSAGE_STRUCTURE (message);
1471 g_value_get_uint64 (gst_structure_id_get_value (structure,
1472 GST_QUARK (RUNNING_TIME)));
1476 * gst_message_parse_request_state:
1477 * @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
1478 * @state: (out) (allow-none): Result location for the requested state or %NULL
1480 * Extract the requested state from the request_state message.
1485 gst_message_parse_request_state (GstMessage * message, GstState * state)
1487 GstStructure *structure;
1489 g_return_if_fail (GST_IS_MESSAGE (message));
1490 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_REQUEST_STATE);
1492 structure = GST_MESSAGE_STRUCTURE (message);
1495 g_value_get_enum (gst_structure_id_get_value (structure,
1496 GST_QUARK (NEW_STATE)));
1500 * gst_message_new_stream_status:
1501 * @src: The object originating the message.
1502 * @type: The stream status type.
1503 * @owner: (transfer none): the owner element of @src.
1505 * Create a new stream status message. This message is posted when a streaming
1506 * thread is created/destroyed or when the state changed.
1508 * Returns: (transfer full): the new stream status message.
1513 gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
1516 GstMessage *message;
1517 GstStructure *structure;
1519 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_STATUS),
1520 GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
1521 GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
1522 message = gst_message_new_custom (GST_MESSAGE_STREAM_STATUS, src, structure);
1528 * gst_message_parse_stream_status:
1529 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1530 * @type: (out): A pointer to hold the status type
1531 * @owner: (out) (transfer none): The owner element of the message source
1533 * Extracts the stream status type and owner the GstMessage. The returned
1534 * owner remains valid for as long as the reference to @message is valid and
1535 * should thus not be unreffed.
1540 gst_message_parse_stream_status (GstMessage * message,
1541 GstStreamStatusType * type, GstElement ** owner)
1543 const GValue *owner_gvalue;
1544 GstStructure *structure;
1546 g_return_if_fail (GST_IS_MESSAGE (message));
1547 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1549 structure = GST_MESSAGE_STRUCTURE (message);
1550 owner_gvalue = gst_structure_id_get_value (structure, GST_QUARK (OWNER));
1551 g_return_if_fail (owner_gvalue != NULL);
1554 *type = (GstStreamStatusType)
1555 g_value_get_enum (gst_structure_id_get_value (structure,
1558 *owner = (GstElement *) g_value_get_object (owner_gvalue);
1562 * gst_message_set_stream_status_object:
1563 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1564 * @object: the object controlling the streaming
1566 * Configures the object handling the streaming thread. This is usually a
1567 * GstTask object but other objects might be added in the future.
1570 gst_message_set_stream_status_object (GstMessage * message,
1571 const GValue * object)
1573 GstStructure *structure;
1575 g_return_if_fail (GST_IS_MESSAGE (message));
1576 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS);
1578 structure = GST_MESSAGE_STRUCTURE (message);
1579 gst_structure_id_set_value (structure, GST_QUARK (OBJECT), object);
1583 * gst_message_get_stream_status_object:
1584 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_STATUS.
1586 * Extracts the object managing the streaming thread from @message.
1588 * Returns: a GValue containing the object that manages the streaming thread.
1589 * This object is usually of type GstTask but other types can be added in the
1590 * future. The object remains valid as long as @message is valid.
1593 gst_message_get_stream_status_object (GstMessage * message)
1595 const GValue *result;
1596 GstStructure *structure;
1598 g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
1599 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS,
1602 structure = GST_MESSAGE_STRUCTURE (message);
1603 result = gst_structure_id_get_value (structure, GST_QUARK (OBJECT));
1609 * gst_message_new_step_done:
1610 * @src: The object originating the message.
1611 * @format: the format of @amount
1612 * @amount: the amount of stepped data
1613 * @rate: the rate of the stepped amount
1614 * @flush: is this an flushing step
1615 * @intermediate: is this an intermediate step
1616 * @duration: the duration of the data
1617 * @eos: the step caused EOS
1619 * This message is posted by elements when they complete a part, when @intermediate set
1620 * to %TRUE, or a complete step operation.
1622 * @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
1623 * @amount of media in format @format.
1625 * Returns: (transfer full): the new step_done message.
1630 gst_message_new_step_done (GstObject * src, GstFormat format, guint64 amount,
1631 gdouble rate, gboolean flush, gboolean intermediate, guint64 duration,
1634 GstMessage *message;
1635 GstStructure *structure;
1637 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_DONE),
1638 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1639 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1640 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1641 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1642 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1643 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1644 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1645 message = gst_message_new_custom (GST_MESSAGE_STEP_DONE, src, structure);
1651 * gst_message_parse_step_done:
1652 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1653 * @format: (out) (allow-none): result location for the format
1654 * @amount: (out) (allow-none): result location for the amount
1655 * @rate: (out) (allow-none): result location for the rate
1656 * @flush: (out) (allow-none): result location for the flush flag
1657 * @intermediate: (out) (allow-none): result location for the intermediate flag
1658 * @duration: (out) (allow-none): result location for the duration
1659 * @eos: (out) (allow-none): result location for the EOS flag
1661 * Extract the values the step_done message.
1666 gst_message_parse_step_done (GstMessage * message, GstFormat * format,
1667 guint64 * amount, gdouble * rate, gboolean * flush, gboolean * intermediate,
1668 guint64 * duration, gboolean * eos)
1670 GstStructure *structure;
1672 g_return_if_fail (GST_IS_MESSAGE (message));
1673 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_DONE);
1675 structure = GST_MESSAGE_STRUCTURE (message);
1676 gst_structure_id_get (structure,
1677 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1678 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1679 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1680 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1681 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate,
1682 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1683 GST_QUARK (EOS), G_TYPE_BOOLEAN, eos, NULL);
1687 * gst_message_new_step_start:
1688 * @src: The object originating the message.
1689 * @active: if the step is active or queued
1690 * @format: the format of @amount
1691 * @amount: the amount of stepped data
1692 * @rate: the rate of the stepped amount
1693 * @flush: is this an flushing step
1694 * @intermediate: is this an intermediate step
1696 * This message is posted by elements when they accept or activate a new step
1697 * event for @amount in @format.
1699 * @active is set to %FALSE when the element accepted the new step event and has
1700 * queued it for execution in the streaming threads.
1702 * @active is set to %TRUE when the element has activated the step operation and
1703 * is now ready to start executing the step in the streaming thread. After this
1704 * message is emitted, the application can queue a new step operation in the
1707 * Returns: (transfer full): The new step_start message.
1712 gst_message_new_step_start (GstObject * src, gboolean active, GstFormat format,
1713 guint64 amount, gdouble rate, gboolean flush, gboolean intermediate)
1715 GstMessage *message;
1716 GstStructure *structure;
1718 structure = gst_structure_new_id (GST_QUARK (MESSAGE_STEP_START),
1719 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1720 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1721 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1722 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1723 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1724 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1725 message = gst_message_new_custom (GST_MESSAGE_STEP_START, src, structure);
1731 * gst_message_parse_step_start:
1732 * @message: A valid #GstMessage of type GST_MESSAGE_STEP_DONE.
1733 * @active: (out) (allow-none): result location for the active flag
1734 * @format: (out) (allow-none): result location for the format
1735 * @amount: (out) (allow-none): result location for the amount
1736 * @rate: (out) (allow-none): result location for the rate
1737 * @flush: (out) (allow-none): result location for the flush flag
1738 * @intermediate: (out) (allow-none): result location for the intermediate flag
1740 * Extract the values from step_start message.
1745 gst_message_parse_step_start (GstMessage * message, gboolean * active,
1746 GstFormat * format, guint64 * amount, gdouble * rate, gboolean * flush,
1747 gboolean * intermediate)
1749 GstStructure *structure;
1751 g_return_if_fail (GST_IS_MESSAGE (message));
1752 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STEP_START);
1754 structure = GST_MESSAGE_STRUCTURE (message);
1755 gst_structure_id_get (structure,
1756 GST_QUARK (ACTIVE), G_TYPE_BOOLEAN, active,
1757 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1758 GST_QUARK (AMOUNT), G_TYPE_UINT64, amount,
1759 GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
1760 GST_QUARK (FLUSH), G_TYPE_BOOLEAN, flush,
1761 GST_QUARK (INTERMEDIATE), G_TYPE_BOOLEAN, intermediate, NULL);
1765 * gst_message_new_qos:
1766 * @src: The object originating the message.
1767 * @live: if the message was generated by a live element
1768 * @running_time: the running time of the buffer that generated the message
1769 * @stream_time: the stream time of the buffer that generated the message
1770 * @timestamp: the timestamps of the buffer that generated the message
1771 * @duration: the duration of the buffer that generated the message
1773 * A QOS message is posted on the bus whenever an element decides to drop a
1774 * buffer because of QoS reasons or whenever it changes its processing strategy
1775 * because of QoS reasons (quality adjustments such as processing at lower
1778 * This message can be posted by an element that performs synchronisation against the
1779 * clock (live) or it could be dropped by an element that performs QoS because of QOS
1780 * events received from a downstream element (!live).
1782 * @running_time, @stream_time, @timestamp, @duration should be set to the
1783 * respective running-time, stream-time, timestamp and duration of the (dropped)
1784 * buffer that generated the QoS event. Values can be left to
1785 * GST_CLOCK_TIME_NONE when unknown.
1787 * Returns: (transfer full): The new qos message.
1792 gst_message_new_qos (GstObject * src, gboolean live, guint64 running_time,
1793 guint64 stream_time, guint64 timestamp, guint64 duration)
1795 GstMessage *message;
1796 GstStructure *structure;
1798 structure = gst_structure_new_id (GST_QUARK (MESSAGE_QOS),
1799 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1800 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1801 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1802 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1803 GST_QUARK (DURATION), G_TYPE_UINT64, duration,
1804 GST_QUARK (JITTER), G_TYPE_INT64, (gint64) 0,
1805 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, (gdouble) 1.0,
1806 GST_QUARK (QUALITY), G_TYPE_INT, (gint) 1000000,
1807 GST_QUARK (FORMAT), GST_TYPE_FORMAT, GST_FORMAT_UNDEFINED,
1808 GST_QUARK (PROCESSED), G_TYPE_UINT64, (guint64) - 1,
1809 GST_QUARK (DROPPED), G_TYPE_UINT64, (guint64) - 1, NULL);
1810 message = gst_message_new_custom (GST_MESSAGE_QOS, src, structure);
1816 * gst_message_set_qos_values:
1817 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1818 * @jitter: The difference of the running-time against the deadline.
1819 * @proportion: Long term prediction of the ideal rate relative to normal rate
1820 * to get optimal quality.
1821 * @quality: An element dependent integer value that specifies the current
1822 * quality level of the element. The default maximum quality is 1000000.
1824 * Set the QoS values that have been calculated/analysed from the QoS data
1829 gst_message_set_qos_values (GstMessage * message, gint64 jitter,
1830 gdouble proportion, gint quality)
1832 GstStructure *structure;
1834 g_return_if_fail (GST_IS_MESSAGE (message));
1835 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1837 structure = GST_MESSAGE_STRUCTURE (message);
1838 gst_structure_id_set (structure,
1839 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1840 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1841 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1845 * gst_message_set_qos_stats:
1846 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1847 * @format: Units of the 'processed' and 'dropped' fields. Video sinks and video
1848 * filters will use GST_FORMAT_BUFFERS (frames). Audio sinks and audio filters
1849 * will likely use GST_FORMAT_DEFAULT (samples).
1850 * @processed: Total number of units correctly processed since the last state
1851 * change to READY or a flushing operation.
1852 * @dropped: Total number of units dropped since the last state change to READY
1853 * or a flushing operation.
1855 * Set the QoS stats representing the history of the current continuous pipeline
1858 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1859 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1864 gst_message_set_qos_stats (GstMessage * message, GstFormat format,
1865 guint64 processed, guint64 dropped)
1867 GstStructure *structure;
1869 g_return_if_fail (GST_IS_MESSAGE (message));
1870 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1872 structure = GST_MESSAGE_STRUCTURE (message);
1873 gst_structure_id_set (structure,
1874 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1875 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1876 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1880 * gst_message_parse_qos:
1881 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1882 * @live: (out) (allow-none): if the message was generated by a live element
1883 * @running_time: (out) (allow-none): the running time of the buffer that
1884 * generated the message
1885 * @stream_time: (out) (allow-none): the stream time of the buffer that
1886 * generated the message
1887 * @timestamp: (out) (allow-none): the timestamps of the buffer that
1888 * generated the message
1889 * @duration: (out) (allow-none): the duration of the buffer that
1890 * generated the message
1892 * Extract the timestamps and live status from the QoS message.
1894 * The returned values give the running_time, stream_time, timestamp and
1895 * duration of the dropped buffer. Values of GST_CLOCK_TIME_NONE mean unknown
1901 gst_message_parse_qos (GstMessage * message, gboolean * live,
1902 guint64 * running_time, guint64 * stream_time, guint64 * timestamp,
1905 GstStructure *structure;
1907 g_return_if_fail (GST_IS_MESSAGE (message));
1908 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1910 structure = GST_MESSAGE_STRUCTURE (message);
1911 gst_structure_id_get (structure,
1912 GST_QUARK (LIVE), G_TYPE_BOOLEAN, live,
1913 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time,
1914 GST_QUARK (STREAM_TIME), G_TYPE_UINT64, stream_time,
1915 GST_QUARK (TIMESTAMP), G_TYPE_UINT64, timestamp,
1916 GST_QUARK (DURATION), G_TYPE_UINT64, duration, NULL);
1920 * gst_message_parse_qos_values:
1921 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1922 * @jitter: (out) (allow-none): The difference of the running-time against
1924 * @proportion: (out) (allow-none): Long term prediction of the ideal rate
1925 * relative to normal rate to get optimal quality.
1926 * @quality: (out) (allow-none): An element dependent integer value that
1927 * specifies the current quality level of the element. The default
1928 * maximum quality is 1000000.
1930 * Extract the QoS values that have been calculated/analysed from the QoS data
1935 gst_message_parse_qos_values (GstMessage * message, gint64 * jitter,
1936 gdouble * proportion, gint * quality)
1938 GstStructure *structure;
1940 g_return_if_fail (GST_IS_MESSAGE (message));
1941 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1943 structure = GST_MESSAGE_STRUCTURE (message);
1944 gst_structure_id_get (structure,
1945 GST_QUARK (JITTER), G_TYPE_INT64, jitter,
1946 GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
1947 GST_QUARK (QUALITY), G_TYPE_INT, quality, NULL);
1951 * gst_message_parse_qos_stats:
1952 * @message: A valid #GstMessage of type GST_MESSAGE_QOS.
1953 * @format: (out) (allow-none): Units of the 'processed' and 'dropped' fields.
1954 * Video sinks and video filters will use GST_FORMAT_BUFFERS (frames).
1955 * Audio sinks and audio filters will likely use GST_FORMAT_DEFAULT
1957 * @processed: (out) (allow-none): Total number of units correctly processed
1958 * since the last state change to READY or a flushing operation.
1959 * @dropped: (out) (allow-none): Total number of units dropped since the last
1960 * state change to READY or a flushing operation.
1962 * Extract the QoS stats representing the history of the current continuous
1963 * pipeline playback period.
1965 * When @format is @GST_FORMAT_UNDEFINED both @dropped and @processed are
1966 * invalid. Values of -1 for either @processed or @dropped mean unknown values.
1971 gst_message_parse_qos_stats (GstMessage * message, GstFormat * format,
1972 guint64 * processed, guint64 * dropped)
1974 GstStructure *structure;
1976 g_return_if_fail (GST_IS_MESSAGE (message));
1977 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_QOS);
1979 structure = GST_MESSAGE_STRUCTURE (message);
1980 gst_structure_id_get (structure,
1981 GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
1982 GST_QUARK (PROCESSED), G_TYPE_UINT64, processed,
1983 GST_QUARK (DROPPED), G_TYPE_UINT64, dropped, NULL);
1987 * gst_message_new_progress:
1988 * @src: The object originating the message.
1989 * @type: a #GstProgressType
1990 * @code: a progress code
1991 * @text: free, user visible text describing the progress
1993 * Progress messages are posted by elements when they use an asynchronous task
1994 * to perform actions triggered by a state change.
1996 * @code contains a well defined string describing the action.
1997 * @test should contain a user visible string detailing the current action.
1999 * Returns: (transfer full): The new qos message.
2002 gst_message_new_progress (GstObject * src, GstProgressType type,
2003 const gchar * code, const gchar * text)
2005 GstMessage *message;
2006 GstStructure *structure;
2007 gint percent = 100, timeout = -1;
2009 g_return_val_if_fail (code != NULL, NULL);
2010 g_return_val_if_fail (text != NULL, NULL);
2012 if (type == GST_PROGRESS_TYPE_START || type == GST_PROGRESS_TYPE_CONTINUE)
2015 structure = gst_structure_new_id (GST_QUARK (MESSAGE_PROGRESS),
2016 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2017 GST_QUARK (CODE), G_TYPE_STRING, code,
2018 GST_QUARK (TEXT), G_TYPE_STRING, text,
2019 GST_QUARK (PERCENT), G_TYPE_INT, percent,
2020 GST_QUARK (TIMEOUT), G_TYPE_INT, timeout, NULL);
2021 message = gst_message_new_custom (GST_MESSAGE_PROGRESS, src, structure);
2027 * gst_message_parse_progress:
2028 * @message: A valid #GstMessage of type GST_MESSAGE_PROGRESS.
2029 * @type: (out) (allow-none): location for the type
2030 * @code: (out) (allow-none) (transfer full): location for the code
2031 * @text: (out) (allow-none) (transfer full): location for the text
2033 * Parses the progress @type, @code and @text.
2036 gst_message_parse_progress (GstMessage * message, GstProgressType * type,
2037 gchar ** code, gchar ** text)
2039 GstStructure *structure;
2041 g_return_if_fail (GST_IS_MESSAGE (message));
2042 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROGRESS);
2044 structure = GST_MESSAGE_STRUCTURE (message);
2045 gst_structure_id_get (structure,
2046 GST_QUARK (TYPE), GST_TYPE_PROGRESS_TYPE, type,
2047 GST_QUARK (CODE), G_TYPE_STRING, code,
2048 GST_QUARK (TEXT), G_TYPE_STRING, text, NULL);
2052 * gst_message_new_toc:
2053 * @src: the object originating the message.
2054 * @toc: (transfer none): #GstToc structure for the message.
2055 * @updated: whether TOC was updated or not.
2057 * Create a new TOC message. The message is posted by elements
2058 * that discovered or updated a TOC.
2060 * Returns: (transfer full): a new TOC message.
2065 gst_message_new_toc (GstObject * src, GstToc * toc, gboolean updated)
2067 GstStructure *toc_struct;
2069 g_return_val_if_fail (toc != NULL, NULL);
2071 toc_struct = gst_structure_new_id (GST_QUARK (MESSAGE_TOC),
2072 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2073 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2075 return gst_message_new_custom (GST_MESSAGE_TOC, src, toc_struct);
2079 * gst_message_parse_toc:
2080 * @message: a valid #GstMessage of type GST_MESSAGE_TOC.
2081 * @toc: (out) (transfer full): return location for the TOC.
2082 * @updated: (out): return location for the updated flag.
2084 * Extract the TOC from the #GstMessage. The TOC returned in the
2085 * output argument is a copy; the caller must free it with
2086 * gst_toc_unref() when done.
2091 gst_message_parse_toc (GstMessage * message, GstToc ** toc, gboolean * updated)
2093 g_return_if_fail (GST_IS_MESSAGE (message));
2094 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TOC);
2095 g_return_if_fail (toc != NULL);
2097 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2098 GST_QUARK (TOC), GST_TYPE_TOC, toc,
2099 GST_QUARK (UPDATED), G_TYPE_BOOLEAN, updated, NULL);
2103 * gst_message_new_reset_time:
2104 * @src: (transfer none) (allow-none): The object originating the message.
2105 * @running_time: the requested running-time
2107 * This message is posted when the pipeline running-time should be reset to
2108 * @running_time, like after a flushing seek.
2110 * Returns: (transfer full): The new reset_time message.
2115 gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
2117 GstMessage *message;
2118 GstStructure *structure;
2120 structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
2121 GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
2122 message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);
2128 * gst_message_parse_reset_time:
2129 * @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
2130 * @running_time: (out) (allow-none): Result location for the running_time or
2133 * Extract the running-time from the RESET_TIME message.
2138 gst_message_parse_reset_time (GstMessage * message, GstClockTime * running_time)
2140 GstStructure *structure;
2142 g_return_if_fail (GST_IS_MESSAGE (message));
2143 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_RESET_TIME);
2145 structure = GST_MESSAGE_STRUCTURE (message);
2148 g_value_get_uint64 (gst_structure_id_get_value (structure,
2149 GST_QUARK (RUNNING_TIME)));
2153 * gst_message_new_stream_start:
2154 * @src: (transfer none) (allow-none): The object originating the message.
2156 * Create a new stream_start message. This message is generated and posted in
2157 * the sink elements of a GstBin. The bin will only forward the STREAM_START
2158 * message to the application if all sinks have posted an STREAM_START message.
2160 * Returns: (transfer full): The new stream_start message.
2165 gst_message_new_stream_start (GstObject * src)
2167 GstMessage *message;
2170 s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
2171 message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
2178 * gst_message_set_group_id:
2179 * @message: the message
2180 * @group_id: the group id
2182 * Sets the group id on the stream-start message.
2184 * All streams that have the same group id are supposed to be played
2185 * together, i.e. all streams inside a container file should have the
2186 * same group id but different stream ids. The group id should change
2187 * each time the stream is started, resulting in different group ids
2188 * each time a file is played for example.
2195 gst_message_set_group_id (GstMessage * message, guint group_id)
2197 GstStructure *structure;
2199 g_return_if_fail (GST_IS_MESSAGE (message));
2200 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
2201 g_return_if_fail (gst_message_is_writable (message));
2203 structure = GST_MESSAGE_STRUCTURE (message);
2204 gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
2209 * gst_message_parse_group_id:
2210 * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
2211 * @group_id: (out) (allow-none): Result location for the group id or
2214 * Extract the group from the STREAM_START message.
2216 * Returns: %TRUE if the message had a group id set, %FALSE otherwise
2223 gst_message_parse_group_id (GstMessage * message, guint * group_id)
2225 GstStructure *structure;
2228 g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
2229 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
2235 structure = GST_MESSAGE_STRUCTURE (message);
2237 v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
2241 *group_id = g_value_get_uint (v);
2246 * gst_message_new_need_context:
2247 * @src: (transfer none) (allow-none): The object originating the message.
2248 * @context_type: The context type that is needed
2250 * This message is posted when an element needs a specific #GstContext.
2252 * Returns: (transfer full): The new need-context message.
2259 gst_message_new_need_context (GstObject * src, const gchar * context_type)
2261 GstMessage *message;
2262 GstStructure *structure;
2264 g_return_val_if_fail (context_type != NULL, NULL);
2266 structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
2267 GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
2268 message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
2274 * gst_message_parse_context_type:
2275 * @message: a GST_MESSAGE_NEED_CONTEXT type message
2276 * @context_type: (out) (allow-none): the context type, or %NULL
2278 * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
2280 * Returns: a #gboolean indicating if the parsing succeeded.
2285 gst_message_parse_context_type (GstMessage * message,
2286 const gchar ** context_type)
2288 GstStructure *structure;
2289 const GValue *value;
2291 g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
2294 structure = GST_MESSAGE_STRUCTURE (message);
2297 value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
2298 *context_type = g_value_get_string (value);
2305 * gst_message_new_have_context:
2306 * @src: (transfer none) (allow-none): The object originating the message.
2307 * @context: (transfer full): the context
2309 * This message is posted when an element has a new local #GstContext.
2311 * Returns: (transfer full): The new have-context message.
2318 gst_message_new_have_context (GstObject * src, GstContext * context)
2320 GstMessage *message;
2321 GstStructure *structure;
2323 structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
2324 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2325 message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
2326 gst_context_unref (context);
2332 * gst_message_parse_have_context:
2333 * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
2334 * @context: (out) (transfer full) (allow-none): Result location for the
2337 * Extract the context from the HAVE_CONTEXT message.
2344 gst_message_parse_have_context (GstMessage * message, GstContext ** context)
2346 g_return_if_fail (GST_IS_MESSAGE (message));
2347 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
2350 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2351 GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
2355 * gst_message_new_device_added:
2356 * @src: The #GstObject that created the message
2357 * @device: (transfer none): The new #GstDevice
2359 * Creates a new device-added message. The device-added message is produced by
2360 * #GstDeviceProvider or a #GstDeviceMonitor. They announce the appearance
2361 * of monitored devices.
2363 * Returns: a newly allocated #GstMessage
2368 gst_message_new_device_added (GstObject * src, GstDevice * device)
2370 GstMessage *message;
2371 GstStructure *structure;
2373 g_return_val_if_fail (device != NULL, NULL);
2374 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2376 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
2377 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2378 message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
2384 * gst_message_parse_device_added:
2385 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_ADDED
2386 * @device: (out) (allow-none) (transfer none): A location where to store a
2387 * pointer to the new #GstDevice, or %NULL
2389 * Parses a device-added message. The device-added message is produced by
2390 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the appearance
2391 * of monitored devices.
2396 gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
2398 g_return_if_fail (GST_IS_MESSAGE (message));
2399 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
2402 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2403 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2407 * gst_message_new_device_removed:
2408 * @src: The #GstObject that created the message
2409 * @device: (transfer none): The removed #GstDevice
2411 * Creates a new device-removed message. The device-removed message is produced
2412 * by #GstDeviceProvider or a #GstDeviceMonitor. They announce the
2413 * disappearance of monitored devices.
2415 * Returns: a newly allocated #GstMessage
2420 gst_message_new_device_removed (GstObject * src, GstDevice * device)
2422 GstMessage *message;
2423 GstStructure *structure;
2425 g_return_val_if_fail (device != NULL, NULL);
2426 g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
2428 structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
2429 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2430 message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
2436 * gst_message_parse_device_removed:
2437 * @message: a #GstMessage of type %GST_MESSAGE_DEVICE_REMOVED
2438 * @device: (out) (allow-none) (transfer none): A location where to store a
2439 * pointer to the removed #GstDevice, or %NULL
2441 * Parses a device-removed message. The device-removed message is produced by
2442 * #GstDeviceProvider or a #GstDeviceMonitor. It announces the
2443 * disappearance of monitored devices.
2448 gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
2450 g_return_if_fail (GST_IS_MESSAGE (message));
2451 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
2454 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2455 GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
2459 * gst_message_new_property_notify:
2460 * @src: The #GstObject whose property changed (may or may not be a #GstElement)
2461 * @property_name: name of the property that changed
2462 * @val: (allow-none) (transfer full): new property value, or %NULL
2464 * Returns: a newly allocated #GstMessage
2469 gst_message_new_property_notify (GstObject * src, const gchar * property_name,
2472 GstStructure *structure;
2473 GValue name_val = G_VALUE_INIT;
2475 g_return_val_if_fail (property_name != NULL, NULL);
2477 structure = gst_structure_new_id_empty (GST_QUARK (MESSAGE_PROPERTY_NOTIFY));
2478 g_value_init (&name_val, G_TYPE_STRING);
2479 /* should already be interned, but let's make sure */
2480 g_value_set_static_string (&name_val, g_intern_string (property_name));
2481 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_NAME), &name_val);
2483 gst_structure_id_take_value (structure, GST_QUARK (PROPERTY_VALUE), val);
2485 return gst_message_new_custom (GST_MESSAGE_PROPERTY_NOTIFY, src, structure);
2489 * gst_message_parse_property_notify:
2490 * @message: a #GstMessage of type %GST_MESSAGE_PROPERTY_NOTIFY
2491 * @object: (out) (allow-none) (transfer none): location where to store a
2492 * pointer to the object whose property got changed, or %NULL
2493 * @property_name: (out) (allow-none): return location for the name of the
2494 * property that got changed, or %NULL
2495 * @property_value: (out) (allow-none): return location for the new value of
2496 * the property that got changed, or %NULL. This will only be set if the
2497 * property notify watch was told to include the value when it was set up
2499 * Parses a property-notify message. These will be posted on the bus only
2500 * when set up with gst_element_add_property_notify_watch() or
2501 * gst_element_add_property_deep_notify_watch().
2506 gst_message_parse_property_notify (GstMessage * message, GstObject ** object,
2507 const gchar ** property_name, const GValue ** property_value)
2509 const GstStructure *s = GST_MESSAGE_STRUCTURE (message);
2511 g_return_if_fail (GST_IS_MESSAGE (message));
2512 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_PROPERTY_NOTIFY);
2515 *object = GST_MESSAGE_SRC (message);
2517 if (property_name) {
2518 const GValue *name_value;
2520 name_value = gst_structure_id_get_value (s, GST_QUARK (PROPERTY_NAME));
2521 *property_name = g_value_get_string (name_value);
2526 gst_structure_id_get_value (s, GST_QUARK (PROPERTY_VALUE));
2530 * gst_message_new_stream_collection:
2531 * @src: The #GstObject that created the message
2532 * @collection: (transfer none): The #GstStreamCollection
2534 * Creates a new stream-collection message. The message is used to announce new
2535 * #GstStreamCollection
2537 * Returns: a newly allocated #GstMessage
2542 gst_message_new_stream_collection (GstObject * src,
2543 GstStreamCollection * collection)
2545 GstMessage *message;
2546 GstStructure *structure;
2548 g_return_val_if_fail (collection != NULL, NULL);
2549 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2552 gst_structure_new_id (GST_QUARK (MESSAGE_STREAM_COLLECTION),
2553 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2555 gst_message_new_custom (GST_MESSAGE_STREAM_COLLECTION, src, structure);
2561 * gst_message_parse_stream_collection:
2562 * @message: a #GstMessage of type %GST_MESSAGE_STREAM_COLLECTION
2563 * @collection: (out) (allow-none) (transfer none): A location where to store a
2564 * pointer to the #GstStreamCollection, or %NULL
2566 * Parses a stream-collection message.
2571 gst_message_parse_stream_collection (GstMessage * message,
2572 GstStreamCollection ** collection)
2574 g_return_if_fail (GST_IS_MESSAGE (message));
2575 g_return_if_fail (GST_MESSAGE_TYPE (message) ==
2576 GST_MESSAGE_STREAM_COLLECTION);
2579 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2580 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2584 * gst_message_new_streams_selected:
2585 * @src: The #GstObject that created the message
2586 * @collection: (transfer none): The #GstStreamCollection
2588 * Creates a new steams-selected message. The message is used to announce
2589 * that an array of streams has been selected. This is generally in response
2590 * to a #GST_EVENT_SELECT_STREAMS event, or when an element (such as decodebin3)
2591 * makes an initial selection of streams.
2593 * The message also contains the #GstStreamCollection to which the various streams
2596 * Users of gst_message_new_streams_selected() can add the selected streams with
2597 * gst_message_streams_selected_add().
2599 * Returns: a newly allocated #GstMessage
2604 gst_message_new_streams_selected (GstObject * src,
2605 GstStreamCollection * collection)
2607 GstMessage *message;
2608 GstStructure *structure;
2609 GValue val = G_VALUE_INIT;
2611 g_return_val_if_fail (collection != NULL, NULL);
2612 g_return_val_if_fail (GST_IS_STREAM_COLLECTION (collection), NULL);
2615 gst_structure_new_id (GST_QUARK (MESSAGE_STREAMS_SELECTED),
2616 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);
2617 g_value_init (&val, GST_TYPE_ARRAY);
2618 gst_structure_id_take_value (structure, GST_QUARK (STREAMS), &val);
2620 gst_message_new_custom (GST_MESSAGE_STREAMS_SELECTED, src, structure);
2626 * gst_message_streams_selected_get_size:
2627 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2629 * Returns the number of streams contained in the @message.
2631 * Returns: The number of streams contained within.
2636 gst_message_streams_selected_get_size (GstMessage * msg)
2640 g_return_val_if_fail (GST_IS_MESSAGE (msg), 0);
2641 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2645 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2646 GST_QUARK (STREAMS));
2647 return gst_value_array_get_size (val);
2651 * gst_message_streams_selected_add:
2652 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2653 * @stream: (transfer none): a #GstStream to add to @message
2655 * Adds the @stream to the @message.
2660 gst_message_streams_selected_add (GstMessage * msg, GstStream * stream)
2663 GValue to_add = G_VALUE_INIT;
2665 g_return_if_fail (GST_IS_MESSAGE (msg));
2666 g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED);
2667 g_return_if_fail (GST_IS_STREAM (stream));
2670 (GValue *) gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2671 GST_QUARK (STREAMS));
2672 g_value_init (&to_add, GST_TYPE_STREAM);
2673 g_value_set_object (&to_add, stream);
2674 gst_value_array_append_and_take_value (val, &to_add);
2678 * gst_message_streams_selected_get_stream:
2679 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2680 * @idx: Index of the stream to retrieve
2682 * Retrieves the #GstStream with index @index from the @message.
2684 * Returns: (transfer full): A #GstStream
2689 gst_message_streams_selected_get_stream (GstMessage * msg, guint idx)
2691 const GValue *streams, *val;
2693 g_return_val_if_fail (GST_IS_MESSAGE (msg), NULL);
2694 g_return_val_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_STREAMS_SELECTED,
2698 gst_structure_id_get_value (GST_MESSAGE_STRUCTURE (msg),
2699 GST_QUARK (STREAMS));
2700 val = gst_value_array_get_value (streams, idx);
2702 return (GstStream *) g_value_dup_object (val);
2709 * gst_message_parse_streams_selected:
2710 * @message: a #GstMessage of type %GST_MESSAGE_STREAMS_SELECTED
2711 * @collection: (out) (allow-none) (transfer none): A location where to store a
2712 * pointer to the #GstStreamCollection, or %NULL
2714 * Parses a streams-selected message.
2719 gst_message_parse_streams_selected (GstMessage * message,
2720 GstStreamCollection ** collection)
2722 g_return_if_fail (GST_IS_MESSAGE (message));
2723 g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAMS_SELECTED);
2726 gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
2727 GST_QUARK (COLLECTION), GST_TYPE_STREAM_COLLECTION, collection, NULL);