From 05efcbf757790818d36488ae4b7c9ccbbd706bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 12 Feb 2014 15:16:23 +0100 Subject: [PATCH] hlsdemux: Properly error out if caps can't be typefind instead of using NULL caps --- ext/hls/gsthlsdemux.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ext/hls/gsthlsdemux.c b/ext/hls/gsthlsdemux.c index a7bcf3d513..11cf476f4e 100644 --- a/ext/hls/gsthlsdemux.c +++ b/ext/hls/gsthlsdemux.c @@ -731,12 +731,19 @@ gst_hls_demux_stream_loop (GstHLSDemux * demux) if (!fragment) fragment = g_queue_pop_head (demux->queue); - buf = gst_fragment_get_buffer (fragment); - /* Figure out if we need to create/switch pads */ if (G_LIKELY (demux->srcpad)) srccaps = gst_pad_get_current_caps (demux->srcpad); bufcaps = gst_fragment_get_caps (fragment); + if (G_UNLIKELY (!bufcaps)) { + if (srccaps) + gst_caps_unref (srccaps); + g_object_unref (fragment); + goto type_not_found; + } + + buf = gst_fragment_get_buffer (fragment); + if (G_UNLIKELY (!srccaps || !gst_caps_is_equal_fixed (bufcaps, srccaps) || demux->need_segment)) { switch_pads (demux, bufcaps); @@ -792,6 +799,17 @@ cache_error: return; } +type_not_found: + { + gst_task_pause (demux->stream_task); + if (!demux->cancelled) { + GST_ELEMENT_ERROR (demux, STREAM, TYPE_NOT_FOUND, + ("Could not determine type of stream"), (NULL)); + gst_hls_demux_pause_tasks (demux, FALSE); + } + return; + } + error_pushing: { if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) { @@ -1459,6 +1477,14 @@ gst_hls_demux_get_next_fragment (GstHLSDemux * demux, gboolean caching, if (G_UNLIKELY (demux->do_typefind)) { GstCaps *caps = gst_fragment_get_caps (download); + if (G_UNLIKELY (!caps)) { + GST_ELEMENT_ERROR (demux, STREAM, TYPE_NOT_FOUND, + ("Could not determine type of stream"), (NULL)); + gst_buffer_unref (buf); + g_object_unref (download); + goto error; + } + if (!demux->input_caps || !gst_caps_is_equal (caps, demux->input_caps)) { gst_caps_replace (&demux->input_caps, caps); /* gst_pad_set_caps (demux->srcpad, demux->input_caps); */