PipeWire  0.2.4
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 
147 struct pw_stream;
148 
149 #include <spa/buffer/buffer.h>
150 #include <spa/param/param.h>
151 
152 #include <pipewire/remote.h>
153 
164 };
165 
166 struct pw_buffer {
167  struct spa_buffer *buffer; /* the spa buffer */
168  void *user_data; /* user data attached to the buffer */
169  uint64_t size; /* For input streams, this field is set by pw_stream
170  with the duration of the buffer in ticks.
171  For output streams, this field is set by the user.
172  This field is added for all queued buffers and
173  returned in the time info. */
174 };
175 
178 #define PW_VERSION_STREAM_EVENTS 0
179  uint32_t version;
180 
181  void (*destroy) (void *data);
183  void (*state_changed) (void *data, enum pw_stream_state old,
184  enum pw_stream_state state, const char *error);
188  void (*format_changed) (void *data, const struct spa_pod *format);
189 
191  void (*add_buffer) (void *data, struct pw_buffer *buffer);
193  void (*remove_buffer) (void *data, struct pw_buffer *buffer);
194 
199  void (*process) (void *data);
200 };
201 
203 const char * pw_stream_state_as_string(enum pw_stream_state state);
204 
218 };
219 
222 struct pw_stream *
223 pw_stream_new(struct pw_remote *remote,
224  const char *name,
225  struct pw_properties *props );
226 
227 struct pw_stream *
228 pw_stream_new_simple(struct pw_loop *loop,
229  const char *name,
230  struct pw_properties *props,
231  const struct pw_stream_events *events,
232  void *data );
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 
246 struct pw_remote *pw_stream_get_remote(struct pw_stream *stream);
247 
249 #define PW_STREAM_PROP_IS_LIVE "pipewire.latency.is-live"
250 
251 #define PW_STREAM_PROP_LATENCY_MIN "pipewire.latency.min"
252 
253 #define PW_STREAM_PROP_LATENCY_MAX "pipewire.latency.max"
254 
255 const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
256 
262 int
263 pw_stream_connect(struct pw_stream *stream,
264  enum pw_direction direction,
265  const char *port_path,
267  enum pw_stream_flags flags,
268  const struct spa_pod **params,
271  uint32_t n_params );
272 
275 uint32_t
276 pw_stream_get_node_id(struct pw_stream *stream);
277 
279 int pw_stream_disconnect(struct pw_stream *stream);
280 
287 void
288 pw_stream_finish_format(struct pw_stream *stream,
289  int res,
290  const struct spa_pod **params,
293  uint32_t n_params );
294 
295 
297 #define PW_STREAM_CONTROL_VOLUME "volume"
298 
300 #define PW_STREAM_CONTROL_CONTRAST "contrast"
301 #define PW_STREAM_CONTROL_BRIGHTNESS "brightness"
302 #define PW_STREAM_CONTROL_HUE "hue"
303 #define PW_STREAM_CONTROL_SATURATION "saturation"
304 
306 int pw_stream_set_control(struct pw_stream *stream, const char *name, float value);
308 int pw_stream_get_control(struct pw_stream *stream, const char *name, float *value);
309 
311 int pw_stream_set_active(struct pw_stream *stream, bool active);
312 
314 struct pw_time {
315  int64_t now;
316  struct spa_fraction rate;
317  uint64_t ticks;
319  uint64_t delay;
322  uint64_t queued;
325 };
326 
328 int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
329 
332 struct pw_buffer *pw_stream_dequeue_buffer(struct pw_stream *stream);
333 
335 int pw_stream_queue_buffer(struct pw_stream *stream, struct pw_buffer *buffer);
336 
337 
338 #ifdef __cplusplus
339 }
340 #endif
341 
342 #endif /* __PIPEWIRE_STREAM_H__ */
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:1404
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
uint64_t ticks
the ticks at now.
Definition: stream.h:317
A collection of key/value pairs.
Definition: properties.h:38
int pw_stream_set_control(struct pw_stream *stream, const char *name, float value)
Set a control value.
Definition: stream.c:1380
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:1256
require exclusive access to the device
Definition: stream.h:216
paused, fully configured but not processing data yet
Definition: stream.h:161
void(* format_changed)(void *data, const struct spa_pod *format)
when the format changed.
Definition: stream.h:188
try to automatically connect this stream
Definition: stream.h:208
const char * pw_stream_state_as_string(enum pw_stream_state state)
Convert a stream state to a readable string.
Definition: stream.c:352
int64_t now
the monotonic time
Definition: stream.h:315
PipeWire loop object provides an implementation of the spa loop interfaces.
Definition: loop.h:37
A time structure.
Definition: stream.h:314
void(* add_buffer)(void *data, struct pw_buffer *buffer)
when a new buffer was created for this stream
Definition: stream.h:191
Events for a stream.
Definition: stream.h:177
int pw_stream_get_control(struct pw_stream *stream, const char *name, float *value)
Get a control value.
Definition: stream.c:1385
pw_stream_state
The state of a stream.
Definition: stream.h:155
mmap the buffers
Definition: stream.h:211
struct spa_fraction rate
the rate of ticks
Definition: stream.h:316
stream is ready
Definition: stream.h:160
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
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:373
int pw_stream_disconnect(struct pw_stream *stream)
Disconnect stream.
Definition: stream.c:1332
streaming
Definition: stream.h:163
PipeWire stream object class.
void pw_stream_destroy(struct pw_stream *stream)
Destroy a stream.
Definition: stream.c:529
enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error)
Definition: stream.c:433
don&#39;t convert format
Definition: stream.h:215
uint32_t pw_stream_get_node_id(struct pw_stream *stream)
Get the node ID of the stream.
Definition: stream.c:1302
be a driver
Definition: stream.h:212
the strean is in error
Definition: stream.h:156
Represents a connection with a remote PipeWire instance.
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:427
void(* destroy)(void *data)
Definition: stream.h:181
int pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
Query the time on the stream.
Definition: stream.c:1361
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:1390
uint64_t size
Definition: stream.h:169
start the stream inactive
Definition: stream.h:210
const char * pw_stream_get_name(struct pw_stream *stream)
Definition: stream.c:440
const struct pw_properties * pw_stream_get_properties(struct pw_stream *stream)
Definition: stream.c:445
pw_stream_flags
Extra flags that can be used in pw_stream_connect()
Definition: stream.h:206
void pw_stream_add_listener(struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data)
Definition: stream.c:450
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:183
void(* remove_buffer)(void *data, struct pw_buffer *buffer)
when a buffer was destroyed for this stream
Definition: stream.h:193
call process from the realtime thread
Definition: stream.h:213
struct spa_buffer * buffer
Definition: stream.h:167
void pw_stream_finish_format(struct pw_stream *stream, int res, const struct spa_pod **params, uint32_t n_params)
Complete the negotiation process with result code res.
Definition: stream.c:1308
int pw_stream_set_active(struct pw_stream *stream, bool active)
Activate or deactivate the stream.
Definition: stream.c:1349
connection is in progress
Definition: stream.h:158
Definition: stream.h:166
struct pw_remote * pw_stream_get_remote(struct pw_stream *stream)
Definition: stream.c:1296
void(* process)(void *data)
when a buffer can be queued (for playback streams) or dequeued (for capture streams).
Definition: stream.h:199
uint32_t version
Definition: stream.h:179
unconnected
Definition: stream.h:157
stream is being configured
Definition: stream.h:159
void * user_data
Definition: stream.h:168
no flags
Definition: stream.h:207
pw_direction
The direction of a port.
Definition: introspect.h:47