From 4c411761fd22ab7faad8fbb246b51803152513f4 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 22 Nov 2013 17:33:18 -0300 Subject: [PATCH] layer: Add an API to get the total duration of the layer API: ges_layer_get_duration --- docs/libs/ges-sections.txt | 1 + ges/ges-layer.c | 24 +++++++++++++++++++++++- ges/ges-layer.h | 1 + 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index 489780401d..d29916953d 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -385,6 +385,7 @@ ges_layer_get_timeline ges_layer_get_auto_transition ges_layer_set_auto_transition ges_layer_is_empty +ges_layer_get_duration GES_TIMELINE_GET_LAYERS GES_TIMELINE_GET_TRACKS diff --git a/ges/ges-layer.c b/ges/ges-layer.c index d7dc059d88..98714e2590 100644 --- a/ges/ges-layer.c +++ b/ges/ges-layer.c @@ -219,7 +219,7 @@ ges_layer_init (GESLayer * self) * ges_layer_resync_priorities: * @layer: a #GESLayer * - * Resyncs the priorities of the objects controlled by @layer. + * Resyncs the priorities of the clips controlled by @layer. * This method */ static gboolean @@ -285,6 +285,28 @@ new_asset_cb (GESAsset * source, GAsyncResult * res, NewAssetUData * udata) g_slice_free (NewAssetUData, udata); } +/** + * ges_layer_get_duration: + * @layer: The #GESLayer to get the duration from + * + * Lets you retrieve the duration of the layer, which means + * the end time of the last clip inside it + * + * Returns: The duration of a layer + */ +GstClockTime +ges_layer_get_duration (GESLayer * layer) +{ + GList *tmp; + GstClockTime duration = 0; + + for (tmp = layer->priv->clips_start; tmp; tmp = tmp->next) { + duration = MAX (duration, _END (tmp->data)); + } + + return duration; +} + /* Public methods */ /** * ges_layer_remove_clip: diff --git a/ges/ges-layer.h b/ges/ges-layer.h index 11034b9295..eff5a906cc 100644 --- a/ges/ges-layer.h +++ b/ges/ges-layer.h @@ -124,6 +124,7 @@ void ges_layer_set_auto_transition (GESLayer * layer, gboolean auto_transition); GList* ges_layer_get_clips (GESLayer * layer); +GstClockTime ges_layer_get_duration (GESLayer *layer); G_END_DECLS