trackobject: Take into account the max duration when trying to set a new duration

Change its default value to GST_CLOCK_TIME_NONE instead of 0.

(unreleased code so it still can be changed)
This commit is contained in:
Thibault Saunier 2012-04-23 20:17:42 -04:00
parent 5cae3f844f
commit 606a788314
2 changed files with 23 additions and 14 deletions

View file

@ -231,7 +231,8 @@ filesource_set_max_duration (GESTimelineObject * object, guint64 maxduration)
tckobjs = ges_timeline_object_get_track_objects (object);
for (tmp = tckobjs; tmp; tmp = g_list_next (tmp)) {
g_object_set (tmp->data, "max-duration", maxduration, NULL);
ges_track_object_set_max_duration (GES_TRACK_OBJECT (tmp->data),
maxduration);
}
g_list_free_full (tckobjs, g_object_unref);

View file

@ -309,8 +309,8 @@ ges_track_object_class_init (GESTrackObjectClass * klass)
*/
g_object_class_install_property (object_class, PROP_MAX_DURATION,
g_param_spec_uint64 ("max-duration", "Maximum duration",
"The duration of the object", 0, G_MAXUINT64, G_MAXUINT64,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
"The duration of the object", GST_CLOCK_TIME_NONE, G_MAXUINT64,
G_MAXUINT64, G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
/**
* GESTrackObject::deep-notify:
@ -338,17 +338,18 @@ ges_track_object_class_init (GESTrackObjectClass * klass)
static void
ges_track_object_init (GESTrackObject * self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GESTrackObjectPrivate *priv = self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_TRACK_OBJECT, GESTrackObjectPrivate);
/* Sane default values */
self->priv->pending_start = 0;
self->priv->pending_inpoint = 0;
self->priv->pending_duration = GST_SECOND;
self->priv->pending_priority = 1;
self->priv->pending_active = TRUE;
self->priv->locked = TRUE;
self->priv->properties_hashtable = NULL;
priv->pending_start = 0;
priv->pending_inpoint = 0;
priv->pending_duration = GST_SECOND;
priv->pending_priority = 1;
priv->pending_active = TRUE;
priv->locked = TRUE;
priv->properties_hashtable = NULL;
priv->maxduration = GST_CLOCK_TIME_NONE;
}
static inline gboolean
@ -429,17 +430,24 @@ static inline gboolean
ges_track_object_set_duration_internal (GESTrackObject * object,
guint64 duration)
{
GESTrackObjectPrivate *priv = object->priv;
GST_DEBUG ("object:%p, duration:%" GST_TIME_FORMAT,
object, GST_TIME_ARGS (duration));
if (object->priv->gnlobject != NULL) {
if (GST_CLOCK_TIME_IS_VALID (priv->maxduration) &&
duration > object->inpoint + priv->maxduration)
duration = priv->maxduration - object->inpoint;
if (priv->gnlobject != NULL) {
if (G_UNLIKELY (duration == object->duration))
return FALSE;
g_object_set (object->priv->gnlobject, "duration", duration,
g_object_set (priv->gnlobject, "duration", duration,
"media-duration", duration, NULL);
} else
object->priv->pending_duration = duration;
priv->pending_duration = duration;
return TRUE;
}