PipeWire  0.3.45
spa_node_methods Struct Reference

Node methods. More...

Data Fields

uint32_t version
 
int(* add_listener )(void *object, struct spa_hook *listener, const struct spa_node_events *events, void *data)
 Adds an event listener on node. More...
 
int(* set_callbacks )(void *object, const struct spa_node_callbacks *callbacks, void *data)
 Set callbacks to on node. More...
 
int(* sync )(void *object, int seq)
 Perform a sync operation. More...
 
int(* enum_params )(void *object, int seq, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter)
 Enumerate the parameters of a node. More...
 
int(* set_param )(void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)
 Set the configurable parameter in node. More...
 
int(* set_io )(void *object, uint32_t id, void *data, size_t size)
 Configure the given memory area with id on node. More...
 
int(* send_command )(void *object, const struct spa_command *command)
 Send a command to a node. More...
 
int(* add_port )(void *object, enum spa_direction direction, uint32_t port_id, const struct spa_dict *props)
 Make a new port with port_id. More...
 
int(* remove_port )(void *object, enum spa_direction direction, uint32_t port_id)
 Remove a port with port_id. More...
 
int(* port_enum_params )(void *object, int seq, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter)
 Enumerate all possible parameters of id on port_id of node that are compatible with filter. More...
 
int(* port_set_param )(void *object, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t flags, const struct spa_pod *param)
 Set a parameter on port_id of node. More...
 
int(* port_use_buffers )(void *object, enum spa_direction direction, uint32_t port_id, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers)
 Tell the port to use the given buffers. More...
 
int(* port_set_io )(void *object, enum spa_direction direction, uint32_t port_id, uint32_t id, void *data, size_t size)
 Configure the given memory area with id on port_id. More...
 
int(* port_reuse_buffer )(void *object, uint32_t port_id, uint32_t buffer_id)
 Tell an output port to reuse a buffer. More...
 
int(* process )(void *object)
 Process the node. More...
 

Detailed Description

Node methods.

Examples
export-sink.c, export-source.c, and local-v4l2.c.

Field Documentation

◆ version

uint32_t spa_node_methods::version

◆ add_listener

int(* spa_node_methods::add_listener) (void *object, struct spa_hook *listener, const struct spa_node_events *events, void *data)

Adds an event listener on node.

Setting the events will trigger the info event and a port_info event for each managed port on the new listener.

Parameters
nodea spa_node
listenera listener
eventsa struct spa_node_events
datadata passed as first argument in functions of events
Returns
0 on success < 0 errno on error

◆ set_callbacks

int(* spa_node_methods::set_callbacks) (void *object, const struct spa_node_callbacks *callbacks, void *data)

Set callbacks to on node.

if callbacks is NULL, the current callbacks are removed.

This function must be called from the main thread.

All callbacks are called from the data thread.

Parameters
nodea spa_node
callbackscallbacks to set
Returns
0 on success -EINVAL when node is NULL

◆ sync

int(* spa_node_methods::sync) (void *object, int seq)

Perform a sync operation.

This method will emit the result event with the given sequence number synchronously or with the returned async return value asynchronously.

Because all methods are serialized in the node, this can be used to wait for completion of all previous method calls.

Parameters
seqa sequence number
Returns
0 on success -EINVAL when node is NULL an async result

◆ enum_params

int(* spa_node_methods::enum_params) (void *object, int seq, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter)

Enumerate the parameters of a node.

Parameters are identified with an id. Some parameters can have multiple values, see the documentation of the parameter id.

Parameters can be filtered by passing a non-NULL filter.

The function will emit the result event up to max times with the result value. The seq in the result will either be the seq number when executed synchronously or the async return value of this function when executed asynchronously.

This function must be called from the main thread.

Parameters
nodea Node
seqa sequence number to pass to the result event when this method is executed synchronously.
idthe param id to enumerate
startthe index of enumeration, pass 0 for the first item
maxthe maximum number of parameters to enumerate
filterand optional filter to use
Returns
0 when no more items can be iterated. -EINVAL when invalid arguments are given -ENOENT the parameter id is unknown -ENOTSUP when there are no parameters implemented on node an async return value when the result event will be emitted later.

◆ set_param

int(* spa_node_methods::set_param) (void *object, uint32_t id, uint32_t flags, const struct spa_pod *param)

Set the configurable parameter in node.

Usually, param will be obtained from enum_params and then modified but it is also possible to set another spa_pod as long as its keys and types match a supported object.

Objects with property keys that are not known are ignored.

This function must be called from the main thread.

Parameters
nodea Node
idthe parameter id to configure
flagsadditional flags
paramthe parameter to configure
Returns
0 on success -EINVAL when node is NULL -ENOTSUP when there are no parameters implemented on node -ENOENT the parameter is unknown

◆ set_io

int(* spa_node_methods::set_io) (void *object, uint32_t id, void *data, size_t size)

Configure the given memory area with id on node.

This structure is allocated by the host and is used to exchange data and parameters with the node.

Setting an io of NULL will disable the node io.

This function must be called from the main thread.

Parameters
idthe id of the io area, the available ids can be enumerated with the node parameters.
dataa io area memory
sizethe size of data
Returns
0 on success -EINVAL when invalid input is given -ENOENT when id is unknown -ENOSPC when size is too small

◆ send_command

int(* spa_node_methods::send_command) (void *object, const struct spa_command *command)

Send a command to a node.

Upon completion, a command might change the state of a node.

This function must be called from the main thread.

Parameters
nodea spa_node
commanda spa_command
Returns
0 on success -EINVAL when node or command is NULL -ENOTSUP when this node can't process commands -EINVAL command is an invalid command

◆ add_port

int(* spa_node_methods::add_port) (void *object, enum spa_direction direction, uint32_t port_id, const struct spa_dict *props)

Make a new port with port_id.

The caller should use the lowest unused port id for the given direction.

Port ids should be between 0 and max_ports as obtained from the info event.

This function must be called from the main thread.

Parameters
nodea spa_node
directiona enum spa_direction
port_idan unused port id
propsextra properties
Returns
0 on success -EINVAL when node is NULL

◆ remove_port

int(* spa_node_methods::remove_port) (void *object, enum spa_direction direction, uint32_t port_id)

Remove a port with port_id.

Parameters
nodea spa_node
directiona enum spa_direction
port_ida port id
Returns
0 on success -EINVAL when node is NULL or when port_id is unknown or when the port can't be removed.

◆ port_enum_params

int(* spa_node_methods::port_enum_params) (void *object, int seq, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t start, uint32_t max, const struct spa_pod *filter)

Enumerate all possible parameters of id on port_id of node that are compatible with filter.

The result parameters can be queried and modified and ultimately be used to call port_set_param.

The function will emit the result event up to max times with the result value. The seq in the result event will either be the seq number when executed synchronously or the async return value of this function when executed asynchronously.

This function must be called from the main thread.

Parameters
nodea spa_node
seqa sequence number to pass to the result event when this method is executed synchronously.
directionan spa_direction
port_idthe port to query
idthe parameter id to query
startthe first index to query, 0 to get the first item
maxthe maximum number of params to query
filtera parameter filter or NULL for no filter
Returns
0 when no more items can be iterated. -EINVAL when invalid parameters are given -ENOENT when id is unknown an async return value when the result event will be emitted later.

◆ port_set_param

int(* spa_node_methods::port_set_param) (void *object, enum spa_direction direction, uint32_t port_id, uint32_t id, uint32_t flags, const struct spa_pod *param)

Set a parameter on port_id of node.

When param is NULL, the parameter will be unset.

This function must be called from the main thread.

Parameters
nodea struct Node
directiona enum spa_direction
port_idthe port to configure
idthe parameter id to set
flagsoptional flags
parama struct POD with the parameter to set
Returns
0 on success 1 on success, the value of param might have been changed depending on flags and the final value can be found by doing port_enum_params. -EINVAL when node is NULL or invalid arguments are given -ESRCH when one of the mandatory param properties is not specified and SPA_NODE_PARAM_FLAG_FIXATE was not set in flags. -ESRCH when the type or size of a property is not correct. -ENOENT when the param id is not found

◆ port_use_buffers

int(* spa_node_methods::port_use_buffers) (void *object, enum spa_direction direction, uint32_t port_id, uint32_t flags, struct spa_buffer **buffers, uint32_t n_buffers)

Tell the port to use the given buffers.

When flags contains SPA_NODE_BUFFERS_FLAG_ALLOC, the data in the buffers should point to an array of at least 1 data entry with the desired supported type that will be filled by this function.

The port should also have a spa_io_buffers io area configured to exchange the buffers with the port.

For an input port, all the buffers will remain dequeued. Once a buffer has been queued on a port in the spa_io_buffers, it should not be reused until the reuse_buffer callback is notified or when the buffer has been returned in the spa_io_buffers of the port.

For output ports, all buffers will be queued in the port. When process returns SPA_STATUS_HAVE_DATA, buffers are available in one or more of the spa_io_buffers areas.

When a buffer can be reused, port_reuse_buffer() should be called or the buffer_id should be placed in the spa_io_buffers area before calling process.

Passing NULL as buffers will remove the reference that the port has on the buffers.

When this function returns async, use the spa_node_sync operation to wait for completion.

This function must be called from the main thread.

Parameters
objectan object implementing the interface
directiona port direction
port_ida port id
flagsextra flags
buffersan array of buffer pointers
n_buffersnumber of elements in buffers
Returns
0 on success

◆ port_set_io

int(* spa_node_methods::port_set_io) (void *object, enum spa_direction direction, uint32_t port_id, uint32_t id, void *data, size_t size)

Configure the given memory area with id on port_id.

This structure is allocated by the host and is used to exchange data and parameters with the port.

Setting an io of NULL will disable the port io.

This function must be called from the main thread.

Parameters
directiona spa_direction
port_ida port id
idthe id of the io area, the available ids can be enumerated with the port parameters.
dataa io area memory
sizethe size of data
Returns
0 on success -EINVAL when invalid input is given -ENOENT when id is unknown -ENOSPC when size is too small

◆ port_reuse_buffer

int(* spa_node_methods::port_reuse_buffer) (void *object, uint32_t port_id, uint32_t buffer_id)

Tell an output port to reuse a buffer.

This function must be called from the data thread.

Parameters
nodea spa_node
port_ida port id
buffer_ida buffer id to reuse
Returns
0 on success -EINVAL when node is NULL

◆ process

int(* spa_node_methods::process) (void *object)

Process the node.

This function must be called from the data thread.

Output io areas with SPA_STATUS_NEED_DATA will recycle the buffers if any.

Input areas with SPA_STATUS_HAVE_DATA are consumed if possible and the status is set to SPA_STATUS_NEED_DATA or SPA_STATUS_OK.

When the node has new output buffers, the SPA_STATUS_HAVE_DATA bit will be set.

When the node can accept new input in the next cycle, the SPA_STATUS_NEED_DATA bit will be set.


The documentation for this struct was generated from the following file: