adaptivedemux: Handle stop_type:SET, stop:NONE
authorEdward Hervey <edward@centricular.com>
Mon, 15 May 2017 16:10:11 +0000 (18:10 +0200)
committerEdward Hervey <bilboed@bilboed.com>
Mon, 15 May 2017 16:11:35 +0000 (18:11 +0200)
Seek values of type GST_SEEK_TYPE_SET with values of GST_CLOCK_TIME_NONE
are perfectly valid (we essentially don't modify the existing position)

gst-libs/gst/adaptivedemux/gstadaptivedemux.c

index 093145c..a719874 100644 (file)
@@ -1507,6 +1507,7 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux, GstPad * pad,
   if (gst_adaptive_demux_is_live (demux)) {
     gint64 range_start, range_stop;
     gboolean changed = FALSE;
+    gboolean start_valid = TRUE, stop_valid = TRUE;
 
     if (!gst_adaptive_demux_get_live_seek_range (demux, &range_start,
             &range_stop)) {
@@ -1555,13 +1556,29 @@ gst_adaptive_demux_handle_seek_event (GstAdaptiveDemux * demux, GstPad * pad,
       }
     }
 
+    if (start_type == GST_SEEK_TYPE_SET && GST_CLOCK_TIME_IS_VALID (start) &&
+        (start < range_start || start > range_stop)) {
+      GST_WARNING_OBJECT (demux,
+          "Seek to invalid position start:%" GST_STIME_FORMAT
+          " out of seekable range (%" GST_STIME_FORMAT " - %" GST_STIME_FORMAT
+          ")", GST_STIME_ARGS (start), GST_STIME_ARGS (range_start),
+          GST_STIME_ARGS (range_stop));
+      start_valid = FALSE;
+    }
+    if (stop_type == GST_SEEK_TYPE_SET && GST_CLOCK_TIME_IS_VALID (stop) &&
+        (stop < range_start || stop > range_stop)) {
+      GST_WARNING_OBJECT (demux,
+          "Seek to invalid position stop:%" GST_STIME_FORMAT
+          " out of seekable range (%" GST_STIME_FORMAT " - %" GST_STIME_FORMAT
+          ")", GST_STIME_ARGS (stop), GST_STIME_ARGS (range_start),
+          GST_STIME_ARGS (range_stop));
+      stop_valid = FALSE;
+    }
+
     /* If the seek position is still outside of the seekable range, refuse the seek */
-    if (((start_type == GST_SEEK_TYPE_SET) && (start < range_start
-                || start > range_stop)) || ((stop_type == GST_SEEK_TYPE_SET)
-            && (stop < range_start || stop > range_stop))) {
+    if (!start_valid || !stop_valid) {
       GST_MANIFEST_UNLOCK (demux);
       GST_API_UNLOCK (demux);
-      GST_WARNING_OBJECT (demux, "Seek to invalid position");
       gst_event_unref (event);
       return FALSE;
     }