PipeWire: stream.h Source File

PipeWire 0.1.9

stream.h
Go to the documentation of this file.
1 /* PipeWire
2 * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef __PIPEWIRE_STREAM_H__
21 #define __PIPEWIRE_STREAM_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
163 struct pw_stream;
164
165 #include <spa/buffer/buffer.h>
166 #include <spa/param/param.h>
167
168 #include <pipewire/remote.h>
169
171 enum pw_stream_state {
172 PW_STREAM_STATE_ERROR = -1,
173 PW_STREAM_STATE_UNCONNECTED = 0,
174 PW_STREAM_STATE_CONNECTING = 1,
175 PW_STREAM_STATE_CONFIGURE = 2,
176 PW_STREAM_STATE_READY = 3,
177 PW_STREAM_STATE_PAUSED = 4,
179 PW_STREAM_STATE_STREAMING = 5
180 };
181
183 struct pw_stream_events {
184 #define PW_VERSION_STREAM_EVENTS 0
185 uint32_t version;
186
187 void (*destroy) (void *data);
189 void (*state_changed) (void *data, enum pw_stream_state old,
190 enum pw_stream_state state, const char *error);
194 void (*format_changed) (void *data, struct spa_pod *format);
195
197 void (*add_buffer) (void *data, uint32_t id);
199 void (*remove_buffer) (void *data, uint32_t id);
202 void (*new_buffer) (void *data, uint32_t id);
204 void (*need_buffer) (void *data);
205 };
206
208 const char * pw_stream_state_as_string(enum pw_stream_state state);
209
211 enum pw_stream_flags {
212 PW_STREAM_FLAG_NONE = 0,
213 PW_STREAM_FLAG_AUTOCONNECT = (1 << 0),
215 PW_STREAM_FLAG_CLOCK_UPDATE = (1 << 1),
217 PW_STREAM_FLAG_INACTIVE = (1 << 2),
218 };
219
221 struct pw_time {
222 int64_t now;
223 int64_t ticks;
224 int32_t rate;
225 };
226
229 struct pw_stream *
230 pw_stream_new(struct pw_remote *remote,
231 const char *name,
232 struct pw_properties *props );
233
235 void pw_stream_destroy(struct pw_stream *stream);
236
237 void pw_stream_add_listener(struct pw_stream *stream,
238 struct spa_hook *listener,
239 const struct pw_stream_events *events,
240 void *data);
241
242 enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error);
243
244 const char *pw_stream_get_name(struct pw_stream *stream);
245
247 #define PW_STREAM_PROP_IS_LIVE "pipewire.latency.is-live"
248
249 #define PW_STREAM_PROP_LATENCY_MIN "pipewire.latency.min"
250
251 #define PW_STREAM_PROP_LATENCY_MAX "pipewire.latency.max"
252
253 const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
254
261 int
262 pw_stream_connect(struct pw_stream *stream,
263 enum pw_direction direction,
264 const char *port_path,
266 enum pw_stream_flags flags,
267 const struct spa_pod **params,
270 uint32_t n_params );
271
274 uint32_t
275 pw_stream_get_node_id(struct pw_stream *stream);
276
278 int pw_stream_disconnect(struct pw_stream *stream);
279
286 void
287 pw_stream_finish_format(struct pw_stream *stream,
288 int res,
289 struct spa_pod **params,
292 uint32_t n_params );
293
295 int pw_stream_set_active(struct pw_stream *stream, bool active);
296
298 int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
299
303 uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream);
304
308 int pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id);
309
314 struct spa_buffer *
315 pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id);
316
322 int pw_stream_send_buffer(struct pw_stream *stream, uint32_t id);
323
324 #ifdef __cplusplus
325 }
326 #endif
327
328 #endif /* __PIPEWIRE_STREAM_H__ */
pw_stream::pw_stream_recycle_buffer
int pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
Recycle the buffer with id.
Definition: stream.c:1219
pw_properties
A collection of key/value pairs.
Definition: properties.h:38
pw_stream::pw_stream_connect
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)
Connect a stream for input or output on port_path.
Definition: stream.c:1092
pw_stream::pw_stream_send_buffer
int pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
Send a buffer with id to stream.
Definition: stream.c:1254
pw_stream::pw_stream_peek_buffer
struct spa_buffer * pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id)
Get the buffer with id from stream.
Definition: stream.c:1244
PW_STREAM_STATE_PAUSED
paused, fully configured but not processing data yet
Definition: stream.h:177
PW_STREAM_FLAG_AUTOCONNECT
try to automatically connect this stream
Definition: stream.h:213
pw_stream::pw_stream_state_as_string
const char * pw_stream_state_as_string(enum pw_stream_state state)
Convert a stream state to a readable string.
Definition: stream.c:227
pw_time::now
int64_t now
the monotonic time
Definition: stream.h:222
pw_stream::pw_stream_get_empty_buffer
uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
Get the id of an empty buffer that can be filled.
Definition: stream.c:1206
pw_time
A time structure.
Definition: stream.h:221
pw_stream_events::new_buffer
void(* new_buffer)(void *data, uint32_t id)
when a buffer can be reused (for playback streams) or is filled (for capture streams ...
Definition: stream.h:202
pw_stream_events
Events for a stream.
Definition: stream.h:183
pw_stream_state
pw_stream_state
The state of a stream.
Definition: stream.h:171
pw_time::ticks
int64_t ticks
the ticks at now
Definition: stream.h:223
PW_STREAM_STATE_READY
stream is ready
Definition: stream.h:176
pw_stream::pw_stream_new
struct pw_stream * pw_stream_new(struct pw_remote *remote, const char *name, struct pw_properties *props)
Create a new unconneced pw_stream.
Definition: stream.c:248
pw_stream::pw_stream_disconnect
int pw_stream_disconnect(struct pw_stream *stream)
Disconnect stream.
Definition: stream.c:1164
PW_STREAM_STATE_STREAMING
streaming
Definition: stream.h:179
pw_stream
PipeWire stream object class.
pw_stream::pw_stream_destroy
void pw_stream_destroy(struct pw_stream *stream)
Destroy a stream.
Definition: stream.c:396
pw_stream_get_state
enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error)
Definition: stream.c:300
pw_stream::pw_stream_get_node_id
uint32_t pw_stream_get_node_id(struct pw_stream *stream)
Get the node ID of the stream.
Definition: stream.c:1134
PW_STREAM_STATE_ERROR
the strean is in error
Definition: stream.h:172
pw_remote
Represents a connection with a remote PipeWire instance.
pw_stream_events::destroy
void(* destroy)(void *data)
Definition: stream.h:187
pw_stream::pw_stream_get_time
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
Query the time on the stream.
Definition: stream.c:1190
pw_stream_events::format_changed
void(* format_changed)(void *data, struct spa_pod *format)
when the format changed.
Definition: stream.h:194
PW_STREAM_FLAG_INACTIVE
start the stream inactive
Definition: stream.h:217
pw_stream_get_name
const char * pw_stream_get_name(struct pw_stream *stream)
Definition: stream.c:307
pw_stream_get_properties
const struct pw_properties * pw_stream_get_properties(struct pw_stream *stream)
Definition: stream.c:312
pw_stream_flags
pw_stream_flags
Extra flags that can be used in pw_stream_connect()
Definition: stream.h:211
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:317
pw_stream_events::state_changed
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:189
pw_stream_events::need_buffer
void(* need_buffer)(void *data)
when a buffer is needed (for playback streams)
Definition: stream.h:204
pw_stream::pw_stream_finish_format
void pw_stream_finish_format(struct pw_stream *stream, int res, struct spa_pod **params, uint32_t n_params)
Complete the negotiation process with result code res.
Definition: stream.c:1140
pw_stream_events::remove_buffer
void(* remove_buffer)(void *data, uint32_t id)
when a buffer was destroyed for this stream
Definition: stream.h:199
pw_stream_events::add_buffer
void(* add_buffer)(void *data, uint32_t id)
when a new buffer was created for this stream
Definition: stream.h:197
pw_stream::pw_stream_set_active
int pw_stream_set_active(struct pw_stream *stream, bool active)
Activate or deactivate the stream.
Definition: stream.c:1183
remote.h
PW_STREAM_STATE_CONNECTING
connection is in progress
Definition: stream.h:174
PW_STREAM_FLAG_CLOCK_UPDATE
request periodic clock updates for this stream
Definition: stream.h:215
pw_stream_events::version
uint32_t version
Definition: stream.h:185
pw_time::rate
int32_t rate
the rate of ticks
Definition: stream.h:224
PW_STREAM_STATE_UNCONNECTED
unconnected
Definition: stream.h:173
PW_STREAM_STATE_CONFIGURE
stream is being configured
Definition: stream.h:175
PW_STREAM_FLAG_NONE
no flags
Definition: stream.h:212
pw_direction
pw_direction
The direction of a port.
Definition: introspect.h:47