mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-06 15:38:53 +00:00
hlsdemux: Early terminate seeking if we don't need to do
Some codes are imported from dashdemux https://bugzilla.gnome.org/show_bug.cgi?id=776997
This commit is contained in:
parent
9ce5646a0f
commit
32c4850b33
1 changed files with 64 additions and 62 deletions
|
@ -294,13 +294,17 @@ gst_hls_demux_set_current (GstHLSDemux * self, GstM3U8 * m3u8)
|
|||
}
|
||||
#endif
|
||||
|
||||
#define SEEK_UPDATES_PLAY_POSITION(r, start_type, stop_type) \
|
||||
((r >= 0 && start_type != GST_SEEK_TYPE_NONE) || \
|
||||
(r < 0 && stop_type != GST_SEEK_TYPE_NONE))
|
||||
|
||||
static gboolean
|
||||
gst_hls_demux_seek (GstAdaptiveDemux * demux, GstEvent * seek)
|
||||
{
|
||||
GstHLSDemux *hlsdemux = GST_HLS_DEMUX_CAST (demux);
|
||||
GstFormat format;
|
||||
GstSeekFlags flags;
|
||||
GstSeekType start_type, stop_type, target_type;
|
||||
GstSeekType start_type, stop_type;
|
||||
gint64 start, stop;
|
||||
gdouble rate, old_rate;
|
||||
GList *walk, *stream_walk;
|
||||
|
@ -310,11 +314,16 @@ gst_hls_demux_seek (GstAdaptiveDemux * demux, GstEvent * seek)
|
|||
gboolean snap_before, snap_after, snap_nearest, keyunit;
|
||||
gboolean reverse;
|
||||
|
||||
old_rate = demux->segment.rate;
|
||||
|
||||
gst_event_parse_seek (seek, &rate, &format, &flags, &start_type, &start,
|
||||
&stop_type, &stop);
|
||||
|
||||
if (!SEEK_UPDATES_PLAY_POSITION (rate, start_type, stop_type)) {
|
||||
/* nothing to do if we don't have to update the current position */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
old_rate = demux->segment.rate;
|
||||
|
||||
bitrate = gst_hls_demux_get_bitrate (hlsdemux);
|
||||
|
||||
/* properly cleanup pending decryption status */
|
||||
|
@ -364,13 +373,7 @@ gst_hls_demux_seek (GstAdaptiveDemux * demux, GstEvent * seek)
|
|||
hls_stream->playlist->first_file_start : 0;
|
||||
reverse = rate < 0;
|
||||
target_pos = reverse ? stop : start;
|
||||
target_type = reverse ? stop_type : start_type;
|
||||
|
||||
if (target_type == GST_SEEK_TYPE_NONE && !(flags & GST_SEEK_FLAG_FLUSH)) {
|
||||
/* No need to move */
|
||||
gst_segment_do_seek (&demux->segment, rate, format, flags, start_type,
|
||||
start, stop_type, stop, NULL);
|
||||
} else {
|
||||
/* Snap to segment boundary. Improves seek performance on slow machines. */
|
||||
keyunit = ! !(flags & GST_SEEK_FLAG_KEY_UNIT);
|
||||
snap_nearest =
|
||||
|
@ -432,7 +435,6 @@ gst_hls_demux_seek (GstAdaptiveDemux * demux, GstEvent * seek)
|
|||
start, stop_type, current_pos, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue