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 stil 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_a (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1817 return GST_PAD_PROBE_OK;
1820 static GstPadProbeReturn
1821 probe_block_b (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1823 gboolean *probe_b_called = user_data;
1825 *probe_b_called = TRUE;
1827 return GST_PAD_PROBE_OK;
1830 static GstPadProbeReturn
1831 probe_block_c (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1833 gboolean *probe_c_called = user_data;
1835 *probe_c_called = TRUE;
1837 return GST_PAD_PROBE_REMOVE;
1840 GST_START_TEST (test_pad_probe_block_add_remove)
1844 gulong probe_a, probe_b;
1845 gboolean probe_b_called = FALSE;
1846 gboolean probe_c_called = FALSE;
1848 pad = gst_pad_new ("src", GST_PAD_SRC);
1849 fail_unless (pad != NULL);
1851 gst_pad_set_active (pad, TRUE);
1852 fail_unless (pad->num_probes == 0);
1853 fail_unless (pad->num_blocked == 0);
1855 fail_unless (gst_pad_push_event (pad,
1856 gst_event_new_stream_start ("test")) == TRUE);
1857 fail_unless (gst_pad_push_event (pad,
1858 gst_event_new_segment (&dummy_segment)) == TRUE);
1860 probe_a = gst_pad_add_probe (pad,
1861 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1862 probe_block_a, NULL, NULL);
1864 fail_unless (pad->num_probes == 1);
1865 fail_unless (pad->num_blocked == 1);
1867 thread = g_thread_try_new ("gst-check", (GThreadFunc) push_buffer_async,
1870 /* wait for the block */
1871 while (!gst_pad_is_blocking (pad)) {
1875 probe_b = gst_pad_add_probe (pad,
1876 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1877 probe_block_b, &probe_b_called, NULL);
1879 gst_pad_remove_probe (pad, probe_a);
1881 /* wait for the callback */
1882 while (!probe_b_called) {
1886 /* wait for the block */
1887 while (!gst_pad_is_blocking (pad)) {
1891 gst_pad_add_probe (pad,
1892 GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_BUFFER,
1893 probe_block_c, &probe_c_called, NULL);
1895 gst_pad_remove_probe (pad, probe_b);
1897 /* wait for the callback */
1898 while (!probe_c_called) {
1902 /* wait for the unblock */
1903 while (gst_pad_is_blocking (pad)) {
1907 gst_object_unref (pad);
1909 g_thread_join (thread);
1914 static gboolean src_flush_start_probe_called = FALSE;
1915 static gboolean src_flush_stop_probe_called = FALSE;
1916 static gboolean sink_flush_start_probe_called = FALSE;
1917 static gboolean sink_flush_stop_probe_called = FALSE;
1919 static GstPadProbeReturn
1920 flush_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
1924 if (!(GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_EVENT_FLUSH))
1927 event = gst_pad_probe_info_get_event (info);
1928 switch (GST_EVENT_TYPE (event)) {
1929 case GST_EVENT_FLUSH_START:
1930 if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
1931 src_flush_start_probe_called = TRUE;
1933 sink_flush_start_probe_called = TRUE;
1935 case GST_EVENT_FLUSH_STOP:
1936 if (GST_PAD_DIRECTION (pad) == GST_PAD_SRC)
1937 src_flush_stop_probe_called = TRUE;
1939 sink_flush_stop_probe_called = TRUE;
1946 return GST_PAD_PROBE_OK;
1949 GST_START_TEST (test_pad_probe_flush_events)
1953 src = gst_pad_new ("src", GST_PAD_SRC);
1954 sink = gst_pad_new ("sink", GST_PAD_SINK);
1955 gst_pad_set_chain_function (sink, gst_check_chain_func);
1956 gst_pad_set_active (src, TRUE);
1957 gst_pad_set_active (sink, TRUE);
1959 fail_unless (gst_pad_push_event (src,
1960 gst_event_new_stream_start ("test")) == TRUE);
1961 fail_unless (gst_pad_push_event (src,
1962 gst_event_new_segment (&dummy_segment)) == TRUE);
1964 fail_unless (gst_pad_link (src, sink) == GST_PAD_LINK_OK);
1966 gst_pad_add_probe (src,
1967 GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM |
1968 GST_PAD_PROBE_TYPE_EVENT_FLUSH, flush_probe_cb, NULL, NULL);
1969 gst_pad_add_probe (sink,
1970 GST_PAD_PROBE_TYPE_PUSH | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM |
1971 GST_PAD_PROBE_TYPE_EVENT_FLUSH, flush_probe_cb, NULL, NULL);
1973 gst_pad_push_event (src, gst_event_new_flush_start ());
1974 gst_pad_push_event (src, gst_event_new_flush_stop (TRUE));
1976 fail_unless (gst_pad_push_event (src,
1977 gst_event_new_segment (&dummy_segment)) == TRUE);
1979 /* push a buffer so the events are propagated downstream */
1980 gst_pad_push (src, gst_buffer_new ());
1982 fail_unless (src_flush_start_probe_called);
1983 fail_unless (src_flush_stop_probe_called);
1984 fail_unless (sink_flush_start_probe_called);
1985 fail_unless (sink_flush_stop_probe_called);
1987 gst_check_drop_buffers ();
1988 gst_object_unref (src);
1989 gst_object_unref (sink);
1994 static gboolean probe_was_called;
1996 static GstPadProbeReturn
1997 flush_events_only_probe (GstPad * pad, GstPadProbeInfo * info, gpointer data)
1999 GST_LOG_OBJECT (pad, "%" GST_PTR_FORMAT, GST_PAD_PROBE_INFO_DATA (info));
2001 probe_was_called = TRUE;
2003 return GST_PAD_PROBE_OK;
2006 GST_START_TEST (test_pad_probe_flush_events_only)
2010 src = gst_pad_new ("src", GST_PAD_SRC);
2011 sink = gst_pad_new ("sink", GST_PAD_SINK);
2012 gst_pad_set_chain_function (sink, gst_check_chain_func);
2013 gst_pad_set_active (src, TRUE);
2014 gst_pad_set_active (sink, TRUE);
2016 fail_unless (gst_pad_link (src, sink) == GST_PAD_LINK_OK);
2018 fail_unless (gst_pad_push_event (src,
2019 gst_event_new_stream_start ("test")) == TRUE);
2021 gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_EVENT_FLUSH,
2022 flush_events_only_probe, NULL, NULL);
2024 probe_was_called = FALSE;
2025 fail_unless (gst_pad_push_event (src,
2026 gst_event_new_segment (&dummy_segment)) == TRUE);
2027 fail_if (probe_was_called);
2029 fail_unless_equals_int (gst_pad_push (src, gst_buffer_new ()), GST_FLOW_OK);
2030 fail_if (probe_was_called);
2032 gst_pad_push_event (src, gst_event_new_flush_start ());
2033 fail_unless (probe_was_called);
2035 probe_was_called = FALSE;
2036 gst_pad_push_event (src, gst_event_new_flush_stop (TRUE));
2037 fail_unless (probe_was_called);
2039 gst_check_drop_buffers ();
2040 gst_object_unref (src);
2041 gst_object_unref (sink);
2046 #define NUM_PROBES 4
2049 static GstPadProbeReturn
2050 order_others_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
2052 *(guint *) (user_data) = ++count;
2054 return GST_PAD_PROBE_REMOVE;
2057 GST_START_TEST (test_pad_probe_call_order)
2061 guint counters[NUM_PROBES];
2064 src = gst_pad_new ("src", GST_PAD_SRC);
2065 gst_pad_set_active (src, TRUE);
2066 sink = gst_pad_new ("sink", GST_PAD_SINK);
2067 gst_pad_set_chain_function (sink, gst_check_chain_func);
2068 gst_pad_set_active (sink, TRUE);
2070 fail_unless (gst_pad_push_event (src,
2071 gst_event_new_stream_start ("test")) == TRUE);
2072 fail_unless (gst_pad_push_event (src,
2073 gst_event_new_segment (&dummy_segment)) == TRUE);
2075 fail_unless_equals_int (gst_pad_link (src, sink), GST_PAD_LINK_OK);
2077 for (i = 0; i < NUM_PROBES; i++) {
2078 gst_pad_add_probe (src,
2079 GST_PAD_PROBE_TYPE_BUFFER, order_others_probe_cb, &(counters[i]), NULL);
2082 /* push a buffer so the events are propagated downstream */
2083 flow = gst_pad_push (src, gst_buffer_new ());
2084 fail_unless_equals_int (flow, GST_FLOW_OK);
2086 for (i = 0; i < NUM_PROBES; i++) {
2087 fail_unless (counters[i] == i + 1);
2090 gst_check_drop_buffers ();
2091 gst_object_unref (src);
2092 gst_object_unref (sink);
2097 static GstPadProbeReturn
2098 buffers_probe_handled (GstPad * pad, GstPadProbeInfo * info, gpointer gp)
2100 if (GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_BUFFER) {
2101 GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
2103 GST_DEBUG_OBJECT (pad, "buffer: %" GST_PTR_FORMAT ", refcount: %d",
2104 buffer, (GST_MINI_OBJECT (buffer))->refcount);
2105 gst_buffer_unref (buffer);
2108 return GST_PAD_PROBE_HANDLED;
2111 static GstPadProbeReturn
2112 buffers_probe_drop (GstPad * pad, GstPadProbeInfo * info, gboolean * called)
2114 if (GST_PAD_PROBE_INFO_TYPE (info) & GST_PAD_PROBE_TYPE_BUFFER) {
2115 GstBuffer *buffer = GST_PAD_PROBE_INFO_BUFFER (info);
2117 GST_DEBUG_OBJECT (pad, "buffer: %" GST_PTR_FORMAT ", refcount: %d",
2118 buffer, (GST_MINI_OBJECT (buffer))->refcount);
2122 return GST_PAD_PROBE_DROP;
2125 GST_START_TEST (test_pad_probe_handled_and_drop)
2131 src = gst_pad_new ("src", GST_PAD_SRC);
2132 gst_pad_set_active (src, TRUE);
2133 sink = gst_pad_new ("sink", GST_PAD_SINK);
2134 gst_pad_set_chain_function (sink, gst_check_chain_func);
2135 gst_pad_set_active (sink, TRUE);
2137 fail_unless (gst_pad_push_event (src,
2138 gst_event_new_stream_start ("test")) == TRUE);
2139 fail_unless (gst_pad_push_event (src,
2140 gst_event_new_segment (&dummy_segment)) == TRUE);
2142 fail_unless_equals_int (gst_pad_link (src, sink), GST_PAD_LINK_OK);
2144 gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
2145 (GstPadProbeCallback) buffers_probe_handled, NULL, NULL);
2146 gst_pad_add_probe (src, GST_PAD_PROBE_TYPE_BUFFER,
2147 (GstPadProbeCallback) buffers_probe_drop, &called, NULL);
2150 flow = gst_pad_push (src, gst_buffer_new ());
2151 fail_unless_equals_int (flow, GST_FLOW_OK);
2154 /* no buffer should have made it through to the sink pad, and especially
2155 * not a NULL pointer buffer */
2156 fail_if (buffers && buffers->data == NULL);
2157 fail_unless (buffers == NULL);
2159 gst_object_unref (src);
2160 gst_object_unref (sink);
2165 static gboolean got_notify;
2168 caps_notify (GstPad * pad, GParamSpec * spec, gpointer data)
2174 test_queue_src_caps_notify (gboolean link_queue)
2177 GstPad *src, *sink, *another_pad;
2180 queue = gst_element_factory_make ("queue", NULL);
2181 fail_unless (queue != NULL);
2183 src = gst_element_get_static_pad (queue, "src");
2184 fail_unless (src != NULL);
2186 sink = gst_element_get_static_pad (queue, "sink");
2187 fail_unless (sink != NULL);
2190 another_pad = gst_pad_new ("sink", GST_PAD_SINK);
2191 fail_unless (another_pad != NULL);
2192 gst_pad_set_active (another_pad, TRUE);
2194 gst_pad_link_full (src, another_pad, GST_PAD_LINK_CHECK_NOTHING);
2199 gst_element_set_state (queue, GST_STATE_PLAYING);
2203 g_signal_connect (src, "notify::caps", G_CALLBACK (caps_notify), NULL);
2205 caps = gst_caps_from_string ("caps");
2206 gst_pad_send_event (sink, gst_event_new_caps (caps));
2207 gst_caps_unref (caps);
2209 while (got_notify == FALSE)
2212 gst_element_set_state (queue, GST_STATE_NULL);
2214 gst_object_unref (src);
2215 gst_object_unref (sink);
2216 gst_object_unref (queue);
2218 gst_object_unref (another_pad);
2222 GST_START_TEST (test_queue_src_caps_notify_linked)
2224 test_queue_src_caps_notify (TRUE);
2228 GST_START_TEST (test_queue_src_caps_notify_not_linked)
2230 /* This test will fail because queue doesn't set the caps
2231 on src pad unless it is linked */
2232 test_queue_src_caps_notify (FALSE);
2239 block_async_second (GstPad * pad, gboolean blocked, gpointer user_data)
2241 gst_pad_set_blocked (pad, FALSE, unblock_async_cb, NULL, NULL);
2245 block_async_first (GstPad * pad, gboolean blocked, gpointer user_data)
2247 static int n_calls = 0;
2248 gboolean *bool_user_data = (gboolean *) user_data;
2251 /* we expect this callback to be called only once */
2252 g_warn_if_reached ();
2254 *bool_user_data = blocked;
2256 /* replace block_async_first with block_async_second so next time the pad is
2257 * blocked the latter should be called */
2258 gst_pad_set_blocked (pad, TRUE, block_async_second, NULL, NULL);
2260 /* unblock temporarily, in the next push block_async_second should be called
2262 gst_pad_push_event (pad, gst_event_new_flush_start ());
2265 GST_START_TEST (test_block_async_replace_callback)
2270 pad = gst_pad_new ("src", GST_PAD_SRC);
2271 fail_unless (pad != NULL);
2272 gst_pad_set_active (pad, TRUE);
2274 gst_pad_set_blocked (pad, TRUE, block_async_first, &blocked, NULL);
2277 gst_pad_push (pad, gst_buffer_new ());
2278 fail_unless (blocked == TRUE);
2279 /* block_async_first flushes to unblock */
2280 gst_pad_push_event (pad, gst_event_new_flush_stop ());
2282 /* push again, this time block_async_second should be called */
2283 gst_pad_push (pad, gst_buffer_new ());
2284 fail_unless (blocked == TRUE);
2286 gst_object_unref (pad);
2293 block_async_full_destroy (gpointer user_data)
2295 gint *state = (gint *) user_data;
2297 fail_unless (*state < 2);
2299 GST_DEBUG ("setting state to 2");
2303 static GstPadProbeReturn
2304 block_async_full_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data)
2306 *(gint *) user_data = (gint) TRUE;
2308 gst_pad_push_event (pad, gst_event_new_flush_start ());
2309 GST_DEBUG ("setting state to 1");
2311 return GST_PAD_PROBE_OK;
2314 GST_START_TEST (test_block_async_full_destroy)
2317 /* 0 = unblocked, 1 = blocked, 2 = destroyed */
2321 pad = gst_pad_new ("src", GST_PAD_SRC);
2322 fail_unless (pad != NULL);
2323 gst_pad_set_active (pad, TRUE);
2325 fail_unless (gst_pad_push_event (pad,
2326 gst_event_new_stream_start ("test")) == TRUE);
2327 fail_unless (gst_pad_push_event (pad,
2328 gst_event_new_segment (&dummy_segment)) == TRUE);
2330 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK, block_async_full_cb,
2331 &state, block_async_full_destroy);
2332 fail_unless (state == 0);
2334 gst_pad_push (pad, gst_buffer_new ());
2335 /* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
2337 fail_unless (state == 1);
2338 gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
2340 /* unblock callback is called */
2341 gst_pad_remove_probe (pad, id);
2342 fail_unless (state == 2);
2344 gst_object_unref (pad);
2349 GST_START_TEST (test_block_async_full_destroy_dispose)
2352 /* 0 = unblocked, 1 = blocked, 2 = destroyed */
2355 pad = gst_pad_new ("src", GST_PAD_SRC);
2356 fail_unless (pad != NULL);
2357 gst_pad_set_active (pad, TRUE);
2359 fail_unless (gst_pad_push_event (pad,
2360 gst_event_new_stream_start ("test")) == TRUE);
2361 fail_unless (gst_pad_push_event (pad,
2362 gst_event_new_segment (&dummy_segment)) == TRUE);
2364 (void) gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK, block_async_full_cb,
2365 &state, block_async_full_destroy);
2367 gst_pad_push (pad, gst_buffer_new ());
2368 /* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
2370 fail_unless_equals_int (state, 1);
2371 gst_pad_push_event (pad, gst_event_new_flush_stop (TRUE));
2373 /* gst_BLOCK calls the destroy_notify function if necessary */
2374 gst_object_unref (pad);
2376 fail_unless_equals_int (state, 2);
2384 unblock_async_no_flush_cb (GstPad * pad, gboolean blocked, gpointer user_data)
2386 gboolean *bool_user_data = (gboolean *) user_data;
2388 /* here we should have blocked == 1 unblocked == 0 */
2390 fail_unless (blocked == FALSE);
2392 fail_unless (bool_user_data[0] == TRUE);
2393 fail_unless (bool_user_data[1] == TRUE);
2394 fail_unless (bool_user_data[2] == FALSE);
2396 bool_user_data[2] = TRUE;
2403 unblock_async_not_called (GstPad * pad, gboolean blocked, gpointer user_data)
2405 g_warn_if_reached ();
2409 static GstPadProbeReturn
2410 block_async_second_no_flush (GstPad * pad, GstPadProbeInfo * info,
2413 gboolean *bool_user_data = (gboolean *) user_data;
2415 GST_DEBUG ("second probe called");
2417 fail_unless (info->type & GST_PAD_PROBE_TYPE_BLOCK);
2419 fail_unless (bool_user_data[0] == TRUE);
2420 fail_unless (bool_user_data[1] == FALSE);
2421 fail_unless (bool_user_data[2] == FALSE);
2423 bool_user_data[1] = TRUE;
2425 GST_DEBUG ("removing second probe with id %lu", id);
2426 gst_pad_remove_probe (pad, id);
2428 return GST_PAD_PROBE_OK;
2431 static GstPadProbeReturn
2432 block_async_first_no_flush (GstPad * pad, GstPadProbeInfo * info,
2435 static int n_calls = 0;
2436 gboolean *bool_user_data = (gboolean *) user_data;
2438 fail_unless (info->type & GST_PAD_PROBE_TYPE_BLOCK);
2440 GST_DEBUG ("first probe called");
2443 /* we expect this callback to be called only once */
2444 g_warn_if_reached ();
2446 *bool_user_data = TRUE;
2448 fail_unless (bool_user_data[0] == TRUE);
2449 fail_unless (bool_user_data[1] == FALSE);
2450 fail_unless (bool_user_data[2] == FALSE);
2452 GST_DEBUG ("removing first probe with id %lu", id);
2453 gst_pad_remove_probe (pad, id);
2455 GST_DEBUG ("adding second probe");
2456 /* replace block_async_first with block_async_second so next time the pad is
2457 * blocked the latter should be called */
2458 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK,
2459 block_async_second_no_flush, user_data, NULL);
2460 GST_DEBUG ("added probe with id %lu", id);
2462 return GST_PAD_PROBE_OK;
2465 GST_START_TEST (test_block_async_replace_callback_no_flush)
2468 gboolean bool_user_data[3] = { FALSE, FALSE, FALSE };
2470 pad = gst_pad_new ("src", GST_PAD_SRC);
2471 fail_unless (pad != NULL);
2472 gst_pad_set_active (pad, TRUE);
2474 fail_unless (gst_pad_push_event (pad,
2475 gst_event_new_stream_start ("test")) == TRUE);
2476 fail_unless (gst_pad_push_event (pad,
2477 gst_event_new_segment (&dummy_segment)) == TRUE);
2479 GST_DEBUG ("adding probe");
2480 id = gst_pad_add_probe (pad, GST_PAD_PROBE_TYPE_BLOCK,
2481 block_async_first_no_flush, bool_user_data, NULL);
2482 GST_DEBUG ("added probe with id %lu", id);
2485 GST_DEBUG ("pushing buffer");
2486 gst_pad_push (pad, gst_buffer_new ());
2487 fail_unless (bool_user_data[0] == TRUE);
2488 fail_unless (bool_user_data[1] == TRUE);
2489 fail_unless (bool_user_data[2] == FALSE);
2491 gst_object_unref (pad);
2496 static gint sticky_count;
2499 test_sticky_events_handler (GstPad * pad, GstObject * parent, GstEvent * event)
2501 GST_DEBUG_OBJECT (pad, "received event %" GST_PTR_FORMAT, event);
2503 switch (sticky_count) {
2505 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_STREAM_START);
2512 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_CAPS);
2514 gst_event_parse_caps (event, &caps);
2515 fail_unless (gst_caps_get_size (caps) == 1);
2516 s = gst_caps_get_structure (caps, 0);
2517 fail_unless (gst_structure_has_name (s, "foo/baz"));
2521 fail_unless (GST_EVENT_TYPE (event) == GST_EVENT_SEGMENT);
2524 fail_unless (FALSE);
2528 gst_event_unref (event);
2534 static GstFlowReturn
2535 test_sticky_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
2537 gst_buffer_unref (buffer);
2541 GST_START_TEST (test_sticky_events)
2543 GstPad *srcpad, *sinkpad;
2548 /* make unlinked srcpad */
2549 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2550 fail_unless (srcpad != NULL);
2551 gst_pad_set_active (srcpad, TRUE);
2553 /* test stream-start */
2554 fail_unless (gst_pad_get_stream_id (srcpad) == NULL);
2556 /* push an event, it should be sticky on the srcpad */
2557 fail_unless (gst_pad_push_event (srcpad,
2558 gst_event_new_stream_start ("test")) == TRUE);
2560 /* let's see if it stuck */
2561 id = gst_pad_get_stream_id (srcpad);
2562 fail_unless_equals_string (id, "test");
2565 /* make a caps event */
2566 caps = gst_caps_new_empty_simple ("foo/bar");
2567 gst_pad_push_event (srcpad, gst_event_new_caps (caps));
2568 gst_caps_unref (caps);
2570 /* make segment event */
2571 gst_segment_init (&seg, GST_FORMAT_TIME);
2572 gst_pad_push_event (srcpad, gst_event_new_segment (&seg));
2574 /* now make a sinkpad */
2575 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2576 fail_unless (sinkpad != NULL);
2578 gst_pad_set_event_function (sinkpad, test_sticky_events_handler);
2579 gst_pad_set_chain_function (sinkpad, test_sticky_chain);
2580 fail_unless (sticky_count == 0);
2581 gst_pad_set_active (sinkpad, TRUE);
2584 gst_pad_link (srcpad, sinkpad);
2585 /* should not trigger events */
2586 fail_unless (sticky_count == 0);
2588 /* caps replaces old caps event at position 2, the pushes all
2590 caps = gst_caps_new_empty_simple ("foo/baz");
2591 gst_pad_push_event (srcpad, gst_event_new_caps (caps));
2592 gst_caps_unref (caps);
2594 /* should have triggered 2 events, the segment event is still pending */
2595 fail_unless_equals_int (sticky_count, 2);
2597 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
2599 /* should have triggered 3 events */
2600 fail_unless_equals_int (sticky_count, 3);
2602 gst_object_unref (srcpad);
2603 gst_object_unref (sinkpad);
2608 static GstFlowReturn next_return;
2610 static GstFlowReturn
2611 test_lastflow_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
2613 gst_buffer_unref (buffer);
2617 GST_START_TEST (test_last_flow_return_push)
2619 GstPad *srcpad, *sinkpad;
2622 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2623 fail_unless (srcpad != NULL);
2624 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2625 fail_unless (sinkpad != NULL);
2626 gst_pad_set_chain_function (sinkpad, test_lastflow_chain);
2627 gst_pad_link (srcpad, sinkpad);
2629 /* initial value is flushing */
2630 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_FLUSHING);
2632 /* when active it goes to ok */
2633 gst_pad_set_active (srcpad, TRUE);
2634 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
2635 gst_pad_set_active (sinkpad, TRUE);
2637 /* startup events */
2638 gst_pad_push_event (srcpad, gst_event_new_stream_start ("test"));
2639 gst_segment_init (&seg, GST_FORMAT_TIME);
2640 gst_pad_push_event (srcpad, gst_event_new_segment (&seg));
2644 next_return = GST_FLOW_OK;
2645 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
2646 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
2648 /* push not-linked */
2649 next_return = GST_FLOW_NOT_LINKED;
2650 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_NOT_LINKED);
2651 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
2653 /* push not-linked */
2654 next_return = GST_FLOW_NOT_NEGOTIATED;
2655 fail_unless (gst_pad_push (srcpad,
2656 gst_buffer_new ()) == GST_FLOW_NOT_NEGOTIATED);
2657 fail_unless (gst_pad_get_last_flow_return (srcpad) ==
2658 GST_FLOW_NOT_NEGOTIATED);
2661 next_return = GST_FLOW_ERROR;
2662 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_ERROR);
2663 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_ERROR);
2666 next_return = GST_FLOW_OK;
2667 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_OK);
2668 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_OK);
2671 gst_pad_unlink (srcpad, sinkpad);
2672 fail_unless (gst_pad_push (srcpad, gst_buffer_new ()) == GST_FLOW_NOT_LINKED);
2673 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_NOT_LINKED);
2675 gst_pad_link (srcpad, sinkpad);
2676 fail_unless (gst_pad_push_event (srcpad, gst_event_new_eos ()));
2677 fail_unless (gst_pad_get_last_flow_return (srcpad) == GST_FLOW_EOS);
2679 gst_object_unref (srcpad);
2680 gst_object_unref (sinkpad);
2685 static GstFlowReturn
2686 test_lastflow_getrange (GstPad * pad, GstObject * parent, guint64 offset,
2687 guint length, GstBuffer ** buf)
2689 if (next_return == GST_FLOW_OK)
2690 *buf = gst_buffer_new ();
2697 test_lastflow_activate_pull_func (GstPad * pad, GstObject * object)
2699 return gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE);
2702 GST_START_TEST (test_last_flow_return_pull)
2704 GstPad *srcpad, *sinkpad;
2705 GstBuffer *buf = NULL;
2707 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2708 fail_unless (srcpad != NULL);
2709 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2710 fail_unless (sinkpad != NULL);
2711 gst_pad_set_getrange_function (srcpad, test_lastflow_getrange);
2712 gst_pad_set_activate_function (sinkpad, test_lastflow_activate_pull_func);
2713 gst_pad_link (srcpad, sinkpad);
2715 /* initial value is flushing */
2716 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_FLUSHING);
2718 /* when active it goes to ok */
2719 gst_pad_set_active (sinkpad, TRUE);
2720 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
2721 gst_pad_set_active (srcpad, TRUE);
2724 next_return = GST_FLOW_OK;
2725 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_OK);
2726 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
2727 gst_buffer_unref (buf);
2730 /* pull not-linked */
2731 next_return = GST_FLOW_NOT_LINKED;
2732 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_NOT_LINKED);
2733 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
2736 next_return = GST_FLOW_ERROR;
2737 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_ERROR);
2738 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_ERROR);
2741 next_return = GST_FLOW_NOT_NEGOTIATED;
2742 fail_unless (gst_pad_pull_range (sinkpad, 0, 1,
2743 &buf) == GST_FLOW_NOT_NEGOTIATED);
2744 fail_unless (gst_pad_get_last_flow_return (sinkpad) ==
2745 GST_FLOW_NOT_NEGOTIATED);
2748 next_return = GST_FLOW_OK;
2749 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_OK);
2750 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_OK);
2751 gst_buffer_unref (buf);
2755 gst_pad_unlink (srcpad, sinkpad);
2756 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_NOT_LINKED);
2757 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_NOT_LINKED);
2760 gst_pad_link (srcpad, sinkpad);
2761 next_return = GST_FLOW_EOS;
2762 fail_unless (gst_pad_pull_range (sinkpad, 0, 1, &buf) == GST_FLOW_EOS);
2763 fail_unless (gst_pad_get_last_flow_return (sinkpad) == GST_FLOW_EOS);
2765 gst_object_unref (srcpad);
2766 gst_object_unref (sinkpad);
2771 GST_START_TEST (test_flush_stop_inactive)
2773 GstPad *sinkpad, *srcpad;
2775 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
2776 fail_unless (sinkpad != NULL);
2778 /* new pads are inactive and flushing */
2779 fail_if (GST_PAD_IS_ACTIVE (sinkpad));
2780 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2782 /* this should fail, pad is inactive */
2783 fail_if (gst_pad_send_event (sinkpad, gst_event_new_flush_stop (FALSE)));
2785 /* nothing should have changed */
2786 fail_if (GST_PAD_IS_ACTIVE (sinkpad));
2787 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2789 gst_pad_set_active (sinkpad, TRUE);
2791 /* pad is now active an not flushing anymore */
2792 fail_unless (GST_PAD_IS_ACTIVE (sinkpad));
2793 fail_if (GST_PAD_IS_FLUSHING (sinkpad));
2795 /* do flush, does not deactivate the pad */
2796 fail_unless (gst_pad_send_event (sinkpad, gst_event_new_flush_start ()));
2797 fail_unless (GST_PAD_IS_ACTIVE (sinkpad));
2798 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2800 fail_unless (gst_pad_send_event (sinkpad, gst_event_new_flush_stop (FALSE)));
2801 fail_unless (GST_PAD_IS_ACTIVE (sinkpad));
2802 fail_if (GST_PAD_IS_FLUSHING (sinkpad));
2804 gst_pad_set_active (sinkpad, FALSE);
2805 fail_if (GST_PAD_IS_ACTIVE (sinkpad));
2806 fail_unless (GST_PAD_IS_FLUSHING (sinkpad));
2808 gst_object_unref (sinkpad);
2810 /* we should not be able to push on an inactive srcpad */
2811 srcpad = gst_pad_new ("src", GST_PAD_SRC);
2812 fail_unless (srcpad != NULL);
2814 fail_if (GST_PAD_IS_ACTIVE (srcpad));
2815 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2817 fail_if (gst_pad_push_event (srcpad, gst_event_new_flush_stop (FALSE)));
2819 /* should still be inactive and flushing */
2820 fail_if (GST_PAD_IS_ACTIVE (srcpad));
2821 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2823 gst_pad_set_active (srcpad, TRUE);
2825 /* pad is now active an not flushing anymore */
2826 fail_unless (GST_PAD_IS_ACTIVE (srcpad));
2827 fail_if (GST_PAD_IS_FLUSHING (srcpad));
2829 /* do flush, does not deactivate the pad */
2830 fail_if (gst_pad_push_event (srcpad, gst_event_new_flush_start ()));
2831 fail_unless (GST_PAD_IS_ACTIVE (srcpad));
2832 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2834 fail_if (gst_pad_push_event (srcpad, gst_event_new_flush_stop (FALSE)));
2835 fail_unless (GST_PAD_IS_ACTIVE (srcpad));
2836 fail_if (GST_PAD_IS_FLUSHING (srcpad));
2838 gst_pad_set_active (srcpad, FALSE);
2839 fail_if (GST_PAD_IS_ACTIVE (srcpad));
2840 fail_unless (GST_PAD_IS_FLUSHING (srcpad));
2842 gst_object_unref (srcpad);
2847 /* For proxy caps flag tests */
2849 typedef struct _GstProxyTestElement GstProxyTestElement;
2850 typedef struct _GstProxyTestElementClass GstProxyTestElementClass;
2852 struct _GstProxyTestElement
2857 struct _GstProxyTestElementClass
2859 GstElementClass parent_class;
2862 G_GNUC_INTERNAL GType gst_proxytestelement_get_type (void);
2864 static GstStaticPadTemplate proxytestelement_peer_template =
2865 GST_STATIC_PAD_TEMPLATE ("sink",
2868 GST_STATIC_CAPS ("test/proxy, option=(int)1"));
2870 static GstStaticPadTemplate proxytestelement_peer_incompatible_template =
2871 GST_STATIC_PAD_TEMPLATE ("sink",
2874 GST_STATIC_CAPS ("test/proxy-incompatible"));
2876 static GstStaticPadTemplate proxytestelement_sink_template =
2877 GST_STATIC_PAD_TEMPLATE ("sink",
2880 GST_STATIC_CAPS ("test/proxy"));
2882 static GstStaticPadTemplate proxytestelement_src_template =
2883 GST_STATIC_PAD_TEMPLATE ("src",
2886 GST_STATIC_CAPS_ANY);
2888 G_DEFINE_TYPE (GstProxyTestElement, gst_proxytestelement, GST_TYPE_ELEMENT);
2891 gst_proxytestelement_class_init (GstProxyTestElementClass * klass)
2893 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
2895 gst_element_class_set_static_metadata (gstelement_class,
2896 "Proxy Test Element", "Test", "Proxy test element",
2897 "Thiago Santos <thiagoss@osg.samsung.com>");
2899 gst_element_class_add_static_pad_template (gstelement_class,
2900 &proxytestelement_sink_template);
2904 gst_proxytestelement_init (GstProxyTestElement * element)
2908 gst_pad_new_from_static_template (&proxytestelement_sink_template,
2910 GST_PAD_SET_PROXY_CAPS (sinkpad);
2911 gst_element_add_pad (GST_ELEMENT_CAST (element), sinkpad);
2914 GST_START_TEST (test_proxy_accept_caps_no_proxy)
2916 GstElement *element;
2920 gst_element_register (NULL, "proxytestelement", GST_RANK_NONE,
2921 gst_proxytestelement_get_type ());
2922 element = gst_element_factory_make ("proxytestelement", NULL);
2923 sinkpad = gst_element_get_static_pad (element, "sink");
2925 gst_element_set_state (element, GST_STATE_PLAYING);
2927 caps = gst_caps_from_string ("test/proxy");
2928 fail_unless (gst_pad_query_accept_caps (sinkpad, caps));
2929 gst_caps_unref (caps);
2931 caps = gst_caps_from_string ("test/bad");
2932 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
2933 gst_caps_unref (caps);
2935 gst_object_unref (sinkpad);
2936 gst_element_set_state (element, GST_STATE_NULL);
2937 gst_object_unref (element);
2943 GST_START_TEST (test_proxy_accept_caps_with_proxy)
2945 GstElement *element;
2946 GstPad *sinkpad, *srcpad;
2950 gst_element_register (NULL, "proxytestelement", GST_RANK_NONE,
2951 gst_proxytestelement_get_type ());
2952 element = gst_element_factory_make ("proxytestelement", NULL);
2955 gst_pad_new_from_static_template (&proxytestelement_src_template, "src");
2956 gst_element_add_pad (GST_ELEMENT_CAST (element), srcpad);
2958 sinkpad = gst_element_get_static_pad (element, "sink");
2959 srcpad = gst_element_get_static_pad (element, "src");
2962 gst_pad_new_from_static_template (&proxytestelement_peer_template,
2964 fail_unless (gst_pad_link (srcpad, peerpad) == GST_PAD_LINK_OK);
2965 gst_pad_set_active (peerpad, TRUE);
2967 gst_element_set_state (element, GST_STATE_PLAYING);
2969 caps = gst_caps_from_string ("test/bad");
2970 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
2971 gst_caps_unref (caps);
2973 caps = gst_caps_from_string ("test/proxy, option=(int)1");
2974 fail_unless (gst_pad_query_accept_caps (sinkpad, caps));
2975 gst_caps_unref (caps);
2977 caps = gst_caps_from_string ("test/proxy, option=(int)2");
2978 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
2979 gst_caps_unref (caps);
2981 gst_object_unref (sinkpad);
2982 gst_object_unref (srcpad);
2983 gst_pad_set_active (peerpad, FALSE);
2984 gst_object_unref (peerpad);
2985 gst_element_set_state (element, GST_STATE_NULL);
2986 gst_object_unref (element);
2991 GST_START_TEST (test_proxy_accept_caps_with_incompatible_proxy)
2993 GstElement *element;
2994 GstPad *sinkpad, *srcpad;
2998 gst_element_register (NULL, "proxytestelement", GST_RANK_NONE,
2999 gst_proxytestelement_get_type ());
3000 element = gst_element_factory_make ("proxytestelement", NULL);
3003 gst_pad_new_from_static_template (&proxytestelement_src_template, "src");
3004 gst_element_add_pad (GST_ELEMENT_CAST (element), srcpad);
3006 sinkpad = gst_element_get_static_pad (element, "sink");
3007 srcpad = gst_element_get_static_pad (element, "src");
3010 gst_pad_new_from_static_template
3011 (&proxytestelement_peer_incompatible_template, "sink");
3012 fail_unless (gst_pad_link (srcpad, peerpad) == GST_PAD_LINK_OK);
3014 gst_element_set_state (element, GST_STATE_PLAYING);
3016 caps = gst_caps_from_string ("test/bad");
3017 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
3018 gst_caps_unref (caps);
3020 caps = gst_caps_from_string ("test/proxy");
3021 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
3022 gst_caps_unref (caps);
3024 caps = gst_caps_from_string ("test/proxy-incompatible");
3025 fail_if (gst_pad_query_accept_caps (sinkpad, caps));
3026 gst_caps_unref (caps);
3028 gst_object_unref (sinkpad);
3029 gst_object_unref (srcpad);
3030 gst_pad_set_active (peerpad, FALSE);
3031 gst_object_unref (peerpad);
3032 gst_element_set_state (element, GST_STATE_NULL);
3033 gst_object_unref (element);
3038 static GstSegment sink_segment;
3039 static gint sink_segment_counter;
3042 segment_event_func (GstPad * pad, GstObject * parent, GstEvent * event)
3044 switch (GST_EVENT_TYPE (event)) {
3045 case GST_EVENT_SEGMENT:
3046 gst_event_copy_segment (event, &sink_segment);
3047 sink_segment_counter++;
3053 gst_event_unref (event);
3058 test_pad_offset (gboolean on_srcpad)
3060 GstPad *srcpad, *sinkpad, *offset_pad;
3065 srcpad = gst_pad_new ("src", GST_PAD_SRC);
3066 fail_unless (srcpad != NULL);
3067 sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
3069 offset_pad = on_srcpad ? srcpad : sinkpad;
3071 gst_segment_init (&sink_segment, GST_FORMAT_UNDEFINED);
3072 sink_segment_counter = 0;
3073 gst_pad_set_chain_function (sinkpad, gst_check_chain_func);
3074 gst_pad_set_event_function (sinkpad, segment_event_func);
3076 fail_unless (sinkpad != NULL);
3077 fail_unless_equals_int (gst_pad_link (srcpad, sinkpad), GST_PAD_LINK_OK);
3078 fail_unless (gst_pad_set_active (sinkpad, TRUE));
3079 fail_unless (gst_pad_set_active (srcpad, TRUE));
3081 /* Set an offset of 5s, meaning:
3082 * segment position 0 gives running time 5s, stream time 0s
3083 * segment start of 0 should stay 0
3085 gst_pad_set_offset (offset_pad, 5 * GST_SECOND);
3087 fail_unless (gst_pad_push_event (srcpad,
3088 gst_event_new_stream_start ("test")) == TRUE);
3089 /* We should have no segment event yet */
3090 fail_if (sink_segment.format != GST_FORMAT_UNDEFINED);
3091 fail_unless_equals_int (sink_segment_counter, 0);
3093 /* Send segment event, expect it to arrive with a modified start running time */
3094 gst_segment_init (&segment, GST_FORMAT_TIME);
3095 fail_unless (gst_pad_push_event (srcpad,
3096 gst_event_new_segment (&segment)) == TRUE);
3097 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3098 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3099 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3100 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3101 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3102 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3104 fail_unless_equals_int (sink_segment_counter, 1);
3106 /* Send a buffer and check if all timestamps are as expected, and especially
3107 * if the buffer timestamp was not changed */
3108 buffer = gst_buffer_new ();
3109 GST_BUFFER_PTS (buffer) = 0 * GST_SECOND;
3110 fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
3112 fail_unless_equals_int (g_list_length (buffers), 1);
3113 buffer = buffers->data;
3114 buffers = g_list_delete_link (buffers, buffers);
3115 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3116 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 5 * GST_SECOND);
3117 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3118 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 0 * GST_SECOND);
3119 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
3120 gst_buffer_unref (buffer);
3122 fail_unless_equals_int (sink_segment_counter, 1);
3124 /* Set a negative offset of -5s, meaning:
3125 * segment position 5s gives running time 0s, stream time 5s
3126 * segment start would have a negative running time!
3128 gst_pad_set_offset (offset_pad, -5 * GST_SECOND);
3130 /* Segment should still be the same as before */
3131 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3132 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3133 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3134 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3135 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3136 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3138 fail_unless_equals_int (sink_segment_counter, 1);
3140 /* Send segment event, expect it to arrive with a modified start running time */
3141 gst_segment_init (&segment, GST_FORMAT_TIME);
3142 fail_unless (gst_pad_push_event (srcpad,
3143 gst_event_new_segment (&segment)) == TRUE);
3144 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3145 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3146 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3148 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3149 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3151 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3153 fail_unless_equals_int (sink_segment_counter, 2);
3155 /* Send a buffer and check if all timestamps are as expected, and especially
3156 * if the buffer timestamp was not changed */
3157 buffer = gst_buffer_new ();
3158 GST_BUFFER_PTS (buffer) = 5 * GST_SECOND;
3159 fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
3161 fail_unless_equals_int (g_list_length (buffers), 1);
3162 buffer = buffers->data;
3163 buffers = g_list_delete_link (buffers, buffers);
3164 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3165 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 0 * GST_SECOND);
3166 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3167 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 5 * GST_SECOND);
3168 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 5 * GST_SECOND);
3169 gst_buffer_unref (buffer);
3171 fail_unless_equals_int (sink_segment_counter, 2);
3173 /* Set offset to 5s again, same situation as above but don't send a new
3174 * segment event. The segment should be adjusted *before* the buffer comes
3175 * out of the srcpad */
3176 gst_pad_set_offset (offset_pad, 5 * GST_SECOND);
3178 /* Segment should still be the same as before */
3179 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3180 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3181 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3183 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3184 GST_FORMAT_TIME, sink_segment.start + 5 * GST_SECOND),
3186 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3188 fail_unless_equals_int (sink_segment_counter, 2);
3190 /* Send a buffer and check if a new segment event was sent and all buffer
3191 * timestamps are as expected */
3192 buffer = gst_buffer_new ();
3193 GST_BUFFER_PTS (buffer) = 0 * GST_SECOND;
3194 fail_unless_equals_int (gst_pad_push (srcpad, buffer), GST_FLOW_OK);
3196 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3197 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3198 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3199 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3200 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3201 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3203 fail_unless_equals_int (sink_segment_counter, 3);
3205 fail_unless_equals_int (g_list_length (buffers), 1);
3206 buffer = buffers->data;
3207 buffers = g_list_delete_link (buffers, buffers);
3208 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3209 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 5 * GST_SECOND);
3210 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3211 GST_FORMAT_TIME, GST_BUFFER_PTS (buffer)), 0 * GST_SECOND);
3212 fail_unless_equals_uint64 (GST_BUFFER_PTS (buffer), 0 * GST_SECOND);
3213 gst_buffer_unref (buffer);
3215 fail_unless_equals_int (sink_segment_counter, 3);
3217 /* Set offset to 10s and send another sticky event. In between a new
3218 * segment event should've been sent */
3219 gst_pad_set_offset (offset_pad, 10 * GST_SECOND);
3221 /* Segment should still be the same as before */
3222 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3223 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3224 GST_FORMAT_TIME, sink_segment.start), 5 * GST_SECOND);
3225 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3226 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3227 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3228 fail_unless_equals_int (sink_segment_counter, 3);
3230 fail_unless (gst_pad_push_event (srcpad,
3231 gst_event_new_tag (gst_tag_list_new_empty ())) == TRUE);
3233 /* Segment should be updated */
3234 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3235 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3236 GST_FORMAT_TIME, sink_segment.start), 10 * GST_SECOND);
3237 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3238 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3239 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3241 fail_unless_equals_int (sink_segment_counter, 4);
3243 /* Set offset to 15s and do a serialized query. In between a new
3244 * segment event should've been sent */
3245 gst_pad_set_offset (offset_pad, 15 * GST_SECOND);
3247 /* Segment should still be the same as before */
3248 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3249 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3250 GST_FORMAT_TIME, sink_segment.start), 10 * GST_SECOND);
3251 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3252 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3253 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3254 fail_unless_equals_int (sink_segment_counter, 4);
3256 query = gst_query_new_drain ();
3257 gst_pad_peer_query (srcpad, query);
3258 gst_query_unref (query);
3260 /* Segment should be updated */
3261 fail_if (sink_segment.format == GST_FORMAT_UNDEFINED);
3262 fail_unless_equals_uint64 (gst_segment_to_running_time (&sink_segment,
3263 GST_FORMAT_TIME, sink_segment.start), 15 * GST_SECOND);
3264 fail_unless_equals_uint64 (gst_segment_to_stream_time (&sink_segment,
3265 GST_FORMAT_TIME, sink_segment.start), 0 * GST_SECOND);
3266 fail_unless_equals_uint64 (sink_segment.start, 0 * GST_SECOND);
3268 fail_unless_equals_int (sink_segment_counter, 5);
3270 gst_check_drop_buffers ();
3272 fail_unless (gst_pad_set_active (sinkpad, FALSE));
3273 fail_unless (gst_pad_set_active (srcpad, FALSE));
3274 gst_object_unref (sinkpad);
3275 gst_object_unref (srcpad);
3278 GST_START_TEST (test_pad_offset_src)
3280 test_pad_offset (TRUE);
3286 gst_pad_suite (void)
3288 Suite *s = suite_create ("GstPad");
3289 TCase *tc_chain = tcase_create ("general");
3291 /* turn off timeout */
3292 tcase_set_timeout (tc_chain, 60);
3294 gst_segment_init (&dummy_segment, GST_FORMAT_BYTES);
3296 suite_add_tcase (s, tc_chain);
3297 tcase_add_test (tc_chain, test_link);
3298 tcase_add_test (tc_chain, test_refcount);
3299 tcase_add_test (tc_chain, test_get_allowed_caps);
3300 tcase_add_test (tc_chain, test_sticky_caps_unlinked);
3301 tcase_add_test (tc_chain, test_sticky_caps_unlinked_incompatible);
3302 tcase_add_test (tc_chain, test_sticky_caps_flushing);
3303 tcase_add_test (tc_chain, test_default_accept_caps);
3304 tcase_add_test (tc_chain, test_link_unlink_threaded);
3305 tcase_add_test (tc_chain, test_name_is_valid);
3306 tcase_add_test (tc_chain, test_push_unlinked);
3307 tcase_add_test (tc_chain, test_push_linked);
3308 tcase_add_test (tc_chain, test_push_linked_flushing);
3309 tcase_add_test (tc_chain, test_push_buffer_list_compat);
3310 tcase_add_test (tc_chain, test_flowreturn);
3311 tcase_add_test (tc_chain, test_push_negotiation);
3312 tcase_add_test (tc_chain, test_src_unref_unlink);
3313 tcase_add_test (tc_chain, test_sink_unref_unlink);
3314 tcase_add_test (tc_chain, test_block_async);
3315 tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_block);
3316 tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_blocking);
3317 tcase_add_test (tc_chain, test_pad_blocking_with_probe_type_idle);
3318 tcase_add_test (tc_chain, test_pad_probe_pull);
3319 tcase_add_test (tc_chain, test_pad_probe_pull_idle);
3320 tcase_add_test (tc_chain, test_pad_probe_pull_buffer);
3321 tcase_add_test (tc_chain, test_pad_probe_remove);
3322 tcase_add_test (tc_chain, test_pad_probe_block_add_remove);
3323 tcase_add_test (tc_chain, test_pad_probe_block_and_drop_buffer);
3324 tcase_add_test (tc_chain, test_pad_probe_flush_events);
3325 tcase_add_test (tc_chain, test_pad_probe_flush_events_only);
3326 tcase_add_test (tc_chain, test_pad_probe_call_order);
3327 tcase_add_test (tc_chain, test_pad_probe_handled_and_drop);
3328 tcase_add_test (tc_chain, test_events_query_unlinked);
3329 tcase_add_test (tc_chain, test_queue_src_caps_notify_linked);
3330 tcase_add_test (tc_chain, test_queue_src_caps_notify_not_linked);
3332 tcase_add_test (tc_chain, test_block_async_replace_callback);
3334 tcase_add_test (tc_chain, test_block_async_full_destroy);
3335 tcase_add_test (tc_chain, test_block_async_full_destroy_dispose);
3336 tcase_add_test (tc_chain, test_block_async_replace_callback_no_flush);
3337 tcase_add_test (tc_chain, test_sticky_events);
3338 tcase_add_test (tc_chain, test_last_flow_return_push);
3339 tcase_add_test (tc_chain, test_last_flow_return_pull);
3340 tcase_add_test (tc_chain, test_flush_stop_inactive);
3341 tcase_add_test (tc_chain, test_proxy_accept_caps_no_proxy);
3342 tcase_add_test (tc_chain, test_proxy_accept_caps_with_proxy);
3343 tcase_add_test (tc_chain, test_proxy_accept_caps_with_incompatible_proxy);
3344 tcase_add_test (tc_chain, test_pad_offset_src);
3349 GST_CHECK_MAIN (gst_pad);