2009-09-29 13:29:11 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* 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.
|
2009-09-29 13:29:11 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
#include "test-utils.h"
|
2009-09-29 13:29:11 +00:00
|
|
|
#include <ges/ges.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
static gboolean
|
2013-02-15 02:34:48 +00:00
|
|
|
my_fill_track_func (GESClip * clip,
|
|
|
|
GESTrackElement * track_element, GstElement * gnlobj, gpointer user_data)
|
2009-09-29 13:29:11 +00:00
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
GST_DEBUG ("timelineobj:%p, trackelementec:%p, gnlobj:%p",
|
2013-02-15 02:34:48 +00:00
|
|
|
clip, track_element, gnlobj);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* Let's just put a fakesource in for the time being */
|
|
|
|
src = gst_element_factory_make ("fakesrc", NULL);
|
2010-12-09 16:43:08 +00:00
|
|
|
|
|
|
|
/* If this fails... that means that there already was something
|
|
|
|
* in it */
|
|
|
|
fail_unless (gst_bin_add (GST_BIN (gnlobj), src));
|
|
|
|
|
|
|
|
return TRUE;
|
2009-09-29 13:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_gsl_add)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2009-09-29 13:29:11 +00:00
|
|
|
GESTrack *track;
|
2013-01-17 03:35:39 +00:00
|
|
|
GESCustomSourceClip *source;
|
2013-01-20 15:42:29 +00:00
|
|
|
GESClip *source2;
|
2010-12-16 16:47:54 +00:00
|
|
|
gint result;
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
/* This is the simplest scenario ever */
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
timeline = ges_timeline_new ();
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = (GESLayer *) ges_simple_layer_new ();
|
2009-09-29 13:29:11 +00:00
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
2012-12-24 12:29:48 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
2009-09-29 13:29:11 +00:00
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
|
2013-01-17 03:35:39 +00:00
|
|
|
source = ges_custom_source_clip_new (my_fill_track_func, NULL);
|
2009-09-29 13:29:11 +00:00
|
|
|
fail_unless (source != NULL);
|
2009-11-25 11:52:50 +00:00
|
|
|
g_object_set (source, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source), 42);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (GES_SIMPLE_LAYER
|
2013-01-20 15:42:29 +00:00
|
|
|
(layer), GES_CLIP (source), -1));
|
|
|
|
fail_unless (ges_clip_get_layer (GES_CLIP (source)) == layer);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source), 0);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
2010-12-15 15:50:44 +00:00
|
|
|
/* test nth */
|
2013-04-23 23:04:04 +00:00
|
|
|
source2 = ges_simple_layer_nth ((GESSimpleLayer *) layer, -1);
|
2010-12-15 15:50:44 +00:00
|
|
|
fail_if (source2);
|
2013-04-23 23:04:04 +00:00
|
|
|
source2 = ges_simple_layer_nth ((GESSimpleLayer *) layer, 2);
|
2010-12-15 15:50:44 +00:00
|
|
|
fail_if (source2);
|
2013-04-23 23:04:04 +00:00
|
|
|
source2 = ges_simple_layer_nth ((GESSimpleLayer *) layer, 0);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless ((GESClip *) source == source2);
|
2010-12-15 15:50:44 +00:00
|
|
|
|
2010-12-16 16:47:54 +00:00
|
|
|
/* test position */
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
result = ges_simple_layer_index ((GESSimpleLayer *) layer, source2);
|
2010-12-16 16:47:54 +00:00
|
|
|
fail_unless_equals_int (result, 0);
|
2013-04-23 23:04:04 +00:00
|
|
|
result = ges_simple_layer_index ((GESSimpleLayer *) layer, (GESClip *) NULL);
|
2010-12-16 16:47:54 +00:00
|
|
|
fail_unless_equals_int (result, -1);
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source)));
|
2009-09-29 13:29:11 +00:00
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
|
|
|
fail_unless (ges_timeline_remove_layer (timeline, layer));
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2009-09-29 13:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-08-05 10:51:31 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gint new;
|
|
|
|
gint old;
|
|
|
|
} siginfo;
|
|
|
|
|
|
|
|
static void
|
2013-04-23 23:04:04 +00:00
|
|
|
object_moved_cb (GESSimpleLayer * layer,
|
2013-02-15 02:34:48 +00:00
|
|
|
GESClip * clip, gint old, gint new, gpointer user)
|
2010-08-05 10:51:31 +00:00
|
|
|
{
|
|
|
|
siginfo *info;
|
|
|
|
info = (siginfo *) user;
|
|
|
|
info->new = new;
|
|
|
|
info->old = old;
|
|
|
|
}
|
|
|
|
|
2009-09-29 13:29:11 +00:00
|
|
|
GST_START_TEST (test_gsl_move_simple)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2009-09-29 13:29:11 +00:00
|
|
|
GESTrack *track;
|
2013-01-17 03:35:39 +00:00
|
|
|
GESCustomSourceClip *source1, *source2;
|
2010-08-05 10:51:31 +00:00
|
|
|
siginfo info = { 0, 0 };
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
timeline = ges_timeline_new ();
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = (GESLayer *) ges_simple_layer_new ();
|
2009-09-29 13:29:11 +00:00
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
2012-02-10 19:44:49 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_new_any ());
|
2009-09-29 13:29:11 +00:00
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
2010-08-05 10:51:31 +00:00
|
|
|
g_signal_connect (G_OBJECT (layer), "object-moved", G_CALLBACK
|
|
|
|
(object_moved_cb), &info);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* Create two 1s sources */
|
2013-01-17 03:35:39 +00:00
|
|
|
source1 = ges_custom_source_clip_new (my_fill_track_func, NULL);
|
2009-11-25 11:52:50 +00:00
|
|
|
g_object_set (source1, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
2013-01-17 03:35:39 +00:00
|
|
|
source2 = ges_custom_source_clip_new (my_fill_track_func, NULL);
|
2009-11-25 11:52:50 +00:00
|
|
|
g_object_set (source2, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source2), GST_SECOND);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* Add source to any position */
|
|
|
|
GST_DEBUG ("Adding the source to the timeline layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (GES_SIMPLE_LAYER
|
2013-01-20 15:42:29 +00:00
|
|
|
(layer), GES_CLIP (source1), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* Add source2 to the end */
|
|
|
|
GST_DEBUG ("Adding the source to the timeline layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (GES_SIMPLE_LAYER
|
2013-01-20 15:42:29 +00:00
|
|
|
(layer), GES_CLIP (source2), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), GST_SECOND);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* Move source2 before source 1 (newpos:0) */
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_move_object (GES_SIMPLE_LAYER
|
2013-01-20 15:42:29 +00:00
|
|
|
(layer), GES_CLIP (source2), 0));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), 0);
|
2010-08-05 10:51:31 +00:00
|
|
|
fail_unless_equals_int (info.new, 0);
|
|
|
|
fail_unless_equals_int (info.old, 1);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
2010-12-01 11:16:37 +00:00
|
|
|
/* Move source2 after source 1 (newpos:0) */
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_move_object (GES_SIMPLE_LAYER
|
2013-01-20 15:42:29 +00:00
|
|
|
(layer), GES_CLIP (source2), 1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), GST_SECOND);
|
2010-12-01 11:16:37 +00:00
|
|
|
fail_unless_equals_int (info.new, 1);
|
|
|
|
fail_unless_equals_int (info.old, 0);
|
|
|
|
|
|
|
|
/* Move source1 to end (newpos:-1) */
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_move_object (GES_SIMPLE_LAYER
|
2013-01-20 15:42:29 +00:00
|
|
|
(layer), GES_CLIP (source1), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), 0);
|
2010-08-05 13:21:57 +00:00
|
|
|
/* position will be decremented, this is expected */
|
2010-12-01 11:16:37 +00:00
|
|
|
fail_unless_equals_int (info.new, -1);
|
2010-08-05 10:51:31 +00:00
|
|
|
fail_unless_equals_int (info.old, 0);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* remove source1, source2 should be moved to the beginning */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (source1);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source1)));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source2), 0);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
2009-11-25 11:52:50 +00:00
|
|
|
g_object_set (source1, "start", (guint64) 42, NULL);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* re-add source1... using the normal API, it should be added to the end */
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (source1)));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source2), 0);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), GST_SECOND);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
/* remove source1 ... */
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source1)));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_START (source2), 0);
|
2009-09-29 13:29:11 +00:00
|
|
|
/* ... and source2 */
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source2)));
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
|
|
|
fail_unless (ges_timeline_remove_layer (timeline, layer));
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2009-09-29 13:29:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-08-05 13:21:57 +00:00
|
|
|
static void
|
|
|
|
valid_notify_cb (GObject * obj, GParamSpec * unused G_GNUC_UNUSED, gint * count)
|
|
|
|
{
|
|
|
|
(*count)++;
|
|
|
|
}
|
|
|
|
|
2010-05-27 21:10:04 +00:00
|
|
|
GST_START_TEST (test_gsl_with_transitions)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer;
|
2010-05-27 21:10:04 +00:00
|
|
|
GESTrack *track;
|
2013-03-24 17:42:55 +00:00
|
|
|
GESTestClip *source1, *source2, *source3, *source4;
|
2013-01-25 18:16:21 +00:00
|
|
|
GESTransitionClip *tr1, *tr2, *tr3, *tr4, *tr5;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESSimpleLayer *gstl;
|
2010-08-05 13:21:57 +00:00
|
|
|
gboolean valid;
|
|
|
|
gint count = 0;
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
timeline = ges_timeline_new ();
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = (GESLayer *) ges_simple_layer_new ();
|
2010-08-05 13:21:57 +00:00
|
|
|
|
|
|
|
g_signal_connect (G_OBJECT (layer), "notify::valid",
|
|
|
|
G_CALLBACK (valid_notify_cb), &count);
|
|
|
|
|
2010-05-27 21:10:04 +00:00
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
2013-04-23 23:04:04 +00:00
|
|
|
ges_layer_set_priority (layer, 0);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2012-02-10 19:44:49 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_VIDEO, gst_caps_new_any ());
|
2010-05-27 21:10:04 +00:00
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
|
2012-02-10 19:44:49 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_AUDIO, gst_caps_new_any ());
|
2010-05-31 13:42:23 +00:00
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
|
|
|
|
|
2010-05-27 21:10:04 +00:00
|
|
|
/* Create four 1s sources */
|
2013-03-24 17:42:55 +00:00
|
|
|
source1 = ges_test_clip_new ();
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (source1, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
2010-07-16 14:43:38 +00:00
|
|
|
|
|
|
|
/* make this source taller than the others, so we can check that
|
|
|
|
* gstlrecalculate handles this properly */
|
|
|
|
|
2013-03-24 17:42:55 +00:00
|
|
|
source2 = ges_test_clip_new ();
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (source2, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-03-01 01:27:50 +00:00
|
|
|
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source2), GST_SECOND);
|
2013-03-24 17:42:55 +00:00
|
|
|
source3 = ges_test_clip_new ();
|
2010-05-28 09:42:29 +00:00
|
|
|
g_object_set (source3, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source3), GST_SECOND);
|
2010-07-16 14:43:38 +00:00
|
|
|
|
2013-03-24 17:42:55 +00:00
|
|
|
source4 = ges_test_clip_new ();
|
2010-05-28 09:42:29 +00:00
|
|
|
g_object_set (source4, "duration", GST_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source4), GST_SECOND);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* create half-second transitions */
|
|
|
|
|
|
|
|
#define HALF_SECOND ((guint64) (0.5 * GST_SECOND))
|
|
|
|
#define SECOND(a) ((guint64) (a * GST_SECOND))
|
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
tr1 = ges_transition_clip_new (GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (tr1, "duration", HALF_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (tr1), HALF_SECOND);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
tr2 = ges_transition_clip_new (GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (tr2, "duration", HALF_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (tr2), HALF_SECOND);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
tr3 = ges_transition_clip_new (GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (tr3, "duration", HALF_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (tr3), HALF_SECOND);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
tr4 = ges_transition_clip_new (GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (tr4, "duration", HALF_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (tr4), HALF_SECOND);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-01-25 18:16:21 +00:00
|
|
|
tr5 = ges_transition_clip_new (GES_VIDEO_STANDARD_TRANSITION_TYPE_CROSSFADE);
|
2010-05-27 21:10:04 +00:00
|
|
|
g_object_set (tr5, "duration", HALF_SECOND, "start", (guint64) 42, NULL);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (tr5), HALF_SECOND);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* simple test scenario with several sources in layer */
|
2010-06-09 16:57:59 +00:00
|
|
|
/* [0 0.5 1 1.5 2 2.5 3] */
|
2010-07-09 16:29:27 +00:00
|
|
|
/* 0 */
|
|
|
|
/* 1 [1-tr1--] */
|
2010-12-09 18:36:44 +00:00
|
|
|
/* 2 [0--source1----][3-tr2--] */
|
|
|
|
/* 3 [2---source2-----] */
|
2013-03-24 17:42:55 +00:00
|
|
|
/* 4 [4---source3---] */
|
|
|
|
/* 5 [5---source4-----] */
|
2010-12-09 18:36:44 +00:00
|
|
|
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
gstl = GES_SIMPLE_LAYER (layer);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* add objects in sequence */
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Adding source1");
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (source1), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source1), 2);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Adding tr1");
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (tr1), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source1), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr1), 1);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Adding source2");
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (source2), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source1), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr1), 1);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source2), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source2), 3);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* add the third source before the second transition */
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Adding source3");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (source3), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source1), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr1), 1);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source2), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source2), 3);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source3), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source3), SECOND (1.5));
|
2013-03-24 17:42:55 +00:00
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source3), 4);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* now add the second transition */
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Adding tr2");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (tr2), 3));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source1), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr1), 1);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source2), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source2), 3);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr2), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr2), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr2), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source3), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source3), GST_SECOND);
|
2013-03-24 17:42:55 +00:00
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source3), 4);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* fourth source */
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Adding source4");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (source4), -1));
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source1), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source1), 0);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source1), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr1), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr1), 1);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source2), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source2), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source2), 3);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (tr2), HALF_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (tr2), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_PRIORITY (tr2), 2);
|
|
|
|
fail_unless_equals_uint64 (_DURATION (source3), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source3), GST_SECOND);
|
2013-03-24 17:42:55 +00:00
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source3), 4);
|
2013-01-15 13:52:17 +00:00
|
|
|
fail_unless_equals_uint64 (_DURATION (source4), GST_SECOND);
|
|
|
|
fail_unless_equals_uint64 (_START (source4), SECOND (2));
|
2013-03-24 17:42:55 +00:00
|
|
|
fail_unless_equals_uint64 (_PRIORITY (source4), 5);
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* check that any insertion which might result in two adjacent transitions
|
|
|
|
* will fail */
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Checking wrong insertion of tr3");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_if (ges_simple_layer_add_object (gstl, GES_CLIP (tr3), 1));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_if (ges_simple_layer_add_object (gstl, GES_CLIP (tr3), 2));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_if (ges_simple_layer_add_object (gstl, GES_CLIP (tr3), 3));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_if (ges_simple_layer_add_object (gstl, GES_CLIP (tr3), 4));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
|
|
|
/* check that insertions which don't cause problems still work */
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Checking correct insertion of tr3");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (tr3), 5));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2010-08-05 13:46:02 +00:00
|
|
|
/* at this point the layer should still be valid */
|
|
|
|
g_object_get (G_OBJECT (layer), "valid", &valid, NULL);
|
|
|
|
fail_unless (valid);
|
|
|
|
fail_unless_equals_int (count, 3);
|
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Checking correct insertion of tr4");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (tr4), -1));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Checking correct insertion of tr5");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_simple_layer_add_object (gstl, GES_CLIP (tr5), 0));
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2010-08-05 13:21:57 +00:00
|
|
|
/* removals which result in two or more adjacent transitions will also
|
|
|
|
* print a warning on the console. This is expected */
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Removing source1");
|
2010-06-08 16:38:44 +00:00
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source1)));
|
2010-08-05 13:21:57 +00:00
|
|
|
|
2010-08-05 13:46:02 +00:00
|
|
|
/* layer should now be invalid */
|
2010-08-05 13:21:57 +00:00
|
|
|
|
|
|
|
g_object_get (G_OBJECT (layer), "valid", &valid, NULL);
|
|
|
|
fail_unless (!valid);
|
2010-11-27 15:56:10 +00:00
|
|
|
fail_unless_equals_int (count, 4);
|
2010-08-05 13:21:57 +00:00
|
|
|
|
2010-12-09 18:36:44 +00:00
|
|
|
GST_DEBUG ("Removing source2/3/4");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source2)));
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source3)));
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (source4)));
|
2010-06-08 16:38:44 +00:00
|
|
|
|
2010-08-05 13:21:57 +00:00
|
|
|
g_object_get (G_OBJECT (layer), "valid", &valid, NULL);
|
|
|
|
fail_unless (!valid);
|
2010-08-05 13:46:02 +00:00
|
|
|
fail_unless_equals_int (count, 4);
|
2010-08-05 13:21:57 +00:00
|
|
|
|
2010-06-08 16:38:44 +00:00
|
|
|
GST_DEBUG ("Removing transitions");
|
|
|
|
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (tr1)));
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (tr2)));
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (tr3)));
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (tr4)));
|
|
|
|
fail_unless (ges_layer_remove_clip (layer, GES_CLIP (tr5)));
|
2010-06-08 16:38:44 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("done removing transition");
|
2010-05-27 21:10:04 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2010-05-27 21:10:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-09-29 13:29:11 +00:00
|
|
|
static Suite *
|
|
|
|
ges_suite (void)
|
|
|
|
{
|
2013-04-23 23:04:04 +00:00
|
|
|
Suite *s = suite_create ("ges-simple-layer");
|
2009-09-29 13:29:11 +00:00
|
|
|
TCase *tc_chain = tcase_create ("basic");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain, test_gsl_add);
|
|
|
|
tcase_add_test (tc_chain, test_gsl_move_simple);
|
2010-05-27 21:10:04 +00:00
|
|
|
tcase_add_test (tc_chain, test_gsl_with_transitions);
|
2009-09-29 13:29:11 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-05-28 02:10:03 +00:00
|
|
|
GST_CHECK_MAIN (ges);
|