hlsdemux: typefind might fail if first buffer is too short
authorVijay Jayaraman <Vijay.Jayaraman@echostar.com>
Mon, 24 Nov 2014 19:18:36 +0000 (12:18 -0700)
committerThiago Santos <thiagoss@osg.samsung.com>
Tue, 23 Dec 2014 13:08:57 +0000 (10:08 -0300)
If typefind fails, check to see if the buffer is too short for typefind. If this is the case,
prepend the decrypted buffer to the pending buffer and try again the next time around.

https://bugzilla.gnome.org/show_bug.cgi?id=740458

ext/hls/gsthlsdemux.c

index 49edaf31f4c75b51a3097622287f362ea8d37795..c532cc39f9adc376de8dd77e88a02f11a450b339 100644 (file)
@@ -656,13 +656,29 @@ gst_hls_demux_chunk_received (GstAdaptiveDemux * demux,
     tmp_buffer = hlsdemux->pending_buffer;
     hlsdemux->pending_buffer = buffer;
     *chunk = tmp_buffer;
+  } else if (hlsdemux->pending_buffer) {
+    *chunk = gst_buffer_append (hlsdemux->pending_buffer, buffer);
+    hlsdemux->pending_buffer = NULL;
   }
 
-  if (G_UNLIKELY (hlsdemux->do_typefind && *chunk != NULL)) {
+  buffer = *chunk;
+
+  if (G_UNLIKELY (hlsdemux->do_typefind && buffer != NULL)) {
     GstCaps *caps;
 
     caps = gst_type_find_helper_for_buffer (NULL, buffer, NULL);
     if (G_UNLIKELY (!caps)) {
+      /* Typefind could fail if buffer is too small. Retry later */
+      if (gst_buffer_get_size (buffer) < (2 * 1024 * 1024)) {
+        if (hlsdemux->pending_buffer)
+          hlsdemux->pending_buffer =
+              gst_buffer_append (buffer, hlsdemux->pending_buffer);
+        else
+          hlsdemux->pending_buffer = buffer;
+        *chunk = NULL;
+        return GST_FLOW_OK;
+      }
+
       GST_ELEMENT_ERROR (hlsdemux, STREAM, TYPE_NOT_FOUND,
           ("Could not determine type of stream"), (NULL));
       return GST_FLOW_NOT_NEGOTIATED;