hlsdemux: Properly error out if caps can't be typefind instead of using NULL caps

This commit is contained in:
Sebastian Dröge 2014-02-12 15:16:23 +01:00
parent 63e18bb7bf
commit 05efcbf757

View file

@ -731,12 +731,19 @@ gst_hls_demux_stream_loop (GstHLSDemux * demux)
if (!fragment) if (!fragment)
fragment = g_queue_pop_head (demux->queue); fragment = g_queue_pop_head (demux->queue);
buf = gst_fragment_get_buffer (fragment);
/* Figure out if we need to create/switch pads */ /* Figure out if we need to create/switch pads */
if (G_LIKELY (demux->srcpad)) if (G_LIKELY (demux->srcpad))
srccaps = gst_pad_get_current_caps (demux->srcpad); srccaps = gst_pad_get_current_caps (demux->srcpad);
bufcaps = gst_fragment_get_caps (fragment); 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) if (G_UNLIKELY (!srccaps || !gst_caps_is_equal_fixed (bufcaps, srccaps)
|| demux->need_segment)) { || demux->need_segment)) {
switch_pads (demux, bufcaps); switch_pads (demux, bufcaps);
@ -792,6 +799,17 @@ cache_error:
return; 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: error_pushing:
{ {
if (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS) { 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)) { if (G_UNLIKELY (demux->do_typefind)) {
GstCaps *caps = gst_fragment_get_caps (download); 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)) { if (!demux->input_caps || !gst_caps_is_equal (caps, demux->input_caps)) {
gst_caps_replace (&demux->input_caps, caps); gst_caps_replace (&demux->input_caps, caps);
/* gst_pad_set_caps (demux->srcpad, demux->input_caps); */ /* gst_pad_set_caps (demux->srcpad, demux->input_caps); */