How to add GstMeta to buffers in a pool?

Spruyt, Randy Randy.Spruyt at
Thu Jun 11 07:12:41 PDT 2015

Thanks Mohammed, adding the GST_META_FLAG_POOLED helps. However, if we append memory to Gst Buffers after they are allocated we see the same thing, the meta data disappears. Perhaps I am approaching this wrong and need to do the wrapping during the buffer allocation by overloading GstBufferPoolClass->alloc instead? 

i.e. here is what I am currently doing:

gst_buffer_pool_acquire_buffer( pool, &buf, NULL);
mem = gst_memory_new_wrapped( 0, dataBuf, dataBufSize, 0, dataBufSize, NULL, NULL );
gst_buffer_append_memory( buf, mem );

if I then add metadata, it does not show up the next time I acquire the buffer. The idea is that we have a block of memory from Intel MediaSDK created, we just want to wrap a GstBuffer around it, then add some meta data with additional information (i.e. YUV planes, RGB planes, etc). If I remove the gst_buffer_append_memory() the metadata shows up.


-----Original Message-----
From: gstreamer-devel [mailto:gstreamer-devel-bounces at] On Behalf Of Mohammed Sameer
Sent: Wednesday, June 10, 2015 7:10 PM
To: gstreamer-devel at
Subject: Re: How to add GstMeta to buffers in a pool?

On Wed, Jun 10, 2015 at 05:37:09PM +0000, Spruyt, Randy wrote:
>  When using a buffer pool, adding MetaData to an acquired buffer seems
>  work fine, but the next time I acquire the same buffer, the data is
>  gone. I suspect I may be using this incorrectly somehow?


>  void test()
>  {
>  GstBuffer* buf = NULL;
>  mfxFrameSurface1 someSurface;
>  IntelQuickSyncMeta* metaData = NULL;
>  GstBufferPool* pool = NULL;
>  GstStructure* config = NULL;
>  GstCaps* caps = NULL;
>  pool = gst_buffer_pool_new();
>  config = gst_buffer_pool_get_config( pool );
>  caps = gst_caps_from_string("video/x-raw");
>  gst_buffer_pool_config_set_params( config, caps, 100, 1, 1 );
>  if( gst_buffer_pool_set_config( pool, config ) )
>  {
>  if( gst_buffer_pool_set_active( pool, TRUE ) )
>  {
>  while( gst_buffer_pool_acquire_buffer( pool, &buf,
>  {
>  // first loop this is NULL which is fine,
>  2nd loop this should not be null, but it is
>  metaData =
>  gst_buffer_get_intel_quicksync_meta( buf );
>  if( !metaData )
>  {
>  // add some meta data,

Here you can set the GST_META_FLAG_POOLED flag:
and check the note in alloc_buffer()


GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
gstreamer-devel mailing list
gstreamer-devel at

More information about the gstreamer-devel mailing list