diff options
author | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-07-13 22:51:48 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2009-07-13 23:00:04 +0100 |
commit | d53e754d42a0473b8ca049f8aaed23c2afcdb0d3 (patch) | |
tree | f727fcb07fed9f9d2a4a0b3a04cdf922d6fdc1c5 | |
parent | 0a5d5206f36c189d8072eeeaf25c0f7eaba4f2d8 (diff) | |
download | gstreamer-plugins-base-d53e754d42a0473b8ca049f8aaed23c2afcdb0d3.tar.gz |
typefinding: use subtitle/x-kate for Kate subtitle streams and application/x-kate for the rest
Differentiate subtitle streams and lyrics/cracktastic/complex streams via
the category string in the headers. This seems like a useful distinction
to make, and also seems more future-proof. See #525743.
-rw-r--r-- | gst-libs/gst/pbutils/descriptions.c | 3 | ||||
-rw-r--r-- | gst/typefind/gsttypefindfunctions.c | 30 |
2 files changed, 30 insertions, 3 deletions
diff --git a/gst-libs/gst/pbutils/descriptions.c b/gst-libs/gst/pbutils/descriptions.c index 90acada81..a51fc573d 100644 --- a/gst-libs/gst/pbutils/descriptions.c +++ b/gst-libs/gst/pbutils/descriptions.c @@ -215,7 +215,8 @@ static const FormatInfo formats[] = { /* subtitle formats with static descriptions */ {"application/x-subtitle-sami", N_("Sami subtitle format"), 0}, {"application/x-subtitle-tmplayer", N_("TMPlayer subtitle format"), 0}, - {"application/x-kate", N_("Kate subtitle format"), 0}, + {"application/x-kate", "Kate", 0}, + {"subtitle/x-kate", N_("Kate subtitle format"), 0}, /* add variant field to typefinder? { "application/x-subtitle", N_("subtitle"), 0}, */ /* non-audio/video/container formats */ diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 9603ec6ce..8a45ae4a0 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -2672,6 +2672,32 @@ theora_type_find (GstTypeFind * tf, gpointer private) } } +/*** kate ***/ +static void +kate_type_find (GstTypeFind * tf, gpointer private) +{ + guint8 *data = gst_type_find_peek (tf, 0, 64); + gchar category[16] = { 0, }; + + if (G_UNLIKELY (data == NULL)) + return; + + /* see: http://wiki.xiph.org/index.php/OggKate#Format_specification */ + if (G_LIKELY (memcmp (data, "\200kate\0\0\0", 8) != 0)) + return; + + /* make sure we always have a NUL-terminated string */ + memcpy (category, data + 48, 15); + GST_LOG ("kate category: %s", category); + if (strstr (category, "subtitle") != NULL) { + gst_type_find_suggest_simple (tf, GST_TYPE_FIND_MAXIMUM, + "subtitle/x-kate", NULL); + } else { + gst_type_find_suggest_simple (tf, GST_TYPE_FIND_MAXIMUM, + "application/x-kate", NULL); + } +} + /*** application/x-ogm-video or audio***/ static GstStaticCaps ogmvideo_caps = @@ -3416,8 +3442,8 @@ plugin_init (GstPlugin * plugin) zip_exts, "PK\003\004", 4, GST_TYPE_FIND_LIKELY); TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-compress", GST_RANK_SECONDARY, compress_exts, "\037\235", 2, GST_TYPE_FIND_LIKELY); - TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-kate", - GST_RANK_MARGINAL, NULL, "\200kate\0\0\0", 8, GST_TYPE_FIND_LIKELY); + TYPE_FIND_REGISTER (plugin, "subtitle/x-kate", GST_RANK_MARGINAL, + kate_type_find, NULL, NULL, NULL, NULL); TYPE_FIND_REGISTER (plugin, "audio/x-flac", GST_RANK_PRIMARY, flac_type_find, flac_exts, FLAC_CAPS, NULL, NULL); TYPE_FIND_REGISTER (plugin, "audio/x-vorbis", GST_RANK_PRIMARY, |