#include "test_transform.c"
-static gboolean buffer_alloc_pt1_called;
-
-#if 0
-static GstFlowReturn
-buffer_alloc_pt1 (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
- GstBuffer ** buf)
-{
- GST_DEBUG_OBJECT (pad, "buffer_alloc called %" G_GUINT64_FORMAT ", %u, %"
- GST_PTR_FORMAT, offset, size, caps);
-
- buffer_alloc_pt1_called = TRUE;
-
- *buf = gst_buffer_new_and_alloc (size);
- gst_buffer_set_caps (*buf, caps);
-
- return GST_FLOW_OK;
-}
-#endif
-
static gboolean set_caps_pt1_called;
static gboolean
TestTransData *trans;
GstBuffer *buffer;
GstFlowReturn res;
- //GstCaps *caps;
+ GstCaps *caps;
klass_set_caps = set_caps_pt1;
trans = gst_test_trans_new ();
+ gst_test_trans_push_segment (trans);
+
GST_DEBUG_OBJECT (trans, "buffer without caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
- buffer_alloc_pt1_called = FALSE;
set_caps_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
fail_unless (set_caps_pt1_called == FALSE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- /* caps should not have been set */
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
-#endif
gst_buffer_unref (buffer);
GST_DEBUG_OBJECT (trans, "buffer without caps, size 10");
buffer = gst_buffer_new_and_alloc (10);
- buffer_alloc_pt1_called = FALSE;
set_caps_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
fail_unless (set_caps_pt1_called == FALSE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 10);
-#if 0
- /* caps should not have been set */
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
-#endif
gst_buffer_unref (buffer);
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
caps = gst_caps_new_empty_simple ("foo/x-bar");
- buffer_alloc_pt1_called = FALSE;
set_caps_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt1_called == FALSE);
- gst_buffer_unref (buffer);
-
- /* once more */
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt1_called == FALSE);
- gst_buffer_unref (buffer);
-
+ gst_test_trans_setcaps (trans, caps);
+ fail_unless (set_caps_pt1_called == TRUE);
gst_caps_unref (caps);
-#endif
+
+ gst_test_trans_push_segment (trans);
gst_test_trans_free (trans);
}
trans = gst_test_trans_new ();
/* first buffer */
+ set_caps_pt2_called = FALSE;
caps = gst_caps_new_empty_simple ("foo/x-bar");
+ gst_test_trans_setcaps (trans, caps);
+ gst_test_trans_push_segment (trans);
GST_DEBUG_OBJECT (trans, "buffer with caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
- //fail_unless (set_caps_pt2_called == TRUE);
+ fail_unless (set_caps_pt2_called == TRUE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
gst_buffer_unref (buffer);
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt2_called == FALSE);
- gst_buffer_unref (buffer);
-#endif
-
gst_caps_unref (caps);
/* second buffer, renegotiates, keeps extra type arg in caps */
caps = gst_caps_new_simple ("foo/x-bar", "type", G_TYPE_INT, 1, NULL);
+ set_caps_pt2_called = FALSE;
+ gst_test_trans_setcaps (trans, caps);
GST_DEBUG_OBJECT (trans, "buffer with caps, size 10");
buffer = gst_buffer_new_and_alloc (10);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- /* FIXME, passthough without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
- //fail_unless (set_caps_pt2_called == TRUE);
+ fail_unless (set_caps_pt2_called == TRUE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
fail_unless (gst_buffer_get_size (buffer) == 10);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
gst_buffer_unref (buffer);
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt2_called == FALSE);
- gst_buffer_unref (buffer);
-#endif
-
gst_caps_unref (caps);
/* with caps that is a superset */
caps = gst_caps_new_empty_simple ("foo/x-bar");
+ set_caps_pt2_called = FALSE;
+ gst_test_trans_setcaps (trans, caps);
-#if 0
- GST_DEBUG_OBJECT (trans, "alloc with superset caps, size 20");
+ GST_DEBUG_OBJECT (trans, "buffer with caps, size 10");
- buffer_alloc_pt1_called = FALSE;
- set_caps_pt2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
+ buffer = gst_buffer_new_and_alloc (10);
+
+ res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (set_caps_pt2_called == FALSE);
+ fail_unless (set_caps_pt2_called == TRUE);
+
+ buffer = gst_test_trans_pop (trans);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 10);
+
gst_buffer_unref (buffer);
-#endif
gst_caps_unref (caps);
klass_transform_ip = transform_ip_1;
trans = gst_test_trans_new ();
+ gst_test_trans_push_segment (trans);
+
GST_DEBUG_OBJECT (trans, "buffer without caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
transform_ip_1_called = FALSE;
transform_ip_1_writable = TRUE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
fail_unless (transform_ip_1_called == TRUE);
fail_unless (transform_ip_1_writable == TRUE);
- /* FIXME, in-place without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
buffer = gst_test_trans_pop (trans);
fail_unless (buffer != NULL);
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_OK);
fail_unless (transform_ip_1_called == TRUE);
/* copy should have been taken with pad-alloc */
fail_unless (transform_ip_1_writable == TRUE);
- //fail_unless (buffer_alloc_pt1_called == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
/* with caps buffer */
GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-#if 0
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- gst_buffer_unref (buffer);
-#endif
-
gst_test_trans_free (trans);
}
trans = gst_test_trans_new ();
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 20);
- fail_unless (GST_BUFFER_CAPS (buffer) == NULL);
- gst_buffer_unref (buffer);
-#endif
-
caps = gst_caps_new_empty_simple ("foo/x-bar");
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 20);
- fail_unless (GST_BUFFER_CAPS (buffer) == caps);
- gst_buffer_unref (buffer);
-#endif
+ gst_test_trans_push_segment (trans);
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- buffer_alloc_pt1_called = FALSE;
set_caps_1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ip_1_called == FALSE);
fail_unless (transform_ip_1_writable == FALSE);
fail_unless (set_caps_1_called == FALSE);
- fail_unless (buffer_alloc_pt1_called == FALSE);
/* try to push a buffer with caps */
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
+ set_caps_1_called = FALSE;
+ gst_test_trans_setcaps (trans, caps);
+ gst_test_trans_push_segment (trans);
+
GST_DEBUG_OBJECT (trans, "buffer with caps, size 20");
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- set_caps_1_called = FALSE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ip_1_called == TRUE);
- //fail_unless (transform_ip_1_writable == TRUE);
- //fail_unless (set_caps_1_called == TRUE);
- /* FIXME, in-place without pad-alloc, do pad-alloc on the srcpad */
- //fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ip_1_called == TRUE);
+ fail_unless (transform_ip_1_writable == TRUE);
+ fail_unless (set_caps_1_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
gst_buffer_unref (buffer);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps extra ref, size 20");
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, caps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
transform_ip_1_called = FALSE;
transform_ip_1_writable = FALSE;
- buffer_alloc_pt1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ip_1_called == TRUE);
- //fail_unless (transform_ip_1_writable == TRUE);
- //fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ip_1_called == TRUE);
+ fail_unless (transform_ip_1_writable == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), caps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_pt1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, caps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_pt1_called == TRUE);
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
-#endif
gst_caps_unref (caps);
return TRUE;
}
-gboolean buffer_alloc_ct1_called;
-
-#if 0
-static GstFlowReturn
-buffer_alloc_ct1 (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
- GstBuffer ** buf)
-{
- GstCaps *outcaps;
-
- GST_DEBUG_OBJECT (pad, "buffer_alloc called %" G_GUINT64_FORMAT ", %u, %"
- GST_PTR_FORMAT, offset, size, caps);
-
- buffer_alloc_ct1_called = TRUE;
-
- outcaps = gst_caps_new_empty_simple ("foo/x-bar");
- fail_unless (gst_caps_is_equal (outcaps, caps));
- gst_caps_unref (outcaps);
-
- *buf = gst_buffer_new_and_alloc (size);
- gst_buffer_set_caps (*buf, caps);
-
- return GST_FLOW_OK;
-}
-#endif
-
/* basic copy-transform, check if the transform function is called,
* buffer should be writable. we also set a setcaps function and
* see if it's called. */
incaps = gst_caps_new_empty_simple ("baz/x-foo");
outcaps = gst_caps_new_empty_simple ("foo/x-bar");
-
-#if 0
- /* without caps buffer, I think this should fail */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct1_called == FALSE);
-#endif
-
-#if 0
- /* with wrong (unsupported) caps */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 20");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- gst_buffer_unref (buffer);
- /* FIXME, why would this call the alloc function? we try to alloc something
- * with caps that are not supported on the sinkpad */
- fail_unless (buffer_alloc_ct1_called == FALSE);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 20");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct1_called == FALSE);
- gst_buffer_unref (buffer);
-#endif
+ gst_test_trans_push_segment (trans);
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
transform_ct1_called = FALSE;
transform_ct1_writable = FALSE;
set_caps_ct1_called = FALSE;
- buffer_alloc_ct1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ct1_called == FALSE);
fail_unless (transform_ct1_writable == FALSE);
fail_unless (set_caps_ct1_called == FALSE);
- fail_unless (buffer_alloc_ct1_called == FALSE);
/* try to push a buffer with caps */
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
+ set_caps_ct1_called = FALSE;
+ gst_test_trans_setcaps (trans, incaps);
+ gst_test_trans_push_segment (trans);
+
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
transform_ct1_called = FALSE;
transform_ct1_writable = FALSE;
- set_caps_ct1_called = FALSE;
- buffer_alloc_ct1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct1_called == TRUE);
- //fail_unless (transform_ct1_writable == TRUE);
- //fail_unless (set_caps_ct1_called == TRUE);
- //fail_unless (buffer_alloc_ct1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct1_called == TRUE);
+ fail_unless (transform_ct1_writable == TRUE);
+ fail_unless (set_caps_ct1_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 40);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
-#endif
- //gst_buffer_unref (buffer);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 40);
+ gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
transform_ct1_called = FALSE;
transform_ct1_writable = FALSE;
- buffer_alloc_ct1_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct1_called == TRUE);
- //fail_unless (transform_ct1_writable == TRUE);
- //fail_unless (buffer_alloc_ct1_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct1_called == TRUE);
+ fail_unless (transform_ct1_writable == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 40);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 40);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- /* should not call pad-alloc because the caps and sizes are different, it
- * currently still calls the pad alloc for no reason and then throws away the
- * buffer. */
- fail_unless (buffer_alloc_ct1_called == FALSE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 10");
-
- buffer_alloc_ct1_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
- /* should not call the pad-alloc function */
- fail_unless (buffer_alloc_ct1_called == FALSE);
-#endif
gst_caps_unref (incaps);
gst_caps_unref (outcaps);
if (dir == GST_PAD_SINK) {
/* everything on the sinkpad can be transformed to the output formats */
- res = gst_caps_from_string ("foo/x-bar;baz/x-foo");
+ if (set_caps_ct2_case == 1)
+ res = gst_caps_new_empty_simple ("foo/x-bar");
+ else
+ res = gst_caps_new_empty_simple ("baz/x-foo");
} else {
/* all on the srcpad can be transformed to the format of the sinkpad */
res = gst_caps_new_empty_simple ("foo/x-bar");
return TRUE;
}
-static gint buffer_alloc_ct2_case;
-static gboolean buffer_alloc_ct2_called;
-static gboolean buffer_alloc_ct2_suggest;
-
-#if 0
-static GstFlowReturn
-buffer_alloc_ct2 (GstPad * pad, guint64 offset, guint size, GstCaps * caps,
- GstBuffer ** buf)
-{
- GstCaps *incaps, *outcaps;
-
- GST_DEBUG_OBJECT (pad, "buffer_alloc called %" G_GUINT64_FORMAT ", %u, %"
- GST_PTR_FORMAT, offset, size, caps);
-
- buffer_alloc_ct2_called = TRUE;
-
- if (buffer_alloc_ct2_case == 1) {
- incaps = gst_caps_new_empty_simple ("foo/x-bar");
- if (buffer_alloc_ct2_suggest) {
- outcaps = gst_caps_new_empty_simple ("baz/x-foo");
- size *= 2;
- } else
- outcaps = gst_caps_ref (incaps);
- } else {
- incaps = gst_caps_new_empty_simple ("baz/x-foo");
- if (buffer_alloc_ct2_suggest) {
- outcaps = gst_caps_new_empty_simple ("foo/x-bar");
- size /= 2;
- } else
- outcaps = gst_caps_ref (incaps);
- }
- GST_DEBUG_OBJECT (pad, "expect %" GST_PTR_FORMAT, incaps);
-
- fail_unless (gst_caps_is_equal (caps, incaps));
-
- *buf = gst_buffer_new_and_alloc (size);
- gst_buffer_set_caps (*buf, outcaps);
-
- GST_DEBUG_OBJECT (pad, "return buffer of size %u, caps %" GST_PTR_FORMAT,
- size, outcaps);
-
- gst_caps_unref (outcaps);
- gst_caps_unref (incaps);
-
- return GST_FLOW_OK;
-}
-#endif
-
/* basic copy-transform, check if the transform function is called,
* buffer should be writable. we also set a setcaps function and
* see if it's called. */
incaps = gst_caps_new_empty_simple ("foo/x-bar");
outcaps = gst_caps_new_empty_simple ("baz/x-foo");
-#if 0
- /* without caps buffer, I think this should fail */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
-
-#if 0
- /* with passthrough caps */
- GST_DEBUG_OBJECT (trans, "alloc size 20, with passthrough caps %"
- GST_PTR_FORMAT, incaps);
-
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc size 20, with wrong caps %" GST_PTR_FORMAT,
- outcaps);
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- gst_buffer_unref (buffer);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
+ gst_test_trans_push_segment (trans);
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ct2_called == FALSE);
fail_unless (transform_ct2_writable == FALSE);
fail_unless (set_caps_ct2_called == FALSE);
- fail_unless (buffer_alloc_ct2_called == FALSE);
+
/* try to push a buffer with caps */
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
+ set_caps_ct2_case = 1;
+ set_caps_ct2_called = FALSE;
+ gst_test_trans_setcaps (trans, incaps);
+ gst_test_trans_push_segment (trans);
+
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
- buffer_alloc_ct2_case = 1;
- set_caps_ct2_case = 1;
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
- set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- //fail_unless (transform_ct2_writable == TRUE);
- //fail_unless (set_caps_ct2_called == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
+ fail_unless (transform_ct2_writable == TRUE);
+ fail_unless (set_caps_ct2_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
- //gst_buffer_unref (buffer);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
+ gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- //fail_unless (transform_ct2_writable == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
+ fail_unless (transform_ct2_writable == TRUE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 10");
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
- /* should not call the pad-alloc function */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
gst_caps_unref (incaps);
gst_caps_unref (outcaps);
incaps = gst_caps_new_empty_simple ("foo/x-bar");
outcaps = gst_caps_new_empty_simple ("baz/x-foo");
-#if 0
- /* without caps buffer, I think this should fail */
- GST_DEBUG_OBJECT (trans, "alloc without caps, size 20");
-
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, NULL, &buffer);
- fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
-
/* with passthrough caps */
+ gst_test_trans_push_segment (trans);
GST_DEBUG_OBJECT (trans, "alloc size 20, with passthrough caps %"
GST_PTR_FORMAT, incaps);
-#if 0
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc size 20, with wrong caps %" GST_PTR_FORMAT,
- outcaps);
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 20, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- gst_buffer_unref (buffer);
- /* should not call pad-alloc because the caps and sizes are different */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
-
/* first try to push a buffer without caps, this should fail */
buffer = gst_buffer_new_and_alloc (20);
transform_ct2_called = FALSE;
transform_ct2_writable = FALSE;
set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
fail_unless (res == GST_FLOW_NOT_NEGOTIATED);
fail_unless (transform_ct2_called == FALSE);
fail_unless (transform_ct2_writable == FALSE);
fail_unless (set_caps_ct2_called == FALSE);
- fail_unless (buffer_alloc_ct2_called == FALSE);
/* try to push a buffer with caps */
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
- buffer_alloc_ct2_case = 1;
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_start ());
+ gst_pad_push_event (trans->srcpad, gst_event_new_flush_stop (TRUE));
+
set_caps_ct2_case = 1;
- transform_ct2_called = FALSE;
set_caps_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
+ gst_test_trans_setcaps (trans, incaps);
+ gst_test_trans_push_segment (trans);
+
+ transform_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == FALSE);
- //fail_unless (set_caps_ct2_called == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == FALSE);
+ fail_unless (set_caps_ct2_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
- //gst_buffer_unref (buffer);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
+ gst_buffer_unref (buffer);
buffer = gst_buffer_new_and_alloc (20);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* take additional ref to make it non-writable */
gst_buffer_ref (buffer);
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
transform_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == FALSE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == FALSE);
/* after push, get rid of the final ref we had */
gst_buffer_unref (buffer);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
-#if 0
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
-#endif
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- gst_buffer_unref (buffer);
-
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with wrong caps, size 10");
-
- buffer_alloc_ct2_case = 2;
- buffer_alloc_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, outcaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_if (buffer == NULL);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
- /* if we don't push here, basetransform will think it doesn't need do a
- * pad alloc for downstream caps suggestions */
- res = gst_test_trans_push (trans, buffer);
- buffer = gst_test_trans_pop (trans);
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
- /* FIXME should not call the pad-alloc function but it currently does */
- fail_unless (buffer_alloc_ct2_called == FALSE);
-#endif
/* change the return value of the buffer-alloc function */
GST_DEBUG_OBJECT (trans, "switching transform output");
- buffer_alloc_ct2_suggest = TRUE;
GST_DEBUG_OBJECT (trans,
"buffer with in passthrough with caps %" GST_PTR_FORMAT, incaps);
buffer = gst_buffer_new_and_alloc (10);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* don't suggest anything else */
- buffer_alloc_ct2_case = 1;
set_caps_ct2_case = 2;
+ gst_pad_push_event (trans->sinkpad, gst_event_new_reconfigure ());
transform_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- /* FIXME, pad alloc must be called to get the new caps, because we don't call
- * pad alloc */
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- /* FIXME changing src caps should produce converted buffer */
-#if 0
- GST_DEBUG_OBJECT (trans, "received caps %" GST_PTR_FORMAT,
- GST_BUFFER_CAPS (buffer));
-#endif
- //fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
- //fail_unless (gst_buffer_get_size (buffer) == 20);
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
-
-#if 0
- /* with caps buffer */
- GST_DEBUG_OBJECT (trans, "alloc with caps, size 10");
-
- set_caps_ct2_case = 0;
- buffer_alloc_ct2_case = 1;
- buffer_alloc_ct2_called = FALSE;
- set_caps_ct2_called = FALSE;
- res = gst_pad_alloc_buffer (trans->srcpad, 0, 10, incaps, &buffer);
- fail_unless (res == GST_FLOW_OK);
- fail_unless (buffer_alloc_ct2_called == TRUE);
- /* FIXME a buffer alloc should never set caps */
- fail_unless (set_caps_ct2_called == FALSE);
- fail_unless (gst_buffer_get_size (buffer) == 10);
- /* FIXME, ideally we want to reuse these caps */
- fail_unless (GST_BUFFER_CAPS (buffer) == incaps);
- fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), incaps));
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
gst_buffer_unref (buffer);
-#endif
GST_DEBUG_OBJECT (trans, "buffer with caps %" GST_PTR_FORMAT, incaps);
buffer = gst_buffer_new_and_alloc (10);
-#if 0
- gst_buffer_set_caps (buffer, incaps);
-#endif
/* don't suggest anything else */
- buffer_alloc_ct2_suggest = FALSE;
- buffer_alloc_ct2_case = 0;
transform_ct2_called = FALSE;
- buffer_alloc_ct2_called = FALSE;
res = gst_test_trans_push (trans, buffer);
- //fail_unless (res == GST_FLOW_OK);
- //fail_unless (transform_ct2_called == TRUE);
- //fail_unless (buffer_alloc_ct2_called == TRUE);
+ fail_unless (res == GST_FLOW_OK);
+ fail_unless (transform_ct2_called == TRUE);
/* after push, get rid of the final ref we had */
buffer = gst_test_trans_pop (trans);
- //fail_unless (buffer != NULL);
- //fail_unless (gst_buffer_get_size (buffer) == 20);
- //fail_unless (gst_caps_is_equal (GST_BUFFER_CAPS (buffer), outcaps));
+ fail_unless (buffer != NULL);
+ fail_unless (gst_buffer_get_size (buffer) == 20);
/* output buffer has refcount 1 */
- //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
- //gst_buffer_unref (buffer);
+ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1);
+ gst_buffer_unref (buffer);
gst_caps_unref (incaps);
gst_caps_unref (outcaps);