pwg: fixup tag docs

This commit is contained in:
Wim Taymans 2012-10-01 10:40:54 +02:00
parent 16d0728e98
commit 98b133fe54

View file

@ -65,13 +65,10 @@
of the type the tag was registered as (the API documentation for each of the type the tag was registered as (the API documentation for each
predefined tag should contain the type). Be sure to use functions like predefined tag should contain the type). Be sure to use functions like
<function>gst_value_transform ()</function> <function>gst_value_transform ()</function>
to make sure that your data is of the right type. After data reading, the to make sure that your data is of the right type.
application can be notified of the new taglist by calling After data reading, you can send the tags downstream with the TAG event.
<function>gst_element_found_tags ()</function> or When the TAG event reaches the sink, it will post the TAG message on
<function>gst_element_found_tags_for_pad ()</function> (if they only the pipeline's GstBus for the application to pick up.
refer to a specific sub-stream). These functions will post a tag message
on the pipeline's GstBus for the application to pick up, but also send
tag events downstream, either over all source pad or the pad specified.
</para> </para>
<para> <para>
We currently require the core to know the GType of tags before they are We currently require the core to know the GType of tags before they are
@ -112,7 +109,7 @@ gst_my_filter_class_init (GstMyFilterClass *klass)
TagSetter interface (which is just a layer). Pipeline tags are tags TagSetter interface (which is just a layer). Pipeline tags are tags
provided to the element from within the pipeline. The element receives provided to the element from within the pipeline. The element receives
such tags via the <symbol>GST_EVENT_TAG</symbol> event, which means such tags via the <symbol>GST_EVENT_TAG</symbol> event, which means
that tags writers should automatically be event aware. The tag writer is that tags writers should implment an event handler. The tag writer is
responsible for combining all these three into one list and writing them responsible for combining all these three into one list and writing them
to the output stream. to the output stream.
</para> </para>
@ -122,6 +119,10 @@ gst_my_filter_class_init (GstMyFilterClass *klass)
setter so applications can set tags, and retrieves pipeline tags from setter so applications can set tags, and retrieves pipeline tags from
incoming events. incoming events.
</para> </para>
<para>
Warning, this example is outdated and doesn't work with the 1.0 version
of &GStreamer; anymore.
</para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
GType GType
@ -143,7 +144,6 @@ gst_my_filter_get_type (void)
static void static void
gst_my_filter_init (GstMyFilter *filter) gst_my_filter_init (GstMyFilter *filter)
{ {
GST_FLAG_SET (filter, GST_ELEMENT_EVENT_AWARE);
[..] [..]
} }
@ -165,14 +165,18 @@ gst_my_filter_write_tag (const GstTagList *taglist,
g_value_init (&to, G_TYPE_STRING); g_value_init (&to, G_TYPE_STRING);
for (n = 0; n < num_values; n++) { for (n = 0; n < num_values; n++) {
guint8 * data;
gsize size;
from = gst_tag_list_get_value_index (taglist, tagname, n); from = gst_tag_list_get_value_index (taglist, tagname, n);
g_value_transform (from, &to); g_value_transform (from, &to);
buf = gst_buffer_new (); data = g_strdup_printf ("%s:%s", tagname,
GST_BUFFER_DATA (buf) = g_strdup_printf ("%s:%s", tagname, g_value_get_string (&to));
g_value_get_string (&to)); size = strlen (data);
GST_BUFFER_SIZE (buf) = strlen (GST_BUFFER_DATA (buf));
gst_pad_push (filter->srcpad, GST_DATA (buf)); buf = gst_buffer_new_wrapped (data, size);
gst_pad_push (filter->srcpad, buf);
} }
g_value_unset (&to); g_value_unset (&to);
@ -223,8 +227,7 @@ gst_my_filter_task_func (GstElement *element)
gst_tag_list_foreach (taglist, gst_my_filter_write_tag, filter); gst_tag_list_foreach (taglist, gst_my_filter_write_tag, filter);
/* signal EOS */ /* signal EOS */
gst_pad_push (filter->srcpad, GST_DATA (gst_event_new (GST_EVENT_EOS))); gst_pad_push (filter->srcpad, gst_event_new (GST_EVENT_EOS));
gst_element_set_eos (element);
} }
]]> ]]>
</programlisting> </programlisting>