From 763f4c3fc3bf6ece9f747e4e5bd8c26a807d01fb Mon Sep 17 00:00:00 2001 From: David Corvoysier Date: Wed, 17 Oct 2012 15:50:33 +0200 Subject: [PATCH] Added a typefind helper for DASH: this commit should be reverted as soon as a proper patch has been submitted to gst-plugins-base --- ext/dash/Makefile.am | 2 +- ext/dash/gstplugin.c | 85 ++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 4 deletions(-) diff --git a/ext/dash/Makefile.am b/ext/dash/Makefile.am index b0f72e4d0f..f0489ee058 100644 --- a/ext/dash/Makefile.am +++ b/ext/dash/Makefile.am @@ -18,7 +18,7 @@ noinst_HEADERS = \ # compiler and linker flags used to compile this plugin, set in configure.ac libgstdashdemux_la_CFLAGS = $(GST_CFLAGS) -libgstdashdemux_la_LIBADD = $(GST_LIBS) +libgstdashdemux_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) libgstdashdemux_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) libgstdashdemux_la_LIBTOOLFLAGS = --tag=disable-static diff --git a/ext/dash/gstplugin.c b/ext/dash/gstplugin.c index f6712c6baf..9e7361869a 100644 --- a/ext/dash/gstplugin.c +++ b/ext/dash/gstplugin.c @@ -2,6 +2,8 @@ # include #endif +#include + #include #include "gstfragmented.h" @@ -9,14 +11,93 @@ GST_DEBUG_CATEGORY (fragmented_debug); +#define XML_BUFFER_SIZE 16 +#define XML_INC_BUFFER { \ + pos++; \ + if (pos == XML_BUFFER_SIZE) { \ + pos = 0; \ + offset += XML_BUFFER_SIZE; \ + data = gst_type_find_peek (tf, offset, XML_BUFFER_SIZE); \ + if (data == NULL) return FALSE; \ + } else { \ + data++; \ + } \ +} + +static gboolean +xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen, + gboolean strict) +{ + gboolean got_xmldec; + const guint8 *data; + guint offset = 0; + guint pos = 0; + + data = gst_type_find_peek (tf, 0, XML_BUFFER_SIZE); + if (!data) + return FALSE; + + /* look for the XMLDec + * see XML spec 2.8, Prolog and Document Type Declaration + * http://www.w3.org/TR/2004/REC-xml-20040204/#sec-prolog-dtd */ + got_xmldec = (memcmp (data, "