From c1917156086c89a906561bc2f6337e57e9c4d70c Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 8 Jul 2011 03:37:28 +0200 Subject: [PATCH] ges: Add API to get the TrackObject-s contained in a Track Sort the track_objects list API: ges_track_get_objects --- ges/ges-track.c | 42 ++++++++++++++++++++++++++++++++++++++++-- ges/ges-track.h | 2 ++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ges/ges-track.c b/ges/ges-track.c index 0e808615a6..c61451acdb 100644 --- a/ges/ges-track.c +++ b/ges/ges-track.c @@ -335,6 +335,26 @@ ges_track_set_caps (GESTrack * track, const GstCaps * caps) /* FIXME : update all trackobjects ? */ } + +/* FIXME : put the compare function in the utils */ + +static gint +objects_start_compare (GESTrackObject * a, GESTrackObject * b) +{ + if (a->start == b->start) { + if (a->priority < b->priority) + return -1; + if (a->priority > b->priority) + return 1; + return 0; + } + if (a->start < b->start) + return -1; + if (a->start > b->start) + return 1; + return 0; +} + /** * ges_track_add_object: * @track: a #GESTrack @@ -383,14 +403,32 @@ ges_track_add_object (GESTrack * track, GESTrackObject * object) } g_object_ref_sink (object); - - track->priv->trackobjects = g_list_append (track->priv->trackobjects, object); + track->priv->trackobjects = + g_list_insert_sorted (track->priv->trackobjects, object, + (GCompareFunc) objects_start_compare); g_signal_emit (track, ges_track_signals[TRACK_OBJECT_ADDED], 0, GES_TRACK_OBJECT (object)); return TRUE; } +GList * +ges_track_get_objects (GESTrack * track) +{ + GList *ret = NULL; + GList *tmp; + + g_return_val_if_fail (GES_IS_TRACK (track), NULL); + + for (tmp = track->priv->trackobjects; tmp; tmp = tmp->next) { + ret = g_list_prepend (ret, tmp->data); + g_object_ref (tmp->data); + } + + ret = g_list_reverse (ret); + return ret; +} + /** * ges_track_remove_object: * @track: a #GESTrack diff --git a/ges/ges-track.h b/ges/ges-track.h index c082e9e27d..fa44ced20c 100644 --- a/ges/ges-track.h +++ b/ges/ges-track.h @@ -98,6 +98,8 @@ gboolean ges_track_remove_object (GESTrack * track, GESTrack *ges_track_video_raw_new (void); GESTrack *ges_track_audio_raw_new (void); +GList* ges_track_get_objects (GESTrack *track); + G_END_DECLS #endif /* _GES_TRACK */