uri-clip: use duration-limit in set_max_duration
authorHenry Wilkes <hwilkes@igalia.com>
Tue, 28 Apr 2020 17:01:04 +0000 (18:01 +0100)
committerHenry Wilkes <hwilkes@igalia.com>
Thu, 7 May 2020 08:37:15 +0000 (09:37 +0100)
Use the duration-limit rather than max-duration - in-point, since the
former will be able to take other factors, such as effects, into
account.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-editing-services/-/merge_requests/169>

ges/ges-uri-clip.c

index 6e617d9..742eea9 100644 (file)
@@ -388,14 +388,17 @@ gboolean
 uri_clip_set_max_duration (GESTimelineElement * element,
     GstClockTime maxduration)
 {
-  if (_DURATION (element) == GST_CLOCK_TIME_NONE || _DURATION (element) == 0)
-    /* If we don't have a valid duration, use the max duration */
-    /* FIXME: don't do this when we have time effects */
-    _set_duration0 (element, maxduration - _INPOINT (element));
-
-  return
+  gboolean ret =
       GES_TIMELINE_ELEMENT_CLASS (parent_class)->set_max_duration (element,
       maxduration);
+
+  if (ret) {
+    GstClockTime limit = ges_clip_get_duration_limit (GES_CLIP (element));
+    if (GST_CLOCK_TIME_IS_VALID (limit) && (element->duration == 0))
+      _set_duration0 (element, limit);
+  }
+
+  return ret;
 }
 
 /**