7
7
#include < opentimelineio/clip.h>
8
8
#include < opentimelineio/stack.h>
9
9
#include < opentimelineio/track.h>
10
+ #include < opentimelineio/gap.h>
10
11
#include < opentimelineio/stackAlgorithm.h>
11
12
12
13
#include < iostream>
@@ -213,6 +214,103 @@ main(int argc, char** argv)
213
214
assertEqual (result->duration ().value (), 300 );
214
215
});
215
216
217
+ tests.add_test (
218
+ " test_flatten_stack_04" , [] {
219
+ using namespace otio ;
220
+
221
+ otio::RationalTime rt_0_24{0 , 24 };
222
+ otio::RationalTime rt_150_24{150 , 24 };
223
+ otio::TimeRange tr_AB_150_24{rt_0_24, rt_150_24};
224
+
225
+ otio::TimeRange tr_C_150_24{rt_0_24, otio::RationalTime (300 , 24 )};
226
+
227
+ // A and B are Gaps placed over clip C
228
+ // C should remain uncut
229
+ // 0 150 300
230
+ // [ A | B ]
231
+ // [ C ]
232
+ //
233
+ // should flatten to:
234
+ // [ C ]
235
+
236
+ otio::SerializableObject::Retainer<otio::Gap> cl_A =
237
+ new otio::Gap (tr_AB_150_24, " track1_A" );
238
+ otio::SerializableObject::Retainer<otio::Gap> cl_B =
239
+ new otio::Gap (tr_AB_150_24, " track1_B" );
240
+ otio::SerializableObject::Retainer<otio::Clip> cl_C =
241
+ new otio::Clip (" track2_C" , nullptr , tr_C_150_24);
242
+
243
+ otio::SerializableObject::Retainer<otio::Track> tr_over =
244
+ new otio::Track ();
245
+ tr_over->append_child (cl_A);
246
+ tr_over->append_child (cl_B);
247
+
248
+ otio::SerializableObject::Retainer<otio::Track> tr_under =
249
+ new otio::Track ();
250
+ tr_under->append_child (cl_C);
251
+
252
+ otio::SerializableObject::Retainer<otio::Stack> st =
253
+ new otio::Stack ();
254
+ st->append_child (tr_under);
255
+ st->append_child (tr_over);
256
+
257
+ auto result = flatten_stack (st);
258
+
259
+ assertEqual (result->children ().size (), 1 );
260
+ assertEqual (result->children ()[0 ]->name (), std::string (" track2_C" ));
261
+ assertEqual (result->duration ().value (), 300 );
262
+ });
263
+
264
+ tests.add_test (
265
+ " test_flatten_stack_05" , [] {
266
+ using namespace otio ;
267
+
268
+ otio::RationalTime rt_0_24{0 , 24 };
269
+ otio::RationalTime rt_150_24{150 , 24 };
270
+ otio::TimeRange tr_150_24{rt_0_24, rt_150_24};
271
+
272
+ // A and B are Gaps placed over clips C and D
273
+ // with a cut at the same location
274
+ // 0 150 300
275
+ // [ A | B ]
276
+ // [ C | D ]
277
+ //
278
+ // should flatten to:
279
+ // [ C | D ]
280
+
281
+ otio::SerializableObject::Retainer<otio::Gap> cl_A =
282
+ new otio::Gap (tr_150_24, " track1_A" );
283
+ otio::SerializableObject::Retainer<otio::Gap> cl_B =
284
+ new otio::Gap (tr_150_24, " track1_B" );
285
+ otio::SerializableObject::Retainer<otio::Clip> cl_C =
286
+ new otio::Clip (" track2_C" , nullptr , tr_150_24);
287
+ otio::SerializableObject::Retainer<otio::Clip> cl_D =
288
+ new otio::Clip (" track2_D" , nullptr , tr_150_24);
289
+
290
+
291
+ otio::SerializableObject::Retainer<otio::Track> tr_over =
292
+ new otio::Track ();
293
+ tr_over->append_child (cl_A);
294
+ tr_over->append_child (cl_B);
295
+
296
+ otio::SerializableObject::Retainer<otio::Track> tr_under =
297
+ new otio::Track ();
298
+ tr_under->append_child (cl_C);
299
+ tr_under->append_child (cl_D);
300
+
301
+ otio::SerializableObject::Retainer<otio::Stack> st =
302
+ new otio::Stack ();
303
+ st->append_child (tr_under);
304
+ st->append_child (tr_over);
305
+
306
+ auto result = flatten_stack (st);
307
+
308
+ assertEqual (result->children ().size (), 2 );
309
+ assertEqual (result->children ()[0 ]->name (), std::string (" track2_C" ));
310
+ assertEqual (result->children ()[1 ]->name (), std::string (" track2_D" ));
311
+ assertEqual (result->duration ().value (), 300 );
312
+ });
313
+
216
314
tests.run (argc, argv);
217
315
return 0 ;
218
316
}
0 commit comments