PipeWire  0.3.27
filter.c File Reference

Data Structures

struct  buffer
 
struct  queue
 
struct  data
 
struct  param
 
struct  port
 
struct  filter
 

Macros

#define NAME   "filter"
 
#define MAX_SAMPLES   8192
 
#define MAX_BUFFERS   64
 
#define MASK_BUFFERS   (MAX_BUFFERS-1)
 
#define MAX_PORTS   1024
 
#define BUFFER_FLAG_MAPPED   (1 << 0)
 
#define BUFFER_FLAG_QUEUED   (1 << 1)
 
#define BUFFER_FLAG_ADDED   (1 << 2)
 
#define PARAM_FLAG_LOCKED   (1 << 0)
 

Functions

SPA_EXPORT struct pw_filterpw_filter_new (struct pw_core *core, const char *name, struct pw_properties *props)
 
SPA_EXPORT 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)
 
SPA_EXPORT const char * pw_filter_state_as_string (enum pw_filter_state state)
 
SPA_EXPORT void pw_filter_destroy (struct pw_filter *filter)
 
SPA_EXPORT void pw_filter_add_listener (struct pw_filter *filter, struct spa_hook *listener, const struct pw_filter_events *events, void *data)
 
SPA_EXPORT enum pw_filter_state pw_filter_get_state (struct pw_filter *filter, const char **error)
 
SPA_EXPORT struct pw_core * pw_filter_get_core (struct pw_filter *filter)
 
SPA_EXPORT const char * pw_filter_get_name (struct pw_filter *filter)
 
SPA_EXPORT 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...
 
SPA_EXPORT 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...
 
SPA_EXPORT int pw_filter_connect (struct pw_filter *filter, enum pw_filter_flags flags, const struct spa_pod **params, uint32_t n_params)
 
SPA_EXPORT uint32_t pw_filter_get_node_id (struct pw_filter *filter)
 
SPA_EXPORT int pw_filter_disconnect (struct pw_filter *filter)
 
SPA_EXPORT 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...
 
SPA_EXPORT int pw_filter_remove_port (void *port_data)
 remove a port from the filter More...
 
SPA_EXPORT int pw_filter_set_error (struct pw_filter *filter, int res, const char *error,...)
 
SPA_EXPORT 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...
 
SPA_EXPORT int pw_filter_set_active (struct pw_filter *filter, bool active)
 
SPA_EXPORT int pw_filter_get_time (struct pw_filter *filter, struct pw_time *time)
 
SPA_EXPORT 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...
 
SPA_EXPORT int pw_filter_queue_buffer (void *port_data, struct pw_buffer *buffer)
 Submit a buffer for playback or recycle a buffer for capture. More...
 
SPA_EXPORT void * pw_filter_get_dsp_buffer (void *port_data, uint32_t n_samples)
 Get a data pointer to the buffer data. More...
 
SPA_EXPORT int pw_filter_flush (struct pw_filter *filter, bool drain)
 Flush a filter. More...
 

Macro Definition Documentation

◆ BUFFER_FLAG_ADDED

#define BUFFER_FLAG_ADDED   (1 << 2)

◆ BUFFER_FLAG_MAPPED

#define BUFFER_FLAG_MAPPED   (1 << 0)

◆ BUFFER_FLAG_QUEUED

#define BUFFER_FLAG_QUEUED   (1 << 1)

◆ MASK_BUFFERS

#define MASK_BUFFERS   (MAX_BUFFERS-1)

◆ MAX_BUFFERS

#define MAX_BUFFERS   64

◆ MAX_PORTS

#define MAX_PORTS   1024

◆ MAX_SAMPLES

#define MAX_SAMPLES   8192

◆ NAME

#define NAME   "filter"

◆ PARAM_FLAG_LOCKED

#define PARAM_FLAG_LOCKED   (1 << 0)

Function Documentation

◆ pw_filter_add_listener()

SPA_EXPORT 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()

SPA_EXPORT 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_connect()

SPA_EXPORT int pw_filter_connect ( struct pw_filter filter,
enum pw_filter_flags  flags,
const struct spa_pod **  params,
uint32_t  n_params 
)

◆ pw_filter_dequeue_buffer()

SPA_EXPORT 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_destroy()

SPA_EXPORT void pw_filter_destroy ( struct pw_filter filter)

◆ pw_filter_disconnect()

SPA_EXPORT int pw_filter_disconnect ( struct pw_filter filter)

◆ pw_filter_flush()

SPA_EXPORT 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()

SPA_EXPORT struct pw_core* pw_filter_get_core ( struct pw_filter filter)

◆ pw_filter_get_dsp_buffer()

SPA_EXPORT 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()

SPA_EXPORT const char* pw_filter_get_name ( struct pw_filter filter)

◆ pw_filter_get_node_id()

SPA_EXPORT uint32_t pw_filter_get_node_id ( struct pw_filter filter)

◆ pw_filter_get_properties()

SPA_EXPORT 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()

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

◆ pw_filter_get_time()

SPA_EXPORT int pw_filter_get_time ( struct pw_filter filter,
struct pw_time time 
)

◆ pw_filter_new()

SPA_EXPORT struct pw_filter* pw_filter_new ( struct pw_core *  core,
const char *  name,
struct pw_properties props 
)

◆ pw_filter_new_simple()

SPA_EXPORT 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()

SPA_EXPORT 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()

SPA_EXPORT 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_active()

SPA_EXPORT int pw_filter_set_active ( struct pw_filter filter,
bool  active 
)

References NAME, and pw_log::pw_log_debug.

◆ pw_filter_set_error()

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

References args, pw_proxy_error(), r, res, va_end(), and va_start().

◆ pw_filter_state_as_string()

SPA_EXPORT const char* pw_filter_state_as_string ( enum pw_filter_state  state)

◆ pw_filter_update_params()

SPA_EXPORT 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()

SPA_EXPORT 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.