ges: Add API to get the TrackObject-s contained in a Track

Sort the track_objects list

API: ges_track_get_objects
This commit is contained in:
Mathieu Duponchelle 2011-07-08 03:37:28 +02:00 committed by Thibault Saunier
parent 49e547d8fb
commit c191715608
2 changed files with 42 additions and 2 deletions

View file

@ -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

View file

@ -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 */