From 33ebda8ecfd976ab28879ea7fd232572d0cb1ace Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Fri, 25 Oct 2013 18:22:00 -0300 Subject: [PATCH] qtdemux: handle fragmented files with mdat before moofs Assume a file with atoms in the following order: moov, mdat, moof, mdat, moof ... The first moov usually doesn't contain any sample entries atoms (or they are all set to 0 length), because the real samples are signaled at the moofs. In push mode, qtdemux parses the moov and then finds the mdat, but then it has 0 entries and assumes it is EOS. This patch makes it continue parsing in case it is a fragmented file so that it might find the moofs and play the media. https://bugzilla.gnome.org/show_bug.cgi?id=710623 --- gst/isomp4/qtdemux.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gst/isomp4/qtdemux.c b/gst/isomp4/qtdemux.c index c6240cd9e5..86c7ebd9fc 100644 --- a/gst/isomp4/qtdemux.c +++ b/gst/isomp4/qtdemux.c @@ -4608,10 +4608,11 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) break; } if (fourcc == FOURCC_mdat) { - if (demux->n_streams > 0) { + gint next_entry = next_entry_size (demux); + if (demux->n_streams > 0 && (next_entry != -1 || !demux->fragmented)) { /* we have the headers, start playback */ demux->state = QTDEMUX_STATE_MOVIE; - demux->neededbytes = next_entry_size (demux); + demux->neededbytes = next_entry; demux->mdatleft = size; } else { /* no headers yet, try to get them */ @@ -4675,7 +4676,8 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) } else { /* this means we already started buffering and still no moov header, * let's continue buffering everything till we get moov */ - if (demux->mdatbuffer && (fourcc != FOURCC_moov)) + if (demux->mdatbuffer && !(fourcc == FOURCC_moov + || fourcc == FOURCC_moof)) goto buffer_data; demux->neededbytes = size; demux->state = QTDEMUX_STATE_HEADER;