stream.h
Go to the documentation of this file.
/* PipeWire
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_STREAM_H__
#define __PIPEWIRE_STREAM_H__
#ifdef __cplusplus
extern "C" {
#endif
struct pw_stream;
#include <spa/buffer/buffer.h>
#include <spa/param/param.h>
#include <pipewire/remote.h>
enum pw_stream_state {
PW_STREAM_STATE_ERROR = -1,
PW_STREAM_STATE_UNCONNECTED = 0,
PW_STREAM_STATE_CONNECTING = 1,
PW_STREAM_STATE_CONFIGURE = 2,
PW_STREAM_STATE_READY = 3,
PW_STREAM_STATE_PAUSED = 4,
PW_STREAM_STATE_STREAMING = 5
};
struct pw_buffer {
struct spa_buffer *buffer; /* the spa buffer */
void *user_data; /* user data attached to the buffer */
uint64_t size; /* For input streams, this field is set by pw_stream
with the duration of the buffer in ticks.
For output streams, this field is set by the user.
This field is added for all queued buffers and
returned in the time info. */
};
struct pw_stream_events {
#define PW_VERSION_STREAM_EVENTS 0
uint32_t version;
void (*destroy) (void *data);
void (*state_changed) (void *data, enum pw_stream_state old,
enum pw_stream_state state, const char *error);
void (*format_changed) (void *data, const struct spa_pod *format);
void (*add_buffer) (void *data, struct pw_buffer *buffer);
void (*remove_buffer) (void *data, struct pw_buffer *buffer);
void (*process) (void *data);
};
const char * pw_stream_state_as_string(enum pw_stream_state state);
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),
};
struct pw_stream *
pw_stream_new(struct pw_remote *remote,
const char *name,
struct pw_properties *props );
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);
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_remote *pw_stream_get_remote(struct pw_stream *stream);
#define PW_STREAM_PROP_IS_LIVE "pipewire.latency.is-live"
#define PW_STREAM_PROP_LATENCY_MIN "pipewire.latency.min"
#define PW_STREAM_PROP_LATENCY_MAX "pipewire.latency.max"
const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
int
pw_stream_connect(struct pw_stream *stream,
enum pw_direction direction,
const char *port_path,
enum pw_stream_flags flags,
const struct spa_pod **params,
uint32_t n_params );
uint32_t
pw_stream_get_node_id(struct pw_stream *stream);
int pw_stream_disconnect(struct pw_stream *stream);
void
pw_stream_finish_format(struct pw_stream *stream,
int res,
const struct spa_pod **params,
uint32_t n_params );
#define PW_STREAM_CONTROL_VOLUME "volume"
#define PW_STREAM_CONTROL_CONTRAST "contrast"
#define PW_STREAM_CONTROL_BRIGHTNESS "brightness"
#define PW_STREAM_CONTROL_HUE "hue"
#define PW_STREAM_CONTROL_SATURATION "saturation"
int pw_stream_set_control(struct pw_stream *stream, const char *name, float value);
int pw_stream_get_control(struct pw_stream *stream, const char *name, float *value);
int pw_stream_set_active(struct pw_stream *stream, bool active);
struct pw_time {
int64_t now;
struct spa_fraction rate;
uint64_t ticks;
uint64_t delay;
uint64_t queued;
};
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
struct pw_buffer *pw_stream_dequeue_buffer(struct pw_stream *stream);
int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer);
#ifdef __cplusplus
}
#endif
#endif /* __PIPEWIRE_STREAM_H__ */
pw_stream_queue_buffer
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:1417
pw_time::delay
uint64_t delay
delay to device, add to ticks for INPUT streams and subtract from ticks for OUTPUT streams to get the...
Definition: stream.h:319
pw_time::ticks
uint64_t ticks
the ticks at now.
Definition: stream.h:317
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_stream_set_control
int pw_stream_set_control(struct pw_stream *stream, const char *name, float value)
Set a control value.
Definition: stream.c:1390
PW_STREAM_FLAG_EXCLUSIVE
require exclusive access to the device
Definition: stream.h:216
PW_STREAM_STATE_PAUSED
paused, fully configured but not processing data yet
Definition: stream.h:161
PW_STREAM_FLAG_AUTOCONNECT
try to automatically connect this stream
Definition: stream.h:208
pw_time::now
int64_t now
the monotonic time
Definition: stream.h:315
pw_loop
PipeWire loop object provides an implementation of the spa loop interfaces.
Definition: loop.h:37
pw_time
A time structure.
Definition: stream.h:314
pw_stream_events
Events for a stream.
Definition: stream.h:177
pw_stream_get_control
int pw_stream_get_control(struct pw_stream *stream, const char *name, float *value)
Get a control value.
Definition: stream.c:1396
pw_stream_state
pw_stream_state
The state of a stream.
Definition: stream.h:155
PW_STREAM_FLAG_MAP_BUFFERS
mmap the buffers
Definition: stream.h:211
PW_STREAM_STATE_READY
stream is ready
Definition: stream.h:160
pw_time::queued
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:322
pw_stream_get_time
SPA_EXPORT int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
Definition: stream.c:1370
PW_STREAM_STATE_STREAMING
streaming
Definition: stream.h:163
pw_stream
PipeWire stream object class.
pw_stream_set_active
SPA_EXPORT int pw_stream_set_active(struct pw_stream *stream, bool active)
Definition: stream.c:1357
pw_stream_connect
SPA_EXPORT int pw_stream_connect(struct pw_stream *stream, enum pw_direction direction, const char *port_path, enum pw_stream_flags flags, const struct spa_pod **params, uint32_t n_params)
Definition: stream.c:1259
pw_stream_get_state
enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error)
Definition: stream.c:436
pw_stream_new
SPA_EXPORT struct pw_stream * pw_stream_new(struct pw_remote *remote, const char *name, struct pw_properties *props)
Definition: stream.c:374
PW_STREAM_FLAG_NO_CONVERT
don&#39;t convert format
Definition: stream.h:215
PW_STREAM_FLAG_DRIVER
be a driver
Definition: stream.h:212
PW_STREAM_STATE_ERROR
the strean is in error
Definition: stream.h:156
pw_remote
Represents a connection with a remote PipeWire instance.
pw_stream_new_simple
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:429
pw_stream_dequeue_buffer
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:1402
pw_buffer::size
uint64_t size
Definition: stream.h:169
PW_STREAM_FLAG_INACTIVE
start the stream inactive
Definition: stream.h:210
pw_stream_get_name
const char * pw_stream_get_name(struct pw_stream *stream)
Definition: stream.c:444
pw_stream_finish_format
SPA_EXPORT void pw_stream_finish_format(struct pw_stream *stream, int res, const struct spa_pod **params, uint32_t n_params)
Definition: stream.c:1314
pw_stream_get_properties
const struct pw_properties * pw_stream_get_properties(struct pw_stream *stream)
Definition: stream.c:450
pw_stream_flags
pw_stream_flags
Extra flags that can be used in pw_stream_connect()
Definition: stream.h:206
pw_stream_add_listener
void pw_stream_add_listener(struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data)
Definition: stream.c:456
PW_STREAM_FLAG_RT_PROCESS
call process from the realtime thread
Definition: stream.h:213
pw_buffer::buffer
struct spa_buffer * buffer
Definition: stream.h:167
remote.h
PW_STREAM_STATE_CONNECTING
connection is in progress
Definition: stream.h:158
pw_buffer
Definition: stream.h:166
pw_stream_get_remote
struct pw_remote * pw_stream_get_remote(struct pw_stream *stream)
Definition: stream.c:1300
pw_stream_destroy
SPA_EXPORT void pw_stream_destroy(struct pw_stream *stream)
Definition: stream.c:536
pw_stream_events::version
uint32_t version
Definition: stream.h:179
PW_STREAM_STATE_UNCONNECTED
unconnected
Definition: stream.h:157
PW_STREAM_STATE_CONFIGURE
stream is being configured
Definition: stream.h:159
pw_buffer::user_data
void * user_data
Definition: stream.h:168
PW_STREAM_FLAG_NONE
no flags
Definition: stream.h:207
pw_direction
pw_direction
The direction of a port.
Definition: introspect.h:47
pw_stream_disconnect
SPA_EXPORT int pw_stream_disconnect(struct pw_stream *stream)
Definition: stream.c:1339
pw_stream_get_node_id
SPA_EXPORT uint32_t pw_stream_get_node_id(struct pw_stream *stream)
Definition: stream.c:1307
pw_stream_state_as_string
SPA_EXPORT const char * pw_stream_state_as_string(enum pw_stream_state state)
Definition: stream.c:352