mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
GESTimelineObject: add a ges_timeline_object_set_top_effect_priority method
Lets the user have a minimum of control over effects priorities
This commit is contained in:
parent
bad1b419c2
commit
d18c9fe8fb
4 changed files with 137 additions and 2 deletions
|
@ -287,6 +287,7 @@ ges_timeline_object_find_track_object
|
||||||
ges_timeline_object_add_track_object
|
ges_timeline_object_add_track_object
|
||||||
ges_timeline_object_get_effects
|
ges_timeline_object_get_effects
|
||||||
ges_timeline_object_get_top_effect_position
|
ges_timeline_object_get_top_effect_position
|
||||||
|
ges_timeline_object_set_top_effect_priority
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GES_TIMELINE_OBJECT_DURATION
|
GES_TIMELINE_OBJECT_DURATION
|
||||||
GES_TIMELINE_OBJECT_INPOINT
|
GES_TIMELINE_OBJECT_INPOINT
|
||||||
|
|
|
@ -844,6 +844,55 @@ ges_timeline_object_get_top_effect_position (GESTimelineObject * object,
|
||||||
GES_TRACK_OBJECT (effect))->priority_offset;
|
GES_TRACK_OBJECT (effect))->priority_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ges_timeline_object_set_top_effect_priority:
|
||||||
|
*
|
||||||
|
* @object: The origin #GESTimelineObject
|
||||||
|
* @effect: The #GESTrackEffect to move
|
||||||
|
* @newpriority: the new position at which to move the @effect inside this
|
||||||
|
* #GESTimelineObject
|
||||||
|
*
|
||||||
|
* This is a convenience method that lets you set the priority of a top effect.
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if @effect was successfuly moved, %FALSE otherwize.
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
ges_timeline_object_set_top_effect_priority (GESTimelineObject * object,
|
||||||
|
GESTrackOperation * effect, guint newpriority)
|
||||||
|
{
|
||||||
|
GList *tmp;
|
||||||
|
guint inc;
|
||||||
|
GESTrackObject *tck_obj = GES_TRACK_OBJECT (effect);
|
||||||
|
GESTimelineObjectPrivate *priv = object->priv;
|
||||||
|
|
||||||
|
/* We don't change the priority */
|
||||||
|
if (tck_obj->priority == newpriority ||
|
||||||
|
(newpriority > (object->priv->nb_effects - 1)) ||
|
||||||
|
(G_UNLIKELY (ges_track_object_get_timeline_object (tck_obj) != object))) {
|
||||||
|
return FALSE;
|
||||||
|
} else if (tck_obj->priority < newpriority)
|
||||||
|
inc = -1;
|
||||||
|
else
|
||||||
|
inc = +1;
|
||||||
|
|
||||||
|
ges_track_object_set_priority (tck_obj, newpriority);
|
||||||
|
for (tmp = priv->trackobjects; tmp; tmp = tmp->next) {
|
||||||
|
GESTrackObject *tmpo = GES_TRACK_OBJECT (tmp->data);
|
||||||
|
guint tck_priority = ges_track_object_get_priority (tmpo);
|
||||||
|
|
||||||
|
if ((inc == +1 && tck_priority >= newpriority) ||
|
||||||
|
(inc == -1 && tck_priority <= newpriority)) {
|
||||||
|
ges_track_object_set_priority (tmpo, tck_priority + inc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* We keep the list of trackobjects sorted */
|
||||||
|
priv->trackobjects = g_list_sort_with_data (priv->trackobjects,
|
||||||
|
(GCompareDataFunc) sort_track_effects, object);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_height (GESTimelineObject * object)
|
update_height (GESTimelineObject * object)
|
||||||
{
|
{
|
||||||
|
|
|
@ -248,6 +248,10 @@ gint
|
||||||
ges_timeline_object_get_top_effect_position (GESTimelineObject *object,
|
ges_timeline_object_get_top_effect_position (GESTimelineObject *object,
|
||||||
GESTrackOperation *effect);
|
GESTrackOperation *effect);
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
ges_timeline_object_set_top_effect_priority (GESTimelineObject *object,
|
||||||
|
GESTrackOperation *effect, guint newpriority);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* _GES_TIMELINE_OBJECT */
|
#endif /* _GES_TIMELINE_OBJECT */
|
||||||
|
|
|
@ -218,8 +218,88 @@ GST_START_TEST (test_tl_effect)
|
||||||
GES_TRACK_OPERATION (tmp->data));
|
GES_TRACK_OPERATION (tmp->data));
|
||||||
fail_unless (priority > effect_prio);
|
fail_unless (priority > effect_prio);
|
||||||
fail_unless (GES_IS_TRACK_EFFECT (tmp->data));
|
fail_unless (GES_IS_TRACK_EFFECT (tmp->data));
|
||||||
fail_unless (ges_track_object_get_track (GES_TRACK_OBJECT (tmp->
|
fail_unless (ges_track_object_get_track (GES_TRACK_OBJECT (tmp->data))->
|
||||||
data))->type == track_type[i]);
|
type == track_type[i]);
|
||||||
|
effect_prio = priority;
|
||||||
|
|
||||||
|
g_object_unref (tmp->data);
|
||||||
|
}
|
||||||
|
g_list_free (effects);
|
||||||
|
|
||||||
|
ges_timeline_layer_remove_object (layer, (GESTimelineObject *) tl_effect);
|
||||||
|
|
||||||
|
g_object_unref (timeline);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_priorities_tl_object)
|
||||||
|
{
|
||||||
|
GESTimeline *timeline;
|
||||||
|
GESTimelineLayer *layer;
|
||||||
|
GESTrack *track_audio, *track_video;
|
||||||
|
GESTimelineEffect *tl_effect;
|
||||||
|
GESTrackEffect *tck_effect, *tck_effect1;
|
||||||
|
GList *effects, *tmp;
|
||||||
|
gint i, tl_object_height;
|
||||||
|
gint effect_prio = -1;
|
||||||
|
|
||||||
|
ges_init ();
|
||||||
|
|
||||||
|
timeline = ges_timeline_new ();
|
||||||
|
layer = (GESTimelineLayer *) ges_simple_timeline_layer_new ();
|
||||||
|
track_audio = ges_track_audio_raw_new ();
|
||||||
|
track_video = ges_track_video_raw_new ();
|
||||||
|
|
||||||
|
ges_timeline_add_track (timeline, track_audio);
|
||||||
|
ges_timeline_add_track (timeline, track_video);
|
||||||
|
ges_timeline_add_layer (timeline, layer);
|
||||||
|
|
||||||
|
GST_DEBUG ("Create effect");
|
||||||
|
tl_effect = ges_timeline_effect_new_from_bin_desc ("identity", "identity");
|
||||||
|
|
||||||
|
g_object_set (tl_effect, "duration", 25 * GST_SECOND, NULL);
|
||||||
|
|
||||||
|
ges_simple_timeline_layer_add_object ((GESSimpleTimelineLayer *) (layer),
|
||||||
|
(GESTimelineObject *) tl_effect, 0);
|
||||||
|
|
||||||
|
tck_effect = ges_track_effect_new_from_bin_desc ("identity");
|
||||||
|
fail_unless (ges_timeline_object_add_track_object (GES_TIMELINE_OBJECT
|
||||||
|
(tl_effect), GES_TRACK_OBJECT (tck_effect)));
|
||||||
|
fail_unless (ges_track_add_object (track_video,
|
||||||
|
GES_TRACK_OBJECT (tck_effect)));
|
||||||
|
|
||||||
|
g_object_get (tl_effect, "height", &tl_object_height, NULL);
|
||||||
|
fail_unless (tl_object_height == 3);
|
||||||
|
|
||||||
|
tck_effect1 = ges_track_effect_new_from_bin_desc ("identity");
|
||||||
|
fail_unless (ges_timeline_object_add_track_object (GES_TIMELINE_OBJECT
|
||||||
|
(tl_effect), GES_TRACK_OBJECT (tck_effect1)));
|
||||||
|
fail_unless (ges_track_add_object (track_audio,
|
||||||
|
GES_TRACK_OBJECT (tck_effect1)));
|
||||||
|
|
||||||
|
fail_unless (ges_timeline_object_set_top_effect_priority (GES_TIMELINE_OBJECT
|
||||||
|
(tl_effect), GES_TRACK_OPERATION (tck_effect1), 0));
|
||||||
|
|
||||||
|
fail_unless (ges_track_object_get_priority (GES_TRACK_OBJECT (tck_effect)) ==
|
||||||
|
3);
|
||||||
|
|
||||||
|
fail_unless (ges_timeline_object_set_top_effect_priority (GES_TIMELINE_OBJECT
|
||||||
|
(tl_effect), GES_TRACK_OPERATION (tck_effect1), 3));
|
||||||
|
fail_unless (ges_track_object_get_priority (GES_TRACK_OBJECT (tck_effect)) ==
|
||||||
|
2);
|
||||||
|
|
||||||
|
g_object_get (tl_effect, "height", &tl_object_height, NULL);
|
||||||
|
fail_unless (tl_object_height == 4);
|
||||||
|
|
||||||
|
effects = ges_timeline_object_get_effects (GES_TIMELINE_OBJECT (tl_effect));
|
||||||
|
for (tmp = effects, i = 0; tmp; tmp = tmp->next, i++) {
|
||||||
|
gint priority =
|
||||||
|
ges_timeline_object_get_top_effect_position (GES_TIMELINE_OBJECT
|
||||||
|
(tl_effect),
|
||||||
|
GES_TRACK_OPERATION (tmp->data));
|
||||||
|
fail_unless (priority > effect_prio);
|
||||||
|
fail_unless (GES_IS_TRACK_EFFECT (tmp->data));
|
||||||
effect_prio = priority;
|
effect_prio = priority;
|
||||||
|
|
||||||
g_object_unref (tmp->data);
|
g_object_unref (tmp->data);
|
||||||
|
@ -245,6 +325,7 @@ ges_suite (void)
|
||||||
tcase_add_test (tc_chain, test_add_effect_to_tl_object);
|
tcase_add_test (tc_chain, test_add_effect_to_tl_object);
|
||||||
tcase_add_test (tc_chain, test_get_effects_from_tl);
|
tcase_add_test (tc_chain, test_get_effects_from_tl);
|
||||||
tcase_add_test (tc_chain, test_tl_effect);
|
tcase_add_test (tc_chain, test_tl_effect);
|
||||||
|
tcase_add_test (tc_chain, test_priorities_tl_object);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue