mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
meta: Set the parent refcount of the GstStructure correctly
The parent refcount is of the *transformed* buffer, not the input buffer. Also update the docs to clarify that @transbuf is the transformed buffer, and not the buffer on which a transformation is being performed. Due to this bug, modifying the structure of a meta that has been copied to another buffer fails with: gst_structure_set: assertion 'IS_MUTABLE (structure) || field == NULL' failed Add a test for the same. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2890>
This commit is contained in:
parent
df64226e71
commit
a14df98ff4
3 changed files with 17 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue