From b5456cc6f43b19258ee4bf881b7edbf03a6bfaac Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 9 May 2011 16:21:28 +0200 Subject: [PATCH] caps: remove caps from buffers and pads Remove the GstCaps from buffers and pads. We now use CAPS events to negotiate formats between element. --- gst/gstbuffer.c | 67 --------------------------------- gst/gstbuffer.h | 20 ++-------- gst/gstpad.c | 2 +- gst/gstpad.h | 8 ---- tests/check/elements/selector.c | 3 +- tests/check/elements/tee.c | 2 + tests/check/gst/gstcaps.c | 22 ----------- tests/check/gst/gstghostpad.c | 8 ++-- tests/check/libs/transform1.c | 50 ++++++++++++++++++++++++ 9 files changed, 61 insertions(+), 121 deletions(-) diff --git a/gst/gstbuffer.c b/gst/gstbuffer.c index 16dddfcd6c..380e866892 100644 --- a/gst/gstbuffer.c +++ b/gst/gstbuffer.c @@ -305,11 +305,6 @@ gst_buffer_copy_into (GstBuffer * dest, GstBuffer * src, GST_BUFFER_OFFSET_END (dest) = GST_BUFFER_OFFSET_NONE; } } -#if 0 - if (flags & GST_BUFFER_COPY_CAPS) { - gst_caps_replace (&GST_BUFFER_CAPS (dest), GST_BUFFER_CAPS (src)); - } -#endif if (flags & GST_BUFFER_COPY_MEMORY) { GstMemory *mem; @@ -403,10 +398,6 @@ _gst_buffer_free (GstBuffer * buffer) GST_CAT_LOG (GST_CAT_BUFFER, "finalize %p", buffer); -#if 0 - gst_caps_replace (&GST_BUFFER_CAPS (buffer), NULL); -#endif - /* free metadata */ for (walk = GST_BUFFER_META (buffer); walk; walk = next) { GstMeta *meta = &walk->meta; @@ -447,9 +438,6 @@ gst_buffer_init (GstBufferImpl * buffer, gsize size) (GstMiniObjectFreeFunction) _gst_buffer_free; GST_BUFFER (buffer)->pool = NULL; -#if 0 - GST_BUFFER_CAPS (buffer) = NULL; -#endif GST_BUFFER_TIMESTAMP (buffer) = GST_CLOCK_TIME_NONE; GST_BUFFER_DURATION (buffer) = GST_CLOCK_TIME_NONE; GST_BUFFER_OFFSET (buffer) = GST_BUFFER_OFFSET_NONE; @@ -1061,61 +1049,6 @@ gst_buffer_memcmp (GstBuffer * buffer, gsize offset, gconstpointer mem, return res; } -/** - * gst_buffer_get_caps: - * @buffer: a #GstBuffer. - * - * Gets the media type of the buffer. This can be NULL if there - * is no media type attached to this buffer. - * - * Returns: (transfer full): a reference to the #GstCaps. unref after usage. - * Returns NULL if there were no caps on this buffer. - */ -/* this is not made atomic because if the buffer were reffed from multiple - * threads, it would have a refcount > 2 and thus be immutable. - */ -GstCaps * -gst_buffer_get_caps (GstBuffer * buffer) -{ - GstCaps *ret; - - g_return_val_if_fail (buffer != NULL, NULL); - - ret = GST_BUFFER_CAPS (buffer); - - if (ret) - gst_caps_ref (ret); - - return ret; -} - -/** - * gst_buffer_set_caps: - * @buffer: a #GstBuffer. - * @caps: (transfer none): a #GstCaps. - * - * Sets the media type on the buffer. The refcount of the caps will - * be increased and any previous caps on the buffer will be - * unreffed. - */ -/* this is not made atomic because if the buffer were reffed from multiple - * threads, it would have a refcount > 2 and thus be immutable. - */ -void -gst_buffer_set_caps (GstBuffer * buffer, GstCaps * caps) -{ - g_return_if_fail (buffer != NULL); - g_return_if_fail (caps == NULL || GST_CAPS_IS_SIMPLE (caps)); - -#if GST_VERSION_NANO == 1 - /* we enable this extra debugging in git versions only for now */ - g_warn_if_fail (gst_buffer_is_writable (buffer)); - /* FIXME: would be nice to also check if caps are fixed here, but expensive */ -#endif - - gst_caps_replace (&GST_BUFFER_CAPS (buffer), caps); -} - /** * gst_buffer_copy_region: * @parent: a #GstBuffer. diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index 73499fafa4..601c68bc4b 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -111,13 +111,6 @@ typedef struct _GstBufferPool GstBufferPool; * Value will be %GST_CLOCK_TIME_NONE if the duration is unknown. */ #define GST_BUFFER_DURATION(buf) (GST_BUFFER_CAST(buf)->duration) -/** - * GST_BUFFER_CAPS: - * @buf: a #GstBuffer. - * - * The caps for this buffer. - */ -#define GST_BUFFER_CAPS(buf) (GST_BUFFER_CAST(buf)->caps) /** * GST_BUFFER_OFFSET: * @buf: a #GstBuffer. @@ -259,8 +252,6 @@ struct _GstBuffer { /*< public >*/ /* with COW */ GstBufferPool *pool; - /* the media type of this buffer */ - GstCaps *caps; /* timestamp */ GstClockTime timestamp; @@ -386,7 +377,6 @@ gst_buffer_copy (const GstBuffer * buf) * @GST_BUFFER_COPY_FLAGS: flag indicating that buffer flags should be copied * @GST_BUFFER_COPY_TIMESTAMPS: flag indicating that buffer timestamp, duration, * offset and offset_end should be copied - * @GST_BUFFER_COPY_CAPS: flag indicating that buffer caps should be copied * @GST_BUFFER_COPY_MEMORY: flag indicating that buffer memory should be copied * and appended to already existing memory * @GST_BUFFER_COPY_MERGE: flag indicating that buffer memory should be @@ -399,9 +389,8 @@ typedef enum { GST_BUFFER_COPY_NONE = 0, GST_BUFFER_COPY_FLAGS = (1 << 0), GST_BUFFER_COPY_TIMESTAMPS = (1 << 1), - GST_BUFFER_COPY_CAPS = (1 << 2), - GST_BUFFER_COPY_MEMORY = (1 << 3), - GST_BUFFER_COPY_MERGE = (1 << 4) + GST_BUFFER_COPY_MEMORY = (1 << 2), + GST_BUFFER_COPY_MERGE = (1 << 3) } GstBufferCopyFlags; /** @@ -410,7 +399,7 @@ typedef enum { * Combination of all possible metadata fields that can be copied with * gst_buffer_copy_into(). */ -#define GST_BUFFER_COPY_METADATA (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_CAPS) +#define GST_BUFFER_COPY_METADATA (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS) /** * GST_BUFFER_COPY_ALL: @@ -469,9 +458,6 @@ G_STMT_START { \ GST_MINI_OBJECT_CAST (nbuf)); \ } G_STMT_END -GstCaps* gst_buffer_get_caps (GstBuffer *buffer); -void gst_buffer_set_caps (GstBuffer *buffer, GstCaps *caps); - /* creating a region */ GstBuffer* gst_buffer_copy_region (GstBuffer *parent, GstBufferCopyFlags flags, gsize offset, gsize size); diff --git a/gst/gstpad.c b/gst/gstpad.c index bf21cf61ee..e1c3298524 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -2316,7 +2316,7 @@ gst_pad_get_current_caps (GstPad * pad) * * Gets the capabilities this pad can produce or consume. * Note that this method doesn't necessarily return the caps set by - * gst_pad_set_caps() - use GST_PAD_CAPS() for that instead. + * gst_pad_set_caps() - use gst_pad_get_current_caps() for that instead. * gst_pad_get_caps returns all possible caps a pad can operate with, using * the pad's get_caps function; * this returns the pad template caps if not explicitly set. diff --git a/gst/gstpad.h b/gst/gstpad.h index e9a4feedc3..6db9570c16 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -601,7 +601,6 @@ struct _GstPad { gboolean block_callback_called; /* the pad capabilities */ - GstCaps *caps; GstPadGetCapsFunction getcapsfunc; GstPadSetCapsFunction setcapsfunc; GstPadAcceptCapsFunction acceptcapsfunc; @@ -682,13 +681,6 @@ struct _GstPadClass { #define GST_PAD_LINKFUNC(pad) (GST_PAD_CAST(pad)->linkfunc) #define GST_PAD_UNLINKFUNC(pad) (GST_PAD_CAST(pad)->unlinkfunc) -/** - * GST_PAD_CAPS: - * @pad: a #GstPad. - * - * The caps for this pad. - */ -#define GST_PAD_CAPS(pad) (GST_PAD_CAST(pad)->caps) #define GST_PAD_GETCAPSFUNC(pad) (GST_PAD_CAST(pad)->getcapsfunc) #define GST_PAD_SETCAPSFUNC(pad) (GST_PAD_CAST(pad)->setcapsfunc) #define GST_PAD_ACCEPTCAPSFUNC(pad) (GST_PAD_CAST(pad)->acceptcapsfunc) diff --git a/tests/check/elements/selector.c b/tests/check/elements/selector.c index fd6799adeb..a1bb508c48 100644 --- a/tests/check/elements/selector.c +++ b/tests/check/elements/selector.c @@ -208,8 +208,6 @@ push_switched_buffers (GList * input_pads, /* setup dummy buffer */ caps = gst_caps_from_string ("application/x-unknown"); buf = gst_buffer_new_and_alloc (1); - gst_buffer_set_caps (buf, caps); - gst_caps_unref (caps); while (l != NULL) { /* set selector pad */ @@ -226,6 +224,7 @@ push_switched_buffers (GList * input_pads, /* cleanup buffer */ gst_buffer_unref (buf); + gst_caps_unref (caps); } /* Create output-selector with given number of src pads and switch diff --git a/tests/check/elements/tee.c b/tests/check/elements/tee.c index 5c44ea844c..5080ce0251 100644 --- a/tests/check/elements/tee.c +++ b/tests/check/elements/tee.c @@ -491,7 +491,9 @@ GST_START_TEST (test_flow_aggregation) GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS); buffer = gst_buffer_new (); +#if 0 gst_buffer_set_caps (buffer, caps); +#endif /* First check if everything works in normal state */ fail_unless (gst_pad_push (mysrc, gst_buffer_ref (buffer)) == GST_FLOW_OK); diff --git a/tests/check/gst/gstcaps.c b/tests/check/gst/gstcaps.c index a22c15f0d2..4ee58606fb 100644 --- a/tests/check/gst/gstcaps.c +++ b/tests/check/gst/gstcaps.c @@ -53,27 +53,6 @@ GST_START_TEST (test_from_string) GST_END_TEST; -GST_START_TEST (test_buffer) -{ - GstCaps *c1; - GstBuffer *buffer; - - buffer = gst_buffer_new_and_alloc (1000); - c1 = gst_caps_new_simple ("audio/x-raw-int", - "buffer", GST_TYPE_BUFFER, buffer, NULL); - - GST_DEBUG ("caps: %" GST_PTR_FORMAT, c1); - gst_buffer_unref (buffer); - - buffer = gst_buffer_new_and_alloc (1000); - gst_buffer_set_caps (buffer, c1); /* doesn't give away our c1 ref */ - - gst_caps_unref (c1); - gst_buffer_unref (buffer); /* Should now drop both references */ -} - -GST_END_TEST; - GST_START_TEST (test_double_append) { GstStructure *s1; @@ -927,7 +906,6 @@ gst_caps_suite (void) tcase_add_test (tc_chain, test_from_string); tcase_add_test (tc_chain, test_double_append); tcase_add_test (tc_chain, test_mutability); - tcase_add_test (tc_chain, test_buffer); tcase_add_test (tc_chain, test_static_caps); tcase_add_test (tc_chain, test_simplify); tcase_add_test (tc_chain, test_truncate); diff --git a/tests/check/gst/gstghostpad.c b/tests/check/gst/gstghostpad.c index b78538aaa4..46ba417180 100644 --- a/tests/check/gst/gstghostpad.c +++ b/tests/check/gst/gstghostpad.c @@ -697,7 +697,7 @@ GST_START_TEST (test_ghost_pads_forward_setcaps) caps1 = gst_caps_from_string ("meh"); fail_unless (gst_pad_set_caps (src, caps1)); - caps2 = GST_PAD_CAPS (ghost); + caps2 = gst_pad_get_current_caps (ghost); fail_unless (gst_caps_is_equal (caps1, caps2)); fail_unless_equals_int (notify_counter, 1); @@ -716,7 +716,7 @@ GST_START_TEST (test_ghost_pads_forward_setcaps) caps1 = gst_caps_from_string ("meh"); fail_unless (gst_pad_set_caps (ghost, caps1)); - caps2 = GST_PAD_CAPS (src); + caps2 = gst_pad_get_current_caps (src); fail_unless (caps2 == NULL); fail_unless_equals_int (notify_counter, 1); @@ -734,7 +734,7 @@ GST_START_TEST (test_ghost_pads_forward_setcaps) caps1 = gst_caps_from_string ("muh"); fail_unless (gst_pad_set_caps (ghost, caps1)); - caps2 = GST_PAD_CAPS (sink); + caps2 = gst_pad_get_current_caps (sink); fail_unless (gst_caps_is_equal (caps1, caps2)); fail_unless_equals_int (notify_counter, 1); @@ -751,7 +751,7 @@ GST_START_TEST (test_ghost_pads_forward_setcaps) caps1 = gst_caps_from_string ("muh"); fail_unless (gst_pad_set_caps (sink, caps1)); - caps2 = GST_PAD_CAPS (ghost); + caps2 = gst_pad_get_current_caps (ghost); fail_unless (caps2 == NULL); fail_unless_equals_int (notify_counter, 0); diff --git a/tests/check/libs/transform1.c b/tests/check/libs/transform1.c index 2ecca4980b..36ca995690 100644 --- a/tests/check/libs/transform1.c +++ b/tests/check/libs/transform1.c @@ -87,8 +87,10 @@ GST_START_TEST (basetransform_chain_pt1) 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); @@ -106,8 +108,10 @@ GST_START_TEST (basetransform_chain_pt1) 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); @@ -173,7 +177,9 @@ GST_START_TEST (basetransform_chain_pt2) 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; @@ -186,7 +192,9 @@ GST_START_TEST (basetransform_chain_pt2) 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); @@ -211,7 +219,9 @@ GST_START_TEST (basetransform_chain_pt2) 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; @@ -224,7 +234,9 @@ GST_START_TEST (basetransform_chain_pt2) 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); @@ -438,7 +450,9 @@ GST_START_TEST (basetransform_chain_ip2) 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; @@ -455,7 +469,9 @@ GST_START_TEST (basetransform_chain_ip2) 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 @@ -472,7 +488,9 @@ GST_START_TEST (basetransform_chain_ip2) 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); @@ -492,7 +510,9 @@ GST_START_TEST (basetransform_chain_ip2) 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 /* output buffer has refcount 1 */ //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1); @@ -686,7 +706,9 @@ GST_START_TEST (basetransform_chain_ct1) /* 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); @@ -704,11 +726,15 @@ GST_START_TEST (basetransform_chain_ct1) 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); 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); @@ -730,7 +756,9 @@ GST_START_TEST (basetransform_chain_ct1) 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 /* output buffer has refcount 1 */ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1); @@ -977,7 +1005,9 @@ GST_START_TEST (basetransform_chain_ct2) /* 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); @@ -997,11 +1027,15 @@ GST_START_TEST (basetransform_chain_ct2) 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); 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); @@ -1023,7 +1057,9 @@ GST_START_TEST (basetransform_chain_ct2) 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 /* output buffer has refcount 1 */ //fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1); @@ -1139,7 +1175,9 @@ GST_START_TEST (basetransform_chain_ct3) /* 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); @@ -1157,11 +1195,15 @@ GST_START_TEST (basetransform_chain_ct3) 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); 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); @@ -1181,7 +1223,9 @@ GST_START_TEST (basetransform_chain_ct3) 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 /* output buffer has refcount 1 */ fail_unless (GST_MINI_OBJECT_REFCOUNT_VALUE (buffer) == 1); @@ -1224,7 +1268,9 @@ GST_START_TEST (basetransform_chain_ct3) 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; @@ -1241,8 +1287,10 @@ GST_START_TEST (basetransform_chain_ct3) 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); @@ -1272,7 +1320,9 @@ GST_START_TEST (basetransform_chain_ct3) 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;