From 0bd8070ebde27a67efeea5cb6401a507bbf4b9e8 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Mon, 11 Jun 2012 11:09:24 +0100 Subject: [PATCH] typefind: probe for DVD ISO files, to avoid matching H.264 https://bugzilla.gnome.org/show_bug.cgi?id=674069 --- gst/typefind/gsttypefindfunctions.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 8e8c5df..10ac159 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -4568,6 +4568,32 @@ degas_type_find (GstTypeFind * tf, gpointer private) } } +/*** DVD ISO images (looks like H.264, see #674069) ***/ +static void +dvdiso_type_find (GstTypeFind * tf, gpointer private) +{ + /* 0x8000 bytes of zeros, then "\001CD001" */ + gint64 len; + const guint8 *data; + + len = gst_type_find_get_length (tf); + if (len < 0x8006) + return; + data = gst_type_find_peek (tf, 0, 0x8006); + if (G_UNLIKELY (data == NULL)) + return; + for (len = 0; len < 0x8000; len++) + if (data[len]) + return; + /* Can the '1' be anything else ? My three samples all have '1'. */ + if (memcmp (data + 0x8000, "\001CD001", 6)) + return; + + /* May need more inspection, we may be able to demux some of them */ + gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY, + "application/octet-stream", NULL); +} + /*** generic typefind for streams that have some data at a specific position***/ typedef struct { @@ -4939,6 +4965,8 @@ plugin_init (GstPlugin * plugin) TYPE_FIND_REGISTER (plugin, "image/x-degas", GST_RANK_MARGINAL, degas_type_find, NULL, NULL, NULL, NULL); + TYPE_FIND_REGISTER (plugin, "application/octet-stream", GST_RANK_MARGINAL, + dvdiso_type_find, NULL, NULL, NULL, NULL); return TRUE; } -- 2.7.4