diff --git a/ges/ges-clip.c b/ges/ges-clip.c index b2b1a65835..0d09e3d7e0 100644 --- a/ges/ges-clip.c +++ b/ges/ges-clip.c @@ -91,6 +91,21 @@ static GParamSpec *properties[PROP_LAST]; * * *****************************************************/ +static void +_get_priority_range (GESContainer * container, guint32 * min_priority, + guint32 * max_priority) +{ + GESLayer *layer = GES_CLIP (container)->priv->layer; + + if (layer) { + *min_priority = layer->min_gnl_priority; + *max_priority = layer->max_gnl_priority; + } else { + *min_priority = 0; + *max_priority = G_MAXUINT32; + } +} + static gboolean _set_start (GESTimelineElement * element, GstClockTime start) { @@ -186,14 +201,17 @@ _set_priority (GESTimelineElement * element, guint32 priority) GESContainer *container = GES_CONTAINER (element); - GES_CONTAINER_GET_CLASS (element)->get_priority_range (container, &min_prio, - &max_prio); + _get_priority_range (container, &min_prio, &max_prio); - _ges_container_set_children_control_mode (container, - GES_CHILDREN_IGNORE_NOTIFIES); for (tmp = container->children; tmp; tmp = g_list_next (tmp)) { - guint32 real_tck_prio = min_prio + priority; + guint32 real_tck_prio; GESTimelineElement *child = (GESTimelineElement *) tmp->data; + gint off = _PRIORITY (child) - _PRIORITY (element) - MIN_GNL_PRIO; + + if (off >= LAYER_HEIGHT) + off = 0; + + real_tck_prio = min_prio + priority + off; if (real_tck_prio > max_prio) { GST_WARNING ("%p priority of %i, is outside of the its containing " @@ -241,21 +259,6 @@ _compute_height (GESContainer * container) _ges_container_set_height (container, max_prio - min_prio + 1); } -static void -_get_priority_range (GESContainer * container, guint32 * min_priority, - guint32 * max_priority) -{ - GESLayer *layer = GES_CLIP (container)->priv->layer; - - if (layer) { - *min_priority = layer->min_gnl_priority; - *max_priority = layer->max_gnl_priority; - } else { - *min_priority = 0; - *max_priority = G_MAXUINT32; - } -} - static gboolean _add_child (GESContainer * container, GESTimelineElement * element) { diff --git a/tests/check/ges/effects.c b/tests/check/ges/effects.c index f35aa3e1c2..dc720f3f8e 100644 --- a/tests/check/ges/effects.c +++ b/tests/check/ges/effects.c @@ -226,8 +226,8 @@ GST_START_TEST (test_effect_clip) GES_BASE_EFFECT (tmp->data)); fail_unless (priority > effect_prio); fail_unless (GES_IS_EFFECT (tmp->data)); - fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (tmp->data))-> - type == track_type[i]); + fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (tmp-> + data))->type == track_type[i]); effect_prio = priority; gst_object_unref (tmp->data); @@ -256,7 +256,7 @@ GST_START_TEST (test_priorities_clip) ges_init (); timeline = ges_timeline_new (); - layer = (GESLayer *) ges_simple_layer_new (); + layer = ges_layer_new (); track_audio = GES_TRACK (ges_audio_track_new ()); track_video = GES_TRACK (ges_video_track_new ()); @@ -269,9 +269,7 @@ GST_START_TEST (test_priorities_clip) g_object_set (effect_clip, "duration", 25 * GST_SECOND, NULL); - ges_simple_layer_add_object ((GESSimpleLayer *) (layer), - (GESClip *) effect_clip, 0); - + ges_layer_add_clip ((layer), (GESClip *) effect_clip); for (tmp = GES_CONTAINER_CHILDREN (effect_clip); tmp; tmp = tmp->next) { if (ges_track_element_get_track_type (GES_TRACK_ELEMENT (tmp->data)) == GES_TRACK_TYPE_AUDIO) @@ -329,6 +327,22 @@ GST_START_TEST (test_priorities_clip) } g_list_free (effects); + ges_timeline_element_set_priority (GES_TIMELINE_ELEMENT (effect_clip), 2); + assert_equals_int (_PRIORITY (effect_clip), 2); + assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), 4); + effects = ges_clip_get_top_effects (GES_CLIP (effect_clip)); + effect_prio = 0; + for (tmp = effects, i = 0; tmp; tmp = tmp->next, i++) { + gint priority = ges_clip_get_top_effect_position (GES_CLIP (effect_clip), + GES_BASE_EFFECT (tmp->data)); + fail_unless (priority > effect_prio); + fail_unless (GES_IS_EFFECT (tmp->data)); + effect_prio = priority; + + gst_object_unref (tmp->data); + } + g_list_free (effects); + ges_layer_remove_clip (layer, (GESClip *) effect_clip); gst_object_unref (timeline);