Go to the documentation of this file.
25 #ifndef PIPEWIRE_STREAM_H
26 #define PIPEWIRE_STREAM_H
152 #include <spa/buffer/buffer.h>
153 #include <spa/param/param.h>
201 #define PW_VERSION_STREAM_EVENTS 0
277 struct spa_hook *listener,
303 const struct spa_pod **params,
319 const char *error, ... ) SPA_PRINTF_FUNC(3, 4);
329 const struct spa_pod **params,
parameters to map a memory range
Definition: mem.h:175
static uint32_t int int res
Definition: core.h:326
void * user_data
user data attached to the buffer
Definition: stream.h:166
void(* param_changed)(void *data, uint32_t id, const struct spa_pod *param)
when a parameter changed
Definition: stream.h:215
uint32_t max_values
max values that can be set on this control
Definition: stream.h:179
uint32_t flags
extra flags
Definition: properties.h:47
uint32_t clock_id
Definition: stream.c:135
static uint32_t id
Definition: core.h:325
uint32_t n_params
number of items in params
Definition: node.h:79
SPA_EXPORT int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer)
Submit a buffer for playback or recycle a buffer for capture.
Definition: stream.c:1845
#define BUFFER_FLAG_MAPPED
Definition: stream.c:55
#define PW_KEY_FORMAT_DSP
format related properties
Definition: keys.h:264
struct pw_stream * pw_stream_new(struct pw_core *core, const char *name, struct pw_properties *props)
Create a new unconneced pw_stream.
Definition: stream.c:1191
#define pw_log_error(...)
unsigned int allow_mlock
Definition: stream.c:141
int pw_proxy_error(struct pw_proxy *proxy, int res, const char *error)
Generate an error for a proxy.
Definition: proxy.c:341
SPA_EXPORT void pw_stream_add_listener(struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data)
Definition: stream.c:1321
struct spa_param_info * params
parameters
Definition: node.h:78
#define PW_KEY_STREAM_IS_LIVE
Stream properties.
Definition: keys.h:224
enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error)
Definition: stream.c:1330
void(* destroy)(void *data)
Definition: stream.h:204
struct spa_hook stream_listener
Definition: stream.c:70
struct queue queued
Definition: stream.c:129
#define PW_TYPE_INTERFACE_Node
Definition: node.h:42
@ PW_STREAM_FLAG_DRIVER
be a driver
Definition: stream.h:245
const SPA_EXPORT char * pw_stream_get_name(struct pw_stream *stream)
Definition: stream.c:1338
const char * pw_stream_get_name(struct pw_stream *stream)
Definition: stream.c:1338
const struct pw_properties * pw_stream_get_properties(struct pw_stream *stream)
Definition: stream.c:1344
unsigned int drained
Definition: stream.c:140
SPA_EXPORT int pw_stream_set_control(struct pw_stream *stream, uint32_t id, uint32_t n_values, float *values,...)
Set control values.
Definition: stream.c:1705
void(* remove_buffer)(void *data, struct pw_buffer *buffer)
when a buffer was destroyed for this stream
Definition: stream.h:220
SPA_EXPORT int pw_impl_node_set_param(struct pw_impl_node *node, uint32_t id, uint32_t flags, const struct spa_pod *param)
Definition: impl-node.c:1781
int pw_core_disconnect(struct pw_core *core)
disconnect and destroy a core
Definition: core.c:492
void(* add_buffer)(void *data, struct pw_buffer *buffer)
when a new buffer was created for this stream
Definition: stream.h:218
unsigned int disconnect_core
Definition: stream.c:138
@ PW_STREAM_FLAG_EXCLUSIVE
require exclusive access to the device
Definition: stream.h:250
int pw_stream_set_active(struct pw_stream *stream, bool active)
Activate or deactivate the stream.
Definition: stream.c:1771
void pw_context_destroy(struct pw_context *context)
destroy a context object, all resources except the main_loop will be destroyed
SPA_EXPORT void pw_impl_node_destroy(struct pw_impl_node *node)
Destroy a node.
Definition: impl-node.c:1627
#define PW_KEY_NODE_AUTOCONNECT
node wants to be automatically connected to a compatible node
Definition: keys.h:136
#define pw_direction
Definition: port.h:47
A time structure.
Definition: stream.h:183
SPA_EXPORT void pw_proxy_destroy(struct pw_proxy *proxy)
Destroy a proxy object.
Definition: proxy.c:232
Proxy events, use pw_proxy_add_listener.
Definition: proxy.h:106
struct spa_node impl_node
Definition: stream.c:105
void(* drained)(void *data)
The stream is drained.
Definition: stream.h:229
uint32_t ids[MAX_BUFFERS]
Definition: filter.c:65
static uint32_t int int const char int r
Definition: core.h:338
uint32_t media_subtype
Definition: stream.c:123
uint32_t id
Definition: filter.c:77
unsigned int disconnecting
Definition: stream.c:137
int64_t delay
delay to device, add to ticks to get the time of the device.
Definition: stream.h:188
struct spa_list param_list
Definition: stream.c:119
void(* io_changed)(void *data, uint32_t id, void *area, uint32_t size)
when io changed on the stream.
Definition: stream.h:213
@ PW_STREAM_STATE_PAUSED
paused
Definition: stream.h:160
int pw_impl_node_set_active(struct pw_impl_node *node, bool active)
Set a node active.
Definition: impl-node.c:1980
SPA_EXPORT int pw_stream_set_error(struct pw_stream *stream, int res, const char *error,...)
Definition: stream.c:1664
struct spa_io_position * position
Definition: stream.c:110
#define PW_DIRECTION_INPUT
Definition: port.h:48
int pw_impl_node_set_implementation(struct pw_impl_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: impl-node.c:1581
struct spa_port_info port_info
Definition: stream.c:117
struct pw_impl_node * pw_context_create_node(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Create a new node.
Definition: impl-node.c:1058
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
#define PW_KEY_NODE_LATENCY
the requested latency of the node as a fraction.
Definition: keys.h:140
uint64_t ticks
the ticks at now.
Definition: stream.h:186
uintptr_t seq
Definition: stream.c:132
enum spa_direction direction
Definition: stream.c:100
const char * path
Definition: stream.c:95
SPA_EXPORT struct pw_core * pw_stream_get_core(struct pw_stream *stream)
Definition: stream.c:1367
unsigned int draining
Definition: stream.c:139
struct spa_hook_list hooks
Definition: stream.c:107
struct spa_pod * param
Definition: filter.c:81
#define pw_log(lev,...)
Definition: log.h:76
#define PW_VERSION_PROXY_EVENTS
Definition: proxy.h:107
void pw_impl_node_add_listener(struct pw_impl_node *node, struct spa_hook *listener, const struct pw_impl_node_events *events, void *data)
Add an event listener.
Definition: impl-node.c:1610
@ PW_STREAM_STATE_ERROR
the stream is in error
Definition: stream.h:157
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:433
#define NAME
Definition: stream.c:45
struct pw_stream_control control
Definition: stream.c:86
uint64_t size
This field is set by the user and the sum of all queued buffer is returned in the time info.
Definition: stream.h:167
int int pw_stream_update_params(struct pw_stream *stream, const struct spa_pod **params, uint32_t n_params)
Complete the negotiation process with result code res.
Definition: stream.c:1688
enum pw_stream_flags flags
Definition: stream.c:101
buffer[1023]
Definition: core.h:330
#define BUFFER_FLAG_QUEUED
Definition: stream.c:56
#define PW_KEY_MEDIA_CLASS
class Ex: "Video/Source"
Definition: keys.h:247
uint32_t n_values
number of values in array
Definition: stream.h:178
struct spa_io_buffers * io
Definition: stream.c:111
@ PW_STREAM_FLAG_ALLOC_BUFFERS
the application will allocate buffer memory.
Definition: stream.h:254
struct data data
Definition: stream.c:131
SPA_EXPORT const struct pw_stream_control * pw_stream_get_control(struct pw_stream *stream, uint32_t id)
Definition: stream.c:1757
#define PW_KEY_NODE_EXCLUSIVE
node wants exclusive access to resources
Definition: keys.h:135
int64_t now
the monotonic time in nanoseconds
Definition: stream.h:184
uint32_t container
Definition: stream.c:84
unsigned int emitted
Definition: stream.c:88
static uint32_t int int const char * message
Definition: core.h:326
#define PARAM_FLAG_LOCKED
Definition: stream.c:75
uint32_t id
Definition: stream.c:82
#define PW_VERSION_IMPL_NODE_EVENTS
Definition: impl-node.h:54
#define pw_log_debug(...)
struct spa_pod * info
Definition: stream.c:87
uint32_t version
Definition: stream.h:202
struct spa_list link
Definition: stream.c:85
void(* control_info)(void *data, uint32_t id, const struct pw_stream_control *control)
Notify information about a control.
Definition: stream.h:210
SPA_EXPORT int pw_stream_flush(struct pw_stream *stream, bool drain)
Flush a stream.
Definition: stream.c:1890
#define PW_KEY_APP_PROCESS_BINARY
binary name
Definition: keys.h:105
struct pw_impl_node * node
Definition: stream.c:103
SPA_EXPORT int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:263
SPA_EXPORT const struct pw_properties * pw_stream_get_properties(struct pw_stream *stream)
Definition: stream.c:1344
Node events, listen to them with pw_impl_node_add_listener.
Definition: impl-node.h:53
#define pw_core_add_listener(c,...)
Definition: core.h:316
#define PW_KEY_NODE_DONT_RECONNECT
don't reconnect this node
Definition: keys.h:142
struct pw_proxy * pw_core_export(struct pw_core *core, const char *type, const struct spa_dict *props, void *object, size_t user_data_size)
Export an object into the PipeWire instance associated with core.
Definition: core.c:277
SPA_EXPORT struct pw_stream * pw_stream_new_simple(struct pw_loop *loop, const char *name, struct pw_properties *props, const struct pw_stream_events *events, void *data)
Definition: stream.c:1213
@ PW_STREAM_FLAG_AUTOCONNECT
try to automatically connect this stream
Definition: stream.h:239
#define MAX_BUFFERS
Definition: stream.c:47
#define PW_NODE_CHANGE_MASK_PARAMS
Definition: node.h:70
uint32_t type
Definition: stream.c:83
void * pw_impl_factory_create_object(struct pw_impl_factory *factory, struct pw_resource *resource, const char *type, uint32_t version, struct pw_properties *properties, uint32_t new_id)
Definition: impl-factory.c:261
#define PW_KEY_NODE_NAME
node name
Definition: keys.h:124
@ PW_STREAM_FLAG_MAP_BUFFERS
mmap the buffers
Definition: stream.h:244
const SPA_EXPORT char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:456
static uint32_t int int const char va_list args
Definition: core.h:327
#define PW_VERSION_CORE_EVENTS
Definition: core.h:106
SPA_EXPORT struct pw_buffer * pw_stream_dequeue_buffer(struct pw_stream *stream)
Get a buffer that can be filled for playback streams or consumed for capture streams.
Definition: stream.c:1827
#define MASK_BUFFERS
Definition: stream.c:49
#define PW_KEY_MEDIA_NAME
media name.
Definition: keys.h:248
struct pw_context * pw_context_new(struct pw_loop *main_loop, struct pw_properties *props, size_t user_data_size)
Make a new context object for a given main_loop.
struct buffer buffers[MAX_BUFFERS]
Definition: stream.c:125
int pw_stream_set_error(struct pw_stream *stream, int res, const char *error,...) SPA_PRINTF_FUNC(3
Set the stream in error state.
struct spa_hook context_listener
Definition: stream.c:98
struct pw_time time
Definition: stream.c:133
float values[64]
Definition: stream.c:89
int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer)
Submit a buffer for playback or recycle a buffer for capture.
Definition: stream.c:1845
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:205
float * values
array of values
Definition: stream.h:177
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:400
struct spa_node_methods node_methods
Definition: stream.c:106
@ PW_STREAM_FLAG_RT_PROCESS
call process from the realtime thread.
Definition: stream.h:246
@ PW_STREAM_STATE_STREAMING
streaming
Definition: stream.h:161
struct pw_properties * port_props
Definition: stream.c:118
#define PW_KEY_MEDIA_TYPE
Media.
Definition: keys.h:239
struct pw_stream this
Definition: stream.c:93
const char * pw_stream_state_as_string(enum pw_stream_state state)
Convert a stream state to a readable string.
Definition: stream.c:1258
#define pw_log_trace(...)
uint32_t flags
Definition: filter.c:79
SPA_EXPORT struct pw_impl_factory * pw_context_find_factory(struct pw_context *context, const char *name)
Find a factory by name.
Definition: impl-factory.c:287
pw_stream_flags
Definition: stream.h:237
void pw_proxy_add_listener(struct pw_proxy *proxy, struct spa_hook *listener, const struct pw_proxy_events *events, void *data)
Add an event listener to proxy.
Definition: proxy.c:197
uint32_t media_type
Definition: stream.c:122
struct pw_context * context
Definition: stream.c:97
int pw_stream_disconnect(struct pw_stream *stream)
Disconnect stream.
Definition: stream.c:1630
uint32_t id
Definition: filter.c:57
uint32_t n_buffers
Definition: stream.c:126
struct pw_buffer * pw_stream_dequeue_buffer(struct pw_stream *stream)
Get a buffer that can be filled for playback streams or consumed for capture streams.
Definition: stream.c:1827
uint64_t base_pos
Definition: stream.c:134
@ PW_STREAM_FLAG_INACTIVE
start the stream inactive, pw_stream_set_active() needs to be called explicitly
Definition: stream.h:241
int pw_impl_node_update_properties(struct pw_impl_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: impl-node.c:1222
void(* process)(void *data)
when a buffer can be queued (for playback streams) or dequeued (for capture streams).
Definition: stream.h:226
float max
max value
Definition: stream.h:176
struct spa_param_info params[5]
Definition: stream.c:120
struct spa_buffer * buffer
the spa buffer
Definition: stream.h:165
struct pw_core * pw_stream_get_core(struct pw_stream *stream)
Definition: stream.c:1367
#define PW_KEY_NODE_DRIVER
node can drive the graph
Definition: keys.h:145
void(* state_changed)(void *data, enum pw_stream_state old, enum pw_stream_state state, const char *error)
when the stream state changes
Definition: stream.h:206
struct pw_buffer this
Definition: filter.c:56
float def
default value
Definition: stream.h:174
struct pw_control this
Definition: control.c:34
#define PW_KEY_APP_NAME
application keys
Definition: keys.h:94
struct spa_ringbuffer ring
Definition: filter.c:66
int pw_impl_node_for_each_param(struct pw_impl_node *node, int seq, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, int(*callback)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: impl-node.c:1746
int pw_stream_flush(struct pw_stream *stream, bool drain)
Flush a stream.
Definition: stream.c:1890
void pw_stream_destroy(struct pw_stream *stream)
Destroy a stream.
Definition: stream.c:1276
@ PW_STREAM_FLAG_DONT_RECONNECT
don't try to reconnect this stream when the sink/source is removed
Definition: stream.h:252
#define BUFFER_FLAG_ADDED
Definition: stream.c:57
int pw_stream_set_control(struct pw_stream *stream, uint32_t id, uint32_t n_values, float *values,...)
Set control values.
Definition: stream.c:1705
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:98
@ PW_STREAM_FLAG_NONE
no flags
Definition: stream.h:238
struct spa_list link
Definition: filter.c:80
pw_stream_state
Definition: stream.h:156
SPA_EXPORT int pw_stream_update_properties(struct pw_stream *stream, const struct spa_dict *dict)
Definition: stream.c:1350
static uint32_t int seq
Definition: core.h:325
PipeWire stream object class.
uint32_t pw_stream_get_node_id(struct pw_stream *stream)
Get the node ID of the stream.
Definition: stream.c:1624
SPA_EXPORT enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error)
Definition: stream.c:1330
#define PW_ID_CORE
Definition: core.h:49
#define PW_ID_ANY
Definition: core.h:52
@ PW_STREAM_FLAG_NO_CONVERT
don't convert format
Definition: stream.h:249
struct queue dequeued
Definition: stream.c:128
@ PW_STREAM_STATE_CONNECTING
connection is in progress
Definition: stream.h:159
uint32_t change_mask_all
Definition: stream.c:116
#define pw_loop_invoke(l,...)
Definition: loop.h:57
unsigned int process_rt
Definition: stream.c:142
void pw_stream_add_listener(struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data)
Definition: stream.c:1321
#define PW_KEY_NODE_TARGET
node wants to be connected to the target node/session
Definition: keys.h:138
struct spa_callbacks callbacks
Definition: stream.c:108
PipeWire factory interface.
int pw_stream_connect(struct pw_stream *stream, enum pw_direction direction, uint32_t target_id, enum pw_stream_flags flags, const struct spa_pod **params, uint32_t n_params)
Connect a stream for input or output on port_path.
Definition: stream.c:1439
uint64_t change_mask
bitfield of changed fields since last call
Definition: node.h:72
int pw_stream_update_properties(struct pw_stream *stream, const struct spa_dict *dict)
Definition: stream.c:1350
#define PW_KEY_STREAM_MONITOR
Indicates that the stream is monitoring and might select a less accurate but faster conversion algori...
Definition: keys.h:227
uint64_t incount
Definition: filter.c:67
SPA_EXPORT struct pw_core * pw_context_connect(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: core.c:405
The node information.
Definition: node.h:62
uint32_t flags
Definition: filter.c:61
struct pw_stream * pw_stream_new_simple(struct pw_loop *loop, const char *name, struct pw_properties *props, const struct pw_stream_events *events, void *data)
Definition: stream.c:1213
struct spa_fraction rate
the rate of ticks and delay
Definition: stream.h:185
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
Query the time on the stream.
Definition: stream.c:1781
struct pw_context * context
Definition: filter.c:72
#define PW_VERSION_NODE
Definition: node.h:44
@ PW_STREAM_STATE_UNCONNECTED
unconnected
Definition: stream.h:158
float min
min value
Definition: stream.h:175
A collection of key/value pairs.
Definition: properties.h:45
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:335
uint32_t flags
extra flags (unused)
Definition: stream.h:173
uint64_t queued
data queued in the stream, this is the sum of the size fields in the pw_buffer that are currently que...
Definition: stream.h:191
Core events.
Definition: core.h:105
uint64_t outcount
Definition: filter.c:68
const char * name
name of the control
Definition: stream.h:172
Events for a stream.
Definition: stream.h:200