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
This commit is contained in:
Thiago Santos 2013-10-25 18:22:00 -03:00
parent 0e78ffc9d6
commit 33ebda8ecf

View file

@ -4608,10 +4608,11 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)
break; break;
} }
if (fourcc == FOURCC_mdat) { 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 */ /* we have the headers, start playback */
demux->state = QTDEMUX_STATE_MOVIE; demux->state = QTDEMUX_STATE_MOVIE;
demux->neededbytes = next_entry_size (demux); demux->neededbytes = next_entry;
demux->mdatleft = size; demux->mdatleft = size;
} else { } else {
/* no headers yet, try to get them */ /* no headers yet, try to get them */
@ -4675,7 +4676,8 @@ gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)
} else { } else {
/* this means we already started buffering and still no moov header, /* this means we already started buffering and still no moov header,
* let's continue buffering everything till we get moov */ * 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; goto buffer_data;
demux->neededbytes = size; demux->neededbytes = size;
demux->state = QTDEMUX_STATE_HEADER; demux->state = QTDEMUX_STATE_HEADER;