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
diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c
index 518d0e3..086e2ea 100644
--- a/gst/rtsp/gstrtspsrc.c
+++ b/gst/rtsp/gstrtspsrc.c
@@ -2282,7 +2282,7 @@
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 @@
/* 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 @@
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_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 97a0d19..57921d2 100644
--- a/gst/rtsp/gstrtspsrc.h
+++ b/gst/rtsp/gstrtspsrc.h
@@ -270,7 +270,14 @@
/* 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;