BufferPool

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

A gstreamer.BufferPool is created with Buffer.poolNew.

Once a pool is created, it needs to be configured. A call to Buffer.poolGetConfig returns the current configuration structure from the pool. With Buffer.poolConfigSetParams and Buffer.poolConfigSetAllocator 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 Buffer.poolConfigAddOption. The available options can be retrieved with Buffer.poolGetOptions. Some options allow for additional configuration properties to be set.

After the configuration structure has been configured, Buffer.poolSetConfig 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 Buffer.poolSetActive. This will preallocate the configured resources in the pool.

When the pool is active, Buffer.poolAcquireBuffer can be used to retrieve a buffer from the pool.

Buffers allocated from a bufferpool will automatically be returned to the pool with Buffer.poolReleaseBuffer when their refcount drops to 0.

The bufferpool can be deactivated again with Buffer.poolSetActive. All further Buffer.poolAcquireBuffer 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.

Constructors

this
this(GstBufferPool* gstBufferPool, bool ownedRef = false)

Sets our main struct and passes it to the parent class.

this
this()

Creates a new gstreamer.BufferPool instance.

Members

Functions

acquireBuffer
GstFlowReturn acquireBuffer(out 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.

getBufferPoolStruct
GstBufferPool* getBufferPoolStruct(bool transferOwnership = false)

Get the main Gtk struct

getConfig
Structure getConfig()

Get a copy of the current configuration of the pool. This configuration can either be modified and used for the Buffer.poolSetConfig 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 Buffer.poolConfigAddOption.

getStruct
void* getStruct()

the main Gtk struct as a void*

hasOption
bool hasOption(string option)

Check if the bufferpool supports option.

isActive
bool isActive()

Check if pool is active. A pool can be activated with the Buffer.poolSetActive call.

releaseBuffer
void releaseBuffer(Buffer buffer)

Release buffer to pool. buffer should have previously been allocated from pool with Buffer.poolAcquireBuffer.

setActive
bool setActive(bool active)

Control the active state of pool. When the pool is inactive, new calls to Buffer.poolAcquireBuffer will return with GST_FLOW_FLUSHING.

setConfig
bool setConfig(Structure config)

Set the configuration of the pool. If the pool is already configured, and the configuration haven't change, this function will return TRUE. If the pool is active, this method will return FALSE and active configuration will remain. Buffers allocated form this pool must be returned or else this function will do nothing and return FALSE.

setFlushing
void setFlushing(bool flushing)

Enable or disable the flushing state of a pool without freeing or allocating buffers.

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.

configGetAllocator
bool configGetAllocator(Structure config, ref Allocator allocator, out AllocationParams 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
bool configGetParams(Structure config, out Caps caps, out uint size, out uint minBuffers, out uint maxBuffers)

Get the configuration values from config.

configHasOption
bool 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, AllocationParams params)

Set the allocator and params on config.

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

Configure config with the given parameters.

configValidateParams
bool configValidateParams(Structure config, Caps caps, uint size, uint minBuffers, uint maxBuffers)

Validate that changes made to config are still valid in the context of the expected parameters. This function is a helper that can be used to validate changes made by a pool to a config when Buffer.poolSetConfig returns FALSE. This expects that caps haven't changed and that min_buffers aren't lower then what we initially expected. This does not check if options or allocator parameters are still valid, won't check if size have changed, since changing the size is valid to adapt padding.

getType
GType getType()

Variables

gstBufferPool
GstBufferPool* gstBufferPool;

the main Gtk struct

Inherited Members

From ObjectGst

gstObject
GstObject* gstObject;

the main Gtk struct

getObjectGstStruct
GstObject* getObjectGstStruct(bool transferOwnership = false)

Get the main Gtk struct

getStruct
void* getStruct()

the main Gtk struct as a void*

getType
GType getType()
checkUniqueness
bool checkUniqueness(ListG list, string name)

Checks to see if there is any object named name in list. This function does not do any locking of any kind. You might want to protect the provided list with the lock of the owner of the list. This function will lock each GstObject in the list to compare the name, so be careful when passing a list with a locked object.

defaultDeepNotify
void defaultDeepNotify(ObjectG object, ObjectGst orig, ParamSpec pspec, string[] excludedProps)

A default deep_notify signal callback for an object. The user data should contain a pointer to an array of strings that should be excluded from the notify. The default handler will print the new value of the property using g_print.

refSink
void* refSink(void* object)

Increase the reference count of object, and possibly remove the floating reference, if object has a floating reference.

replace
bool replace(ref ObjectGst oldobj, ObjectGst newobj)

Atomically modifies a pointer to point to a new object. The reference count of oldobj is decreased and the reference count of newobj is increased.

addControlBinding
bool addControlBinding(ControlBinding binding)

Attach the gstreamer.ControlBinding to the object. If there already was a gstreamer.ControlBinding for this property it will be replaced.

defaultError
void defaultError(ErrorG error, string dbg)

A default error function that uses g_printerr() to display the error message and the optional debug sting..

getControlBinding
ControlBinding getControlBinding(string propertyName)

Gets the corresponding gstreamer.ControlBinding for the property. This should be unreferenced again after use.

getControlRate
GstClockTime getControlRate()

Obtain the control-rate for this object. Audio processing gstreamer.Element objects will use this rate to sub-divide their processing loop and call gst_object_sync_values() inbetween. The length of the processing segment should be up to control-rate nanoseconds.

getGValueArray
bool getGValueArray(string propertyName, GstClockTime timestamp, GstClockTime interval, Value[] values)

Gets a number of gobject.Values for the given controlled property starting at the requested time. The array values need to hold enough space for n_values of gobject.Value

getName
string getName()

Returns a copy of the name of object. Caller should g_free() the return value after usage. For a nameless object, this returns NULL, which you can safely g_free() as well.

getParent
ObjectGst getParent()

Returns the parent of object. This function increases the refcount of the parent object so you should gst_object_unref() it after usage.

getPathString
string getPathString()

Generates a string describing the path of object in the object hierarchy. Only useful (or used) for debugging.

getValue
Value getValue(string propertyName, GstClockTime timestamp)

Gets the value for the given controlled property at the requested time.

getValueArray
bool getValueArray(string propertyName, GstClockTime timestamp, GstClockTime interval, uint nValues, void* values)

Gets a number of values for the given controlled property starting at the requested time. The array values need to hold enough space for n_values of the same type as the objects property's type.

hasActiveControlBindings
bool hasActiveControlBindings()

Check if the object has active controlled properties.

hasAncestor
bool hasAncestor(ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy. One can e.g. check if a gstreamer.Element is inside a gstreamer.Pipeline

hasAsAncestor
bool hasAsAncestor(ObjectGst ancestor)

Check if object has an ancestor ancestor somewhere up in the hierarchy. One can e.g. check if a gstreamer.Element is inside a gstreamer.Pipeline

hasAsParent
bool hasAsParent(ObjectGst parent)

Check if parent is the parent of object. E.g. a gstreamer.Element can check if it owns a given gstreamer.Pad

doref
ObjectGst doref()

Increments the reference count on object. This function does not take the lock on object because it relies on atomic refcounting.

removeControlBinding
bool removeControlBinding(ControlBinding binding)

Removes the corresponding gstreamer.ControlBinding If it was the last ref of the binding, it will be disposed.

setControlBindingDisabled
void setControlBindingDisabled(string propertyName, bool disabled)

This function is used to disable the control bindings on a property for some time, i.e. gst_object_sync_values() will do nothing for the property.

setControlBindingsDisabled
void setControlBindingsDisabled(bool disabled)

This function is used to disable all controlled properties of the object for some time, i.e. gst_object_sync_values() will do nothing.

setControlRate
void setControlRate(GstClockTime controlRate)

Change the control-rate for this object. Audio processing gstreamer.Element objects will use this rate to sub-divide their processing loop and call gst_object_sync_values() inbetween. The length of the processing segment should be up to control-rate nanoseconds.

setName
bool setName(string name)

Sets the name of object, or gives object a guaranteed unique name (if name is NULL). This function makes a copy of the provided name, so the caller retains ownership of the name it sent.

setParent
bool setParent(ObjectGst parent)

Sets the parent of object to parent. The object's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink()).

suggestNextSync
GstClockTime suggestNextSync()

Returns a suggestion for timestamps where buffers should be split to get best controller results.

syncValues
bool syncValues(GstClockTime timestamp)

Sets the properties of the object, according to the gstreamer.ControlSources that (maybe) handle them and for the given timestamp.

unparent
void unparent()

Clear the parent of object, removing the associated reference. This function decreases the refcount of object.

unref
void unref()

Decrements the reference count on object. If reference count hits zero, destroy object. This function does not take the lock on object as it relies on atomic refcounting.

addOnDeepNotify
gulong addOnDeepNotify(void delegate(ObjectGst, ParamSpec, ObjectGst) dlg, ConnectFlags connectFlags = cast(ConnectFlags)0)

The deep notify signal is used to be notified of property changes. It is typically attached to the toplevel bin to receive notifications from all the elements contained in that bin.

Meta