mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-08 21:28:45 +00:00
qtdemux: fix push based seeking
... where it comes down to transforming incoming BYTE segment to a corresponding TIME segment. Also fixes #609405.
This commit is contained in:
parent
5fcbea7e7e
commit
bcde9fab09
1 changed files with 10 additions and 19 deletions
|
@ -1401,7 +1401,6 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
|
||||||
gboolean set, QtDemuxStream ** _stream, gint * _index, gint64 * _time)
|
gboolean set, QtDemuxStream ** _stream, gint * _index, gint64 * _time)
|
||||||
{
|
{
|
||||||
gint i, n, index;
|
gint i, n, index;
|
||||||
guint32 ts_timescale = -1; /* the timescale corresponding to min_time */
|
|
||||||
gint64 time, min_time;
|
gint64 time, min_time;
|
||||||
QtDemuxStream *stream;
|
QtDemuxStream *stream;
|
||||||
|
|
||||||
|
@ -1414,7 +1413,6 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
|
||||||
gint inc;
|
gint inc;
|
||||||
gboolean set_sample;
|
gboolean set_sample;
|
||||||
|
|
||||||
|
|
||||||
str = qtdemux->streams[n];
|
str = qtdemux->streams[n];
|
||||||
set_sample = !set;
|
set_sample = !set;
|
||||||
|
|
||||||
|
@ -1438,10 +1436,10 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
|
||||||
}
|
}
|
||||||
/* determine min/max time */
|
/* determine min/max time */
|
||||||
time = str->samples[i].timestamp + str->samples[i].pts_offset;
|
time = str->samples[i].timestamp + str->samples[i].pts_offset;
|
||||||
if (min_time == -1 || (!fw && min_time > time) ||
|
time = gst_util_uint64_scale (time, GST_SECOND, str->timescale);
|
||||||
(fw && min_time < time)) {
|
if (min_time == -1 || (!fw && time > min_time) ||
|
||||||
|
(fw && time < min_time)) {
|
||||||
min_time = time;
|
min_time = time;
|
||||||
ts_timescale = str->timescale;
|
|
||||||
}
|
}
|
||||||
/* determine stream with leading sample, to get its position */
|
/* determine stream with leading sample, to get its position */
|
||||||
if (!stream || (fw
|
if (!stream || (fw
|
||||||
|
@ -1459,8 +1457,8 @@ gst_qtdemux_find_sample (GstQTDemux * qtdemux, gint64 byte_pos, gboolean fw,
|
||||||
gst_qtdemux_move_stream (qtdemux, str, str->n_samples);
|
gst_qtdemux_move_stream (qtdemux, str, str->n_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_time && ts_timescale != -1)
|
if (_time)
|
||||||
*_time = gst_util_uint64_scale (min_time, GST_SECOND, ts_timescale);
|
*_time = min_time;
|
||||||
if (_stream)
|
if (_stream)
|
||||||
*_stream = stream;
|
*_stream = stream;
|
||||||
if (_index)
|
if (_index)
|
||||||
|
@ -1528,7 +1526,9 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
|
||||||
if (stop > 0) {
|
if (stop > 0) {
|
||||||
gst_qtdemux_find_sample (demux, stop, FALSE, FALSE, NULL, NULL,
|
gst_qtdemux_find_sample (demux, stop, FALSE, FALSE, NULL, NULL,
|
||||||
&stop);
|
&stop);
|
||||||
stop = MAX (stop, 0);
|
/* keyframe seeking should already arrange for start >= stop,
|
||||||
|
* but make sure in other rare cases */
|
||||||
|
stop = MAX (stop, start);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (demux, "unsupported segment format, ignoring");
|
GST_DEBUG_OBJECT (demux, "unsupported segment format, ignoring");
|
||||||
|
@ -1543,17 +1543,6 @@ gst_qtdemux_handle_sink_event (GstPad * sinkpad, GstEvent * event)
|
||||||
"stop %" GST_TIME_FORMAT, update, rate, arate, GST_FORMAT_TIME,
|
"stop %" GST_TIME_FORMAT, update, rate, arate, GST_FORMAT_TIME,
|
||||||
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
GST_TIME_ARGS (start), GST_TIME_ARGS (stop));
|
||||||
|
|
||||||
/* FIXME: workaround/safety check for broken files (don't want to end
|
|
||||||
* up with NULL events if stop < start). Figure out real cause of this
|
|
||||||
* and fix it. */
|
|
||||||
if (stop < start) {
|
|
||||||
GST_ELEMENT_ERROR (demux, STREAM, DEMUX,
|
|
||||||
(_("This file is invalid and cannot be played.")),
|
|
||||||
("stop %" GST_TIME_FORMAT " < start %" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (stop), GST_TIME_ARGS (start)));
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_qtdemux_push_event (demux,
|
gst_qtdemux_push_event (demux,
|
||||||
gst_event_new_new_segment_full (update, rate, arate, GST_FORMAT_TIME,
|
gst_event_new_new_segment_full (update, rate, arate, GST_FORMAT_TIME,
|
||||||
start, stop, start));
|
start, stop, start));
|
||||||
|
@ -1734,6 +1723,8 @@ gst_qtdemux_change_state (GstElement * element, GstStateChange transition)
|
||||||
qtdemux->n_audio_streams = 0;
|
qtdemux->n_audio_streams = 0;
|
||||||
qtdemux->n_sub_streams = 0;
|
qtdemux->n_sub_streams = 0;
|
||||||
gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME);
|
gst_segment_init (&qtdemux->segment, GST_FORMAT_TIME);
|
||||||
|
qtdemux->requested_seek_time = GST_CLOCK_TIME_NONE;
|
||||||
|
qtdemux->seek_offset = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue