tags: Remove crazy tag messages

Don't mix messages and pads and tags.
Make the sink post tag messages when a tag event is received.
Since tags are sticky on pads now, they can be retrieved from there
when needed.
This commit is contained in:
Wim Taymans 2011-06-22 16:16:56 +02:00
parent 314a2b961a
commit 6da2a33b7a
4 changed files with 15 additions and 86 deletions

View file

@ -481,39 +481,6 @@ gst_message_new_tag (GstObject * src, GstTagList * tag_list)
return message;
}
/**
* gst_message_new_tag_full:
* @src: (transfer none): the object originating the message.
* @pad: (transfer none): the originating pad for the tag.
* @tag_list: (transfer full): 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.
*
* MT safe.
*
* Returns: (transfer full): the new tag message.
*
* Since: 0.10.24
*/
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: (transfer none): The object originating the message.
@ -1053,48 +1020,6 @@ gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
*tag_list = (GstTagList *) ret;
}
/**
* gst_message_parse_tag_full:
* @message: A valid #GstMessage of type GST_MESSAGE_TAG.
* @pad: (out callee-allocates): location where the originating pad is stored,
* unref after usage
* @tag_list: (out callee-allocates): 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.
*
* MT safe.
*
* Since: 0.10.24
*/
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 (GST_MESSAGE_STRUCTURE (message));
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;
}
/**
* gst_message_parse_buffering:
* @message: A valid #GstMessage of type GST_MESSAGE_BUFFERING.

View file

@ -425,9 +425,7 @@ void gst_message_parse_info (GstMessage *message, GError **g
/* 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);

View file

@ -3049,9 +3049,6 @@ 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. */
gst_element_post_message (element,
gst_message_new_tag_full (GST_OBJECT (element), pad, list));
}
static void
@ -3087,9 +3084,6 @@ gst_element_found_tags (GstElement * element, GstTagList * list)
gst_iterator_foreach (iter, (GstIteratorForeachFunction) push_and_ref, event);
gst_iterator_free (iter);
gst_event_unref (event);
gst_element_post_message (element,
gst_message_new_tag (GST_OBJECT (element), list));
}
static GstPad *

View file

@ -2066,8 +2066,8 @@ gst_base_sink_wait_clock (GstBaseSink * sink, GstClockTime time,
/* FIXME: Casting to GstClockEntry only works because the types
* are the same */
if (G_LIKELY (sink->priv->cached_clock_id != NULL
&& GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->priv->
cached_clock_id) == clock)) {
&& GST_CLOCK_ENTRY_CLOCK ((GstClockEntry *) sink->
priv->cached_clock_id) == clock)) {
if (!gst_clock_single_shot_id_reinit (clock, sink->priv->cached_clock_id,
time)) {
gst_clock_id_unref (sink->priv->cached_clock_id);
@ -2958,7 +2958,19 @@ again:
gst_base_sink_configure_segment (basesink, pad, event,
&basesink->segment);
break;
case GST_EVENT_SINK_MESSAGE:{
case GST_EVENT_TAG:
{
GstTagList *taglist;
gst_event_parse_tag (event, &taglist);
gst_element_post_message (GST_ELEMENT_CAST (basesink),
gst_message_new_tag (GST_OBJECT_CAST (basesink),
gst_tag_list_copy (taglist)));
break;
}
case GST_EVENT_SINK_MESSAGE:
{
GstMessage *msg = NULL;
gst_event_parse_sink_message (event, &msg);