mxfdemux: implement simple KEY_UNIT seeking

If a KEY_UNIT seek was requested, adjust segment
start to position of the key frame.
This commit is contained in:
Tim-Philipp Müller 2014-04-08 14:33:06 +01:00
parent db7934233f
commit 6e764e5b11

View file

@ -3316,6 +3316,7 @@ no_new_offset:
static gboolean static gboolean
gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event) gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event)
{ {
GstClockTime keyunit_ts;
GstFormat format; GstFormat format;
GstSeekFlags flags; GstSeekFlags flags;
GstSeekType start_type, stop_type; GstSeekType start_type, stop_type;
@ -3340,6 +3341,8 @@ gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event)
flush = ! !(flags & GST_SEEK_FLAG_FLUSH); flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
keyframe = ! !(flags & GST_SEEK_FLAG_KEY_UNIT); keyframe = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
keyunit_ts = start;
if (flush) { if (flush) {
GstEvent *e; GstEvent *e;
@ -3391,10 +3394,13 @@ gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event)
/* Do the actual seeking */ /* Do the actual seeking */
for (i = 0; i < demux->src->len; i++) { for (i = 0; i < demux->src->len; i++) {
MXFMetadataTrackType track_type;
GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i); GstMXFDemuxPad *p = g_ptr_array_index (demux->src, i);
gint64 position; gint64 position;
guint64 off; guint64 off;
track_type = p->material_track->parent.type;
/* Reset EOS flag on all pads */ /* Reset EOS flag on all pads */
p->eos = FALSE; p->eos = FALSE;
p->last_flow = GST_FLOW_OK; p->last_flow = GST_FLOW_OK;
@ -3419,6 +3425,11 @@ gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event)
p->current_essence_track->source_track->edit_rate.n); p->current_essence_track->source_track->edit_rate.n);
} }
p->current_essence_track_position = position; p->current_essence_track_position = position;
/* FIXME: what about DV + MPEG-TS container essence tracks? */
if (track_type == MXF_METADATA_TRACK_PICTURE_ESSENCE) {
keyunit_ts = MIN (p->position, keyunit_ts);
}
} }
p->discont = TRUE; p->discont = TRUE;
} }
@ -3452,8 +3463,11 @@ gst_mxf_demux_seek_pull (GstMXFDemux * demux, GstEvent * event)
gst_event_set_seqnum (demux->close_seg_event, demux->seqnum); gst_event_set_seqnum (demux->close_seg_event, demux->seqnum);
} }
if (keyframe) { if (keyframe && keyunit_ts != start) {
/* FIXME: fix up segment start to position of key unit */ GST_INFO_OBJECT (demux, "key unit seek, adjusting segment start to "
"%" GST_TIME_FORMAT, GST_TIME_ARGS (keyunit_ts));
gst_segment_do_seek (&seeksegment, rate, format, flags,
start_type, keyunit_ts, stop_type, stop, &update);
} }
/* Ok seek succeeded, take the newly configured segment */ /* Ok seek succeeded, take the newly configured segment */