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
This commit is contained in:
Edward Hervey 2017-11-24 15:37:44 +01:00 committed by Edward Hervey
parent a260eb80fb
commit 10bc8fdfd2
2 changed files with 24 additions and 2 deletions

View file

@ -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;

View file

@ -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;