mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 03:01:03 +00:00
message: Add gst_message_writable_structure()
Add gst_message_writable_structure() to be able to add extra fields to messages (and be on par with GstEvent). https://bugzilla.gnome.org/show_bug.cgi?id=792928
This commit is contained in:
parent
117200faeb
commit
46b1a6e505
5 changed files with 50 additions and 0 deletions
|
@ -1638,6 +1638,7 @@ gst_message_ref
|
|||
gst_message_unref
|
||||
gst_message_copy
|
||||
gst_message_get_structure
|
||||
gst_message_writable_structure
|
||||
gst_message_make_writable
|
||||
gst_message_get_seqnum
|
||||
gst_message_set_seqnum
|
||||
|
|
|
@ -1158,6 +1158,43 @@ gst_message_get_structure (GstMessage * message)
|
|||
return GST_MESSAGE_STRUCTURE (message);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_message_writable_structure:
|
||||
* @message: The #GstMessage.
|
||||
*
|
||||
* Get a writable version of the structure.
|
||||
*
|
||||
* Returns: (transfer none): The structure of the message. The structure
|
||||
* is still owned by the message, which means that you should not free
|
||||
* it and that the pointer becomes invalid when you free the message.
|
||||
* This function checks if @message is writable and will never return
|
||||
* %NULL.
|
||||
*
|
||||
* MT safe.
|
||||
*
|
||||
* Since: 1.14
|
||||
*/
|
||||
GstStructure *
|
||||
gst_message_writable_structure (GstMessage * message)
|
||||
{
|
||||
GstStructure *structure;
|
||||
|
||||
g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
|
||||
g_return_val_if_fail (gst_message_is_writable (message), NULL);
|
||||
|
||||
structure = GST_MESSAGE_STRUCTURE (message);
|
||||
|
||||
if (structure == NULL) {
|
||||
structure =
|
||||
gst_structure_new_id_empty (gst_message_type_to_quark (GST_MESSAGE_TYPE
|
||||
(message)));
|
||||
gst_structure_set_parent_refcount (structure,
|
||||
&message->mini_object.refcount);
|
||||
GST_MESSAGE_STRUCTURE (message) = structure;
|
||||
}
|
||||
return structure;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_message_has_name:
|
||||
* @message: The #GstMessage.
|
||||
|
|
|
@ -449,6 +449,9 @@ GST_EXPORT
|
|||
const GstStructure *
|
||||
gst_message_get_structure (GstMessage *message);
|
||||
|
||||
GST_EXPORT
|
||||
GstStructure * gst_message_writable_structure (GstMessage *message);
|
||||
|
||||
GST_EXPORT
|
||||
gboolean gst_message_has_name (GstMessage *message, const gchar *name);
|
||||
|
||||
|
|
|
@ -35,10 +35,18 @@ GST_START_TEST (test_parsing)
|
|||
|
||||
/* GST_MESSAGE_EOS */
|
||||
{
|
||||
GstStructure *s;
|
||||
|
||||
message = gst_message_new_eos (NULL);
|
||||
fail_if (message == NULL);
|
||||
fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EOS);
|
||||
fail_unless (GST_MESSAGE_SRC (message) == NULL);
|
||||
|
||||
/* Add an extra field */
|
||||
s = gst_message_writable_structure (message);
|
||||
fail_if (s == NULL);
|
||||
gst_structure_set (s, "eos-extra-field", G_TYPE_BOOLEAN, TRUE, NULL);
|
||||
|
||||
gst_message_unref (message);
|
||||
}
|
||||
/* GST_MESSAGE_ERROR */
|
||||
|
|
|
@ -826,6 +826,7 @@ EXPORTS
|
|||
gst_message_type_get_name
|
||||
gst_message_type_get_type
|
||||
gst_message_type_to_quark
|
||||
gst_message_writable_structure
|
||||
gst_meta_api_type_get_tags
|
||||
gst_meta_api_type_has_tag
|
||||
gst_meta_api_type_register
|
||||
|
|
Loading…
Reference in a new issue