From 68e77265a00b131fa45aba45b4c1b8e4ceff3ac7 Mon Sep 17 00:00:00 2001 From: Vijay Jayaraman Date: Mon, 24 Nov 2014 12:18:36 -0700 Subject: [PATCH] hlsdemux: typefind might fail if first buffer is too short 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 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index 49edaf31f4..c532cc39f9 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -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;