PipeWire 1.6.5

Loading...
Searching...
No Matches
introspect-funcs.h
Go to the documentation of this file.
1/* PipeWire */
2/* SPDX-FileCopyrightText: Copyright © 2020 Collabora Ltd. */
3/* @author George Kiagiadakis <george.kiagiadakis@collabora.com> */
4/* SPDX-License-Identifier: MIT */
5
6#ifndef PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H
7#define PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H
8
9#include "introspect.h"
10#include <spa/pod/builder.h>
11#include <pipewire/pipewire.h>
12
13#ifdef __cplusplus
14 extern "C" {
15#endif
16
21
22 static inline struct pw_session_info *
23 pw_session_info_update (struct pw_session_info *info,
24 const struct pw_session_info *update)
25{
26 struct extended_info {
27 struct pw_properties *props_storage;
28 struct pw_session_info info;
29 } *ext;
30
31 if (update == NULL)
32 return info;
33
34 if (info == NULL) {
35 ext = (struct extended_info *) calloc(1, sizeof(*ext));
36 if (ext == NULL)
37 return NULL;
38
39 info = &ext->info;
40 info->id = update->id;
41 } else {
42 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
43 }
44
45 info->change_mask = update->change_mask;
46
47 if (update->change_mask & PW_SESSION_CHANGE_MASK_PROPS) {
48 if (!ext->props_storage) {
49 ext->props_storage = pw_properties_new(NULL, NULL);
50 info->props = &ext->props_storage->dict;
51 }
52 pw_properties_clear(ext->props_storage);
53 pw_properties_update(ext->props_storage, update->props);
54 }
55 if (update->change_mask & PW_SESSION_CHANGE_MASK_PARAMS) {
56 info->n_params = update->n_params;
57 free((void *) info->params);
58 if (update->params) {
59 size_t size = info->n_params * sizeof(struct spa_param_info);
60 info->params = (struct spa_param_info *) malloc(size);
61 memcpy(info->params, update->params, size);
62 }
63 else
64 info->params = NULL;
65 }
66 return info;
67}
68
69 static inline void
70 pw_session_info_free (struct pw_session_info *info)
71{
72 struct extended_info {
73 struct pw_properties *props_storage;
74 struct pw_session_info info;
75 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
76
77 pw_properties_free(ext->props_storage);
78 free((void *) info->params);
79 free(ext);
80}
81
82 static inline struct pw_endpoint_info *
83 pw_endpoint_info_update (struct pw_endpoint_info *info,
84 const struct pw_endpoint_info *update)
85{
86 struct extended_info {
87 struct pw_properties *props_storage;
88 struct pw_endpoint_info info;
89 } *ext;
90
91 if (update == NULL)
92 return info;
93
94 if (info == NULL) {
95 ext = (struct extended_info *) calloc(1, sizeof(*ext));
96 if (ext == NULL)
97 return NULL;
98
99 info = &ext->info;
100 info->id = update->id;
101 info->name = strdup(update->name);
102 info->media_class = strdup(update->media_class);
103 info->direction = update->direction;
104 info->flags = update->flags;
105 } else {
106 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
107 }
108
109 info->change_mask = update->change_mask;
110
111 if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_STREAMS)
112 info->n_streams = update->n_streams;
113
114 if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_SESSION)
115 info->session_id = update->session_id;
116
117 if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PROPS) {
118 if (!ext->props_storage) {
119 ext->props_storage = pw_properties_new(NULL, NULL);
120 info->props = &ext->props_storage->dict;
121 }
122 pw_properties_clear(ext->props_storage);
123 pw_properties_update(ext->props_storage, update->props);
124 }
125 if (update->change_mask & PW_ENDPOINT_CHANGE_MASK_PARAMS) {
126 info->n_params = update->n_params;
127 free((void *) info->params);
128 if (update->params) {
129 size_t size = info->n_params * sizeof(struct spa_param_info);
130 info->params = (struct spa_param_info *) malloc(size);
131 memcpy(info->params, update->params, size);
132 }
133 else
134 info->params = NULL;
135 }
136 return info;
137}
138
139 static inline void
140 pw_endpoint_info_free (struct pw_endpoint_info *info)
141{
142 struct extended_info {
143 struct pw_properties *props_storage;
144 struct pw_endpoint_info info;
145 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
146
147 pw_properties_free(ext->props_storage);
148 free(info->name);
149 free(info->media_class);
150 free((void *) info->params);
151 free(ext);
152}
153
154 static inline struct pw_endpoint_stream_info *
155 pw_endpoint_stream_info_update (struct pw_endpoint_stream_info *info,
156 const struct pw_endpoint_stream_info *update)
157{
158 struct extended_info {
159 struct pw_properties *props_storage;
160 struct pw_endpoint_stream_info info;
161 } *ext;
162
163 if (update == NULL)
164 return info;
165
166 if (info == NULL) {
167 ext = (struct extended_info *) calloc(1, sizeof(*ext));
168 if (ext == NULL)
169 return NULL;
170
171 info = &ext->info;
172 info->id = update->id;
173 info->endpoint_id = update->endpoint_id;
174 info->name = strdup(update->name);
175 } else {
176 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
177 }
178
179 info->change_mask = update->change_mask;
180
181 if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS) {
182 free(info->link_params);
183 info->link_params = update->link_params ?
184 spa_pod_copy(update->link_params) : NULL;
185 }
186 if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS) {
187 if (!ext->props_storage) {
188 ext->props_storage = pw_properties_new(NULL, NULL);
189 info->props = &ext->props_storage->dict;
190 }
191 pw_properties_clear(ext->props_storage);
192 pw_properties_update(ext->props_storage, update->props);
193 }
194 if (update->change_mask & PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS) {
195 info->n_params = update->n_params;
196 free((void *) info->params);
197 if (update->params) {
198 size_t size = info->n_params * sizeof(struct spa_param_info);
199 info->params = (struct spa_param_info *) malloc(size);
200 memcpy(info->params, update->params, size);
201 }
202 else
203 info->params = NULL;
204 }
205 return info;
206}
207
208 static inline void
209 pw_endpoint_stream_info_free (struct pw_endpoint_stream_info *info)
210{
211 struct extended_info {
212 struct pw_properties *props_storage;
213 struct pw_endpoint_stream_info info;
214 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
215
216 pw_properties_free(ext->props_storage);
217 free(info->name);
218 free(info->link_params);
219 free((void *) info->params);
220 free(ext);
221}
222
223
224 static inline struct pw_endpoint_link_info *
225 pw_endpoint_link_info_update (struct pw_endpoint_link_info *info,
226 const struct pw_endpoint_link_info *update)
227{
228 struct extended_info {
229 struct pw_properties *props_storage;
230 struct pw_endpoint_link_info info;
231 } *ext;
232
233 if (update == NULL)
234 return info;
235
236 if (info == NULL) {
237 ext = (struct extended_info *) calloc(1, sizeof(*ext));
238 if (ext == NULL)
239 return NULL;
240
241 info = &ext->info;
242 info->id = update->id;
243 info->session_id = update->session_id;
244 info->output_endpoint_id = update->output_endpoint_id;
245 info->output_stream_id = update->output_stream_id;
246 info->input_endpoint_id = update->input_endpoint_id;
247 info->input_stream_id = update->input_stream_id;
248 } else {
249 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
250 }
251
252 info->change_mask = update->change_mask;
253
254 if (update->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_STATE) {
255 info->state = update->state;
256 free(info->error);
257 info->error = update->error ? strdup(update->error) : NULL;
258 }
259 if (update->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_PROPS) {
260 if (!ext->props_storage) {
261 ext->props_storage = pw_properties_new(NULL, NULL);
262 info->props = &ext->props_storage->dict;
263 }
264 pw_properties_clear(ext->props_storage);
265 pw_properties_update(ext->props_storage, update->props);
266 }
267 if (update->change_mask & PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS) {
268 info->n_params = update->n_params;
269 free((void *) info->params);
270 if (update->params) {
271 size_t size = info->n_params * sizeof(struct spa_param_info);
272 info->params = (struct spa_param_info *) malloc(size);
273 memcpy(info->params, update->params, size);
274 }
275 else
276 info->params = NULL;
277 }
278 return info;
279}
280
281 static inline void
282 pw_endpoint_link_info_free (struct pw_endpoint_link_info *info)
283{
284 struct extended_info {
285 struct pw_properties *props_storage;
286 struct pw_endpoint_link_info info;
287 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
288
289 pw_properties_free(ext->props_storage);
290 free(info->error);
291 free((void *) info->params);
292 free(ext);
293}
294
298
299#ifdef __cplusplus
300} /* extern "C" */
301#endif
302
303#endif /* PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H */
builder.h
spa/pod/builder.h
pw_properties_free
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition properties.c:559
pw_properties_new
struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition properties.c:97
pw_properties_update
int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition properties.c:478
pw_properties_clear
void pw_properties_clear(struct pw_properties *properties)
Clear a properties object.
Definition properties.c:457
PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS
Definition introspect.h:91
pw_endpoint_info_free
static void pw_endpoint_info_free(struct pw_endpoint_info *info)
Definition introspect-funcs.h:144
PW_SESSION_CHANGE_MASK_PROPS
#define PW_SESSION_CHANGE_MASK_PROPS
Definition introspect.h:39
PW_ENDPOINT_CHANGE_MASK_SESSION
#define PW_ENDPOINT_CHANGE_MASK_SESSION
Definition introspect.h:64
PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS
Definition introspect.h:89
PW_ENDPOINT_CHANGE_MASK_STREAMS
#define PW_ENDPOINT_CHANGE_MASK_STREAMS
Definition introspect.h:62
pw_session_info_free
static void pw_session_info_free(struct pw_session_info *info)
Definition introspect-funcs.h:74
pw_session_info_update
static struct pw_session_info * pw_session_info_update(struct pw_session_info *info, const struct pw_session_info *update)
Definition introspect-funcs.h:27
PW_ENDPOINT_CHANGE_MASK_PROPS
#define PW_ENDPOINT_CHANGE_MASK_PROPS
Definition introspect.h:66
PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS
#define PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS
Definition introspect.h:116
pw_endpoint_stream_info_update
static struct pw_endpoint_stream_info * pw_endpoint_stream_info_update(struct pw_endpoint_stream_info *info, const struct pw_endpoint_stream_info *update)
Definition introspect-funcs.h:159
pw_endpoint_link_info_update
static struct pw_endpoint_link_info * pw_endpoint_link_info_update(struct pw_endpoint_link_info *info, const struct pw_endpoint_link_info *update)
Definition introspect-funcs.h:229
PW_ENDPOINT_CHANGE_MASK_PARAMS
#define PW_ENDPOINT_CHANGE_MASK_PARAMS
Definition introspect.h:68
PW_ENDPOINT_LINK_CHANGE_MASK_PROPS
#define PW_ENDPOINT_LINK_CHANGE_MASK_PROPS
Definition introspect.h:114
PW_SESSION_CHANGE_MASK_PARAMS
#define PW_SESSION_CHANGE_MASK_PARAMS
Definition introspect.h:41
pw_endpoint_stream_info_free
static void pw_endpoint_stream_info_free(struct pw_endpoint_stream_info *info)
Definition introspect-funcs.h:213
pw_endpoint_link_info_free
static void pw_endpoint_link_info_free(struct pw_endpoint_link_info *info)
Definition introspect-funcs.h:286
PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS
#define PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS
Definition introspect.h:87
pw_endpoint_info_update
static struct pw_endpoint_info * pw_endpoint_info_update(struct pw_endpoint_info *info, const struct pw_endpoint_info *update)
Definition introspect-funcs.h:87
PW_ENDPOINT_LINK_CHANGE_MASK_STATE
#define PW_ENDPOINT_LINK_CHANGE_MASK_STATE
Definition introspect.h:112
spa_pod_copy
SPA_API_POD_BUILDER struct spa_pod * spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure.
Definition builder.h:754
SPA_CONTAINER_OF
#define SPA_CONTAINER_OF(p, t, m)
Definition defs.h:235
introspect.h
pipewire/extensions/session-manager/introspect.h
pipewire.h
pipewire/pipewire.h
pw_endpoint_info
Definition introspect.h:50
pw_endpoint_info::params
struct spa_param_info * params
parameters
Definition introspect.h:75
pw_endpoint_info::id
uint32_t id
the endpoint id (global)
Definition introspect.h:54
pw_endpoint_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition introspect.h:71
pw_endpoint_info::direction
enum pw_direction direction
direction of the endpoint
Definition introspect.h:57
pw_endpoint_info::n_params
uint32_t n_params
number of items in params
Definition introspect.h:76
pw_endpoint_info::flags
uint32_t flags
additional flags
Definition introspect.h:60
pw_endpoint_info::media_class
char * media_class
media class of the endpoint
Definition introspect.h:56
pw_endpoint_info::session_id
uint32_t session_id
the id of the controlling session
Definition introspect.h:73
pw_endpoint_info::n_streams
uint32_t n_streams
number of streams available
Definition introspect.h:72
pw_endpoint_link_info
Definition introspect.h:101
pw_endpoint_link_info::id
uint32_t id
the link id (global)
Definition introspect.h:105
pw_endpoint_link_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition introspect.h:119
pw_endpoint_link_info::output_endpoint_id
uint32_t output_endpoint_id
the output endpoint id (global)
Definition introspect.h:107
pw_endpoint_link_info::input_endpoint_id
uint32_t input_endpoint_id
the input endpoint id (global)
Definition introspect.h:109
pw_endpoint_link_info::error
char * error
error string if state == ERROR
Definition introspect.h:121
pw_endpoint_link_info::params
struct spa_param_info * params
parameters
Definition introspect.h:123
pw_endpoint_link_info::state
enum pw_endpoint_link_state state
the state of the link
Definition introspect.h:120
pw_endpoint_link_info::n_params
uint32_t n_params
number of items in params
Definition introspect.h:124
pw_endpoint_link_info::output_stream_id
uint32_t output_stream_id
the output stream id (local or global)
Definition introspect.h:108
pw_endpoint_link_info::input_stream_id
uint32_t input_stream_id
the input stream id (local or global)
Definition introspect.h:110
pw_endpoint_link_info::session_id
uint32_t session_id
the session id (global)
Definition introspect.h:106
pw_endpoint_stream_info
Definition introspect.h:79
pw_endpoint_stream_info::n_params
uint32_t n_params
number of items in params
Definition introspect.h:98
pw_endpoint_stream_info::params
struct spa_param_info * params
parameters
Definition introspect.h:97
pw_endpoint_stream_info::endpoint_id
uint32_t endpoint_id
the endpoint id (global)
Definition introspect.h:84
pw_endpoint_stream_info::link_params
struct spa_pod * link_params
information for linking this stream
Definition introspect.h:95
pw_endpoint_stream_info::id
uint32_t id
the stream id (local or global)
Definition introspect.h:83
pw_endpoint_stream_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition introspect.h:94
pw_properties
Definition properties.h:39
pw_session_info
Definition introspect.h:33
pw_session_info::params
struct spa_param_info * params
parameters
Definition introspect.h:46
pw_session_info::change_mask
uint64_t change_mask
bitfield of changed fields since last call
Definition introspect.h:44
pw_session_info::id
uint32_t id
the session id (global)
Definition introspect.h:37
pw_session_info::n_params
uint32_t n_params
number of items in params
Definition introspect.h:47
spa_param_info
information about a parameter
Definition param.h:56