mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
API: Add gst_message_{new,parse}_tag_full() to get/set the source pad
Fixes bug #582588.
This commit is contained in:
parent
db6f445620
commit
4e8f547f98
6 changed files with 88 additions and 6 deletions
|
@ -1108,7 +1108,9 @@ gst_message_parse_warning
|
|||
gst_message_new_info
|
||||
gst_message_parse_info
|
||||
gst_message_new_tag
|
||||
gst_message_new_tag_full
|
||||
gst_message_parse_tag
|
||||
gst_message_parse_tag_full
|
||||
gst_message_new_buffering
|
||||
gst_message_parse_buffering
|
||||
gst_message_set_buffering_stats
|
||||
|
|
|
@ -472,6 +472,39 @@ gst_message_new_tag (GstObject * src, GstTagList * tag_list)
|
|||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_message_new_tag_full:
|
||||
* @src: The object originating the message.
|
||||
* @pad: The originating pad for the tag.
|
||||
* @tag_list: The tag list for the message.
|
||||
*
|
||||
* Create a new tag message. The message will take ownership of the tag list.
|
||||
* The message is posted by elements that discovered a new taglist.
|
||||
*
|
||||
* Returns: The new tag message.
|
||||
*
|
||||
* Since: 0.10.24
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
GstMessage *
|
||||
gst_message_new_tag_full (GstObject * src, GstPad * pad, GstTagList * tag_list)
|
||||
{
|
||||
GstMessage *message;
|
||||
GstStructure *s;
|
||||
|
||||
g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL);
|
||||
g_return_val_if_fail (pad == NULL || GST_IS_PAD (pad), NULL);
|
||||
|
||||
s = (GstStructure *) tag_list;
|
||||
if (pad)
|
||||
gst_structure_set (s, "source-pad", GST_TYPE_PAD, pad, NULL);
|
||||
|
||||
message = gst_message_new_custom (GST_MESSAGE_TAG, src, s);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_message_new_buffering:
|
||||
* @src: The object originating the message.
|
||||
|
@ -970,11 +1003,57 @@ gst_message_get_structure (GstMessage * message)
|
|||
void
|
||||
gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
|
||||
{
|
||||
GstStructure *ret;
|
||||
|
||||
g_return_if_fail (GST_IS_MESSAGE (message));
|
||||
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
|
||||
g_return_if_fail (tag_list != NULL);
|
||||
|
||||
*tag_list = (GstTagList *) gst_structure_copy (message->structure);
|
||||
ret = gst_structure_copy (message->structure);
|
||||
gst_structure_remove_field (ret, "source-pad");
|
||||
|
||||
*tag_list = (GstTagList *) ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_message_parse_tag_full:
|
||||
* @message: A valid #GstMessage of type GST_MESSAGE_TAG.
|
||||
* @pad: Location where the originating pad is stored, unref after usage
|
||||
* @tag_list: Return location for the tag-list.
|
||||
*
|
||||
* Extracts the tag list from the GstMessage. The tag list returned in the
|
||||
* output argument is a copy; the caller must free it when done.
|
||||
*
|
||||
* Since: 0.10.24
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
void
|
||||
gst_message_parse_tag_full (GstMessage * message, GstPad ** pad,
|
||||
GstTagList ** tag_list)
|
||||
{
|
||||
GstStructure *ret;
|
||||
|
||||
g_return_if_fail (GST_IS_MESSAGE (message));
|
||||
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_TAG);
|
||||
g_return_if_fail (tag_list != NULL);
|
||||
|
||||
ret = gst_structure_copy (message->structure);
|
||||
|
||||
if (gst_structure_has_field (ret, "source-pad") && pad) {
|
||||
const GValue *v;
|
||||
|
||||
v = gst_structure_get_value (ret, "source-pad");
|
||||
if (v && G_VALUE_HOLDS (v, GST_TYPE_PAD))
|
||||
*pad = g_value_dup_object (v);
|
||||
else
|
||||
*pad = NULL;
|
||||
} else if (pad) {
|
||||
*pad = NULL;
|
||||
}
|
||||
gst_structure_remove_field (ret, "source-pad");
|
||||
|
||||
*tag_list = (GstTagList *) ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -360,7 +360,9 @@ void gst_message_parse_info (GstMessage *message, GError **gerror, gchar **de
|
|||
|
||||
/* TAG */
|
||||
GstMessage * gst_message_new_tag (GstObject * src, GstTagList * tag_list);
|
||||
GstMessage * gst_message_new_tag_full (GstObject * src, GstPad *pad, GstTagList * tag_list);
|
||||
void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list);
|
||||
void gst_message_parse_tag_full (GstMessage *message, GstPad **pad, GstTagList **tag_list);
|
||||
|
||||
/* BUFFERING */
|
||||
GstMessage * gst_message_new_buffering (GstObject * src, gint percent);
|
||||
|
|
|
@ -3081,11 +3081,9 @@ gst_element_found_tags_for_pad (GstElement * element,
|
|||
g_return_if_fail (list != NULL);
|
||||
|
||||
gst_pad_push_event (pad, gst_event_new_tag (gst_tag_list_copy (list)));
|
||||
/* FIXME 0.11: Set the pad as source to make it possible to detect for
|
||||
* which pad the tags are actually found.
|
||||
*/
|
||||
/* FIXME 0.11: Set the pad as source. */
|
||||
gst_element_post_message (element,
|
||||
gst_message_new_tag (GST_OBJECT (element), list));
|
||||
gst_message_new_tag_full (GST_OBJECT (element), pad, list));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -5,7 +5,6 @@ EXPORTS
|
|||
gst_adapter_copy
|
||||
gst_adapter_flush
|
||||
gst_adapter_get_type
|
||||
gst_adapter_masked_scan_uint32
|
||||
gst_adapter_new
|
||||
gst_adapter_peek
|
||||
gst_adapter_prev_timestamp
|
||||
|
|
|
@ -490,6 +490,7 @@ EXPORTS
|
|||
gst_message_new_stream_status
|
||||
gst_message_new_structure_change
|
||||
gst_message_new_tag
|
||||
gst_message_new_tag_full
|
||||
gst_message_new_warning
|
||||
gst_message_parse_async_start
|
||||
gst_message_parse_buffering
|
||||
|
@ -507,6 +508,7 @@ EXPORTS
|
|||
gst_message_parse_stream_status
|
||||
gst_message_parse_structure_change
|
||||
gst_message_parse_tag
|
||||
gst_message_parse_tag_full
|
||||
gst_message_parse_warning
|
||||
gst_message_set_buffering_stats
|
||||
gst_message_set_seqnum
|
||||
|
|
Loading…
Reference in a new issue