9 #include "gstfragmented.h"
10 #include "gstdashdemux.h"
12 GST_DEBUG_CATEGORY (fragmented_debug);
14 #define XML_BUFFER_SIZE 16
15 #define XML_INC_BUFFER { \
17 if (pos == XML_BUFFER_SIZE) { \
19 offset += XML_BUFFER_SIZE; \
20 data = gst_type_find_peek (tf, offset, XML_BUFFER_SIZE); \
21 if (data == NULL) return FALSE; \
28 xml_check_first_element (GstTypeFind * tf, const gchar * element, guint elen,
36 data = gst_type_find_peek (tf, 0, XML_BUFFER_SIZE);
40 /* look for the XMLDec
41 * see XML spec 2.8, Prolog and Document Type Declaration
42 * http://www.w3.org/TR/2004/REC-xml-20040204/#sec-prolog-dtd */
43 got_xmldec = (memcmp (data, "<?xml", 5) == 0);
45 if (strict && !got_xmldec)
48 /* skip XMLDec in any case if we've got one */
54 /* look for the first element, it has to be the requested element. Bail
55 * out if it is not within the first 4kB. */
56 while (data && (offset + pos) < 4096) {
57 while (*data != '<' && (offset + pos) < 4096) {
62 if (!g_ascii_isalpha (*data)) {
63 /* if not alphabetic, it's a PI or an element / attribute declaration
64 * like <?xxx or <!xxx */
69 /* the first normal element, check if it's the one asked for */
70 data = gst_type_find_peek (tf, offset + pos, elen + 1);
71 return (data && element && strncmp ((char *) data, element, elen) == 0);
77 /*** application/dash+xml typefind helper ***/
79 static GstStaticCaps dash_caps = GST_STATIC_CAPS ("application/dash+xml");
81 #define DASH_CAPS gst_static_caps_get (&dash_caps)
84 dash_type_find (GstTypeFind * tf, gpointer unused)
86 if (xml_check_first_element (tf, "MPD", 3, FALSE) ||
87 xml_check_first_element (tf, "mpd", 3, FALSE)) {
88 gst_type_find_suggest (tf, GST_TYPE_FIND_MAXIMUM, DASH_CAPS);
93 fragmented_init (GstPlugin * plugin)
95 GST_DEBUG_CATEGORY_INIT (fragmented_debug, "dashdemux", 0, "dashdemux");
96 if (!gst_element_register (plugin, "dashdemux", GST_RANK_PRIMARY,
97 GST_TYPE_DASH_DEMUX) || FALSE)
99 if(!gst_type_find_register (plugin, "application/dash+xml",
100 GST_RANK_SECONDARY, dash_type_find, NULL, DASH_CAPS, NULL, NULL))
105 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
108 "DASH demuxer plugin",
109 fragmented_init, VERSION, "LGPL", PACKAGE_NAME, "http://www.gstreamer.org/")