2009-08-06 17:51:29 +00:00
|
|
|
/* GStreamer Editing Services
|
|
|
|
* Copyright (C) 2009 Edward Hervey <bilboed@bilboed.com>
|
2012-12-20 23:23:54 +00:00
|
|
|
* 2012 Collabora Ltd.
|
|
|
|
* Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
|
2009-08-06 17:51:29 +00:00
|
|
|
*
|
|
|
|
* 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-08-06 17:51:29 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <ges/ges.h>
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_init)
|
|
|
|
{
|
|
|
|
/* Yes, I know.. minimalistic... */
|
|
|
|
ges_init ();
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-08-07 14:47:18 +00:00
|
|
|
static gboolean
|
2013-01-20 15:42:29 +00:00
|
|
|
my_fill_track_func (GESClip * object,
|
2009-08-07 18:31:11 +00:00
|
|
|
GESTrackObject * trobject, GstElement * gnlobj, gpointer user_data)
|
2009-08-07 14:47:18 +00:00
|
|
|
{
|
|
|
|
GstElement *src;
|
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
GST_DEBUG ("timelineobj:%p, trackobject:%p, gnlobj:%p",
|
2009-08-07 14:47:18 +00:00
|
|
|
object, trobject, gnlobj);
|
|
|
|
|
|
|
|
/* 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-08-07 14:47:18 +00:00
|
|
|
}
|
|
|
|
|
2009-08-06 18:04:59 +00:00
|
|
|
GST_START_TEST (test_ges_scenario)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2009-08-06 18:04:59 +00:00
|
|
|
GESTrack *track;
|
2009-08-07 14:47:18 +00:00
|
|
|
GESCustomTimelineSource *source;
|
2010-03-12 18:05:36 +00:00
|
|
|
GESTrackObject *trackobject;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers, *tracks;
|
2009-08-06 18:04:59 +00:00
|
|
|
|
2009-08-07 14:47:18 +00:00
|
|
|
ges_init ();
|
2009-08-06 18:04:59 +00:00
|
|
|
/* This is the simplest scenario ever */
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
2009-08-06 18:04:59 +00:00
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Create a layer");
|
2009-08-06 18:04:59 +00:00
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
2009-09-14 17:45:43 +00:00
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
|
|
|
/* Give the Timeline a Track */
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Create a Track");
|
2012-12-24 12:29:48 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
2010-12-15 18:05:48 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
/* The timeline steals the reference to the track */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2009-09-14 17:45:43 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Creating a source");
|
2009-08-07 18:31:11 +00:00
|
|
|
source = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (source != NULL);
|
|
|
|
|
2010-12-20 11:01:04 +00:00
|
|
|
/* The source will be floating before added to the layer... */
|
|
|
|
fail_unless (g_object_is_floating (source));
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Adding the source to the timeline layer");
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (source)));
|
2010-12-20 11:01:04 +00:00
|
|
|
fail_if (g_object_is_floating (source));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (source));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2010-12-20 11:01:04 +00:00
|
|
|
/* The timeline stole our reference */
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (tmp_layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2010-11-28 12:24:07 +00:00
|
|
|
/* Make sure the associated TrackObject is in the Track */
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (source));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 3 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 3);
|
2010-03-12 18:05:36 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
GST_DEBUG ("Remove the Clip from the layer");
|
2010-12-20 10:56:37 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
/* Now remove the clip */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_ref (source);
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_remove_object (layer, GES_CLIP (source)));
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (source, "source", 1);
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (source));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (source));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects == NULL); /* No unreffing then */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_unref (source);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Removing track from the timeline");
|
2009-08-07 14:47:18 +00:00
|
|
|
/* Remove the track from the timeline */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_ref (track);
|
2009-08-07 14:47:18 +00:00
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == NULL);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
tracks = ges_timeline_get_tracks (timeline);
|
|
|
|
fail_unless (tracks == NULL);
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
|
|
|
g_object_unref (track);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Removing layer from the timeline");
|
2009-08-07 14:47:18 +00:00
|
|
|
/* Remove the layer from the timeline */
|
2009-09-14 17:45:43 +00:00
|
|
|
g_object_ref (layer);
|
2009-08-07 14:47:18 +00:00
|
|
|
fail_unless (ges_timeline_remove_layer (timeline, layer));
|
|
|
|
fail_unless (layer->timeline == NULL);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (layers == NULL);
|
2009-09-14 17:45:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
g_object_unref (layer);
|
|
|
|
|
|
|
|
/* Finally clean up our object */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
|
|
|
|
g_object_unref (timeline);
|
2009-08-06 18:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-19 16:56:37 +00:00
|
|
|
/* very similar to the above, except we add the timeline object to the layer
|
|
|
|
* and then add it to the timeline.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_timeline_add_layer)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2010-10-19 16:56:37 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers;
|
2010-10-19 16:56:37 +00:00
|
|
|
GESTrackObject *trackobject;
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
2012-12-24 12:29:48 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
/* The timeline steals the reference to the track */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s1)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s2)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s3)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 2);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the trackobject
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 3 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the trackobject */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 3);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 3 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the trackobject */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (trackobject), "trackobject", 3);
|
2010-11-28 12:24:07 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
trackobject = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 3 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the trackobject */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (trackobject, "trackobject", 3);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
/* theoretically this is all we need to do to ensure cleanup */
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-20 15:23:22 +00:00
|
|
|
/* this time we add the layer before we add the track. */
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_timeline_add_layer_first)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2010-10-20 15:23:22 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers;
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
2012-12-24 12:29:48 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s1)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s2)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s3)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2012-04-24 00:52:45 +00:00
|
|
|
/* Each object has 4 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by _get_track_object() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2012-04-24 00:52:45 +00:00
|
|
|
/* Each object has 4 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by _get_track_object() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2012-04-24 00:52:45 +00:00
|
|
|
/* Each object has 4 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by _get_track_object() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_list_free (trackobjects);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
/* theoretically this is all we need to do to ensure cleanup */
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-22 13:01:34 +00:00
|
|
|
GST_START_TEST (test_ges_timeline_remove_track)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2010-11-28 12:24:07 +00:00
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
2010-10-22 13:01:34 +00:00
|
|
|
GESTrack *track;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
|
|
|
GESTrackObject *t1, *t2, *t3;
|
2011-01-08 10:22:36 +00:00
|
|
|
GList *trackobjects, *tmp, *layers;
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
2012-12-24 12:29:48 +00:00
|
|
|
track = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (track != NULL);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s1)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s2)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s3)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
2011-01-08 10:22:36 +00:00
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Add the track to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track));
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track, "track", 1);
|
2010-12-15 18:05:48 +00:00
|
|
|
fail_unless (ges_track_get_timeline (track) == timeline);
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t1 = GES_TRACK_OBJECT ((trackobjects)->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references held:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (t1);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references held:
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackobject", 4);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t2 = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references held:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (t2);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references held:
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "t2", 4);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t3 = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references held:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by the call to _get_track_objects() above */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
2010-12-20 10:56:37 +00:00
|
|
|
g_object_ref (t3);
|
2010-11-28 12:24:07 +00:00
|
|
|
g_list_free (trackobjects);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 4 references held:
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
2012-04-24 00:52:45 +00:00
|
|
|
* 1 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "t3", 4);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
/* remove the track and check that the track objects have been released */
|
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
|
|
|
|
2012-04-24 00:52:45 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackobject", 2);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "trackobject", 2);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "trackobject", 2);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
g_object_unref (t1);
|
|
|
|
g_object_unref (t2);
|
|
|
|
g_object_unref (t3);
|
|
|
|
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2010-10-20 15:23:22 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GESCustomTimelineSource **o1, **o2, **o3;
|
|
|
|
GESTrack **tr1, **tr2;
|
|
|
|
} SelectTracksData;
|
|
|
|
|
|
|
|
static GPtrArray *
|
2013-01-20 15:42:29 +00:00
|
|
|
select_tracks_cb (GESTimeline * timeline, GESClip * tobj,
|
2012-12-20 23:23:54 +00:00
|
|
|
GESTrackObject * trobj, SelectTracksData * st_data)
|
|
|
|
{
|
|
|
|
GESTrack *track;
|
|
|
|
|
|
|
|
GPtrArray *ret = g_ptr_array_new ();
|
2013-01-20 15:42:29 +00:00
|
|
|
track = (tobj == (GESClip *) * st_data->o2) ? *st_data->tr2 : *st_data->tr1;
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
gst_object_ref (track);
|
|
|
|
|
|
|
|
g_ptr_array_add (ret, track);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_timeline_multiple_tracks)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GESTimelineLayer *layer, *tmp_layer;
|
|
|
|
GESTrack *track1, *track2;
|
|
|
|
GESCustomTimelineSource *s1, *s2, *s3;
|
|
|
|
GESTrackObject *t1, *t2, *t3;
|
|
|
|
GList *trackobjects, *tmp, *layers;
|
|
|
|
SelectTracksData st_data = { &s1, &s2, &s3, &track1, &track2 };
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
|
|
|
timeline = ges_timeline_new ();
|
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
g_signal_connect (timeline, "select-tracks-for-object",
|
|
|
|
G_CALLBACK (select_tracks_cb), &st_data);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
|
|
|
layer = ges_timeline_layer_new ();
|
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create Track 1");
|
|
|
|
track1 = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
|
|
|
fail_unless (track1 != NULL);
|
|
|
|
GST_DEBUG ("Create Track 2");
|
|
|
|
track2 = ges_track_new (GES_TRACK_TYPE_CUSTOM, gst_caps_ref (GST_CAPS_ANY));
|
|
|
|
fail_unless (track2 != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Add the track 1 to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track1));
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track1, "track", 1);
|
|
|
|
fail_unless (ges_track_get_timeline (track1) == timeline);
|
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track1) == (gpointer) timeline);
|
|
|
|
|
|
|
|
GST_DEBUG ("Add the track 2 to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_track (timeline, track2));
|
|
|
|
ASSERT_OBJECT_REFCOUNT (track2, "track", 1);
|
|
|
|
fail_unless (ges_track_get_timeline (track2) == timeline);
|
|
|
|
fail_unless ((gpointer) GST_ELEMENT_PARENT (track2) == (gpointer) timeline);
|
|
|
|
|
|
|
|
/* Create a source and add it to the Layer */
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s1 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s1 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s1)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s2 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s2 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s2)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
|
|
|
s3 = ges_custom_timeline_source_new (my_fill_track_func, NULL);
|
|
|
|
fail_unless (s3 != NULL);
|
2013-01-20 15:42:29 +00:00
|
|
|
fail_unless (ges_timeline_layer_add_object (layer, GES_CLIP (s3)));
|
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
|
|
|
g_object_unref (tmp_layer);
|
|
|
|
|
|
|
|
GST_DEBUG ("Add the layer to the timeline");
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
/* The timeline steals our reference to the layer */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
|
|
|
fail_unless (layer->timeline == timeline);
|
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
|
|
|
g_list_foreach (layers, (GFunc) g_object_unref, NULL);
|
|
|
|
g_list_free (layers);
|
|
|
|
|
|
|
|
/* Make sure the associated TrackObjects are in the Track */
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s1));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t1 = GES_TRACK_OBJECT ((trackobjects)->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
/* There are 4 references held:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-12-20 23:23:54 +00:00
|
|
|
* 1 by the track
|
|
|
|
* 1 by the timeline
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
|
|
|
fail_unless (ges_track_object_get_track (tmp->data) == track1);
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_object_ref (t1);
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
/* There are 4 references held:
|
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 by the timeline
|
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackobject", 4);
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s2));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t2 = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
/* There are 4 references held:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-12-20 23:23:54 +00:00
|
|
|
* 1 by the track
|
|
|
|
* 1 by the timeline
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
|
|
|
fail_unless (ges_track_object_get_track (tmp->data) == track2);
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_object_ref (t2);
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
/* There are 4 references held:
|
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 by the timeline
|
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "t2", 4);
|
|
|
|
|
2013-01-20 15:42:29 +00:00
|
|
|
trackobjects = ges_clip_get_track_objects (GES_CLIP (s3));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (trackobjects != NULL);
|
|
|
|
t3 = GES_TRACK_OBJECT (trackobjects->data);
|
|
|
|
for (tmp = trackobjects; tmp; tmp = tmp->next) {
|
|
|
|
/* There are 4 references held:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2012-12-20 23:23:54 +00:00
|
|
|
* 1 by the track
|
|
|
|
* 1 by the timeline
|
|
|
|
* 1 added by the call to _get_track_objects() above */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_OBJECT (tmp->data), "trackobject", 4);
|
|
|
|
fail_unless (ges_track_object_get_track (tmp->data) == track1);
|
|
|
|
g_object_unref (GES_TRACK_OBJECT (tmp->data));
|
|
|
|
}
|
|
|
|
g_object_ref (t3);
|
|
|
|
g_list_free (trackobjects);
|
|
|
|
/* There are 4 references held:
|
|
|
|
* 1 by the timelinobject
|
|
|
|
* 1 by the track
|
|
|
|
* 1 by the timeline
|
|
|
|
* 1 added by ourselves above (g_object_ref (t1)) */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "t3", 4);
|
|
|
|
|
|
|
|
g_object_unref (t1);
|
|
|
|
g_object_unref (t2);
|
|
|
|
g_object_unref (t3);
|
|
|
|
|
|
|
|
g_object_unref (timeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2009-08-06 17:51:29 +00:00
|
|
|
static Suite *
|
|
|
|
ges_suite (void)
|
|
|
|
{
|
2010-12-20 10:38:31 +00:00
|
|
|
Suite *s = suite_create ("ges-basic");
|
2009-08-06 17:51:29 +00:00
|
|
|
TCase *tc_chain = tcase_create ("basic");
|
|
|
|
|
|
|
|
suite_add_tcase (s, tc_chain);
|
|
|
|
|
|
|
|
tcase_add_test (tc_chain, test_ges_init);
|
2009-08-06 18:04:59 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_scenario);
|
2010-10-19 16:56:37 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_add_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_add_layer_first);
|
2010-10-22 13:01:34 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_remove_track);
|
2012-12-20 23:23:54 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_multiple_tracks);
|
2009-08-06 17:51:29 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int nf;
|
|
|
|
|
|
|
|
Suite *s = ges_suite ();
|
|
|
|
SRunner *sr = srunner_create (s);
|
|
|
|
|
|
|
|
gst_check_init (&argc, &argv);
|
|
|
|
|
|
|
|
srunner_run_all (sr, CK_NORMAL);
|
|
|
|
nf = srunner_ntests_failed (sr);
|
|
|
|
srunner_free (sr);
|
|
|
|
|
|
|
|
return nf;
|
|
|
|
}
|