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

Thibault Saunier tsaunier at kemper.freedesktop.org
Wed Jan 11 07:04:30 PST 2012


Module: gst-editing-services
Branch: master
Commit: c1917156086c89a906561bc2f6337e57e9c4d70c
URL:    http://cgit.freedesktop.org/gstreamer/gst-editing-services/commit/?id=c1917156086c89a906561bc2f6337e57e9c4d70c

Author: Mathieu Duponchelle <seeed at laposte.net>
Date:   Fri Jul  8 03:37:28 2011 +0200

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 0e80861..c61451a 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 c082e9e..fa44ced 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 */



More information about the gstreamer-commits mailing list