From 7a85af3ce6b0c8a57c64891ddd35fba880d8ba20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 12 Mar 2009 23:54:12 +0000 Subject: xdgmime: make xdg typefinder more conservative The whole raison d'etre of this typefinder is to help avoid false positives when used in combination with our main typefinder in -base. Its task is not really to typefind audio/video files, even less so given that it detects *MIME* types, not GStreamer media types. Therefore, if this typefinder detects an audio or video type, don't even suggest it - our own typefinders are hopefully better at this and detect the right type of type on top of that, and even if they're not we really want to know about it and fix it. Fixes #575157. --- gst/xdgmime/gstxdgmime.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'gst') diff --git a/gst/xdgmime/gstxdgmime.c b/gst/xdgmime/gstxdgmime.c index 04f86123..74253bfa 100644 --- a/gst/xdgmime/gstxdgmime.c +++ b/gst/xdgmime/gstxdgmime.c @@ -36,7 +36,6 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data) guint64 tf_length; gint prio; guint8 *data; - GstCaps *caps; if ((tf_length = gst_type_find_get_length (find)) > 0) length = MIN (length, tf_length); @@ -57,8 +56,25 @@ xdgmime_typefind (GstTypeFind * find, gpointer user_data) GST_DEBUG ("Got mimetype '%s' with prio %d", mimetype, prio); - caps = gst_caps_new_simple (mimetype, NULL); - gst_type_find_suggest (find, GST_TYPE_FIND_POSSIBLE, caps); + /* Ignore audio/video types: + * - our own typefinders in -base are likely to be better at this + * (and if they're not, we really want to fix them, that's why we don't + * report xdg-detected audio/video types at all, not even with a low + * probability) + * - we want to detect GStreamer media types and not MIME types + * - the purpose of this xdg mime finder is mainly to prevent false + * positives of non-media formats, not to typefind audio/video formats */ + if (g_str_has_prefix (mimetype, "audio/") || + g_str_has_prefix (mimetype, "video/")) { + GST_LOG ("Ignoring audio/video mime type"); + return; + } + + /* Again, we mainly want the xdg typefinding to prevent false-positives on + * non-media formats, so suggest the type with a probability that trumps + * uncertain results of our typefinders, but not more than that. */ + GST_LOG ("Suggesting '%s' with probability POSSIBLE", mimetype); + gst_type_find_suggest_simple (find, GST_TYPE_FIND_POSSIBLE, mimetype, NULL); } static gboolean -- cgit v1.2.1