diff options
author | Edward Hervey <edward@centricular.com> | 2016-11-22 16:22:49 +0100 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2016-11-22 18:21:46 +0100 |
commit | 45c7826d76dfcb94cebbc57208c553d432fdc4a9 (patch) | |
tree | 316d8030ac57f2449bfb6b92ac10884401d549c0 /gst/asfdemux | |
parent | aab716ac400b6687a46c14c214833b7e3bb33510 (diff) | |
download | gstreamer-plugins-ugly-45c7826d76dfcb94cebbc57208c553d432fdc4a9.tar.gz |
asfdemux: Handle issues with "empty" files
In some corrupted files, we could end up with no actual streams
being exposed.
In those cases, make sure we properly propagate the failure all
the way to the loop function. This avoids ending up in cases where
we are neither EOS'd nor ERROR'd out from a pipeline point of view.
https://bugzilla.gnome.org/show_bug.cgi?id=774846
Diffstat (limited to 'gst/asfdemux')
-rw-r--r-- | gst/asfdemux/gstasfdemux.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c index 28e1f094..53dceea0 100644 --- a/gst/asfdemux/gstasfdemux.c +++ b/gst/asfdemux/gstasfdemux.c @@ -1493,7 +1493,7 @@ gst_asf_demux_update_caps_from_payload (GstASFDemux * demux, AsfStream * stream) static gboolean gst_asf_demux_check_activate_streams (GstASFDemux * demux, gboolean force) { - guint i; + guint i, actual_streams = 0; if (demux->activated_streams) return TRUE; @@ -1522,11 +1522,18 @@ gst_asf_demux_check_activate_streams (GstASFDemux * demux, gboolean force) * a stream, then we active it, or we don't, then we'll ignore it */ GST_LOG_OBJECT (stream->pad, "is prerolled - activate!"); gst_asf_demux_activate_stream (demux, stream); + actual_streams += 1; } else { GST_LOG_OBJECT (stream->pad, "no data, ignoring stream"); } } + if (actual_streams == 0) { + /* We don't have any streams activated ! */ + GST_ERROR_OBJECT (demux, "No streams activated!"); + return FALSE; + } + gst_asf_demux_release_old_pads (demux); demux->activated_streams = TRUE; @@ -2078,7 +2085,7 @@ eos: * less data queued than required for preroll; force stream activation and * send any pending payloads before sending EOS */ if (!demux->activated_streams) - gst_asf_demux_push_complete_payloads (demux, TRUE); + flow = gst_asf_demux_push_complete_payloads (demux, TRUE); /* we want to push an eos or post a segment-done in any case */ if (demux->segment.flags & GST_SEEK_FLAG_SEGMENT) { @@ -2105,9 +2112,14 @@ eos: } if (!(demux->segment.flags & GST_SEEK_FLAG_SEGMENT)) { - /* normal playback, send EOS to all linked pads */ - GST_INFO_OBJECT (demux, "Sending EOS, at end of stream"); - gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ()); + if (demux->activated_streams) { + /* normal playback, send EOS to all linked pads */ + GST_INFO_OBJECT (demux, "Sending EOS, at end of stream"); + gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ()); + } else { + GST_WARNING_OBJECT (demux, "EOS without exposed streams"); + flow = GST_FLOW_EOS; + } } /* ... and fall through to pause */ } @@ -2119,7 +2131,10 @@ pause: gst_pad_pause_task (demux->sinkpad); /* For the error cases */ - if (flow < GST_FLOW_EOS || flow == GST_FLOW_NOT_LINKED) { + if (flow == GST_FLOW_EOS && !demux->activated_streams) { + GST_ELEMENT_ERROR (demux, STREAM, WRONG_TYPE, (NULL), + ("This doesn't seem to be an ASF file")); + } else if (flow < GST_FLOW_EOS || flow == GST_FLOW_NOT_LINKED) { /* Post an error. Hopefully something else already has, but if not... */ GST_ELEMENT_FLOW_ERROR (demux, flow); gst_asf_demux_send_event_unlocked (demux, gst_event_new_eos ()); |