From 76571840ef489a9935ae32b2cd775a7b67076daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 4 Aug 2009 10:35:34 +0200 Subject: [PATCH] typefindfunctions: Add SVG typefinder --- gst/typefind/gsttypefindfunctions.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index e4a780cede..31e1f58f9c 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -1271,6 +1271,29 @@ postscript_type_find (GstTypeFind * tf, gpointer unused) } +/*** image/svg+xml ***/ +static GstStaticCaps svg_caps = GST_STATIC_CAPS ("image/svg+xml"); + +#define SVG_CAPS (gst_static_caps_get(&svg_caps)) + +static void +svg_type_find (GstTypeFind * tf, gpointer unused) +{ + static const gchar svg_doctype[] = "!DOCTYPE svg"; + DataScanCtx c = { 0, NULL, 0 }; + + while (c.offset <= 1024) { + if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 12))) + break; + + if (memcmp (svg_doctype, c.data, 12) == 0) { + gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, SVG_CAPS); + return; + } + data_scan_ctx_advance (tf, &c, 1); + } +} + /*** multipart/x-mixed-replace mimestream ***/ static GstStaticCaps multipart_caps = @@ -3402,6 +3425,7 @@ plugin_init (GstPlugin * plugin) static gchar *imelody_exts[] = { "imy", "ime", "imelody", NULL }; static gchar *pdf_exts[] = { "pdf", NULL }; static gchar *ps_exts[] = { "ps", NULL }; + static gchar *svg_exts[] = { "svg", NULL }; static gchar *mxf_exts[] = { "mxf", NULL }; static gchar *msword_exts[] = { "doc", NULL }; static gchar *dsstore_exts[] = { "DS_Store", NULL }; @@ -3609,6 +3633,8 @@ plugin_init (GstPlugin * plugin) NULL); TYPE_FIND_REGISTER (plugin, "application/postscript", GST_RANK_SECONDARY, postscript_type_find, ps_exts, POSTSCRIPT_CAPS, NULL, NULL); + TYPE_FIND_REGISTER (plugin, "image/svg+xml", GST_RANK_SECONDARY, + svg_type_find, svg_exts, SVG_CAPS, NULL, NULL); TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-rar", GST_RANK_SECONDARY, rar_exts, "Rar!", 4, GST_TYPE_FIND_LIKELY); TYPE_FIND_REGISTER (plugin, "application/x-tar", GST_RANK_SECONDARY,