gst/multipart/multipartdemux.c: Accept leading whitespace before the boundary
authorSjoerd Simons <sjoerd@luon.net>
Thu, 17 Aug 2006 15:51:50 +0000 (15:51 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Thu, 17 Aug 2006 15:51:50 +0000 (15:51 +0000)
Original commit message from CVS:
Patch by: Sjoerd Simons <sjoerd at luon dot net>
* gst/multipart/multipartdemux.c: (multipart_parse_header):
Accept leading whitespace before the boundary
This patch makes the demuxer allow some whitespace before the actual
boundary. This makes the demuxer work with the ``old'' gstreamer
multipartmuxer again (which placed an extra \n before the start
of the stream) Fixes #349068.

ChangeLog
gst/multipart/multipartdemux.c

index 605b32e..7e024dc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2006-08-17  Wim Taymans  <wim@fluendo.com>
 
+       Patch by: Sjoerd Simons <sjoerd at luon dot net>
+
+       * gst/multipart/multipartdemux.c: (multipart_parse_header):
+       Accept leading whitespace before the boundary
+       This patch makes the demuxer allow some whitespace before the actual
+       boundary. This makes the demuxer work with the ``old'' gstreamer
+       multipartmuxer again (which placed an extra \n before the start
+       of the stream) Fixes #349068.
+
+2006-08-17  Wim Taymans  <wim@fluendo.com>
+
        * gst/rtp/gstrtph264depay.c: (gst_rtp_h264_depay_process):
        Error out on non-implemented stuff.
 
index 714d207..c8488e0 100644 (file)
@@ -334,13 +334,27 @@ multipart_parse_header (GstMultipartDemux * multipart)
   data = gst_adapter_peek (multipart->adapter, datalen);
   dataend = data + datalen;
 
+  /* Skip leading whitespace, pos endposition should at least leave space for
+   * the boundary and a \n */
+  for (pos = (guint8 *) data; pos < dataend - 4 && g_ascii_isspace (*pos);
+      pos++);
+
+  if (pos >= dataend - 4) {
+    return MULTIPART_NEED_MORE_DATA;
+  }
+
+  if (G_UNLIKELY (pos[0] != '-' || pos[1] != '-')) {
+    GST_DEBUG_OBJECT (multipart, "No boundary available");
+    goto wrong_header;
+  }
+
   /* First the boundary */
-  if (!get_line_end (data, dataend, &end, &next))
+  if (!get_line_end (pos, dataend, &end, &next))
     return MULTIPART_NEED_MORE_DATA;
 
   /* Ignore the leading -- */
-  boundary_len = end - data - 2;
-  boundary = (gchar *) data + 2;
+  boundary_len = end - pos - 2;
+  boundary = (gchar *) pos + 2;
   if (boundary_len < 1) {
     GST_DEBUG_OBJECT (multipart, "No boundary available");
     goto wrong_header;