summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2018-09-05 21:49:09 -0300
committerThibault Saunier <tsaunier@igalia.com>2018-09-05 23:10:19 -0300
commitb61e045806752799b2e320c26139489e0cfd8719 (patch)
tree809fefa6f9137427ca5fe9b11a3325d1f82dc7df
parentddd422172b0c35309608158d704cf57eb5601a8c (diff)
clip: Resync priorities when removing an effect
When removing a top effect in the list of top effects, other effects priorities need to take that into account to avoid holes in the indices.
-rw-r--r--ges/ges-clip.c17
-rw-r--r--ges/ges-container.c7
-rw-r--r--tests/check/python/test_clip.py29
3 files changed, 49 insertions, 4 deletions
diff --git a/ges/ges-clip.c b/ges/ges-clip.c
index 52ef8f3d4b..0e067843af 100644
--- a/ges/ges-clip.c
+++ b/ges/ges-clip.c
@@ -327,7 +327,7 @@ _add_child (GESContainer * container, GESTimelineElement * element)
/* If the TrackElement is an effect:
* - We add it on top of the list of TrackEffect
- * - We put all TrackObject present in the TimelineObject
+ * - We put all TrackElements present in the Clip
* which are not BaseEffect on top of them
* FIXME: Let the full control over priorities to the user
*/
@@ -368,8 +368,21 @@ _add_child (GESContainer * container, GESTimelineElement * element)
static gboolean
_remove_child (GESContainer * container, GESTimelineElement * element)
{
- if (GES_IS_BASE_EFFECT (element))
+ if (GES_IS_BASE_EFFECT (element)) {
+ GList *tmp;
+ GESChildrenControlMode mode = container->children_control_mode;
+
+ GST_DEBUG_OBJECT (container, "Resyncing effects priority.");
+
+ container->children_control_mode = GES_CHILDREN_UPDATE_OFFSETS;
+ tmp = g_list_find (GES_CONTAINER_CHILDREN (container), element);
+ for (tmp = tmp->next; tmp; tmp = tmp->next) {
+ ges_timeline_element_set_priority (GES_TIMELINE_ELEMENT (tmp->data),
+ GES_TIMELINE_ELEMENT_PRIORITY (tmp->data) - 1);
+ }
+ container->children_control_mode = mode;
GES_CLIP (container)->priv->nb_effects--;
+ }
GST_FIXME_OBJECT (container, "We should set other children prios");
diff --git a/ges/ges-container.c b/ges/ges-container.c
index a048a002bd..6a8e572e8d 100644
--- a/ges/ges-container.c
+++ b/ges/ges-container.c
@@ -366,9 +366,12 @@ _dispose (GObject * object)
{
GList *tmp;
GESContainer *self = GES_CONTAINER (object);
- GList *children = ges_container_get_children (self, FALSE);
+ GList *children;
- for (tmp = children; tmp; tmp = tmp->next)
+ _ges_container_sort_children (self);
+ children = ges_container_get_children (self, FALSE);
+
+ for (tmp = g_list_last (children); tmp; tmp = tmp->prev)
ges_container_remove (self, tmp->data);
g_list_free_full (children, gst_object_unref);
diff --git a/tests/check/python/test_clip.py b/tests/check/python/test_clip.py
index ad825921b0..4bae750612 100644
--- a/tests/check/python/test_clip.py
+++ b/tests/check/python/test_clip.py
@@ -166,3 +166,32 @@ class TestTrackElements(unittest.TestCase):
audio_source = test_clip.find_track_element(None, GES.AudioSource)
self.assertFalse(audio_source is None)
self.assertEqual(audio_source.get_child_property("volume")[1], 0.0)
+
+ def check_effects(self, clip, expected_effects, expected_indexes):
+ effects = clip.get_top_effects()
+ self.assertEqual(effects, expected_effects)
+ self.assertEqual([clip.get_top_effect_index(effect) for effect in effects], expected_indexes)
+
+ def test_effects_priority(self):
+ timeline = GES.Timeline.new_audio_video()
+ self.assertEqual(len(timeline.get_tracks()), 2)
+ layer = timeline.append_layer()
+
+ test_clip = GES.TestClip()
+ self.assertEqual(test_clip.get_children(True), [])
+ self.assertTrue(layer.add_clip(test_clip))
+
+ effect1 = GES.Effect.new("agingtv")
+ test_clip.add(effect1)
+ self.check_effects(test_clip, [effect1], [0])
+
+ test_clip.set_top_effect_index(effect1, 1)
+ self.check_effects(test_clip, [effect1], [0])
+ test_clip.set_top_effect_index(effect1, 10)
+ self.check_effects(test_clip, [effect1], [0])
+
+ effect2 = GES.Effect.new("dicetv")
+ test_clip.add(effect2)
+
+ test_clip.remove(effect1)
+ self.check_effects(test_clip, [effect2], [0]) \ No newline at end of file