1 #include "common.h"
2
3 static void
test_simplest_full(void)4 test_simplest_full (void)
5 {
6 gboolean ret = FALSE;
7 GstElement *pipeline;
8 GstElement *comp, *sink, *source1;
9 CollectStructure *collect;
10 GstBus *bus;
11 GstPad *sinkpad;
12
13 pipeline = gst_pipeline_new ("test_pipeline");
14 comp =
15 gst_element_factory_make_or_warn ("nlecomposition", "test_composition");
16 gst_element_set_state (comp, GST_STATE_READY);
17 fail_if (comp == NULL);
18
19 /*
20 Source 1
21 Start : 0s
22 Duration : 1s
23 Media start : 5s
24 Media Duartion : 1s
25 Priority : 1
26 */
27 source1 =
28 videotest_nle_src_full ("source1", 0, 1 * GST_SECOND, 5 * GST_SECOND, 3,
29 1);
30 fail_if (source1 == NULL);
31 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
32
33 /* Add one source */
34
35 nle_composition_add (GST_BIN (comp), source1);
36 commit_and_wait (comp, &ret);
37 fail_unless (ret);
38 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
39 check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
40 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
41
42 sink = gst_element_factory_make_or_warn ("fakesink", "sink");
43 fail_if (sink == NULL);
44
45 gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
46
47 /* Shared data */
48 collect = g_new0 (CollectStructure, 1);
49 collect->comp = comp;
50 collect->sink = sink;
51
52 /* Expected segments */
53 collect->expected_segments = g_list_append (collect->expected_segments,
54 segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
55
56 gst_element_link (comp, sink);
57 sinkpad = gst_element_get_static_pad (sink, "sink");
58 gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
59 (GstPadProbeCallback) sinkpad_probe, collect, NULL);
60
61 bus = gst_element_get_bus (GST_ELEMENT (pipeline));
62
63 GST_ERROR ("Setting pipeline to PLAYING");
64 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
65
66 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
67 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
68
69 GST_DEBUG ("Let's poll the bus");
70
71 poll_the_bus (bus);
72
73 GST_DEBUG ("Setting pipeline to NULL");
74
75 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
76 GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
77
78 fail_if (collect->expected_segments != NULL);
79
80 GST_ERROR ("Resetted pipeline to READY");
81
82 if (collect->seen_segments)
83 g_list_free (collect->seen_segments);
84
85 collect->seen_segments = NULL;
86
87 /* Expected segments */
88 collect->expected_segments = g_list_append (collect->expected_segments,
89 segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
90 collect->expected_base = 0;
91 collect->gotsegment = FALSE;
92
93 GST_ERROR ("Setting pipeline to PLAYING again");
94
95 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
96 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
97
98 GST_DEBUG ("Let's poll the bus AGAIN");
99
100 poll_the_bus (bus);
101
102 fail_if (collect->expected_segments != NULL);
103
104 gst_object_unref (GST_OBJECT (sinkpad));
105
106 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
107 GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
108
109 ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
110 gst_check_objects_destroyed_on_unref (pipeline, comp, source1, NULL);
111 ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
112
113 collect_free (collect);
114 }
115
116 static void
test_time_duration_full(void)117 test_time_duration_full (void)
118 {
119 gboolean ret = FALSE;
120 GstElement *comp, *source1, *source2;
121
122 comp =
123 gst_element_factory_make_or_warn ("nlecomposition", "test_composition");
124 gst_element_set_state (comp, GST_STATE_READY);
125
126 /*
127 Source 1
128 Start : 0s
129 Duration : 1s
130 Priority : 1
131 */
132 source1 = videotest_nle_src ("source1", 0, 1 * GST_SECOND, 3, 1);
133 fail_if (source1 == NULL);
134 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
135
136 /*
137 Source 2
138 Start : 1s
139 Duration : 1s
140 Priority : 1
141 */
142 source2 = videotest_nle_src ("source2", 1 * GST_SECOND, 1 * GST_SECOND, 2, 1);
143 fail_if (source2 == NULL);
144 check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
145 1 * GST_SECOND);
146
147 /* Add one source */
148 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
149 ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
150
151 nle_composition_add (GST_BIN (comp), source1);
152 commit_and_wait (comp, &ret);
153 fail_unless (ret == TRUE);
154 check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
155
156 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
157
158 /* Second source */
159
160 ret = FALSE;
161 nle_composition_add (GST_BIN (comp), source2);
162 commit_and_wait (comp, &ret);
163 fail_unless (ret == TRUE);
164 check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
165
166 ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
167
168 /* Remove first source */
169
170 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
171 gst_object_ref (source1);
172 ASSERT_OBJECT_REFCOUNT (source1, "source1", 2);
173 GST_ERROR_OBJECT (source1, "Num refs : %i", ((GObject *) source1)->ref_count);
174 nle_composition_remove (GST_BIN (comp), source1);
175 commit_and_wait (comp, &ret);
176 GST_ERROR_OBJECT (source1, "Num refs : %i", ((GObject *) source1)->ref_count);
177 check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
178 1 * GST_SECOND);
179
180 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
181
182 /* Re-add first source */
183
184 nle_composition_add (GST_BIN (comp), source1);
185 commit_and_wait (comp, &ret);
186 check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
187 gst_object_unref (source1);
188
189 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
190
191 gst_element_set_state (comp, GST_STATE_NULL);
192 gst_object_unref (comp);
193 }
194
195 static void
test_one_after_other_full(void)196 test_one_after_other_full (void)
197 {
198 GstElement *pipeline;
199 GstElement *comp, *sink, *source1, *source2;
200 CollectStructure *collect;
201 GstBus *bus;
202 GstMessage *message;
203 gboolean carry_on = TRUE;
204 GstPad *sinkpad;
205
206 gboolean ret = FALSE;
207
208 pipeline = gst_pipeline_new ("test_pipeline");
209 comp =
210 gst_element_factory_make_or_warn ("nlecomposition", "test_composition");
211 gst_element_set_state (comp, GST_STATE_READY);
212 fail_if (comp == NULL);
213
214 /*
215 Source 1
216 Start : 0s
217 Duration : 1s
218 Media start : 5s
219 Priority : 1
220 */
221 source1 =
222 videotest_nle_src_full ("source1", 0, 1 * GST_SECOND, 5 * GST_SECOND, 3,
223 1);
224 fail_if (source1 == NULL);
225 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
226
227 /*
228 Source 2
229 Start : 1s
230 Duration : 1s
231 Media start : 2s
232 Priority : 1
233 */
234 source2 = videotest_nle_src_full ("source2", 1 * GST_SECOND, 1 * GST_SECOND,
235 2 * GST_SECOND, 2, 1);
236 fail_if (source2 == NULL);
237 check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
238 1 * GST_SECOND);
239
240 /* Add one source */
241 nle_composition_add (GST_BIN (comp), source1);
242 commit_and_wait (comp, &ret);
243 check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
244
245 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
246
247 /* Second source */
248 nle_composition_add (GST_BIN (comp), source2);
249 commit_and_wait (comp, &ret);
250 fail_unless (ret);
251 check_start_stop_duration (source1, 0 * GST_SECOND, 1 * GST_SECOND,
252 1 * GST_SECOND);
253 check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
254 1 * GST_SECOND);
255 check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
256
257 ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
258
259 sink = gst_element_factory_make_or_warn ("fakesink", "sink");
260 fail_if (sink == NULL);
261
262 gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
263
264 /* Shared data */
265 collect = g_new0 (CollectStructure, 1);
266 collect->comp = comp;
267 collect->sink = sink;
268
269 /* Expected segments */
270 collect->expected_segments = g_list_append (collect->expected_segments,
271 segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
272 collect->expected_segments = g_list_append (collect->expected_segments,
273 segment_new (1.0, GST_FORMAT_TIME,
274 2 * GST_SECOND, 3 * GST_SECOND, 1 * GST_SECOND));
275
276 gst_element_link (comp, sink);
277
278 sinkpad = gst_element_get_static_pad (sink, "sink");
279 gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
280 (GstPadProbeCallback) sinkpad_probe, collect, NULL);
281
282 bus = gst_element_get_bus (GST_ELEMENT (pipeline));
283
284 GST_DEBUG ("Setting pipeline to PLAYING");
285 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
286
287 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
288 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
289
290 GST_DEBUG ("Let's poll the bus");
291
292 while (carry_on) {
293 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
294 if (message) {
295 switch (GST_MESSAGE_TYPE (message)) {
296 case GST_MESSAGE_EOS:
297 /* we should check if we really finished here */
298 GST_WARNING ("Got an EOS");
299 carry_on = FALSE;
300 break;
301 case GST_MESSAGE_SEGMENT_START:
302 case GST_MESSAGE_SEGMENT_DONE:
303 /* We shouldn't see any segement messages, since we didn't do a segment seek */
304 GST_WARNING ("Saw a Segment start/stop");
305 fail_if (TRUE);
306 break;
307 case GST_MESSAGE_ERROR:
308 fail_error_message (message);
309 default:
310 break;
311 }
312 gst_mini_object_unref (GST_MINI_OBJECT (message));
313 }
314 }
315
316 GST_DEBUG ("Setting pipeline to NULL");
317
318 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
319 GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
320
321 fail_if (collect->expected_segments != NULL);
322
323 GST_DEBUG ("Resetted pipeline to READY");
324
325 if (collect->seen_segments)
326 g_list_free (collect->seen_segments);
327
328 collect->seen_segments = NULL;
329
330 /* Expected segments */
331 collect->expected_segments = g_list_append (collect->expected_segments,
332 segment_new (1.0, GST_FORMAT_TIME, 5 * GST_SECOND, 6 * GST_SECOND, 0));
333 collect->expected_segments = g_list_append (collect->expected_segments,
334 segment_new (1.0, GST_FORMAT_TIME,
335 2 * GST_SECOND, 3 * GST_SECOND, 1 * GST_SECOND));
336 collect->gotsegment = FALSE;
337 collect->expected_base = 0;
338
339
340 GST_DEBUG ("Setting pipeline to PLAYING again");
341
342 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
343 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
344
345 carry_on = TRUE;
346
347 GST_DEBUG ("Let's poll the bus AGAIN");
348
349 while (carry_on) {
350 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
351 if (message) {
352 switch (GST_MESSAGE_TYPE (message)) {
353 case GST_MESSAGE_EOS:
354 /* we should check if we really finished here */
355 carry_on = FALSE;
356 break;
357 case GST_MESSAGE_SEGMENT_START:
358 case GST_MESSAGE_SEGMENT_DONE:
359 /* We shouldn't see any segement messages, since we didn't do a segment seek */
360 GST_WARNING ("Saw a Segment start/stop");
361 fail_if (TRUE);
362 break;
363 case GST_MESSAGE_ERROR:
364 fail_error_message (message);
365 default:
366 break;
367 }
368 gst_mini_object_unref (GST_MINI_OBJECT (message));
369 } else {
370 GST_DEBUG ("bus_poll responded, but there wasn't any message...");
371 }
372 }
373
374 fail_if (collect->expected_segments != NULL);
375
376 gst_object_unref (GST_OBJECT (sinkpad));
377
378 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
379 GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
380
381 ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
382 gst_object_unref (pipeline);
383 ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
384 gst_object_unref (bus);
385
386 collect_free (collect);
387 }
388
389 static void
test_one_under_another_full(void)390 test_one_under_another_full (void)
391 {
392 gboolean ret = FALSE;
393 GstElement *pipeline;
394 GstElement *comp, *sink, *source1, *source2;
395 CollectStructure *collect;
396 GstBus *bus;
397 GstMessage *message;
398 gboolean carry_on = TRUE;
399 GstPad *sinkpad;
400
401 pipeline = gst_pipeline_new ("test_pipeline");
402 comp =
403 gst_element_factory_make_or_warn ("nlecomposition", "test_composition");
404 gst_element_set_state (comp, GST_STATE_READY);
405 fail_if (comp == NULL);
406
407 /* TOPOLOGY
408 *
409 * 0 1 2 3 4 5 | Priority
410 * ----------------------------------------------------------------------------
411 * [- source1 -] | 1
412 * [- source2 -] | 2
413 * */
414
415 /*
416 Source 1
417 Start : 0s
418 Duration : 2s
419 Priority : 1
420 */
421 source1 = videotest_nle_src ("source1", 0, 2 * GST_SECOND, 18, 1);
422 fail_if (source1 == NULL);
423 check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
424
425 /*
426 Source 2
427 Start : 1s
428 Duration : 2s
429 Priority : 2
430 */
431 source2 = videotest_nle_src ("source2", 1 * GST_SECOND, 2 * GST_SECOND, 0, 2);
432 fail_if (source2 == NULL);
433 check_start_stop_duration (source2, 1 * GST_SECOND, 3 * GST_SECOND,
434 2 * GST_SECOND);
435
436 /* Add two sources */
437
438 nle_composition_add (GST_BIN (comp), source1);
439 nle_composition_add (GST_BIN (comp), source2);
440 check_start_stop_duration (comp, 0, 0 * GST_SECOND, 0 * GST_SECOND);
441 /* Now commiting changes */
442 commit_and_wait (comp, &ret);
443 check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
444 check_start_stop_duration (source1, 0, 2 * GST_SECOND, 2 * GST_SECOND);
445 check_start_stop_duration (source2, 1 * GST_SECOND, 3 * GST_SECOND,
446 2 * GST_SECOND);
447
448 /* Remove second source */
449
450 gst_object_ref (source1);
451 nle_composition_remove (GST_BIN (comp), source1);
452 check_start_stop_duration (comp, 1 * GST_SECOND, 3 * GST_SECOND,
453 2 * GST_SECOND);
454
455 /* Re-add second source */
456
457 nle_composition_add (GST_BIN (comp), source1);
458 commit_and_wait (comp, &ret);
459 check_start_stop_duration (comp, 0, 3 * GST_SECOND, 3 * GST_SECOND);
460 gst_object_unref (source1);
461
462 sink = gst_element_factory_make_or_warn ("fakesink", "sink");
463 fail_if (sink == NULL);
464
465 gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
466
467 /* Shared data */
468 collect = g_new0 (CollectStructure, 1);
469 collect->comp = comp;
470 collect->sink = sink;
471
472 /* Expected segments */
473 collect->expected_segments = g_list_append (collect->expected_segments,
474 segment_new (1.0, GST_FORMAT_TIME, 0, GST_SECOND, 0));
475
476 collect->expected_segments = g_list_append (collect->expected_segments,
477 segment_new (1.0, GST_FORMAT_TIME, GST_SECOND, 2 * GST_SECOND,
478 GST_SECOND));
479
480 collect->expected_segments = g_list_append (collect->expected_segments,
481 segment_new (1.0, GST_FORMAT_TIME,
482 2 * GST_SECOND, 3 * GST_SECOND, 2 * GST_SECOND));
483
484 gst_element_link (comp, sink);
485
486 sinkpad = gst_element_get_static_pad (sink, "sink");
487 gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
488 (GstPadProbeCallback) sinkpad_probe, collect, NULL);
489
490 bus = gst_element_get_bus (GST_ELEMENT (pipeline));
491
492 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
493 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
494
495 while (carry_on) {
496 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
497 if (message) {
498 switch (GST_MESSAGE_TYPE (message)) {
499 case GST_MESSAGE_EOS:
500 /* we should check if we really finished here */
501 carry_on = FALSE;
502 break;
503 case GST_MESSAGE_SEGMENT_START:
504 case GST_MESSAGE_SEGMENT_DONE:
505 /* check if the segment is the correct one (0s-4s) */
506 carry_on = FALSE;
507 break;
508 case GST_MESSAGE_ERROR:
509 fail_error_message (message);
510 default:
511 break;
512 }
513 gst_message_unref (message);
514 }
515 }
516
517 fail_if (collect->expected_segments != NULL);
518
519 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
520 GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
521
522 gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
523 gst_object_unref (GST_OBJECT (sinkpad));
524 ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
525 gst_object_unref (pipeline);
526 ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
527 gst_object_unref (bus);
528
529 collect_free (collect);
530 }
531
532 static void
test_one_bin_after_other_full(void)533 test_one_bin_after_other_full (void)
534 {
535 gboolean ret = FALSE;
536 GstElement *pipeline;
537 GstElement *comp, *sink, *source1, *source2;
538 CollectStructure *collect;
539 GstBus *bus;
540 GstMessage *message;
541 gboolean carry_on = TRUE;
542 GstPad *sinkpad;
543
544 pipeline = gst_pipeline_new ("test_pipeline");
545 comp =
546 gst_element_factory_make_or_warn ("nlecomposition", "test_composition");
547 gst_element_set_state (comp, GST_STATE_READY);
548 fail_if (comp == NULL);
549
550 /*
551 Source 1
552 Start : 0s
553 Duration : 1s
554 Priority : 1
555 */
556 source1 = videotest_in_bin_nle_src ("source1", 0, 1 * GST_SECOND, 3, 1);
557 if (source1 == NULL) {
558 gst_object_unref (pipeline);
559 gst_object_unref (comp);
560 return;
561 }
562 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
563
564 /*
565 Source 2
566 Start : 1s
567 Duration : 1s
568 Priority : 1
569 */
570 source2 =
571 videotest_in_bin_nle_src ("source2", 1 * GST_SECOND, 1 * GST_SECOND, 2,
572 1);
573 fail_if (source2 == NULL);
574 check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
575 1 * GST_SECOND);
576
577 /* Add one source */
578
579 nle_composition_add (GST_BIN (comp), source1);
580 commit_and_wait (comp, &ret);
581 fail_unless (ret);
582 check_start_stop_duration (comp, 0, 1 * GST_SECOND, 1 * GST_SECOND);
583 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
584
585 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
586
587 /* Second source */
588
589 nle_composition_add (GST_BIN (comp), source2);
590 commit_and_wait (comp, &ret);
591 check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
592 check_start_stop_duration (source1, 0, 1 * GST_SECOND, 1 * GST_SECOND);
593 check_start_stop_duration (source2, 1 * GST_SECOND, 2 * GST_SECOND,
594 1 * GST_SECOND);
595
596 ASSERT_OBJECT_REFCOUNT (source2, "source2", 1);
597
598 /* Remove first source */
599
600 gst_object_ref (source1);
601 nle_composition_remove (GST_BIN (comp), source1);
602 check_start_stop_duration (comp, 1 * GST_SECOND, 2 * GST_SECOND,
603 1 * GST_SECOND);
604
605 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
606
607 /* Re-add first source */
608
609 nle_composition_add (GST_BIN (comp), source1);
610 commit_and_wait (comp, &ret);
611 check_start_stop_duration (comp, 0, 2 * GST_SECOND, 2 * GST_SECOND);
612 gst_object_unref (source1);
613
614 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
615
616 sink = gst_element_factory_make_or_warn ("fakesink", "sink");
617 fail_if (sink == NULL);
618
619 gst_bin_add_many (GST_BIN (pipeline), comp, sink, NULL);
620
621 /* Shared data */
622 collect = g_new0 (CollectStructure, 1);
623 collect->comp = comp;
624 collect->sink = sink;
625
626 /* Expected segments */
627 collect->expected_segments = g_list_append (collect->expected_segments,
628 segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
629 collect->expected_segments = g_list_append (collect->expected_segments,
630 segment_new (1.0, GST_FORMAT_TIME,
631 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
632
633 gst_element_link (comp, sink);
634
635 sinkpad = gst_element_get_static_pad (sink, "sink");
636 gst_pad_add_probe (sinkpad, GST_PAD_PROBE_TYPE_DATA_DOWNSTREAM,
637 (GstPadProbeCallback) sinkpad_probe, collect, NULL);
638
639 bus = gst_element_get_bus (GST_ELEMENT (pipeline));
640
641 GST_DEBUG ("Setting pipeline to PLAYING");
642 ASSERT_OBJECT_REFCOUNT (source1, "source1", 1);
643
644 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
645 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
646
647 GST_DEBUG ("Let's poll the bus");
648
649 while (carry_on) {
650 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
651 if (message) {
652 switch (GST_MESSAGE_TYPE (message)) {
653 case GST_MESSAGE_EOS:
654 /* we should check if we really finished here */
655 GST_WARNING ("Got an EOS");
656 carry_on = FALSE;
657 break;
658 case GST_MESSAGE_SEGMENT_START:
659 case GST_MESSAGE_SEGMENT_DONE:
660 /* We shouldn't see any segement messages, since we didn't do a segment seek */
661 GST_WARNING ("Saw a Segment start/stop");
662 fail_if (FALSE);
663 break;
664 case GST_MESSAGE_ERROR:
665 fail_error_message (message);
666 default:
667 break;
668 }
669 gst_mini_object_unref (GST_MINI_OBJECT (message));
670 }
671 }
672
673 GST_DEBUG ("Setting pipeline to NULL");
674
675 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
676 GST_STATE_READY) == GST_STATE_CHANGE_FAILURE);
677
678 fail_if (collect->expected_segments != NULL);
679
680 GST_DEBUG ("Resetted pipeline to READY");
681
682 if (collect->seen_segments)
683 g_list_free (collect->seen_segments);
684
685 collect->seen_segments = NULL;
686
687 /* Expected segments */
688 collect->expected_segments = g_list_append (collect->expected_segments,
689 segment_new (1.0, GST_FORMAT_TIME, 0, 1 * GST_SECOND, 0));
690 collect->expected_segments = g_list_append (collect->expected_segments,
691 segment_new (1.0, GST_FORMAT_TIME,
692 1 * GST_SECOND, 2 * GST_SECOND, 1 * GST_SECOND));
693 collect->gotsegment = FALSE;
694 collect->expected_base = 0;
695
696 GST_DEBUG ("Setting pipeline to PLAYING again");
697
698 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
699 GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE);
700
701 carry_on = TRUE;
702 while (carry_on) {
703 message = gst_bus_poll (bus, GST_MESSAGE_ANY, GST_SECOND / 10);
704 if (message) {
705 switch (GST_MESSAGE_TYPE (message)) {
706 case GST_MESSAGE_EOS:
707 /* we should check if we really finished here */
708 carry_on = FALSE;
709 break;
710 case GST_MESSAGE_SEGMENT_START:
711 case GST_MESSAGE_SEGMENT_DONE:
712 /* We shouldn't see any segement messages, since we didn't do a segment seek */
713 GST_WARNING ("Saw a Segment start/stop");
714 fail_if (FALSE);
715 break;
716 case GST_MESSAGE_ERROR:
717 fail_error_message (message);
718 default:
719 break;
720 }
721 gst_mini_object_unref (GST_MINI_OBJECT (message));
722 }
723 }
724
725 gst_object_unref (GST_OBJECT (sinkpad));
726
727 fail_if (collect->expected_segments != NULL);
728
729 fail_if (gst_element_set_state (GST_ELEMENT (pipeline),
730 GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE);
731
732 ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "main pipeline", 1, 2);
733 gst_object_unref (pipeline);
734 ASSERT_OBJECT_REFCOUNT_BETWEEN (bus, "main bus", 1, 2);
735 gst_object_unref (bus);
736
737 collect_free (collect);
738 }
739
GST_START_TEST(test_simplest)740 GST_START_TEST (test_simplest)
741 {
742 ges_init ();
743 test_simplest_full ();
744 ges_deinit ();
745 }
746
747 GST_END_TEST;
748
GST_START_TEST(test_time_duration)749 GST_START_TEST (test_time_duration)
750 {
751 ges_init ();
752 test_time_duration_full ();
753 ges_deinit ();
754 }
755
756 GST_END_TEST;
757
GST_START_TEST(test_one_after_other)758 GST_START_TEST (test_one_after_other)
759 {
760 ges_init ();
761 test_one_after_other_full ();
762 ges_deinit ();
763 }
764
765 GST_END_TEST;
766
GST_START_TEST(test_one_under_another)767 GST_START_TEST (test_one_under_another)
768 {
769 ges_init ();
770 test_one_under_another_full ();
771 ges_deinit ();
772 }
773
774 GST_END_TEST;
775
GST_START_TEST(test_one_bin_after_other)776 GST_START_TEST (test_one_bin_after_other)
777 {
778 ges_init ();
779 test_one_bin_after_other_full ();
780 ges_deinit ();
781 }
782
783 GST_END_TEST;
784
785 static Suite *
gnonlin_suite(void)786 gnonlin_suite (void)
787 {
788 Suite *s = suite_create ("gnonlin-simple");
789 TCase *tc_chain = tcase_create ("general");
790
791 suite_add_tcase (s, tc_chain);
792
793 tcase_add_test (tc_chain, test_time_duration);
794 tcase_add_test (tc_chain, test_simplest);
795 tcase_add_test (tc_chain, test_one_after_other);
796 tcase_add_test (tc_chain, test_one_under_another);
797 tcase_add_test (tc_chain, test_one_bin_after_other);
798 return s;
799 }
800
801 GST_CHECK_MAIN (gnonlin)
802