[0.10] gst-editing-services: trackobject: Take into account the max duration when trying to set a new duration
Thibault Saunier
tsaunier at kemper.freedesktop.org
Wed Apr 25 14:37:15 PDT 2012
Module: gst-editing-services
Branch: 0.10
Commit: 606a7883145f8addbbaed895af6056b11b0b0117
URL: http://cgit.freedesktop.org/gstreamer/gst-editing-services/commit/?id=606a7883145f8addbbaed895af6056b11b0b0117
Author: Thibault Saunier <thibault.saunier at collabora.com>
Date: Mon Apr 23 20:17:42 2012 -0400
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)
---
ges/ges-timeline-file-source.c | 3 ++-
ges/ges-track-object.c | 34 +++++++++++++++++++++-------------
2 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/ges/ges-timeline-file-source.c b/ges/ges-timeline-file-source.c
index 8df0456..b17abf4 100644
--- a/ges/ges-timeline-file-source.c
+++ b/ges/ges-timeline-file-source.c
@@ -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);
diff --git a/ges/ges-track-object.c b/ges/ges-track-object.c
index 0902938..2bc7885 100644
--- a/ges/ges-track-object.c
+++ b/ges/ges-track-object.c
@@ -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;
}
More information about the gstreamer-commits
mailing list