BufferPool

a GstBufferPool is an object that can be used to pre-allocate and recycle buffers of the same size and with the same properties.

A GstBufferPool is created with gst_buffer_pool_new().

After the buffer is created, it needs to be configured. gst_buffer_pool_get_config() get the current configuration structure from the pool. With gst_buffer_pool_config_set_params() and gst_buffer_pool_config_set_allocator() the bufferpool parameters and allocator can be configured. Other properties can be configured in the pool depending on the pool implementation.

A bufferpool can have extra options that can be enabled with gst_buffer_pool_config_add_option(). The available options can be retrieved with gst_buffer_pool_get_options(). Some options allow for additional configuration properties to be set.

After the configuration structure has been configured, gst_buffer_pool_set_config() updates the configuration in the pool. This can fail when the configuration structure is not accepted.

After the a pool has been configured, it can be activated with gst_buffer_pool_set_active(). This will preallocate the configured resources in the pool.

When the pool is active, gst_buffer_pool_acquire_buffer() can be used to retrieve a buffer from the pool.

Buffer allocated from a bufferpool will automatically be returned to the pool with gst_buffer_pool_release_buffer() when their refcount drops to 0.

The bufferpool can be deactivated again with gst_buffer_pool_set_active(). All further gst_buffer_pool_acquire_buffer() calls will return an error. When all buffers are returned to the pool they will be freed.

Use gst_object_unref() to release the reference to a bufferpool. If the refcount of the pool reaches 0, the pool will be freed.

Last reviewed on 2012-03-28 (0.11.3)

Constructors

this
this(GstBufferPool* gstBufferPool)

Sets our main struct and passes it to the parent class

this
this()

Creates a new GstBufferPool instance.

Members

Functions

acquireBuffer
GstFlowReturn acquireBuffer(Buffer buffer, GstBufferPoolAcquireParams* params)

Acquire a buffer from pool. buffer should point to a memory location that can hold a pointer to the new buffer. params can be NULL or contain optional parameters to influence the allocation.

getBufferPoolStruct
GstBufferPool* getBufferPoolStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getConfig
Structure getConfig()

Get a copy of the current configuration of the pool. This configuration can either be modified and used for the gst_buffer_pool_set_config() call or it must be freed after usage.

getOptions
string[] getOptions()

Get a NULL terminated array of string with supported bufferpool options for pool. An option would typically be enabled with gst_buffer_pool_config_add_option().

getStruct
void* getStruct()

the main Gtk struct as a void*

hasOption
int hasOption(string option)

Check if the bufferpool supports option.

isActive
int isActive()

Check if pool is active. A pool can be activated with the gst_buffer_pool_set_active() call.

releaseBuffer
void releaseBuffer(Buffer buffer)

Release buffer to pool. buffer should have previously been allocated from pool with gst_buffer_pool_acquire_buffer(). This function is usually called automatically when the last ref on buffer disappears.

setActive
int setActive(int active)

Control the active state of pool. When the pool is inactive, new calls to gst_buffer_pool_acquire_buffer() will return with GST_FLOW_FLUSHING. Activating the bufferpool will preallocate all resources in the pool based on the configuration of the pool. Deactivating will free the resources again when there are no outstanding buffers. When there are outstanding buffers, they will be freed as soon as they are all returned to the pool.

setConfig
int setConfig(Structure config)

Set the configuration of the pool. The pool must be inactive and all buffers allocated form this pool must be returned or else this function will do nothing and return FALSE. config is a GstStructure that contains the configuration parameters for the pool. A default and mandatory set of parameters can be configured with gst_buffer_pool_config_set_params(), gst_buffer_pool_config_set_allocator() and gst_buffer_pool_config_add_option(). If the parameters in config can not be set exactly, this function returns FALSE and will try to update as much state as possible. The new state can then be retrieved and refined with gst_buffer_pool_get_config(). This function takes ownership of config.

Static functions

configAddOption
void configAddOption(Structure config, string option)

Enabled the option in config. This will instruct the bufferpool to enable the specified option on the buffers that it allocates. The supported options by pool can be retrieved with gst_buffer_pool_get_options().

configGetAllocator
int configGetAllocator(Structure config, Allocator allocator, GstAllocationParams* params)

Get the allocator and params from config.

configGetOption
string configGetOption(Structure config, uint index)

Parse an available config and get the option at index of the options API array.

configGetParams
int configGetParams(Structure config, Caps caps, uint size, uint minBuffers, uint maxBuffers)

Get the configuration values from config.

configHasOption
int configHasOption(Structure config, string option)

Check if config contains option

configNOptions
uint configNOptions(Structure config)

Retrieve the number of values currently stored in the options array of the config structure.

configSetAllocator
void configSetAllocator(Structure config, Allocator allocator, GstAllocationParams* params)

Set the allocator and params on config. One of allocator and params can be NULL, but not both. When allocator is NULL, the default allocator of the pool will use the values in param to perform its allocation. When param is NULL, the pool will use the provided allocator with its default GstAllocationParams. A call to gst_buffer_pool_set_config() can update the allocator and params with the values that it is able to do. Some pools are, for example, not able to operate with different allocators or cannot allocate with the values specified in params. Use gst_buffer_pool_get_config() to get the currently used values.

configSetParams
void configSetParams(Structure config, Caps caps, uint size, uint minBuffers, uint maxBuffers)

Configure config with the given parameters.

Variables

gstBufferPool
GstBufferPool* gstBufferPool;

the main Gtk struct

Meta