From 10bc8fdfd2ccb2e9ff49bac0d9f09987439366b3 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Fri, 24 Nov 2017 15:37:44 +0100 Subject: [PATCH] rtspsrc: Do more checks for seekability When receiving a seek event, check whether we can actually seek based on the information the server provided. Also add more documentation on what the seekable field means --- gst/rtsp/gstrtspsrc.c | 17 ++++++++++++++++- gst/rtsp/gstrtspsrc.h | 9 ++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index 518d0e3a4d..086e2ea27d 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -2282,7 +2282,7 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event) const gchar *seek_style = NULL; if (event) { - GST_DEBUG_OBJECT (src, "doing seek with event"); + GST_DEBUG_OBJECT (src, "doing seek with event %" GST_PTR_FORMAT, event); gst_event_parse_seek (event, &rate, &format, &flags, &cur_type, &cur, &stop_type, &stop); @@ -2294,6 +2294,14 @@ gst_rtspsrc_perform_seek (GstRTSPSrc * src, GstEvent * event) /* we need TIME format */ if (format != src->segment.format) goto no_format; + + /* Check if we are not at all seekable */ + if (src->seekable == -1.0) + goto not_seekable; + + /* Additional seeking-to-beginning-only check */ + if (src->seekable == 0.0 && cur != 0) + goto not_seekable; } else { GST_DEBUG_OBJECT (src, "doing seek without event"); flags = 0; @@ -2425,6 +2433,11 @@ no_format: GST_DEBUG_OBJECT (src, "unsupported format given, seek aborted."); return FALSE; } +not_seekable: + { + GST_DEBUG_OBJECT (src, "stream is not seekable"); + return FALSE; + } } static gboolean @@ -2622,6 +2635,8 @@ gst_rtspsrc_handle_src_query (GstPad * pad, GstObject * parent, } } + GST_LOG_OBJECT (src, "seekable : %d", seekable); + gst_query_set_seeking (query, GST_FORMAT_TIME, seekable, start, duration); res = TRUE; diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h index 97a0d194d5..57921d2e19 100644 --- a/gst/rtsp/gstrtspsrc.h +++ b/gst/rtsp/gstrtspsrc.h @@ -270,7 +270,14 @@ struct _GstRTSPSrc { /* supported methods */ gint methods; - /* Same semantic as described in gst_rtsp_media_seekable */ + /* seekability + * -1.0 : Stream is not seekable + * 0.0 : seekable only to the beginning + * G_MAXFLOAT : Any value is possible + * + * Any other positive value indicates the longest duration + * between any two random access points + * */ gfloat seekable; GstClockTime last_pos;