PipeWire
0.3.29
|
PipeWire stream objects. More...
Data Structures | |
struct | pw_buffer |
struct | pw_stream_control |
struct | pw_time |
A time structure. More... | |
struct | pw_stream_events |
Events for a stream. More... | |
Enumerations | |
enum | pw_stream_state { PW_STREAM_STATE_ERROR = -1 , PW_STREAM_STATE_UNCONNECTED = 0 , PW_STREAM_STATE_CONNECTING = 1 , PW_STREAM_STATE_PAUSED = 2 , PW_STREAM_STATE_STREAMING = 3 } |
The state of a stream. More... | |
enum | pw_stream_flags { PW_STREAM_FLAG_NONE = 0 , PW_STREAM_FLAG_AUTOCONNECT = (1 << 0) , PW_STREAM_FLAG_INACTIVE = (1 << 1) , PW_STREAM_FLAG_MAP_BUFFERS = (1 << 2) , PW_STREAM_FLAG_DRIVER = (1 << 3) , PW_STREAM_FLAG_RT_PROCESS = (1 << 4) , PW_STREAM_FLAG_NO_CONVERT = (1 << 5) , PW_STREAM_FLAG_EXCLUSIVE = (1 << 6) , PW_STREAM_FLAG_DONT_RECONNECT = (1 << 7) , PW_STREAM_FLAG_ALLOC_BUFFERS = (1 << 8) } |
Extra flags that can be used in pw_stream_connect() More... | |
Functions | |
const char * | pw_stream_state_as_string (enum pw_stream_state state) |
Convert a stream state to a readable string. More... | |
struct pw_stream * | pw_stream_new (struct pw_core *core, const char *name, struct pw_properties *props) |
Create a new unconneced Stream Object. More... | |
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) |
void | pw_stream_destroy (struct pw_stream *stream) |
Destroy a stream. More... | |
void | pw_stream_add_listener (struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data) |
enum pw_stream_state | pw_stream_get_state (struct pw_stream *stream, const char **error) |
const char * | pw_stream_get_name (struct pw_stream *stream) |
struct pw_core * | pw_stream_get_core (struct pw_stream *stream) |
const struct pw_properties * | pw_stream_get_properties (struct pw_stream *stream) |
int | pw_stream_update_properties (struct pw_stream *stream, const struct spa_dict *dict) |
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. More... | |
uint32_t | pw_stream_get_node_id (struct pw_stream *stream) |
Get the node ID of the stream. More... | |
int | pw_stream_disconnect (struct pw_stream *stream) |
Disconnect stream More... | |
int | pw_stream_set_error (struct pw_stream *stream, int res, const char *error,...) SPA_PRINTF_FUNC(3 |
Set the stream in error state. More... | |
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. More... | |
int | pw_stream_set_control (struct pw_stream *stream, uint32_t id, uint32_t n_values, float *values,...) |
Set control values. More... | |
int | pw_stream_get_time (struct pw_stream *stream, struct pw_time *time) |
Query the time on the stream More... | |
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. More... | |
int | pw_stream_queue_buffer (struct pw_stream *stream, struct pw_buffer *buffer) |
Submit a buffer for playback or recycle a buffer for capture. More... | |
int | pw_stream_set_active (struct pw_stream *stream, bool active) |
Activate or deactivate the stream. More... | |
int | pw_stream_flush (struct pw_stream *stream, bool drain) |
Flush a stream. More... | |
PipeWire stream objects.
The stream object provides a convenient way to send and receive data streams from/to PipeWire.
See also Media Streams and Core API
enum pw_stream_flags |
Extra flags that can be used in pw_stream_connect()
Enumerator | |
---|---|
PW_STREAM_FLAG_NONE | no flags |
PW_STREAM_FLAG_AUTOCONNECT | try to automatically connect this stream |
PW_STREAM_FLAG_INACTIVE | start the stream inactive, pw_stream_set_active() needs to be called explicitly |
PW_STREAM_FLAG_MAP_BUFFERS | mmap the buffers except DmaBuf |
PW_STREAM_FLAG_DRIVER | be a driver |
PW_STREAM_FLAG_RT_PROCESS | call process from the realtime thread. You MUST use RT safe functions in the process callback. |
PW_STREAM_FLAG_NO_CONVERT | don't convert format |
PW_STREAM_FLAG_EXCLUSIVE | require exclusive access to the device |
PW_STREAM_FLAG_DONT_RECONNECT | don't try to reconnect this stream when the sink/source is removed |
PW_STREAM_FLAG_ALLOC_BUFFERS | the application will allocate buffer memory. In the add_buffer event, the data of the buffer should be set |
enum pw_stream_state |
void pw_stream_add_listener | ( | struct pw_stream * | stream, |
struct spa_hook * | listener, | ||
const struct pw_stream_events * | events, | ||
void * | data | ||
) |
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.
You should connect to the process event and use pw_stream_dequeue_buffer() to get the latest metadata and data.
stream | a Stream Object |
direction | the stream direction |
target_id | the target object id to connect to or PW_ID_ANY to let the manager select a target. |
flags | stream flags |
params | an array with params. The params should ideally contain supported formats. |
n_params | number of items in params |
References NAME, PW_DIRECTION_INPUT, pw_log_debug, res, SPA_CONTAINER_OF, SPA_DIRECTION_INPUT, and SPA_DIRECTION_OUTPUT.
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.
References res, and SPA_CONTAINER_OF.
void pw_stream_destroy | ( | struct pw_stream * | stream | ) |
Destroy a stream.
References NAME, pw_log_debug, pw_stream_disconnect(), SPA_CONTAINER_OF, spa_hook_remove(), and spa_list_remove().
int pw_stream_disconnect | ( | struct pw_stream * | stream | ) |
Disconnect stream
References NAME, pw_core_disconnect(), pw_impl_node_destroy(), pw_impl_node_set_active(), pw_log_debug, pw_proxy_destroy(), SPA_CONTAINER_OF, spa_hook_remove(), and spa_list_remove().
Referenced by pw_stream_destroy().
int pw_stream_flush | ( | struct pw_stream * | stream, |
bool | drain | ||
) |
Flush a stream.
When drain is true, the drained callback will be called when all data is played or recorded
References pw_loop_invoke, and SPA_CONTAINER_OF.
struct pw_core* pw_stream_get_core | ( | struct pw_stream * | stream | ) |
const char* pw_stream_get_name | ( | struct pw_stream * | stream | ) |
uint32_t pw_stream_get_node_id | ( | struct pw_stream * | stream | ) |
Get the node ID of the stream.
const struct pw_properties* pw_stream_get_properties | ( | struct pw_stream * | stream | ) |
enum pw_stream_state pw_stream_get_state | ( | struct pw_stream * | stream, |
const char ** | error | ||
) |
int pw_stream_get_time | ( | struct pw_stream * | stream, |
struct pw_time * | time | ||
) |
Query the time on the stream
References pw_time::delay, spa_fraction::denom, NAME, pw_time::now, spa_fraction::num, pw_log_trace, pw_time::queued, pw_time::rate, SPA_CONTAINER_OF, SPA_DIRECTION_INPUT, SPA_NSEC_PER_SEC, pw_time::ticks, and stream::time.
struct pw_stream* pw_stream_new | ( | struct pw_core * | core, |
const char * | name, | ||
struct pw_properties * | props | ||
) |
Create a new unconneced Stream Object.
core | a The Core Global Object |
name | a stream media name |
props | stream properties, ownership is taken |
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 | ||
) |
loop | a Pipewire Loop to use |
name | a stream media name |
props | stream properties, ownership is taken |
events | stream events |
data | data passed to events |
References pw_context_new(), pw_properties::pw_properties_new(), and res.
int pw_stream_queue_buffer | ( | struct pw_stream * | stream, |
struct pw_buffer * | buffer | ||
) |
Submit a buffer for playback or recycle a buffer for capture.
References buffer::busy, spa_meta_busy::count, buffer::id, NAME, pw_log_trace, res, and SPA_CONTAINER_OF.
int pw_stream_set_active | ( | struct pw_stream * | stream, |
bool | active | ||
) |
Activate or deactivate the stream.
References NAME, pw_impl_node_set_active(), pw_log_debug, and SPA_CONTAINER_OF.
int pw_stream_set_control | ( | struct pw_stream * | stream, |
uint32_t | id, | ||
uint32_t | n_values, | ||
float * | values, | ||
... | |||
) |
Set control values.
References NAME, pw_log_debug, SPA_CONTAINER_OF, SPA_PARAM_Props, SPA_POD_BUILDER_INIT, spa_pod_builder_push_object(), SPA_TYPE_OBJECT_Props, va_start(), and control::values.
int pw_stream_set_error | ( | struct pw_stream * | stream, |
int | res, | ||
const char * | error, | ||
... | |||
) |
Set the stream in error state.
stream | a Stream Object |
res | a result code |
error | an error message |
const char* pw_stream_state_as_string | ( | enum pw_stream_state | state | ) |
Convert a stream state to a readable string.
References PW_STREAM_STATE_CONNECTING, PW_STREAM_STATE_ERROR, PW_STREAM_STATE_PAUSED, PW_STREAM_STATE_STREAMING, and PW_STREAM_STATE_UNCONNECTED.
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.
This function should be called after notification of the format.
When res indicates success, params contain the parameters for the allocation state.
stream | a Stream Object |
params | an array of params. The params should ideally contain parameters for doing buffer allocation. |
n_params | number of elements in params |
References NAME, pw_log_debug, res, and SPA_CONTAINER_OF.
int pw_stream_update_properties | ( | struct pw_stream * | stream, |
const struct spa_dict * | dict | ||
) |
References pw_impl_node_update_properties(), pw_properties::pw_properties_update(), res, and SPA_CONTAINER_OF.