tools: Handle times as doubles + concider duration=0 as TIME_NONE

https://bugzilla.gnome.org/show_bug.cgi?id=729382
This commit is contained in:
Thibault Saunier 2014-04-29 21:29:54 +02:00
parent 44cbc27cb8
commit 36cc9f13ec

View file

@ -189,11 +189,13 @@ check_time (char *time)
static guint64
str_to_time (char *time)
{
if (check_time (time)) {
return (guint64) (atof (time) * GST_SECOND);
}
GST_ERROR ("%s not a valid time", time);
return 0;
gdouble nsecs;
g_return_val_if_fail (check_time (time), 0);
nsecs = g_ascii_strtod (time, NULL);
return nsecs * GST_SECOND;
}
static GESTimeline *
@ -251,6 +253,9 @@ create_timeline (int nbargs, gchar ** argv, const gchar * proj_uri)
char *arg0 = argv[(i * 3) + 1];
guint64 duration = str_to_time (argv[(i * 3) + 2]);
if (duration == 0)
duration = GST_CLOCK_TIME_NONE;
if (!g_strcmp0 ("+pattern", source)) {
clip = GES_CLIP (ges_test_clip_new_for_nick (arg0));
if (!clip) {
@ -321,6 +326,10 @@ create_timeline (int nbargs, gchar ** argv, const gchar * proj_uri)
return NULL;
}
if (!GST_CLOCK_TIME_IS_VALID (duration))
duration =
GES_TIMELINE_ELEMENT_DURATION (clip) - (GstClockTime) inpoint;
g_object_set (clip,
"in-point", (guint64) inpoint, "duration", (guint64) duration, NULL);