clip: Fix the ges_clip_set_position function

And enhance the new test

https://bugzilla.gnome.org/show_bug.cgi?id=731248
This commit is contained in:
Thibault Saunier 2014-06-05 04:20:15 +02:00
parent bb4cf62b62
commit 03c87dbbc7
3 changed files with 35 additions and 12 deletions

View file

@ -1104,7 +1104,7 @@ ges_clip_set_top_effect_index (GESClip * clip, GESBaseEffect * effect,
{
gint inc;
GList *tmp;
guint current_prio;
guint current_prio, min_prio, max_prio;
GESTrackElement *track_element;
g_return_val_if_fail (GES_IS_CLIP (clip), FALSE);
@ -1112,21 +1112,22 @@ ges_clip_set_top_effect_index (GESClip * clip, GESBaseEffect * effect,
track_element = GES_TRACK_ELEMENT (effect);
current_prio = _PRIORITY (track_element);
/* FIXME, do we actually want to change what the user is telling us to do? */
newindex = newindex + MIN_GNL_PRIO;
_get_priority_range (GES_CONTAINER (clip), &min_prio, &max_prio);
newindex = newindex + min_prio;
/* We don't change the priority */
if (current_prio == newindex ||
(G_UNLIKELY (GES_CLIP (GES_TIMELINE_ELEMENT_PARENT (track_element)) !=
clip)))
return FALSE;
if (newindex > (clip->priv->nb_effects - 1 + MIN_GNL_PRIO)) {
if (newindex > (clip->priv->nb_effects - 1 + min_prio)) {
GST_DEBUG ("You are trying to make %p not a top effect", effect);
return FALSE;
}
if (current_prio > clip->priv->nb_effects + MIN_GNL_PRIO) {
GST_DEBUG ("%p is not a top effect", effect);
if (current_prio > clip->priv->nb_effects + min_prio) {
GST_ERROR ("%p is not a top effect", effect);
return FALSE;
}

View file

@ -432,6 +432,7 @@ GST_START_TEST (test_effects_priorities)
GESClip *clip;
GESTimeline *timeline;
GESTrack *audio_track, *video_track;
GESLayer *layer, *layer1;
GESTrackElement *effect, *effect1, *effect2;
@ -445,18 +446,20 @@ GST_START_TEST (test_effects_priorities)
fail_unless (ges_timeline_add_track (timeline, audio_track));
fail_unless (ges_timeline_add_track (timeline, video_track));
effect = GES_TRACK_ELEMENT (ges_effect_new ("identity"));
fail_unless (ges_track_add_element (video_track, effect));
layer = ges_timeline_append_layer (timeline);
layer1 = ges_timeline_append_layer (timeline);
ges_layer_add_clip (layer, clip);
effect = GES_TRACK_ELEMENT (ges_effect_new ("agingtv"));
fail_unless (ges_container_add (GES_CONTAINER (clip),
GES_TIMELINE_ELEMENT (effect)));
effect1 = GES_TRACK_ELEMENT (ges_effect_new ("identity"));
fail_unless (ges_track_add_element (video_track, effect1));
effect1 = GES_TRACK_ELEMENT (ges_effect_new ("agingtv"));
fail_unless (ges_container_add (GES_CONTAINER (clip),
GES_TIMELINE_ELEMENT (effect1)));
effect2 = GES_TRACK_ELEMENT (ges_effect_new ("identity"));
fail_unless (ges_track_add_element (video_track, effect2));
effect2 = GES_TRACK_ELEMENT (ges_effect_new ("agingtv"));
fail_unless (ges_container_add (GES_CONTAINER (clip),
GES_TIMELINE_ELEMENT (effect2)));
@ -476,6 +479,23 @@ GST_START_TEST (test_effects_priorities)
fail_unless_equals_int (MIN_GNL_PRIO + 1, _PRIORITY (effect1));
fail_unless_equals_int (MIN_GNL_PRIO + 2, _PRIORITY (effect2));
fail_unless (ges_clip_move_to_layer (clip, layer1));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 0, _PRIORITY (effect));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 1, _PRIORITY (effect1));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 2, _PRIORITY (effect2));
fail_unless (ges_clip_set_top_effect_priority (clip, GES_BASE_EFFECT (effect),
2));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 0, _PRIORITY (effect1));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 1, _PRIORITY (effect2));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 2, _PRIORITY (effect));
fail_unless (ges_clip_set_top_effect_priority (clip, GES_BASE_EFFECT (effect),
0));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 0, _PRIORITY (effect));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 1, _PRIORITY (effect1));
fail_unless_equals_int (LAYER_HEIGHT + MIN_GNL_PRIO + 2, _PRIORITY (effect2));
gst_object_unref (timeline);
}

View file

@ -32,6 +32,8 @@ GESPipeline * ges_test_create_pipeline (GESTimeline *timeline);
*/
#define MIN_GNL_PRIO 2
#define LAYER_HEIGHT 1000
gchar * ges_test_get_audio_only_uri (void);
gchar * ges_test_get_audio_video_uri (void);
gchar * ges_test_get_image_uri (void);