1 /* GStreamer Editing Services
2 * Copyright (C) 2010 Edward Hervey <bilboed@bilboed.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #include "test-utils.h"
22 #include <gst/check/gstcheck.h>
24 #define LAYER_HEIGHT 1000
26 GST_START_TEST (test_layer_properties)
28 GESTimeline *timeline;
31 GESTrackElement *trackelement;
36 /* Timeline and 1 Layer */
37 timeline = ges_timeline_new ();
38 layer = (GESLayer *) ges_layer_new ();
40 /* The default priority is 0 */
41 fail_unless_equals_int (ges_layer_get_priority (layer), 0);
43 /* Layers are initially floating, once we add them to the timeline,
44 * the timeline will take that reference. */
45 fail_unless (g_object_is_floating (layer));
46 fail_unless (ges_timeline_add_layer (timeline, layer));
47 fail_if (g_object_is_floating (layer));
49 track = GES_TRACK (ges_video_track_new ());
50 fail_unless (track != NULL);
51 fail_unless (ges_timeline_add_track (timeline, track));
53 clip = (GESClip *) ges_test_clip_new ();
54 fail_unless (clip != NULL);
56 /* Set some properties */
57 g_object_set (clip, "start", (guint64) 42, "duration", (guint64) 51,
58 "in-point", (guint64) 12, NULL);
59 assert_equals_uint64 (_START (clip), 42);
60 assert_equals_uint64 (_DURATION (clip), 51);
61 assert_equals_uint64 (_INPOINT (clip), 12);
62 assert_equals_uint64 (_PRIORITY (clip), 0);
64 /* Add the clip to the timeline */
65 fail_unless (g_object_is_floating (clip));
66 fail_unless (ges_layer_add_clip (layer, GES_CLIP (clip)));
67 fail_if (g_object_is_floating (clip));
68 trackelement = ges_clip_find_track_element (clip, track, G_TYPE_NONE);
69 fail_unless (trackelement != NULL);
71 /* This is not a SimpleLayer, therefore the properties shouldn't have changed */
72 assert_equals_uint64 (_START (clip), 42);
73 assert_equals_uint64 (_DURATION (clip), 51);
74 assert_equals_uint64 (_INPOINT (clip), 12);
75 assert_equals_uint64 (_PRIORITY (clip), 1);
76 ges_timeline_commit (timeline);
77 nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12,
78 51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT, TRUE);
80 /* Change the priority of the layer */
81 g_object_set (layer, "priority", 1, NULL);
82 assert_equals_int (ges_layer_get_priority (layer), 1);
83 assert_equals_uint64 (_PRIORITY (clip), 1);
84 ges_timeline_commit (timeline);
85 nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12,
86 51, LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT, TRUE);
88 /* Change it to an insanely high value */
89 g_object_set (layer, "priority", 31, NULL);
90 assert_equals_int (ges_layer_get_priority (layer), 31);
91 assert_equals_uint64 (_PRIORITY (clip), 1);
92 ges_timeline_commit (timeline);
93 nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12,
94 51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT + LAYER_HEIGHT * 31, TRUE);
97 g_object_set (layer, "priority", 0, NULL);
98 assert_equals_int (ges_layer_get_priority (layer), 0);
99 assert_equals_uint64 (_PRIORITY (clip), 1);
100 ges_timeline_commit (timeline);
101 nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12,
102 51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 0, TRUE);
104 gst_object_unref (trackelement);
105 fail_unless (ges_layer_remove_clip (layer, clip));
106 fail_unless (ges_timeline_remove_track (timeline, track));
107 fail_unless (ges_timeline_remove_layer (timeline, layer));
108 gst_object_unref (timeline);
113 GST_START_TEST (test_layer_priorities)
116 GESTimeline *timeline;
117 GESLayer *layer1, *layer2, *layer3;
118 GESTrackElement *trackelement1, *trackelement2, *trackelement3;
119 GESClip *clip1, *clip2, *clip3;
120 GstElement *nleobj1, *nleobj2, *nleobj3;
121 guint prio1, prio2, prio3;
126 /* Timeline and 3 Layer */
127 timeline = ges_timeline_new ();
128 layer1 = (GESLayer *) ges_layer_new ();
129 layer2 = (GESLayer *) ges_layer_new ();
130 layer3 = (GESLayer *) ges_layer_new ();
132 ges_layer_set_priority (layer2, 1);
133 ges_layer_set_priority (layer3, 2);
135 fail_unless (ges_timeline_add_layer (timeline, layer1));
136 fail_unless (ges_timeline_add_layer (timeline, layer2));
137 fail_unless (ges_timeline_add_layer (timeline, layer3));
138 fail_unless_equals_int (ges_layer_get_priority (layer1), 0);
139 fail_unless_equals_int (ges_layer_get_priority (layer2), 1);
140 fail_unless_equals_int (ges_layer_get_priority (layer3), 2);
142 track = GES_TRACK (ges_video_track_new ());
143 fail_unless (track != NULL);
144 fail_unless (ges_timeline_add_track (timeline, track));
146 clip1 = GES_CLIP (ges_test_clip_new ());
147 clip2 = GES_CLIP (ges_test_clip_new ());
148 clip3 = GES_CLIP (ges_test_clip_new ());
149 fail_unless (clip1 != NULL);
150 fail_unless (clip2 != NULL);
151 fail_unless (clip3 != NULL);
153 g_object_set (clip1, "start", 0, "duration", 10, NULL);
154 g_object_set (clip2, "start", 10, "duration", 10, NULL);
155 g_object_set (clip3, "start", 20, "duration", 10, NULL);
157 /* Add objects to the timeline */
158 fail_unless (ges_layer_add_clip (layer1, clip1));
159 trackelement1 = ges_clip_find_track_element (clip1, track, G_TYPE_NONE);
160 fail_unless (trackelement1 != NULL);
162 fail_unless (ges_layer_add_clip (layer2, clip2));
163 trackelement2 = ges_clip_find_track_element (clip2, track, G_TYPE_NONE);
164 fail_unless (trackelement2 != NULL);
166 fail_unless (ges_layer_add_clip (layer3, clip3));
167 trackelement3 = ges_clip_find_track_element (clip3, track, G_TYPE_NONE);
168 fail_unless (trackelement3 != NULL);
170 ges_timeline_commit (timeline);
171 assert_equals_int (_PRIORITY (clip1), 1);
172 nleobj1 = ges_track_element_get_nleobject (trackelement1);
173 fail_unless (nleobj1 != NULL);
174 g_object_get (nleobj1, "priority", &prio1, NULL);
175 assert_equals_int (prio1, MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
177 assert_equals_int (_PRIORITY (clip2), 1);
178 nleobj2 = ges_track_element_get_nleobject (trackelement2);
179 fail_unless (nleobj2 != NULL);
180 g_object_get (nleobj2, "priority", &prio2, NULL);
181 /* clip2 is on the second layer and has a priority of 1 */
182 assert_equals_int (prio2, MIN_NLE_PRIO + LAYER_HEIGHT + 1);
184 /* We do not take into account users set priorities */
185 assert_equals_int (_PRIORITY (clip3), 1);
187 nleobj3 = ges_track_element_get_nleobject (trackelement3);
188 fail_unless (nleobj3 != NULL);
190 /* clip3 is on the third layer and has a priority of LAYER_HEIGHT + 1
191 * it priority must have the maximum priority of this layer*/
192 g_object_get (nleobj3, "priority", &prio3, NULL);
193 assert_equals_int (prio3, 1 + MIN_NLE_PRIO + LAYER_HEIGHT * 2);
195 /* Move layers around */
196 g_object_set (layer1, "priority", 2, NULL);
197 g_object_set (layer2, "priority", 0, NULL);
198 g_object_set (layer3, "priority", 1, NULL);
199 ges_timeline_commit (timeline);
201 /* And check the new priorities */
202 assert_equals_int (ges_layer_get_priority (layer1), 2);
203 assert_equals_int (ges_layer_get_priority (layer2), 0);
204 assert_equals_int (ges_layer_get_priority (layer3), 1);
205 assert_equals_int (_PRIORITY (clip1), 1);
206 assert_equals_int (_PRIORITY (clip2), 1);
207 assert_equals_int (_PRIORITY (clip3), 1);
208 g_object_get (nleobj1, "priority", &prio1, NULL);
209 g_object_get (nleobj2, "priority", &prio2, NULL);
210 g_object_get (nleobj3, "priority", &prio3, NULL);
211 assert_equals_int (prio1,
212 2 * LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
213 assert_equals_int (prio2, MIN_NLE_PRIO + 1);
214 assert_equals_int (prio3, LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
216 /* And move objects around */
217 fail_unless (ges_clip_move_to_layer (clip2, layer1));
218 fail_unless (ges_clip_move_to_layer (clip3, layer1));
219 ges_timeline_commit (timeline);
221 objs = ges_layer_get_clips (layer1);
222 assert_equals_int (g_list_length (objs), 3);
223 fail_unless (ges_layer_get_clips (layer2) == NULL);
224 fail_unless (ges_layer_get_clips (layer3) == NULL);
225 g_list_free_full (objs, gst_object_unref);
227 /* Check their priorities (layer1 priority is now 2) */
228 assert_equals_int (_PRIORITY (clip1), 1);
229 assert_equals_int (_PRIORITY (clip2), 2);
230 assert_equals_int (_PRIORITY (clip3), 3);
231 g_object_get (nleobj1, "priority", &prio1, NULL);
232 g_object_get (nleobj2, "priority", &prio2, NULL);
233 g_object_get (nleobj3, "priority", &prio3, NULL);
234 assert_equals_int (prio1,
235 2 * LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
236 assert_equals_int (prio2,
237 2 * LAYER_HEIGHT + 1 + MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
238 assert_equals_int (prio3,
239 2 * LAYER_HEIGHT + 2 + MIN_NLE_PRIO + TRANSITIONS_HEIGHT);
241 gst_object_unref (trackelement1);
242 gst_object_unref (trackelement2);
243 gst_object_unref (trackelement3);
244 gst_object_unref (timeline);
249 GST_START_TEST (test_timeline_auto_transition)
252 GESTimeline *timeline;
253 GESLayer *layer, *layer1, *layer2;
257 asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
258 fail_unless (GES_IS_ASSET (asset));
260 GST_DEBUG ("Create timeline");
261 timeline = ges_timeline_new_audio_video ();
262 assert_is_type (timeline, GES_TYPE_TIMELINE);
264 GST_DEBUG ("Create layers");
265 layer = ges_layer_new ();
266 assert_is_type (layer, GES_TYPE_LAYER);
267 layer1 = ges_layer_new ();
268 assert_is_type (layer, GES_TYPE_LAYER);
269 layer2 = ges_layer_new ();
270 assert_is_type (layer, GES_TYPE_LAYER);
272 GST_DEBUG ("Set auto-transition to the layers");
273 ges_layer_set_auto_transition (layer, TRUE);
274 ges_layer_set_auto_transition (layer1, TRUE);
275 ges_layer_set_auto_transition (layer2, TRUE);
277 GST_DEBUG ("Add layers to the timeline");
278 ges_timeline_add_layer (timeline, layer);
279 ges_timeline_add_layer (timeline, layer1);
280 ges_timeline_add_layer (timeline, layer2);
282 GST_DEBUG ("Check that auto-transition was properly set to the layers");
283 fail_unless (ges_layer_get_auto_transition (layer));
284 fail_unless (ges_layer_get_auto_transition (layer1));
285 fail_unless (ges_layer_get_auto_transition (layer2));
287 GST_DEBUG ("Set timeline auto-transition property to FALSE");
288 ges_timeline_set_auto_transition (timeline, FALSE);
291 ("Check that layers auto-transition has the same value as timeline");
292 fail_if (ges_layer_get_auto_transition (layer));
293 fail_if (ges_layer_get_auto_transition (layer1));
294 fail_if (ges_layer_get_auto_transition (layer2));
296 GST_DEBUG ("Set timeline auto-transition property to TRUE");
297 ges_timeline_set_auto_transition (timeline, TRUE);
300 ("Check that layers auto-transition has the same value as timeline");
301 fail_unless (ges_layer_get_auto_transition (layer));
302 fail_unless (ges_layer_get_auto_transition (layer1));
303 fail_unless (ges_layer_get_auto_transition (layer2));
305 gst_object_unref (timeline);
310 GST_START_TEST (test_single_layer_automatic_transition)
313 GESTimeline *timeline;
314 GList *objects, *current;
317 GESTimelineElement *src, *src1, *src2;
321 asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
322 fail_unless (GES_IS_ASSET (asset));
324 GST_DEBUG ("Create timeline");
325 timeline = ges_timeline_new_audio_video ();
326 assert_is_type (timeline, GES_TYPE_TIMELINE);
328 GST_DEBUG ("Create first layer");
329 layer = ges_layer_new ();
330 assert_is_type (layer, GES_TYPE_LAYER);
332 GST_DEBUG ("Add first layer to timeline");
333 fail_unless (ges_timeline_add_layer (timeline, layer));
335 GST_DEBUG ("Set auto transition to first layer");
336 ges_layer_set_auto_transition (layer, TRUE);
338 GST_DEBUG ("Check that auto-transition was properly set");
339 fail_unless (ges_layer_get_auto_transition (layer));
341 GST_DEBUG ("Adding assets to first layer");
342 GST_DEBUG ("Adding clip from 0 -- 1000 to first layer");
343 src = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 0, 0,
344 1000, GES_TRACK_TYPE_UNKNOWN));
345 fail_unless (GES_IS_CLIP (src));
347 GST_DEBUG ("Adding clip from 500 -- 1000 to first layer");
348 src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500,
349 0, 1000, GES_TRACK_TYPE_UNKNOWN));
350 fail_unless (GES_IS_CLIP (src1));
353 * 500__transition__1000
354 * 0___________src_________1000
355 * 500___________src1_________1500
357 GST_DEBUG ("Checking src timing values");
358 assert_equals_uint64 (_START (src), 0);
359 assert_equals_uint64 (_DURATION (src), 1000);
360 assert_equals_uint64 (_START (src1), 500);
361 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
362 ges_timeline_commit (timeline);
364 GST_DEBUG ("Checking that a transition has been added");
365 objects = ges_layer_get_clips (layer);
366 assert_equals_int (g_list_length (objects), 4);
367 assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
369 transition = objects->next->data;
370 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
371 assert_equals_uint64 (_START (transition), 500);
372 assert_equals_uint64 (_DURATION (transition), 500);
374 transition = objects->next->next->data;
375 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
376 assert_equals_uint64 (_START (transition), 500);
377 assert_equals_uint64 (_DURATION (transition), 500);
378 g_list_free_full (objects, gst_object_unref);
379 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
381 GST_DEBUG ("Moving first source to 250");
382 ges_timeline_element_set_start (src, 250);
385 * 500_____transition____1250
386 * 250___________src_________1250
387 * 500___________src1_________1500
389 GST_DEBUG ("Checking src timing values");
390 assert_equals_uint64 (_START (src), 250);
391 assert_equals_uint64 (_DURATION (src), 1250 - 250);
392 assert_equals_uint64 (_START (src1), 500);
393 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
395 objects = ges_layer_get_clips (layer);
396 assert_equals_int (g_list_length (objects), 4);
397 assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
399 transition = objects->next->data;
400 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
401 assert_equals_uint64 (_START (transition), 500);
402 assert_equals_uint64 (_DURATION (transition), 750);
404 transition = objects->next->next->data;
405 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
406 assert_equals_int (_START (transition), 500);
407 assert_equals_uint64 (_DURATION (transition), 750);
408 g_list_free_full (objects, gst_object_unref);
410 GST_DEBUG ("Moving second source to 250, the transitions should be removed");
411 ges_timeline_element_set_start (src1, 250);
413 /* The transition should be removed
414 * 250___________src_________1250
415 * 250___________src1________1250
417 GST_DEBUG ("Checking src timing values");
418 assert_equals_uint64 (_START (src), 250);
419 assert_equals_uint64 (_DURATION (src), 1250 - 250);
420 assert_equals_uint64 (_START (src1), 250);
421 assert_equals_uint64 (_DURATION (src1), 1250 - 250);
423 objects = ges_layer_get_clips (layer);
424 assert_equals_int (g_list_length (objects), 2);
425 g_list_free_full (objects, gst_object_unref);
427 GST_DEBUG ("Trimming second source to 500 no transition should be created "
428 "as they have the same end");
429 ges_container_edit (GES_CONTAINER (src1), NULL, -1,
430 GES_EDIT_MODE_TRIM, GES_EDGE_START, 500);
432 /* 250___________src_________1250
433 * 500______src1_______1250
435 GST_DEBUG ("Checking src timing values");
436 assert_equals_uint64 (_START (src), 250);
437 assert_equals_uint64 (_DURATION (src), 1250 - 250);
438 assert_equals_uint64 (_START (src1), 500);
439 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
441 objects = ges_layer_get_clips (layer);
442 assert_equals_int (g_list_length (objects), 2);
443 g_list_free_full (objects, gst_object_unref);
445 GST_DEBUG ("Trimming second source to 500, no transition should be created");
446 ges_timeline_element_trim (src, 500);
448 /* 500___________src_________1250
449 * 500___________src1________1250
451 GST_DEBUG ("Checking src timing values");
452 assert_equals_uint64 (_START (src), 500);
453 assert_equals_uint64 (_DURATION (src), 1250 - 500);
454 assert_equals_uint64 (_START (src1), 500);
455 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
457 GST_DEBUG ("Trimming first source to 750, no transition should be created");
458 ges_timeline_element_trim (src, 750);
460 /* 750_______src_______1250
461 * 500___________src1________1250
463 GST_DEBUG ("Checking src timing values");
464 assert_equals_uint64 (_START (src), 750);
465 assert_equals_uint64 (_DURATION (src), 1250 - 750);
466 assert_equals_uint64 (_START (src1), 500);
467 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
469 objects = ges_layer_get_clips (layer);
470 assert_equals_int (g_list_length (objects), 2);
471 g_list_free_full (objects, gst_object_unref);
473 objects = ges_layer_get_clips (layer);
474 assert_equals_int (g_list_length (objects), 2);
475 g_list_free_full (objects, gst_object_unref);
477 GST_DEBUG ("Moving first source to 500, no transition should be created");
478 ges_timeline_element_set_start (src, 500);
480 /* 500________src______1000
481 * 500___________src1________1250
483 GST_DEBUG ("Checking src timing values");
484 assert_equals_uint64 (_START (src), 500);
485 assert_equals_uint64 (_DURATION (src), 1000 - 500);
486 assert_equals_uint64 (_START (src1), 500);
487 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
489 objects = ges_layer_get_clips (layer);
490 assert_equals_int (g_list_length (objects), 2);
491 g_list_free_full (objects, gst_object_unref);
493 objects = ges_layer_get_clips (layer);
494 assert_equals_int (g_list_length (objects), 2);
495 g_list_free_full (objects, gst_object_unref);
497 GST_DEBUG ("Moving first source to 600, no transition should be created");
498 ges_timeline_element_set_start (src, 600);
500 * 500___________src1________1250
502 GST_DEBUG ("Checking src timing values");
503 assert_equals_uint64 (_START (src), 600);
504 assert_equals_uint64 (_DURATION (src), 1100 - 600);
505 assert_equals_uint64 (_START (src1), 500);
506 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
508 objects = ges_layer_get_clips (layer);
509 assert_equals_int (g_list_length (objects), 2);
510 g_list_free_full (objects, gst_object_unref);
512 objects = ges_layer_get_clips (layer);
513 assert_equals_int (g_list_length (objects), 2);
514 g_list_free_full (objects, gst_object_unref);
516 GST_DEBUG ("Adding asset to first layer");
517 GST_DEBUG ("Adding clip from 1250 -- 1000 to first layer");
519 GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 1250, 0,
520 1000, GES_TRACK_TYPE_UNKNOWN));
521 assert_is_type (src2, GES_TYPE_TEST_CLIP);
524 * 500___________src1________1250
525 * 1250___________src2________2250
527 assert_equals_uint64 (_START (src), 600);
528 assert_equals_uint64 (_DURATION (src), 1100 - 600);
529 assert_equals_uint64 (_START (src1), 500);
530 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
531 assert_equals_uint64 (_START (src2), 1250);
532 assert_equals_uint64 (_DURATION (src2), 1000);
534 objects = ges_layer_get_clips (layer);
535 assert_equals_int (g_list_length (objects), 3);
536 g_list_free_full (objects, gst_object_unref);
539 ("Changig first source duration to 800 2 transitions should be created");
540 ges_timeline_element_set_duration (src, 800);
541 ges_timeline_commit (timeline);
542 /* 600__________________src_____________1400
543 * 500___________src1________1250
544 * 1250___________src2________2250
545 * 600_____trans1_______1250
546 * 1250___trans2___1400
548 GST_DEBUG ("Checking src timing values");
549 assert_equals_uint64 (_START (src), 600);
550 assert_equals_uint64 (_DURATION (src), 1400 - 600);
551 assert_equals_uint64 (_START (src1), 500);
552 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
554 current = objects = ges_layer_get_clips (layer);
555 assert_equals_int (g_list_length (objects), 7);
556 assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
557 fail_unless (objects->data == src1);
559 current = current->next;
560 transition = current->data;
561 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
562 assert_equals_uint64 (_START (transition), 600);
563 assert_equals_uint64 (_DURATION (transition), 1250 - 600);
564 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline + ourself", 3);
566 current = current->next;
567 transition = current->data;
568 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
569 assert_equals_uint64 (_START (transition), 600);
570 assert_equals_uint64 (_DURATION (transition), 1250 - 600);
571 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline + ourself", 3);
573 current = current->next;
574 fail_unless (current->data == src);
576 current = current->next;
577 transition = current->data;
578 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
579 assert_equals_uint64 (_START (transition), 1250);
580 assert_equals_uint64 (_DURATION (transition), 1400 - 1250);
581 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline + ourself", 3);
583 current = current->next;
584 transition = current->data;
585 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
586 assert_equals_uint64 (_START (transition), 1250);
587 assert_equals_uint64 (_DURATION (transition), 1400 - 1250);
588 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline + ourself", 3);
590 current = current->next;
591 fail_unless (current->data == src2);
592 g_list_free_full (objects, gst_object_unref);
594 GST_DEBUG ("Back to previous state");
595 /* Make sure to keep 1 ref so we can check_destroyed afterward */
596 gst_object_ref (transition);
597 ges_timeline_element_set_duration (src, 1100 - 600);
599 * 500___________src1________1250
600 * 1250___________src2________2250
602 assert_equals_uint64 (_START (src), 600);
603 assert_equals_uint64 (_DURATION (src), 1100 - 600);
604 assert_equals_uint64 (_START (src1), 500);
605 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
606 assert_equals_uint64 (_START (src2), 1250);
607 assert_equals_uint64 (_DURATION (src2), 1000);
609 /* We check that the transition as actually been freed */
610 check_destroyed (G_OBJECT (transition), NULL, NULL);
612 objects = ges_layer_get_clips (layer);
613 assert_equals_int (g_list_length (objects), 3);
614 g_list_free_full (objects, gst_object_unref);
617 ("Set third clip start to 1100, 1 new transition should be created");
618 ges_timeline_element_set_start (src2, 1100);
619 ges_timeline_commit (timeline);
621 * 500___________src1________1250
622 * 1100___________src2________2100
625 assert_equals_uint64 (_START (src), 600);
626 assert_equals_uint64 (_DURATION (src), 1100 - 600);
627 assert_equals_uint64 (_START (src1), 500);
628 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
629 assert_equals_uint64 (_START (src2), 1100);
630 assert_equals_uint64 (_DURATION (src2), 1000);
632 current = objects = ges_layer_get_clips (layer);
633 assert_equals_int (g_list_length (objects), 5);
634 assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
635 fail_unless (current->data == src1);
637 current = current->next;
638 fail_unless (current->data == src);
640 current = current->next;
641 transition = current->data;
642 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
643 assert_equals_uint64 (_START (transition), 1100);
644 assert_equals_uint64 (_DURATION (transition), 1250 - 1100);
646 current = current->next;
647 transition = current->data;
648 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
649 assert_equals_uint64 (_START (transition), 1100);
650 assert_equals_uint64 (_DURATION (transition), 1250 - 1100);
652 current = current->next;
653 fail_unless (current->data == src2);
654 g_list_free_full (objects, gst_object_unref);
656 GST_DEBUG ("Check that we can not create 2 transitions at the same place");
657 fail_if (ges_container_edit (GES_CONTAINER (src2), NULL, -1,
658 GES_EDIT_MODE_NORMAL, GES_EDGE_START, 1000));
661 * 500___________src1________1250
662 * 1000___________src2________2000
665 ges_layer_remove_clip (layer, GES_CLIP (src));
666 fail_unless (ges_container_edit (GES_CONTAINER (src2), NULL, -1,
667 GES_EDIT_MODE_NORMAL, GES_EDGE_START, 1000));
668 assert_equals_uint64 (_START (src1), 500);
669 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
670 assert_equals_uint64 (_START (src2), 1000);
671 assert_equals_uint64 (_DURATION (src2), 1000);
673 current = objects = ges_layer_get_clips (layer);
675 assert_equals_int (g_list_length (objects), 4);
676 assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
677 transition = objects->next->data;
678 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
679 fail_unless (current->data == src1);
680 g_list_free_full (objects, gst_object_unref);
683 * 500___________src1________1250
685 * 1100___________src2________2000
687 ges_container_edit (GES_CONTAINER (transition),
688 NULL, -1, GES_EDIT_MODE_TRIM, GES_EDGE_START, 1100);
689 assert_equals_uint64 (_START (src1), 500);
690 assert_equals_uint64 (_DURATION (src1), 1250 - 500);
691 assert_equals_uint64 (_START (src2), 1100);
692 assert_equals_uint64 (_DURATION (src2), 2000 - 1100);
694 current = objects = ges_layer_get_clips (layer);
696 assert_equals_int (g_list_length (objects), 4);
697 assert_is_type (objects->data, GES_TYPE_TEST_CLIP);
698 fail_unless (current->data == src1);
699 g_list_free_full (objects, gst_object_unref);
701 gst_object_unref (timeline);
706 GST_START_TEST (test_multi_layer_automatic_transition)
709 GESTimeline *timeline;
710 GList *objects, *current;
712 GESLayer *layer, *layer1;
713 GESTimelineElement *src, *src1, *src2, *src3;
717 asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
718 fail_unless (GES_IS_ASSET (asset));
720 GST_DEBUG ("Create timeline");
721 timeline = ges_timeline_new_audio_video ();
722 assert_is_type (timeline, GES_TYPE_TIMELINE);
724 GST_DEBUG ("Create first layer");
725 layer = ges_layer_new ();
726 assert_is_type (layer, GES_TYPE_LAYER);
728 GST_DEBUG ("Add first layer to timeline");
729 fail_unless (ges_timeline_add_layer (timeline, layer));
731 GST_DEBUG ("Append a new layer to the timeline");
732 layer1 = ges_timeline_append_layer (timeline);
733 assert_is_type (layer1, GES_TYPE_LAYER);
735 GST_DEBUG ("Set auto transition to first layer");
736 ges_layer_set_auto_transition (layer, TRUE);
738 GST_DEBUG ("Check that auto-transition was properly set");
739 fail_unless (ges_layer_get_auto_transition (layer));
740 fail_if (ges_layer_get_auto_transition (layer1));
742 GST_DEBUG ("Adding assets to first layer");
743 GST_DEBUG ("Adding clip from 0 -- 1000 to first layer");
744 src = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 0, 0,
745 1000, GES_TRACK_TYPE_UNKNOWN));
746 fail_unless (GES_IS_CLIP (src));
748 GST_DEBUG ("Adding clip from 500 -- 1000 to first layer");
749 src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500,
750 0, 1000, GES_TRACK_TYPE_UNKNOWN));
751 ges_timeline_commit (timeline);
752 fail_unless (GES_IS_CLIP (src1));
755 * 500__transition__1000
756 * 0___________src_________1000
757 * 500___________src1_________1500
759 GST_DEBUG ("Checking src timing values");
760 assert_equals_uint64 (_START (src), 0);
761 assert_equals_uint64 (_DURATION (src), 1000);
762 assert_equals_uint64 (_START (src1), 500);
763 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
765 GST_DEBUG ("Checking that a transition has been added");
766 current = objects = ges_layer_get_clips (layer);
767 assert_equals_int (g_list_length (objects), 4);
768 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
770 current = current->next;
771 transition = current->data;
772 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
773 assert_equals_uint64 (_START (transition), 500);
774 assert_equals_uint64 (_DURATION (transition), 500);
776 current = current->next;
777 transition = current->data;
778 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
779 assert_equals_uint64 (_START (transition), 500);
780 assert_equals_uint64 (_DURATION (transition), 500);
781 g_list_free_full (objects, gst_object_unref);
782 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
784 GST_DEBUG ("Adding clip 2 from 500 -- 1000 to second layer");
785 src2 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer1, asset, 0,
786 0, 1000, GES_TRACK_TYPE_UNKNOWN));
787 GST_DEBUG ("Adding clip 3 from 500 -- 1000 to second layer");
788 src3 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer1, asset, 500,
789 0, 1000, GES_TRACK_TYPE_UNKNOWN));
790 assert_is_type (src3, GES_TYPE_TEST_CLIP);
792 /* 500__transition__1000
793 * 0___________src_________1000
794 * 500___________src1_________1500
795 *----------------------------------------------------
796 * 0___________src2_________1000
797 * 500___________src3_________1500 Layer1
799 GST_DEBUG ("Checking src timing values");
800 assert_equals_uint64 (_START (src), 0);
801 assert_equals_uint64 (_DURATION (src), 1000);
802 assert_equals_uint64 (_START (src1), 500);
803 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
804 assert_equals_uint64 (_START (src2), 0);
805 assert_equals_uint64 (_DURATION (src2), 1000);
806 assert_equals_uint64 (_START (src3), 500);
807 assert_equals_uint64 (_DURATION (src3), 1500 - 500);
809 GST_DEBUG ("Checking transitions on first layer");
810 current = objects = ges_layer_get_clips (layer);
811 assert_equals_int (g_list_length (objects), 4);
812 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
814 current = current->next;
815 transition = current->data;
816 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
817 assert_equals_uint64 (_START (transition), 500);
818 assert_equals_uint64 (_DURATION (transition), 500);
820 current = current->next;
821 transition = current->data;
822 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
823 assert_equals_uint64 (_START (transition), 500);
824 assert_equals_uint64 (_DURATION (transition), 500);
825 g_list_free_full (objects, gst_object_unref);
826 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
828 GST_DEBUG ("Checking transitions on second layer");
829 current = objects = ges_layer_get_clips (layer1);
830 assert_equals_int (g_list_length (objects), 2);
831 fail_unless (current->data == src2);
832 fail_unless (current->next->data == src3);
833 g_list_free_full (objects, gst_object_unref);
836 ("Set auto transition to second layer, a new transition should be added");
837 ges_layer_set_auto_transition (layer1, TRUE);
839 /* 500__transition__1000
840 * 0___________src_________1000
841 * 500___________src1_________1500
842 *----------------------------------------------------
843 * 500__transition__1000
844 * 0__________src2_________1000
845 * 500___________src3_________1500 Layer1
847 GST_DEBUG ("Checking src timing values");
848 assert_equals_uint64 (_START (src), 0);
849 assert_equals_uint64 (_DURATION (src), 1000);
850 assert_equals_uint64 (_START (src1), 500);
851 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
852 assert_equals_uint64 (_START (src2), 0);
853 assert_equals_uint64 (_DURATION (src2), 1000);
854 assert_equals_uint64 (_START (src3), 500);
855 assert_equals_uint64 (_DURATION (src3), 1500 - 500);
857 GST_DEBUG ("Checking transitions on first layer");
858 current = objects = ges_layer_get_clips (layer);
859 assert_equals_int (g_list_length (objects), 4);
860 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
862 current = current->next;
863 transition = current->data;
864 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
865 assert_equals_uint64 (_START (transition), 500);
866 assert_equals_uint64 (_DURATION (transition), 500);
868 current = current->next;
869 transition = current->data;
870 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
871 assert_equals_uint64 (_START (transition), 500);
872 assert_equals_uint64 (_DURATION (transition), 500);
873 g_list_free_full (objects, gst_object_unref);
874 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
876 GST_DEBUG ("Checking transitions has been added on second layer");
877 current = objects = ges_layer_get_clips (layer1);
878 assert_equals_int (g_list_length (objects), 4);
879 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
881 current = current->next;
882 transition = current->data;
883 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
884 assert_equals_uint64 (_START (transition), 500);
885 assert_equals_uint64 (_DURATION (transition), 500);
887 current = current->next;
888 transition = current->data;
889 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
890 assert_equals_uint64 (_START (transition), 500);
891 assert_equals_uint64 (_DURATION (transition), 500);
892 g_list_free_full (objects, gst_object_unref);
893 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
895 GST_DEBUG ("Moving src3 to 1000. should remove transition");
896 ges_timeline_element_set_start (src3, 1000);
898 /* 500__transition__1000
899 * 0___________src_________1000
900 * 500___________src1_________1500 Layer
901 *----------------------------------------------------
902 * 0__________src2_________1000
903 * 1000___________src3_________2000 Layer1
905 GST_DEBUG ("Checking src timing values");
906 assert_equals_uint64 (_START (src), 0);
907 assert_equals_uint64 (_DURATION (src), 1000);
908 assert_equals_uint64 (_START (src1), 500);
909 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
910 assert_equals_uint64 (_START (src2), 0);
911 assert_equals_uint64 (_DURATION (src2), 1000);
912 assert_equals_uint64 (_START (src3), 1000);
913 assert_equals_uint64 (_DURATION (src3), 2000 - 1000);
915 GST_DEBUG ("Checking transitions on first layer");
916 current = objects = ges_layer_get_clips (layer);
917 assert_equals_int (g_list_length (objects), 4);
918 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
920 current = current->next;
921 transition = current->data;
922 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
923 assert_equals_uint64 (_START (transition), 500);
924 assert_equals_uint64 (_DURATION (transition), 500);
926 current = current->next;
927 transition = current->data;
928 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
929 assert_equals_uint64 (_START (transition), 500);
930 assert_equals_uint64 (_DURATION (transition), 500);
931 g_list_free_full (objects, gst_object_unref);
932 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
934 GST_DEBUG ("Checking transitions has been removed on second layer");
935 current = objects = ges_layer_get_clips (layer1);
936 assert_equals_int (g_list_length (objects), 2);
937 fail_unless (current->data == src2);
938 fail_unless (current->next->data == src3);
939 g_list_free_full (objects, gst_object_unref);
940 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
942 GST_DEBUG ("Moving src3 to first layer, should add a transition");
943 ges_clip_move_to_layer (GES_CLIP (src3), layer);
945 /* 500__transition__1000
946 * 0___________src_________1000
947 * 500___________src1_________1500
948 * 1000___________src3_________2000 Layer
950 *----------------------------------------------------
951 * 0__________src2_________1000 Layer1
953 GST_DEBUG ("Checking src timing values");
954 assert_equals_uint64 (_START (src), 0);
955 assert_equals_uint64 (_DURATION (src), 1000);
956 assert_equals_uint64 (_START (src1), 500);
957 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
958 assert_equals_uint64 (_START (src2), 0);
959 assert_equals_uint64 (_DURATION (src2), 1000);
960 assert_equals_uint64 (_START (src3), 1000);
961 assert_equals_uint64 (_DURATION (src3), 2000 - 1000);
963 GST_DEBUG ("Checking transitions on first layer");
964 current = objects = ges_layer_get_clips (layer);
965 assert_equals_int (g_list_length (objects), 7);
966 fail_unless (current->data == src);
968 current = current->next;
969 transition = current->data;
970 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
971 assert_equals_uint64 (_START (transition), 500);
972 assert_equals_uint64 (_DURATION (transition), 500);
974 current = current->next;
975 transition = current->data;
976 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
977 assert_equals_uint64 (_START (transition), 500);
978 assert_equals_uint64 (_DURATION (transition), 500);
980 current = current->next;
981 fail_unless (current->data == src1);
983 current = current->next;
984 transition = current->data;
985 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
986 assert_equals_uint64 (_START (transition), 1000);
987 assert_equals_uint64 (_DURATION (transition), 1500 - 1000);
989 current = current->next;
990 transition = current->data;
991 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
992 assert_equals_uint64 (_START (transition), 1000);
993 assert_equals_uint64 (_DURATION (transition), 1500 - 1000);
995 current = current->next;
996 fail_unless (current->data == src3);
998 g_list_free_full (objects, gst_object_unref);
999 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1001 GST_DEBUG ("Checking second layer");
1002 current = objects = ges_layer_get_clips (layer1);
1003 assert_equals_int (g_list_length (objects), 1);
1004 fail_unless (current->data == src2);
1005 g_list_free_full (objects, gst_object_unref);
1006 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1009 ("Moving src to second layer, should remove first transition on first layer");
1010 ges_clip_move_to_layer (GES_CLIP (src), layer1);
1012 /* 500___________src1_________1500
1013 * 1000___________src3_________2000 Layer
1015 *----------------------------------------------------
1016 * 0___________src_________1000
1017 * 0__________src2_________1000 Layer1
1019 GST_DEBUG ("Checking src timing values");
1020 assert_equals_uint64 (_START (src), 0);
1021 assert_equals_uint64 (_DURATION (src), 1000);
1022 assert_equals_uint64 (_START (src1), 500);
1023 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
1024 assert_equals_uint64 (_START (src2), 0);
1025 assert_equals_uint64 (_DURATION (src2), 1000);
1026 assert_equals_uint64 (_START (src3), 1000);
1027 assert_equals_uint64 (_DURATION (src3), 2000 - 1000);
1029 GST_DEBUG ("Checking transitions on first layer");
1030 current = objects = ges_layer_get_clips (layer);
1031 assert_equals_int (g_list_length (objects), 4);
1032 fail_unless (current->data == src1);
1034 current = current->next;
1035 transition = current->data;
1036 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1037 assert_equals_uint64 (_START (transition), 1000);
1038 assert_equals_uint64 (_DURATION (transition), 500);
1040 current = current->next;
1041 transition = current->data;
1042 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1043 assert_equals_uint64 (_START (transition), 1000);
1044 assert_equals_uint64 (_DURATION (transition), 500);
1046 current = current->next;
1047 fail_unless (current->data == src3);
1048 g_list_free_full (objects, gst_object_unref);
1049 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1051 GST_DEBUG ("Checking second layer");
1052 current = objects = ges_layer_get_clips (layer1);
1053 assert_equals_int (g_list_length (objects), 2);
1054 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1055 assert_is_type (current->next->data, GES_TYPE_TEST_CLIP);
1056 g_list_free_full (objects, gst_object_unref);
1057 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1059 GST_DEBUG ("Edit src to first layer start=1500");
1060 ges_container_edit (GES_CONTAINER (src), NULL, 0,
1061 GES_EDIT_MODE_NORMAL, GES_EDGE_NONE, 1500);
1062 /* 1500___________src_________2500
1063 * 1500______tr______2000
1064 * 500___________src1_________1500 ^
1065 * 1000_________^_src3_________2000 Layer
1067 *---------------------------------------------------------------------------
1068 * 0__________src2_________1000 Layer1
1070 GST_DEBUG ("Checking src timing values");
1071 assert_equals_uint64 (_START (src), 1500);
1072 assert_equals_uint64 (_DURATION (src), 1000);
1073 assert_equals_uint64 (_START (src1), 500);
1074 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
1075 assert_equals_uint64 (_START (src2), 0);
1076 assert_equals_uint64 (_DURATION (src2), 1000);
1077 assert_equals_uint64 (_START (src3), 1000);
1078 assert_equals_uint64 (_DURATION (src3), 2000 - 1000);
1080 GST_DEBUG ("Checking transitions on first layer");
1081 current = objects = ges_layer_get_clips (layer);
1082 assert_equals_int (g_list_length (objects), 7);
1083 fail_unless (current->data == src1);
1085 current = current->next;
1086 transition = current->data;
1087 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1088 assert_equals_uint64 (_START (transition), 1000);
1089 assert_equals_uint64 (_DURATION (transition), 500);
1091 current = current->next;
1092 transition = current->data;
1093 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1094 assert_equals_uint64 (_START (transition), 1000);
1095 assert_equals_uint64 (_DURATION (transition), 500);
1097 current = current->next;
1098 fail_unless (current->data == src3);
1100 current = current->next;
1101 transition = current->data;
1102 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1103 assert_equals_uint64 (_START (transition), 1500);
1104 assert_equals_uint64 (_DURATION (transition), 500);
1106 current = current->next;
1107 transition = current->data;
1108 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1109 assert_equals_uint64 (_START (transition), 1500);
1110 assert_equals_uint64 (_DURATION (transition), 500);
1112 current = current->next;
1113 fail_unless (current->data == src);
1114 g_list_free_full (objects, gst_object_unref);
1115 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1117 GST_DEBUG ("Checking second layer");
1118 current = objects = ges_layer_get_clips (layer1);
1119 assert_equals_int (g_list_length (objects), 1);
1120 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1121 g_list_free_full (objects, gst_object_unref);
1122 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1124 GST_DEBUG ("Ripple src1 to 700");
1125 ges_container_edit (GES_CONTAINER (src1), NULL, 0,
1126 GES_EDIT_MODE_RIPPLE, GES_EDGE_NONE, 700);
1128 /* 1700___________src_________2700
1130 * 700___________src1_________1700
1131 * 1200___________src3_________2200 Layer
1133 *---------------------------------------------------------------------------
1134 * 0__________src2_________1000 Layer1
1136 GST_DEBUG ("Checking src timing values");
1137 assert_equals_uint64 (_START (src), 1700);
1138 assert_equals_uint64 (_DURATION (src), 1000);
1139 assert_equals_uint64 (_START (src1), 700);
1140 assert_equals_uint64 (_DURATION (src1), 1700 - 700);
1141 assert_equals_uint64 (_START (src2), 0);
1142 assert_equals_uint64 (_DURATION (src2), 1000);
1143 assert_equals_uint64 (_START (src3), 1200);
1144 assert_equals_uint64 (_DURATION (src3), 2200 - 1200);
1146 GST_DEBUG ("Checking transitions on first layer");
1147 current = objects = ges_layer_get_clips (layer);
1148 assert_equals_int (g_list_length (objects), 7);
1149 fail_unless (current->data == src1);
1151 current = current->next;
1152 transition = current->data;
1153 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1154 assert_equals_uint64 (_START (transition), 1200);
1155 assert_equals_uint64 (_DURATION (transition), 1700 - 1200);
1157 current = current->next;
1158 transition = current->data;
1159 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1160 assert_equals_uint64 (_START (transition), 1200);
1161 assert_equals_uint64 (_DURATION (transition), 1700 - 1200);
1163 current = current->next;
1164 fail_unless (current->data == src3);
1166 current = current->next;
1167 transition = current->data;
1168 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1169 assert_equals_uint64 (_START (transition), 1700);
1170 assert_equals_uint64 (_DURATION (transition), 2200 - 1700);
1172 current = current->next;
1173 transition = current->data;
1174 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1175 assert_equals_uint64 (_START (transition), 1700);
1176 assert_equals_uint64 (_DURATION (transition), 2200 - 1700);
1178 current = current->next;
1179 fail_unless (current->data == src);
1180 g_list_free_full (objects, gst_object_unref);
1181 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1183 GST_DEBUG ("Checking second layer");
1184 current = objects = ges_layer_get_clips (layer1);
1185 assert_equals_int (g_list_length (objects), 1);
1186 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1187 g_list_free_full (objects, gst_object_unref);
1188 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1190 gst_object_unref (timeline);
1195 GST_START_TEST (test_layer_activate_automatic_transition)
1197 GESAsset *asset, *transition_asset;
1198 GESTimeline *timeline;
1200 GList *objects, *current;
1201 GESClip *transition;
1202 GESTimelineElement *src, *src1, *src2, *src3;
1206 asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL);
1208 ges_asset_request (GES_TYPE_TRANSITION_CLIP, "crossfade", NULL);
1209 fail_unless (GES_IS_ASSET (asset));
1211 GST_DEBUG ("Create timeline");
1212 timeline = ges_timeline_new_audio_video ();
1213 assert_is_type (timeline, GES_TYPE_TIMELINE);
1215 GST_DEBUG ("Append a layer to the timeline");
1216 layer = ges_timeline_append_layer (timeline);
1217 assert_is_type (layer, GES_TYPE_LAYER);
1219 GST_DEBUG ("Adding clip from 0 -- 1000 to layer");
1220 src = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 0, 0,
1221 1000, GES_TRACK_TYPE_UNKNOWN));
1222 fail_unless (GES_IS_CLIP (src));
1224 GST_DEBUG ("Adding clip from 500 -- 1000 to first layer");
1225 src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500,
1226 0, 1000, GES_TRACK_TYPE_UNKNOWN));
1227 fail_unless (GES_IS_CLIP (src1));
1229 GST_DEBUG ("Adding clip from 1000 -- 2000 to layer");
1230 src2 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 1000,
1231 0, 1000, GES_TRACK_TYPE_UNKNOWN));
1232 fail_unless (GES_IS_CLIP (src2));
1234 GST_DEBUG ("Adding clip from 2000 -- 2500 to layer");
1235 src3 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 2000,
1236 0, 500, GES_TRACK_TYPE_UNKNOWN));
1237 fail_unless (GES_IS_CLIP (src3));
1240 * 0___________src_________1000
1241 * 500___________src1_________1500
1242 * 1000____src2_______2000
1243 * 2000_______src2_____2500
1245 GST_DEBUG ("Checking src timing values");
1246 assert_equals_uint64 (_START (src), 0);
1247 assert_equals_uint64 (_DURATION (src), 1000);
1248 assert_equals_uint64 (_START (src1), 500);
1249 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
1250 assert_equals_uint64 (_START (src2), 1000);
1251 assert_equals_uint64 (_DURATION (src2), 1000);
1252 assert_equals_uint64 (_START (src3), 2000);
1253 assert_equals_uint64 (_DURATION (src3), 500);
1255 GST_DEBUG ("Checking that no transition has been added");
1256 current = objects = ges_layer_get_clips (layer);
1257 assert_equals_int (g_list_length (objects), 4);
1258 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1259 g_list_free_full (objects, gst_object_unref);
1261 GST_DEBUG ("Adding transition from 1000 -- 1500 to layer");
1263 GES_CLIP (ges_layer_add_asset (layer,
1264 transition_asset, 1000, 0, 500, GES_TRACK_TYPE_VIDEO));
1265 fail_unless (GES_IS_TRANSITION_CLIP (transition));
1266 objects = GES_CONTAINER_CHILDREN (transition);
1267 assert_equals_int (g_list_length (objects), 1);
1269 GST_DEBUG ("Checking the transitions");
1271 * 0___________src_________1000
1272 * 500___________src1_________1500
1273 * 1000__tr__1500 (1 of the 2 tracks only)
1274 * 1000____src2_______2000
1275 * 2000_______src3_____2500
1277 current = objects = ges_layer_get_clips (layer);
1278 assert_equals_int (g_list_length (objects), 5);
1279 current = current->next;
1280 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1281 current = current->next;
1282 assert_is_type (current->data, GES_TYPE_TRANSITION_CLIP);
1283 current = current->next;
1284 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1285 current = current->next;
1286 assert_is_type (current->data, GES_TYPE_TEST_CLIP);
1287 g_list_free_full (objects, gst_object_unref);
1289 ges_layer_set_auto_transition (layer, TRUE);
1291 * 0___________src_________1000
1292 * 500______tr______1000
1293 * 500___________src1_________1500
1295 * 1000____src2_______2000
1296 * 2000_______src3_____2500
1298 current = objects = ges_layer_get_clips (layer);
1299 assert_equals_int (g_list_length (objects), 8);
1300 assert_equals_uint64 (_START (src), 0);
1301 assert_equals_uint64 (_DURATION (src), 1000);
1302 assert_equals_uint64 (_START (src1), 500);
1303 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
1304 assert_equals_uint64 (_START (src2), 1000);
1305 assert_equals_uint64 (_DURATION (src2), 1000);
1306 assert_equals_uint64 (_START (src3), 2000);
1307 assert_equals_uint64 (_DURATION (src3), 500);
1309 GST_DEBUG ("Checking transitions");
1310 fail_unless (current->data == src);
1312 current = current->next;
1313 transition = current->data;
1314 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1315 assert_equals_uint64 (_START (transition), 500);
1316 assert_equals_uint64 (_DURATION (transition), 500);
1318 current = current->next;
1319 transition = current->data;
1320 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1321 assert_equals_uint64 (_START (transition), 500);
1322 assert_equals_uint64 (_DURATION (transition), 500);
1324 current = current->next;
1325 fail_unless (current->data == src1);
1327 current = current->next;
1328 transition = current->data;
1329 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1330 assert_equals_uint64 (_START (transition), 1000);
1331 assert_equals_uint64 (_DURATION (transition), 500);
1333 current = current->next;
1334 transition = current->data;
1335 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1336 assert_equals_uint64 (_START (transition), 1000);
1337 assert_equals_uint64 (_DURATION (transition), 500);
1339 current = current->next;
1340 fail_unless (current->data == src2);
1342 current = current->next;
1343 fail_unless (current->data == src3);
1344 g_list_free_full (objects, gst_object_unref);
1345 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1347 GST_DEBUG ("Moving src2 to 1200, check everything updates properly");
1348 ges_timeline_element_set_start (src2, 1200);
1349 ges_timeline_commit (timeline);
1351 * 0___________src_________1000
1352 * 500______tr______1000
1353 * 500___________src1_________1500
1355 * 1200____src2_______2200
1357 * 2000_______src3_____2500
1359 current = objects = ges_layer_get_clips (layer);
1360 assert_equals_int (g_list_length (objects), 10);
1361 assert_equals_uint64 (_START (src), 0);
1362 assert_equals_uint64 (_DURATION (src), 1000);
1363 assert_equals_uint64 (_START (src1), 500);
1364 assert_equals_uint64 (_DURATION (src1), 1500 - 500);
1365 assert_equals_uint64 (_START (src2), 1200);
1366 assert_equals_uint64 (_DURATION (src2), 1000);
1367 assert_equals_uint64 (_START (src3), 2000);
1368 assert_equals_uint64 (_DURATION (src3), 500);
1370 GST_DEBUG ("Checking transitions");
1371 fail_unless (current->data == src);
1373 current = current->next;
1374 transition = current->data;
1375 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1376 assert_equals_uint64 (_START (transition), 500);
1377 assert_equals_uint64 (_DURATION (transition), 500);
1379 current = current->next;
1380 transition = current->data;
1381 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1382 assert_equals_uint64 (_START (transition), 500);
1383 assert_equals_uint64 (_DURATION (transition), 500);
1385 current = current->next;
1386 fail_unless (current->data == src1);
1388 current = current->next;
1389 transition = current->data;
1390 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1391 assert_equals_uint64 (_START (transition), 1200);
1392 assert_equals_uint64 (_DURATION (transition), 300);
1394 current = current->next;
1395 transition = current->data;
1396 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1397 assert_equals_uint64 (_START (transition), 1200);
1398 assert_equals_uint64 (_DURATION (transition), 300);
1400 current = current->next;
1401 fail_unless (current->data == src2);
1403 current = current->next;
1404 transition = current->data;
1405 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1406 assert_equals_uint64 (_START (transition), 2000);
1407 assert_equals_uint64 (_DURATION (transition), 200);
1409 current = current->next;
1410 transition = current->data;
1411 assert_is_type (transition, GES_TYPE_TRANSITION_CLIP);
1412 assert_equals_uint64 (_START (transition), 2000);
1413 assert_equals_uint64 (_DURATION (transition), 200);
1415 current = current->next;
1416 fail_unless (current->data == src3);
1417 g_list_free_full (objects, gst_object_unref);
1418 ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2);
1421 gst_object_unref (timeline);
1426 GST_START_TEST (test_layer_meta_string)
1428 GESTimeline *timeline;
1430 const gchar *result;
1434 timeline = ges_timeline_new_audio_video ();
1435 layer = ges_layer_new ();
1436 ges_timeline_add_layer (timeline, layer);
1438 ges_meta_container_set_string (GES_META_CONTAINER (layer),
1439 "ges-test", "blub");
1441 fail_unless ((result = ges_meta_container_get_string (GES_META_CONTAINER
1442 (layer), "ges-test")) != NULL);
1444 assert_equals_string (result, "blub");
1449 GST_START_TEST (test_layer_meta_boolean)
1451 GESTimeline *timeline;
1457 timeline = ges_timeline_new_audio_video ();
1458 layer = ges_layer_new ();
1459 ges_timeline_add_layer (timeline, layer);
1461 ges_meta_container_set_boolean (GES_META_CONTAINER (layer), "ges-test", TRUE);
1463 fail_unless (ges_meta_container_get_boolean (GES_META_CONTAINER
1464 (layer), "ges-test", &result));
1466 fail_unless (result);
1471 GST_START_TEST (test_layer_meta_int)
1473 GESTimeline *timeline;
1479 timeline = ges_timeline_new_audio_video ();
1480 layer = ges_layer_new ();
1481 ges_timeline_add_layer (timeline, layer);
1483 ges_meta_container_set_int (GES_META_CONTAINER (layer), "ges-test", 1234);
1485 fail_unless (ges_meta_container_get_int (GES_META_CONTAINER (layer),
1486 "ges-test", &result));
1488 assert_equals_int (result, 1234);
1493 GST_START_TEST (test_layer_meta_uint)
1495 GESTimeline *timeline;
1501 timeline = ges_timeline_new_audio_video ();
1502 layer = ges_layer_new ();
1503 ges_timeline_add_layer (timeline, layer);
1505 ges_meta_container_set_uint (GES_META_CONTAINER (layer), "ges-test", 42);
1507 fail_unless (ges_meta_container_get_uint (GES_META_CONTAINER
1508 (layer), "ges-test", &result));
1510 assert_equals_int (result, 42);
1515 GST_START_TEST (test_layer_meta_int64)
1517 GESTimeline *timeline;
1523 timeline = ges_timeline_new_audio_video ();
1524 layer = ges_layer_new ();
1525 ges_timeline_add_layer (timeline, layer);
1527 ges_meta_container_set_int64 (GES_META_CONTAINER (layer), "ges-test", 1234);
1529 fail_unless (ges_meta_container_get_int64 (GES_META_CONTAINER (layer),
1530 "ges-test", &result));
1532 assert_equals_int64 (result, 1234);
1537 GST_START_TEST (test_layer_meta_uint64)
1539 GESTimeline *timeline;
1545 timeline = ges_timeline_new_audio_video ();
1546 layer = ges_layer_new ();
1547 ges_timeline_add_layer (timeline, layer);
1549 ges_meta_container_set_uint64 (GES_META_CONTAINER (layer), "ges-test", 42);
1551 fail_unless (ges_meta_container_get_uint64 (GES_META_CONTAINER
1552 (layer), "ges-test", &result));
1554 assert_equals_uint64 (result, 42);
1559 GST_START_TEST (test_layer_meta_float)
1561 GESTimeline *timeline;
1567 timeline = ges_timeline_new_audio_video ();
1568 layer = ges_layer_new ();
1569 ges_timeline_add_layer (timeline, layer);
1571 fail_unless (ges_meta_container_set_float (GES_META_CONTAINER (layer),
1572 "ges-test", 23.456));
1574 fail_unless (ges_meta_container_get_float (GES_META_CONTAINER (layer),
1575 "ges-test", &result));
1577 assert_equals_float (result, 23.456f);
1582 GST_START_TEST (test_layer_meta_double)
1584 GESTimeline *timeline;
1590 timeline = ges_timeline_new_audio_video ();
1591 layer = ges_layer_new ();
1592 ges_timeline_add_layer (timeline, layer);
1594 ges_meta_container_set_double (GES_META_CONTAINER (layer),
1595 "ges-test", 23.456);
1597 fail_unless (ges_meta_container_get_double (GES_META_CONTAINER
1598 (layer), "ges-test", &result));
1599 fail_unless (result == 23.456);
1602 assert_equals_float (result, 23.456);
1607 GST_START_TEST (test_layer_meta_date)
1609 GESTimeline *timeline;
1616 timeline = ges_timeline_new_audio_video ();
1617 layer = ges_layer_new ();
1618 ges_timeline_add_layer (timeline, layer);
1620 input = g_date_new_dmy (1, 1, 2012);
1622 ges_meta_container_set_date (GES_META_CONTAINER (layer), "ges-test", input);
1624 fail_unless (ges_meta_container_get_date (GES_META_CONTAINER
1625 (layer), "ges-test", &result));
1627 fail_unless (g_date_compare (result, input) == 0);
1629 g_date_free (input);
1630 g_date_free (result);
1635 GST_START_TEST (test_layer_meta_date_time)
1637 GESTimeline *timeline;
1640 GstDateTime *result = NULL;
1644 timeline = ges_timeline_new_audio_video ();
1645 layer = ges_layer_new ();
1646 ges_timeline_add_layer (timeline, layer);
1648 input = gst_date_time_new_from_unix_epoch_local_time (123456789);
1650 fail_unless (ges_meta_container_set_date_time (GES_META_CONTAINER
1651 (layer), "ges-test", input));
1653 fail_unless (ges_meta_container_get_date_time (GES_META_CONTAINER
1654 (layer), "ges-test", &result));
1656 fail_unless (result != NULL);
1657 fail_unless (gst_date_time_get_day (input) == gst_date_time_get_day (result));
1658 fail_unless (gst_date_time_get_hour (input) ==
1659 gst_date_time_get_hour (result));
1661 gst_date_time_unref (input);
1662 gst_date_time_unref (result);
1668 GST_START_TEST (test_layer_meta_value)
1670 GESTimeline *timeline;
1672 GValue data = G_VALUE_INIT;
1673 const GValue *result;
1677 timeline = ges_timeline_new_audio_video ();
1678 layer = ges_layer_new ();
1679 ges_timeline_add_layer (timeline, layer);
1681 g_value_init (&data, G_TYPE_STRING);
1682 g_value_set_string (&data, "Hello world!");
1684 ges_meta_container_set_meta (GES_META_CONTAINER (layer),
1685 "ges-test-value", &data);
1688 ges_meta_container_get_meta (GES_META_CONTAINER (layer),
1690 assert_equals_string (g_value_get_string (result), "Hello world!");
1692 g_value_unset (&data);
1697 GST_START_TEST (test_layer_meta_register)
1699 GESTimeline *timeline;
1701 const gchar *result;
1705 timeline = ges_timeline_new_audio_video ();
1706 layer = ges_layer_new ();
1707 ges_timeline_add_layer (timeline, layer);
1709 fail_unless (ges_meta_container_register_meta_string (GES_META_CONTAINER
1710 (layer), GES_META_READABLE, "ges-test-value", "Hello world!"));
1712 result = ges_meta_container_get_string (GES_META_CONTAINER (layer),
1714 assert_equals_string (result, "Hello world!");
1716 fail_if (ges_meta_container_set_int (GES_META_CONTAINER (layer),
1717 "ges-test-value", 123456));
1719 result = ges_meta_container_get_string (GES_META_CONTAINER (layer),
1721 assert_equals_string (result, "Hello world!");
1727 test_foreach (const GESMetaContainer * container, const gchar * key,
1728 GValue * value, gpointer user_data)
1730 fail_unless ((0 == g_strcmp0 (key, "some-string")) ||
1731 (0 == g_strcmp0 (key, "some-int")) || (0 == g_strcmp0 (key, "volume")));
1734 GST_START_TEST (test_layer_meta_foreach)
1736 GESTimeline *timeline;
1741 timeline = ges_timeline_new_audio_video ();
1742 layer = ges_layer_new ();
1743 ges_timeline_add_layer (timeline, layer);
1745 ges_meta_container_set_string (GES_META_CONTAINER (layer),
1746 "some-string", "some-content");
1748 ges_meta_container_set_int (GES_META_CONTAINER (layer), "some-int", 123456);
1750 ges_meta_container_foreach (GES_META_CONTAINER (layer),
1751 (GESMetaForeachFunc) test_foreach, NULL);
1759 Suite *s = suite_create ("ges-layer");
1760 TCase *tc_chain = tcase_create ("timeline-layer");
1762 if (atexit (ges_deinit) != 0) {
1763 GST_ERROR ("failed to set ges_deinit as exit function");
1766 suite_add_tcase (s, tc_chain);
1768 tcase_add_test (tc_chain, test_layer_properties);
1769 tcase_add_test (tc_chain, test_layer_priorities);
1770 tcase_add_test (tc_chain, test_timeline_auto_transition);
1771 tcase_add_test (tc_chain, test_single_layer_automatic_transition);
1772 tcase_add_test (tc_chain, test_multi_layer_automatic_transition);
1773 tcase_add_test (tc_chain, test_layer_activate_automatic_transition);
1774 tcase_add_test (tc_chain, test_layer_meta_string);
1775 tcase_add_test (tc_chain, test_layer_meta_boolean);
1776 tcase_add_test (tc_chain, test_layer_meta_int);
1777 tcase_add_test (tc_chain, test_layer_meta_uint);
1778 tcase_add_test (tc_chain, test_layer_meta_int64);
1779 tcase_add_test (tc_chain, test_layer_meta_uint64);
1780 tcase_add_test (tc_chain, test_layer_meta_float);
1781 tcase_add_test (tc_chain, test_layer_meta_double);
1782 tcase_add_test (tc_chain, test_layer_meta_date);
1783 tcase_add_test (tc_chain, test_layer_meta_date_time);
1784 tcase_add_test (tc_chain, test_layer_meta_value);
1785 tcase_add_test (tc_chain, test_layer_meta_register);
1786 tcase_add_test (tc_chain, test_layer_meta_foreach);
1791 GST_CHECK_MAIN (ges);