2010-11-05 11:12:24 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2010 Thibault Saunier <tsaunier@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
2011-02-01 20:22:04 +00:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
2010-11-05 11:12:24 +00:00
|
|
|
* License along with this library; if not, write to the
|
2012-11-04 00:25:20 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-11-05 11:12:24 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
#include "test-utils.h"
|
2010-11-05 11:12:24 +00:00
|
|
|
#include <ges/ges.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
2011-02-08 14:29:21 +00:00
|
|
|
void
|
2013-02-15 02:34:48 +00:00
|
|
|
deep_prop_changed_cb (GESTrackElement * track_element, GstElement * element,
|
2011-02-08 14:29:21 +00:00
|
|
|
GParamSpec * spec);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2010-11-05 11:12:24 +00:00
|
|
|
GST_START_TEST (test_effect_basic)
|
|
|
|
{
|
2013-01-26 15:40:51 +00:00
|
|
|
GESEffect *effect;
|
2010-11-05 11:12:24 +00:00
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-01-26 15:40:51 +00:00
|
|
|
effect = ges_effect_new ("agingtv");
|
2010-11-05 11:12:24 +00:00
|
|
|
fail_unless (effect != NULL);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (effect);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2010-11-15 22:32:23 +00:00
|
|
|
}
|
2010-11-05 11:12:24 +00:00
|
|
|
|
2010-11-15 22:32:23 +00:00
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_START_TEST (test_add_effect_to_clip)
|
2010-11-15 22:32:23 +00:00
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2010-11-15 22:32:23 +00:00
|
|
|
GESTrack *track_audio, *track_video;
|
2013-03-01 01:27:50 +00:00
|
|
|
GESEffect *effect;
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *source;
|
2010-11-15 22:32:23 +00:00
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2013-11-22 20:49:49 +00:00
|
|
|
layer = ges_layer_new ();
|
2013-03-28 17:51:45 +00:00
|
|
|
track_audio = GES_TRACK (ges_audio_track_new ());
|
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
2010-11-15 22:32:23 +00:00
|
|
|
|
|
|
|
ges_timeline_add_track (timeline, track_audio);
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
2013-01-17 03:58:28 +00:00
|
|
|
source = ges_test_clip_new ();
|
2010-11-15 22:32:23 +00:00
|
|
|
|
|
|
|
g_object_set (source, "duration", 10 * GST_SECOND, NULL);
|
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_layer_add_clip (layer, (GESClip *) source);
|
2010-11-15 22:32:23 +00:00
|
|
|
|
|
|
|
|
2011-01-18 19:05:54 +00:00
|
|
|
GST_DEBUG ("Create effect");
|
2013-03-01 01:27:50 +00:00
|
|
|
effect = ges_effect_new ("agingtv");
|
2011-01-18 19:05:54 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (GES_IS_EFFECT (effect));
|
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (source),
|
|
|
|
GES_TIMELINE_ELEMENT (effect)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect)) !=
|
|
|
|
NULL);
|
2011-01-18 19:05:54 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
assert_equals_int (GES_TRACK_ELEMENT (effect)->active, TRUE);
|
2010-11-15 22:32:23 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (layer, (GESClip *) source);
|
2010-11-15 22:32:23 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2010-11-05 11:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2011-01-31 10:32:14 +00:00
|
|
|
GST_START_TEST (test_get_effects_from_tl)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2011-01-31 10:32:14 +00:00
|
|
|
GESTrack *track_video;
|
2013-03-29 18:04:54 +00:00
|
|
|
GESTrackElement *video_source;
|
2013-03-01 01:27:50 +00:00
|
|
|
GESEffect *effect, *effect1, *effect2;
|
2013-01-17 03:58:28 +00:00
|
|
|
GESTestClip *source;
|
2011-01-31 10:32:14 +00:00
|
|
|
GList *effects, *tmp = NULL;
|
|
|
|
gint effect_prio = -1;
|
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2013-11-22 20:49:49 +00:00
|
|
|
layer = ges_layer_new ();
|
2013-03-28 17:51:45 +00:00
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
2011-01-31 10:32:14 +00:00
|
|
|
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
2013-01-17 03:58:28 +00:00
|
|
|
source = ges_test_clip_new ();
|
2011-01-31 10:32:14 +00:00
|
|
|
|
|
|
|
g_object_set (source, "duration", 10 * GST_SECOND, NULL);
|
|
|
|
|
2013-03-29 18:04:54 +00:00
|
|
|
GST_DEBUG ("Adding source to layer");
|
|
|
|
ges_layer_add_clip (layer, (GESClip *) source);
|
|
|
|
assert_equals_int (g_list_length (GES_CONTAINER_CHILDREN (source)), 1);
|
|
|
|
video_source = GES_CONTAINER_CHILDREN (source)->data;
|
|
|
|
fail_unless (GES_IS_VIDEO_TEST_SOURCE (video_source));
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_int (_PRIORITY (video_source),
|
|
|
|
MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
|
2011-01-31 10:32:14 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Create effect");
|
2013-03-01 01:27:50 +00:00
|
|
|
effect = ges_effect_new ("agingtv");
|
|
|
|
effect1 = ges_effect_new ("agingtv");
|
|
|
|
effect2 = ges_effect_new ("agingtv");
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (GES_IS_EFFECT (effect));
|
|
|
|
fail_unless (GES_IS_EFFECT (effect1));
|
|
|
|
fail_unless (GES_IS_EFFECT (effect2));
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-03-29 18:04:54 +00:00
|
|
|
GST_DEBUG ("Adding effect (0)");
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (source),
|
|
|
|
GES_TIMELINE_ELEMENT (effect)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect)) ==
|
|
|
|
track_video);
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_int (_PRIORITY (effect), MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 0);
|
|
|
|
assert_equals_int (_PRIORITY (video_source),
|
|
|
|
MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 1);
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-03-29 18:04:54 +00:00
|
|
|
GST_DEBUG ("Adding effect 1");
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (source),
|
|
|
|
GES_TIMELINE_ELEMENT (effect1)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect1)) ==
|
|
|
|
track_video);
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_int (_PRIORITY (effect), MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
|
|
|
|
assert_equals_int (_PRIORITY (effect1),
|
|
|
|
MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 1);
|
|
|
|
assert_equals_int (_PRIORITY (video_source),
|
|
|
|
MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 2);
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-03-29 18:04:54 +00:00
|
|
|
GST_DEBUG ("Adding effect 2");
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (source),
|
|
|
|
GES_TIMELINE_ELEMENT (effect2)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect2)) ==
|
|
|
|
track_video);
|
2013-03-01 01:27:50 +00:00
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (source), 4);
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
effects = ges_clip_get_top_effects (GES_CLIP (source));
|
2011-02-16 16:45:05 +00:00
|
|
|
fail_unless (g_list_length (effects) == 3);
|
2011-01-31 10:32:14 +00:00
|
|
|
for (tmp = effects; tmp; tmp = tmp->next) {
|
2013-01-20 15:42:29 +00:00
|
|
|
gint priority = ges_clip_get_top_effect_position (GES_CLIP (source),
|
2013-01-26 15:35:19 +00:00
|
|
|
GES_BASE_EFFECT (tmp->data));
|
2011-01-31 10:32:14 +00:00
|
|
|
fail_unless (priority > effect_prio);
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (GES_IS_EFFECT (tmp->data));
|
2011-01-31 10:32:14 +00:00
|
|
|
effect_prio = priority;
|
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp->data);
|
2011-01-31 10:32:14 +00:00
|
|
|
}
|
|
|
|
g_list_free (effects);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (layer, (GESClip *) source);
|
2011-01-31 10:32:14 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2011-01-31 10:32:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_START_TEST (test_effect_clip)
|
2011-02-01 20:22:04 +00:00
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2011-02-01 20:22:04 +00:00
|
|
|
GESTrack *track_audio, *track_video;
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClip *effect_clip;
|
2020-03-02 12:56:03 +00:00
|
|
|
GESEffect *effect, *effect1, *core_effect, *core_effect1;
|
|
|
|
GList *children, *top_effects, *tmp;
|
|
|
|
gint clip_height;
|
|
|
|
gint core_effect_prio;
|
|
|
|
gint effect_index, effect1_index;
|
2011-02-01 20:22:04 +00:00
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2013-11-22 20:49:49 +00:00
|
|
|
layer = ges_layer_new ();
|
2013-03-28 17:51:45 +00:00
|
|
|
track_audio = GES_TRACK (ges_audio_track_new ());
|
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
2011-02-01 20:22:04 +00:00
|
|
|
|
|
|
|
ges_timeline_add_track (timeline, track_audio);
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create effect");
|
2020-03-02 12:56:03 +00:00
|
|
|
/* these are the core video and audio effects for the clip */
|
|
|
|
effect_clip = ges_effect_clip_new ("videobalance", "audioecho");
|
2011-02-01 20:22:04 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_set (effect_clip, "duration", 25 * GST_SECOND, NULL);
|
2011-02-01 20:22:04 +00:00
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_layer_add_clip (layer, (GESClip *) effect_clip);
|
2011-02-01 20:22:04 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* core elements should now be created */
|
|
|
|
fail_unless (children = GES_CONTAINER_CHILDREN (effect_clip));
|
|
|
|
core_effect = GES_EFFECT (children->data);
|
|
|
|
fail_unless (children = children->next);
|
|
|
|
core_effect1 = GES_EFFECT (children->data);
|
|
|
|
fail_unless (children->next == NULL);
|
|
|
|
|
|
|
|
/* both effects are placed at the same priority since they are core
|
|
|
|
* children of the clip, destined for different tracks */
|
|
|
|
core_effect_prio = _PRIORITY (core_effect);
|
|
|
|
assert_equals_int (core_effect_prio, _PRIORITY (core_effect1));
|
|
|
|
g_object_get (effect_clip, "height", &clip_height, NULL);
|
|
|
|
assert_equals_int (clip_height, 1);
|
|
|
|
|
|
|
|
/* add additional non-core effects */
|
2013-03-14 16:53:25 +00:00
|
|
|
effect = ges_effect_new ("agingtv");
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (effect_clip),
|
|
|
|
GES_TIMELINE_ELEMENT (effect)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect)) ==
|
|
|
|
track_video);
|
2011-02-03 15:03:10 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* placed at a higher priority than the effects */
|
|
|
|
core_effect_prio = _PRIORITY (core_effect);
|
|
|
|
assert_equals_int (core_effect_prio, _PRIORITY (core_effect1));
|
|
|
|
fail_unless (_PRIORITY (effect) < core_effect_prio);
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_get (effect_clip, "height", &clip_height, NULL);
|
2020-03-02 12:56:03 +00:00
|
|
|
assert_equals_int (clip_height, 2);
|
|
|
|
|
|
|
|
effect_index =
|
|
|
|
ges_clip_get_top_effect_index (GES_CLIP (effect_clip),
|
|
|
|
GES_BASE_EFFECT (effect));
|
|
|
|
assert_equals_int (effect_index, 0);
|
2011-02-03 15:03:10 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* 'effect1' is placed in between the core children and 'effect' */
|
2013-03-14 16:53:25 +00:00
|
|
|
effect1 = ges_effect_new ("audiopanorama");
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (effect_clip),
|
|
|
|
GES_TIMELINE_ELEMENT (effect1)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect1)) ==
|
|
|
|
track_audio);
|
2011-02-03 15:03:10 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* 'effect' is still the highest priority effect, and the core
|
|
|
|
* elements are at the lowest priority */
|
|
|
|
core_effect_prio = _PRIORITY (core_effect);
|
|
|
|
assert_equals_int (core_effect_prio, _PRIORITY (core_effect1));
|
|
|
|
fail_unless (_PRIORITY (effect1) < core_effect_prio);
|
|
|
|
fail_unless (_PRIORITY (effect1) > _PRIORITY (effect));
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_get (effect_clip, "height", &clip_height, NULL);
|
2020-03-02 12:56:03 +00:00
|
|
|
assert_equals_int (clip_height, 3);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
effect_index =
|
|
|
|
ges_clip_get_top_effect_index (GES_CLIP (effect_clip),
|
|
|
|
GES_BASE_EFFECT (effect));
|
|
|
|
effect1_index =
|
|
|
|
ges_clip_get_top_effect_index (GES_CLIP (effect_clip),
|
|
|
|
GES_BASE_EFFECT (effect1));
|
|
|
|
assert_equals_int (effect_index, 0);
|
|
|
|
assert_equals_int (effect1_index, 1);
|
|
|
|
|
|
|
|
/* all effects are children of the effect_clip, ordered by priority */
|
|
|
|
fail_unless (children = GES_CONTAINER_CHILDREN (effect_clip));
|
|
|
|
fail_unless (children->data == effect);
|
|
|
|
fail_unless (children = children->next);
|
|
|
|
fail_unless (children->data == effect1);
|
|
|
|
fail_unless (children = children->next);
|
|
|
|
fail_unless (children->data == core_effect);
|
|
|
|
fail_unless (children = children->next);
|
|
|
|
fail_unless (children->data == core_effect1);
|
|
|
|
fail_unless (children->next == NULL);
|
|
|
|
|
|
|
|
/* but only the additional effects are part of the top effects */
|
|
|
|
top_effects = ges_clip_get_top_effects (GES_CLIP (effect_clip));
|
|
|
|
fail_unless (tmp = top_effects);
|
|
|
|
fail_unless (tmp->data == effect);
|
|
|
|
fail_unless (tmp = tmp->next);
|
|
|
|
fail_unless (tmp->data == effect1);
|
|
|
|
fail_unless (tmp->next == NULL);
|
|
|
|
|
|
|
|
g_list_free_full (top_effects, gst_object_unref);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2011-02-04 10:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_START_TEST (test_priorities_clip)
|
2011-02-04 10:44:19 +00:00
|
|
|
{
|
2020-03-02 12:56:03 +00:00
|
|
|
GList *top_effects, *tmp;
|
2011-02-04 10:44:19 +00:00
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2020-03-02 12:56:03 +00:00
|
|
|
GESClip *effect_clip;
|
|
|
|
GESTrack *track_audio, *track_video, *track;
|
|
|
|
GESBaseEffect *effects[6], *audio_effect = NULL, *video_effect = NULL;
|
|
|
|
gint prev_index, i, num_effects = G_N_ELEMENTS (effects);
|
|
|
|
guint32 base_prio = MIN_NLE_PRIO + TRANSITIONS_HEIGHT;
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2013-06-29 23:31:23 +00:00
|
|
|
layer = ges_layer_new ();
|
2013-03-28 17:51:45 +00:00
|
|
|
track_audio = GES_TRACK (ges_audio_track_new ());
|
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
2011-02-04 10:44:19 +00:00
|
|
|
|
|
|
|
ges_timeline_add_track (timeline, track_audio);
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create effect");
|
2020-03-02 12:56:03 +00:00
|
|
|
effect_clip = GES_CLIP (ges_effect_clip_new ("videobalance", "audioecho"));
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_set (effect_clip, "duration", 25 * GST_SECOND, NULL);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2013-06-29 23:31:23 +00:00
|
|
|
ges_layer_add_clip ((layer), (GESClip *) effect_clip);
|
2013-03-01 01:27:50 +00:00
|
|
|
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)
|
|
|
|
audio_effect = tmp->data;
|
|
|
|
else if (ges_track_element_get_track_type (GES_TRACK_ELEMENT (tmp->data)) ==
|
|
|
|
GES_TRACK_TYPE_VIDEO)
|
|
|
|
video_effect = tmp->data;
|
|
|
|
else
|
|
|
|
g_assert (0);
|
|
|
|
}
|
|
|
|
fail_unless (GES_IS_EFFECT (audio_effect));
|
|
|
|
fail_unless (GES_IS_EFFECT (video_effect));
|
2020-03-02 12:56:03 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (audio_effect)) ==
|
|
|
|
track_audio);
|
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (video_effect)) ==
|
|
|
|
track_video);
|
2013-03-01 01:27:50 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* both the core effects have the same priority */
|
|
|
|
assert_equals_int (_PRIORITY (audio_effect), base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (video_effect), base_prio);
|
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), 1);
|
|
|
|
|
|
|
|
/* can not change their priority using the top effect methods since
|
|
|
|
* they are not top effects */
|
|
|
|
fail_unless (ges_clip_set_top_effect_index (effect_clip, audio_effect, 1)
|
|
|
|
== FALSE);
|
|
|
|
fail_unless (ges_clip_set_top_effect_index (effect_clip, video_effect, 0)
|
|
|
|
== FALSE);
|
|
|
|
|
|
|
|
/* adding non-core effects */
|
|
|
|
GST_DEBUG ("Adding effects to the effect clip ");
|
|
|
|
for (i = 0; i < num_effects; i++) {
|
|
|
|
if (i % 2)
|
|
|
|
effects[i] = GES_BASE_EFFECT (ges_effect_new ("agingtv"));
|
|
|
|
else
|
|
|
|
effects[i] = GES_BASE_EFFECT (ges_effect_new ("audiopanorama"));
|
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (effect_clip),
|
|
|
|
GES_TIMELINE_ELEMENT (effects[i])));
|
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), 2 + i);
|
|
|
|
track = ges_track_element_get_track (GES_TRACK_ELEMENT (effects[i]));
|
|
|
|
if (i % 2)
|
|
|
|
fail_unless (track == track_video);
|
|
|
|
else
|
|
|
|
fail_unless (track == track_audio);
|
|
|
|
}
|
2013-03-01 01:27:50 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* change top effect index */
|
|
|
|
for (i = 0; i < num_effects; i++) {
|
|
|
|
assert_equals_int (ges_clip_get_top_effect_index (effect_clip, effects[i]),
|
|
|
|
i);
|
|
|
|
assert_equals_int (_PRIORITY (effects[i]), i + base_prio);
|
|
|
|
}
|
2013-03-01 01:27:50 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
assert_equals_int (_PRIORITY (video_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (audio_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effect_clip), 1);
|
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), num_effects + 1);
|
|
|
|
|
|
|
|
/* moving 4th effect to index 1 should only change the priority of
|
|
|
|
* effects 1, 2, 3, and 4 because these lie between the new index (1)
|
|
|
|
* and the old index (4). */
|
|
|
|
fail_unless (ges_clip_set_top_effect_index (effect_clip, effects[4], 1));
|
|
|
|
|
|
|
|
assert_equals_int (_PRIORITY (effects[0]), 0 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[1]), 2 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[2]), 3 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[3]), 4 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[4]), 1 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[5]), 5 + base_prio);
|
|
|
|
|
|
|
|
/* everything else stays the same */
|
|
|
|
assert_equals_int (_PRIORITY (video_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (audio_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effect_clip), 1);
|
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), num_effects + 1);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* move back */
|
|
|
|
fail_unless (ges_clip_set_top_effect_index (effect_clip, effects[4], 4));
|
|
|
|
|
|
|
|
for (i = 0; i < num_effects; i++) {
|
|
|
|
assert_equals_int (ges_clip_get_top_effect_index (effect_clip, effects[i]),
|
|
|
|
i);
|
|
|
|
assert_equals_int (_PRIORITY (effects[i]), i + base_prio);
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equals_int (_PRIORITY (video_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (audio_effect), num_effects + base_prio);
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_int (_PRIORITY (effect_clip), 1);
|
2020-03-02 12:56:03 +00:00
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), num_effects + 1);
|
2016-08-11 13:14:42 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* moving 2nd effect to index 4 should only change the priority of
|
|
|
|
* effects 2, 3 and 4 because these lie between the new index (4) and
|
|
|
|
* the old index (2). */
|
2016-08-11 13:14:42 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
fail_unless (ges_clip_set_top_effect_index (effect_clip, effects[2], 4));
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
assert_equals_int (_PRIORITY (effects[0]), 0 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[1]), 1 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[2]), 4 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[3]), 2 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[4]), 3 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[5]), 5 + base_prio);
|
2011-02-04 10:44:19 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* everything else stays the same */
|
|
|
|
assert_equals_int (_PRIORITY (video_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (audio_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effect_clip), 1);
|
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), num_effects + 1);
|
2013-06-29 23:31:23 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
/* move 4th effect to index 0 should only change the priority of
|
|
|
|
* effects 0, 1, 3 and 4 because these lie between the new index (0) and
|
|
|
|
* the old index (3) */
|
2013-06-29 23:31:23 +00:00
|
|
|
|
2020-03-02 12:56:03 +00:00
|
|
|
fail_unless (ges_clip_set_top_effect_index (effect_clip, effects[4], 0));
|
|
|
|
|
|
|
|
assert_equals_int (_PRIORITY (effects[0]), 1 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[1]), 2 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[2]), 4 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[3]), 3 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[4]), 0 + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effects[5]), 5 + base_prio);
|
|
|
|
|
|
|
|
/* everything else stays the same */
|
|
|
|
assert_equals_int (_PRIORITY (video_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (audio_effect), num_effects + base_prio);
|
|
|
|
assert_equals_int (_PRIORITY (effect_clip), 1);
|
|
|
|
assert_equals_int (GES_CONTAINER_HEIGHT (effect_clip), num_effects + 1);
|
|
|
|
|
|
|
|
/* make sure top effects are ordered by index */
|
|
|
|
top_effects = ges_clip_get_top_effects (effect_clip);
|
|
|
|
prev_index = -1;
|
|
|
|
for (tmp = top_effects; tmp; tmp = tmp->next) {
|
|
|
|
gint index = ges_clip_get_top_effect_index (effect_clip,
|
2013-06-29 23:31:23 +00:00
|
|
|
GES_BASE_EFFECT (tmp->data));
|
2020-03-02 12:56:03 +00:00
|
|
|
fail_unless (index >= 0);
|
|
|
|
fail_unless (index > prev_index);
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (GES_IS_EFFECT (tmp->data));
|
2020-03-02 12:56:03 +00:00
|
|
|
prev_index = index;
|
2011-02-01 20:22:04 +00:00
|
|
|
}
|
2020-03-02 12:56:03 +00:00
|
|
|
g_list_free_full (top_effects, gst_object_unref);
|
2011-02-01 20:22:04 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2011-02-01 20:22:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
GST_START_TEST (test_effect_set_properties)
|
2011-02-08 09:25:41 +00:00
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2011-02-08 09:25:41 +00:00
|
|
|
GESTrack *track_video;
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClip *effect_clip;
|
2015-02-19 15:30:18 +00:00
|
|
|
GESTimelineElement *effect;
|
2011-02-25 16:10:00 +00:00
|
|
|
guint scratch_line, n_props, i;
|
2011-02-25 11:13:03 +00:00
|
|
|
gboolean color_aging;
|
2011-02-25 16:10:00 +00:00
|
|
|
GParamSpec **pspecs, *spec;
|
|
|
|
GValue val = { 0 };
|
|
|
|
GValue nval = { 0 };
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2013-11-22 20:49:49 +00:00
|
|
|
layer = ges_layer_new ();
|
2013-03-28 17:51:45 +00:00
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
2011-02-08 09:25:41 +00:00
|
|
|
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create effect");
|
2013-01-25 18:51:02 +00:00
|
|
|
effect_clip = ges_effect_clip_new ("agingtv", NULL);
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_set (effect_clip, "duration", 25 * GST_SECOND, NULL);
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_layer_add_clip (layer, (GESClip *) effect_clip);
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
effect = GES_TIMELINE_ELEMENT (ges_effect_new ("agingtv"));
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (effect_clip),
|
|
|
|
GES_TIMELINE_ELEMENT (effect)));
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect)) ==
|
|
|
|
track_video);
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_set_child_properties (effect,
|
2011-02-25 11:13:03 +00:00
|
|
|
"GstAgingTV::scratch-lines", 17, "color-aging", FALSE, NULL);
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_get_child_properties (effect,
|
2011-02-25 11:13:03 +00:00
|
|
|
"GstAgingTV::scratch-lines", &scratch_line,
|
|
|
|
"color-aging", &color_aging, NULL);
|
2023-04-18 21:19:16 +00:00
|
|
|
assert_equals_int (scratch_line, 17);
|
|
|
|
assert_equals_int (color_aging, FALSE);
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
pspecs = ges_timeline_element_list_children_properties (effect, &n_props);
|
2023-04-18 21:19:16 +00:00
|
|
|
assert_equals_int (n_props, 7);
|
2011-02-25 16:10:00 +00:00
|
|
|
|
|
|
|
spec = pspecs[0];
|
|
|
|
i = 1;
|
|
|
|
while (g_strcmp0 (spec->name, "scratch-lines")) {
|
|
|
|
spec = pspecs[i++];
|
|
|
|
}
|
|
|
|
|
|
|
|
g_value_init (&val, G_TYPE_UINT);
|
|
|
|
g_value_init (&nval, G_TYPE_UINT);
|
|
|
|
g_value_set_uint (&val, 10);
|
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_set_child_property_by_pspec (effect, spec, &val);
|
|
|
|
ges_timeline_element_get_child_property_by_pspec (effect, spec, &nval);
|
2023-04-18 21:19:16 +00:00
|
|
|
assert_equals_int (g_value_get_uint (&nval), 10);
|
2011-02-25 16:10:00 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n_props; i++) {
|
|
|
|
g_param_spec_unref (pspecs[i]);
|
|
|
|
}
|
2011-05-06 20:21:22 +00:00
|
|
|
g_free (pspecs);
|
2011-02-25 16:10:00 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (layer, (GESClip *) effect_clip);
|
2011-02-08 09:25:41 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2011-02-08 09:25:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
static void
|
|
|
|
effect_added_cb (GESClip * clip, GESBaseEffect * trop, gboolean * effect_added)
|
2011-02-08 13:04:39 +00:00
|
|
|
{
|
|
|
|
GST_DEBUG ("Effect added");
|
2013-02-15 02:34:48 +00:00
|
|
|
fail_unless (GES_IS_CLIP (clip));
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (GES_IS_EFFECT (trop));
|
|
|
|
*effect_added = TRUE;
|
2011-02-08 13:04:39 +00:00
|
|
|
}
|
|
|
|
|
2011-02-08 14:29:21 +00:00
|
|
|
void
|
2013-02-15 02:34:48 +00:00
|
|
|
deep_prop_changed_cb (GESTrackElement * track_element, GstElement * element,
|
2011-02-08 14:29:21 +00:00
|
|
|
GParamSpec * spec)
|
|
|
|
{
|
|
|
|
GST_DEBUG ("%s property changed", g_param_spec_get_name (spec));
|
2013-02-15 02:34:48 +00:00
|
|
|
fail_unless (GES_IS_TRACK_ELEMENT (track_element));
|
2011-02-08 14:29:21 +00:00
|
|
|
fail_unless (GST_IS_ELEMENT (element));
|
|
|
|
}
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_START_TEST (test_clip_signals)
|
2011-02-08 13:04:39 +00:00
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2011-02-08 13:04:39 +00:00
|
|
|
GESTrack *track_video;
|
2013-01-25 18:51:02 +00:00
|
|
|
GESEffectClip *effect_clip;
|
2015-02-19 15:30:18 +00:00
|
|
|
GESTimelineElement *effect;
|
2012-12-19 13:37:02 +00:00
|
|
|
GValue val = { 0, };
|
2013-03-01 01:27:50 +00:00
|
|
|
gboolean effect_added = FALSE;
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2013-11-22 20:49:49 +00:00
|
|
|
layer = ges_layer_new ();
|
2013-03-28 17:51:45 +00:00
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
2011-02-08 13:04:39 +00:00
|
|
|
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create effect");
|
2013-01-25 18:51:02 +00:00
|
|
|
effect_clip = ges_effect_clip_new ("agingtv", NULL);
|
2013-03-01 01:27:50 +00:00
|
|
|
g_signal_connect (effect_clip, "child-added", (GCallback) effect_added_cb,
|
|
|
|
&effect_added);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
g_object_set (effect_clip, "duration", 25 * GST_SECOND, NULL);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2013-11-22 20:49:49 +00:00
|
|
|
ges_layer_add_clip (layer, (GESClip *) effect_clip);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
effect = GES_TIMELINE_ELEMENT (ges_effect_new ("agingtv"));
|
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (effect_clip), effect));
|
2013-03-01 01:27:50 +00:00
|
|
|
fail_unless (effect_added);
|
|
|
|
g_signal_handlers_disconnect_by_func (effect_clip, effect_added_cb,
|
|
|
|
&effect_added);
|
2013-03-14 16:53:25 +00:00
|
|
|
fail_unless (ges_track_element_get_track (GES_TRACK_ELEMENT (effect)) ==
|
|
|
|
track_video);
|
2013-03-01 01:27:50 +00:00
|
|
|
g_signal_connect (effect, "deep-notify", (GCallback) deep_prop_changed_cb,
|
|
|
|
effect);
|
|
|
|
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_set_child_properties (effect,
|
2011-02-25 11:13:03 +00:00
|
|
|
"GstAgingTV::scratch-lines", 17, NULL);
|
2012-12-19 13:37:02 +00:00
|
|
|
|
|
|
|
g_value_init (&val, G_TYPE_UINT);
|
2015-02-19 15:30:18 +00:00
|
|
|
ges_timeline_element_get_child_property (effect,
|
2012-12-19 13:37:02 +00:00
|
|
|
"GstAgingTV::scratch-lines", &val);
|
|
|
|
fail_unless (G_VALUE_HOLDS_UINT (&val));
|
|
|
|
g_value_unset (&val);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_remove_clip (layer, (GESClip *) effect_clip);
|
2011-02-08 13:04:39 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2011-02-08 13:04:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2016-02-09 11:31:10 +00:00
|
|
|
|
|
|
|
GST_START_TEST (test_split_clip_effect_priorities)
|
|
|
|
{
|
|
|
|
GESLayer *layer;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GESTrack *track_video;
|
|
|
|
GESClip *clip, *nclip;
|
|
|
|
GESEffect *effect;
|
|
|
|
GESTrackElement *source, *nsource, *neffect;
|
|
|
|
|
2019-01-28 02:24:29 +00:00
|
|
|
ges_init ();
|
|
|
|
|
2016-02-09 11:31:10 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2020-03-02 12:56:03 +00:00
|
|
|
layer = ges_timeline_append_layer (timeline);
|
2016-02-09 11:31:10 +00:00
|
|
|
track_video = GES_TRACK (ges_video_track_new ());
|
|
|
|
|
|
|
|
g_object_set (timeline, "auto-transition", TRUE, NULL);
|
|
|
|
ges_timeline_add_track (timeline, track_video);
|
|
|
|
ges_timeline_add_layer (timeline, layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create effect");
|
|
|
|
effect = ges_effect_new ("agingtv");
|
|
|
|
clip = GES_CLIP (ges_test_clip_new ());
|
|
|
|
g_object_set (clip, "duration", GST_SECOND * 2, NULL);
|
|
|
|
|
|
|
|
fail_unless (ges_container_add (GES_CONTAINER (clip),
|
|
|
|
GES_TIMELINE_ELEMENT (effect)));
|
|
|
|
ges_layer_add_clip (layer, clip);
|
|
|
|
|
|
|
|
source = ges_clip_find_track_element (clip, NULL, GES_TYPE_VIDEO_SOURCE);
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (effect), 3);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (source), 4);
|
2016-02-09 11:31:10 +00:00
|
|
|
|
|
|
|
nclip = ges_clip_split (clip, GST_SECOND);
|
2020-03-02 12:56:03 +00:00
|
|
|
fail_unless (nclip);
|
2016-02-09 11:31:10 +00:00
|
|
|
neffect = ges_clip_find_track_element (nclip, NULL, GES_TYPE_EFFECT);
|
|
|
|
nsource = ges_clip_find_track_element (nclip, NULL, GES_TYPE_VIDEO_SOURCE);
|
|
|
|
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (effect), 3);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (source), 4);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (neffect), 5);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (nsource), 6);
|
2016-02-09 11:31:10 +00:00
|
|
|
|
|
|
|
/* Create a transition ... */
|
|
|
|
ges_timeline_element_set_start (GES_TIMELINE_ELEMENT (clip), GST_SECOND / 2);
|
|
|
|
|
2016-08-11 13:14:42 +00:00
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (effect), 3);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (source), 4);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (neffect), 5);
|
|
|
|
assert_equals_uint64 (GES_TIMELINE_ELEMENT_PRIORITY (nsource), 6);
|
2016-02-09 11:31:10 +00:00
|
|
|
|
|
|
|
gst_object_unref (timeline);
|
2019-01-28 02:24:29 +00:00
|
|
|
|
|
|
|
ges_deinit ();
|
2016-02-09 11:31:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2020-05-15 13:53:49 +00:00
|
|
|
#define _NO_ERROR -1
|
|
|
|
#define _set_rate(videorate, rate, error_code) \
|
|
|
|
{ \
|
|
|
|
g_value_set_double (&val, rate); \
|
|
|
|
if (error_code != _NO_ERROR) { \
|
|
|
|
fail_if (ges_timeline_element_set_child_property_full ( \
|
|
|
|
GES_TIMELINE_ELEMENT (videorate), "rate", &val, &error)); \
|
|
|
|
assert_GESError (error, error_code); \
|
|
|
|
} else { \
|
|
|
|
fail_unless (ges_timeline_element_set_child_property_full ( \
|
|
|
|
GES_TIMELINE_ELEMENT (videorate), "rate", &val, &error)); \
|
|
|
|
fail_if (error); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define _add_effect(clip, effect, _index, error_code) \
|
|
|
|
{ \
|
|
|
|
gint index = _index; \
|
|
|
|
if (error_code != _NO_ERROR) { \
|
|
|
|
fail_if (ges_clip_add_top_effect (clip, effect, index, &error)); \
|
|
|
|
assert_GESError (error, error_code); \
|
|
|
|
} else { \
|
|
|
|
GList *effects; \
|
|
|
|
gboolean res = ges_clip_add_top_effect (clip, effect, index, &error); \
|
|
|
|
fail_unless (res, "Adding effect " #effect " failed: %s", \
|
|
|
|
error ? error->message : "No error produced"); \
|
|
|
|
fail_if (error); \
|
|
|
|
effects = ges_clip_get_top_effects (clip); \
|
|
|
|
fail_unless (g_list_find (effects, effect)); \
|
|
|
|
if (index < 0 || index >= g_list_length (effects)) \
|
|
|
|
index = g_list_length (effects) - 1; \
|
|
|
|
assert_equals_int (ges_clip_get_top_effect_index (clip, effect), index); \
|
|
|
|
fail_unless (g_list_nth_data (effects, index) == effect); \
|
|
|
|
g_list_free_full (effects, gst_object_unref); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define _remove_effect(clip, effect, error_code) \
|
|
|
|
{ \
|
|
|
|
if (error_code != _NO_ERROR) { \
|
|
|
|
fail_if (ges_clip_remove_top_effect (clip, effect, &error)); \
|
|
|
|
assert_GESError (error, error_code); \
|
|
|
|
} else { \
|
|
|
|
GList *effects; \
|
|
|
|
gboolean res = ges_clip_remove_top_effect (clip, effect, &error); \
|
|
|
|
fail_unless (res, "Removing effect " #effect " failed: %s", \
|
|
|
|
error ? error->message : "No error produced"); \
|
|
|
|
fail_if (error); \
|
|
|
|
effects = ges_clip_get_top_effects (clip); \
|
|
|
|
fail_if (g_list_find (effects, effect)); \
|
|
|
|
g_list_free_full (effects, gst_object_unref); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define _move_effect(clip, effect, index, error_code) \
|
|
|
|
{ \
|
|
|
|
if (error_code != _NO_ERROR) { \
|
|
|
|
fail_if ( \
|
|
|
|
ges_clip_set_top_effect_index_full (clip, effect, index, &error)); \
|
|
|
|
assert_GESError (error, error_code); \
|
|
|
|
} else { \
|
|
|
|
GList *effects; \
|
|
|
|
gboolean res = \
|
|
|
|
ges_clip_set_top_effect_index_full (clip, effect, index, &error); \
|
|
|
|
fail_unless (res, "Moving effect " #effect " failed: %s", \
|
|
|
|
error ? error->message : "No error produced"); \
|
|
|
|
fail_if (error); \
|
|
|
|
effects = ges_clip_get_top_effects (clip); \
|
|
|
|
fail_unless (g_list_find (effects, effect)); \
|
|
|
|
assert_equals_int (ges_clip_get_top_effect_index (clip, effect), index); \
|
|
|
|
fail_unless (g_list_nth_data (effects, index) == effect); \
|
|
|
|
g_list_free_full (effects, gst_object_unref); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_move_time_effect)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GESTrack *track;
|
|
|
|
GESLayer *layer;
|
|
|
|
GESAsset *asset;
|
|
|
|
GESClip *clip;
|
|
|
|
GESBaseEffect *rate0, *rate1, *overlay;
|
|
|
|
GError *error = NULL;
|
|
|
|
GValue val = G_VALUE_INIT;
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
g_value_init (&val, G_TYPE_DOUBLE);
|
|
|
|
|
|
|
|
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
track = GES_TRACK (ges_video_track_new ());
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
|
|
|
|
layer = ges_timeline_append_layer (timeline);
|
|
|
|
|
|
|
|
/* add a dummy clip for overlap */
|
|
|
|
asset = ges_asset_request (GES_TYPE_TEST_CLIP, "max-duration=16", &error);
|
|
|
|
fail_unless (asset);
|
|
|
|
fail_if (error);
|
|
|
|
|
|
|
|
fail_unless (ges_layer_add_asset_full (layer, asset, 0, 0, 16,
|
|
|
|
GES_TRACK_TYPE_UNKNOWN, &error));
|
|
|
|
fail_if (error);
|
|
|
|
|
|
|
|
clip = GES_CLIP (ges_asset_extract (asset, &error));
|
|
|
|
fail_unless (clip);
|
|
|
|
fail_if (error);
|
|
|
|
assert_set_start (clip, 8);
|
|
|
|
assert_set_duration (clip, 16);
|
|
|
|
|
|
|
|
rate0 = GES_BASE_EFFECT (ges_effect_new ("videorate"));
|
|
|
|
rate1 = GES_BASE_EFFECT (ges_effect_new ("videorate"));
|
|
|
|
overlay = GES_BASE_EFFECT (ges_effect_new ("textoverlay"));
|
|
|
|
|
|
|
|
ges_track_element_set_has_internal_source (GES_TRACK_ELEMENT (overlay), TRUE);
|
|
|
|
/* only has 8ns of content */
|
|
|
|
assert_set_inpoint (overlay, 13);
|
|
|
|
assert_set_max_duration (overlay, 21);
|
|
|
|
|
|
|
|
_set_rate (rate0, 2.0, _NO_ERROR);
|
|
|
|
_set_rate (rate1, 0.5, _NO_ERROR);
|
|
|
|
|
|
|
|
/* keep alive */
|
|
|
|
gst_object_ref (clip);
|
|
|
|
gst_object_ref (rate0);
|
|
|
|
gst_object_ref (rate1);
|
|
|
|
gst_object_ref (overlay);
|
|
|
|
|
|
|
|
/* cannot add to layer with rate effect because it would cause a full
|
|
|
|
* overlap */
|
|
|
|
_add_effect (clip, rate0, 0, _NO_ERROR);
|
|
|
|
fail_if (ges_layer_add_clip_full (layer, clip, &error));
|
|
|
|
assert_GESError (error, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
_remove_effect (clip, rate0, _NO_ERROR);
|
|
|
|
|
|
|
|
/* same with overlay */
|
|
|
|
_add_effect (clip, overlay, 0, _NO_ERROR);
|
|
|
|
fail_if (ges_layer_add_clip_full (layer, clip, &error));
|
|
|
|
assert_GESError (error, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
_remove_effect (clip, overlay, _NO_ERROR);
|
|
|
|
|
|
|
|
CHECK_OBJECT_PROPS (clip, 8, 0, 16);
|
|
|
|
|
|
|
|
fail_unless (ges_layer_add_clip_full (layer, clip, &error));
|
|
|
|
fail_if (error);
|
|
|
|
|
|
|
|
CHECK_OBJECT_PROPS_MAX (clip, 8, 0, 16, 16);
|
|
|
|
|
|
|
|
/* can't add rate0 or overlay in the same way */
|
|
|
|
_add_effect (clip, rate0, 0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
_add_effect (clip, overlay, 0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
|
|
|
|
/* rate1 extends the duration-limit instead */
|
|
|
|
_add_effect (clip, rate1, 0, _NO_ERROR);
|
|
|
|
|
|
|
|
/* can't add overlay next to the timeline */
|
|
|
|
_add_effect (clip, overlay, 0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
/* but next to source is ok */
|
|
|
|
_add_effect (clip, overlay, 1, _NO_ERROR);
|
|
|
|
|
|
|
|
/* can't add rate0 after overlay */
|
|
|
|
_add_effect (clip, rate0, 1, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
/* but before is ok */
|
|
|
|
_add_effect (clip, rate0, -1, _NO_ERROR);
|
|
|
|
|
|
|
|
/* can't move rate0 to end */
|
|
|
|
_move_effect (clip, rate0, 0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
/* can't move overlay to start or end */
|
|
|
|
_move_effect (clip, overlay, 0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
_move_effect (clip, overlay, 2, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
|
|
|
|
/* can now move: swap places with rate1 */
|
|
|
|
_set_rate (rate0, 0.5, _NO_ERROR);
|
|
|
|
_move_effect (clip, rate0, 0, _NO_ERROR);
|
|
|
|
_move_effect (clip, rate1, 2, _NO_ERROR);
|
|
|
|
_set_rate (rate1, 2.0, _NO_ERROR);
|
|
|
|
|
|
|
|
/* cannot speed up either rate too much */
|
|
|
|
_set_rate (rate0, 1.0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
_set_rate (rate1, 4.0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
|
|
|
|
/* cannot remove rate0 which is slowing down */
|
|
|
|
_remove_effect (clip, rate0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
|
|
|
|
/* removing the speed-up is fine */
|
|
|
|
_remove_effect (clip, rate1, _NO_ERROR);
|
|
|
|
|
|
|
|
/* removing the overlay is fine */
|
|
|
|
_remove_effect (clip, overlay, _NO_ERROR);
|
|
|
|
|
|
|
|
CHECK_OBJECT_PROPS_MAX (clip, 8, 0, 16, 16);
|
|
|
|
assert_set_max_duration (clip, 8);
|
|
|
|
CHECK_OBJECT_PROPS_MAX (clip, 8, 0, 16, 8);
|
|
|
|
/* still can't remove the slow down since it is the only thing stopping
|
|
|
|
* a full overlap */
|
|
|
|
_remove_effect (clip, rate0, GES_ERROR_INVALID_OVERLAP_IN_TRACK);
|
|
|
|
|
|
|
|
gst_object_unref (clip);
|
|
|
|
/* shouldn't have any problems when removing from the layer */
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, clip));
|
|
|
|
|
|
|
|
g_value_reset (&val);
|
|
|
|
gst_object_unref (rate0);
|
|
|
|
gst_object_unref (rate1);
|
|
|
|
gst_object_unref (overlay);
|
|
|
|
gst_object_unref (asset);
|
|
|
|
gst_object_unref (timeline);
|
|
|
|
|
|
|
|
ges_deinit ();
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2016-02-09 11:31:10 +00:00
|
|
|
|
2010-11-05 11:12:24 +00:00
|
|
|
static Suite *
|
|
|
|
ges_suite (void)
|
|
|
|
{
|
|
|
|
Suite *s = suite_create ("ges");
|
|
|
|
TCase *tc_chain = tcase_create ("effect");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain, test_effect_basic);
|
2013-01-20 15:42:29 +00:00
|
|
|
tcase_add_test (tc_chain, test_add_effect_to_clip);
|
2011-01-31 10:32:14 +00:00
|
|
|
tcase_add_test (tc_chain, test_get_effects_from_tl);
|
2013-01-20 15:42:29 +00:00
|
|
|
tcase_add_test (tc_chain, test_effect_clip);
|
|
|
|
tcase_add_test (tc_chain, test_priorities_clip);
|
2013-03-01 01:27:50 +00:00
|
|
|
tcase_add_test (tc_chain, test_effect_set_properties);
|
2013-01-20 15:42:29 +00:00
|
|
|
tcase_add_test (tc_chain, test_clip_signals);
|
2016-02-09 11:31:10 +00:00
|
|
|
tcase_add_test (tc_chain, test_split_clip_effect_priorities);
|
2020-05-15 13:53:49 +00:00
|
|
|
tcase_add_test (tc_chain, test_move_time_effect);
|
2010-11-05 11:12:24 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-05-28 02:10:03 +00:00
|
|
|
GST_CHECK_MAIN (ges);
|