mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 09:55:36 +00:00
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.
This commit is contained in:
parent
a9c82f9472
commit
9ca2bf36de
5 changed files with 59 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _GstSsaParse {
|
|||
GstPad *srcpad;
|
||||
|
||||
gboolean framed;
|
||||
gboolean send_tags;
|
||||
|
||||
gchar *ini;
|
||||
};
|
||||
|
|
|
@ -317,6 +317,31 @@ gst_sub_parse_get_property (GObject * object, guint prop_id,
|
|||
GST_OBJECT_UNLOCK (subparse);
|
||||
}
|
||||
|
||||
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))) {
|
||||
|
|
|
@ -81,6 +81,7 @@ struct _GstSubParse {
|
|||
|
||||
GstSubParseFormat parser_type;
|
||||
gboolean parser_detected;
|
||||
const gchar *subtitle_codec;
|
||||
|
||||
Parser parse_line;
|
||||
ParserState state;
|
||||
|
|
Loading…
Reference in a new issue