* application using the #GstBus.
*
* The basic use pattern of posting a message on a #GstBus is as follows:
- *
- * <example>
- * <title>Posting a #GstMessage</title>
- * <programlisting>
- * gst_bus_post (bus, gst_message_new_eos());
- * </programlisting>
- * </example>
+ * |[
+ * gst_bus_post (bus, gst_message_new_eos());
+ * ]|
*
* A #GstElement usually posts messages on the bus provided by the parent
* container using gst_element_post_message().
- *
- * Last reviewed on 2005-11-09 (0.9.4)
*/
{GST_MESSAGE_TOC, "toc", 0},
{GST_MESSAGE_RESET_TIME, "reset-time", 0},
{GST_MESSAGE_STREAM_START, "stream-start", 0},
+ {GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
+ {GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
+ {GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
+ {GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
{0, NULL, 0}
};
*
* Create a new custom-typed message. This can be used for anything not
* handled by other message-specific functions to pass a message to the
- * app. The structure field can be NULL.
+ * app. The structure field can be %NULL.
*
* Returns: (transfer full): The new message.
*
*
* Create a new error message. The message will copy @error and
* @debug. This message is posted by element when a fatal event
- * occured. The pipeline will probably (partially) stop. The application
+ * occurred. The pipeline will probably (partially) stop. The application
* receiving this message should stop the pipeline.
*
* Returns: (transfer full): the new error message.
* gst_message_new_clock_provide:
* @src: (transfer none): the object originating the message.
* @clock: (transfer none): the clock it provides
- * @ready: TRUE if the sender can provide a clock
+ * @ready: %TRUE if the sender can provide a clock
*
* Create a clock provide message. This message is posted whenever an
* element is ready to provide a clock or lost its ability to provide
* @clock: (transfer none): the new selected clock
*
* Create a new clock message. This message is posted whenever the
- * pipeline selectes a new clock for the pipeline.
+ * pipeline selects a new clock for the pipeline.
*
* Returns: (transfer full): The new new clock message.
*
* Create a new element-specific message. This is meant as a generic way of
* allowing one-way communication from an element to an application, for example
* "the firewire cable was unplugged". The format of the message should be
- * documented in the element's documentation. The structure field can be NULL.
+ * documented in the element's documentation. The structure field can be %NULL.
*
* Returns: (transfer full): The new element message.
*
* changed. A typical use case would be an audio server that wants to pause the
* pipeline because a higher priority stream is being played.
*
- * Returns: (transfer full): the new requst state message.
+ * Returns: (transfer full): the new request state message.
*
* MT safe.
*/
/**
* gst_message_parse_buffering_stats:
* @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.
- * @mode: (out) (allow-none): a buffering mode, or NULL
- * @avg_in: (out) (allow-none): the average input rate, or NULL
- * @avg_out: (out) (allow-none): the average output rate, or NULL
+ * @mode: (out) (allow-none): a buffering mode, or %NULL
+ * @avg_in: (out) (allow-none): the average input rate, or %NULL
+ * @avg_out: (out) (allow-none): the average output rate, or %NULL
* @buffering_left: (out) (allow-none): amount of buffering time left in
- * milliseconds, or NULL
+ * milliseconds, or %NULL
*
* Extracts the buffering stats values from @message.
*/
/**
* gst_message_parse_state_changed:
* @message: a valid #GstMessage of type GST_MESSAGE_STATE_CHANGED
- * @oldstate: (out) (allow-none): the previous state, or NULL
- * @newstate: (out) (allow-none): the new (current) state, or NULL
- * @pending: (out) (allow-none): the pending (target) state, or NULL
+ * @oldstate: (out) (allow-none): the previous state, or %NULL
+ * @newstate: (out) (allow-none): the new (current) state, or %NULL
+ * @pending: (out) (allow-none): the pending (target) state, or %NULL
*
* Extracts the old and new states from the GstMessage.
*
* gst_message_parse_clock_provide:
* @message: A valid #GstMessage of type GST_MESSAGE_CLOCK_PROVIDE.
* @clock: (out) (allow-none) (transfer none): a pointer to hold a clock
- * object, or NULL
- * @ready: (out) (allow-none): a pointer to hold the ready flag, or NULL
+ * object, or %NULL
+ * @ready: (out) (allow-none): a pointer to hold the ready flag, or %NULL
*
* Extracts the clock and ready flag from the GstMessage.
* The clock object returned remains valid until the message is freed.
* @message: A valid #GstMessage of type GST_MESSAGE_ERROR.
* @gerror: (out) (allow-none) (transfer full): location for the GError
* @debug: (out) (allow-none) (transfer full): location for the debug message,
- * or NULL
+ * or %NULL
*
* Extracts the GError and debug string from the GstMessage. The values returned
* in the output arguments are copies; the caller must free them when done.
* @message: A valid #GstMessage of type GST_MESSAGE_WARNING.
* @gerror: (out) (allow-none) (transfer full): location for the GError
* @debug: (out) (allow-none) (transfer full): location for the debug message,
- * or NULL
+ * or %NULL
*
* Extracts the GError and debug string from the GstMessage. The values returned
* in the output arguments are copies; the caller must free them when done.
* @message: A valid #GstMessage of type GST_MESSAGE_INFO.
* @gerror: (out) (allow-none) (transfer full): location for the GError
* @debug: (out) (allow-none) (transfer full): location for the debug message,
- * or NULL
+ * or %NULL
*
* Extracts the GError and debug string from the GstMessage. The values returned
* in the output arguments are copies; the caller must free them when done.
/**
* gst_message_parse_segment_start:
* @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_START.
- * @format: (out): Result location for the format, or NULL
- * @position: (out): Result location for the position, or NULL
+ * @format: (out) (allow-none): Result location for the format, or %NULL
+ * @position: (out) (allow-none): Result location for the position, or %NULL
*
* Extracts the position and format from the segment start message.
*
/**
* gst_message_parse_segment_done:
* @message: A valid #GstMessage of type GST_MESSAGE_SEGMENT_DONE.
- * @format: (out): Result location for the format, or NULL
- * @position: (out): Result location for the position, or NULL
+ * @format: (out) (allow-none): Result location for the format, or %NULL
+ * @position: (out) (allow-none): Result location for the position, or %NULL
*
* Extracts the position and format from the segment done message.
*
/**
* gst_message_parse_async_done:
* @message: A valid #GstMessage of type GST_MESSAGE_ASYNC_DONE.
- * @running_time: (out): Result location for the running_time or NULL
+ * @running_time: (out) (allow-none): Result location for the running_time or %NULL
*
* Extract the running_time from the async_done message.
*
/**
* gst_message_parse_request_state:
* @message: A valid #GstMessage of type GST_MESSAGE_REQUEST_STATE.
- * @state: (out): Result location for the requested state or NULL
+ * @state: (out) (allow-none): Result location for the requested state or %NULL
*
* Extract the requested state from the request_state message.
*
* @eos: the step caused EOS
*
* This message is posted by elements when they complete a part, when @intermediate set
- * to TRUE, or a complete step operation.
+ * to %TRUE, or a complete step operation.
*
* @duration will contain the amount of time (in GST_FORMAT_TIME) of the stepped
* @amount of media in format @format.
* This message is posted by elements when they accept or activate a new step
* event for @amount in @format.
*
- * @active is set to FALSE when the element accepted the new step event and has
+ * @active is set to %FALSE when the element accepted the new step event and has
* queued it for execution in the streaming threads.
*
- * @active is set to TRUE when the element has activated the step operation and
+ * @active is set to %TRUE when the element has activated the step operation and
* is now ready to start executing the step in the streaming thread. After this
- * message is emited, the application can queue a new step operation in the
+ * message is emitted, the application can queue a new step operation in the
* element.
*
* Returns: (transfer full): The new step_start message.
* @toc: (out) (transfer full): return location for the TOC.
* @updated: (out): return location for the updated flag.
*
- * Extract thef TOC from the #GstMessage. The TOC returned in the
+ * Extract the TOC from the #GstMessage. The TOC returned in the
* output argument is a copy; the caller must free it with
* gst_toc_unref() when done.
*
/**
* gst_message_parse_reset_time:
* @message: A valid #GstMessage of type GST_MESSAGE_RESET_TIME.
- * @running_time: (out): Result location for the running_time or NULL
+ * @running_time: (out) (allow-none): Result location for the running_time or
+ * %NULL
*
* Extract the running-time from the RESET_TIME message.
*
gst_message_new_stream_start (GstObject * src)
{
GstMessage *message;
+ GstStructure *s;
+
+ s = gst_structure_new_id_empty (GST_QUARK (MESSAGE_STREAM_START));
+ message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, s);
+
+ return message;
+}
+
+
+/**
+ * gst_message_set_group_id:
+ * @message: the message
+ * @group_id: the group id
+ *
+ * Sets the group id on the stream-start message.
+ *
+ * All streams that have the same group id are supposed to be played
+ * together, i.e. all streams inside a container file should have the
+ * same group id but different stream ids. The group id should change
+ * each time the stream is started, resulting in different group ids
+ * each time a file is played for example.
+ *
+ * MT safe.
+ *
+ * Since: 1.2
+ */
+void
+gst_message_set_group_id (GstMessage * message, guint group_id)
+{
+ GstStructure *structure;
+
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START);
+ g_return_if_fail (gst_message_is_writable (message));
+
+ structure = GST_MESSAGE_STRUCTURE (message);
+ gst_structure_id_set (structure, GST_QUARK (GROUP_ID), G_TYPE_UINT, group_id,
+ NULL);
+}
+
+/**
+ * gst_message_parse_group_id:
+ * @message: A valid #GstMessage of type GST_MESSAGE_STREAM_START.
+ * @group_id: (out) (allow-none): Result location for the group id or
+ * %NULL
+ *
+ * Extract the group from the STREAM_START message.
+ *
+ * Returns: %TRUE if the message had a group id set, %FALSE otherwise
+ *
+ * MT safe.
+ *
+ * Since: 1.2
+ */
+gboolean
+gst_message_parse_group_id (GstMessage * message, guint * group_id)
+{
+ GstStructure *structure;
+ const GValue *v;
+
+ g_return_val_if_fail (GST_IS_MESSAGE (message), FALSE);
+ g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_START,
+ FALSE);
+
+ if (!group_id)
+ return TRUE;
+
+ structure = GST_MESSAGE_STRUCTURE (message);
+
+ v = gst_structure_id_get_value (structure, GST_QUARK (GROUP_ID));
+ if (!v)
+ return FALSE;
+
+ *group_id = g_value_get_uint (v);
+ return TRUE;
+}
+
+/**
+ * gst_message_new_need_context:
+ * @src: (transfer none): The object originating the message.
+ * @context_type: The context type that is needed
+ *
+ * This message is posted when an element needs a specific #GstContext.
+ *
+ * Returns: (transfer full): The new need-context message.
+ *
+ * MT safe.
+ *
+ * Since: 1.2
+ */
+GstMessage *
+gst_message_new_need_context (GstObject * src, const gchar * context_type)
+{
+ GstMessage *message;
+ GstStructure *structure;
+
+ g_return_val_if_fail (context_type != NULL, NULL);
+
+ structure = gst_structure_new_id (GST_QUARK (MESSAGE_NEED_CONTEXT),
+ GST_QUARK (CONTEXT_TYPE), G_TYPE_STRING, context_type, NULL);
+ message = gst_message_new_custom (GST_MESSAGE_NEED_CONTEXT, src, structure);
+
+ return message;
+}
+
+/**
+ * gst_message_parse_context_type:
+ * @message: a GST_MESSAGE_NEED_CONTEXT type message
+ * @context_type: (out) (allow-none): the context type, or %NULL
+ *
+ * Parse a context type from an existing GST_MESSAGE_NEED_CONTEXT message.
+ *
+ * Returns: a #gboolean indicating if the parsing succeeded.
+ *
+ * Since: 1.2
+ */
+gboolean
+gst_message_parse_context_type (GstMessage * message,
+ const gchar ** context_type)
+{
+ GstStructure *structure;
+ const GValue *value;
+
+ g_return_val_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_NEED_CONTEXT,
+ FALSE);
+
+ structure = GST_MESSAGE_STRUCTURE (message);
+
+ if (context_type) {
+ value = gst_structure_id_get_value (structure, GST_QUARK (CONTEXT_TYPE));
+ *context_type = g_value_get_string (value);
+ }
+
+ return TRUE;
+}
+
+/**
+ * gst_message_new_have_context:
+ * @src: (transfer none): The object originating the message.
+ * @context: (transfer full): the context
+ *
+ * This message is posted when an element has a new local #GstContext.
+ *
+ * Returns: (transfer full): The new have-context message.
+ *
+ * MT safe.
+ *
+ * Since: 1.2
+ */
+GstMessage *
+gst_message_new_have_context (GstObject * src, GstContext * context)
+{
+ GstMessage *message;
+ GstStructure *structure;
+
+ structure = gst_structure_new_id (GST_QUARK (MESSAGE_HAVE_CONTEXT),
+ GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
+ message = gst_message_new_custom (GST_MESSAGE_HAVE_CONTEXT, src, structure);
+ gst_context_unref (context);
+
+ return message;
+}
+
+/**
+ * gst_message_parse_have_context:
+ * @message: A valid #GstMessage of type GST_MESSAGE_HAVE_CONTEXT.
+ * @context: (out) (transfer full) (allow-none): Result location for the
+ * context or %NULL
+ *
+ * Extract the context from the HAVE_CONTEXT message.
+ *
+ * MT safe.
+ *
+ * Since: 1.2
+ */
+void
+gst_message_parse_have_context (GstMessage * message, GstContext ** context)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_HAVE_CONTEXT);
+
+ if (context)
+ gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
+ GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
+}
+
+/**
+ * gst_message_new_device_added:
+ * @src: The #GstObject that created the message
+ * @device: (transfer none): The new #GstDevice
+ *
+ * Creates a new device-added message. The device-added message is produced by
+ * #GstDeviceMonitor or a #GstGlobalDeviceMonitor. They announce the appearance
+ * of monitored devices.
+ *
+ * Returns: a newly allocated #GstMessage
+ *
+ * Since: 1.4
+ */
+GstMessage *
+gst_message_new_device_added (GstObject * src, GstDevice * device)
+{
+ GstMessage *message;
+ GstStructure *structure;
- message = gst_message_new_custom (GST_MESSAGE_STREAM_START, src, NULL);
+ g_return_val_if_fail (device != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
+
+ structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
+ GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
+ message = gst_message_new_custom (GST_MESSAGE_DEVICE_ADDED, src, structure);
return message;
}
+
+/**
+ * gst_message_parse_device_added:
+ * @device: (out) (allow-none) (transfer none): A location where to store a
+ * pointer to the new #GstDevice, or %NULL
+ *
+ * Parses a device-added message. The device-added message is produced by
+ * #GstDeviceMonitor or a #GstGlobalDeviceMonitor. It announces the appearance
+ * of monitored devices.
+ *
+ * Since: 1.4
+ */
+void
+gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_ADDED);
+
+ if (device)
+ gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
+ GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
+}
+
+/**
+ * gst_message_new_device_removed:
+ * @src: The #GstObject that created the message
+ * @device: (transfer none): The removed #GstDevice
+ *
+ * Creates a new device-removed message. The device-removed message is produced
+ * by #GstDeviceMonitor or a #GstGlobalDeviceMonitor. They announce the
+ * disappearance of monitored devices.
+ *
+ * Returns: a newly allocated #GstMessage
+ *
+ * Since: 1.4
+ */
+GstMessage *
+gst_message_new_device_removed (GstObject * src, GstDevice * device)
+{
+ GstMessage *message;
+ GstStructure *structure;
+
+ g_return_val_if_fail (device != NULL, NULL);
+ g_return_val_if_fail (GST_IS_DEVICE (device), NULL);
+
+ structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
+ GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
+ message = gst_message_new_custom (GST_MESSAGE_DEVICE_REMOVED, src, structure);
+
+ return message;
+}
+
+/**
+ * gst_message_parse_device_removed:
+ * @device: (out) (allow-none) (transfer none): A location where to store a
+ * pointer to the removed #GstDevice, or %NULL
+ *
+ * Parses a device-removed message. The device-removed message is produced by
+ * #GstDeviceMonitor or a #GstGlobalDeviceMonitor. It announces the
+ * disappearance of monitored devices.
+ *
+ * Since: 1.4
+ */
+void
+gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
+{
+ g_return_if_fail (GST_IS_MESSAGE (message));
+ g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_DEVICE_REMOVED);
+
+ if (device)
+ gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
+ GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
+}