PipeWire  0.1.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 
163 struct pw_stream;
164 
165 #include <spa/buffer.h>
166 #include <spa/format.h>
167 
168 #include <pipewire/remote.h>
169 
180 };
181 
183 #define PW_VERSION_STREAM_EVENTS 0
184  uint32_t version;
185 
186  void (*destroy) (void *data);
188  void (*state_changed) (void *data, enum pw_stream_state old,
189  enum pw_stream_state state, const char *error);
193  void (*format_changed) (void *data, struct spa_format *format);
194 
196  void (*add_buffer) (void *data, uint32_t id);
198  void (*remove_buffer) (void *data, uint32_t id);
201  void (*new_buffer) (void *data, uint32_t id);
203  void (*need_buffer) (void *data);
204 };
205 
207 const char * pw_stream_state_as_string(enum pw_stream_state state);
208 
216 };
217 
222 };
223 
225 struct pw_time {
226  int64_t now;
227  int64_t ticks;
228  int32_t rate;
229 };
230 
233 struct pw_stream *
235  const char *name,
236  struct pw_properties *props );
237 
239 void pw_stream_destroy(struct pw_stream *stream);
240 
241 void pw_stream_add_listener(struct pw_stream *stream,
242  struct spa_hook *listener,
243  const struct pw_stream_events *events,
244  void *data);
245 
246 enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error);
247 
248 const char *pw_stream_get_name(struct pw_stream *stream);
249 
250 const struct pw_properties *pw_stream_get_properties(struct pw_stream *stream);
251 
258 bool
259 pw_stream_connect(struct pw_stream *stream,
260  enum pw_direction direction,
261  enum pw_stream_mode mode,
262  const char *port_path,
264  enum pw_stream_flags flags,
265  uint32_t n_possible_formats,
266  const struct spa_format **possible_formats );
267 
270 uint32_t
271 pw_stream_get_node_id(struct pw_stream *stream);
272 
274 void pw_stream_disconnect(struct pw_stream *stream);
275 
282 void
283 pw_stream_finish_format(struct pw_stream *stream,
284  int res,
285  struct spa_param **params,
286  uint32_t n_params );
287 
289 bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
290 
294 uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream);
295 
299 bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id);
300 
305 struct spa_buffer *
306 pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id);
307 
313 bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id);
314 
315 #ifdef __cplusplus
316 }
317 #endif
318 
319 #endif /* __PIPEWIRE_STREAM_H__ */
A collection of key/value pairs.
Definition: properties.h:38
char * error
error reason when state is in error
Definition: private.h:356
void(* format_changed)(void *data, struct spa_format *format)
when the format changed.
Definition: stream.h:193
bool pw_stream_connect(struct pw_stream *stream, enum pw_direction direction, enum pw_stream_mode mode, const char *port_path, enum pw_stream_flags flags, uint32_t n_possible_formats, const struct spa_format **possible_formats)
Definition: stream.c:917
paused, fully configured but not processing data yet
Definition: stream.h:177
try to automatically connect this stream
Definition: stream.h:212
int64_t now
the monotonic time
Definition: stream.h:226
A time structure.
Definition: stream.h:225
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:201
uint32_t pw_stream_get_node_id(struct pw_stream *stream)
Definition: stream.c:961
uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
Definition: stream.c:1024
Definition: stream.h:182
pw_stream_state
The state of a stream.
Definition: stream.h:171
int64_t ticks
the ticks at now
Definition: stream.h:227
bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
Definition: stream.c:1008
stream is ready
Definition: stream.h:176
void pw_stream_destroy(struct pw_stream *stream)
Definition: stream.c:322
streaming
Definition: stream.h:179
Represents a connection with the PipeWire server.
Definition: private.h:320
pw_stream_mode
The method for transfering data for a stream.
Definition: stream.h:219
enum pw_stream_state pw_stream_get_state(struct pw_stream *stream, const char **error)
Definition: stream.c:231
the strean is in error
Definition: stream.h:172
data is placed in buffers
Definition: stream.h:220
struct pw_stream * pw_stream_new(struct pw_remote *remote, const char *name, struct pw_properties *props)
Definition: stream.c:184
PipeWire stream object class.
Definition: private.h:346
void(* destroy)(void *data)
Definition: stream.h:186
a ringbuffer is used to exchange data
Definition: stream.h:221
bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
Definition: stream.c:1067
const char * pw_stream_get_name(struct pw_stream *stream)
Definition: stream.c:238
const struct pw_properties * pw_stream_get_properties(struct pw_stream *stream)
Definition: stream.c:243
char * name
the name of the stream
Definition: private.h:350
pw_stream_flags
Extra flags that can be used in pw_stream_connect()
Definition: stream.h:210
void pw_stream_add_listener(struct pw_stream *stream, struct spa_hook *listener, const struct pw_stream_events *events, void *data)
Definition: stream.c:248
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:188
void(* need_buffer)(void *data)
when a buffer is needed (for playback streams)
Definition: stream.h:203
void pw_stream_finish_format(struct pw_stream *stream, int res, struct spa_param **params, uint32_t n_params)
Definition: stream.c:967
void(* remove_buffer)(void *data, uint32_t id)
when a buffer was destroyed for this stream
Definition: stream.h:198
void(* add_buffer)(void *data, uint32_t id)
when a new buffer was created for this stream
Definition: stream.h:196
connection is in progress
Definition: stream.h:174
struct pw_remote * remote
the owner remote
Definition: private.h:347
request periodic clock updates for this stream
Definition: stream.h:214
struct spa_buffer * pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id)
Definition: stream.c:1057
const char * pw_stream_state_as_string(enum pw_stream_state state)
Definition: stream.c:163
uint32_t version
Definition: stream.h:184
int32_t rate
the rate of ticks
Definition: stream.h:228
unconnected
Definition: stream.h:173
bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
Definition: stream.c:1037
stream is being configured
Definition: stream.h:175
no flags
Definition: stream.h:211
pw_direction
The direction of a port.
Definition: introspect.h:47
void pw_stream_disconnect(struct pw_stream *stream)
Definition: stream.c:990