nlesource: When standalone consider object.duration==0 as not set
authorThibault Saunier <tsaunier@igalia.com>
Wed, 19 Feb 2020 02:08:53 +0000 (23:08 -0300)
committerThibault Saunier <tsaunier@igalia.com>
Wed, 19 Feb 2020 02:08:53 +0000 (23:08 -0300)
nleobject.duration defaults to 0, but this is pretty unintuitive for
end user in the case nlesource is use standalone, just consider
duration=0 equivalent to duration=GST_CLOCK_TIME_NONE as it makes
the element much simpler to use, we could actually forbid 0 as a value
in the future.

Also take into account potential CLOCK_TIME_NONE

plugins/nle/nlesource.c

index 18db65cb72277813e3253c39ecdec109407d7e93..1716d953dcd41ffddda8591b78510ac0e8e5d176 100644 (file)
@@ -535,12 +535,18 @@ nle_source_prepare (NleObject * object)
   priv->ghostedpad = pad;
 
   if (object->in_composition == FALSE) {
+    GstClockTime start =
+        GST_CLOCK_TIME_IS_VALID (object->inpoint) ? object->inpoint : 0;
+    GstClockTime stop = GST_CLOCK_TIME_NONE;
+
+    if (GST_CLOCK_TIME_IS_VALID (object->inpoint)
+        && GST_CLOCK_TIME_IS_VALID (object->duration) && object->duration)
+      stop = object->inpoint + object->duration;
+
     g_mutex_lock (&source->priv->seek_lock);
-    source->priv->seek_event =
-        gst_event_new_seek (1.0, GST_FORMAT_TIME,
+    source->priv->seek_event = gst_event_new_seek (1.0, GST_FORMAT_TIME,
         GST_SEEK_FLAG_ACCURATE | GST_SEEK_FLAG_FLUSH,
-        GST_SEEK_TYPE_SET, object->inpoint, GST_SEEK_TYPE_SET,
-        object->inpoint + object->duration);
+        GST_SEEK_TYPE_SET, start, GST_SEEK_TYPE_SET, stop);
     g_mutex_unlock (&source->priv->seek_lock);
     GST_OBJECT_LOCK (source);
     priv->probeid = gst_pad_add_probe (pad,