qtdemux: Properly handle edit list in push mode

If there are empty segments in edit list, demux should
adjust "accumulated_base" to apply it into running time.

https://bugzilla.gnome.org/show_bug.cgi?id=778426
This commit is contained in:
Seungha Yang 2018-05-23 20:08:56 +09:00 committed by Thibault Saunier
parent d9235404aa
commit f61c2bc301

View file

@ -2240,6 +2240,12 @@ gst_qtdemux_map_and_push_segments (GstQTDemux * qtdemux, GstSegment * segment)
/* push the empty segment and move to the next one */ /* push the empty segment and move to the next one */
gst_qtdemux_send_gap_for_segment (qtdemux, stream, i, gst_qtdemux_send_gap_for_segment (qtdemux, stream, i,
stream->time_position); stream->time_position);
/* accumulate previous segments */
if (GST_CLOCK_TIME_IS_VALID (stream->segment.stop))
stream->accumulated_base +=
(stream->segment.stop -
stream->segment.start) / ABS (stream->segment.rate);
continue; continue;
} }
@ -6559,30 +6565,6 @@ gst_qtdemux_send_gap_for_segment (GstQTDemux * demux,
gst_pad_push_event (stream->pad, gap); gst_pad_push_event (stream->pad, gap);
} }
static void
gst_qtdemux_stream_send_initial_gap_segments (GstQTDemux * demux,
QtDemuxStream * stream)
{
gint i;
/* Push any initial gap segments before proceeding to the
* 'real' data */
for (i = 0; i < stream->n_segments; i++) {
gst_qtdemux_activate_segment (demux, stream, i, stream->time_position);
if (QTSEGMENT_IS_EMPTY (&stream->segments[i])) {
gst_qtdemux_send_gap_for_segment (demux, stream, i,
stream->time_position);
} else {
/* Only support empty segment at the beginning followed by
* one non-empty segment, this was checked when parsing the
* edts atom, arriving here is unexpected */
g_assert (i + 1 == stream->n_segments);
break;
}
}
}
static GstFlowReturn static GstFlowReturn
gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf) gst_qtdemux_chain (GstPad * sinkpad, GstObject * parent, GstBuffer * inbuf)
{ {
@ -6820,8 +6802,6 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force)
extract_initial_length_and_fourcc (data, demux->neededbytes, NULL, extract_initial_length_and_fourcc (data, demux->neededbytes, NULL,
&fourcc); &fourcc);
if (fourcc == FOURCC_moov) { if (fourcc == FOURCC_moov) {
GList *iter;
/* in usual fragmented setup we could try to scan for more /* in usual fragmented setup we could try to scan for more
* and end up at the the moov (after mdat) again */ * and end up at the the moov (after mdat) again */
if (demux->got_moov && demux->n_streams > 0 && if (demux->got_moov && demux->n_streams > 0 &&
@ -6871,15 +6851,12 @@ gst_qtdemux_process_adapter (GstQTDemux * demux, gboolean force)
QTDEMUX_EXPOSE_UNLOCK (demux); QTDEMUX_EXPOSE_UNLOCK (demux);
demux->got_moov = TRUE; demux->got_moov = TRUE;
gst_qtdemux_check_send_pending_segment (demux);
/* fragmented streams headers shouldn't contain edts atoms */ if (demux->fragmented) {
if (!demux->fragmented) { gst_qtdemux_check_send_pending_segment (demux);
for (iter = demux->active_streams; iter; } else {
iter = g_list_next (iter)) { gst_event_replace (&demux->pending_newsegment, NULL);
gst_qtdemux_stream_send_initial_gap_segments (demux, gst_qtdemux_map_and_push_segments (demux, &demux->segment);
QTDEMUX_STREAM (iter->data));
}
} }
if (demux->moov_node_compressed) { if (demux->moov_node_compressed) {