PipeWire  0.3.51
port.h
Go to the documentation of this file.
1 /* PipeWire
2  *
3  * Copyright © 2018 Wim Taymans
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 
25 #ifndef PIPEWIRE_PORT_H
26 #define PIPEWIRE_PORT_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <stdarg.h>
33 #include <errno.h>
34 
35 #include <spa/utils/defs.h>
36 #include <spa/utils/hook.h>
37 #include <spa/param/param.h>
38 
39 #include <pipewire/proxy.h>
40 
50 #define PW_TYPE_INTERFACE_Port PW_TYPE_INFO_INTERFACE_BASE "Port"
51 
52 #define PW_VERSION_PORT 3
53 struct pw_port;
54 
56 #define pw_direction spa_direction
57 #define PW_DIRECTION_INPUT SPA_DIRECTION_INPUT
58 #define PW_DIRECTION_OUTPUT SPA_DIRECTION_OUTPUT
59 
61 const char * pw_direction_as_string(enum pw_direction direction);
62 
63 struct pw_port_info {
64  uint32_t id;
66 #define PW_PORT_CHANGE_MASK_PROPS (1 << 0)
67 #define PW_PORT_CHANGE_MASK_PARAMS (1 << 1)
68 #define PW_PORT_CHANGE_MASK_ALL ((1 << 2)-1)
69  uint64_t change_mask;
70  struct spa_dict *props;
71  struct spa_param_info *params;
72  uint32_t n_params;
73 };
74 
75 struct pw_port_info *
77  const struct pw_port_info *update);
78 
79 struct pw_port_info *
81  const struct pw_port_info *update, bool reset);
82 
83 void
85 
86 #define PW_PORT_EVENT_INFO 0
87 #define PW_PORT_EVENT_PARAM 1
88 #define PW_PORT_EVENT_NUM 2
89 
91 struct pw_port_events {
92 #define PW_VERSION_PORT_EVENTS 0
93  uint32_t version;
99  void (*info) (void *data, const struct pw_port_info *info);
111  void (*param) (void *data, int seq,
112  uint32_t id, uint32_t index, uint32_t next,
113  const struct spa_pod *param);
114 };
115 
116 #define PW_PORT_METHOD_ADD_LISTENER 0
117 #define PW_PORT_METHOD_SUBSCRIBE_PARAMS 1
118 #define PW_PORT_METHOD_ENUM_PARAMS 2
119 #define PW_PORT_METHOD_NUM 3
120 
122 struct pw_port_methods {
123 #define PW_VERSION_PORT_METHODS 0
124  uint32_t version;
125 
126  int (*add_listener) (void *object,
127  struct spa_hook *listener,
128  const struct pw_port_events *events,
129  void *data);
139  int (*subscribe_params) (void *object, uint32_t *ids, uint32_t n_ids);
140 
153  int (*enum_params) (void *object, int seq,
154  uint32_t id, uint32_t start, uint32_t num,
155  const struct spa_pod *filter);
156 };
157 
158 #define pw_port_method(o,method,version,...) \
159 ({ \
160  int _res = -ENOTSUP; \
161  spa_interface_call_res((struct spa_interface*)o, \
162  struct pw_port_methods, _res, \
163  method, version, ##__VA_ARGS__); \
164  _res; \
165 })
166 
167 #define pw_port_add_listener(c,...) pw_port_method(c,add_listener,0,__VA_ARGS__)
168 #define pw_port_subscribe_params(c,...) pw_port_method(c,subscribe_params,0,__VA_ARGS__)
169 #define pw_port_enum_params(c,...) pw_port_method(c,enum_params,0,__VA_ARGS__)
170 
175 #ifdef __cplusplus
176 } /* extern "C" */
177 #endif
178 
179 #endif /* PIPEWIRE_PORT_H */
spa/utils/defs.h
const char * pw_direction_as_string(enum pw_direction direction)
Convert a pw_direction to a readable string.
Definition: introspect.c:52
void pw_port_info_free(struct pw_port_info *info)
Definition: introspect.c:318
struct pw_port_info * pw_port_info_merge(struct pw_port_info *info, const struct pw_port_info *update, bool reset)
Definition: introspect.c:258
#define pw_direction
The direction of a port.
Definition: port.h:63
struct pw_port_info * pw_port_info_update(struct pw_port_info *info, const struct pw_port_info *update)
Definition: introspect.c:311
spa/utils/hook.h
spa/param/param.h
pipewire/proxy.h
Port events.
Definition: port.h:106
void(* info)(void *data, const struct pw_port_info *info)
Notify port info.
Definition: port.h:115
uint32_t version
Definition: port.h:109
void(* param)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, const struct spa_pod *param)
Notify a port param.
Definition: port.h:127
Definition: port.h:72
uint32_t n_params
number of items in params
Definition: port.h:84
struct spa_param_info * params
parameters
Definition: port.h:83
uint64_t change_mask
bitfield of changed fields since last call
Definition: port.h:81
uint32_t id
id of the global
Definition: port.h:73
enum pw_direction direction
port direction
Definition: port.h:74
Port methods.
Definition: port.h:142
int(* subscribe_params)(void *object, uint32_t *ids, uint32_t n_ids)
Subscribe to parameter changes.
Definition: port.h:160
uint32_t version
Definition: port.h:145
int(* enum_params)(void *object, int seq, uint32_t id, uint32_t start, uint32_t num, const struct spa_pod *filter)
Enumerate port parameters.
Definition: port.h:174
int(* add_listener)(void *object, struct spa_hook *listener, const struct pw_port_events *events, void *data)
Definition: port.h:147
Definition: dict.h:59
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:351
information about a parameter
Definition: param.h:70
Definition: pod.h:63