From 2a18fb3546915257b9bdfc722afd92c12f605a19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Wed, 20 Dec 2006 09:25:55 +0000 Subject: [PATCH] gst/typefind/gsttypefindfunctions.c: Add typefinder for VIVO files (my christmas present to the 90s). Original commit message from CVS: * gst/typefind/gsttypefindfunctions.c: (vivo_type_find), (plugin_init): Add typefinder for VIVO files (my christmas present to the 90s). --- ChangeLog | 6 ++++++ gst/typefind/gsttypefindfunctions.c | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/ChangeLog b/ChangeLog index a990b89..2404f56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-12-20 Tim-Philipp Müller + + * gst/typefind/gsttypefindfunctions.c: (vivo_type_find), + (plugin_init): + Add typefinder for VIVO files (my christmas present to the 90s). + 2006-12-16 Tim-Philipp Müller * gst/playback/gstdecodebin.c: (type_found): diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index 7b5bc37..0e99abf 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -2430,6 +2430,47 @@ mmsh_type_find (GstTypeFind * tf, gpointer unused) } } +/*** video/vivo ***/ + +static GstStaticCaps vivo_caps = GST_STATIC_CAPS ("video/vivo"); + +#define VIVO_CAPS gst_static_caps_get(&vivo_caps) + +static void +vivo_type_find (GstTypeFind * tf, gpointer unused) +{ + static const guint8 vivo_marker[] = { 'V', 'e', 'r', 's', 'i', 'o', 'n', + ':', 'V', 'i', 'v', 'o', '/' + }; + guint8 *data; + guint hdr_len, pos; + + data = gst_type_find_peek (tf, 0, 1024); + if (data == NULL || data[0] != 0x00) + return; + + if ((data[1] & 0x80)) { + if ((data[2] & 0x80)) + return; + hdr_len = ((guint) (data[1] & 0x7f)) << 7; + hdr_len += data[2]; + if (hdr_len > 2048) + return; + pos = 3; + } else { + hdr_len = data[1]; + pos = 2; + } + + /* 1008 = 1022 - strlen ("Version:Vivo/") - 1 */ + while (pos < 1008 && data[pos] == '\r' && data[pos + 1] == '\n') + pos += 2; + + if (memcmp (data + pos, vivo_marker, sizeof (vivo_marker)) == 0) { + gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, VIVO_CAPS); + } +} + /*** generic typefind for streams that have some data at a specific position***/ typedef struct { @@ -2798,6 +2839,8 @@ plugin_init (GstPlugin * plugin) multipart_type_find, NULL, MULTIPART_CAPS, NULL, NULL); TYPE_FIND_REGISTER (plugin, "application/x-mmsh", GST_RANK_SECONDARY, mmsh_type_find, NULL, MMSH_CAPS, NULL, NULL); + TYPE_FIND_REGISTER (plugin, "video/vivo", GST_RANK_SECONDARY, + vivo_type_find, NULL, VIVO_CAPS, NULL, NULL); return TRUE; } -- 2.7.4