diff options
author | Robert Swain <robert.swain@collabora.co.uk> | 2010-02-04 14:46:56 +0100 |
---|---|---|
committer | Tim-Philipp Müller <tim.muller@collabora.co.uk> | 2010-02-04 18:54:58 +0000 |
commit | 9ed6c58006704b3ac049503cc9ea9808d7447c48 (patch) | |
tree | da4929333d94e1b300f0be64d26598862f32d4ea | |
parent | 8d4f70c5ce9c4998edc4a9e32e2d65ae87946684 (diff) |
qtdemux: Set the segment start time to the requested seek time for non-keyframe seeks
-rw-r--r-- | gst/qtdemux/qtdemux.c | 31 | ||||
-rw-r--r-- | gst/qtdemux/qtdemux.h | 3 |
2 files changed, 31 insertions, 3 deletions
diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 5e091aef8..c64d43f74 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -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,10 +1500,25 @@ 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_qtdemux_find_sample (demux, start, TRUE, FALSE, NULL, NULL, - &start); - start = MAX (start, 0); + + 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, diff --git a/gst/qtdemux/qtdemux.h b/gst/qtdemux/qtdemux.h index dfe67dce2..0590f4932 100644 --- a/gst/qtdemux/qtdemux.h +++ b/gst/qtdemux/qtdemux.h @@ -99,6 +99,9 @@ struct _GstQTDemux { /* gst index support */ GstIndex *element_index; gint index_id; + + gint64 requested_seek_time; + guint64 seek_offset; }; struct _GstQTDemuxClass { |