Debian Codegraph @

tests/check/nle/simple.c

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