From b7c4171f318a330bf026cc0f64a324aca746fba1 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 18 Feb 2020 23:08:53 -0300 Subject: [PATCH] nlesource: When standalone consider object.duration==0 as not set 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 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/plugins/nle/nlesource.c b/plugins/nle/nlesource.c index 18db65c..1716d95 100644 --- a/plugins/nle/nlesource.c +++ b/plugins/nle/nlesource.c @@ -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, -- 2.7.4