| 1 |
/* GStreamer Editing Services |
| 2 |
* Copyright (C) 2010 Edward Hervey <[email protected]> |
| 3 |
* |
| 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. |
| 8 |
* |
| 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. |
| 13 |
* |
| 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. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "test-utils.h" |
| 21 |
#include <ges/ges.h> |
| 22 |
#include <gst/check/gstcheck.h> |
| 23 |
|
| 24 |
#define LAYER_HEIGHT 1000 |
| 25 |
|
| 26 |
GST_START_TEST (test_layer_properties) |
| 27 |
{ |
| 28 |
GESTimeline *timeline; |
| 29 |
GESLayer *layer, *layer1; |
| 30 |
GESTrack *track; |
| 31 |
GESTrackElement *trackelement; |
| 32 |
GESClip *clip; |
| 33 |
|
| 34 |
ges_init (); |
| 35 |
|
| 36 |
/* Timeline and 1 Layer */ |
| 37 |
timeline = ges_timeline_new (); |
| 38 |
|
| 39 |
/* The default priority is 0 */ |
| 40 |
fail_unless ((layer = ges_timeline_append_layer (timeline))); |
| 41 |
fail_unless_equals_int (ges_layer_get_priority (layer), 0); |
| 42 |
|
| 43 |
fail_if (g_object_is_floating (layer)); |
| 44 |
|
| 45 |
fail_unless ((layer1 = ges_timeline_append_layer (timeline))); |
| 46 |
fail_unless_equals_int (ges_layer_get_priority (layer1), 1); |
| 47 |
|
| 48 |
track = GES_TRACK (ges_video_track_new ()); |
| 49 |
fail_unless (track != NULL); |
| 50 |
fail_unless (ges_timeline_add_track (timeline, track)); |
| 51 |
|
| 52 |
clip = (GESClip *) ges_test_clip_new (); |
| 53 |
fail_unless (clip != NULL); |
| 54 |
|
| 55 |
/* Set some properties */ |
| 56 |
g_object_set (clip, "start", (guint64) 42, "duration", (gint64) 51, |
| 57 |
"in-point", (guint64) 12, NULL); |
| 58 |
assert_equals_uint64 (_START (clip), 42); |
| 59 |
assert_equals_uint64 (_DURATION (clip), 51); |
| 60 |
assert_equals_uint64 (_INPOINT (clip), 12); |
| 61 |
assert_equals_uint64 (_PRIORITY (clip), 0); |
| 62 |
|
| 63 |
/* Add the clip to the timeline */ |
| 64 |
fail_unless (g_object_is_floating (clip)); |
| 65 |
fail_unless (ges_layer_add_clip (layer, GES_CLIP (clip))); |
| 66 |
fail_if (g_object_is_floating (clip)); |
| 67 |
trackelement = ges_clip_find_track_element (clip, track, G_TYPE_NONE); |
| 68 |
fail_unless (trackelement != NULL); |
| 69 |
|
| 70 |
/* This is not a SimpleLayer, therefore the properties shouldn't have changed */ |
| 71 |
assert_equals_uint64 (_START (clip), 42); |
| 72 |
assert_equals_uint64 (_DURATION (clip), 51); |
| 73 |
assert_equals_uint64 (_INPOINT (clip), 12); |
| 74 |
assert_equals_uint64 (_PRIORITY (clip), 1); |
| 75 |
ges_timeline_commit (timeline); |
| 76 |
nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12, |
| 77 |
51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT, TRUE); |
| 78 |
|
| 79 |
/* Change the priority of the layer */ |
| 80 |
g_object_set (layer, "priority", 1, NULL); |
| 81 |
assert_equals_int (ges_layer_get_priority (layer), 1); |
| 82 |
assert_equals_uint64 (_PRIORITY (clip), 1); |
| 83 |
ges_timeline_commit (timeline); |
| 84 |
nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12, |
| 85 |
51, LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT, TRUE); |
| 86 |
|
| 87 |
/* Change it to an insanely high value */ |
| 88 |
g_object_set (layer, "priority", 31, NULL); |
| 89 |
assert_equals_int (ges_layer_get_priority (layer), 31); |
| 90 |
assert_equals_uint64 (_PRIORITY (clip), 1); |
| 91 |
ges_timeline_commit (timeline); |
| 92 |
nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12, |
| 93 |
51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT + LAYER_HEIGHT * 31, TRUE); |
| 94 |
|
| 95 |
/* and back to 0 */ |
| 96 |
fail_unless (ges_timeline_move_layer (timeline, layer, 0)); |
| 97 |
assert_equals_int (ges_layer_get_priority (layer), 0); |
| 98 |
assert_equals_uint64 (_PRIORITY (clip), 1); |
| 99 |
ges_timeline_commit (timeline); |
| 100 |
nle_object_check (ges_track_element_get_nleobject (trackelement), 42, 51, 12, |
| 101 |
51, MIN_NLE_PRIO + TRANSITIONS_HEIGHT + 0, TRUE); |
| 102 |
|
| 103 |
gst_object_unref (trackelement); |
| 104 |
fail_unless (ges_layer_remove_clip (layer, clip)); |
| 105 |
fail_unless (ges_timeline_remove_track (timeline, track)); |
| 106 |
fail_unless (ges_timeline_remove_layer (timeline, layer)); |
| 107 |
gst_object_unref (timeline); |
| 108 |
|
| 109 |
ges_deinit (); |
| 110 |
} |
| 111 |
|
| 112 |
GST_END_TEST; |
| 113 |
|
| 114 |
GST_START_TEST (test_layer_priorities) |
| 115 |
{ |
| 116 |
GESTrack *track; |
| 117 |
GESTimeline *timeline; |
| 118 |
GESLayer *layer1, *layer2, *layer3; |
| 119 |
GESTrackElement *trackelement1, *trackelement2, *trackelement3; |
| 120 |
GESClip *clip1, *clip2, *clip3; |
| 121 |
GstElement *nleobj1, *nleobj2, *nleobj3; |
| 122 |
guint prio1, prio2, prio3; |
| 123 |
GList *objs; |
| 124 |
|
| 125 |
ges_init (); |
| 126 |
|
| 127 |
/* Timeline and 3 Layer */ |
| 128 |
timeline = ges_timeline_new (); |
| 129 |
fail_unless ((layer1 = ges_timeline_append_layer (timeline))); |
| 130 |
fail_unless ((layer2 = ges_timeline_append_layer (timeline))); |
| 131 |
fail_unless ((layer3 = ges_timeline_append_layer (timeline))); |
| 132 |
fail_unless_equals_int (ges_layer_get_priority (layer1), 0); |
| 133 |
fail_unless_equals_int (ges_layer_get_priority (layer2), 1); |
| 134 |
fail_unless_equals_int (ges_layer_get_priority (layer3), 2); |
| 135 |
|
| 136 |
track = GES_TRACK (ges_video_track_new ()); |
| 137 |
fail_unless (track != NULL); |
| 138 |
fail_unless (ges_timeline_add_track (timeline, track)); |
| 139 |
|
| 140 |
clip1 = GES_CLIP (ges_test_clip_new ()); |
| 141 |
clip2 = GES_CLIP (ges_test_clip_new ()); |
| 142 |
clip3 = GES_CLIP (ges_test_clip_new ()); |
| 143 |
fail_unless (clip1 != NULL); |
| 144 |
fail_unless (clip2 != NULL); |
| 145 |
fail_unless (clip3 != NULL); |
| 146 |
|
| 147 |
g_object_set (clip1, "start", (guint64) 0, "duration", (gint64) 10, NULL); |
| 148 |
g_object_set (clip2, "start", (guint64) 10, "duration", (gint64) 10, NULL); |
| 149 |
g_object_set (clip3, "start", (guint64) 20, "duration", (gint64) 10, NULL); |
| 150 |
|
| 151 |
/* Add objects to the timeline */ |
| 152 |
fail_unless (ges_layer_add_clip (layer1, clip1)); |
| 153 |
trackelement1 = ges_clip_find_track_element (clip1, track, G_TYPE_NONE); |
| 154 |
fail_unless (trackelement1 != NULL); |
| 155 |
|
| 156 |
fail_unless (ges_layer_add_clip (layer2, clip2)); |
| 157 |
trackelement2 = ges_clip_find_track_element (clip2, track, G_TYPE_NONE); |
| 158 |
fail_unless (trackelement2 != NULL); |
| 159 |
|
| 160 |
fail_unless (ges_layer_add_clip (layer3, clip3)); |
| 161 |
trackelement3 = ges_clip_find_track_element (clip3, track, G_TYPE_NONE); |
| 162 |
fail_unless (trackelement3 != NULL); |
| 163 |
|
| 164 |
ges_timeline_commit (timeline); |
| 165 |
assert_equals_int (_PRIORITY (clip1), 1); |
| 166 |
nleobj1 = ges_track_element_get_nleobject (trackelement1); |
| 167 |
fail_unless (nleobj1 != NULL); |
| 168 |
g_object_get (nleobj1, "priority", &prio1, NULL); |
| 169 |
assert_equals_int (prio1, MIN_NLE_PRIO + TRANSITIONS_HEIGHT); |
| 170 |
|
| 171 |
assert_equals_int (_PRIORITY (clip2), 1); |
| 172 |
nleobj2 = ges_track_element_get_nleobject (trackelement2); |
| 173 |
fail_unless (nleobj2 != NULL); |
| 174 |
g_object_get (nleobj2, "priority", &prio2, NULL); |
| 175 |
/* clip2 is on the second layer and has a priority of 1 */ |
| 176 |
assert_equals_int (prio2, MIN_NLE_PRIO + LAYER_HEIGHT + 1); |
| 177 |
|
| 178 |
/* We do not take into account users set priorities */ |
| 179 |
assert_equals_int (_PRIORITY (clip3), 1); |
| 180 |
|
| 181 |
nleobj3 = ges_track_element_get_nleobject (trackelement3); |
| 182 |
fail_unless (nleobj3 != NULL); |
| 183 |
|
| 184 |
/* clip3 is on the third layer and has a priority of LAYER_HEIGHT + 1 |
| 185 |
* it priority must have the maximum priority of this layer*/ |
| 186 |
g_object_get (nleobj3, "priority", &prio3, NULL); |
| 187 |
assert_equals_int (prio3, 1 + MIN_NLE_PRIO + LAYER_HEIGHT * 2); |
| 188 |
|
| 189 |
/* Move layers around */ |
| 190 |
fail_unless (ges_timeline_move_layer (timeline, layer1, 2)); |
| 191 |
ges_timeline_commit (timeline); |
| 192 |
|
| 193 |
/* And check the new priorities */ |
| 194 |
assert_equals_int (ges_layer_get_priority (layer1), 2); |
| 195 |
assert_equals_int (ges_layer_get_priority (layer2), 0); |
| 196 |
assert_equals_int (ges_layer_get_priority (layer3), 1); |
| 197 |
assert_equals_int (_PRIORITY (clip1), 1); |
| 198 |
assert_equals_int (_PRIORITY (clip2), 1); |
| 199 |
assert_equals_int (_PRIORITY (clip3), 1); |
| 200 |
g_object_get (nleobj1, "priority", &prio1, NULL); |
| 201 |
g_object_get (nleobj2, "priority", &prio2, NULL); |
| 202 |
g_object_get (nleobj3, "priority", &prio3, NULL); |
| 203 |
assert_equals_int (prio1, |
| 204 |
2 * LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT); |
| 205 |
assert_equals_int (prio2, MIN_NLE_PRIO + 1); |
| 206 |
assert_equals_int (prio3, LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT); |
| 207 |
|
| 208 |
/* And move objects around */ |
| 209 |
fail_unless (ges_clip_move_to_layer (clip2, layer1)); |
| 210 |
fail_unless (ges_clip_move_to_layer (clip3, layer1)); |
| 211 |
ges_timeline_commit (timeline); |
| 212 |
|
| 213 |
objs = ges_layer_get_clips (layer1); |
| 214 |
assert_equals_int (g_list_length (objs), 3); |
| 215 |
fail_unless (ges_layer_get_clips (layer2) == NULL); |
| 216 |
fail_unless (ges_layer_get_clips (layer3) == NULL); |
| 217 |
g_list_free_full (objs, gst_object_unref); |
| 218 |
|
| 219 |
/* Check their priorities (layer1 priority is now 2) */ |
| 220 |
assert_equals_int (_PRIORITY (clip1), 1); |
| 221 |
assert_equals_int (_PRIORITY (clip2), 2); |
| 222 |
assert_equals_int (_PRIORITY (clip3), 3); |
| 223 |
g_object_get (nleobj1, "priority", &prio1, NULL); |
| 224 |
g_object_get (nleobj2, "priority", &prio2, NULL); |
| 225 |
g_object_get (nleobj3, "priority", &prio3, NULL); |
| 226 |
assert_equals_int (prio1, |
| 227 |
2 * LAYER_HEIGHT + MIN_NLE_PRIO + TRANSITIONS_HEIGHT); |
| 228 |
assert_equals_int (prio2, |
| 229 |
2 * LAYER_HEIGHT + 1 + MIN_NLE_PRIO + TRANSITIONS_HEIGHT); |
| 230 |
assert_equals_int (prio3, |
| 231 |
2 * LAYER_HEIGHT + 2 + MIN_NLE_PRIO + TRANSITIONS_HEIGHT); |
| 232 |
|
| 233 |
gst_object_unref (trackelement1); |
| 234 |
gst_object_unref (trackelement2); |
| 235 |
gst_object_unref (trackelement3); |
| 236 |
gst_object_unref (timeline); |
| 237 |
|
| 238 |
ges_deinit (); |
| 239 |
} |
| 240 |
|
| 241 |
GST_END_TEST; |
| 242 |
|
| 243 |
GST_START_TEST (test_timeline_auto_transition) |
| 244 |
{ |
| 245 |
GESAsset *asset; |
| 246 |
GESTimeline *timeline; |
| 247 |
GESLayer *layer, *layer1, *layer2; |
| 248 |
|
| 249 |
ges_init (); |
| 250 |
|
| 251 |
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL); |
| 252 |
fail_unless (GES_IS_ASSET (asset)); |
| 253 |
gst_object_unref (asset); |
| 254 |
|
| 255 |
GST_DEBUG ("Create timeline"); |
| 256 |
timeline = ges_timeline_new_audio_video (); |
| 257 |
assert_is_type (timeline, GES_TYPE_TIMELINE); |
| 258 |
|
| 259 |
GST_DEBUG ("Create layers"); |
| 260 |
layer = ges_layer_new (); |
| 261 |
assert_is_type (layer, GES_TYPE_LAYER); |
| 262 |
layer1 = ges_layer_new (); |
| 263 |
assert_is_type (layer, GES_TYPE_LAYER); |
| 264 |
layer2 = ges_layer_new (); |
| 265 |
assert_is_type (layer, GES_TYPE_LAYER); |
| 266 |
|
| 267 |
GST_DEBUG ("Set auto-transition to the layers"); |
| 268 |
ges_layer_set_auto_transition (layer, TRUE); |
| 269 |
ges_layer_set_auto_transition (layer1, TRUE); |
| 270 |
ges_layer_set_auto_transition (layer2, TRUE); |
| 271 |
|
| 272 |
GST_DEBUG ("Add layers to the timeline"); |
| 273 |
ges_timeline_add_layer (timeline, layer); |
| 274 |
ges_timeline_add_layer (timeline, layer1); |
| 275 |
ges_timeline_add_layer (timeline, layer2); |
| 276 |
|
| 277 |
GST_DEBUG ("Check that auto-transition was properly set to the layers"); |
| 278 |
fail_unless (ges_layer_get_auto_transition (layer)); |
| 279 |
fail_unless (ges_layer_get_auto_transition (layer1)); |
| 280 |
fail_unless (ges_layer_get_auto_transition (layer2)); |
| 281 |
|
| 282 |
GST_DEBUG ("Set timeline auto-transition property to FALSE"); |
| 283 |
ges_timeline_set_auto_transition (timeline, FALSE); |
| 284 |
|
| 285 |
GST_DEBUG |
| 286 |
("Check that layers auto-transition has the same value as timeline"); |
| 287 |
fail_if (ges_layer_get_auto_transition (layer)); |
| 288 |
fail_if (ges_layer_get_auto_transition (layer1)); |
| 289 |
fail_if (ges_layer_get_auto_transition (layer2)); |
| 290 |
|
| 291 |
GST_DEBUG ("Set timeline auto-transition property to TRUE"); |
| 292 |
ges_timeline_set_auto_transition (timeline, TRUE); |
| 293 |
|
| 294 |
GST_DEBUG |
| 295 |
("Check that layers auto-transition has the same value as timeline"); |
| 296 |
fail_unless (ges_layer_get_auto_transition (layer)); |
| 297 |
fail_unless (ges_layer_get_auto_transition (layer1)); |
| 298 |
fail_unless (ges_layer_get_auto_transition (layer2)); |
| 299 |
|
| 300 |
gst_object_unref (timeline); |
| 301 |
|
| 302 |
ges_deinit (); |
| 303 |
} |
| 304 |
|
| 305 |
GST_END_TEST; |
| 306 |
|
| 307 |
GST_START_TEST (test_single_layer_automatic_transition) |
| 308 |
{ |
| 309 |
GESAsset *asset; |
| 310 |
GESTimeline *timeline; |
| 311 |
GList *objects; |
| 312 |
GESClip *transition; |
| 313 |
GESLayer *layer; |
| 314 |
GESTimelineElement *src, *src1, *src2; |
| 315 |
|
| 316 |
ges_init (); |
| 317 |
|
| 318 |
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL); |
| 319 |
fail_unless (GES_IS_ASSET (asset)); |
| 320 |
|
| 321 |
GST_DEBUG ("Create timeline"); |
| 322 |
timeline = ges_timeline_new_audio_video (); |
| 323 |
assert_is_type (timeline, GES_TYPE_TIMELINE); |
| 324 |
|
| 325 |
GST_DEBUG ("Create first layer"); |
| 326 |
layer = ges_layer_new (); |
| 327 |
assert_is_type (layer, GES_TYPE_LAYER); |
| 328 |
|
| 329 |
GST_DEBUG ("Add first layer to timeline"); |
| 330 |
fail_unless (ges_timeline_add_layer (timeline, layer)); |
| 331 |
|
| 332 |
GST_DEBUG ("Set auto transition to first layer"); |
| 333 |
ges_layer_set_auto_transition (layer, TRUE); |
| 334 |
|
| 335 |
GST_DEBUG ("Check that auto-transition was properly set"); |
| 336 |
fail_unless (ges_layer_get_auto_transition (layer)); |
| 337 |
|
| 338 |
GST_DEBUG ("Adding assets to first layer"); |
| 339 |
GST_DEBUG ("Adding clip from 0 -- 1000 to first layer"); |
| 340 |
src = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 0, 0, |
| 341 |
1000, GES_TRACK_TYPE_UNKNOWN)); |
| 342 |
fail_unless (GES_IS_CLIP (src)); |
| 343 |
|
| 344 |
GST_DEBUG ("Adding clip from 500 -- 1000 to first layer"); |
| 345 |
src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500, |
| 346 |
0, 1000, GES_TRACK_TYPE_UNKNOWN)); |
| 347 |
fail_unless (GES_IS_CLIP (src1)); |
| 348 |
|
| 349 |
/* |
| 350 |
* 500__transition__1000 |
| 351 |
* 0___________src_________1000 |
| 352 |
* 500___________src1_________1500 |
| 353 |
*/ |
| 354 |
GST_DEBUG ("Checking src timing values"); |
| 355 |
assert_equals_uint64 (_START (src), 0); |
| 356 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 357 |
assert_equals_uint64 (_START (src1), 500); |
| 358 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 359 |
ges_timeline_commit (timeline); |
| 360 |
|
| 361 |
GST_DEBUG ("Checking that a transition has been added"); |
| 362 |
objects = ges_layer_get_clips (layer); |
| 363 |
assert_equals_int (g_list_length (objects), 4); |
| 364 |
assert_is_type (objects->data, GES_TYPE_TEST_CLIP); |
| 365 |
|
| 366 |
transition = objects->next->data; |
| 367 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 368 |
assert_equals_uint64 (_START (transition), 500); |
| 369 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 370 |
|
| 371 |
transition = objects->next->next->data; |
| 372 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 373 |
assert_equals_uint64 (_START (transition), 500); |
| 374 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 375 |
g_list_free_full (objects, gst_object_unref); |
| 376 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 377 |
|
| 378 |
GST_DEBUG ("Moving first source to 250"); |
| 379 |
ges_timeline_element_set_start (src, 250); |
| 380 |
|
| 381 |
/* |
| 382 |
* 600_____transition______1500 |
| 383 |
* 600___________src_________1600 |
| 384 |
* 500___________src1_________1500 |
| 385 |
*/ |
| 386 |
GST_DEBUG ("Checking src timing values"); |
| 387 |
CHECK_OBJECT_PROPS (src, 250, 0, 1000); |
| 388 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 389 |
|
| 390 |
objects = ges_layer_get_clips (layer); |
| 391 |
assert_equals_int (g_list_length (objects), 4); |
| 392 |
transition = objects->next->data; |
| 393 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 394 |
CHECK_OBJECT_PROPS (transition, 500, 0, 750); |
| 395 |
|
| 396 |
transition = objects->next->next->data; |
| 397 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 398 |
CHECK_OBJECT_PROPS (transition, 500, 0, 750); |
| 399 |
g_list_free_full (objects, gst_object_unref); |
| 400 |
|
| 401 |
fail_if (ges_timeline_element_set_start (src1, 250)); |
| 402 |
|
| 403 |
fail_if (ges_container_edit (GES_CONTAINER (src), NULL, -1, |
| 404 |
GES_EDIT_MODE_TRIM, GES_EDGE_START, 500)); |
| 405 |
CHECK_OBJECT_PROPS (src, 250, 0, 1000); |
| 406 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 407 |
fail_if (ges_timeline_element_trim (src, 500)); |
| 408 |
CHECK_OBJECT_PROPS (src, 250, 0, 1000); |
| 409 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 410 |
fail_if (ges_timeline_element_trim (src, 750)); |
| 411 |
CHECK_OBJECT_PROPS (src, 250, 0, 1000); |
| 412 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 413 |
fail_if (ges_timeline_element_set_start (src, 500)); |
| 414 |
CHECK_OBJECT_PROPS (src, 250, 0, 1000); |
| 415 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 416 |
|
| 417 |
/* |
| 418 |
* 600_____transition______1500 |
| 419 |
* 600___________src_________1600 |
| 420 |
* 500___________src1_________1500 |
| 421 |
*/ |
| 422 |
ges_timeline_element_set_start (src, 600); |
| 423 |
CHECK_OBJECT_PROPS (src, 600, 0, 1000); |
| 424 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 425 |
objects = ges_layer_get_clips (layer); |
| 426 |
assert_equals_int (g_list_length (objects), 4); |
| 427 |
transition = objects->next->data; |
| 428 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 429 |
CHECK_OBJECT_PROPS (transition, 600, 0, 900); |
| 430 |
g_list_free_full (objects, gst_object_unref); |
| 431 |
|
| 432 |
GST_DEBUG ("Adding asset to first layer"); |
| 433 |
GST_DEBUG ("Adding clip from 1250 -- 1000 to first layer"); |
| 434 |
fail_if (ges_layer_add_asset (layer, asset, 1250, 0, |
| 435 |
1000, GES_TRACK_TYPE_UNKNOWN)); |
| 436 |
|
| 437 |
/* |
| 438 |
* 1500___________src2________2000 |
| 439 |
* 1500_trans_1600 |
| 440 |
* 600______________src________________1600 |
| 441 |
* 600_____transition______1500 |
| 442 |
* 500___________src1_________1500 |
| 443 |
*/ |
| 444 |
src2 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 1500, 0, |
| 445 |
500, GES_TRACK_TYPE_UNKNOWN)); |
| 446 |
assert_is_type (src2, GES_TYPE_TEST_CLIP); |
| 447 |
|
| 448 |
CHECK_OBJECT_PROPS (src, 600, 0, 1000); |
| 449 |
CHECK_OBJECT_PROPS (src1, 500, 0, 1000); |
| 450 |
CHECK_OBJECT_PROPS (src2, 1500, 0, 500); |
| 451 |
objects = ges_layer_get_clips (layer); |
| 452 |
transition = objects->next->next->data; |
| 453 |
assert_equals_int (g_list_length (objects), 7); |
| 454 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 455 |
CHECK_OBJECT_PROPS (transition, 600, 0, 900); |
| 456 |
transition = objects->next->next->next->next->data; |
| 457 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 458 |
CHECK_OBJECT_PROPS (transition, 1500, 0, 100); |
| 459 |
|
| 460 |
g_list_free_full (objects, gst_object_unref); |
| 461 |
|
| 462 |
gst_object_unref (timeline); |
| 463 |
gst_object_unref (asset); |
| 464 |
|
| 465 |
ges_deinit (); |
| 466 |
} |
| 467 |
|
| 468 |
GST_END_TEST; |
| 469 |
|
| 470 |
GST_START_TEST (test_multi_layer_automatic_transition) |
| 471 |
{ |
| 472 |
GESAsset *asset; |
| 473 |
GESTimeline *timeline; |
| 474 |
GList *objects, *current; |
| 475 |
GESClip *transition; |
| 476 |
GESLayer *layer, *layer1; |
| 477 |
GESTimelineElement *src, *src1, *src2, *src3; |
| 478 |
|
| 479 |
ges_init (); |
| 480 |
|
| 481 |
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL); |
| 482 |
fail_unless (GES_IS_ASSET (asset)); |
| 483 |
|
| 484 |
GST_DEBUG ("Create timeline"); |
| 485 |
timeline = ges_timeline_new_audio_video (); |
| 486 |
assert_is_type (timeline, GES_TYPE_TIMELINE); |
| 487 |
|
| 488 |
GST_DEBUG ("Create first layer"); |
| 489 |
layer = ges_layer_new (); |
| 490 |
assert_is_type (layer, GES_TYPE_LAYER); |
| 491 |
|
| 492 |
GST_DEBUG ("Add first layer to timeline"); |
| 493 |
fail_unless (ges_timeline_add_layer (timeline, layer)); |
| 494 |
|
| 495 |
GST_DEBUG ("Append a new layer to the timeline"); |
| 496 |
layer1 = ges_timeline_append_layer (timeline); |
| 497 |
assert_is_type (layer1, GES_TYPE_LAYER); |
| 498 |
|
| 499 |
GST_DEBUG ("Set auto transition to first layer"); |
| 500 |
ges_layer_set_auto_transition (layer, TRUE); |
| 501 |
|
| 502 |
GST_DEBUG ("Check that auto-transition was properly set"); |
| 503 |
fail_unless (ges_layer_get_auto_transition (layer)); |
| 504 |
fail_if (ges_layer_get_auto_transition (layer1)); |
| 505 |
|
| 506 |
GST_DEBUG ("Adding assets to first layer"); |
| 507 |
GST_DEBUG ("Adding clip from 0 -- 1000 to first layer"); |
| 508 |
src = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 0, 0, |
| 509 |
1000, GES_TRACK_TYPE_UNKNOWN)); |
| 510 |
fail_unless (GES_IS_CLIP (src)); |
| 511 |
|
| 512 |
GST_DEBUG ("Adding clip from 500 -- 1000 to first layer"); |
| 513 |
src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500, |
| 514 |
0, 1000, GES_TRACK_TYPE_UNKNOWN)); |
| 515 |
ges_timeline_commit (timeline); |
| 516 |
fail_unless (GES_IS_CLIP (src1)); |
| 517 |
|
| 518 |
/* |
| 519 |
* 500__transition__1000 |
| 520 |
* 0___________src_________1000 |
| 521 |
* 500___________src1_________1500 |
| 522 |
*/ |
| 523 |
GST_DEBUG ("Checking src timing values"); |
| 524 |
assert_equals_uint64 (_START (src), 0); |
| 525 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 526 |
assert_equals_uint64 (_START (src1), 500); |
| 527 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 528 |
|
| 529 |
GST_DEBUG ("Checking that a transition has been added"); |
| 530 |
current = objects = ges_layer_get_clips (layer); |
| 531 |
assert_equals_int (g_list_length (objects), 4); |
| 532 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 533 |
|
| 534 |
current = current->next; |
| 535 |
transition = current->data; |
| 536 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 537 |
assert_equals_uint64 (_START (transition), 500); |
| 538 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 539 |
|
| 540 |
current = current->next; |
| 541 |
transition = current->data; |
| 542 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 543 |
assert_equals_uint64 (_START (transition), 500); |
| 544 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 545 |
g_list_free_full (objects, gst_object_unref); |
| 546 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 547 |
|
| 548 |
GST_DEBUG ("Adding clip 2 from 500 -- 1000 to second layer"); |
| 549 |
src2 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer1, asset, 0, |
| 550 |
0, 1000, GES_TRACK_TYPE_UNKNOWN)); |
| 551 |
GST_DEBUG ("Adding clip 3 from 500 -- 1000 to second layer"); |
| 552 |
src3 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer1, asset, 500, |
| 553 |
0, 1000, GES_TRACK_TYPE_UNKNOWN)); |
| 554 |
assert_is_type (src3, GES_TYPE_TEST_CLIP); |
| 555 |
|
| 556 |
/* 500__transition__1000 |
| 557 |
* 0___________src_________1000 |
| 558 |
* 500___________src1_________1500 |
| 559 |
*---------------------------------------------------- |
| 560 |
* 0___________src2_________1000 |
| 561 |
* 500___________src3_________1500 Layer1 |
| 562 |
*/ |
| 563 |
GST_DEBUG ("Checking src timing values"); |
| 564 |
assert_equals_uint64 (_START (src), 0); |
| 565 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 566 |
assert_equals_uint64 (_START (src1), 500); |
| 567 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 568 |
assert_equals_uint64 (_START (src2), 0); |
| 569 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 570 |
assert_equals_uint64 (_START (src3), 500); |
| 571 |
assert_equals_uint64 (_DURATION (src3), 1500 - 500); |
| 572 |
|
| 573 |
GST_DEBUG ("Checking transitions on first layer"); |
| 574 |
current = objects = ges_layer_get_clips (layer); |
| 575 |
assert_equals_int (g_list_length (objects), 4); |
| 576 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 577 |
|
| 578 |
current = current->next; |
| 579 |
transition = current->data; |
| 580 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 581 |
assert_equals_uint64 (_START (transition), 500); |
| 582 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 583 |
|
| 584 |
current = current->next; |
| 585 |
transition = current->data; |
| 586 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 587 |
assert_equals_uint64 (_START (transition), 500); |
| 588 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 589 |
g_list_free_full (objects, gst_object_unref); |
| 590 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 591 |
|
| 592 |
GST_DEBUG ("Checking transitions on second layer"); |
| 593 |
current = objects = ges_layer_get_clips (layer1); |
| 594 |
assert_equals_int (g_list_length (objects), 2); |
| 595 |
fail_unless (current->data == src2); |
| 596 |
fail_unless (current->next->data == src3); |
| 597 |
g_list_free_full (objects, gst_object_unref); |
| 598 |
|
| 599 |
GST_DEBUG |
| 600 |
("Set auto transition to second layer, a new transition should be added"); |
| 601 |
ges_layer_set_auto_transition (layer1, TRUE); |
| 602 |
|
| 603 |
/* 500__transition__1000 |
| 604 |
* 0___________src_________1000 |
| 605 |
* 500___________src1_________1500 |
| 606 |
*---------------------------------------------------- |
| 607 |
* 500__transition__1000 |
| 608 |
* 0__________src2_________1000 |
| 609 |
* 500___________src3_________1500 Layer1 |
| 610 |
*/ |
| 611 |
GST_DEBUG ("Checking src timing values"); |
| 612 |
assert_equals_uint64 (_START (src), 0); |
| 613 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 614 |
assert_equals_uint64 (_START (src1), 500); |
| 615 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 616 |
assert_equals_uint64 (_START (src2), 0); |
| 617 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 618 |
assert_equals_uint64 (_START (src3), 500); |
| 619 |
assert_equals_uint64 (_DURATION (src3), 1500 - 500); |
| 620 |
|
| 621 |
GST_DEBUG ("Checking transitions on first layer"); |
| 622 |
current = objects = ges_layer_get_clips (layer); |
| 623 |
assert_equals_int (g_list_length (objects), 4); |
| 624 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 625 |
|
| 626 |
current = current->next; |
| 627 |
transition = current->data; |
| 628 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 629 |
assert_equals_uint64 (_START (transition), 500); |
| 630 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 631 |
|
| 632 |
current = current->next; |
| 633 |
transition = current->data; |
| 634 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 635 |
assert_equals_uint64 (_START (transition), 500); |
| 636 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 637 |
g_list_free_full (objects, gst_object_unref); |
| 638 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 639 |
|
| 640 |
GST_DEBUG ("Checking transitions has been added on second layer"); |
| 641 |
current = objects = ges_layer_get_clips (layer1); |
| 642 |
assert_equals_int (g_list_length (objects), 4); |
| 643 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 644 |
|
| 645 |
current = current->next; |
| 646 |
transition = current->data; |
| 647 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 648 |
assert_equals_uint64 (_START (transition), 500); |
| 649 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 650 |
|
| 651 |
current = current->next; |
| 652 |
transition = current->data; |
| 653 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 654 |
assert_equals_uint64 (_START (transition), 500); |
| 655 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 656 |
g_list_free_full (objects, gst_object_unref); |
| 657 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 658 |
|
| 659 |
GST_DEBUG ("Moving src3 to 1000. should remove transition"); |
| 660 |
ges_timeline_element_set_start (src3, 1000); |
| 661 |
|
| 662 |
/* 500__transition__1000 |
| 663 |
* 0___________src_________1000 |
| 664 |
* 500___________src1_________1500 Layer |
| 665 |
*---------------------------------------------------- |
| 666 |
* 0__________src2_________1000 |
| 667 |
* 1000___________src3_________2000 Layer1 |
| 668 |
*/ |
| 669 |
GST_DEBUG ("Checking src timing values"); |
| 670 |
assert_equals_uint64 (_START (src), 0); |
| 671 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 672 |
assert_equals_uint64 (_START (src1), 500); |
| 673 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 674 |
assert_equals_uint64 (_START (src2), 0); |
| 675 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 676 |
assert_equals_uint64 (_START (src3), 1000); |
| 677 |
assert_equals_uint64 (_DURATION (src3), 2000 - 1000); |
| 678 |
|
| 679 |
GST_DEBUG ("Checking transitions on first layer"); |
| 680 |
current = objects = ges_layer_get_clips (layer); |
| 681 |
assert_equals_int (g_list_length (objects), 4); |
| 682 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 683 |
|
| 684 |
current = current->next; |
| 685 |
transition = current->data; |
| 686 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 687 |
assert_equals_uint64 (_START (transition), 500); |
| 688 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 689 |
|
| 690 |
current = current->next; |
| 691 |
transition = current->data; |
| 692 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 693 |
assert_equals_uint64 (_START (transition), 500); |
| 694 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 695 |
g_list_free_full (objects, gst_object_unref); |
| 696 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 697 |
|
| 698 |
GST_DEBUG ("Checking transitions has been removed on second layer"); |
| 699 |
current = objects = ges_layer_get_clips (layer1); |
| 700 |
assert_equals_int (g_list_length (objects), 2); |
| 701 |
fail_unless (current->data == src2); |
| 702 |
fail_unless (current->next->data == src3); |
| 703 |
g_list_free_full (objects, gst_object_unref); |
| 704 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 705 |
|
| 706 |
GST_DEBUG ("Moving src3 to first layer, should add a transition"); |
| 707 |
ges_clip_move_to_layer (GES_CLIP (src3), layer); |
| 708 |
|
| 709 |
/* 500__transition__1000 |
| 710 |
* 0___________src_________1000 |
| 711 |
* 500___________src1_________1500 |
| 712 |
* 1000___________src3_________2000 Layer |
| 713 |
* 1000__tr__1500 |
| 714 |
*---------------------------------------------------- |
| 715 |
* 0__________src2_________1000 Layer1 |
| 716 |
*/ |
| 717 |
GST_DEBUG ("Checking src timing values"); |
| 718 |
assert_equals_uint64 (_START (src), 0); |
| 719 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 720 |
assert_equals_uint64 (_START (src1), 500); |
| 721 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 722 |
assert_equals_uint64 (_START (src2), 0); |
| 723 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 724 |
assert_equals_uint64 (_START (src3), 1000); |
| 725 |
assert_equals_uint64 (_DURATION (src3), 2000 - 1000); |
| 726 |
|
| 727 |
GST_DEBUG ("Checking transitions on first layer"); |
| 728 |
current = objects = ges_layer_get_clips (layer); |
| 729 |
assert_equals_int (g_list_length (objects), 7); |
| 730 |
fail_unless (current->data == src); |
| 731 |
|
| 732 |
current = current->next; |
| 733 |
transition = current->data; |
| 734 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 735 |
assert_equals_uint64 (_START (transition), 500); |
| 736 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 737 |
|
| 738 |
current = current->next; |
| 739 |
transition = current->data; |
| 740 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 741 |
assert_equals_uint64 (_START (transition), 500); |
| 742 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 743 |
|
| 744 |
current = current->next; |
| 745 |
fail_unless (current->data == src1); |
| 746 |
|
| 747 |
current = current->next; |
| 748 |
transition = current->data; |
| 749 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 750 |
assert_equals_uint64 (_START (transition), 1000); |
| 751 |
assert_equals_uint64 (_DURATION (transition), 1500 - 1000); |
| 752 |
|
| 753 |
current = current->next; |
| 754 |
transition = current->data; |
| 755 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 756 |
assert_equals_uint64 (_START (transition), 1000); |
| 757 |
assert_equals_uint64 (_DURATION (transition), 1500 - 1000); |
| 758 |
|
| 759 |
current = current->next; |
| 760 |
fail_unless (current->data == src3); |
| 761 |
|
| 762 |
g_list_free_full (objects, gst_object_unref); |
| 763 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 764 |
|
| 765 |
GST_DEBUG ("Checking second layer"); |
| 766 |
current = objects = ges_layer_get_clips (layer1); |
| 767 |
assert_equals_int (g_list_length (objects), 1); |
| 768 |
fail_unless (current->data == src2); |
| 769 |
g_list_free_full (objects, gst_object_unref); |
| 770 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 771 |
|
| 772 |
GST_DEBUG |
| 773 |
("Moving src to second layer, should remove first transition on first layer"); |
| 774 |
fail_if (ges_clip_move_to_layer (GES_CLIP (src), layer1)); |
| 775 |
|
| 776 |
/* 500___________src1_________1500 |
| 777 |
* 1000___________src3_________2000 Layer |
| 778 |
* 1000__tr__1500 |
| 779 |
*---------------------------------------------------- |
| 780 |
* 0___________src_________1000 |
| 781 |
* 0__________src2_________1000 Layer1 |
| 782 |
*/ |
| 783 |
GST_DEBUG ("Checking src timing values"); |
| 784 |
assert_equals_uint64 (_START (src), 0); |
| 785 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 786 |
assert_equals_uint64 (_START (src1), 500); |
| 787 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 788 |
assert_equals_uint64 (_START (src2), 0); |
| 789 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 790 |
assert_equals_uint64 (_START (src3), 1000); |
| 791 |
assert_equals_uint64 (_DURATION (src3), 2000 - 1000); |
| 792 |
|
| 793 |
GST_DEBUG ("Checking transitions on first layer"); |
| 794 |
current = objects = ges_layer_get_clips (layer); |
| 795 |
assert_equals_int (g_list_length (objects), 7); |
| 796 |
|
| 797 |
g_list_free_full (objects, gst_object_unref); |
| 798 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 799 |
|
| 800 |
GST_DEBUG ("Edit src to first layer start=1500"); |
| 801 |
ges_container_edit (GES_CONTAINER (src), NULL, 0, |
| 802 |
GES_EDIT_MODE_NORMAL, GES_EDGE_NONE, 1500); |
| 803 |
/* 1500___________src_________2500 |
| 804 |
* 1500______tr______2000 |
| 805 |
* 500___________src1_________1500 ^ |
| 806 |
* 1000_________^_src3_________2000 Layer |
| 807 |
* 1000__tr__1500 |
| 808 |
*--------------------------------------------------------------------------- |
| 809 |
* 0__________src2_________1000 Layer1 |
| 810 |
*/ |
| 811 |
GST_DEBUG ("Checking src timing values"); |
| 812 |
assert_equals_uint64 (_START (src), 1500); |
| 813 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 814 |
assert_equals_uint64 (_START (src1), 500); |
| 815 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 816 |
assert_equals_uint64 (_START (src2), 0); |
| 817 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 818 |
assert_equals_uint64 (_START (src3), 1000); |
| 819 |
assert_equals_uint64 (_DURATION (src3), 2000 - 1000); |
| 820 |
|
| 821 |
GST_DEBUG ("Checking transitions on first layer"); |
| 822 |
current = objects = ges_layer_get_clips (layer); |
| 823 |
assert_equals_int (g_list_length (objects), 7); |
| 824 |
fail_unless (current->data == src1); |
| 825 |
|
| 826 |
current = current->next; |
| 827 |
transition = current->data; |
| 828 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 829 |
assert_equals_uint64 (_START (transition), 1000); |
| 830 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 831 |
|
| 832 |
current = current->next; |
| 833 |
transition = current->data; |
| 834 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 835 |
assert_equals_uint64 (_START (transition), 1000); |
| 836 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 837 |
|
| 838 |
current = current->next; |
| 839 |
fail_unless (current->data == src3); |
| 840 |
|
| 841 |
current = current->next; |
| 842 |
transition = current->data; |
| 843 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 844 |
assert_equals_uint64 (_START (transition), 1500); |
| 845 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 846 |
|
| 847 |
current = current->next; |
| 848 |
transition = current->data; |
| 849 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 850 |
assert_equals_uint64 (_START (transition), 1500); |
| 851 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 852 |
|
| 853 |
current = current->next; |
| 854 |
fail_unless (current->data == src); |
| 855 |
g_list_free_full (objects, gst_object_unref); |
| 856 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 857 |
|
| 858 |
GST_DEBUG ("Checking second layer"); |
| 859 |
current = objects = ges_layer_get_clips (layer1); |
| 860 |
assert_equals_int (g_list_length (objects), 1); |
| 861 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 862 |
g_list_free_full (objects, gst_object_unref); |
| 863 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 864 |
|
| 865 |
GST_DEBUG ("Ripple src1 to 700"); |
| 866 |
ges_container_edit (GES_CONTAINER (src1), NULL, 0, |
| 867 |
GES_EDIT_MODE_RIPPLE, GES_EDGE_NONE, 700); |
| 868 |
|
| 869 |
/* 1700___________src_________2700 |
| 870 |
* 1700__tr__2000 |
| 871 |
* 700___________src1_________1700 |
| 872 |
* 1200___________src3_________2200 Layer |
| 873 |
* 1200___tr__1700 |
| 874 |
*--------------------------------------------------------------------------- |
| 875 |
* 0__________src2_________1000 Layer1 |
| 876 |
*/ |
| 877 |
GST_DEBUG ("Checking src timing values"); |
| 878 |
assert_equals_uint64 (_START (src), 1700); |
| 879 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 880 |
assert_equals_uint64 (_START (src1), 700); |
| 881 |
assert_equals_uint64 (_DURATION (src1), 1700 - 700); |
| 882 |
assert_equals_uint64 (_START (src2), 0); |
| 883 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 884 |
assert_equals_uint64 (_START (src3), 1200); |
| 885 |
assert_equals_uint64 (_DURATION (src3), 2200 - 1200); |
| 886 |
|
| 887 |
GST_DEBUG ("Checking transitions on first layer"); |
| 888 |
current = objects = ges_layer_get_clips (layer); |
| 889 |
assert_equals_int (g_list_length (objects), 7); |
| 890 |
fail_unless (current->data == src1); |
| 891 |
|
| 892 |
current = current->next; |
| 893 |
transition = current->data; |
| 894 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 895 |
assert_equals_uint64 (_START (transition), 1200); |
| 896 |
assert_equals_uint64 (_DURATION (transition), 1700 - 1200); |
| 897 |
|
| 898 |
current = current->next; |
| 899 |
transition = current->data; |
| 900 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 901 |
assert_equals_uint64 (_START (transition), 1200); |
| 902 |
assert_equals_uint64 (_DURATION (transition), 1700 - 1200); |
| 903 |
|
| 904 |
current = current->next; |
| 905 |
fail_unless (current->data == src3); |
| 906 |
|
| 907 |
current = current->next; |
| 908 |
transition = current->data; |
| 909 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 910 |
assert_equals_uint64 (_START (transition), 1700); |
| 911 |
assert_equals_uint64 (_DURATION (transition), 2200 - 1700); |
| 912 |
|
| 913 |
current = current->next; |
| 914 |
transition = current->data; |
| 915 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 916 |
assert_equals_uint64 (_START (transition), 1700); |
| 917 |
assert_equals_uint64 (_DURATION (transition), 2200 - 1700); |
| 918 |
|
| 919 |
current = current->next; |
| 920 |
fail_unless (current->data == src); |
| 921 |
g_list_free_full (objects, gst_object_unref); |
| 922 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 923 |
|
| 924 |
GST_DEBUG ("Checking second layer"); |
| 925 |
current = objects = ges_layer_get_clips (layer1); |
| 926 |
assert_equals_int (g_list_length (objects), 1); |
| 927 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 928 |
g_list_free_full (objects, gst_object_unref); |
| 929 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 930 |
|
| 931 |
gst_object_unref (timeline); |
| 932 |
gst_object_unref (asset); |
| 933 |
|
| 934 |
ges_deinit (); |
| 935 |
} |
| 936 |
|
| 937 |
GST_END_TEST; |
| 938 |
|
| 939 |
GST_START_TEST (test_layer_activate_automatic_transition) |
| 940 |
{ |
| 941 |
GESAsset *asset, *transition_asset; |
| 942 |
GESTimeline *timeline; |
| 943 |
GESLayer *layer; |
| 944 |
GList *objects, *current; |
| 945 |
GESClip *transition; |
| 946 |
GESTimelineElement *src, *src1, *src2, *src3; |
| 947 |
|
| 948 |
ges_init (); |
| 949 |
|
| 950 |
asset = ges_asset_request (GES_TYPE_TEST_CLIP, NULL, NULL); |
| 951 |
transition_asset = |
| 952 |
ges_asset_request (GES_TYPE_TRANSITION_CLIP, "crossfade", NULL); |
| 953 |
fail_unless (GES_IS_ASSET (asset)); |
| 954 |
|
| 955 |
GST_DEBUG ("Create timeline"); |
| 956 |
timeline = ges_timeline_new_audio_video (); |
| 957 |
assert_is_type (timeline, GES_TYPE_TIMELINE); |
| 958 |
|
| 959 |
GST_DEBUG ("Append a layer to the timeline"); |
| 960 |
layer = ges_timeline_append_layer (timeline); |
| 961 |
assert_is_type (layer, GES_TYPE_LAYER); |
| 962 |
|
| 963 |
GST_DEBUG ("Adding clip from 0 -- 1000 to layer"); |
| 964 |
src = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 0, 0, |
| 965 |
1000, GES_TRACK_TYPE_UNKNOWN)); |
| 966 |
fail_unless (GES_IS_CLIP (src)); |
| 967 |
|
| 968 |
GST_DEBUG ("Adding clip from 500 -- 1000 to first layer"); |
| 969 |
src1 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 500, |
| 970 |
0, 1000, GES_TRACK_TYPE_UNKNOWN)); |
| 971 |
fail_unless (GES_IS_CLIP (src1)); |
| 972 |
|
| 973 |
GST_DEBUG ("Adding clip from 1000 -- 2000 to layer"); |
| 974 |
src2 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 1000, |
| 975 |
0, 1000, GES_TRACK_TYPE_UNKNOWN)); |
| 976 |
fail_unless (GES_IS_CLIP (src2)); |
| 977 |
|
| 978 |
GST_DEBUG ("Adding clip from 2000 -- 2500 to layer"); |
| 979 |
src3 = GES_TIMELINE_ELEMENT (ges_layer_add_asset (layer, asset, 2000, |
| 980 |
0, 500, GES_TRACK_TYPE_UNKNOWN)); |
| 981 |
fail_unless (GES_IS_CLIP (src3)); |
| 982 |
|
| 983 |
/* |
| 984 |
* 0___________src_________1000 |
| 985 |
* 500___________src1_________1500 |
| 986 |
* 1000____src2_______2000 |
| 987 |
* 2000_______src2_____2500 |
| 988 |
*/ |
| 989 |
GST_DEBUG ("Checking src timing values"); |
| 990 |
assert_equals_uint64 (_START (src), 0); |
| 991 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 992 |
assert_equals_uint64 (_START (src1), 500); |
| 993 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 994 |
assert_equals_uint64 (_START (src2), 1000); |
| 995 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 996 |
assert_equals_uint64 (_START (src3), 2000); |
| 997 |
assert_equals_uint64 (_DURATION (src3), 500); |
| 998 |
|
| 999 |
GST_DEBUG ("Checking that no transition has been added"); |
| 1000 |
current = objects = ges_layer_get_clips (layer); |
| 1001 |
assert_equals_int (g_list_length (objects), 4); |
| 1002 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 1003 |
g_list_free_full (objects, gst_object_unref); |
| 1004 |
|
| 1005 |
GST_DEBUG ("Adding transition from 1000 -- 1500 to layer"); |
| 1006 |
transition = |
| 1007 |
GES_CLIP (ges_layer_add_asset (layer, |
| 1008 |
transition_asset, 1000, 0, 500, GES_TRACK_TYPE_VIDEO)); |
| 1009 |
g_object_unref (transition_asset); |
| 1010 |
fail_unless (GES_IS_TRANSITION_CLIP (transition)); |
| 1011 |
objects = GES_CONTAINER_CHILDREN (transition); |
| 1012 |
assert_equals_int (g_list_length (objects), 1); |
| 1013 |
|
| 1014 |
GST_DEBUG ("Checking the transitions"); |
| 1015 |
/* |
| 1016 |
* 0___________src_________1000 |
| 1017 |
* 500___________src1_________1500 |
| 1018 |
* 1000__tr__1500 (1 of the 2 tracks only) |
| 1019 |
* 1000____src2_______2000 |
| 1020 |
* 2000_______src3_____2500 |
| 1021 |
*/ |
| 1022 |
current = objects = ges_layer_get_clips (layer); |
| 1023 |
assert_equals_int (g_list_length (objects), 5); |
| 1024 |
current = current->next; |
| 1025 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 1026 |
current = current->next; |
| 1027 |
assert_is_type (current->data, GES_TYPE_TRANSITION_CLIP); |
| 1028 |
current = current->next; |
| 1029 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 1030 |
current = current->next; |
| 1031 |
assert_is_type (current->data, GES_TYPE_TEST_CLIP); |
| 1032 |
g_list_free_full (objects, gst_object_unref); |
| 1033 |
|
| 1034 |
ges_layer_set_auto_transition (layer, TRUE); |
| 1035 |
/* |
| 1036 |
* 0___________src_________1000 |
| 1037 |
* 500______tr______1000 |
| 1038 |
* 500___________src1_________1500 |
| 1039 |
* 1000__tr__1500 |
| 1040 |
* 1000____src2_______2000 |
| 1041 |
* 2000_______src3_____2500 |
| 1042 |
*/ |
| 1043 |
current = objects = ges_layer_get_clips (layer); |
| 1044 |
assert_equals_int (g_list_length (objects), 8); |
| 1045 |
assert_equals_uint64 (_START (src), 0); |
| 1046 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 1047 |
assert_equals_uint64 (_START (src1), 500); |
| 1048 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 1049 |
assert_equals_uint64 (_START (src2), 1000); |
| 1050 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 1051 |
assert_equals_uint64 (_START (src3), 2000); |
| 1052 |
assert_equals_uint64 (_DURATION (src3), 500); |
| 1053 |
|
| 1054 |
GST_DEBUG ("Checking transitions"); |
| 1055 |
fail_unless (current->data == src); |
| 1056 |
|
| 1057 |
current = current->next; |
| 1058 |
transition = current->data; |
| 1059 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1060 |
assert_equals_uint64 (_START (transition), 500); |
| 1061 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 1062 |
|
| 1063 |
current = current->next; |
| 1064 |
transition = current->data; |
| 1065 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1066 |
assert_equals_uint64 (_START (transition), 500); |
| 1067 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 1068 |
|
| 1069 |
current = current->next; |
| 1070 |
fail_unless (current->data == src1); |
| 1071 |
|
| 1072 |
current = current->next; |
| 1073 |
transition = current->data; |
| 1074 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1075 |
assert_equals_uint64 (_START (transition), 1000); |
| 1076 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 1077 |
|
| 1078 |
current = current->next; |
| 1079 |
transition = current->data; |
| 1080 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1081 |
assert_equals_uint64 (_START (transition), 1000); |
| 1082 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 1083 |
|
| 1084 |
current = current->next; |
| 1085 |
fail_unless (current->data == src2); |
| 1086 |
|
| 1087 |
current = current->next; |
| 1088 |
fail_unless (current->data == src3); |
| 1089 |
g_list_free_full (objects, gst_object_unref); |
| 1090 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 1091 |
|
| 1092 |
GST_DEBUG ("Moving src2 to 1200, check everything updates properly"); |
| 1093 |
ges_timeline_element_set_start (src2, 1200); |
| 1094 |
ges_timeline_commit (timeline); |
| 1095 |
/* |
| 1096 |
* 0___________src_________1000 |
| 1097 |
* 500______tr______1000 |
| 1098 |
* 500___________src1_________1500 |
| 1099 |
* 1200_tr_1500 |
| 1100 |
* 1200____src2_______2200 |
| 1101 |
* !__tr__^ |
| 1102 |
* 2000_______src3_____2500 |
| 1103 |
*/ |
| 1104 |
current = objects = ges_layer_get_clips (layer); |
| 1105 |
assert_equals_int (g_list_length (objects), 10); |
| 1106 |
assert_equals_uint64 (_START (src), 0); |
| 1107 |
assert_equals_uint64 (_DURATION (src), 1000); |
| 1108 |
assert_equals_uint64 (_START (src1), 500); |
| 1109 |
assert_equals_uint64 (_DURATION (src1), 1500 - 500); |
| 1110 |
assert_equals_uint64 (_START (src2), 1200); |
| 1111 |
assert_equals_uint64 (_DURATION (src2), 1000); |
| 1112 |
assert_equals_uint64 (_START (src3), 2000); |
| 1113 |
assert_equals_uint64 (_DURATION (src3), 500); |
| 1114 |
|
| 1115 |
GST_DEBUG ("Checking transitions"); |
| 1116 |
fail_unless (current->data == src); |
| 1117 |
|
| 1118 |
current = current->next; |
| 1119 |
transition = current->data; |
| 1120 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1121 |
assert_equals_uint64 (_START (transition), 500); |
| 1122 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 1123 |
|
| 1124 |
current = current->next; |
| 1125 |
transition = current->data; |
| 1126 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1127 |
assert_equals_uint64 (_START (transition), 500); |
| 1128 |
assert_equals_uint64 (_DURATION (transition), 500); |
| 1129 |
|
| 1130 |
current = current->next; |
| 1131 |
fail_unless (current->data == src1); |
| 1132 |
|
| 1133 |
current = current->next; |
| 1134 |
transition = current->data; |
| 1135 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1136 |
assert_equals_uint64 (_START (transition), 1200); |
| 1137 |
assert_equals_uint64 (_DURATION (transition), 300); |
| 1138 |
|
| 1139 |
current = current->next; |
| 1140 |
transition = current->data; |
| 1141 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1142 |
assert_equals_uint64 (_START (transition), 1200); |
| 1143 |
assert_equals_uint64 (_DURATION (transition), 300); |
| 1144 |
|
| 1145 |
current = current->next; |
| 1146 |
fail_unless (current->data == src2); |
| 1147 |
|
| 1148 |
current = current->next; |
| 1149 |
transition = current->data; |
| 1150 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1151 |
assert_equals_uint64 (_START (transition), 2000); |
| 1152 |
assert_equals_uint64 (_DURATION (transition), 200); |
| 1153 |
|
| 1154 |
current = current->next; |
| 1155 |
transition = current->data; |
| 1156 |
assert_is_type (transition, GES_TYPE_TRANSITION_CLIP); |
| 1157 |
assert_equals_uint64 (_START (transition), 2000); |
| 1158 |
assert_equals_uint64 (_DURATION (transition), 200); |
| 1159 |
|
| 1160 |
current = current->next; |
| 1161 |
fail_unless (current->data == src3); |
| 1162 |
g_list_free_full (objects, gst_object_unref); |
| 1163 |
ASSERT_OBJECT_REFCOUNT (transition, "layer + timeline", 2); |
| 1164 |
|
| 1165 |
|
| 1166 |
gst_object_unref (timeline); |
| 1167 |
gst_object_unref (asset); |
| 1168 |
|
| 1169 |
ges_deinit (); |
| 1170 |
} |
| 1171 |
|
| 1172 |
GST_END_TEST; |
| 1173 |
|
| 1174 |
GST_START_TEST (test_layer_meta_string) |
| 1175 |
{ |
| 1176 |
GESTimeline *timeline; |
| 1177 |
GESLayer *layer; |
| 1178 |
const gchar *result; |
| 1179 |
|
| 1180 |
ges_init (); |
| 1181 |
|
| 1182 |
timeline = ges_timeline_new_audio_video (); |
| 1183 |
layer = ges_layer_new (); |
| 1184 |
ges_timeline_add_layer (timeline, layer); |
| 1185 |
|
| 1186 |
ges_meta_container_set_string (GES_META_CONTAINER (layer), |
| 1187 |
"ges-test", "blub"); |
| 1188 |
|
| 1189 |
fail_unless ((result = ges_meta_container_get_string (GES_META_CONTAINER |
| 1190 |
(layer), "ges-test")) != NULL); |
| 1191 |
|
| 1192 |
assert_equals_string (result, "blub"); |
| 1193 |
|
| 1194 |
gst_object_unref (timeline); |
| 1195 |
|
| 1196 |
ges_deinit (); |
| 1197 |
} |
| 1198 |
|
| 1199 |
GST_END_TEST; |
| 1200 |
|
| 1201 |
GST_START_TEST (test_layer_meta_boolean) |
| 1202 |
{ |
| 1203 |
GESTimeline *timeline; |
| 1204 |
GESLayer *layer; |
| 1205 |
gboolean result; |
| 1206 |
|
| 1207 |
ges_init (); |
| 1208 |
|
| 1209 |
timeline = ges_timeline_new_audio_video (); |
| 1210 |
layer = ges_layer_new (); |
| 1211 |
ges_timeline_add_layer (timeline, layer); |
| 1212 |
|
| 1213 |
ges_meta_container_set_boolean (GES_META_CONTAINER (layer), "ges-test", TRUE); |
| 1214 |
|
| 1215 |
fail_unless (ges_meta_container_get_boolean (GES_META_CONTAINER |
| 1216 |
(layer), "ges-test", &result)); |
| 1217 |
|
| 1218 |
fail_unless (result); |
| 1219 |
|
| 1220 |
gst_object_unref (timeline); |
| 1221 |
|
| 1222 |
ges_deinit (); |
| 1223 |
} |
| 1224 |
|
| 1225 |
GST_END_TEST; |
| 1226 |
|
| 1227 |
GST_START_TEST (test_layer_meta_int) |
| 1228 |
{ |
| 1229 |
GESTimeline *timeline; |
| 1230 |
GESLayer *layer; |
| 1231 |
gint result; |
| 1232 |
|
| 1233 |
ges_init (); |
| 1234 |
|
| 1235 |
timeline = ges_timeline_new_audio_video (); |
| 1236 |
layer = ges_layer_new (); |
| 1237 |
ges_timeline_add_layer (timeline, layer); |
| 1238 |
|
| 1239 |
ges_meta_container_set_int (GES_META_CONTAINER (layer), "ges-test", 1234); |
| 1240 |
|
| 1241 |
fail_unless (ges_meta_container_get_int (GES_META_CONTAINER (layer), |
| 1242 |
"ges-test", &result)); |
| 1243 |
|
| 1244 |
assert_equals_int (result, 1234); |
| 1245 |
|
| 1246 |
gst_object_unref (timeline); |
| 1247 |
|
| 1248 |
ges_deinit (); |
| 1249 |
} |
| 1250 |
|
| 1251 |
GST_END_TEST; |
| 1252 |
|
| 1253 |
GST_START_TEST (test_layer_meta_uint) |
| 1254 |
{ |
| 1255 |
GESTimeline *timeline; |
| 1256 |
GESLayer *layer; |
| 1257 |
guint result; |
| 1258 |
|
| 1259 |
ges_init (); |
| 1260 |
|
| 1261 |
timeline = ges_timeline_new_audio_video (); |
| 1262 |
layer = ges_layer_new (); |
| 1263 |
ges_timeline_add_layer (timeline, layer); |
| 1264 |
|
| 1265 |
ges_meta_container_set_uint (GES_META_CONTAINER (layer), "ges-test", 42); |
| 1266 |
|
| 1267 |
fail_unless (ges_meta_container_get_uint (GES_META_CONTAINER |
| 1268 |
(layer), "ges-test", &result)); |
| 1269 |
|
| 1270 |
assert_equals_int (result, 42); |
| 1271 |
|
| 1272 |
gst_object_unref (timeline); |
| 1273 |
|
| 1274 |
ges_deinit (); |
| 1275 |
} |
| 1276 |
|
| 1277 |
GST_END_TEST; |
| 1278 |
|
| 1279 |
GST_START_TEST (test_layer_meta_int64) |
| 1280 |
{ |
| 1281 |
GESTimeline *timeline; |
| 1282 |
GESLayer *layer; |
| 1283 |
gint64 result; |
| 1284 |
|
| 1285 |
ges_init (); |
| 1286 |
|
| 1287 |
timeline = ges_timeline_new_audio_video (); |
| 1288 |
layer = ges_layer_new (); |
| 1289 |
ges_timeline_add_layer (timeline, layer); |
| 1290 |
|
| 1291 |
ges_meta_container_set_int64 (GES_META_CONTAINER (layer), "ges-test", 1234); |
| 1292 |
|
| 1293 |
fail_unless (ges_meta_container_get_int64 (GES_META_CONTAINER (layer), |
| 1294 |
"ges-test", &result)); |
| 1295 |
|
| 1296 |
assert_equals_int64 (result, 1234); |
| 1297 |
|
| 1298 |
gst_object_unref (timeline); |
| 1299 |
|
| 1300 |
ges_deinit (); |
| 1301 |
} |
| 1302 |
|
| 1303 |
GST_END_TEST; |
| 1304 |
|
| 1305 |
GST_START_TEST (test_layer_meta_uint64) |
| 1306 |
{ |
| 1307 |
GESTimeline *timeline; |
| 1308 |
GESLayer *layer; |
| 1309 |
guint64 result; |
| 1310 |
|
| 1311 |
ges_init (); |
| 1312 |
|
| 1313 |
timeline = ges_timeline_new_audio_video (); |
| 1314 |
layer = ges_layer_new (); |
| 1315 |
ges_timeline_add_layer (timeline, layer); |
| 1316 |
|
| 1317 |
ges_meta_container_set_uint64 (GES_META_CONTAINER (layer), "ges-test", 42); |
| 1318 |
|
| 1319 |
fail_unless (ges_meta_container_get_uint64 (GES_META_CONTAINER |
| 1320 |
(layer), "ges-test", &result)); |
| 1321 |
|
| 1322 |
assert_equals_uint64 (result, 42); |
| 1323 |
|
| 1324 |
gst_object_unref (timeline); |
| 1325 |
|
| 1326 |
ges_deinit (); |
| 1327 |
} |
| 1328 |
|
| 1329 |
GST_END_TEST; |
| 1330 |
|
| 1331 |
GST_START_TEST (test_layer_meta_float) |
| 1332 |
{ |
| 1333 |
GESTimeline *timeline; |
| 1334 |
GESLayer *layer; |
| 1335 |
gfloat result; |
| 1336 |
|
| 1337 |
ges_init (); |
| 1338 |
|
| 1339 |
timeline = ges_timeline_new_audio_video (); |
| 1340 |
layer = ges_layer_new (); |
| 1341 |
ges_timeline_add_layer (timeline, layer); |
| 1342 |
|
| 1343 |
fail_unless (ges_meta_container_set_float (GES_META_CONTAINER (layer), |
| 1344 |
"ges-test", 23.456)); |
| 1345 |
|
| 1346 |
fail_unless (ges_meta_container_get_float (GES_META_CONTAINER (layer), |
| 1347 |
"ges-test", &result)); |
| 1348 |
|
| 1349 |
assert_equals_float (result, 23.456f); |
| 1350 |
|
| 1351 |
gst_object_unref (timeline); |
| 1352 |
|
| 1353 |
ges_deinit (); |
| 1354 |
} |
| 1355 |
|
| 1356 |
GST_END_TEST; |
| 1357 |
|
| 1358 |
GST_START_TEST (test_layer_meta_double) |
| 1359 |
{ |
| 1360 |
GESTimeline *timeline; |
| 1361 |
GESLayer *layer; |
| 1362 |
gdouble result; |
| 1363 |
|
| 1364 |
ges_init (); |
| 1365 |
|
| 1366 |
timeline = ges_timeline_new_audio_video (); |
| 1367 |
layer = ges_layer_new (); |
| 1368 |
ges_timeline_add_layer (timeline, layer); |
| 1369 |
|
| 1370 |
ges_meta_container_set_double (GES_META_CONTAINER (layer), |
| 1371 |
"ges-test", 23.456); |
| 1372 |
|
| 1373 |
fail_unless (ges_meta_container_get_double (GES_META_CONTAINER |
| 1374 |
(layer), "ges-test", &result)); |
| 1375 |
fail_unless (result == 23.456); |
| 1376 |
|
| 1377 |
//TODO CHECK |
| 1378 |
assert_equals_float (result, 23.456); |
| 1379 |
|
| 1380 |
gst_object_unref (timeline); |
| 1381 |
|
| 1382 |
ges_deinit (); |
| 1383 |
} |
| 1384 |
|
| 1385 |
GST_END_TEST; |
| 1386 |
|
| 1387 |
GST_START_TEST (test_layer_meta_date) |
| 1388 |
{ |
| 1389 |
GESTimeline *timeline; |
| 1390 |
GESLayer *layer; |
| 1391 |
GDate *input; |
| 1392 |
GDate *result; |
| 1393 |
|
| 1394 |
ges_init (); |
| 1395 |
|
| 1396 |
timeline = ges_timeline_new_audio_video (); |
| 1397 |
layer = ges_layer_new (); |
| 1398 |
ges_timeline_add_layer (timeline, layer); |
| 1399 |
|
| 1400 |
input = g_date_new_dmy (1, 1, 2012); |
| 1401 |
|
| 1402 |
ges_meta_container_set_date (GES_META_CONTAINER (layer), "ges-test", input); |
| 1403 |
|
| 1404 |
fail_unless (ges_meta_container_get_date (GES_META_CONTAINER |
| 1405 |
(layer), "ges-test", &result)); |
| 1406 |
|
| 1407 |
fail_unless (g_date_compare (result, input) == 0); |
| 1408 |
|
| 1409 |
g_date_free (input); |
| 1410 |
g_date_free (result); |
| 1411 |
|
| 1412 |
gst_object_unref (timeline); |
| 1413 |
|
| 1414 |
ges_deinit (); |
| 1415 |
} |
| 1416 |
|
| 1417 |
GST_END_TEST; |
| 1418 |
|
| 1419 |
GST_START_TEST (test_layer_meta_date_time) |
| 1420 |
{ |
| 1421 |
GESTimeline *timeline; |
| 1422 |
GESLayer *layer; |
| 1423 |
GstDateTime *input; |
| 1424 |
GstDateTime *result = NULL; |
| 1425 |
|
| 1426 |
ges_init (); |
| 1427 |
|
| 1428 |
timeline = ges_timeline_new_audio_video (); |
| 1429 |
layer = ges_layer_new (); |
| 1430 |
ges_timeline_add_layer (timeline, layer); |
| 1431 |
|
| 1432 |
input = gst_date_time_new_from_unix_epoch_local_time (123456789); |
| 1433 |
|
| 1434 |
fail_unless (ges_meta_container_set_date_time (GES_META_CONTAINER |
| 1435 |
(layer), "ges-test", input)); |
| 1436 |
|
| 1437 |
fail_unless (ges_meta_container_get_date_time (GES_META_CONTAINER |
| 1438 |
(layer), "ges-test", &result)); |
| 1439 |
|
| 1440 |
fail_unless (result != NULL); |
| 1441 |
fail_unless (gst_date_time_get_day (input) == gst_date_time_get_day (result)); |
| 1442 |
fail_unless (gst_date_time_get_hour (input) == |
| 1443 |
gst_date_time_get_hour (result)); |
| 1444 |
|
| 1445 |
gst_date_time_unref (input); |
| 1446 |
gst_date_time_unref (result); |
| 1447 |
|
| 1448 |
gst_object_unref (timeline); |
| 1449 |
|
| 1450 |
ges_deinit (); |
| 1451 |
} |
| 1452 |
|
| 1453 |
GST_END_TEST; |
| 1454 |
|
| 1455 |
|
| 1456 |
GST_START_TEST (test_layer_meta_value) |
| 1457 |
{ |
| 1458 |
GESTimeline *timeline; |
| 1459 |
GESLayer *layer; |
| 1460 |
GValue data = G_VALUE_INIT; |
| 1461 |
const GValue *result; |
| 1462 |
|
| 1463 |
ges_init (); |
| 1464 |
|
| 1465 |
timeline = ges_timeline_new_audio_video (); |
| 1466 |
layer = ges_layer_new (); |
| 1467 |
ges_timeline_add_layer (timeline, layer); |
| 1468 |
|
| 1469 |
g_value_init (&data, G_TYPE_STRING); |
| 1470 |
g_value_set_string (&data, "Hello world!"); |
| 1471 |
|
| 1472 |
ges_meta_container_set_meta (GES_META_CONTAINER (layer), |
| 1473 |
"ges-test-value", &data); |
| 1474 |
|
| 1475 |
result = |
| 1476 |
ges_meta_container_get_meta (GES_META_CONTAINER (layer), |
| 1477 |
"ges-test-value"); |
| 1478 |
assert_equals_string (g_value_get_string (result), "Hello world!"); |
| 1479 |
|
| 1480 |
g_value_unset (&data); |
| 1481 |
|
| 1482 |
gst_object_unref (timeline); |
| 1483 |
|
| 1484 |
ges_deinit (); |
| 1485 |
} |
| 1486 |
|
| 1487 |
GST_END_TEST; |
| 1488 |
|
| 1489 |
|
| 1490 |
GST_START_TEST (test_layer_meta_marker_list) |
| 1491 |
{ |
| 1492 |
GESTimeline *timeline; |
| 1493 |
GESLayer *layer, *layer2; |
| 1494 |
GESMarkerList *mlist, *mlist2; |
| 1495 |
GESMarker *marker; |
| 1496 |
gchar *metas1, *metas2; |
| 1497 |
|
| 1498 |
ges_init (); |
| 1499 |
|
| 1500 |
timeline = ges_timeline_new_audio_video (); |
| 1501 |
layer = ges_layer_new (); |
| 1502 |
ges_timeline_add_layer (timeline, layer); |
| 1503 |
layer2 = ges_layer_new (); |
| 1504 |
ges_timeline_add_layer (timeline, layer2); |
| 1505 |
|
| 1506 |
mlist = ges_marker_list_new (); |
| 1507 |
marker = ges_marker_list_add (mlist, 42); |
| 1508 |
ges_meta_container_set_string (GES_META_CONTAINER (marker), "bar", "baz"); |
| 1509 |
marker = ges_marker_list_add (mlist, 84); |
| 1510 |
ges_meta_container_set_string (GES_META_CONTAINER (marker), "lorem", |
| 1511 |
"ip\tsu\"m;"); |
| 1512 |
|
| 1513 |
ASSERT_OBJECT_REFCOUNT (mlist, "local ref", 1); |
| 1514 |
|
| 1515 |
fail_unless (ges_meta_container_set_marker_list (GES_META_CONTAINER (layer), |
| 1516 |
"foo", mlist)); |
| 1517 |
|
| 1518 |
ASSERT_OBJECT_REFCOUNT (mlist, "GstStructure + local ref", 2); |
| 1519 |
|
| 1520 |
mlist2 = |
| 1521 |
ges_meta_container_get_marker_list (GES_META_CONTAINER (layer), "foo"); |
| 1522 |
|
| 1523 |
fail_unless (mlist == mlist2); |
| 1524 |
|
| 1525 |
ASSERT_OBJECT_REFCOUNT (mlist, "GstStructure + getter + local ref", 3); |
| 1526 |
|
| 1527 |
g_object_unref (mlist2); |
| 1528 |
|
| 1529 |
ASSERT_OBJECT_REFCOUNT (mlist, "GstStructure + local ref", 2); |
| 1530 |
|
| 1531 |
metas1 = ges_meta_container_metas_to_string (GES_META_CONTAINER (layer)); |
| 1532 |
ges_meta_container_add_metas_from_string (GES_META_CONTAINER (layer2), |
| 1533 |
metas1); |
| 1534 |
metas2 = ges_meta_container_metas_to_string (GES_META_CONTAINER (layer2)); |
| 1535 |
|
| 1536 |
fail_unless_equals_string (metas1, metas2); |
| 1537 |
g_free (metas1); |
| 1538 |
g_free (metas2); |
| 1539 |
|
| 1540 |
fail_unless (ges_meta_container_set_marker_list (GES_META_CONTAINER (layer), |
| 1541 |
"foo", NULL)); |
| 1542 |
|
| 1543 |
ASSERT_OBJECT_REFCOUNT (mlist, "local ref", 1); |
| 1544 |
|
| 1545 |
g_object_unref (mlist); |
| 1546 |
g_object_unref (timeline); |
| 1547 |
|
| 1548 |
ges_deinit (); |
| 1549 |
} |
| 1550 |
|
| 1551 |
GST_END_TEST; |
| 1552 |
|
| 1553 |
GST_START_TEST (test_layer_meta_register) |
| 1554 |
{ |
| 1555 |
GESTimeline *timeline; |
| 1556 |
GESLayer *layer; |
| 1557 |
const gchar *result; |
| 1558 |
|
| 1559 |
ges_init (); |
| 1560 |
|
| 1561 |
timeline = ges_timeline_new_audio_video (); |
| 1562 |
layer = ges_layer_new (); |
| 1563 |
ges_timeline_add_layer (timeline, layer); |
| 1564 |
|
| 1565 |
fail_unless (ges_meta_container_register_meta_string (GES_META_CONTAINER |
| 1566 |
(layer), GES_META_READABLE, "ges-test-value", "Hello world!")); |
| 1567 |
|
| 1568 |
result = ges_meta_container_get_string (GES_META_CONTAINER (layer), |
| 1569 |
"ges-test-value"); |
| 1570 |
assert_equals_string (result, "Hello world!"); |
| 1571 |
|
| 1572 |
fail_if (ges_meta_container_set_int (GES_META_CONTAINER (layer), |
| 1573 |
"ges-test-value", 123456)); |
| 1574 |
|
| 1575 |
result = ges_meta_container_get_string (GES_META_CONTAINER (layer), |
| 1576 |
"ges-test-value"); |
| 1577 |
assert_equals_string (result, "Hello world!"); |
| 1578 |
|
| 1579 |
gst_object_unref (timeline); |
| 1580 |
|
| 1581 |
ges_deinit (); |
| 1582 |
} |
| 1583 |
|
| 1584 |
GST_END_TEST; |
| 1585 |
|
| 1586 |
static void |
| 1587 |
test_foreach (const GESMetaContainer * container, const gchar * key, |
| 1588 |
GValue * value, gpointer user_data) |
| 1589 |
{ |
| 1590 |
fail_unless ((0 == g_strcmp0 (key, "some-string")) || |
| 1591 |
(0 == g_strcmp0 (key, "some-int")) || (0 == g_strcmp0 (key, "volume"))); |
| 1592 |
} |
| 1593 |
|
| 1594 |
GST_START_TEST (test_layer_meta_foreach) |
| 1595 |
{ |
| 1596 |
GESTimeline *timeline; |
| 1597 |
GESLayer *layer; |
| 1598 |
|
| 1599 |
ges_init (); |
| 1600 |
|
| 1601 |
timeline = ges_timeline_new_audio_video (); |
| 1602 |
layer = ges_layer_new (); |
| 1603 |
ges_timeline_add_layer (timeline, layer); |
| 1604 |
|
| 1605 |
ges_meta_container_set_string (GES_META_CONTAINER (layer), |
| 1606 |
"some-string", "some-content"); |
| 1607 |
|
| 1608 |
ges_meta_container_set_int (GES_META_CONTAINER (layer), "some-int", 123456); |
| 1609 |
|
| 1610 |
ges_meta_container_foreach (GES_META_CONTAINER (layer), |
| 1611 |
(GESMetaForeachFunc) test_foreach, NULL); |
| 1612 |
|
| 1613 |
gst_object_unref (timeline); |
| 1614 |
|
| 1615 |
ges_deinit (); |
| 1616 |
} |
| 1617 |
|
| 1618 |
GST_END_TEST; |
| 1619 |
|
| 1620 |
GST_START_TEST (test_layer_get_clips_in_interval) |
| 1621 |
{ |
| 1622 |
GESTimeline *timeline; |
| 1623 |
GESLayer *layer; |
| 1624 |
GESClip *clip, *clip2, *clip3; |
| 1625 |
GList *objects, *current; |
| 1626 |
|
| 1627 |
ges_init (); |
| 1628 |
|
| 1629 |
timeline = ges_timeline_new_audio_video (); |
| 1630 |
layer = ges_layer_new (); |
| 1631 |
ges_timeline_add_layer (timeline, layer); |
| 1632 |
|
| 1633 |
clip = (GESClip *) ges_test_clip_new (); |
| 1634 |
fail_unless (clip != NULL); |
| 1635 |
g_object_set (clip, "start", (guint64) 10, "duration", (gint64) 30, NULL); |
| 1636 |
assert_equals_uint64 (_START (clip), 10); |
| 1637 |
assert_equals_uint64 (_DURATION (clip), 30); |
| 1638 |
|
| 1639 |
ges_layer_add_clip (layer, GES_CLIP (clip)); |
| 1640 |
|
| 1641 |
/* Clip's start lies between the interval */ |
| 1642 |
current = objects = ges_layer_get_clips_in_interval (layer, 0, 30); |
| 1643 |
assert_equals_int (g_list_length (objects), 1); |
| 1644 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1645 |
g_list_free_full (objects, gst_object_unref); |
| 1646 |
|
| 1647 |
current = objects = ges_layer_get_clips_in_interval (layer, 0, 11); |
| 1648 |
assert_equals_int (g_list_length (objects), 1); |
| 1649 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1650 |
g_list_free_full (objects, gst_object_unref); |
| 1651 |
|
| 1652 |
/* Clip's end lies between the interval */ |
| 1653 |
current = objects = ges_layer_get_clips_in_interval (layer, 30, 50); |
| 1654 |
assert_equals_int (g_list_length (objects), 1); |
| 1655 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1656 |
g_list_free_full (objects, gst_object_unref); |
| 1657 |
|
| 1658 |
current = objects = ges_layer_get_clips_in_interval (layer, 39, 50); |
| 1659 |
assert_equals_int (g_list_length (objects), 1); |
| 1660 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1661 |
g_list_free_full (objects, gst_object_unref); |
| 1662 |
|
| 1663 |
/* Clip exactly overlaps the interval */ |
| 1664 |
current = objects = ges_layer_get_clips_in_interval (layer, 10, 40); |
| 1665 |
assert_equals_int (g_list_length (objects), 1); |
| 1666 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1667 |
g_list_free_full (objects, gst_object_unref); |
| 1668 |
|
| 1669 |
/* Clip completely inside the interval */ |
| 1670 |
current = objects = ges_layer_get_clips_in_interval (layer, 0, 50); |
| 1671 |
assert_equals_int (g_list_length (objects), 1); |
| 1672 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1673 |
g_list_free_full (objects, gst_object_unref); |
| 1674 |
|
| 1675 |
/* Interval completely inside the clip duration */ |
| 1676 |
current = objects = ges_layer_get_clips_in_interval (layer, 20, 30); |
| 1677 |
assert_equals_int (g_list_length (objects), 1); |
| 1678 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1679 |
g_list_free_full (objects, gst_object_unref); |
| 1680 |
|
| 1681 |
/* No intersecting clip */ |
| 1682 |
objects = ges_layer_get_clips_in_interval (layer, 0, 10); |
| 1683 |
assert_equals_int (g_list_length (objects), 0); |
| 1684 |
|
| 1685 |
objects = ges_layer_get_clips_in_interval (layer, 40, 50); |
| 1686 |
assert_equals_int (g_list_length (objects), 0); |
| 1687 |
|
| 1688 |
/* Multiple intersecting clips */ |
| 1689 |
clip2 = (GESClip *) ges_test_clip_new (); |
| 1690 |
fail_unless (clip2 != NULL); |
| 1691 |
g_object_set (clip2, "start", (guint64) 50, "duration", (gint64) 10, NULL); |
| 1692 |
assert_equals_uint64 (_START (clip2), 50); |
| 1693 |
assert_equals_uint64 (_DURATION (clip2), 10); |
| 1694 |
|
| 1695 |
ges_layer_add_clip (layer, GES_CLIP (clip2)); |
| 1696 |
|
| 1697 |
clip3 = (GESClip *) ges_test_clip_new (); |
| 1698 |
fail_unless (clip3 != NULL); |
| 1699 |
g_object_set (clip3, "start", (guint64) 0, "duration", (gint64) 5, NULL); |
| 1700 |
assert_equals_uint64 (_START (clip3), 0); |
| 1701 |
assert_equals_uint64 (_DURATION (clip3), 5); |
| 1702 |
|
| 1703 |
ges_layer_add_clip (layer, GES_CLIP (clip3)); |
| 1704 |
|
| 1705 |
/** |
| 1706 |
* Our timeline: |
| 1707 |
* ------------- |
| 1708 |
* |
| 1709 |
* |-------- 0--------------- 0--------- | |
| 1710 |
* layer: | clip3 | | clip | | clip2 | | |
| 1711 |
* |-------05 10-------------40 50--------60 | |
| 1712 |
* |--------------------------------------------------| |
| 1713 |
* |
| 1714 |
*/ |
| 1715 |
|
| 1716 |
current = objects = ges_layer_get_clips_in_interval (layer, 4, 52); |
| 1717 |
assert_equals_int (g_list_length (objects), 3); |
| 1718 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip3)); |
| 1719 |
current = current->next; |
| 1720 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1721 |
current = current->next; |
| 1722 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip2)); |
| 1723 |
g_list_free_full (objects, gst_object_unref); |
| 1724 |
|
| 1725 |
current = objects = ges_layer_get_clips_in_interval (layer, 39, 65); |
| 1726 |
assert_equals_int (g_list_length (objects), 2); |
| 1727 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip)); |
| 1728 |
current = current->next; |
| 1729 |
fail_unless (current->data == GES_TIMELINE_ELEMENT (clip2)); |
| 1730 |
g_list_free_full (objects, gst_object_unref); |
| 1731 |
|
| 1732 |
gst_object_unref (timeline); |
| 1733 |
|
| 1734 |
ges_deinit (); |
| 1735 |
} |
| 1736 |
|
| 1737 |
GST_END_TEST; |
| 1738 |
|
| 1739 |
static Suite * |
| 1740 |
ges_suite (void) |
| 1741 |
{ |
| 1742 |
Suite *s = suite_create ("ges-layer"); |
| 1743 |
TCase *tc_chain = tcase_create ("timeline-layer"); |
| 1744 |
|
| 1745 |
suite_add_tcase (s, tc_chain); |
| 1746 |
|
| 1747 |
tcase_add_test (tc_chain, test_layer_properties); |
| 1748 |
tcase_add_test (tc_chain, test_layer_priorities); |
| 1749 |
tcase_add_test (tc_chain, test_timeline_auto_transition); |
| 1750 |
tcase_add_test (tc_chain, test_single_layer_automatic_transition); |
| 1751 |
tcase_add_test (tc_chain, test_multi_layer_automatic_transition); |
| 1752 |
tcase_add_test (tc_chain, test_layer_activate_automatic_transition); |
| 1753 |
tcase_add_test (tc_chain, test_layer_meta_string); |
| 1754 |
tcase_add_test (tc_chain, test_layer_meta_boolean); |
| 1755 |
tcase_add_test (tc_chain, test_layer_meta_int); |
| 1756 |
tcase_add_test (tc_chain, test_layer_meta_uint); |
| 1757 |
tcase_add_test (tc_chain, test_layer_meta_int64); |
| 1758 |
tcase_add_test (tc_chain, test_layer_meta_uint64); |
| 1759 |
tcase_add_test (tc_chain, test_layer_meta_float); |
| 1760 |
tcase_add_test (tc_chain, test_layer_meta_double); |
| 1761 |
tcase_add_test (tc_chain, test_layer_meta_date); |
| 1762 |
tcase_add_test (tc_chain, test_layer_meta_date_time); |
| 1763 |
tcase_add_test (tc_chain, test_layer_meta_value); |
| 1764 |
tcase_add_test (tc_chain, test_layer_meta_marker_list); |
| 1765 |
tcase_add_test (tc_chain, test_layer_meta_register); |
| 1766 |
tcase_add_test (tc_chain, test_layer_meta_foreach); |
| 1767 |
tcase_add_test (tc_chain, test_layer_get_clips_in_interval); |
| 1768 |
|
| 1769 |
return s; |
| 1770 |
} |
| 1771 |
|
| 1772 |
GST_CHECK_MAIN (ges); |