GstBufferPool

Name

GstBufferPool -- Create buffers from a pool

Synopsis


#include <gst/gst.h>


struct      GstBufferPool;
GstBuffer*  (*GstBufferPoolCreateFunction)  (GstBufferPool *pool,
                                             gpointer user_data);
void        (*GstBufferPoolDestroyFunction) (GstBufferPool *pool,
                                             GstBuffer *buffer,
                                             gpointer user_data);
GstBufferPool* gst_buffer_pool_new          (void);
GstBuffer*  gst_buffer_pool_new_buffer      (GstBufferPool *pool);
void        gst_buffer_pool_destroy_buffer  (GstBufferPool *pool,
                                             GstBuffer *buffer);
void        gst_buffer_pool_set_create_function
                                            (GstBufferPool *pool,
                                             GstBufferPoolCreateFunction create,
                                             gpointer user_data);
void        gst_buffer_pool_set_destroy_function
                                            (GstBufferPool *pool,
                                             GstBufferPoolDestroyFunction destroy,
                                             gpointer user_data);
void        gst_buffer_pool_destroy         (GstBufferPool *pool);

Description

A bufferpool is used to create buffers in an efficient way. En element can maintain a bufferpool with a fixed number of buffers. This will reduce the g_malloc and g_free overhead.

A bufferpool can also be used to implement direct access. A bufferpool can be sent from one element to another so that the latter can directly write into the memory of the element that maintains the bufferpool. This can greatly reduce the number of memcpy operations.

A bufferpool is created with gst_buffer_pool_new(). You'll have to set the buffer allocation and destroy function afterwards with gst_buffer_pool_set_create_function() and gst_buffer_pool_set_destroy_function().

To create a buffer from the bufferpool use gst_buffer_pool_new_buffer(), which is functionally equivalent to gst_buffer_new_from_pool().

When the buffer is unreffed and has reached a refcount of 0, the bufferpools destroy function is called with the buffer as an argument.

A bufferpool can store private data in the buffer it creates with the GST_BUFFER_POOL_PRIVATE() macro. To check it a buffer was made by a specific bufferpool, use the GST_BUFFER_BUFFERPOOL() macro to get it's bufferpool.

Destroy the bufferpool with gst_buffer_pool_destroy().

A bufferpool can be requested from a pad with the gst_pad_get_bufferpool() function.

Details

struct GstBufferPool

struct GstBufferPool {
  /* will be called when a new buffer is to be created */
  GstBufferPoolCreateFunction new_buffer;
  /* user data to pass with the new_buffer function */
  gpointer new_user_data;

  gpointer destroy_user_data;
  GstBufferPoolDestroyFunction destroy_buffer;
};


GstBufferPoolCreateFunction ()

GstBuffer*  (*GstBufferPoolCreateFunction)  (GstBufferPool *pool,
                                             gpointer user_data);

The function called when a buffer has to be created for this pool.

pool :the pool from which to create the buffer
user_data :any user data
Returns :a new buffer from the pool


GstBufferPoolDestroyFunction ()

void        (*GstBufferPoolDestroyFunction) (GstBufferPool *pool,
                                             GstBuffer *buffer,
                                             gpointer user_data);

This function will be called when the given buffer has to be returned to the pool.

pool :the pool to return the buffer to
buffer :the buffer to return
user_data :any user data


gst_buffer_pool_new ()

GstBufferPool* gst_buffer_pool_new          (void);

Create a new buffer pool.

Returns : new buffer pool


gst_buffer_pool_new_buffer ()

GstBuffer*  gst_buffer_pool_new_buffer      (GstBufferPool *pool);

Uses the given pool to create a new buffer.

pool : the pool to create the buffer from
Returns : The new buffer


gst_buffer_pool_destroy_buffer ()

void        gst_buffer_pool_destroy_buffer  (GstBufferPool *pool,
                                             GstBuffer *buffer);

Gives a buffer back to the given pool.

pool : the pool to return the buffer to
buffer : the buffer to return to the pool


gst_buffer_pool_set_create_function ()

void        gst_buffer_pool_set_create_function
                                            (GstBufferPool *pool,
                                             GstBufferPoolCreateFunction create,
                                             gpointer user_data);

Sets the function that will be called when a buffer is created from this pool.

pool : the pool to set the create function for
create : the create function
user_data : any user data to be passed in the create function


gst_buffer_pool_set_destroy_function ()

void        gst_buffer_pool_set_destroy_function
                                            (GstBufferPool *pool,
                                             GstBufferPoolDestroyFunction destroy,
                                             gpointer user_data);

Sets the function that will be called when a buffer is destroyed from this pool.

pool : the pool to set the destroy function for
destroy : the destroy function
user_data : any user data to be passed in the create function


gst_buffer_pool_destroy ()

void        gst_buffer_pool_destroy         (GstBufferPool *pool);

Frees the memory for this bufferpool.

pool : the pool to destroy

See Also

GstBuffer, GstPad