summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Zapata <jorgeluis.zapata@gmail.com>2013-01-24 18:03:22 +0100
committerJosep Torra <n770galaxy@gmail.com>2013-05-22 14:41:21 +0200
commitd5e6318c5759723ba1a656010eda53f6f2af942b (patch)
tree0e0a43c2ae05e9a1c6d9f783eaef158619a5309b
parentb06de2ff7cce88729d8360117e195b935981b421 (diff)
qtdemux: Only expose the streams whenever we get the samples
In cases where the moov defines several tracks/streams it might be possible that there is no data for such definition. For those cases we should not expose such stream so we better wait until the first 'mdat' is received and we are about to send a new segment to expose the streams.
-rw-r--r--gst/isomp4/qtdemux.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c
index b469b9698..6ec43df4b 100644
--- a/gst/isomp4/qtdemux.c
+++ b/gst/isomp4/qtdemux.c
@@ -4581,7 +4581,6 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
qtdemux_parse_moov (demux, data, demux->neededbytes);
qtdemux_node_dump (demux, demux->moov_node);
qtdemux_parse_tree (demux);
- qtdemux_expose_streams (demux);
g_node_destroy (demux->moov_node);
demux->moov_node = NULL;
@@ -4719,6 +4718,13 @@ gst_qtdemux_chain (GstPad * sinkpad, GstBuffer * inbuf)
/* initial newsegment sent here after having added pads,
* possible others in sink_event */
if (G_UNLIKELY (demux->pending_newsegment)) {
+ /* first expose the streams, this is done here because the
+ * pads need to be created after the first mdat is received
+ * this ensure that the described streams actually have samples
+ * or either from the stbl (static) atom or the trun (fragmented)
+ * atom
+ */
+ qtdemux_expose_streams (demux);
gst_qtdemux_push_pending_newsegment (demux);
/* clear to send tags on all streams */
for (i = 0; i < demux->n_streams; i++) {
@@ -8322,10 +8328,12 @@ qtdemux_expose_streams (GstQTDemux * qtdemux)
if (ret != GST_FLOW_ERROR)
ret = GST_FLOW_OK;
- /* in pull mode, we should have parsed some sample info by now;
- * and quite some code will not handle no samples.
- * in push mode, we'll just have to deal with it */
- if (G_UNLIKELY (qtdemux->pullbased && !stream->n_samples)) {
+ /* in pull mode, we expose the streams whenever we are ready to parse
+ * movie data. in push mode we expose whenever we are about to send
+ * the new segment. In both cases we should have already parsed a moof
+ * that describes the samples or the stbl
+ */
+ if (G_UNLIKELY (!stream->n_samples)) {
GST_DEBUG_OBJECT (qtdemux, "no samples for stream; discarding");
gst_qtdemux_stream_free (qtdemux, stream);
memmove (&(qtdemux->streams[i]), &(qtdemux->streams[i + 1]),