From 3b0897e82784d3d401b5745560d118477d8cfd23 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Tue, 16 Aug 2005 16:29:04 +0000 Subject: [PATCH] gst/gstutils.*: Add two utility functions for tag handling. Original commit message from CVS: * gst/gstutils.c: (gst_element_found_tags_for_pad), (push_and_ref), (gst_element_found_tags): * gst/gstutils.h: Add two utility functions for tag handling. --- ChangeLog | 7 +++++++ gst/gstutils.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ gst/gstutils.h | 7 +++++++ 3 files changed, 69 insertions(+) diff --git a/ChangeLog b/ChangeLog index f10436e..2d9190d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2005-08-16 Ronald S. Bultje + * gst/gstutils.c: (gst_element_found_tags_for_pad), (push_and_ref), + (gst_element_found_tags): + * gst/gstutils.h: + Add two utility functions for tag handling. + +2005-08-16 Ronald S. Bultje + * docs/manual/advanced-dataaccess.xml: * docs/manual/basics-helloworld.xml: Fix docs to use _bin_add() before _link(), which fixes the examples diff --git a/gst/gstutils.c b/gst/gstutils.c index e8bfc64..cf7d6d0 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -2382,3 +2382,58 @@ gst_pad_remove_buffer_probe (GstPad * pad, GCallback handler, gpointer data) count, GST_DEBUG_PAD_NAME (pad), GST_PAD_DO_BUFFER_SIGNALS (pad)); GST_UNLOCK (pad); } + +/** + * gst_element_found_tags_for_pad: + * @element: element for which to post taglist to bus. + * @pad: pad on which to push tag-event. + * @list: the taglist to post on the bus and create event from. + * + * Posts a message to the bus that new tags were found and pushes the + * tags as event. Takes ownership of the taglist. + */ +void +gst_element_found_tags_for_pad (GstElement * element, + GstPad * pad, GstTagList * list) +{ + g_return_if_fail (element != NULL); + g_return_if_fail (pad != NULL); + g_return_if_fail (list != NULL); + + gst_pad_push_event (pad, gst_event_new_tag (gst_tag_list_copy (list))); + gst_element_post_message (element, + gst_message_new_tag (GST_OBJECT (element), list)); +} + +static void +push_and_ref (GstPad * pad, GstEvent * event) +{ + gst_pad_push_event (pad, gst_event_ref (event)); +} + +/** + * gst_element_found_tags: + * @element: element for which we found the tags. + * @list: list of tags. + * + * Posts a message to the bus that new tags were found, and pushes an event + * to all sourcepads. Takes ownership of the taglist. + */ +void +gst_element_found_tags (GstElement * element, GstTagList * list) +{ + GstIterator *iter; + GstEvent *event; + + g_return_if_fail (element != NULL); + g_return_if_fail (list != NULL); + + iter = gst_element_iterate_src_pads (element); + event = gst_event_new_tag (gst_tag_list_copy (list)); + gst_iterator_foreach (iter, (GFunc) 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)); +} diff --git a/gst/gstutils.h b/gst/gstutils.h index 656f961..3e21b9f 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -331,6 +331,13 @@ void gst_pad_remove_buffer_probe (GstPad * pad, GCallback handler, gpointer data); +/* tag emission utility functions */ +void gst_element_found_tags_for_pad (GstElement * element, + GstPad * pad, + GstTagList * list); +void gst_element_found_tags (GstElement * element, + GstTagList * list); + G_END_DECLS #endif /* __GST_UTILS_H__ */ -- 2.7.4