mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-08 21:28:45 +00:00
qtdemux: Handle seeks past EOS as a seek to the end
Fix reverse playback of every frame by making seeks past/to EOS find the last segment and start there.
This commit is contained in:
parent
e3b0fb2a5d
commit
b3d1ab5267
1 changed files with 7 additions and 25 deletions
|
@ -1104,7 +1104,9 @@ beach:
|
||||||
|
|
||||||
/* find the segment for @time_position for @stream
|
/* find the segment for @time_position for @stream
|
||||||
*
|
*
|
||||||
* Returns -1 if the segment cannot be found.
|
* Returns the index of the segment containing @time_position.
|
||||||
|
* Returns the last segment and sets the @eos variable to TRUE
|
||||||
|
* if the time is beyond the end. @eos may be NULL
|
||||||
*/
|
*/
|
||||||
static guint32
|
static guint32
|
||||||
gst_qtdemux_find_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
gst_qtdemux_find_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
|
@ -1116,8 +1118,6 @@ gst_qtdemux_find_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
GST_LOG_OBJECT (qtdemux, "finding segment for %" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (qtdemux, "finding segment for %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (time_position));
|
GST_TIME_ARGS (time_position));
|
||||||
|
|
||||||
/* find segment corresponding to time_position if we are looking
|
|
||||||
* for a segment. */
|
|
||||||
seg_idx = -1;
|
seg_idx = -1;
|
||||||
for (i = 0; i < stream->n_segments; i++) {
|
for (i = 0; i < stream->n_segments; i++) {
|
||||||
QtDemuxSegment *segment = &stream->segments[i];
|
QtDemuxSegment *segment = &stream->segments[i];
|
||||||
|
@ -1134,13 +1134,11 @@ gst_qtdemux_find_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (segment->time <= time_position && time_position <= segment->stop_time) {
|
/* Last segment always matches */
|
||||||
GST_LOG_OBJECT (qtdemux, "segment %d matches", i);
|
|
||||||
seg_idx = i;
|
seg_idx = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return seg_idx;
|
return seg_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1194,10 +1192,6 @@ gst_qtdemux_adjust_seek (GstQTDemux * qtdemux, gint64 desired_time,
|
||||||
seg_idx = gst_qtdemux_find_segment (qtdemux, str, desired_time);
|
seg_idx = gst_qtdemux_find_segment (qtdemux, str, desired_time);
|
||||||
GST_DEBUG_OBJECT (qtdemux, "align segment %d", seg_idx);
|
GST_DEBUG_OBJECT (qtdemux, "align segment %d", seg_idx);
|
||||||
|
|
||||||
/* segment not found, continue with normal flow */
|
|
||||||
if (seg_idx == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* get segment and time in the segment */
|
/* get segment and time in the segment */
|
||||||
seg = &str->segments[seg_idx];
|
seg = &str->segments[seg_idx];
|
||||||
seg_time = desired_time - seg->time;
|
seg_time = desired_time - seg->time;
|
||||||
|
@ -3357,10 +3351,6 @@ gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
|
||||||
seg_idx = gst_qtdemux_find_segment (qtdemux, str,
|
seg_idx = gst_qtdemux_find_segment (qtdemux, str,
|
||||||
qtdemux->segment.position);
|
qtdemux->segment.position);
|
||||||
|
|
||||||
/* segment not found, continue with normal flow */
|
|
||||||
if (seg_idx == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* No candidate yet, take that one */
|
/* No candidate yet, take that one */
|
||||||
if (!ref_str) {
|
if (!ref_str) {
|
||||||
ref_str = str;
|
ref_str = str;
|
||||||
|
@ -3464,10 +3454,6 @@ gst_qtdemux_seek_to_previous_keyframe (GstQTDemux * qtdemux)
|
||||||
"stream %d align segment %d for keyframe pos %" GST_TIME_FORMAT, n,
|
"stream %d align segment %d for keyframe pos %" GST_TIME_FORMAT, n,
|
||||||
seg_idx, GST_TIME_ARGS (k_pos));
|
seg_idx, GST_TIME_ARGS (k_pos));
|
||||||
|
|
||||||
/* segment not found, continue with normal flow */
|
|
||||||
if (seg_idx == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
/* get segment and time in the segment */
|
/* get segment and time in the segment */
|
||||||
seg = &str->segments[seg_idx];
|
seg = &str->segments[seg_idx];
|
||||||
seg_time = k_pos - seg->time;
|
seg_time = k_pos - seg->time;
|
||||||
|
@ -3560,7 +3546,7 @@ gst_qtdemux_activate_segment (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
if (G_UNLIKELY (seg_time > segment->duration)) {
|
if (G_UNLIKELY (seg_time > segment->duration)) {
|
||||||
GST_LOG_OBJECT (qtdemux, "seg_time > segment->duration %" GST_TIME_FORMAT,
|
GST_LOG_OBJECT (qtdemux, "seg_time > segment->duration %" GST_TIME_FORMAT,
|
||||||
GST_TIME_ARGS (segment->duration));
|
GST_TIME_ARGS (segment->duration));
|
||||||
return FALSE;
|
seg_time = segment->duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* qtdemux->segment.stop is in outside-time-realm, whereas
|
/* qtdemux->segment.stop is in outside-time-realm, whereas
|
||||||
|
@ -3742,10 +3728,6 @@ gst_qtdemux_prepare_current_sample (GstQTDemux * qtdemux,
|
||||||
/* find segment corresponding to time_position if we are looking
|
/* find segment corresponding to time_position if we are looking
|
||||||
* for a segment. */
|
* for a segment. */
|
||||||
seg_idx = gst_qtdemux_find_segment (qtdemux, stream, time_position);
|
seg_idx = gst_qtdemux_find_segment (qtdemux, stream, time_position);
|
||||||
|
|
||||||
/* nothing found, we're really eos */
|
|
||||||
if (seg_idx == -1)
|
|
||||||
goto eos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* different segment, activate it, sample_index will be set. */
|
/* different segment, activate it, sample_index will be set. */
|
||||||
|
|
Loading…
Reference in a new issue