qtdemux: Set the segment start time to the requested seek time for non-keyframe seeks

This commit is contained in:
Robert Swain 2010-02-04 14:46:56 +01:00 committed by Tim-Philipp Müller
parent 8d4f70c5ce
commit 9ed6c58006
2 changed files with 31 additions and 3 deletions

View file

@ -1100,6 +1100,16 @@ gst_qtdemux_do_push_seek (GstQTDemux * qtdemux, GstPad * pad, GstEvent * event)
"start %" G_GINT64_FORMAT ", stop %" G_GINT64_FORMAT, rate, byte_cur,
stop);
if (!(flags & GST_SEEK_FLAG_KEY_UNIT)) {
GST_DEBUG_OBJECT (qtdemux,
"Requested seek time: %" GST_TIME_FORMAT ", calculated seek offset: %"
G_GUINT64_FORMAT, GST_TIME_ARGS (cur), byte_cur);
GST_OBJECT_LOCK (qtdemux);
qtdemux->requested_seek_time = cur;
qtdemux->seek_offset = byte_cur;
GST_OBJECT_UNLOCK (qtdemux);
}
/* BYTE seek event */
event = gst_event_new_seek (rate, GST_FORMAT_BYTES, flags, cur_type, byte_cur,
stop_type, stop);
@ -1490,11 +1500,26 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
/* we only expect a BYTE segment, e.g. following a seek */
if (format == GST_FORMAT_BYTES) {
if (start > 0) {
gint64 requested_seek_time;
guint64 seek_offset;
offset = start;
GST_OBJECT_LOCK (demux);
requested_seek_time = demux->requested_seek_time;
seek_offset = demux->seek_offset;
demux->requested_seek_time = -1;
demux->seek_offset = -1;
GST_OBJECT_UNLOCK (demux);
if (offset == seek_offset) {
start = requested_seek_time;
} else {
gst_qtdemux_find_sample (demux, start, TRUE, FALSE, NULL, NULL,
&start);
start = MAX (start, 0);
}
}
if (stop > 0) {
gst_qtdemux_find_sample (demux, stop, FALSE, FALSE, NULL, NULL,
&stop);

View file

@ -99,6 +99,9 @@ struct _GstQTDemux {
/* gst index support */
GstIndex *element_index;
gint index_id;
gint64 requested_seek_time;
guint64 seek_offset;
};
struct _GstQTDemuxClass {