diff --git a/subprojects/gstreamer/gst/gstmeta.c b/subprojects/gstreamer/gst/gstmeta.c index fc8695633e..4bac360876 100644 --- a/subprojects/gstreamer/gst/gstmeta.c +++ b/subprojects/gstreamer/gst/gstmeta.c @@ -188,7 +188,7 @@ custom_transform_func (GstBuffer * transbuf, GstMeta * meta, gst_structure_take (&custom->structure, gst_structure_copy (cmeta->structure)); gst_structure_set_parent_refcount (custom->structure, - &GST_MINI_OBJECT_REFCOUNT (buffer)); + &GST_MINI_OBJECT_REFCOUNT (transbuf)); } else { return FALSE; } diff --git a/subprojects/gstreamer/gst/gstmeta.h b/subprojects/gstreamer/gst/gstmeta.h index 547e5fc870..71c3095bfc 100644 --- a/subprojects/gstreamer/gst/gstmeta.h +++ b/subprojects/gstreamer/gst/gstmeta.h @@ -199,8 +199,8 @@ typedef gboolean (*GstMetaTransformFunction) (GstBuffer *transbuf, * @user_data: user data passed when registering the meta * * Function called for each @meta in @buffer as a result of performing a - * transformation on @transbuf. Additional @type specific transform data - * is passed to the function as @data. + * transformation that yields @transbuf. Additional @type specific transform + * data is passed to the function as @data. * * Implementations should check the @type of the transform and parse * additional type specific fields in @data that should be used to update diff --git a/subprojects/gstreamer/tests/check/gst/gstmeta.c b/subprojects/gstreamer/tests/check/gst/gstmeta.c index c407bef3bd..b5d0392076 100644 --- a/subprojects/gstreamer/tests/check/gst/gstmeta.c +++ b/subprojects/gstreamer/tests/check/gst/gstmeta.c @@ -690,11 +690,11 @@ GST_END_TEST; GST_START_TEST (test_meta_custom) { - GstBuffer *buffer; + GstBuffer *buffer, *trans_buf; const GstMetaInfo *info; - GstCustomMeta *meta; + GstCustomMeta *meta, *trans_meta; GstMeta *it; - GstStructure *s, *expected; + GstStructure *s, *trans_s, *expected; gpointer state = NULL; const gchar *tags[] = { "test-tag", NULL }; @@ -718,9 +718,19 @@ GST_START_TEST (test_meta_custom) gst_structure_free (expected); gst_structure_set (s, "test-field", G_TYPE_INT, 42, NULL); + gst_buffer_ref (buffer); + ASSERT_CRITICAL (gst_structure_set (s, "test-field", G_TYPE_INT, 43, NULL)); + + /* Test that a copied buffer's meta structure has the correct refcount */ + trans_buf = gst_buffer_copy (buffer); + trans_meta = gst_buffer_get_custom_meta (trans_buf, "test-custom"); + trans_s = gst_custom_meta_get_structure (trans_meta); + gst_structure_set (trans_s, "test-field", G_TYPE_INT, 43, NULL); + gst_buffer_unref (buffer); + expected = gst_structure_new ("test-custom", "test-field", G_TYPE_INT, 42, NULL); fail_unless (gst_structure_is_equal (s, expected)); @@ -734,6 +744,7 @@ GST_START_TEST (test_meta_custom) /* clean up */ gst_buffer_unref (buffer); + gst_buffer_unref (trans_buf); } GST_END_TEST;