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
|
|
|
*/
|
|
|
|
|
2013-05-29 20:48:03 +00:00
|
|
|
#include "test-utils.h"
|
|
|
|
|
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-06 18:04:59 +00:00
|
|
|
GST_START_TEST (test_ges_scenario)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer, *tmp_layer;
|
2009-08-06 18:04:59 +00:00
|
|
|
GESTrack *track;
|
2013-08-26 23:15:08 +00:00
|
|
|
GESTestClip *source;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement;
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *trackelements, *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");
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2009-08-06 18:04:59 +00:00
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
2009-09-14 17:45:43 +00:00
|
|
|
GST_DEBUG ("Create a layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = ges_layer_new ();
|
2009-08-06 18:04:59 +00:00
|
|
|
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);
|
2013-03-16 22:05:04 +00:00
|
|
|
g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
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");
|
2013-08-26 23:15:08 +00:00
|
|
|
track = GES_TRACK (ges_video_track_new ());
|
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");
|
2013-08-26 23:15:08 +00:00
|
|
|
source = ges_test_clip_new ();
|
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-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (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 */
|
2014-02-18 14:14:40 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (source, "source + 1 timeline", 2);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2009-08-07 14:47:18 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Make sure the associated TrackElement is in the Track */
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (source);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
trackelement = GES_TRACK_ELEMENT (trackelements->data);
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 4);
|
2012-04-24 00:52:45 +00:00
|
|
|
/* There are 3 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track */
|
2014-02-18 14:14:40 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 4);
|
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 */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (source);
|
2010-11-28 12:24:07 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "layer", 1);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_remove_clip (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-03-16 22:05:04 +00:00
|
|
|
gst_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 */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_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);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_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 */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_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);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (layer);
|
2009-09-14 17:45:43 +00:00
|
|
|
|
|
|
|
/* Finally clean up our object */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (timeline, "timeline", 1);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2009-08-06 18:04:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-02-08 20:11:22 +00:00
|
|
|
/* very similar to the above, except we add the clip to the layer
|
2010-10-19 16:56:37 +00:00
|
|
|
* and then add it to the timeline.
|
|
|
|
*/
|
|
|
|
|
|
|
|
GST_START_TEST (test_ges_timeline_add_layer)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer, *tmp_layer;
|
2010-10-19 16:56:37 +00:00
|
|
|
GESTrack *track;
|
2013-08-26 23:15:08 +00:00
|
|
|
GESTestClip *s1, *s2, *s3;
|
2013-03-01 01:27:50 +00:00
|
|
|
GList *trackelements, *layers;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *trackelement;
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = ges_layer_new ();
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
2013-08-26 23:15:08 +00:00
|
|
|
track = GES_TRACK (ges_video_track_new ());
|
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");
|
2013-08-26 23:15:08 +00:00
|
|
|
s1 = ges_test_clip_new ();
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless (s1 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
|
2013-01-20 15:42:29 +00:00
|
|
|
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);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s2 = ges_test_clip_new ();
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless (s2 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
|
2013-01-20 15:42:29 +00:00
|
|
|
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);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s3 = ges_test_clip_new ();
|
2010-10-19 16:56:37 +00:00
|
|
|
fail_unless (s3 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
|
2013-01-20 15:42:29 +00:00
|
|
|
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);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_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);
|
2013-03-16 22:05:04 +00:00
|
|
|
g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_free (layers);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Make sure the associated TrackElements are in the Track */
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s1);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
trackelement = GES_TRACK_ELEMENT (trackelements->data);
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references:
|
2013-01-20 15:42:29 +00:00
|
|
|
* 1 by the clip
|
2013-01-26 15:31:33 +00:00
|
|
|
* 1 by the trackelement
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 4);
|
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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the trackelement */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 4);
|
2013-01-26 15:31:33 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s2);
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelement = GES_TRACK_ELEMENT (trackelements->data);
|
|
|
|
fail_unless (trackelements != NULL);
|
2013-03-01 01:27:50 +00:00
|
|
|
|
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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the trackelement */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (trackelement), "trackelement", 4);
|
2013-01-26 15:31:33 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s3);
|
2013-01-26 15:31:33 +00:00
|
|
|
trackelement = GES_TRACK_ELEMENT (trackelements->data);
|
|
|
|
fail_unless (trackelements != NULL);
|
2013-03-01 01:27:50 +00:00
|
|
|
|
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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the trackelement */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (trackelement, "trackelement", 4);
|
2010-10-19 16:56:37 +00:00
|
|
|
|
|
|
|
/* theoretically this is all we need to do to ensure cleanup */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2010-10-19 16:56:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer, *tmp_layer;
|
2010-10-20 15:23:22 +00:00
|
|
|
GESTrack *track;
|
2013-08-26 23:15:08 +00:00
|
|
|
GESTestClip *s1, *s2, *s3;
|
2013-01-26 15:31:33 +00:00
|
|
|
GList *trackelements, *tmp, *layers;
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = ges_layer_new ();
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
2013-08-26 23:15:08 +00:00
|
|
|
track = GES_TRACK (ges_video_track_new ());
|
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");
|
2013-08-26 23:15:08 +00:00
|
|
|
s1 = ges_test_clip_new ();
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless (s1 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s2 = ges_test_clip_new ();
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless (s2 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s3 = ges_test_clip_new ();
|
2010-10-20 15:23:22 +00:00
|
|
|
fail_unless (s3 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_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);
|
2013-03-16 22:05:04 +00:00
|
|
|
g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
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);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Make sure the associated TrackElements are in the Track */
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s1);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* Each object has 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s2);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* Each object has 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s3);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* Each object has 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
}
|
2010-10-20 15:23:22 +00:00
|
|
|
|
|
|
|
/* theoretically this is all we need to do to ensure cleanup */
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2010-10-20 15:23:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2010-10-22 13:01:34 +00:00
|
|
|
GST_START_TEST (test_ges_timeline_remove_track)
|
|
|
|
{
|
|
|
|
GESTimeline *timeline;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer, *tmp_layer;
|
2010-10-22 13:01:34 +00:00
|
|
|
GESTrack *track;
|
2013-08-26 23:15:08 +00:00
|
|
|
GESTestClip *s1, *s2, *s3;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *t1, *t2, *t3;
|
|
|
|
GList *trackelements, *tmp, *layers;
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = ges_layer_new ();
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create a Track");
|
2013-08-26 23:15:08 +00:00
|
|
|
track = GES_TRACK (ges_video_track_new ());
|
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");
|
2013-08-26 23:15:08 +00:00
|
|
|
s1 = ges_test_clip_new ();
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (s1 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2013-06-26 21:08:57 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s2 = ges_test_clip_new ();
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (s2 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2013-06-26 21:08:57 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s3 = ges_test_clip_new ();
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (s3 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2010-11-28 12:24:07 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2013-06-26 21:08:57 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
|
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);
|
2013-03-16 22:05:04 +00:00
|
|
|
g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
|
2011-01-10 10:18:27 +00:00
|
|
|
g_list_free (layers);
|
2013-06-26 21:08:57 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
|
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);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Make sure the associated TrackElements are in the Track */
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s1);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
t1 = GES_TRACK_ELEMENT ((trackelements)->data);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
}
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the container
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackelement", 4);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s2);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
t2 = GES_TRACK_ELEMENT (trackelements->data);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
}
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the container
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "t2", 4);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s3);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
t3 = GES_TRACK_ELEMENT (trackelements->data);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2010-11-28 12:24:07 +00:00
|
|
|
}
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the container
|
2010-12-20 10:56:37 +00:00
|
|
|
* 1 by the track
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "t3", 4);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2013-02-08 19:39:18 +00:00
|
|
|
/* remove the track and check that the track elements have been released */
|
2010-10-22 13:01:34 +00:00
|
|
|
fail_unless (ges_timeline_remove_track (timeline, track));
|
|
|
|
|
2013-03-23 07:48:43 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackelement", 2);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "trackelement", 2);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "trackelement", 2);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (layer, "1 for the timeline", 1);
|
|
|
|
ASSERT_OBJECT_REFCOUNT (timeline, "1 for the us", 1);
|
2013-04-23 23:04:04 +00:00
|
|
|
tmp = ges_layer_get_clips (layer);
|
2013-03-23 07:48:43 +00:00
|
|
|
assert_equals_int (g_list_length (tmp), 3);
|
2014-10-26 20:24:09 +00:00
|
|
|
g_list_foreach (tmp, (GFunc) gst_object_unref, NULL);
|
2010-10-22 13:01:34 +00:00
|
|
|
|
2016-06-18 20:16:00 +00:00
|
|
|
gst_check_objects_destroyed_on_unref (G_OBJECT (timeline),
|
|
|
|
G_OBJECT (layer), t1, t2, t3, NULL);
|
2010-10-22 13:01:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
2010-10-20 15:23:22 +00:00
|
|
|
|
2012-12-20 23:23:54 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-08-26 23:15:08 +00:00
|
|
|
GESTestClip **o1, **o2, **o3;
|
2012-12-20 23:23:54 +00:00
|
|
|
GESTrack **tr1, **tr2;
|
|
|
|
} SelectTracksData;
|
|
|
|
|
|
|
|
static GPtrArray *
|
2013-02-15 02:34:48 +00:00
|
|
|
select_tracks_cb (GESTimeline * timeline, GESClip * clip,
|
|
|
|
GESTrackElement * track_element, SelectTracksData * st_data)
|
2012-12-20 23:23:54 +00:00
|
|
|
{
|
|
|
|
GESTrack *track;
|
|
|
|
|
|
|
|
GPtrArray *ret = g_ptr_array_new ();
|
2013-02-15 02:34:48 +00:00
|
|
|
track = (clip == (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;
|
2013-04-23 23:04:04 +00:00
|
|
|
GESLayer *layer, *tmp_layer;
|
2012-12-20 23:23:54 +00:00
|
|
|
GESTrack *track1, *track2;
|
2013-08-26 23:15:08 +00:00
|
|
|
GESTestClip *s1, *s2, *s3;
|
2013-01-26 15:31:33 +00:00
|
|
|
GESTrackElement *t1, *t2, *t3;
|
|
|
|
GList *trackelements, *tmp, *layers;
|
2012-12-20 23:23:54 +00:00
|
|
|
SelectTracksData st_data = { &s1, &s2, &s3, &track1, &track2 };
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
/* Timeline and 1 Layer */
|
|
|
|
GST_DEBUG ("Create a timeline");
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new ();
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (timeline != NULL);
|
|
|
|
|
|
|
|
g_signal_connect (timeline, "select-tracks-for-object",
|
|
|
|
G_CALLBACK (select_tracks_cb), &st_data);
|
|
|
|
|
|
|
|
GST_DEBUG ("Create a layer");
|
2013-04-23 23:04:04 +00:00
|
|
|
layer = ges_layer_new ();
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (layer != NULL);
|
|
|
|
/* Give the Timeline a Track */
|
|
|
|
GST_DEBUG ("Create Track 1");
|
2013-08-26 23:15:08 +00:00
|
|
|
track1 = GES_TRACK (ges_video_track_new ());
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (track1 != NULL);
|
|
|
|
GST_DEBUG ("Create Track 2");
|
2013-08-26 23:15:08 +00:00
|
|
|
track2 = GES_TRACK (ges_video_track_new ());
|
2012-12-20 23:23:54 +00:00
|
|
|
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");
|
2013-08-26 23:15:08 +00:00
|
|
|
s1 = ges_test_clip_new ();
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (s1 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s1)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s1));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s2 = ges_test_clip_new ();
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (s2 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s2)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s2));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
|
|
|
GST_DEBUG ("Creating a source");
|
2013-08-26 23:15:08 +00:00
|
|
|
s3 = ges_test_clip_new ();
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (s3 != NULL);
|
2013-04-23 23:04:04 +00:00
|
|
|
fail_unless (ges_layer_add_clip (layer, GES_CLIP (s3)));
|
2013-01-20 15:42:29 +00:00
|
|
|
tmp_layer = ges_clip_get_layer (GES_CLIP (s3));
|
2012-12-20 23:23:54 +00:00
|
|
|
fail_unless (tmp_layer == layer);
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (tmp_layer);
|
2012-12-20 23:23:54 +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);
|
|
|
|
|
|
|
|
layers = ges_timeline_get_layers (timeline);
|
|
|
|
fail_unless (g_list_find (layers, layer) != NULL);
|
2013-03-16 22:05:04 +00:00
|
|
|
g_list_foreach (layers, (GFunc) gst_object_unref, NULL);
|
2012-12-20 23:23:54 +00:00
|
|
|
g_list_free (layers);
|
|
|
|
|
2013-01-26 15:31:33 +00:00
|
|
|
/* Make sure the associated TrackElements are in the Track */
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s1);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
t1 = GES_TRACK_ELEMENT ((trackelements)->data);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (ges_track_element_get_track (tmp->data) == track1);
|
2012-12-20 23:23:54 +00:00
|
|
|
}
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (t1);
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the container
|
2012-12-20 23:23:54 +00:00
|
|
|
* 1 by the track
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline
|
2013-03-16 22:05:04 +00:00
|
|
|
* 1 added by ourselves above (gst_object_ref (t1)) */
|
2014-02-18 14:14:40 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t1, "trackelement", 5);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s2);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
t2 = GES_TRACK_ELEMENT (trackelements->data);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (ges_track_element_get_track (tmp->data) == track2);
|
2012-12-20 23:23:54 +00:00
|
|
|
}
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (t2);
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the container
|
2012-12-20 23:23:54 +00:00
|
|
|
* 1 by the track
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline
|
2013-03-16 22:05:04 +00:00
|
|
|
* 1 added by ourselves above (gst_object_ref (t2)) */
|
2014-02-18 14:14:40 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t2, "t2", 5);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-01 01:27:50 +00:00
|
|
|
trackelements = GES_CONTAINER_CHILDREN (s3);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (trackelements != NULL);
|
|
|
|
t3 = GES_TRACK_ELEMENT (trackelements->data);
|
|
|
|
for (tmp = trackelements; tmp; tmp = tmp->next) {
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 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
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline */
|
|
|
|
ASSERT_OBJECT_REFCOUNT (GES_TRACK_ELEMENT (tmp->data), "trackelement", 4);
|
2013-01-26 15:31:33 +00:00
|
|
|
fail_unless (ges_track_element_get_track (tmp->data) == track1);
|
2012-12-20 23:23:54 +00:00
|
|
|
}
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_ref (t3);
|
2013-03-01 01:27:50 +00:00
|
|
|
/* There are 3 references held:
|
|
|
|
* 1 by the container
|
2012-12-20 23:23:54 +00:00
|
|
|
* 1 by the track
|
2014-02-18 14:14:40 +00:00
|
|
|
* 2 by the timeline
|
2013-03-16 22:05:04 +00:00
|
|
|
* 1 added by ourselves above (gst_object_ref (t3)) */
|
2014-02-18 14:14:40 +00:00
|
|
|
ASSERT_OBJECT_REFCOUNT (t3, "t3", 5);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (t1);
|
|
|
|
gst_object_unref (t2);
|
|
|
|
gst_object_unref (t3);
|
2012-12-20 23:23:54 +00:00
|
|
|
|
2013-03-16 22:05:04 +00:00
|
|
|
gst_object_unref (timeline);
|
2012-12-20 23:23:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2013-07-01 14:27:54 +00:00
|
|
|
GST_START_TEST (test_ges_pipeline_change_state)
|
2013-05-29 20:48:03 +00:00
|
|
|
{
|
|
|
|
GstState state;
|
|
|
|
GESAsset *asset;
|
|
|
|
GESLayer *layer;
|
|
|
|
GESTimeline *timeline;
|
2013-07-01 14:27:54 +00:00
|
|
|
GESPipeline *pipeline;
|
2013-05-29 20:48:03 +00:00
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
layer = ges_layer_new ();
|
2013-11-28 18:08:33 +00:00
|
|
|
timeline = ges_timeline_new_audio_video ();
|
2013-05-29 20:48:03 +00:00
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
|
|
|
|
pipeline = ges_test_create_pipeline (timeline);
|
|
|
|
|
|
|
|
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
|
|
|
|
ges_layer_add_asset (layer, asset, 0, 0, 10, GES_TRACK_TYPE_UNKNOWN);
|
|
|
|
gst_object_unref (asset);
|
|
|
|
|
2013-06-09 16:29:05 +00:00
|
|
|
ges_timeline_commit (timeline);
|
2013-05-29 20:48:03 +00:00
|
|
|
ASSERT_SET_STATE (GST_ELEMENT (pipeline), GST_STATE_PLAYING,
|
|
|
|
GST_STATE_CHANGE_ASYNC);
|
|
|
|
fail_unless (gst_element_get_state (GST_ELEMENT (pipeline), &state, NULL,
|
|
|
|
GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_SUCCESS);
|
|
|
|
fail_unless (state == GST_STATE_PLAYING);
|
|
|
|
ASSERT_SET_STATE (GST_ELEMENT (pipeline), GST_STATE_NULL,
|
|
|
|
GST_STATE_CHANGE_SUCCESS);
|
|
|
|
|
|
|
|
gst_object_unref (pipeline);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_END_TEST;
|
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
GST_START_TEST (test_ges_timeline_element_name)
|
|
|
|
{
|
2014-05-15 18:44:35 +00:00
|
|
|
GESClip *clip, *clip1, *clip2, *clip3, *clip4, *clip5;
|
2014-02-18 14:14:40 +00:00
|
|
|
GESAsset *asset;
|
|
|
|
GESTimeline *timeline;
|
|
|
|
GESLayer *layer;
|
|
|
|
|
|
|
|
ges_init ();
|
|
|
|
|
|
|
|
timeline = ges_timeline_new_audio_video ();
|
|
|
|
layer = ges_layer_new ();
|
|
|
|
fail_unless (ges_timeline_add_layer (timeline, layer));
|
|
|
|
|
|
|
|
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
|
|
|
|
clip = ges_layer_add_asset (layer, asset, 0, 0, 10, GES_TRACK_TYPE_UNKNOWN);
|
2014-05-14 20:06:55 +00:00
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip), "testclip0");
|
|
|
|
|
|
|
|
|
|
|
|
clip1 = GES_CLIP (ges_test_clip_new ());
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip1), "testclip1");
|
|
|
|
|
|
|
|
ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip1), "testclip1");
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip1), "testclip1");
|
|
|
|
|
|
|
|
/* Check that trying to set to a name that is already used leads to
|
|
|
|
* a change in the name */
|
|
|
|
ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip), "testclip1");
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip), "testclip2");
|
|
|
|
|
|
|
|
ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip1), "testclip4");
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip1), "testclip4");
|
|
|
|
|
|
|
|
clip2 = GES_CLIP (ges_test_clip_new ());
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip2), "testclip5");
|
|
|
|
ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip2), NULL);
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip2), "testclip6");
|
|
|
|
|
|
|
|
clip3 = GES_CLIP (ges_test_clip_new ());
|
2014-05-15 18:44:35 +00:00
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip3), "testclip7");
|
|
|
|
ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip3), "testclip5");
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip3), "testclip8");
|
|
|
|
|
|
|
|
clip4 = GES_CLIP (ges_test_clip_new ());
|
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip4), "testclip9");
|
|
|
|
|
|
|
|
|
|
|
|
clip5 = GES_CLIP (ges_test_clip_new ());
|
|
|
|
ges_timeline_element_set_name (GES_TIMELINE_ELEMENT (clip5),
|
2014-05-14 20:06:55 +00:00
|
|
|
"Something I want!");
|
2014-05-15 18:44:35 +00:00
|
|
|
fail_unless_equals_string (GES_TIMELINE_ELEMENT_NAME (clip5),
|
2014-05-14 20:06:55 +00:00
|
|
|
"Something I want!");
|
|
|
|
|
2014-02-18 14:14:40 +00:00
|
|
|
gst_object_unref (asset);
|
|
|
|
|
2014-05-14 20:06:55 +00:00
|
|
|
gst_object_unref (clip1);
|
|
|
|
gst_object_unref (clip2);
|
|
|
|
gst_object_unref (clip3);
|
2014-05-15 18:44:35 +00:00
|
|
|
gst_object_unref (clip4);
|
|
|
|
gst_object_unref (clip5);
|
2014-05-14 20:06:55 +00:00
|
|
|
gst_object_unref (timeline);
|
2014-02-18 14:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
2017-02-06 11:07:26 +00:00
|
|
|
if (atexit (ges_deinit) != 0) {
|
|
|
|
GST_ERROR ("failed to set ges_deinit as exit function");
|
|
|
|
}
|
|
|
|
|
2009-08-06 17:51:29 +00:00
|
|
|
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);
|
2013-07-01 14:27:54 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_pipeline_change_state);
|
2014-02-18 14:14:40 +00:00
|
|
|
tcase_add_test (tc_chain, test_ges_timeline_element_name);
|
2009-08-06 17:51:29 +00:00
|
|
|
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2013-05-28 02:10:03 +00:00
|
|
|
GST_CHECK_MAIN (ges);
|