rtspsrc: avoid seek DISCONT when only rate changes in same direction

Not setting DISCONT avoids a noticable delay when seeking
with only rate changing, in the same direction as current
rate.
This commit is contained in:
Aaron Boxer 2019-09-12 14:22:10 -06:00 committed by GStreamer Merge Bot
parent 9db1d740e8
commit 4155c59cc4

View file

@ -2751,7 +2751,7 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
gdouble rate; gdouble rate;
GstFormat format; GstFormat format;
GstSeekFlags flags; GstSeekFlags flags;
GstSeekType cur_type = GST_SEEK_TYPE_NONE, stop_type; GstSeekType cur_type = GST_SEEK_TYPE_NONE, stop_type = GST_SEEK_TYPE_NONE;
gint64 cur, stop; gint64 cur, stop;
gboolean flush, server_side_trickmode; gboolean flush, server_side_trickmode;
gboolean update; gboolean update;
@ -2759,11 +2759,15 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
GstSegment seeksegment = { 0, }; GstSegment seeksegment = { 0, };
GList *walk; GList *walk;
const gchar *seek_style = NULL; const gchar *seek_style = NULL;
gboolean rate_change_only = FALSE;
gboolean rate_change_same_direction = FALSE;
GST_DEBUG_OBJECT (src, "doing seek with event %" GST_PTR_FORMAT, event); GST_DEBUG_OBJECT (src, "doing seek with event %" GST_PTR_FORMAT, event);
gst_event_parse_seek (event, &rate, &format, &flags, gst_event_parse_seek (event, &rate, &format, &flags,
&cur_type, &cur, &stop_type, &stop); &cur_type, &cur, &stop_type, &stop);
rate_change_only = cur_type == GST_SEEK_TYPE_NONE
&& stop_type == GST_SEEK_TYPE_NONE;
/* we need TIME format */ /* we need TIME format */
if (format != src->segment.format) if (format != src->segment.format)
@ -2818,6 +2822,7 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
* right values in the segment to perform the seek */ * right values in the segment to perform the seek */
GST_DEBUG_OBJECT (src, "configuring seek"); GST_DEBUG_OBJECT (src, "configuring seek");
seeksegment.duration = GST_CLOCK_TIME_NONE; seeksegment.duration = GST_CLOCK_TIME_NONE;
rate_change_same_direction = (rate * seeksegment.rate) > 0;
gst_segment_do_seek (&seeksegment, rate, format, flags, gst_segment_do_seek (&seeksegment, rate, format, flags,
cur_type, cur, stop_type, stop, &update); cur_type, cur, stop_type, stop, &update);
@ -2861,12 +2866,14 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event)
GST_DEBUG_OBJECT (src, "Creating newsegment from %" G_GINT64_FORMAT GST_DEBUG_OBJECT (src, "Creating newsegment from %" G_GINT64_FORMAT
" to %" G_GINT64_FORMAT, src->segment.position, stop); " to %" G_GINT64_FORMAT, src->segment.position, stop);
/* mark discont */ /* mark discont when needed */
if (!(rate_change_only && rate_change_same_direction)) {
GST_DEBUG_OBJECT (src, "mark DISCONT, we did a seek to another position"); GST_DEBUG_OBJECT (src, "mark DISCONT, we did a seek to another position");
for (walk = src->streams; walk; walk = g_list_next (walk)) { for (walk = src->streams; walk; walk = g_list_next (walk)) {
GstRTSPStream *stream = (GstRTSPStream *) walk->data; GstRTSPStream *stream = (GstRTSPStream *) walk->data;
stream->discont = TRUE; stream->discont = TRUE;
} }
}
/* and continue playing if needed. If we are not acting as a live source, /* and continue playing if needed. If we are not acting as a live source,
* then only the RTSP PLAYING state, set earlier, matters. */ * then only the RTSP PLAYING state, set earlier, matters. */