PipeWire  0.3.27
filter.h File Reference

Go to the source code of this file.

Data Structures

struct  pw_filter_events
 Events for a filter. More...
 

Macros

#define PW_VERSION_FILTER_EVENTS   0
 

Enumerations

enum  pw_filter_state {
  PW_FILTER_STATE_ERROR = -1, PW_FILTER_STATE_UNCONNECTED = 0, PW_FILTER_STATE_CONNECTING = 1, PW_FILTER_STATE_PAUSED = 2,
  PW_FILTER_STATE_STREAMING = 3
}
 The state of a filter. More...
 
enum  pw_filter_flags { PW_FILTER_FLAG_NONE = 0, PW_FILTER_FLAG_INACTIVE = (1 << 0), PW_FILTER_FLAG_DRIVER = (1 << 1), PW_FILTER_FLAG_RT_PROCESS = (1 << 2) }
 Extra flags that can be used in pw_filter_connect() More...
 
enum  pw_filter_port_flags { PW_FILTER_PORT_FLAG_NONE = 0, PW_FILTER_PORT_FLAG_MAP_BUFFERS = (1 << 0), PW_FILTER_PORT_FLAG_ALLOC_BUFFERS = (1 << 1) }
 

Functions

struct pw_filterpw_filter_new_simple (struct pw_loop *loop, const char *name, struct pw_properties *props, const struct pw_filter_events *events, void *data)
 
void pw_filter_add_listener (struct pw_filter *filter, struct spa_hook *listener, const struct pw_filter_events *events, void *data)
 
enum pw_filter_state pw_filter_get_state (struct pw_filter *filter, const char **error)
 
const char * pw_filter_get_name (struct pw_filter *filter)
 
struct pw_core * pw_filter_get_core (struct pw_filter *filter)
 
void * pw_filter_add_port (struct pw_filter *filter, enum pw_direction direction, enum pw_filter_port_flags flags, size_t port_data_size, struct pw_properties *props, const struct spa_pod **params, uint32_t n_params)
 add a port to the filter, returns user data of port_data_size. More...
 
int pw_filter_remove_port (void *port_data)
 remove a port from the filter More...
 
const struct pw_propertiespw_filter_get_properties (struct pw_filter *filter, void *port_data)
 get properties, port_data of NULL will give global properties More...
 
int pw_filter_update_properties (struct pw_filter *filter, void *port_data, const struct spa_dict *dict)
 Update properties, use NULL port_data for global filter properties. More...
 
int pw_filter_set_error (struct pw_filter *filter, int res, const char *error,...) SPA_PRINTF_FUNC(3
 Set the filter in error state. More...
 
int int pw_filter_update_params (struct pw_filter *filter, void *port_data, const struct spa_pod **params, uint32_t n_params)
 Update params, use NULL port_data for global filter params. More...
 
struct pw_bufferpw_filter_dequeue_buffer (void *port_data)
 Get a buffer that can be filled for output ports or consumed for input ports. More...
 
int pw_filter_queue_buffer (void *port_data, struct pw_buffer *buffer)
 Submit a buffer for playback or recycle a buffer for capture. More...
 
void * pw_filter_get_dsp_buffer (void *port_data, uint32_t n_samples)
 Get a data pointer to the buffer data. More...
 
int pw_filter_flush (struct pw_filter *filter, bool drain)
 Flush a filter. More...
 

Macro Definition Documentation

◆ PW_VERSION_FILTER_EVENTS

#define PW_VERSION_FILTER_EVENTS   0

Enumeration Type Documentation

◆ pw_filter_flags

Extra flags that can be used in pw_filter_connect()

Enumerator
PW_FILTER_FLAG_NONE 

no flags

PW_FILTER_FLAG_INACTIVE 

start the filter inactive, pw_filter_set_active() needs to be called explicitly

PW_FILTER_FLAG_DRIVER 

be a driver

PW_FILTER_FLAG_RT_PROCESS 

call process from the realtime thread

◆ pw_filter_port_flags

Enumerator
PW_FILTER_PORT_FLAG_NONE 

no flags

PW_FILTER_PORT_FLAG_MAP_BUFFERS 

mmap the buffers except DmaBuf

PW_FILTER_PORT_FLAG_ALLOC_BUFFERS 

the application will allocate buffer memory.

In the add_buffer event, the data of the buffer should be set

◆ pw_filter_state

The state of a filter.

Enumerator
PW_FILTER_STATE_ERROR 

the stream is in error

PW_FILTER_STATE_UNCONNECTED 

unconnected

PW_FILTER_STATE_CONNECTING 

connection is in progress

PW_FILTER_STATE_PAUSED 

filter is connected and paused

PW_FILTER_STATE_STREAMING 

filter is streaming

Function Documentation

◆ pw_filter_add_listener()

void pw_filter_add_listener ( struct pw_filter filter,
struct spa_hook *  listener,
const struct pw_filter_events events,
void *  data 
)

◆ pw_filter_add_port()

void* pw_filter_add_port ( struct pw_filter filter,
enum pw_direction  direction,
enum pw_filter_port_flags  flags,
size_t  port_data_size,
struct pw_properties props,
const struct spa_pod **  params,
uint32_t  n_params 
)

add a port to the filter, returns user data of port_data_size.

Parameters
directionport direction
flagsport flags
port_data_sizeallocated and given to the user as port_data
propsport properties, ownership is taken
paramsan array of params. The params should ideally contain the supported formats
n_paramsnumber of elements in params

References port::props, pw_properties::pw_properties_new(), and res.

◆ pw_filter_dequeue_buffer()

struct pw_buffer* pw_filter_dequeue_buffer ( void *  port_data)

Get a buffer that can be filled for output ports or consumed for input ports.


References port::filter, res, and port::user_data.

Referenced by pw_filter_get_dsp_buffer().

◆ pw_filter_flush()

int pw_filter_flush ( struct pw_filter filter,
bool  drain 
)

Flush a filter.

When drain is true, the drained callback will be called when all data is played or recorded

References pw_loop_invoke.

◆ pw_filter_get_core()

struct pw_core* pw_filter_get_core ( struct pw_filter filter)

◆ pw_filter_get_dsp_buffer()

void* pw_filter_get_dsp_buffer ( void *  port_data,
uint32_t  n_samples 
)

Get a data pointer to the buffer data.

References pw_filter_dequeue_buffer(), and port::user_data.

◆ pw_filter_get_name()

const char* pw_filter_get_name ( struct pw_filter filter)

◆ pw_filter_get_properties()

const struct pw_properties* pw_filter_get_properties ( struct pw_filter filter,
void *  port_data 
)

get properties, port_data of NULL will give global properties

References port::props, and port::user_data.

◆ pw_filter_get_state()

enum pw_filter_state pw_filter_get_state ( struct pw_filter filter,
const char **  error 
)

◆ pw_filter_new_simple()

struct pw_filter* pw_filter_new_simple ( struct pw_loop loop,
const char *  name,
struct pw_properties props,
const struct pw_filter_events events,
void *  data 
)
Parameters
loopa pw_loop to use
namea filter media name
propsfilter properties, ownership is taken
eventsfilter events
datadata passed to events

References pw_context_new(), pw_properties::pw_properties_new(), and res.

◆ pw_filter_queue_buffer()

int pw_filter_queue_buffer ( void *  port_data,
struct pw_buffer buffer 
)

Submit a buffer for playback or recycle a buffer for capture.

References port::filter, buffer::id, NAME, pw_log::pw_log_trace, res, and port::user_data.

◆ pw_filter_remove_port()

int pw_filter_remove_port ( void *  port_data)

remove a port from the filter

Parameters
port_datadata associated with port

References port::direction, port::filter, port::id, port::link, and port::user_data.

Referenced by pw_filter_destroy().

◆ pw_filter_set_error()

int pw_filter_set_error ( struct pw_filter filter,
int  res,
const char *  error,
  ... 
)

Set the filter in error state.

Parameters
filtera pw_filter
resa result code
...an error message

◆ pw_filter_update_params()

int int pw_filter_update_params ( struct pw_filter filter,
void *  port_data,
const struct spa_pod **  params,
uint32_t  n_params 
)

Update params, use NULL port_data for global filter params.

Parameters
filtera pw_filter
port_datadata associated with port
paramsan array of params.
n_paramsnumber of elements in params

References NAME, port::port, pw_log::pw_log_debug, res, and port::user_data.

◆ pw_filter_update_properties()

int pw_filter_update_properties ( struct pw_filter filter,
void *  port_data,
const struct spa_dict dict 
)

Update properties, use NULL port_data for global filter properties.

References pw_properties::dict, port::info, port::props, pw_properties::pw_properties_update(), and port::user_data.