From: Tim-Philipp Müller Date: Thu, 11 Jun 2009 21:32:28 +0000 (+0100) Subject: subparse, ogmparse: post tags with GST_TAG_SUBTITLE_CODEC X-Git-Tag: 1.19.3~511^2~9559 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9ca2bf36def6124d6a56ea182505a8df2872f4fa;p=platform%2Fupstream%2Fgstreamer.git subparse, ogmparse: post tags with GST_TAG_SUBTITLE_CODEC Make subtitle parsers post a taglist with codec tags, so the application knows what kind of subtitle a subtitle stream is. Fixes #576552. --- diff --git a/ext/ogg/gstogmparse.c b/ext/ogg/gstogmparse.c index b52b466..630fd3e 100644 --- a/ext/ogg/gstogmparse.c +++ b/ext/ogg/gstogmparse.c @@ -664,6 +664,15 @@ gst_ogm_parse_stream_header (GstOgmParse * ogm, const guint8 * data, guint size) gst_pad_push_event (ogm->srcpad, event); } g_list_free (cached_events); + + { + GstTagList *tags; + + tags = gst_tag_list_new (); + gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC, + "Ogm", NULL); + gst_element_found_tags_for_pad (GST_ELEMENT (ogm), ogm->srcpad, tags); + } } gst_caps_unref (caps); diff --git a/gst/subparse/gstssaparse.c b/gst/subparse/gstssaparse.c index d720d1a..0d8010a 100644 --- a/gst/subparse/gstssaparse.c +++ b/gst/subparse/gstssaparse.c @@ -107,6 +107,7 @@ gst_ssa_parse_init (GstSsaParse * parse, GstSsaParseClass * klass) parse->ini = NULL; parse->framed = FALSE; + parse->send_tags = FALSE; } static void @@ -152,6 +153,7 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps) } parse->framed = TRUE; + parse->send_tags = TRUE; priv = (GstBuffer *) gst_value_get_mini_object (val); g_return_val_if_fail (priv != NULL, FALSE); @@ -304,6 +306,16 @@ gst_ssa_parse_chain (GstPad * sinkpad, GstBuffer * buf) if (G_UNLIKELY (!parse->framed)) goto not_framed; + if (G_UNLIKELY (parse->send_tags)) { + GstTagList *tags; + + tags = gst_tag_list_new (); + gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC, + "SubStation Alpha", NULL); + gst_element_found_tags_for_pad (GST_ELEMENT (parse), parse->srcpad, tags); + parse->send_tags = FALSE; + } + /* make double-sure it's 0-terminated and all */ txt = g_strndup ((gchar *) GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); diff --git a/gst/subparse/gstssaparse.h b/gst/subparse/gstssaparse.h index 60593b1..518c3cd 100644 --- a/gst/subparse/gstssaparse.h +++ b/gst/subparse/gstssaparse.h @@ -40,6 +40,7 @@ struct _GstSsaParse { GstPad *srcpad; gboolean framed; + gboolean send_tags; gchar *ini; }; diff --git a/gst/subparse/gstsubparse.c b/gst/subparse/gstsubparse.c index 6aa312c..b75c165 100644 --- a/gst/subparse/gstsubparse.c +++ b/gst/subparse/gstsubparse.c @@ -318,6 +318,31 @@ gst_sub_parse_get_property (GObject * object, guint prop_id, } static gchar * +gst_sub_parse_get_format_description (GstSubParseFormat format) +{ + switch (format) { + case GST_SUB_PARSE_FORMAT_MDVDSUB: + return "MicroDVD"; + case GST_SUB_PARSE_FORMAT_SUBRIP: + return "SubRip"; + case GST_SUB_PARSE_FORMAT_MPSUB: + return "MPSub"; + case GST_SUB_PARSE_FORMAT_SAMI: + return "SAMI"; + case GST_SUB_PARSE_FORMAT_TMPLAYER: + return "TMPlayer"; + case GST_SUB_PARSE_FORMAT_MPL2: + return "MPL2"; + case GST_SUB_PARSE_FORMAT_SUBVIEWER: + return "SubViewer"; + default: + case GST_SUB_PARSE_FORMAT_UNKNOWN: + break; + } + return NULL; +} + +static gchar * gst_convert_to_utf8 (const gchar * str, gsize len, const gchar * encoding, gsize * consumed, GError ** err) { @@ -1144,6 +1169,7 @@ gst_sub_parse_format_autodetect (GstSubParse * self) g_free (data); self->parser_type = format; + self->subtitle_codec = gst_sub_parse_get_format_description (format); parser_state_init (&self->state); switch (format) { @@ -1254,6 +1280,16 @@ handle_buffer (GstSubParse * self, GstBuffer * buf) return GST_FLOW_UNEXPECTED; } gst_caps_unref (caps); + + /* push tags */ + if (self->subtitle_codec != NULL) { + GstTagList *tags; + + tags = gst_tag_list_new (); + gst_tag_list_add (tags, GST_TAG_MERGE_APPEND, GST_TAG_SUBTITLE_CODEC, + self->subtitle_codec, NULL); + gst_element_found_tags_for_pad (GST_ELEMENT (self), self->srcpad, tags); + } } while (!self->flushing && (line = get_next_line (self))) { diff --git a/gst/subparse/gstsubparse.h b/gst/subparse/gstsubparse.h index f40ccee..cd3765d 100644 --- a/gst/subparse/gstsubparse.h +++ b/gst/subparse/gstsubparse.h @@ -81,6 +81,7 @@ struct _GstSubParse { GstSubParseFormat parser_type; gboolean parser_detected; + const gchar *subtitle_codec; Parser parse_line; ParserState state;