gst_pad_set_caps (src, caps);
gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
MAIN_START_THREADS (5, thread_link_unlink, NULL);
for (i = 0; i < 1000; ++i) {
/* one for me */
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
- fail_unless (gst_pad_set_caps (src, caps) == TRUE);
- /* can't set caps on flushing sinkpad */
+ /* can't set caps on flushing pads */
+ fail_if (gst_pad_set_caps (src, caps) == TRUE);
fail_if (gst_pad_set_caps (sink, caps) == TRUE);
- /* one for me and one for each set_caps */
+
+ /* one for me and one for the pending caps on the sinkpad */
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
gst_pad_set_active (sink, TRUE);
fail_unless (gst_pad_set_caps (sink, caps) == TRUE);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+
+ /* can't link with incompatible caps */
+ plr = gst_pad_link (src, sink);
+ fail_if (GST_PAD_LINK_SUCCESSFUL (plr));
+
+ gst_pad_set_active (src, TRUE);
+ fail_unless (gst_pad_set_caps (src, caps) == TRUE);
plr = gst_pad_link (src, sink);
fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
- /* caps replaced by src caps */
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+
+ /* src caps added to pending caps on sink */
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
gst_pad_unlink (src, sink);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
/* cleanup */
gst_object_unref (src);
caps = gst_caps_from_string ("foo/bar");
sink = gst_pad_new ("sink", GST_PAD_SINK);
- fail_unless (gst_pad_set_caps (src, caps) == TRUE);
+ fail_if (gst_pad_set_caps (src, caps) == TRUE);
fail_if (gst_pad_set_caps (sink, caps) == TRUE);
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
gst_pad_set_active (sink, TRUE);
fail_unless (gst_pad_set_caps (sink, caps) == TRUE);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+
+ gst_pad_set_active (src, TRUE);
+ fail_unless (gst_pad_set_caps (src, caps) == TRUE);
ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
plr = gst_pad_link (src, sink);
gotcaps = gst_pad_get_allowed_caps (src);
fail_if (gotcaps == NULL);
+ /* FIXME, does not work, caps events are different so the sinkpad loses caps
+ * when linking */
fail_unless (gst_caps_is_equal (gotcaps, caps));
ASSERT_CAPS_REFCOUNT (gotcaps, "gotcaps", 1);
gst_pad_unlink (src, sink);
/* cleanup */
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
caps = gst_caps_from_string ("foo/bar");
gst_pad_set_caps (src, caps);
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
+
+ /* pushing on an inactive pad will drop the buffer */
+ buffer = gst_buffer_new ();
+ gst_buffer_ref (buffer);
+ fail_unless (gst_pad_push (src, buffer) == GST_FLOW_WRONG_STATE);
+ ASSERT_MINI_OBJECT_REFCOUNT (buffer, "buffer", 1);
+ gst_buffer_unref (buffer);
+
+ gst_pad_set_active (src, TRUE);
/* pushing on an unlinked pad will drop the buffer */
buffer = gst_buffer_new ();
/* cleanup */
- ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
gst_object_unref (src);
src = gst_pad_new ("src", GST_PAD_SRC);
fail_if (src == NULL);
+ buffer = gst_buffer_new ();
+ /* new pad should be flushing */
+ gst_buffer_ref (buffer);
+ fail_unless (gst_pad_push (src, buffer) == GST_FLOW_WRONG_STATE);
+ gst_buffer_ref (buffer);
+ fail_unless (gst_pad_chain (sink, buffer) == GST_FLOW_WRONG_STATE);
+
caps = gst_caps_from_string ("foo/bar");
/* one for me */
ASSERT_CAPS_REFCOUNT (caps, "caps", 1);
gst_pad_set_caps (src, caps);
- gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
/* one for me and one for each set_caps */
- ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
plr = gst_pad_link (src, sink);
- fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
+ fail_if (GST_PAD_LINK_SUCCESSFUL (plr));
ASSERT_CAPS_REFCOUNT (caps, "caps", 2);
- buffer = gst_buffer_new ();
-#if 0
- /* FIXME, new pad should be flushing */
- gst_buffer_ref (buffer);
- fail_unless (gst_pad_push (src, buffer) == GST_FLOW_WRONG_STATE);
- gst_buffer_ref (buffer);
- fail_unless (gst_pad_chain (sink, buffer) == GST_FLOW_WRONG_STATE);
-#endif
-
/* activate pads */
gst_pad_set_active (src, TRUE);
gst_pad_set_active (sink, TRUE);
+ gst_pad_set_caps (src, caps);
+ gst_pad_set_caps (sink, caps);
+ /* one for me and one for each set_caps */
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+
+ plr = gst_pad_link (src, sink);
+ fail_unless (GST_PAD_LINK_SUCCESSFUL (plr));
+ ASSERT_CAPS_REFCOUNT (caps, "caps", 3);
+
/* test */
/* pushing on a linked pad will drop the ref to the buffer */
gst_buffer_ref (buffer);
GstCaps *caps;
GstBufferList *list;
GstBuffer *buffer;
- guint len;
/* setup */
sink = gst_pad_new ("sink", GST_PAD_SINK);
caps = gst_caps_from_string ("foo/bar");
+ gst_pad_set_active (src, TRUE);
gst_pad_set_caps (src, caps);
gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
/* test */
/* adding to a buffer list will drop the ref to the buffer */
- len = gst_buffer_list_len (list);
-
gst_buffer_list_add (list, buffer_from_string ("ListGroup"));
gst_buffer_list_add (list, buffer_from_string ("AnotherListGroup"));
GST_PAD_ALWAYS, srccaps);
sink_template = gst_pad_template_new ("sink", GST_PAD_SINK,
GST_PAD_ALWAYS, sinkcaps);
+ gst_caps_unref (srccaps);
+ gst_caps_unref (sinkcaps);
sink = gst_pad_new_from_template (sink_template, "sink");
fail_if (sink == NULL);
caps = gst_caps_from_string ("foo/bar");
+ gst_pad_set_active (src, TRUE);
gst_pad_set_caps (src, caps);
gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
caps = gst_caps_from_string ("foo/bar");
+ gst_pad_set_active (src, TRUE);
gst_pad_set_caps (src, caps);
gst_pad_set_active (sink, TRUE);
gst_pad_set_caps (sink, caps);
bool_user_data[0] = blocked;
- gst_pad_set_blocked_async (pad, FALSE, unblock_async_cb, user_data);
+ gst_pad_set_blocked (pad, FALSE, unblock_async_cb, user_data, NULL);
}
GST_START_TEST (test_block_async)
fail_unless (pad != NULL);
gst_pad_set_active (pad, TRUE);
- gst_pad_set_blocked_async (pad, TRUE, block_async_cb, &data);
+ gst_pad_set_blocked (pad, TRUE, block_async_cb, &data, NULL);
- fail_unless (data[0] == FALSE);
- fail_unless (data[1] == FALSE);
+ fail_unless (data[0] == TRUE);
+ fail_unless (data[1] == TRUE);
gst_pad_push (pad, gst_buffer_new ());
gst_object_unref (pad);
static void
block_async_second (GstPad * pad, gboolean blocked, gpointer user_data)
{
- gst_pad_set_blocked_async (pad, FALSE, unblock_async_cb, NULL);
+ gst_pad_set_blocked (pad, FALSE, unblock_async_cb, NULL, NULL);
}
static void
/* replace block_async_first with block_async_second so next time the pad is
* blocked the latter should be called */
- gst_pad_set_blocked_async (pad, TRUE, block_async_second, NULL);
+ gst_pad_set_blocked (pad, TRUE, block_async_second, NULL, NULL);
/* unblock temporarily, in the next push block_async_second should be called
*/
fail_unless (pad != NULL);
gst_pad_set_active (pad, TRUE);
- gst_pad_set_blocked_async (pad, TRUE, block_async_first, &blocked);
+ gst_pad_set_blocked (pad, TRUE, block_async_first, &blocked, NULL);
blocked = FALSE;
gst_pad_push (pad, gst_buffer_new ());
fail_unless (pad != NULL);
gst_pad_set_active (pad, TRUE);
- gst_pad_set_blocked_async_full (pad, TRUE, block_async_full_cb,
+ gst_pad_set_blocked (pad, TRUE, block_async_full_cb,
&state, block_async_full_destroy);
- fail_unless (state == 0);
+ fail_unless (state == 2);
gst_pad_push (pad, gst_buffer_new ());
/* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
*/
- fail_unless (state == 1);
+ fail_unless (state == 2);
gst_pad_push_event (pad, gst_event_new_flush_stop ());
/* pad was already blocked so nothing happens */
- gst_pad_set_blocked_async_full (pad, TRUE, block_async_full_cb,
+ state = 0;
+ gst_pad_set_blocked (pad, TRUE, block_async_full_cb,
&state, block_async_full_destroy);
- fail_unless (state == 1);
+ fail_unless (state == 2);
/* unblock with the same data, callback is called */
- gst_pad_set_blocked_async_full (pad, FALSE, block_async_full_cb,
+ gst_pad_set_blocked (pad, FALSE, block_async_full_cb,
&state, block_async_full_destroy);
fail_unless (state == 2);
/* block with the same data, callback is called */
state = 1;
- gst_pad_set_blocked_async_full (pad, TRUE, block_async_full_cb,
+ gst_pad_set_blocked (pad, TRUE, block_async_full_cb,
&state, block_async_full_destroy);
fail_unless (state == 2);
/* now change user_data (to NULL in this case) so destroy_notify should be
* called */
+#if 0
state = 1;
- gst_pad_set_blocked_async_full (pad, FALSE, block_async_full_cb,
+ gst_pad_set_blocked (pad, FALSE, block_async_full_cb,
NULL, block_async_full_destroy);
fail_unless (state == 2);
+#endif
gst_object_unref (pad);
}
fail_unless (pad != NULL);
gst_pad_set_active (pad, TRUE);
- gst_pad_set_blocked_async_full (pad, TRUE, block_async_full_cb,
+ gst_pad_set_blocked (pad, TRUE, block_async_full_cb,
&state, block_async_full_destroy);
gst_pad_push (pad, gst_buffer_new ());
/* block_async_full_cb sets state to 1 and then flushes to unblock temporarily
*/
- fail_unless_equals_int (state, 1);
+ fail_unless_equals_int (state, 2);
gst_pad_push_event (pad, gst_event_new_flush_stop ());
/* gst_pad_dispose calls the destroy_notify function if necessary */
static void
-unblock_async_not_called (GstPad * pad, gboolean blocked, gpointer user_data)
-{
- g_warn_if_reached ();
-}
-
-static void
block_async_second_no_flush (GstPad * pad, gboolean blocked, gpointer user_data)
{
gboolean *bool_user_data = (gboolean *) user_data;
bool_user_data[1] = TRUE;
- fail_unless (gst_pad_set_blocked_async (pad, FALSE, unblock_async_no_flush_cb,
- user_data));
+ fail_unless (gst_pad_set_blocked (pad, FALSE, unblock_async_no_flush_cb,
+ user_data, NULL));
}
static void
fail_unless (bool_user_data[1] == FALSE);
fail_unless (bool_user_data[2] == FALSE);
- fail_unless (gst_pad_set_blocked_async (pad, FALSE, unblock_async_not_called,
- NULL));
+ fail_unless (gst_pad_set_blocked (pad, FALSE, NULL, NULL, NULL));
/* replace block_async_first with block_async_second so next time the pad is
* blocked the latter should be called */
- fail_unless (gst_pad_set_blocked_async (pad, TRUE,
- block_async_second_no_flush, user_data));
+ fail_unless (gst_pad_set_blocked (pad, TRUE,
+ block_async_second_no_flush, user_data, NULL));
}
GST_START_TEST (test_block_async_replace_callback_no_flush)
fail_unless (pad != NULL);
gst_pad_set_active (pad, TRUE);
- fail_unless (gst_pad_set_blocked_async (pad, TRUE, block_async_first_no_flush,
- bool_user_data));
+ fail_unless (gst_pad_set_blocked (pad, TRUE, block_async_first_no_flush,
+ bool_user_data, NULL));
gst_pad_push (pad, gst_buffer_new ());
fail_unless (bool_user_data[0] == TRUE);