ges/ges-simple-timeline-layer.c: implement simple stair-step like priority
authorBrandon Lewis <brandon.lewis@collabora.co.uk>
Thu, 27 May 2010 21:36:10 +0000 (23:36 +0200)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Wed, 9 Jun 2010 09:28:08 +0000 (11:28 +0200)
management scheme.

ges/ges-simple-timeline-layer.c

index 8e7e765ab8836f7fe2c2455ecb57192b4da5bf75..7b279311d1e47df09ce15264e2a74c52bc7b9843 100644 (file)
@@ -29,6 +29,8 @@
 #include "ges-internal.h"
 #include "ges-simple-timeline-layer.h"
 #include "ges-timeline-object.h"
+#include "ges-timeline-source.h"
+#include "ges-timeline-transition.h"
 
 static void
 ges_simple_timeline_layer_object_removed (GESTimelineLayer * layer,
@@ -100,17 +102,53 @@ gstl_recalculate (GESSimpleTimelineLayer * self)
 {
   GList *tmp;
   GstClockTime pos = 0;
+  gint priority = GES_TIMELINE_LAYER (self)->min_gnl_priority;
+  GESTimelineObject *prev_object = NULL;
 
   GST_DEBUG ("recalculating values");
 
   for (tmp = self->objects; tmp; tmp = tmp->next) {
     GESTimelineObject *obj = (GESTimelineObject *) tmp->data;
+    GST_DEBUG ("%p, %ld", obj, pos);
+
+    if (GES_IS_TIMELINE_SOURCE (obj)) {
+      GST_DEBUG ("%p is a source\n", obj);
+      priority++;
+
+      if (G_UNLIKELY (GES_TIMELINE_OBJECT_START (obj) != pos)) {
+        ges_timeline_object_set_start (obj, pos);
+      }
+
+      if (G_UNLIKELY (GES_TIMELINE_OBJECT_PRIORITY (obj) != priority)) {
+        ges_timeline_object_set_priority (obj, priority);
+      }
+
+      pos += GES_TIMELINE_OBJECT_DURATION (obj);
+    } else if (GES_IS_TIMELINE_TRANSITION (obj)) {
+      GST_DEBUG ("%p is transition\n", obj);
+
+      if (GES_IS_TIMELINE_TRANSITION (prev_object)) {
+        GST_ERROR ("two transitions in sequence!");
+      }
+
+      if (GES_IS_TIMELINE_SOURCE (prev_object)) {
+        pos -= GES_TIMELINE_OBJECT_DURATION (obj);
+      }
+
+      if (G_UNLIKELY (GES_TIMELINE_OBJECT_PRIORITY (obj) != priority)) {
+        ges_timeline_object_set_priority (obj, priority - 1);
+      }
 
-    if (G_UNLIKELY (GES_TIMELINE_OBJECT_START (obj) != pos)) {
       ges_timeline_object_set_start (obj, pos);
     }
-    pos += GES_TIMELINE_OBJECT_DURATION (obj);
+
+    GST_DEBUG (", %ld\n", pos);
+
+    prev_object = obj;
+
   }
+
+  GES_TIMELINE_LAYER (self)->max_gnl_priority = priority;
 }
 
 /**