How to properly use gst_buffer_remove_meta()?

Tamas km212121 at
Tue Feb 4 07:13:17 UTC 2020


I'm using GstReferenceTimestampMeta to store some information in buffers.
Adding and getting the meta works fine; removing the meta from the buffer
also works if I have the original address of the meta. However, say, I don't
store the original address but recall the meta with
gst_buffer_get_reference_timestamp_meta(), then I'm unable to use
gst_buffer_remove_meta() to disassociate the meta from the buffer.

In code:


timestampmetacaps = gst_caps_new_any(); // assume this is available

>>>>>>> GST_PAD_PROBE_TYPE_BUFFER probe on PAD1 

// Add meta to buffer:

GstReferenceTimestampMeta* meta =
gst_buffer_add_reference_timestamp_meta(buffer, timestampmetacaps, a, b);

// At this point I can remove the meta:

gst_buffer_remove_meta(buffer, meta); // -> TRUE, further attempts to access
meta fail


// Recalling the meta works (provided it's NOT removed, of course):

GstReferenceTimestampMeta* meta2 =
gst_buffer_get_reference_timestamp_meta(buffer, NULL); // OK, could use
timestampmetacaps as well

// Removing the meta doesn't work:

gboolean res = gst_buffer_remove_meta(buffer, meta2); // -> FALSE

// Tried this as well, not sure if it's supposed to work anyway:

gboolean res2 = gst_buffer_remove_meta(buffer, &meta2->parent); // -> FALSE


In my case, adding and getting the meta happens at different pads, so I
don't have access to the original pointer.

I tried &meta2->parent, because in gstbuffer.c, gst_buffer_remove_meta()
iterates over the metas attached to the buffer and checks equality between
the meta pointer to be removed and m (GstMeta.meta), which should be the
same as GstReferenceTimestampMeta.parent.

for (walk = prev; walk; walk = walk->next) {
    GstMeta *m = &walk->meta;
    if (m == meta) {


So how do I get the right pointer to remove the meta? Your help is very

Sent from:

More information about the gstreamer-devel mailing list