2 * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
4 * gstpad.c: Unit test for GstPad
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
25 #include <gst/check/gstcheck.h>
27 static GstSegment dummy_segment;
29 GST_START_TEST (test_link)
37 src = gst_pad_new ("source", GST_PAD_SRC);
38 fail_if (src == NULL);
39 ASSERT_OBJECT_REFCOUNT (src, "source pad", 1);
41 name = gst_pad_get_name (src);
42 fail_unless (strcmp (name, "source") == 0);
43 ASSERT_OBJECT_REFCOUNT (src, "source pad", 1);
46 sink = gst_pad_new ("sink", GST_PAD_SINK);
47 fail_if (sink == NULL);
49 /* linking without templates or caps should work */
50 ret = gst_pad_link (src, sink);
51 ASSERT_OBJECT_REFCOUNT (src, "source pad", 1);
52 ASSERT_OBJECT_REFCOUNT (sink, "sink pad", 1);
53 fail_unless (ret == GST_PAD_LINK_OK);
55 ASSERT_CRITICAL (gst_pad_get_pad_template (NULL));
57 srct = gst_pad_get_pad_template (src);
58 fail_unless (srct == NULL);
59 ASSERT_OBJECT_REFCOUNT (src, "source pad", 1);
62 ASSERT_OBJECT_REFCOUNT (src, "source pad", 1);
63 gst_object_unref (src);
64 gst_object_unref (sink);
69 /* threaded link/unlink */
71 static GstPad *src, *sink;
74 thread_link_unlink (gpointer data)
78 while (THREAD_TEST_RUNNING ()) {
79 gst_pad_link (src, sink);
80 gst_pad_unlink (src, sink);
85 GST_START_TEST (test_link_unlink_threaded)
90 src = gst_pad_new ("source", GST_PAD_SRC);
91 fail_if (src == NULL);
92 sink = gst_pad_new ("sink", GST_PAD_SINK);
93 fail_if (sink == NULL);
95 caps = gst_caps_from_string ("foo/bar");
96 gst_pad_set_active (src, TRUE);
97 gst_pad_set_caps (src, caps);
98 gst_pad_set_active (sink, TRUE);
99 gst_pad_set_caps (sink, caps);
100 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
102 MAIN_START_THREADS (5, thread_link_unlink, NULL);
103 for (i = 0; i < 1000; ++i) {
104 gst_pad_is_linked (src);
105 gst_pad_is_linked (sink);
108 MAIN_STOP_THREADS ();
110 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
111 gst_caps_unref (caps);
113 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
114 gst_object_unref (src);
115 gst_object_unref (sink);
120 GST_START_TEST (test_refcount)
124 GstPadLinkReturn plr;
126 sink = gst_pad_new ("sink", GST_PAD_SINK);
127 fail_if (sink == NULL);
129 src = gst_pad_new ("src", GST_PAD_SRC);
130 fail_if (src == NULL);
132 caps = gst_caps_from_string ("foo/bar");
134 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
136 /* can't set caps on flushing sinkpad */
137 fail_if (gst_pad_set_caps (src, caps) == TRUE);
138 fail_if (gst_pad_set_caps (sink, caps) == TRUE);
139 /* one for me and one for each set_caps */
140 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
142 gst_pad_set_active (src, TRUE);
143 fail_unless (gst_pad_set_caps (src, caps) == TRUE);
144 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
146 gst_pad_set_active (sink, TRUE);
147 fail_unless (gst_pad_set_caps (sink, caps) == TRUE);
148 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
150 plr = gst_pad_link (src, sink);
151 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
152 /* src caps added to pending caps on sink */
153 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
155 gst_pad_unlink (src, sink);
156 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
159 gst_object_unref (src);
160 gst_object_unref (sink);
161 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
163 gst_caps_unref (caps);
168 GST_START_TEST (test_get_allowed_caps)
171 GstCaps *caps, *gotcaps;
173 GstPadLinkReturn plr;
175 ASSERT_CRITICAL (gst_pad_get_allowed_caps (NULL));
177 buffer = gst_buffer_new ();
178 ASSERT_CRITICAL (gst_pad_get_allowed_caps ((GstPad *) buffer));
179 gst_buffer_unref (buffer);
181 src = gst_pad_new ("src", GST_PAD_SRC);
182 fail_if (src == NULL);
183 caps = gst_pad_get_allowed_caps (src);
184 fail_unless (caps == NULL);
186 caps = gst_caps_from_string ("foo/bar");
188 sink = gst_pad_new ("sink", GST_PAD_SINK);
189 gst_pad_set_active (src, TRUE);
190 /* source pad is active and will accept the caps event */
191 fail_unless (gst_pad_set_caps (src, caps) == TRUE);
192 /* sink pad is not active and will refuse the caps event */
193 fail_if (gst_pad_set_caps (sink, caps) == TRUE);
194 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
196 gst_pad_set_active (sink, TRUE);
197 /* sink pad is now active and will accept the caps event */
198 fail_unless (gst_pad_set_caps (sink, caps) == TRUE);
199 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
201 plr = gst_pad_link (src, sink);
202 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
204 gotcaps = gst_pad_get_allowed_caps (src);
205 fail_if (gotcaps == NULL);
206 fail_unless (gst_caps_is_equal (gotcaps, caps));
208 ASSERT_CAPS_REFCOUNT (gotcaps, "gotcaps", 4);
209 gst_caps_unref (gotcaps);
211 gst_pad_unlink (src, sink);
214 ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
215 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
216 ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
218 gst_object_unref (src);
219 gst_object_unref (sink);
221 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
222 gst_caps_unref (caps);
227 static GstCaps *event_caps = NULL;
230 sticky_event (GstPad * pad, GstObject * parent, GstEvent * event)
234 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CAPS
235 || GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START
236 || GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
238 if (GST_EVENT_TYPE (event) != GST_EVENT_CAPS) {
239 gst_event_unref (event);
243 /* Ensure we get here just once: */
244 fail_unless (event_caps == NULL);
246 /* The event must arrive before any buffer: */
247 fail_unless_equals_int (g_list_length (buffers), 0);
249 gst_event_parse_caps (event, &caps);
250 event_caps = gst_caps_ref (caps);
252 gst_event_unref (event);
257 /* Tests whether caps get properly forwarded when pads
258 are initially unlinked */
259 GST_START_TEST (test_sticky_caps_unlinked)
262 GstPadTemplate *src_template, *sink_template;
266 caps = gst_caps_from_string ("foo/bar, dummy=(int){1, 2}");
267 src_template = gst_pad_template_new ("src", GST_PAD_SRC,
268 GST_PAD_ALWAYS, caps);
269 sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
270 GST_PAD_ALWAYS, caps);
271 gst_caps_unref (caps);
273 src = gst_pad_new_from_template (src_template, "src");
274 fail_if (src == NULL);
275 sink = gst_pad_new_from_template (sink_template, "sink");
276 fail_if (sink == NULL);
277 gst_pad_set_event_function (sink, sticky_event);
278 gst_pad_set_chain_function (sink, gst_check_chain_func);
280 gst_object_unref (src_template);
281 gst_object_unref (sink_template);
283 gst_pad_set_active (src, TRUE);
285 fail_unless (gst_pad_push_event (src,
286 gst_event_new_stream_start ("test")) == TRUE);
288 caps = gst_caps_from_string ("foo/bar, dummy=(int)1");
289 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
291 event = gst_event_new_caps (caps);
292 fail_unless (gst_pad_push_event (src, event) == TRUE);
293 fail_unless (event_caps == NULL);
295 fail_unless (gst_pad_push_event (src,
296 gst_event_new_segment (&dummy_segment)) == TRUE);
298 /* Linking and activating will not forward the sticky event yet... */
299 fail_unless (GST_PAD_LINK_SUCCESSFUL (gst_pad_link (src, sink)));
300 gst_pad_set_active (sink, TRUE);
301 fail_unless (event_caps == NULL);
303 /* ...but the first buffer will: */
304 fail_unless (gst_pad_push (src, gst_buffer_new ()) == GST_FLOW_OK);
305 fail_unless (event_caps == caps);
306 fail_unless_equals_int (g_list_length (buffers), 1);
308 gst_check_drop_buffers ();
310 gst_caps_replace (&caps, NULL);
311 gst_caps_replace (&event_caps, NULL);
312 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
313 ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
314 gst_object_unref (src);
315 gst_object_unref (sink);
321 check_if_caps_is_accepted (GstPad * sink, const gchar * str)
326 caps = gst_caps_from_string (str);
327 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
328 ret = gst_pad_query_accept_caps (sink, caps);
329 gst_caps_unref (caps);
335 sink_query_caps (GstPad * pad, GstObject * object, GstQuery * q)
340 switch (GST_QUERY_TYPE (q)) {
344 gst_caps_from_string ("foo/bar, dummy=(int)1,"
345 " query-only-field=(int)1");
346 gst_query_set_caps_result (q, caps);
347 gst_caps_unref (caps);
349 ret = gst_pad_query_default (pad, object, q);
356 /* Tests whether acceptcaps default handler works properly
357 with all 4 possible flag combinations */
358 GST_START_TEST (test_default_accept_caps)
361 GstPadTemplate *sink_template;
364 caps = gst_caps_from_string ("foo/bar, dummy=(int){1, 2}");
365 sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
366 GST_PAD_ALWAYS, caps);
367 gst_caps_unref (caps);
369 sink = gst_pad_new_from_template (sink_template, "sink");
370 fail_if (sink == NULL);
371 gst_pad_set_query_function (sink, sink_query_caps);
373 gst_object_unref (sink_template);
375 gst_pad_set_active (sink, TRUE);
377 /* 1. Check with caps query, subset check */
378 GST_PAD_UNSET_ACCEPT_INTERSECT (sink);
379 GST_PAD_UNSET_ACCEPT_TEMPLATE (sink);
380 fail_unless (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)1"));
381 fail_if (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)3"));
382 fail_unless (check_if_caps_is_accepted (sink,
383 "foo/bar, dummy=(int)1, query-only-field=(int)1"));
384 fail_if (check_if_caps_is_accepted (sink, "foo/bar, extra-field=(int)1"));
386 /* 2. Check with caps query, intersect check */
387 GST_PAD_SET_ACCEPT_INTERSECT (sink);
388 GST_PAD_UNSET_ACCEPT_TEMPLATE (sink);
389 fail_unless (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)1"));
390 fail_if (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)3"));
391 fail_unless (check_if_caps_is_accepted (sink,
392 "foo/bar, dummy=(int)1, query-only-field=(int)1"));
393 fail_unless (check_if_caps_is_accepted (sink, "foo/bar, extra-field=(int)1"));
395 /* 3. Check with template caps, subset check */
396 GST_PAD_UNSET_ACCEPT_INTERSECT (sink);
397 GST_PAD_SET_ACCEPT_TEMPLATE (sink);
398 fail_unless (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)1"));
399 fail_if (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)3"));
400 fail_unless (check_if_caps_is_accepted (sink,
401 "foo/bar, dummy=(int)1, query-only-field=(int)1"));
402 fail_if (check_if_caps_is_accepted (sink, "foo/bar, extra-field=(int)1"));
404 /* 3. Check with template caps, intersect check */
405 GST_PAD_SET_ACCEPT_INTERSECT (sink);
406 GST_PAD_SET_ACCEPT_TEMPLATE (sink);
407 fail_unless (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)1"));
408 fail_if (check_if_caps_is_accepted (sink, "foo/bar, dummy=(int)3"));
409 fail_unless (check_if_caps_is_accepted (sink,
410 "foo/bar, dummy=(int)1, query-only-field=(int)1"));
411 fail_unless (check_if_caps_is_accepted (sink, "foo/bar, extra-field=(int)1"));
413 ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
414 gst_object_unref (sink);
419 /* Same as test_sticky_caps_unlinked except that the source pad
420 * has a template of ANY and we will attempt to push
421 * incompatible caps */
422 GST_START_TEST (test_sticky_caps_unlinked_incompatible)
424 GstCaps *caps, *failcaps;
425 GstPadTemplate *src_template, *sink_template;
429 /* Source pad has ANY caps
430 * Sink pad has foobar caps
431 * We will push the pony express caps (which should fail)
433 caps = gst_caps_new_any ();
434 src_template = gst_pad_template_new ("src", GST_PAD_SRC,
435 GST_PAD_ALWAYS, caps);
436 gst_caps_unref (caps);
437 caps = gst_caps_from_string ("foo/bar, dummy=(int){1, 2}");
438 sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
439 GST_PAD_ALWAYS, caps);
440 gst_caps_unref (caps);
442 src = gst_pad_new_from_template (src_template, "src");
443 fail_if (src == NULL);
444 sink = gst_pad_new_from_template (sink_template, "sink");
445 fail_if (sink == NULL);
446 gst_pad_set_event_function (sink, sticky_event);
447 gst_pad_set_chain_function (sink, gst_check_chain_func);
449 gst_object_unref (src_template);
450 gst_object_unref (sink_template);
452 gst_pad_set_active (src, TRUE);
454 fail_unless (gst_pad_push_event (src,
455 gst_event_new_stream_start ("test")) == TRUE);
457 failcaps = gst_caps_from_string ("pony/express, failure=(boolean)true");
458 ASSERT_CAPS_REFCOUNT (failcaps, "caps", 1);
460 event = gst_event_new_caps (failcaps);
461 gst_caps_unref (failcaps);
462 /* The pad isn't linked yet, and anything matches the source pad template
464 fail_unless (gst_pad_push_event (src, event) == TRUE);
465 fail_unless (event_caps == NULL);
467 fail_unless (gst_pad_push_event (src,
468 gst_event_new_segment (&dummy_segment)) == TRUE);
470 /* Linking and activating will not forward the sticky event yet... */
471 fail_unless (GST_PAD_LINK_SUCCESSFUL (gst_pad_link (src, sink)));
472 gst_pad_set_active (sink, TRUE);
473 fail_unless (event_caps == NULL);
475 /* ...but the first buffer will and should FAIL since the caps
476 * are not compatible */
477 fail_unless (gst_pad_push (src,
478 gst_buffer_new ()) == GST_FLOW_NOT_NEGOTIATED);
479 /* We shouldn't have received the caps event since it's incompatible */
480 fail_unless (event_caps == NULL);
481 /* We shouldn't have received any buffers since caps are incompatible */
482 fail_unless_equals_int (g_list_length (buffers), 0);
484 gst_check_drop_buffers ();
486 gst_caps_replace (&event_caps, NULL);
488 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
489 ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
490 gst_object_unref (src);
491 gst_object_unref (sink);
496 /* Like test_sticky_caps_unlinked, but link before caps: */
498 GST_START_TEST (test_sticky_caps_flushing)
501 GstPadTemplate *src_template, *sink_template;
505 caps = gst_caps_from_string ("foo/bar, dummy=(int){1, 2}");
506 src_template = gst_pad_template_new ("src", GST_PAD_SRC,
507 GST_PAD_ALWAYS, caps);
508 sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
509 GST_PAD_ALWAYS, caps);
510 gst_caps_unref (caps);
512 src = gst_pad_new_from_template (src_template, "src");
513 fail_if (src == NULL);
514 sink = gst_pad_new_from_template (sink_template, "sink");
515 fail_if (sink == NULL);
516 gst_pad_set_event_function (sink, sticky_event);
517 gst_pad_set_chain_function (sink, gst_check_chain_func);
519 gst_object_unref (src_template);
520 gst_object_unref (sink_template);
522 fail_unless (GST_PAD_LINK_SUCCESSFUL (gst_pad_link (src, sink)));
524 caps = gst_caps_from_string ("foo/bar, dummy=(int)1");
525 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
527 event = gst_event_new_caps (caps);
529 gst_pad_set_active (src, TRUE);
530 fail_unless (gst_pad_push_event (src,
531 gst_event_new_stream_start ("test")) == TRUE);
532 /* The caps event gets accepted by the source pad (and stored) */
533 fail_unless (gst_pad_push_event (src, event) == TRUE);
534 /* But wasn't forwarded since the sink pad is flushing (not activated) */
535 fail_unless (event_caps == NULL);
537 fail_unless (gst_pad_push_event (src,
538 gst_event_new_segment (&dummy_segment)) == TRUE);
540 /* Activating will not forward the sticky event yet... */
541 gst_pad_set_active (sink, TRUE);
542 fail_unless (event_caps == NULL);
544 /* ...but the first buffer will: */
545 fail_unless (gst_pad_push (src, gst_buffer_new ()) == GST_FLOW_OK);
546 fail_unless (event_caps == caps);
547 fail_unless_equals_int (g_list_length (buffers), 1);
549 gst_check_drop_buffers ();
551 gst_caps_replace (&caps, NULL);
552 gst_caps_replace (&event_caps, NULL);
554 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
555 ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
556 gst_object_unref (src);
557 gst_object_unref (sink);
563 name_is_valid (const gchar * name, GstPadPresence presence)
566 GstCaps *any = gst_caps_new_any ();
568 new = gst_pad_template_new (name, GST_PAD_SRC, presence, any);
569 gst_caps_unref (any);
571 gst_object_unref (GST_OBJECT (new));
577 GST_START_TEST (test_name_is_valid)
579 gboolean result = FALSE;
581 fail_unless (name_is_valid ("src", GST_PAD_ALWAYS));
582 ASSERT_WARNING (name_is_valid ("src%", GST_PAD_ALWAYS));
583 ASSERT_WARNING (result = name_is_valid ("src%d", GST_PAD_ALWAYS));
586 fail_unless (name_is_valid ("src", GST_PAD_REQUEST));
587 ASSERT_WARNING (name_is_valid ("src%s%s", GST_PAD_REQUEST));
588 ASSERT_WARNING (name_is_valid ("src%c", GST_PAD_REQUEST));
589 ASSERT_WARNING (name_is_valid ("src%", GST_PAD_REQUEST));
590 fail_unless (name_is_valid ("src%dsrc", GST_PAD_REQUEST));
592 fail_unless (name_is_valid ("src", GST_PAD_SOMETIMES));
593 fail_unless (name_is_valid ("src%c", GST_PAD_SOMETIMES));
598 static GstPadProbeReturn
599 _probe_handler (GstPad * pad, GstPadProbeInfo * info, gpointer userdata)
601 GstPadProbeReturn ret = (GstPadProbeReturn) GPOINTER_TO_INT (userdata);
603 /* If we are handling the data, we unref it */
604 if (ret == GST_PAD_PROBE_HANDLED
605 && !(GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_QUERY_BOTH)) {
606 GST_DEBUG_OBJECT (pad, "Unreffing data");
607 gst_mini_object_unref (info->data);
612 static GstPadProbeReturn
613 _handled_probe_handler (GstPad * pad, GstPadProbeInfo * info, gpointer userdata)
615 GstFlowReturn customflow = (GstFlowReturn) GPOINTER_TO_INT (userdata);
617 /* We are handling the data, we unref it */
618 if (!(GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_QUERY_BOTH))
619 gst_mini_object_unref (info->data);
620 GST_PAD_PROBE_INFO_FLOW_RETURN (info) = customflow;
622 return GST_PAD_PROBE_HANDLED;
627 GST_START_TEST (test_events_query_unlinked)
634 src = gst_pad_new ("src", GST_PAD_SRC);
635 fail_if (src == NULL);
636 caps = gst_pad_get_allowed_caps (src);
637 fail_unless (caps == NULL);
639 caps = gst_caps_from_string ("foo/bar");
641 gst_pad_set_active (src, TRUE);
642 fail_unless (gst_pad_push_event (src,
643 gst_event_new_stream_start ("test")) == TRUE);
644 gst_pad_set_caps (src, caps);
645 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
646 fail_unless (gst_pad_push_event (src,
647 gst_event_new_segment (&dummy_segment)) == TRUE);
648 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
650 /* Doing a query on an unlinked pad will return FALSE */
651 query = gst_query_new_duration (GST_FORMAT_TIME);
652 fail_unless (gst_pad_peer_query (src, query) == FALSE);
653 ASSERT_MINI_OBJECT_REFCOUNT (query, "query", 1);
654 gst_query_unref (query);
656 /* Add a probe that returns _DROP will make the event push return TRUE
657 * even if not linked */
658 GST_DEBUG ("event/query DROP");
659 id = gst_pad_add_probe (src,
660 GST_PAD_PROBE_TYPE_EVENT_BOTH | GST_PAD_PROBE_TYPE_QUERY_BOTH,
661 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_DROP), NULL);
662 fail_unless (gst_pad_push_event (src,
663 gst_event_new_segment (&dummy_segment)) == TRUE);
664 /* Queries should still fail */
665 query = gst_query_new_duration (GST_FORMAT_TIME);
666 fail_unless (gst_pad_peer_query (src, query) == FALSE);
667 ASSERT_MINI_OBJECT_REFCOUNT (query, "query", 1);
668 gst_query_unref (query);
669 gst_pad_remove_probe (src, id);
671 /* Add a probe that returns _HANDLED will make the event push return TRUE
672 * even if not linked */
673 GST_DEBUG ("event/query HANDLED");
674 id = gst_pad_add_probe (src,
675 GST_PAD_PROBE_TYPE_EVENT_BOTH | GST_PAD_PROBE_TYPE_QUERY_BOTH,
676 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_HANDLED), NULL);
677 fail_unless (gst_pad_push_event (src,
678 gst_event_new_segment (&dummy_segment)) == TRUE);
680 /* Queries will succeed */
681 query = gst_query_new_duration (GST_FORMAT_TIME);
682 fail_unless (gst_pad_peer_query (src, query) == TRUE);
683 ASSERT_MINI_OBJECT_REFCOUNT (query, "query", 1);
684 gst_query_unref (query);
685 gst_pad_remove_probe (src, id);
688 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
689 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
691 gst_object_unref (src);
693 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
694 gst_caps_unref (caps);
699 GST_START_TEST (test_push_unlinked)
707 src = gst_pad_new ("src", GST_PAD_SRC);
708 fail_if (src == NULL);
709 caps = gst_pad_get_allowed_caps (src);
710 fail_unless (caps == NULL);
712 caps = gst_caps_from_string ("foo/bar");
714 /* pushing on an inactive pad will return wrong state */
715 GST_DEBUG ("push buffer inactive");
716 buffer = gst_buffer_new ();
717 gst_buffer_ref (buffer);
718 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_FLUSHING);
719 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
720 gst_buffer_unref (buffer);
722 gst_pad_set_active (src, TRUE);
723 fail_unless (gst_pad_push_event (src,
724 gst_event_new_stream_start ("test")) == TRUE);
725 GST_DEBUG ("push caps event inactive");
726 gst_pad_set_caps (src, caps);
727 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
728 fail_unless (gst_pad_push_event (src,
729 gst_event_new_segment (&dummy_segment)) == TRUE);
731 /* pushing on an unlinked pad will drop the buffer */
732 GST_DEBUG ("push buffer unlinked");
733 buffer = gst_buffer_new ();
734 gst_buffer_ref (buffer);
735 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_NOT_LINKED);
736 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
737 gst_buffer_unref (buffer);
739 /* adding a probe that returns _DROP will drop the buffer without trying
741 GST_DEBUG ("push buffer drop");
742 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
743 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_DROP), NULL);
744 buffer = gst_buffer_new ();
745 gst_buffer_ref (buffer);
746 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_OK);
747 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
748 gst_buffer_unref (buffer);
749 gst_pad_remove_probe (src, id);
751 /* adding a probe that returns _HANDLED will drop the buffer without trying
753 GST_DEBUG ("push buffer handled");
754 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
755 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_HANDLED), NULL);
756 buffer = gst_buffer_new ();
757 gst_buffer_ref (buffer);
758 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_OK);
759 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
760 gst_buffer_unref (buffer);
761 gst_pad_remove_probe (src, id);
763 /* adding a probe that returns _OK will still chain the buffer,
764 * and hence drop because pad is unlinked */
765 GST_DEBUG ("push buffer ok");
766 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
767 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_OK), NULL);
768 buffer = gst_buffer_new ();
769 gst_buffer_ref (buffer);
770 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_NOT_LINKED);
771 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
772 gst_buffer_unref (buffer);
773 gst_pad_remove_probe (src, id);
775 GST_DEBUG ("push buffer handled and custom return");
776 for (fl = GST_FLOW_NOT_SUPPORTED; fl <= GST_FLOW_OK; fl += 1) {
777 GST_DEBUG ("Testing with %s", gst_flow_get_name (fl));
778 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
779 _handled_probe_handler, GINT_TO_POINTER (fl), NULL);
780 buffer = gst_buffer_new ();
781 gst_buffer_ref (buffer);
782 fail_unless (gst_pad_push (src, buffer) == fl);
783 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
784 gst_buffer_unref (buffer);
785 gst_pad_remove_probe (src, id);
791 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
792 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
794 gst_object_unref (src);
796 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
797 gst_caps_unref (caps);
802 GST_START_TEST (test_push_linked)
805 GstPadLinkReturn plr;
811 sink = gst_pad_new ("sink", GST_PAD_SINK);
812 fail_if (sink == NULL);
813 gst_pad_set_chain_function (sink, gst_check_chain_func);
815 src = gst_pad_new ("src", GST_PAD_SRC);
816 fail_if (src == NULL);
818 caps = gst_caps_from_string ("foo/bar");
820 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
822 gst_pad_set_active (src, TRUE);
824 fail_unless (gst_pad_push_event (src,
825 gst_event_new_stream_start ("test")) == TRUE);
827 gst_pad_set_caps (src, caps);
829 fail_unless (gst_pad_push_event (src,
830 gst_event_new_segment (&dummy_segment)) == TRUE);
832 gst_pad_set_active (sink, TRUE);
833 /* one for me and one for each set_caps */
834 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
836 plr = gst_pad_link (src, sink);
837 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
838 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
840 buffer = gst_buffer_new ();
843 /* pushing on a linked pad will drop the ref to the buffer */
844 gst_buffer_ref (buffer);
845 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_OK);
846 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 2);
847 gst_buffer_unref (buffer);
848 fail_unless_equals_int (g_list_length (buffers), 1);
849 buffer = GST_BUFFER (buffers->data);
850 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
851 gst_buffer_unref (buffer);
852 g_list_free (buffers);
855 /* adding a probe that returns _DROP will drop the buffer without trying
857 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
858 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_DROP), NULL);
859 buffer = gst_buffer_new ();
860 gst_buffer_ref (buffer);
861 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_OK);
862 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
863 gst_buffer_unref (buffer);
864 gst_pad_remove_probe (src, id);
865 fail_unless_equals_int (g_list_length (buffers), 0);
867 /* adding a probe that returns _OK will still chain the buffer */
868 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
869 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_OK), NULL);
870 buffer = gst_buffer_new ();
871 gst_buffer_ref (buffer);
872 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_OK);
873 gst_pad_remove_probe (src, id);
875 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 2);
876 gst_buffer_unref (buffer);
877 fail_unless_equals_int (g_list_length (buffers), 1);
878 buffer = GST_BUFFER (buffers->data);
879 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
880 gst_buffer_unref (buffer);
881 g_list_free (buffers);
884 /* adding a probe that returns _HANDLED will not chain the buffer */
885 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
886 _probe_handler, GINT_TO_POINTER (GST_PAD_PROBE_HANDLED), NULL);
887 buffer = gst_buffer_new ();
888 gst_buffer_ref (buffer);
889 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_OK);
890 gst_pad_remove_probe (src, id);
892 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
893 gst_buffer_unref (buffer);
894 fail_unless_equals_int (g_list_length (buffers), 0);
895 g_list_free (buffers);
899 gst_check_drop_buffers ();
900 gst_pad_unlink (src, sink);
901 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
902 gst_object_unref (src);
903 gst_object_unref (sink);
904 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
906 gst_caps_unref (caps);
911 GST_START_TEST (test_push_linked_flushing)
915 GstPadLinkReturn plr;
920 src = gst_pad_new ("src", GST_PAD_SRC);
921 fail_if (src == NULL);
922 sink = gst_pad_new ("sink", GST_PAD_SINK);
923 fail_if (sink == NULL);
924 gst_pad_set_chain_function (sink, gst_check_chain_func);
926 caps = gst_pad_get_allowed_caps (src);
927 fail_unless (caps == NULL);
928 caps = gst_pad_get_allowed_caps (sink);
929 fail_unless (caps == NULL);
931 caps = gst_caps_from_string ("foo/bar");
933 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
935 gst_pad_set_active (src, TRUE);
936 fail_unless (gst_pad_push_event (src,
937 gst_event_new_stream_start ("test")) == TRUE);
938 gst_pad_set_caps (src, caps);
939 fail_unless (gst_pad_push_event (src,
940 gst_event_new_segment (&dummy_segment)) == TRUE);
941 /* need to activate to make it accept the caps */
942 gst_pad_set_active (sink, TRUE);
943 /* one for me and one for each set_caps */
944 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
946 plr = gst_pad_link (src, sink);
947 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
948 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
950 /* not activating the pads here, which keeps them flushing */
951 gst_pad_set_active (src, FALSE);
952 gst_pad_set_active (sink, FALSE);
954 /* pushing on a flushing pad will drop the buffer */
955 buffer = gst_buffer_new ();
956 gst_buffer_ref (buffer);
957 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_FLUSHING);
958 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
959 fail_unless_equals_int (g_list_length (buffers), 0);
960 gst_buffer_unref (buffer);
962 gst_pad_set_active (src, TRUE);
963 gst_pad_set_active (sink, FALSE);
965 fail_unless (gst_pad_push_event (src,
966 gst_event_new_stream_start ("test")) == TRUE);
967 gst_pad_set_caps (src, caps);
968 fail_unless (gst_pad_push_event (src,
969 gst_event_new_segment (&dummy_segment)) == TRUE);
970 /* adding a probe that returns _DROP will drop the buffer without trying
972 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER, _probe_handler,
973 GINT_TO_POINTER (GST_PAD_PROBE_DROP), NULL);
974 buffer = gst_buffer_new ();
975 gst_buffer_ref (buffer);
976 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_FLUSHING);
977 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
978 fail_unless_equals_int (g_list_length (buffers), 0);
979 gst_buffer_unref (buffer);
980 gst_pad_remove_probe (src, id);
982 /* adding a probe that returns _OK will still chain the buffer,
983 * and hence drop because pad is flushing */
984 id = gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER, _probe_handler,
985 GINT_TO_POINTER (GST_PAD_PROBE_OK), NULL);
986 buffer = gst_buffer_new ();
987 gst_buffer_ref (buffer);
988 fail_unless (gst_pad_push (src, buffer) == GST_FLOW_FLUSHING);
989 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
990 fail_unless_equals_int (g_list_length (buffers), 0);
991 gst_buffer_unref (buffer);
992 gst_pad_remove_probe (src, id);
995 gst_check_drop_buffers ();
996 ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
997 ASSERT_OBJECT_REFCOUNT (src, "src", 1);
998 gst_pad_link (src, sink);
999 gst_object_unref (src);
1000 gst_object_unref (sink);
1001 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
1002 gst_caps_unref (caps);
1008 buffer_from_string (const gchar * str)
1013 size = strlen (str);
1014 buf = gst_buffer_new_and_alloc (size);
1016 gst_buffer_fill (buf, 0, str, size);
1022 buffer_compare (GstBuffer * buf, const gchar * str, gsize size)
1027 fail_unless (gst_buffer_map (buf, &info, GST_MAP_READ));
1028 res = memcmp (info.data, str, size) == 0;
1029 GST_MEMDUMP ("buffer data", info.data, size);
1030 GST_MEMDUMP ("compare data", (guint8 *) str, size);
1031 GST_DEBUG ("buffers match: %s", res ? "yes" : "no");
1032 gst_buffer_unmap (buf, &info);
1037 GST_START_TEST (test_push_buffer_list_compat)
1040 GstPadLinkReturn plr;
1042 GstBufferList *list;
1046 sink = gst_pad_new ("sink", GST_PAD_SINK);
1047 fail_if (sink == NULL);
1048 gst_pad_set_chain_function (sink, gst_check_chain_func);
1049 /* leave chainlistfunc unset */
1051 src = gst_pad_new ("src", GST_PAD_SRC);
1052 fail_if (src == NULL);
1054 caps = gst_caps_from_string ("foo/bar");
1056 gst_pad_set_active (src, TRUE);
1058 fail_unless (gst_pad_push_event (src,
1059 gst_event_new_stream_start ("test")) == TRUE);
1061 gst_pad_set_caps (src, caps);
1063 fail_unless (gst_pad_push_event (src,
1064 gst_event_new_segment (&dummy_segment)) == TRUE);
1066 gst_pad_set_active (sink, TRUE);
1068 plr = gst_pad_link (src, sink);
1069 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
1071 list = gst_buffer_list_new ();
1074 /* adding to a buffer list will drop the ref to the buffer */
1075 gst_buffer_list_add (list, buffer_from_string ("ListGroup"));
1076 gst_buffer_list_add (list, buffer_from_string ("AnotherListGroup"));
1078 fail_unless (gst_pad_push_list (src, list) == GST_FLOW_OK);
1079 fail_unless_equals_int (g_list_length (buffers), 2);
1080 buffer = GST_BUFFER (buffers->data);
1081 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
1082 fail_unless (buffer_compare (buffer, "ListGroup", 9));
1083 gst_buffer_unref (buffer);
1084 buffers = g_list_delete_link (buffers, buffers);
1085 buffer = GST_BUFFER (buffers->data);
1086 ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
1087 fail_unless (buffer_compare (buffer, "AnotherListGroup", 16));
1088 gst_buffer_unref (buffer);
1089 buffers = g_list_delete_link (buffers, buffers);
1090 fail_unless (buffers == NULL);
1093 gst_check_drop_buffers ();
1094 gst_pad_unlink (src, sink);
1095 gst_object_unref (src);
1096 gst_object_unref (sink);
1097 ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
1098 gst_caps_unref (caps);
1103 GST_START_TEST (test_flowreturn)
1108 /* test some of the macros */
1110 fail_if (strcmp (gst_flow_get_name (ret), "eos"));
1111 quark = gst_flow_to_quark (ret);
1112 fail_if (strcmp (g_quark_to_string (quark), "eos"));
1114 /* custom returns */
1115 ret = GST_FLOW_CUSTOM_SUCCESS;
1116 fail_if (strcmp (gst_flow_get_name (ret), "custom-success"));
1117 quark = gst_flow_to_quark (ret);
1118 fail_if (strcmp (g_quark_to_string (quark), "custom-success"));
1120 ret = GST_FLOW_CUSTOM_ERROR;
1121 fail_if (strcmp (gst_flow_get_name (ret), "custom-error"));
1122 quark = gst_flow_to_quark (ret);
1123 fail_if (strcmp (g_quark_to_string (quark), "custom-error"));
1125 /* custom returns clamping */
1126 ret = GST_FLOW_CUSTOM_SUCCESS + 2;
1127 fail_if (strcmp (gst_flow_get_name (ret), "custom-success"));
1128 quark = gst_flow_to_quark (ret);
1129 fail_if (strcmp (g_quark_to_string (quark), "custom-success"));
1131 ret = GST_FLOW_CUSTOM_ERROR - 2;
1132 fail_if (strcmp (gst_flow_get_name (ret), "custom-error"));
1133 quark = gst_flow_to_quark (ret);
1134 fail_if (strcmp (g_quark_to_string (quark), "custom-error"));
1136 /* unknown values */
1137 ret = GST_FLOW_CUSTOM_ERROR + 2;
1138 fail_if (strcmp (gst_flow_get_name (ret), "unknown"));
1139 quark = gst_flow_to_quark (ret);
1140 fail_unless (quark == 0);
1145 GST_START_TEST (test_push_negotiation)
1148 GstPadLinkReturn plr;
1150 gst_caps_from_string ("audio/x-raw,width={16,32},depth={16,32}");
1152 gst_caps_from_string ("audio/x-raw,width=32,depth={16,32}");
1153 GstPadTemplate *src_template;
1154 GstPadTemplate *sink_template;
1158 src_template = gst_pad_template_new ("src", GST_PAD_SRC,
1159 GST_PAD_ALWAYS, srccaps);
1160 sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
1161 GST_PAD_ALWAYS, sinkcaps);
1162 gst_caps_unref (srccaps);
1163 gst_caps_unref (sinkcaps);
1165 sink = gst_pad_new_from_template (sink_template, "sink");
1166 fail_if (sink == NULL);
1167 gst_pad_set_chain_function (sink, gst_check_chain_func);
1169 src = gst_pad_new_from_template (src_template, "src");
1170 fail_if (src == NULL);
1172 plr = gst_pad_link (src, sink);
1173 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
1176 gst_pad_set_active (src, TRUE);
1177 gst_pad_set_active (sink, TRUE);
1179 caps = gst_caps_from_string ("audio/x-raw,width=16,depth=16");
1181 /* Should fail if src pad caps are incompatible with sink pad caps */
1182 gst_pad_set_caps (src, caps);
1183 fail_unless (gst_pad_set_caps (sink, caps) == FALSE);
1186 gst_check_drop_buffers ();
1187 gst_pad_unlink (src, sink);
1188 gst_object_unref (src);
1189 gst_object_unref (sink);
1190 gst_caps_unref (caps);
1191 gst_object_unref (sink_template);
1192 gst_object_unref (src_template);
1197 /* see that an unref also unlinks the pads */
1198 GST_START_TEST (test_src_unref_unlink)
1202 GstPadLinkReturn plr;
1204 sink = gst_pad_new ("sink", GST_PAD_SINK);
1205 fail_if (sink == NULL);
1207 src = gst_pad_new ("src", GST_PAD_SRC);
1208 fail_if (src == NULL);
1210 caps = gst_caps_from_string ("foo/bar");
1212 gst_pad_set_active (src, TRUE);
1213 gst_pad_set_caps (src, caps);
1214 gst_pad_set_active (sink, TRUE);
1215 gst_pad_set_caps (sink, caps);
1217 plr = gst_pad_link (src, sink);
1218 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
1220 /* unref the srcpad */
1221 gst_object_unref (src);
1223 /* sink should be unlinked now */
1224 fail_if (gst_pad_is_linked (sink));
1227 gst_object_unref (sink);
1228 gst_caps_unref (caps);
1233 /* see that an unref also unlinks the pads */
1234 GST_START_TEST (test_sink_unref_unlink)
1238 GstPadLinkReturn plr;
1240 sink = gst_pad_new ("sink", GST_PAD_SINK);
1241 fail_if (sink == NULL);
1243 src = gst_pad_new ("src", GST_PAD_SRC);
1244 fail_if (src == NULL);
1246 caps = gst_caps_from_string ("foo/bar");
1248 gst_pad_set_active (src, TRUE);
1249 gst_pad_set_caps (src, caps);
1250 gst_pad_set_active (sink, TRUE);
1251 gst_pad_set_caps (sink, caps);
1253 plr = gst_pad_link (src, sink);
1254 fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
1256 /* unref the sinkpad */
1257 gst_object_unref (sink);
1259 /* src should be unlinked now */
1260 fail_if (gst_pad_is_linked (src));
1263 gst_object_unref (src);
1264 gst_caps_unref (caps);
1271 static GstPadProbeReturn
1272 block_async_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1274 gboolean *bool_user_data = (gboolean *) user_data;
1276 fail_unless ((info->type & GST_PAD_PROBE_TYPE_BLOCK) != 0);
1278 /* here we should have blocked == 0 unblocked == 0 */
1279 fail_unless (bool_user_data[0] == FALSE);
1280 fail_unless (bool_user_data[1] == FALSE);
1282 bool_user_data[0] = TRUE;
1284 gst_pad_remove_probe (pad, id);
1285 bool_user_data[1] = TRUE;
1287 return GST_PAD_PROBE_OK;
1290 GST_START_TEST (test_block_async)
1293 /* we set data[0] = TRUE when the pad is blocked, data[1] = TRUE when it's
1295 gboolean data[2] = { FALSE, FALSE };
1297 pad = gst_pad_new ("src", GST_PAD_SRC);
1298 fail_unless (pad != NULL);
1300 gst_pad_set_active (pad, TRUE);
1302 fail_unless (gst_pad_push_event (pad,
1303 gst_event_new_stream_start ("test")) == TRUE);
1304 fail_unless (gst_pad_push_event (pad,
1305 gst_event_new_segment (&dummy_segment)) == TRUE);
1307 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK, block_async_cb, &data,
1310 fail_unless (data[0] == FALSE);
1311 fail_unless (data[1] == FALSE);
1312 gst_pad_push (pad, gst_buffer_new ());
1314 gst_object_unref (pad);
1319 static GstPadProbeReturn
1320 block_async_cb_return_ok (GstPad * pad, GstPadProbeInfo * info,
1323 return GST_PAD_PROBE_OK;
1327 push_buffer_async (GstPad * pad)
1329 return GINT_TO_POINTER (gst_pad_push (pad, gst_buffer_new ()));
1333 test_pad_blocking_with_type (GstPadProbeType type)
1339 pad = gst_pad_new ("src", GST_PAD_SRC);
1340 fail_unless (pad != NULL);
1342 gst_pad_set_active (pad, TRUE);
1344 fail_unless (gst_pad_push_event (pad,
1345 gst_event_new_stream_start ("test")) == TRUE);
1346 fail_unless (gst_pad_push_event (pad,
1347 gst_event_new_segment (&dummy_segment)) == TRUE);
1349 id = gst_pad_add_probe (pad, type, block_async_cb_return_ok, NULL, NULL);
1351 thread = g_thread_try_new ("gst-check", (GThreadFunc) push_buffer_async,
1354 /* wait for the block */
1355 while (!gst_pad_is_blocking (pad)) {
1359 /* stop with flushing */
1360 gst_pad_push_event (pad, gst_event_new_flush_start ());
1362 /* get return value from push */
1363 ret = GPOINTER_TO_INT (g_thread_join (thread));
1365 gst_pad_push_event (pad, gst_event_new_flush_stop (FALSE));
1366 /* must be wrong state */
1367 fail_unless (ret == GST_FLOW_FLUSHING);
1369 gst_object_unref (pad);
1372 GST_START_TEST (test_pad_blocking_with_probe_type_block)
1374 test_pad_blocking_with_type (GST_PAD_PROBE_TYPE_BLOCK);
1379 GST_START_TEST (test_pad_blocking_with_probe_type_blocking)
1381 test_pad_blocking_with_type (GST_PAD_PROBE_TYPE_BLOCKING);
1386 static gboolean idle_probe_running;
1388 static GstFlowReturn
1389 idletest_sink_pad_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
1391 if (idle_probe_running)
1392 fail ("Should not be reached");
1393 gst_buffer_unref (buf);
1397 static GstPadProbeReturn
1398 idle_probe_wait (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1400 /* it is ok to have a probe called multiple times but it is not
1401 * acceptable in our scenario */
1402 fail_if (idle_probe_running);
1404 idle_probe_running = TRUE;
1405 while (idle_probe_running) {
1409 return GST_PAD_PROBE_REMOVE;
1413 add_idle_probe_async (GstPad * pad)
1415 gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_IDLE, idle_probe_wait, NULL, NULL);
1420 GST_START_TEST (test_pad_blocking_with_probe_type_idle)
1422 GstPad *srcpad, *sinkpad;
1423 GThread *idle_thread, *thread;
1425 srcpad = gst_pad_new ("src", GST_PAD_SRC);
1426 fail_unless (srcpad != NULL);
1427 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
1428 fail_unless (sinkpad != NULL);
1430 gst_pad_set_chain_function (sinkpad, idletest_sink_pad_chain);
1432 fail_unless (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK);
1434 gst_pad_set_active (sinkpad, TRUE);
1435 gst_pad_set_active (srcpad, TRUE);
1437 fail_unless (gst_pad_push_event (srcpad,
1438 gst_event_new_stream_start ("test")) == TRUE);
1439 fail_unless (gst_pad_push_event (srcpad,
1440 gst_event_new_segment (&dummy_segment)) == TRUE);
1442 idle_probe_running = FALSE;
1444 g_thread_try_new ("gst-check", (GThreadFunc) add_idle_probe_async, srcpad,
1447 /* wait for the idle function to signal it is being called */
1448 while (!idle_probe_running) {
1452 thread = g_thread_try_new ("gst-check", (GThreadFunc) push_buffer_async,
1455 while (!gst_pad_is_blocking (srcpad)) {
1459 idle_probe_running = FALSE;
1461 g_thread_join (idle_thread);
1462 g_thread_join (thread);
1463 gst_object_unref (srcpad);
1464 gst_object_unref (sinkpad);
1469 static gboolean pull_probe_called;
1470 static gboolean pull_probe_called_with_bad_type;
1471 static gboolean pull_probe_called_with_bad_data;
1473 static GstPadProbeReturn
1474 probe_pull_buffer_cb_check_buffer_return_ok (GstPad * pad,
1475 GstPadProbeInfo * info, gpointer user_data)
1477 if (info->type & GST_PAD_PROBE_TYPE_BUFFER) {
1478 if (GST_IS_BUFFER (info->data))
1479 pull_probe_called = TRUE;
1481 pull_probe_called_with_bad_data = TRUE;
1483 /* shouldn't be called */
1484 pull_probe_called_with_bad_type = TRUE;
1486 return GST_PAD_PROBE_OK;
1489 static GstFlowReturn
1490 test_probe_pull_getrange (GstPad * pad, GstObject * parent, guint64 offset,
1491 guint length, GstBuffer ** buf)
1493 *buf = gst_buffer_new ();
1498 test_probe_pull_activate_pull (GstPad * pad, GstObject * object)
1500 return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
1504 pull_range_async (GstPad * pad)
1506 GstBuffer *buf = NULL;
1507 GstFlowReturn res = gst_pad_pull_range (pad, 0, 100, &buf);
1509 gst_buffer_unref (buf);
1510 return GINT_TO_POINTER (res);
1513 GST_START_TEST (test_pad_probe_pull)
1515 GstPad *srcpad, *sinkpad;
1519 srcpad = gst_pad_new ("src", GST_PAD_SRC);
1520 fail_unless (srcpad != NULL);
1521 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
1522 fail_unless (sinkpad != NULL);
1524 gst_pad_set_getrange_function (srcpad, test_probe_pull_getrange);
1525 gst_pad_set_activate_function (sinkpad, test_probe_pull_activate_pull);
1526 gst_pad_link (srcpad, sinkpad);
1528 gst_pad_set_active (sinkpad, TRUE);
1529 gst_pad_set_active (srcpad, TRUE);
1531 id = gst_pad_add_probe (sinkpad,
1532 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_PULL,
1533 block_async_cb_return_ok, NULL, NULL);
1535 thread = g_thread_try_new ("gst-check", (GThreadFunc) pull_range_async,
1538 /* wait for the block */
1539 while (!gst_pad_is_blocking (sinkpad)) {
1543 /* stop with flushing */
1544 gst_pad_push_event (srcpad, gst_event_new_flush_start ());
1546 /* get return value from push */
1547 ret = GPOINTER_TO_INT (g_thread_join (thread));
1549 gst_pad_push_event (srcpad, gst_event_new_flush_stop (FALSE));
1550 /* must be wrong state */
1551 fail_unless (ret == GST_FLOW_FLUSHING);
1553 gst_object_unref (srcpad);
1554 gst_object_unref (sinkpad);
1559 static gboolean idle_probe_called;
1560 static gboolean get_range_wait;
1561 static gboolean getrange_waiting;
1563 static GstPadProbeReturn
1564 idle_cb_return_ok (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1566 idle_probe_called = TRUE;
1567 return GST_PAD_PROBE_OK;
1570 static GstFlowReturn
1571 test_probe_pull_getrange_wait (GstPad * pad, GstObject * parent, guint64 offset,
1572 guint length, GstBuffer ** buf)
1574 getrange_waiting = TRUE;
1576 *buf = gst_buffer_new ();
1577 while (get_range_wait) {
1581 getrange_waiting = FALSE;
1585 GST_START_TEST (test_pad_probe_pull_idle)
1587 GstPad *srcpad, *sinkpad;
1591 srcpad = gst_pad_new ("src", GST_PAD_SRC);
1592 fail_unless (srcpad != NULL);
1593 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
1594 fail_unless (sinkpad != NULL);
1596 gst_pad_set_getrange_function (srcpad, test_probe_pull_getrange_wait);
1597 gst_pad_set_activate_function (sinkpad, test_probe_pull_activate_pull);
1598 gst_pad_link (srcpad, sinkpad);
1600 gst_pad_set_active (sinkpad, TRUE);
1601 gst_pad_set_active (srcpad, TRUE);
1603 idle_probe_called = FALSE;
1604 get_range_wait = TRUE;
1605 thread = g_thread_try_new ("gst-check", (GThreadFunc) pull_range_async,
1608 /* wait for the block */
1609 while (!getrange_waiting) {
1613 id = gst_pad_add_probe (sinkpad,
1614 GST_PAD_PROBE_TYPE_IDLE | GST_PAD_PROBE_TYPE_PULL,
1615 idle_cb_return_ok, NULL, NULL);
1617 fail_if (idle_probe_called);
1619 get_range_wait = FALSE;
1620 while (getrange_waiting) {
1623 while (!idle_probe_called) {
1627 ret = GPOINTER_TO_INT (g_thread_join (thread));
1628 fail_unless (ret == GST_FLOW_OK);
1629 gst_pad_set_active (srcpad, FALSE);
1630 gst_pad_set_active (sinkpad, FALSE);
1631 gst_object_unref (srcpad);
1632 gst_object_unref (sinkpad);
1638 GST_START_TEST (test_pad_probe_pull_buffer)
1640 GstPad *srcpad, *sinkpad;
1644 srcpad = gst_pad_new ("src", GST_PAD_SRC);
1645 fail_unless (srcpad != NULL);
1646 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
1647 fail_unless (sinkpad != NULL);
1649 gst_pad_set_getrange_function (srcpad, test_probe_pull_getrange);
1650 gst_pad_set_activate_function (sinkpad, test_probe_pull_activate_pull);
1651 gst_pad_link (srcpad, sinkpad);
1653 gst_pad_set_active (sinkpad, TRUE);
1654 gst_pad_set_active (srcpad, TRUE);
1656 id = gst_pad_add_probe (sinkpad,
1657 GST_PAD_PROBE_TYPE_BUFFER | GST_PAD_PROBE_TYPE_PULL,
1658 probe_pull_buffer_cb_check_buffer_return_ok, NULL, NULL);
1660 pull_probe_called = FALSE;
1661 pull_probe_called_with_bad_type = FALSE;
1662 pull_probe_called_with_bad_data = FALSE;
1664 thread = g_thread_try_new ("gst-check", (GThreadFunc) pull_range_async,
1667 /* wait for the block */
1668 while (!pull_probe_called && !pull_probe_called_with_bad_data
1669 && !pull_probe_called_with_bad_type) {
1673 fail_unless (pull_probe_called);
1674 fail_if (pull_probe_called_with_bad_data);
1675 fail_if (pull_probe_called_with_bad_type);
1677 /* get return value from push */
1678 ret = GPOINTER_TO_INT (g_thread_join (thread));
1679 fail_unless (ret == GST_FLOW_OK);
1681 gst_pad_set_active (sinkpad, FALSE);
1682 gst_pad_set_active (srcpad, FALSE);
1683 gst_object_unref (srcpad);
1684 gst_object_unref (sinkpad);
1689 static gboolean pad_probe_remove_notifiy_called = FALSE;
1691 static GstPadProbeReturn
1692 probe_remove_self_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1694 gst_pad_remove_probe (pad, info->id);
1696 fail_unless (pad->num_probes == 0);
1697 fail_unless (pad->num_blocked == 0);
1699 return GST_PAD_PROBE_REMOVE;
1703 probe_remove_notify_cb (gpointer data)
1705 fail_unless (pad_probe_remove_notifiy_called == FALSE);
1706 pad_probe_remove_notifiy_called = TRUE;
1709 GST_START_TEST (test_pad_probe_remove)
1713 pad = gst_pad_new ("src", GST_PAD_SRC);
1714 fail_unless (pad != NULL);
1716 gst_pad_set_active (pad, TRUE);
1717 fail_unless (pad->num_probes == 0);
1718 fail_unless (pad->num_blocked == 0);
1719 gst_pad_add_probe (pad,
1720 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
1721 probe_remove_self_cb, NULL, probe_remove_notify_cb);
1722 fail_unless (pad->num_probes == 1);
1723 fail_unless (pad->num_blocked == 1);
1725 pad_probe_remove_notifiy_called = FALSE;
1726 gst_pad_push_event (pad, gst_event_new_stream_start ("asda"));
1728 fail_unless (pad->num_probes == 0);
1729 fail_unless (pad->num_blocked == 0);
1731 gst_object_unref (pad);
1741 } BlockReplaceProbeHelper;
1744 unblock_probe_thread (gpointer user_data)
1746 BlockReplaceProbeHelper *helper = user_data;
1748 GST_INFO_OBJECT (helper->probe_pad, "removing probe to unblock pad");
1749 gst_pad_remove_probe (helper->probe_pad, helper->probe_id);
1753 static GstPadProbeReturn
1754 block_and_replace_buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info,
1757 BlockReplaceProbeHelper *helper = user_data;
1759 GST_INFO_OBJECT (pad, "about to block pad, replacing buffer");
1761 /* we want to block, but also drop this buffer */
1762 gst_buffer_unref (GST_BUFFER (info->data));
1766 g_thread_new ("gst-pad-test-thread", unblock_probe_thread, helper);
1768 return GST_PAD_PROBE_OK;
1771 GST_START_TEST (test_pad_probe_block_and_drop_buffer)
1773 BlockReplaceProbeHelper helper;
1777 src = gst_pad_new ("src", GST_PAD_SRC);
1778 gst_pad_set_active (src, TRUE);
1779 sink = gst_pad_new ("sink", GST_PAD_SINK);
1780 gst_pad_set_chain_function (sink, gst_check_chain_func);
1781 gst_pad_set_active (sink, TRUE);
1783 fail_unless (gst_pad_push_event (src,
1784 gst_event_new_stream_start ("test")) == TRUE);
1785 fail_unless (gst_pad_push_event (src,
1786 gst_event_new_segment (&dummy_segment)) == TRUE);
1788 fail_unless_equals_int (gst_pad_link (src, sink), GST_PAD_LINK_OK);
1790 helper.probe_id = gst_pad_add_probe (src,
1791 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1792 block_and_replace_buffer_probe_cb, &helper, NULL);
1793 helper.probe_pad = src;
1795 /* push a buffer so the events are propagated downstream */
1796 flow = gst_pad_push (src, gst_buffer_new ());
1798 g_thread_join (helper.thread);
1800 fail_unless_equals_int (flow, GST_FLOW_OK);
1802 /* no buffer should have made it through to the sink pad, and especially
1803 * not a NULL pointer buffer */
1804 fail_if (buffers && buffers->data == NULL);
1805 fail_unless (buffers == NULL);
1807 gst_check_drop_buffers ();
1808 gst_object_unref (src);
1809 gst_object_unref (sink);
1814 static GstPadProbeReturn
1815 probe_block_ok (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1817 gboolean *called = user_data;
1820 return GST_PAD_PROBE_OK;
1823 static GstPadProbeReturn
1824 probe_block_remove (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1826 gboolean *called = user_data;
1828 return GST_PAD_PROBE_REMOVE;
1831 GST_START_TEST (test_pad_probe_block_add_remove)
1835 gulong probe_a, probe_b;
1839 pad = gst_pad_new ("src", GST_PAD_SRC);
1840 fail_unless (pad != NULL);
1842 gst_pad_set_active (pad, TRUE);
1843 fail_unless (pad->num_probes == 0);
1844 fail_unless (pad->num_blocked == 0);
1846 fail_unless (gst_pad_push_event (pad,
1847 gst_event_new_stream_start ("test")) == TRUE);
1848 fail_unless (gst_pad_push_event (pad,
1849 gst_event_new_segment (&dummy_segment)) == TRUE);
1851 probe_a = gst_pad_add_probe (pad,
1852 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1853 probe_block_ok, NULL, NULL);
1855 fail_unless (pad->num_probes == 1);
1856 fail_unless (pad->num_blocked == 1);
1858 thread = g_thread_try_new ("gst-check", (GThreadFunc) push_buffer_async,
1861 /* wait for the block */
1862 while (!gst_pad_is_blocking (pad))
1865 /* alternate 2 probes 100 times */
1866 for (r = 0; r < 100; r++) {
1868 probe_b = gst_pad_add_probe (pad,
1869 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1870 probe_block_ok, &called, NULL);
1872 gst_pad_remove_probe (pad, probe_a);
1874 /* wait for the callback */
1879 probe_a = gst_pad_add_probe (pad,
1880 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1881 probe_block_ok, &called, NULL);
1883 gst_pad_remove_probe (pad, probe_b);
1885 /* wait for the callback */
1891 gst_pad_add_probe (pad,
1892 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1893 probe_block_remove, &called, NULL);
1895 gst_pad_remove_probe (pad, probe_a);
1897 /* wait for the callback */
1901 /* wait for the unblock */
1902 while (gst_pad_is_blocking (pad))
1905 gst_object_unref (pad);
1906 g_thread_join (thread);
1911 static gboolean src_flush_start_probe_called = FALSE;
1912 static gboolean src_flush_stop_probe_called = FALSE;
1913 static gboolean sink_flush_start_probe_called = FALSE;
1914 static gboolean sink_flush_stop_probe_called = FALSE;
1916 static GstPadProbeReturn
1917 flush_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1921 if (!(GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_EVENT_FLUSH))
1924 event = gst_pad_probe_info_get_event (info);
1925 switch (GST_EVENT_TYPE (event)) {
1926 case GST_EVENT_FLUSH_START:
1927 if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
1928 src_flush_start_probe_called = TRUE;
1930 sink_flush_start_probe_called = TRUE;
1932 case GST_EVENT_FLUSH_STOP:
1933 if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
1934 src_flush_stop_probe_called = TRUE;
1936 sink_flush_stop_probe_called = TRUE;
1943 return GST_PAD_PROBE_OK;
1946 GST_START_TEST (test_pad_probe_flush_events)
1950 src = gst_pad_new ("src", GST_PAD_SRC);
1951 sink = gst_pad_new ("sink", GST_PAD_SINK);
1952 gst_pad_set_chain_function (sink, gst_check_chain_func);
1953 gst_pad_set_active (src, TRUE);
1954 gst_pad_set_active (sink, TRUE);
1956 fail_unless (gst_pad_push_event (src,
1957 gst_event_new_stream_start ("test")) == TRUE);
1958 fail_unless (gst_pad_push_event (src,
1959 gst_event_new_segment (&dummy_segment)) == TRUE);
1961 fail_unless (gst_pad_link (src, sink) == GST_PAD_LINK_OK);
1963 gst_pad_add_probe (src,
1964 GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM |
1965 GST_PAD_PROBE_TYPE_EVENT_FLUSH, flush_probe_cb, NULL, NULL);
1966 gst_pad_add_probe (sink,
1967 GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM |
1968 GST_PAD_PROBE_TYPE_EVENT_FLUSH, flush_probe_cb, NULL, NULL);
1970 gst_pad_push_event (src, gst_event_new_flush_start ());
1971 gst_pad_push_event (src, gst_event_new_flush_stop (TRUE));
1973 fail_unless (gst_pad_push_event (src,
1974 gst_event_new_segment (&dummy_segment)) == TRUE);
1976 /* push a buffer so the events are propagated downstream */
1977 gst_pad_push (src, gst_buffer_new ());
1979 fail_unless (src_flush_start_probe_called);
1980 fail_unless (src_flush_stop_probe_called);
1981 fail_unless (sink_flush_start_probe_called);
1982 fail_unless (sink_flush_stop_probe_called);
1984 gst_check_drop_buffers ();
1985 gst_object_unref (src);
1986 gst_object_unref (sink);
1991 static gboolean probe_was_called;
1993 static GstPadProbeReturn
1994 flush_events_only_probe (GstPad * pad, GstPadProbeInfo * info, gpointer data)
1996 GST_LOG_OBJECT (pad, "%" GST_PTR_FORMAT, GST_PAD_PROBE_INFO_DATA (info));
1998 probe_was_called = TRUE;
2000 return GST_PAD_PROBE_OK;
2003 GST_START_TEST (test_pad_probe_flush_events_only)
2007 src = gst_pad_new ("src", GST_PAD_SRC);
2008 sink = gst_pad_new ("sink", GST_PAD_SINK);
2009 gst_pad_set_chain_function (sink, gst_check_chain_func);
2010 gst_pad_set_active (src, TRUE);
2011 gst_pad_set_active (sink, TRUE);
2013 fail_unless (gst_pad_link (src, sink) == GST_PAD_LINK_OK);
2015 fail_unless (gst_pad_push_event (src,
2016 gst_event_new_stream_start ("test")) == TRUE);
2018 gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_EVENT_FLUSH,
2019 flush_events_only_probe, NULL, NULL);
2021 probe_was_called = FALSE;
2022 fail_unless (gst_pad_push_event (src,
2023 gst_event_new_segment (&dummy_segment)) == TRUE);
2024 fail_if (probe_was_called);
2026 fail_unless_equals_int (gst_pad_push (src, gst_buffer_new ()), GST_FLOW_OK);
2027 fail_if (probe_was_called);
2029 gst_pad_push_event (src, gst_event_new_flush_start ());
2030 fail_unless (probe_was_called);
2032 probe_was_called = FALSE;
2033 gst_pad_push_event (src, gst_event_new_flush_stop (TRUE));
2034 fail_unless (probe_was_called);
2036 gst_check_drop_buffers ();
2037 gst_object_unref (src);
2038 gst_object_unref (sink);
2043 #define NUM_PROBES 4
2046 static GstPadProbeReturn
2047 order_others_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
2049 *(guint *) (user_data) = ++count;
2051 return GST_PAD_PROBE_REMOVE;
2054 GST_START_TEST (test_pad_probe_call_order)
2058 guint counters[NUM_PROBES];
2061 src = gst_pad_new ("src", GST_PAD_SRC);
2062 gst_pad_set_active (src, TRUE);
2063 sink = gst_pad_new ("sink", GST_PAD_SINK);
2064 gst_pad_set_chain_function (sink, gst_check_chain_func);
2065 gst_pad_set_active (sink, TRUE);
2067 fail_unless (gst_pad_push_event (src,
2068 gst_event_new_stream_start ("test")) == TRUE);
2069 fail_unless (gst_pad_push_event (src,
2070 gst_event_new_segment (&dummy_segment)) == TRUE);
2072 fail_unless_equals_int (gst_pad_link (src, sink), GST_PAD_LINK_OK);
2074 for (i = 0; i < NUM_PROBES; i++) {
2075 gst_pad_add_probe (src,
2076 GST_PAD_PROBE_TYPE_BUFFER, order_others_probe_cb, &(counters[i]), NULL);
2079 /* push a buffer so the events are propagated downstream */
2080 flow = gst_pad_push (src, gst_buffer_new ());
2081 fail_unless_equals_int (flow, GST_FLOW_OK);
2083 for (i = 0; i < NUM_PROBES; i++) {
2084 fail_unless (counters[i] == i + 1);
2087 gst_check_drop_buffers ();
2088 gst_object_unref (src);
2089 gst_object_unref (sink);
2094 static GstPadProbeReturn
2095 buffers_probe_handled (GstPad * pad, GstPadProbeInfo * info, gpointer gp)
2097 if (GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_BUFFER) {
2098 GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
2100 GST_DEBUG_OBJECT (pad, "buffer: %" GST_PTR_FORMAT ", refcount: %d",
2101 buffer, (GST_MINI_OBJECT (buffer))->refcount);
2102 gst_buffer_unref (buffer);
2105 return GST_PAD_PROBE_HANDLED;
2108 static GstPadProbeReturn
2109 buffers_probe_drop (GstPad * pad, GstPadProbeInfo * info, gboolean * called)
2111 if (GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_BUFFER) {
2112 GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
2114 GST_DEBUG_OBJECT (pad, "buffer: %" GST_PTR_FORMAT ", refcount: %d",
2115 buffer, (GST_MINI_OBJECT (buffer))->refcount);
2119 return GST_PAD_PROBE_DROP;
2122 GST_START_TEST (test_pad_probe_handled_and_drop)
2128 src = gst_pad_new ("src", GST_PAD_SRC);
2129 gst_pad_set_active (src, TRUE);
2130 sink = gst_pad_new ("sink", GST_PAD_SINK);
2131 gst_pad_set_chain_function (sink, gst_check_chain_func);
2132 gst_pad_set_active (sink, TRUE);
2134 fail_unless (gst_pad_push_event (src,
2135 gst_event_new_stream_start ("test")) == TRUE);
2136 fail_unless (gst_pad_push_event (src,
2137 gst_event_new_segment (&dummy_segment)) == TRUE);
2139 fail_unless_equals_int (gst_pad_link (src, sink), GST_PAD_LINK_OK);
2141 gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
2142 (GstPadProbeCallback) buffers_probe_handled, NULL, NULL);
2143 gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
2144 (GstPadProbeCallback) buffers_probe_drop, &called, NULL);
2147 flow = gst_pad_push (src, gst_buffer_new ());
2148 fail_unless_equals_int (flow, GST_FLOW_OK);
2151 /* no buffer should have made it through to the sink pad, and especially
2152 * not a NULL pointer buffer */
2153 fail_if (buffers && buffers->data == NULL);
2154 fail_unless (buffers == NULL);
2156 gst_object_unref (src);
2157 gst_object_unref (sink);
2162 static gboolean got_notify;
2165 caps_notify (GstPad * pad, GParamSpec * spec, gpointer data)
2171 test_queue_src_caps_notify (gboolean link_queue)
2174 GstPad *src, *sink, *another_pad;
2177 queue = gst_element_factory_make ("queue", NULL);
2178 fail_unless (queue != NULL);
2180 src = gst_element_get_static_pad (queue, "src");
2181 fail_unless (src != NULL);
2183 sink = gst_element_get_static_pad (queue, "sink");
2184 fail_unless (sink != NULL);
2187 another_pad = gst_pad_new ("sink", GST_PAD_SINK);
2188 fail_unless (another_pad != NULL);
2189 gst_pad_set_active (another_pad, TRUE);
2191 gst_pad_link_full (src, another_pad, GST_PAD_LINK_CHECK_NOTHING);
2196 gst_element_set_state (queue, GST_STATE_PLAYING);
2200 g_signal_connect (src, "notify::caps", G_CALLBACK (caps_notify), NULL);
2202 caps = gst_caps_from_string ("caps");
2203 gst_pad_send_event (sink, gst_event_new_caps (caps));
2204 gst_caps_unref (caps);
2206 while (got_notify == FALSE)
2209 gst_element_set_state (queue, GST_STATE_NULL);
2211 gst_object_unref (src);
2212 gst_object_unref (sink);
2213 gst_object_unref (queue);
2215 gst_object_unref (another_pad);
2219 GST_START_TEST (test_queue_src_caps_notify_linked)
2221 test_queue_src_caps_notify (TRUE);
2225 GST_START_TEST (test_queue_src_caps_notify_not_linked)
2227 /* This test will fail because queue doesn't set the caps
2228 on src pad unless it is linked */
2229 test_queue_src_caps_notify (FALSE);
2236 block_async_second (GstPad * pad, gboolean blocked, gpointer user_data)
2238 gst_pad_set_blocked (pad, FALSE, unblock_async_cb, NULL, NULL);
2242 block_async_first (GstPad * pad, gboolean blocked, gpointer user_data)
2244 static int n_calls = 0;
2245 gboolean *bool_user_data = (gboolean *) user_data;
2248 /* we expect this callback to be called only once */
2249 g_warn_if_reached ();
2251 *bool_user_data = blocked;
2253 /* replace block_async_first with block_async_second so next time the pad is
2254 * blocked the latter should be called */
2255 gst_pad_set_blocked (pad, TRUE, block_async_second, NULL, NULL);
2257 /* unblock temporarily, in the next push block_async_second should be called
2259 gst_pad_push_event (pad, gst_event_new_flush_start ());
2262 GST_START_TEST (test_block_async_replace_callback)
2267 pad = gst_pad_new ("src", GST_PAD_SRC);
2268 fail_unless (pad != NULL);
2269 gst_pad_set_active (pad, TRUE);
2271 gst_pad_set_blocked (pad, TRUE, block_async_first, &blocked, NULL);
2274 gst_pad_push (pad, gst_buffer_new ());
2275 fail_unless (blocked == TRUE);
2276 /* block_async_first flushes to unblock */
2277 gst_pad_push_event (pad, gst_event_new_flush_stop ());
2279 /* push again, this time block_async_second should be called */
2280 gst_pad_push (pad, gst_buffer_new ());
2281 fail_unless (blocked == TRUE);
2283 gst_object_unref (pad);
2290 block_async_full_destroy (gpointer user_data)
2292 gint *state = (gint *) user_data;
2294 fail_unless (*state < 2);
2296 GST_DEBUG ("setting state to 2");
2300 static GstPadProbeReturn
2301 block_async_full_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
2303 *(gint *) user_data = (gint) TRUE;
2305 gst_pad_push_event (pad, gst_event_new_flush_start ());
2306 GST_DEBUG ("setting state to 1");
2308 return GST_PAD_PROBE_OK;
2311 GST_START_TEST (test_block_async_full_destroy)
2314 /* 0 = unblocked, 1 = blocked, 2 = destroyed */
2318 pad = gst_pad_new ("src", GST_PAD_SRC);
2319 fail_unless (pad != NULL);
2320 gst_pad_set_active (pad, TRUE);
2322 fail_unless (gst_pad_push_event (pad,
2323 gst_event_new_stream_start ("test")) == TRUE);
2324 fail_unless (gst_pad_push_event (pad,
2325 gst_event_new_segment (&dummy_segment)) == TRUE);
2327 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK, block_async_full_cb,
2328 &state, block_async_full_destroy);
2329 fail_unless (state == 0);
2331 gst_pad_push (pad, gst_buffer_new ());
2332 /* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
2334 fail_unless (state == 1);
2335 gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
2337 /* unblock callback is called */
2338 gst_pad_remove_probe (pad, id);
2339 fail_unless (state == 2);
2341 gst_object_unref (pad);
2346 GST_START_TEST (test_block_async_full_destroy_dispose)
2349 /* 0 = unblocked, 1 = blocked, 2 = destroyed */
2352 pad = gst_pad_new ("src", GST_PAD_SRC);
2353 fail_unless (pad != NULL);
2354 gst_pad_set_active (pad, TRUE);
2356 fail_unless (gst_pad_push_event (pad,
2357 gst_event_new_stream_start ("test")) == TRUE);
2358 fail_unless (gst_pad_push_event (pad,
2359 gst_event_new_segment (&dummy_segment)) == TRUE);
2361 (void) gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK, block_async_full_cb,
2362 &state, block_async_full_destroy);
2364 gst_pad_push (pad, gst_buffer_new ());
2365 /* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
2367 fail_unless_equals_int (state, 1);
2368 gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
2370 /* gst_BLOCK calls the destroy_notify function if necessary */
2371 gst_object_unref (pad);
2373 fail_unless_equals_int (state, 2);
2381 unblock_async_no_flush_cb (GstPad * pad, gboolean blocked, gpointer user_data)
2383 gboolean *bool_user_data = (gboolean *) user_data;
2385 /* here we should have blocked == 1 unblocked == 0 */
2387 fail_unless (blocked == FALSE);
2389 fail_unless (bool_user_data[0] == TRUE);
2390 fail_unless (bool_user_data[1] == TRUE);
2391 fail_unless (bool_user_data[2] == FALSE);
2393 bool_user_data[2] = TRUE;
2400 unblock_async_not_called (GstPad * pad, gboolean blocked, gpointer user_data)
2402 g_warn_if_reached ();
2406 static GstPadProbeReturn
2407 block_async_second_no_flush (GstPad * pad, GstPadProbeInfo * info,
2410 gboolean *bool_user_data = (gboolean *) user_data;
2412 GST_DEBUG ("second probe called");
2414 fail_unless (info->type & GST_PAD_PROBE_TYPE_BLOCK);
2416 fail_unless (bool_user_data[0] == TRUE);
2417 fail_unless (bool_user_data[1] == FALSE);
2418 fail_unless (bool_user_data[2] == FALSE);
2420 bool_user_data[1] = TRUE;
2422 GST_DEBUG ("removing second probe with id %lu", id);
2423 gst_pad_remove_probe (pad, id);
2425 return GST_PAD_PROBE_OK;
2428 static GstPadProbeReturn
2429 block_async_first_no_flush (GstPad * pad, GstPadProbeInfo * info,
2432 static int n_calls = 0;
2433 gboolean *bool_user_data = (gboolean *) user_data;
2435 fail_unless (info->type & GST_PAD_PROBE_TYPE_BLOCK);
2437 GST_DEBUG ("first probe called");
2440 /* we expect this callback to be called only once */
2441 g_warn_if_reached ();
2443 *bool_user_data = TRUE;
2445 fail_unless (bool_user_data[0] == TRUE);
2446 fail_unless (bool_user_data[1] == FALSE);
2447 fail_unless (bool_user_data[2] == FALSE);
2449 GST_DEBUG ("removing first probe with id %lu", id);
2450 gst_pad_remove_probe (pad, id);
2452 GST_DEBUG ("adding second probe");
2453 /* replace block_async_first with block_async_second so next time the pad is
2454 * blocked the latter should be called */
2455 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK,
2456 block_async_second_no_flush, user_data, NULL);
2457 GST_DEBUG ("added probe with id %lu", id);
2459 return GST_PAD_PROBE_OK;
2462 GST_START_TEST (test_block_async_replace_callback_no_flush)
2465 gboolean bool_user_data[3] = { FALSE, FALSE, FALSE };
2467 pad = gst_pad_new ("src", GST_PAD_SRC);
2468 fail_unless (pad != NULL);
2469 gst_pad_set_active (pad, TRUE);
2471 fail_unless (gst_pad_push_event (pad,
2472 gst_event_new_stream_start ("test")) == TRUE);
2473 fail_unless (gst_pad_push_event (pad,
2474 gst_event_new_segment (&dummy_segment)) == TRUE);
2476 GST_DEBUG ("adding probe");
2477 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK,
2478 block_async_first_no_flush, bool_user_data, NULL);
2479 GST_DEBUG ("added probe with id %lu", id);
2482 GST_DEBUG ("pushing buffer");
2483 gst_pad_push (pad, gst_buffer_new ());
2484 fail_unless (bool_user_data[0] == TRUE);
2485 fail_unless (bool_user_data[1] == TRUE);
2486 fail_unless (bool_user_data[2] == FALSE);
2488 gst_object_unref (pad);
2493 static gint sticky_count;
2496 test_sticky_events_handler (GstPad * pad, GstObject * parent, GstEvent * event)
2498 GST_DEBUG_OBJECT (pad, "received event %" GST_PTR_FORMAT, event);
2500 switch (sticky_count) {
2502 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START);
2509 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CAPS);
2511 gst_event_parse_caps (event, &caps);
2512 fail_unless (gst_caps_get_size (caps) == 1);
2513 s = gst_caps_get_structure (caps, 0);
2514 fail_unless (gst_structure_has_name (s, "foo/baz"));
2518 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
2521 fail_unless (FALSE);
2525 gst_event_unref (event);
2531 static GstFlowReturn
2532 test_sticky_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
2534 gst_buffer_unref (buffer);
2538 GST_START_TEST (test_sticky_events)
2540 GstPad *srcpad, *sinkpad;
2545 /* make unlinked srcpad */
2546 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2547 fail_unless (srcpad != NULL);
2548 gst_pad_set_active (srcpad, TRUE);
2550 /* test stream-start */
2551 fail_unless (gst_pad_get_stream_id (srcpad) == NULL);
2553 /* push an event, it should be sticky on the srcpad */
2554 fail_unless (gst_pad_push_event (srcpad,
2555 gst_event_new_stream_start ("test")) == TRUE);
2557 /* let's see if it stuck */
2558 id = gst_pad_get_stream_id (srcpad);
2559 fail_unless_equals_string (id, "test");
2562 /* make a caps event */
2563 caps = gst_caps_new_empty_simple ("foo/bar");
2564 gst_pad_push_event (srcpad, gst_event_new_caps (caps));
2565 gst_caps_unref (caps);
2567 /* make segment event */
2568 gst_segment_init (&seg, GST_FORMAT_TIME);
2569 gst_pad_push_event (srcpad, gst_event_new_segment (&seg));
2571 /* now make a sinkpad */
2572 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2573 fail_unless (sinkpad != NULL);
2575 gst_pad_set_event_function (sinkpad, test_sticky_events_handler);
2576 gst_pad_set_chain_function (sinkpad, test_sticky_chain);
2577 fail_unless (sticky_count == 0);
2578 gst_pad_set_active (sinkpad, TRUE);
2581 gst_pad_link (srcpad, sinkpad);
2582 /* should not trigger events */
2583 fail_unless (sticky_count == 0);
2585 /* caps replaces old caps event at position 2, the pushes all
2587 caps = gst_caps_new_empty_simple ("foo/baz");
2588 gst_pad_push_event (srcpad, gst_event_new_caps (caps));
2589 gst_caps_unref (caps);
2591 /* should have triggered 2 events, the segment event is still pending */
2592 fail_unless_equals_int (sticky_count, 2);
2594 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
2596 /* should have triggered 3 events */
2597 fail_unless_equals_int (sticky_count, 3);
2599 gst_object_unref (srcpad);
2600 gst_object_unref (sinkpad);
2605 static GstFlowReturn next_return;
2607 static GstFlowReturn
2608 test_lastflow_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
2610 gst_buffer_unref (buffer);
2614 GST_START_TEST (test_last_flow_return_push)
2616 GstPad *srcpad, *sinkpad;
2619 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2620 fail_unless (srcpad != NULL);
2621 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2622 fail_unless (sinkpad != NULL);
2623 gst_pad_set_chain_function (sinkpad, test_lastflow_chain);
2624 gst_pad_link (srcpad, sinkpad);
2626 /* initial value is flushing */
2627 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_FLUSHING);
2629 /* when active it goes to ok */
2630 gst_pad_set_active (srcpad, TRUE);
2631 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
2632 gst_pad_set_active (sinkpad, TRUE);
2634 /* startup events */
2635 gst_pad_push_event (srcpad, gst_event_new_stream_start ("test"));
2636 gst_segment_init (&seg, GST_FORMAT_TIME);
2637 gst_pad_push_event (srcpad, gst_event_new_segment (&seg));
2641 next_return = GST_FLOW_OK;
2642 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
2643 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
2645 /* push not-linked */
2646 next_return = GST_FLOW_NOT_LINKED;
2647 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_NOT_LINKED);
2648 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
2650 /* push not-linked */
2651 next_return = GST_FLOW_NOT_NEGOTIATED;
2652 fail_unless (gst_pad_push (srcpad,
2653 gst_buffer_new ()) == GST_FLOW_NOT_NEGOTIATED);
2654 fail_unless (gst_pad_get_last_flow_return (srcpad) ==
2655 GST_FLOW_NOT_NEGOTIATED);
2658 next_return = GST_FLOW_ERROR;
2659 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_ERROR);
2660 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_ERROR);
2663 next_return = GST_FLOW_OK;
2664 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
2665 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
2668 gst_pad_unlink (srcpad, sinkpad);
2669 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_NOT_LINKED);
2670 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
2672 gst_pad_link (srcpad, sinkpad);
2673 fail_unless (gst_pad_push_event (srcpad, gst_event_new_eos ()));
2674 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_EOS);
2676 gst_object_unref (srcpad);
2677 gst_object_unref (sinkpad);
2682 static GstFlowReturn
2683 test_lastflow_getrange (GstPad * pad, GstObject * parent, guint64 offset,
2684 guint length, GstBuffer ** buf)
2686 if (next_return == GST_FLOW_OK)
2687 *buf = gst_buffer_new ();
2694 test_lastflow_activate_pull_func (GstPad * pad, GstObject * object)
2696 return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
2699 GST_START_TEST (test_last_flow_return_pull)
2701 GstPad *srcpad, *sinkpad;
2702 GstBuffer *buf = NULL;
2704 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2705 fail_unless (srcpad != NULL);
2706 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2707 fail_unless (sinkpad != NULL);
2708 gst_pad_set_getrange_function (srcpad, test_lastflow_getrange);
2709 gst_pad_set_activate_function (sinkpad, test_lastflow_activate_pull_func);
2710 gst_pad_link (srcpad, sinkpad);
2712 /* initial value is flushing */
2713 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_FLUSHING);
2715 /* when active it goes to ok */
2716 gst_pad_set_active (sinkpad, TRUE);
2717 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
2718 gst_pad_set_active (srcpad, TRUE);
2721 next_return = GST_FLOW_OK;
2722 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_OK);
2723 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
2724 gst_buffer_unref (buf);
2727 /* pull not-linked */
2728 next_return = GST_FLOW_NOT_LINKED;
2729 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_NOT_LINKED);
2730 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
2733 next_return = GST_FLOW_ERROR;
2734 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_ERROR);
2735 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_ERROR);
2738 next_return = GST_FLOW_NOT_NEGOTIATED;
2739 fail_unless (gst_pad_pull_range (sinkpad, 0, 1,
2740 &buf) == GST_FLOW_NOT_NEGOTIATED);
2741 fail_unless (gst_pad_get_last_flow_return (sinkpad) ==
2742 GST_FLOW_NOT_NEGOTIATED);
2745 next_return = GST_FLOW_OK;
2746 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_OK);
2747 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
2748 gst_buffer_unref (buf);
2752 gst_pad_unlink (srcpad, sinkpad);
2753 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_NOT_LINKED);
2754 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
2757 gst_pad_link (srcpad, sinkpad);
2758 next_return = GST_FLOW_EOS;
2759 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_EOS);
2760 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_EOS);
2762 gst_object_unref (srcpad);
2763 gst_object_unref (sinkpad);
2768 GST_START_TEST (test_flush_stop_inactive)
2770 GstPad *sinkpad, *srcpad;
2772 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2773 fail_unless (sinkpad != NULL);
2775 /* new pads are inactive and flushing */
2776 fail_if (GST_PAD_IS_ACTIVE (sinkpad));
2777 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2779 /* this should fail, pad is inactive */
2780 fail_if (gst_pad_send_event (sinkpad, gst_event_new_flush_stop (FALSE)));
2782 /* nothing should have changed */
2783 fail_if (GST_PAD_IS_ACTIVE (sinkpad));
2784 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2786 gst_pad_set_active (sinkpad, TRUE);
2788 /* pad is now active an not flushing anymore */
2789 fail_unless (GST_PAD_IS_ACTIVE (sinkpad));
2790 fail_if (GST_PAD_IS_FLUSHING (sinkpad));
2792 /* do flush, does not deactivate the pad */
2793 fail_unless (gst_pad_send_event (sinkpad, gst_event_new_flush_start ()));
2794 fail_unless (GST_PAD_IS_ACTIVE (sinkpad));
2795 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2797 fail_unless (gst_pad_send_event (sinkpad, gst_event_new_flush_stop (FALSE)));
2798 fail_unless (GST_PAD_IS_ACTIVE (sinkpad));
2799 fail_if (GST_PAD_IS_FLUSHING (sinkpad));
2801 gst_pad_set_active (sinkpad, FALSE);
2802 fail_if (GST_PAD_IS_ACTIVE (sinkpad));
2803 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2805 gst_object_unref (sinkpad);
2807 /* we should not be able to push on an inactive srcpad */
2808 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2809 fail_unless (srcpad != NULL);
2811 fail_if (GST_PAD_IS_ACTIVE (srcpad));
2812 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2814 fail_if (gst_pad_push_event (srcpad, gst_event_new_flush_stop (FALSE)));
2816 /* should still be inactive and flushing */
2817 fail_if (GST_PAD_IS_ACTIVE (srcpad));
2818 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2820 gst_pad_set_active (srcpad, TRUE);
2822 /* pad is now active an not flushing anymore */
2823 fail_unless (GST_PAD_IS_ACTIVE (srcpad));
2824 fail_if (GST_PAD_IS_FLUSHING (srcpad));
2826 /* do flush, does not deactivate the pad */
2827 fail_if (gst_pad_push_event (srcpad, gst_event_new_flush_start ()));
2828 fail_unless (GST_PAD_IS_ACTIVE (srcpad));
2829 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2831 fail_if (gst_pad_push_event (srcpad, gst_event_new_flush_stop (FALSE)));
2832 fail_unless (GST_PAD_IS_ACTIVE (srcpad));
2833 fail_if (GST_PAD_IS_FLUSHING (srcpad));
2835 gst_pad_set_active (srcpad, FALSE);
2836 fail_if (GST_PAD_IS_ACTIVE (srcpad));
2837 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2839 gst_object_unref (srcpad);
2844 /* For proxy caps flag tests */
2846 typedef struct _GstProxyTestElement GstProxyTestElement;
2847 typedef struct _GstProxyTestElementClass GstProxyTestElementClass;
2849 struct _GstProxyTestElement
2854 struct _GstProxyTestElementClass
2856 GstElementClass parent_class;
2859 G_GNUC_INTERNAL GType gst_proxytestelement_get_type (void);
2861 static GstStaticPadTemplate proxytestelement_peer_template =
2862 GST_STATIC_PAD_TEMPLATE ("sink",
2865 GST_STATIC_CAPS ("test/proxy, option=(int)1"));
2867 static GstStaticPadTemplate proxytestelement_peer_incompatible_template =
2868 GST_STATIC_PAD_TEMPLATE ("sink",
2871 GST_STATIC_CAPS ("test/proxy-incompatible"));
2873 static GstStaticPadTemplate proxytestelement_sink_template =
2874 GST_STATIC_PAD_TEMPLATE ("sink",
2877 GST_STATIC_CAPS ("test/proxy"));
2879 static GstStaticPadTemplate proxytestelement_src_template =
2880 GST_STATIC_PAD_TEMPLATE ("src",
2883 GST_STATIC_CAPS_ANY);
2885 G_DEFINE_TYPE (GstProxyTestElement, gst_proxytestelement, GST_TYPE_ELEMENT);
2888 gst_proxytestelement_class_init (GstProxyTestElementClass * klass)
2890 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
2892 gst_element_class_set_static_metadata (gstelement_class,
2893 "Proxy Test Element", "Test", "Proxy test element",
2894 "Thiago Santos <thiagoss@osg.samsung.com>");
2896 gst_element_class_add_static_pad_template (gstelement_class,
2897 &proxytestelement_sink_template);
2901 gst_proxytestelement_init (GstProxyTestElement * element)
2905 gst_pad_new_from_static_template (&proxytestelement_sink_template,
2907 GST_PAD_SET_PROXY_CAPS (sinkpad);
2908 gst_element_add_pad (GST_ELEMENT_CAST (element), sinkpad);
2911 GST_START_TEST (test_proxy_accept_caps_no_proxy)
2913 GstElement *element;
2917 gst_element_register (NULL, "proxytestelement", GST_RANK_NONE,
2918 gst_proxytestelement_get_type ());
2919 element = gst_element_factory_make ("proxytestelement", NULL);
2920 sinkpad = gst_element_get_static_pad (element, "sink");
2922 gst_element_set_state (element, GST_STATE_PLAYING);
2924 caps = gst_caps_from_string ("test/proxy");
2925 fail_unless (gst_pad_query_accept_caps (sinkpad, caps));
2926 gst_caps_unref (caps);
2928 caps = gst_caps_from_string ("test/bad");
2929 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
2930 gst_caps_unref (caps);
2932 gst_object_unref (sinkpad);
2933 gst_element_set_state (element, GST_STATE_NULL);
2934 gst_object_unref (element);
2940 GST_START_TEST (test_proxy_accept_caps_with_proxy)
2942 GstElement *element;
2943 GstPad *sinkpad, *srcpad;
2947 gst_element_register (NULL, "proxytestelement", GST_RANK_NONE,
2948 gst_proxytestelement_get_type ());
2949 element = gst_element_factory_make ("proxytestelement", NULL);
2952 gst_pad_new_from_static_template (&proxytestelement_src_template, "src");
2953 gst_element_add_pad (GST_ELEMENT_CAST (element), srcpad);
2955 sinkpad = gst_element_get_static_pad (element, "sink");
2956 srcpad = gst_element_get_static_pad (element, "src");
2959 gst_pad_new_from_static_template (&proxytestelement_peer_template,
2961 fail_unless (gst_pad_link (srcpad, peerpad) == GST_PAD_LINK_OK);
2962 gst_pad_set_active (peerpad, TRUE);
2964 gst_element_set_state (element, GST_STATE_PLAYING);
2966 caps = gst_caps_from_string ("test/bad");
2967 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
2968 gst_caps_unref (caps);
2970 caps = gst_caps_from_string ("test/proxy, option=(int)1");
2971 fail_unless (gst_pad_query_accept_caps (sinkpad, caps));
2972 gst_caps_unref (caps);
2974 caps = gst_caps_from_string ("test/proxy, option=(int)2");
2975 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
2976 gst_caps_unref (caps);
2978 gst_object_unref (sinkpad);
2979 gst_object_unref (srcpad);
2980 gst_pad_set_active (peerpad, FALSE);
2981 gst_object_unref (peerpad);
2982 gst_element_set_state (element, GST_STATE_NULL);
2983 gst_object_unref (element);
2988 GST_START_TEST (test_proxy_accept_caps_with_incompatible_proxy)
2990 GstElement *element;
2991 GstPad *sinkpad, *srcpad;
2995 gst_element_register (NULL, "proxytestelement", GST_RANK_NONE,
2996 gst_proxytestelement_get_type ());
2997 element = gst_element_factory_make ("proxytestelement", NULL);
3000 gst_pad_new_from_static_template (&proxytestelement_src_template, "src");
3001 gst_element_add_pad (GST_ELEMENT_CAST (element), srcpad);
3003 sinkpad = gst_element_get_static_pad (element, "sink");
3004 srcpad = gst_element_get_static_pad (element, "src");
3007 gst_pad_new_from_static_template
3008 (&proxytestelement_peer_incompatible_template, "sink");
3009 fail_unless (gst_pad_link (srcpad, peerpad) == GST_PAD_LINK_OK);
3011 gst_element_set_state (element, GST_STATE_PLAYING);
3013 caps = gst_caps_from_string ("test/bad");
3014 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
3015 gst_caps_unref (caps);
3017 caps = gst_caps_from_string ("test/proxy");
3018 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
3019 gst_caps_unref (caps);
3021 caps = gst_caps_from_string ("test/proxy-incompatible");
3022 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
3023 gst_caps_unref (caps);
3025 gst_object_unref (sinkpad);
3026 gst_object_unref (srcpad);
3027 gst_pad_set_active (peerpad, FALSE);
3028 gst_object_unref (peerpad);
3029 gst_element_set_state (element, GST_STATE_NULL);
3030 gst_object_unref (element);
3035 static GstSegment sink_segment;
3036 static gint sink_segment_counter;
3039 segment_event_func (GstPad * pad, GstObject * parent, GstEvent * event)
3041 switch (GST_EVENT_TYPE (event)) {
3042 case GST_EVENT_SEGMENT:
3043 gst_event_copy_segment (event, &sink_segment);
3044 sink_segment_counter++;
3050 gst_event_unref (event);
3055 test_pad_offset (gboolean on_srcpad)
3057 GstPad *srcpad, *sinkpad, *offset_pad;
3062 srcpad = gst_pad_new ("src", GST_PAD_SRC);
3063 fail_unless (srcpad != NULL);
3064 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
3066 offset_pad = on_srcpad ? srcpad : sinkpad;
3068 gst_segment_init (&sink_segment, GST_FORMAT_UNDEFINED);
3069 sink_segment_counter = 0;
3070 gst_pad_set_chain_function (sinkpad, gst_check_chain_func);
3071 gst_pad_set_event_function (sinkpad, segment_event_func);
3073 fail_unless (sinkpad != NULL);
3074 fail_unless_equals_int (gst_pad_link (srcpad, sinkpad), GST_PAD_LINK_OK);
3075 fail_unless (gst_pad_set_active (sinkpad, TRUE));
3076 fail_unless (gst_pad_set_active (srcpad, TRUE));
3078 /* Set an offset of 5s, meaning:
3079 * segment position 0 gives running time 5s, stream time 0s
3080 * segment start of 0 should stay 0
3082 gst_pad_set_offset (offset_pad, 5 * GST_SECOND);
3084 fail_unless (gst_pad_push_event (srcpad,
3085 gst_event_new_stream_start ("test")) == TRUE);
3086 /* We should have no segment event yet */
3087 fail_if (sink_segment.format != GST_FORMAT_UNDEFINED);
3088 fail_unless_equals_int (sink_segment_counter, 0);
3090 /* Send segment event, expect it to arrive with a modified start running time */
3091 gst_segment_init (&segment, GST_FORMAT_TIME);
3092 fail_unless (gst_pad_push_event (srcpad,
3093 gst_event_new_segment (&segment)) == TRUE);
3094 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3095 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3096 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3097 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3098 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3099 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3101 fail_unless_equals_int (sink_segment_counter, 1);
3103 /* Send a buffer and check if all timestamps are as expected, and especially
3104 * if the buffer timestamp was not changed */
3105 buffer = gst_buffer_new ();
3106 GST_BUFFER_PTS (buffer) = 0 * GST_SECOND;
3107 fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
3109 fail_unless_equals_int (g_list_length (buffers), 1);
3110 buffer = buffers->data;
3111 buffers = g_list_delete_link (buffers, buffers);
3112 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3113 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 5 * GST_SECOND);
3114 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3115 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 0 * GST_SECOND);
3116 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
3117 gst_buffer_unref (buffer);
3119 fail_unless_equals_int (sink_segment_counter, 1);
3121 /* Set a negative offset of -5s, meaning:
3122 * segment position 5s gives running time 0s, stream time 5s
3123 * segment start would have a negative running time!
3125 gst_pad_set_offset (offset_pad, -5 * GST_SECOND);
3127 /* Segment should still be the same as before */
3128 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3129 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3130 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3131 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3132 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3133 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3135 fail_unless_equals_int (sink_segment_counter, 1);
3137 /* Send segment event, expect it to arrive with a modified start running time */
3138 gst_segment_init (&segment, GST_FORMAT_TIME);
3139 fail_unless (gst_pad_push_event (srcpad,
3140 gst_event_new_segment (&segment)) == TRUE);
3141 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3142 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3143 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3145 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3146 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3148 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3150 fail_unless_equals_int (sink_segment_counter, 2);
3152 /* Send a buffer and check if all timestamps are as expected, and especially
3153 * if the buffer timestamp was not changed */
3154 buffer = gst_buffer_new ();
3155 GST_BUFFER_PTS (buffer) = 5 * GST_SECOND;
3156 fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
3158 fail_unless_equals_int (g_list_length (buffers), 1);
3159 buffer = buffers->data;
3160 buffers = g_list_delete_link (buffers, buffers);
3161 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3162 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 0 * GST_SECOND);
3163 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3164 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 5 * GST_SECOND);
3165 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 5 * GST_SECOND);
3166 gst_buffer_unref (buffer);
3168 fail_unless_equals_int (sink_segment_counter, 2);
3170 /* Set offset to 5s again, same situation as above but don't send a new
3171 * segment event. The segment should be adjusted *before* the buffer comes
3172 * out of the srcpad */
3173 gst_pad_set_offset (offset_pad, 5 * GST_SECOND);
3175 /* Segment should still be the same as before */
3176 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3177 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3178 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3180 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3181 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3183 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3185 fail_unless_equals_int (sink_segment_counter, 2);
3187 /* Send a buffer and check if a new segment event was sent and all buffer
3188 * timestamps are as expected */
3189 buffer = gst_buffer_new ();
3190 GST_BUFFER_PTS (buffer) = 0 * GST_SECOND;
3191 fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
3193 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3194 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3195 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3196 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3197 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3198 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3200 fail_unless_equals_int (sink_segment_counter, 3);
3202 fail_unless_equals_int (g_list_length (buffers), 1);
3203 buffer = buffers->data;
3204 buffers = g_list_delete_link (buffers, buffers);
3205 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3206 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 5 * GST_SECOND);
3207 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3208 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 0 * GST_SECOND);
3209 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
3210 gst_buffer_unref (buffer);
3212 fail_unless_equals_int (sink_segment_counter, 3);
3214 /* Set offset to 10s and send another sticky event. In between a new
3215 * segment event should've been sent */
3216 gst_pad_set_offset (offset_pad, 10 * GST_SECOND);
3218 /* Segment should still be the same as before */
3219 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3220 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3221 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3222 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3223 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3224 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3225 fail_unless_equals_int (sink_segment_counter, 3);
3227 fail_unless (gst_pad_push_event (srcpad,
3228 gst_event_new_tag (gst_tag_list_new_empty ())) == TRUE);
3230 /* Segment should be updated */
3231 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3232 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3233 GST_FORMAT_TIME, sink_segment.start), 10 * GST_SECOND);
3234 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3235 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3236 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3238 fail_unless_equals_int (sink_segment_counter, 4);
3240 /* Set offset to 15s and do a serialized query. In between a new
3241 * segment event should've been sent */
3242 gst_pad_set_offset (offset_pad, 15 * GST_SECOND);
3244 /* Segment should still be the same as before */
3245 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3246 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3247 GST_FORMAT_TIME, sink_segment.start), 10 * GST_SECOND);
3248 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3249 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3250 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3251 fail_unless_equals_int (sink_segment_counter, 4);
3253 query = gst_query_new_drain ();
3254 gst_pad_peer_query (srcpad, query);
3255 gst_query_unref (query);
3257 /* Segment should be updated */
3258 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3259 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3260 GST_FORMAT_TIME, sink_segment.start), 15 * GST_SECOND);
3261 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3262 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3263 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3265 fail_unless_equals_int (sink_segment_counter, 5);
3267 gst_check_drop_buffers ();
3269 fail_unless (gst_pad_set_active (sinkpad, FALSE));
3270 fail_unless (gst_pad_set_active (srcpad, FALSE));
3271 gst_object_unref (sinkpad);
3272 gst_object_unref (srcpad);
3275 GST_START_TEST (test_pad_offset_src)
3277 test_pad_offset (TRUE);
3283 gst_pad_suite (void)
3285 Suite *s = suite_create ("GstPad");
3286 TCase *tc_chain = tcase_create ("general");
3288 /* turn off timeout */
3289 tcase_set_timeout (tc_chain, 60);
3291 gst_segment_init (&dummy_segment, GST_FORMAT_BYTES);
3293 suite_add_tcase (s, tc_chain);
3294 tcase_add_test (tc_chain, test_link);
3295 tcase_add_test (tc_chain, test_refcount);
3296 tcase_add_test (tc_chain, test_get_allowed_caps);
3297 tcase_add_test (tc_chain, test_sticky_caps_unlinked);
3298 tcase_add_test (tc_chain, test_sticky_caps_unlinked_incompatible);
3299 tcase_add_test (tc_chain, test_sticky_caps_flushing);
3300 tcase_add_test (tc_chain, test_default_accept_caps);
3301 tcase_add_test (tc_chain, test_link_unlink_threaded);
3302 tcase_add_test (tc_chain, test_name_is_valid);
3303 tcase_add_test (tc_chain, test_push_unlinked);
3304 tcase_add_test (tc_chain, test_push_linked);
3305 tcase_add_test (tc_chain, test_push_linked_flushing);
3306 tcase_add_test (tc_chain, test_push_buffer_list_compat);
3307 tcase_add_test (tc_chain, test_flowreturn);
3308 tcase_add_test (tc_chain, test_push_negotiation);
3309 tcase_add_test (tc_chain, test_src_unref_unlink);
3310 tcase_add_test (tc_chain, test_sink_unref_unlink);
3311 tcase_add_test (tc_chain, test_block_async);
3312 tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_block);
3313 tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_blocking);
3314 tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_idle);
3315 tcase_add_test (tc_chain, test_pad_probe_pull);
3316 tcase_add_test (tc_chain, test_pad_probe_pull_idle);
3317 tcase_add_test (tc_chain, test_pad_probe_pull_buffer);
3318 tcase_add_test (tc_chain, test_pad_probe_remove);
3319 tcase_add_test (tc_chain, test_pad_probe_block_add_remove);
3320 tcase_add_test (tc_chain, test_pad_probe_block_and_drop_buffer);
3321 tcase_add_test (tc_chain, test_pad_probe_flush_events);
3322 tcase_add_test (tc_chain, test_pad_probe_flush_events_only);
3323 tcase_add_test (tc_chain, test_pad_probe_call_order);
3324 tcase_add_test (tc_chain, test_pad_probe_handled_and_drop);
3325 tcase_add_test (tc_chain, test_events_query_unlinked);
3326 tcase_add_test (tc_chain, test_queue_src_caps_notify_linked);
3327 tcase_add_test (tc_chain, test_queue_src_caps_notify_not_linked);
3329 tcase_add_test (tc_chain, test_block_async_replace_callback);
3331 tcase_add_test (tc_chain, test_block_async_full_destroy);
3332 tcase_add_test (tc_chain, test_block_async_full_destroy_dispose);
3333 tcase_add_test (tc_chain, test_block_async_replace_callback_no_flush);
3334 tcase_add_test (tc_chain, test_sticky_events);
3335 tcase_add_test (tc_chain, test_last_flow_return_push);
3336 tcase_add_test (tc_chain, test_last_flow_return_pull);
3337 tcase_add_test (tc_chain, test_flush_stop_inactive);
3338 tcase_add_test (tc_chain, test_proxy_accept_caps_no_proxy);
3339 tcase_add_test (tc_chain, test_proxy_accept_caps_with_proxy);
3340 tcase_add_test (tc_chain, test_proxy_accept_caps_with_incompatible_proxy);
3341 tcase_add_test (tc_chain, test_pad_offset_src);
3346 GST_CHECK_MAIN (gst_pad);