PipeWire 0.3.65
introspect-funcs.h
Go to the documentation of this file.
1/* PipeWire
2 *
3 * Copyright © 2020 Collabora Ltd.
4 * @author George Kiagiadakis <george.kiagiadakis@collabora.com>
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
15 * Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 * DEALINGS IN THE SOFTWARE.
24 */
25
26#ifndef PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H
27#define PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H
28
29#include "introspect.h"
30#include <spa/pod/builder.h>
31#include <pipewire/pipewire.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
42static inline struct pw_session_info *
44 const struct pw_session_info *update)
45{
46 struct extended_info {
47 struct pw_properties *props_storage;
48 struct pw_session_info info;
49 } *ext;
50
51 if (update == NULL)
52 return info;
53
54 if (info == NULL) {
55 ext = (struct extended_info *) calloc(1, sizeof(*ext));
56 if (ext == NULL)
57 return NULL;
58
59 info = &ext->info;
60 info->id = update->id;
61 } else {
62 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
63 }
64
65 info->change_mask = update->change_mask;
66
68 if (!ext->props_storage) {
69 ext->props_storage = pw_properties_new(NULL, NULL);
70 info->props = &ext->props_storage->dict;
71 }
72 pw_properties_clear(ext->props_storage);
73 pw_properties_update(ext->props_storage, update->props);
74 }
76 info->n_params = update->n_params;
77 free((void *) info->params);
78 if (update->params) {
79 size_t size = info->n_params * sizeof(struct spa_param_info);
80 info->params = (struct spa_param_info *) malloc(size);
81 memcpy(info->params, update->params, size);
82 }
83 else
84 info->params = NULL;
85 }
86 return info;
87}
88
89static inline void
91{
92 struct extended_info {
93 struct pw_properties *props_storage;
94 struct pw_session_info info;
95 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
96
97 pw_properties_free(ext->props_storage);
98 free((void *) info->params);
99 free(ext);
100}
101
102static inline struct pw_endpoint_info *
104 const struct pw_endpoint_info *update)
105{
106 struct extended_info {
107 struct pw_properties *props_storage;
108 struct pw_endpoint_info info;
109 } *ext;
110
111 if (update == NULL)
112 return info;
113
114 if (info == NULL) {
115 ext = (struct extended_info *) calloc(1, sizeof(*ext));
116 if (ext == NULL)
117 return NULL;
118
119 info = &ext->info;
120 info->id = update->id;
121 info->name = strdup(update->name);
122 info->media_class = strdup(update->media_class);
123 info->direction = update->direction;
124 info->flags = update->flags;
125 } else {
126 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
127 }
128
129 info->change_mask = update->change_mask;
130
132 info->n_streams = update->n_streams;
133
135 info->session_id = update->session_id;
136
138 if (!ext->props_storage) {
139 ext->props_storage = pw_properties_new(NULL, NULL);
140 info->props = &ext->props_storage->dict;
141 }
142 pw_properties_clear(ext->props_storage);
143 pw_properties_update(ext->props_storage, update->props);
144 }
146 info->n_params = update->n_params;
147 free((void *) info->params);
148 if (update->params) {
149 size_t size = info->n_params * sizeof(struct spa_param_info);
150 info->params = (struct spa_param_info *) malloc(size);
151 memcpy(info->params, update->params, size);
152 }
153 else
154 info->params = NULL;
155 }
156 return info;
157}
158
159static inline void
161{
162 struct extended_info {
163 struct pw_properties *props_storage;
164 struct pw_endpoint_info info;
165 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
166
167 pw_properties_free(ext->props_storage);
168 free(info->name);
169 free(info->media_class);
170 free((void *) info->params);
171 free(ext);
172}
173
174static inline struct pw_endpoint_stream_info *
176 const struct pw_endpoint_stream_info *update)
177{
178 struct extended_info {
179 struct pw_properties *props_storage;
180 struct pw_endpoint_stream_info info;
181 } *ext;
182
183 if (update == NULL)
184 return info;
185
186 if (info == NULL) {
187 ext = (struct extended_info *) calloc(1, sizeof(*ext));
188 if (ext == NULL)
189 return NULL;
190
191 info = &ext->info;
192 info->id = update->id;
193 info->endpoint_id = update->endpoint_id;
194 info->name = strdup(update->name);
195 } else {
196 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
197 }
198
199 info->change_mask = update->change_mask;
200
202 free(info->link_params);
203 info->link_params = update->link_params ?
204 spa_pod_copy(update->link_params) : NULL;
205 }
207 if (!ext->props_storage) {
208 ext->props_storage = pw_properties_new(NULL, NULL);
209 info->props = &ext->props_storage->dict;
210 }
211 pw_properties_clear(ext->props_storage);
212 pw_properties_update(ext->props_storage, update->props);
213 }
215 info->n_params = update->n_params;
216 free((void *) info->params);
217 if (update->params) {
218 size_t size = info->n_params * sizeof(struct spa_param_info);
219 info->params = (struct spa_param_info *) malloc(size);
220 memcpy(info->params, update->params, size);
221 }
222 else
223 info->params = NULL;
224 }
225 return info;
226}
227
228static inline void
230{
231 struct extended_info {
232 struct pw_properties *props_storage;
234 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
235
236 pw_properties_free(ext->props_storage);
237 free(info->name);
238 free(info->link_params);
239 free((void *) info->params);
240 free(ext);
241}
242
243
244static inline struct pw_endpoint_link_info *
246 const struct pw_endpoint_link_info *update)
247{
248 struct extended_info {
249 struct pw_properties *props_storage;
250 struct pw_endpoint_link_info info;
251 } *ext;
252
253 if (update == NULL)
254 return info;
255
256 if (info == NULL) {
257 ext = (struct extended_info *) calloc(1, sizeof(*ext));
258 if (ext == NULL)
259 return NULL;
260
261 info = &ext->info;
262 info->id = update->id;
263 info->session_id = update->session_id;
265 info->output_stream_id = update->output_stream_id;
266 info->input_endpoint_id = update->input_endpoint_id;
267 info->input_stream_id = update->input_stream_id;
268 } else {
269 ext = SPA_CONTAINER_OF(info, struct extended_info, info);
270 }
271
272 info->change_mask = update->change_mask;
273
275 info->state = update->state;
276 free(info->error);
277 info->error = update->error ? strdup(update->error) : NULL;
278 }
280 if (!ext->props_storage) {
281 ext->props_storage = pw_properties_new(NULL, NULL);
282 info->props = &ext->props_storage->dict;
283 }
284 pw_properties_clear(ext->props_storage);
285 pw_properties_update(ext->props_storage, update->props);
286 }
288 info->n_params = update->n_params;
289 free((void *) info->params);
290 if (update->params) {
291 size_t size = info->n_params * sizeof(struct spa_param_info);
292 info->params = (struct spa_param_info *) malloc(size);
293 memcpy(info->params, update->params, size);
294 }
295 else
296 info->params = NULL;
297 }
298 return info;
299}
300
301static inline void
303{
304 struct extended_info {
305 struct pw_properties *props_storage;
307 } *ext = SPA_CONTAINER_OF(info, struct extended_info, info);
308
309 pw_properties_free(ext->props_storage);
310 free(info->error);
311 free((void *) info->params);
312 free(ext);
313}
314
319#ifdef __cplusplus
320} /* extern "C" */
321#endif
322
323#endif /* PIPEWIRE_EXT_SESSION_MANAGER_INTROSPECT_FUNCS_H */
spa/pod/builder.h
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:368
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:102
int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:302
void pw_properties_clear(struct pw_properties *properties)
Clear a properties object.
Definition: properties.c:281
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PARAMS
Definition: introspect.h:111
static void pw_endpoint_info_free(struct pw_endpoint_info *info)
Definition: introspect-funcs.h:164
#define PW_SESSION_CHANGE_MASK_PROPS
Definition: introspect.h:59
#define PW_ENDPOINT_CHANGE_MASK_SESSION
Definition: introspect.h:84
#define PW_ENDPOINT_STREAM_CHANGE_MASK_PROPS
Definition: introspect.h:109
#define PW_ENDPOINT_CHANGE_MASK_STREAMS
Definition: introspect.h:82
static void pw_session_info_free(struct pw_session_info *info)
Definition: introspect-funcs.h:94
static struct pw_session_info * pw_session_info_update(struct pw_session_info *info, const struct pw_session_info *update)
Definition: introspect-funcs.h:47
#define PW_ENDPOINT_CHANGE_MASK_PROPS
Definition: introspect.h:86
#define PW_ENDPOINT_LINK_CHANGE_MASK_PARAMS
Definition: introspect.h:136
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:179
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:249
#define PW_ENDPOINT_CHANGE_MASK_PARAMS
Definition: introspect.h:88
#define PW_ENDPOINT_LINK_CHANGE_MASK_PROPS
Definition: introspect.h:134
#define PW_SESSION_CHANGE_MASK_PARAMS
Definition: introspect.h:61
static void pw_endpoint_stream_info_free(struct pw_endpoint_stream_info *info)
Definition: introspect-funcs.h:233
static void pw_endpoint_link_info_free(struct pw_endpoint_link_info *info)
Definition: introspect-funcs.h:306
#define PW_ENDPOINT_STREAM_CHANGE_MASK_LINK_PARAMS
Definition: introspect.h:107
static struct pw_endpoint_info * pw_endpoint_info_update(struct pw_endpoint_info *info, const struct pw_endpoint_info *update)
Definition: introspect-funcs.h:107
#define PW_ENDPOINT_LINK_CHANGE_MASK_STATE
Definition: introspect.h:132
static struct spa_pod * spa_pod_copy(const struct spa_pod *pod)
Copy a pod structure.
Definition: builder.h:708
#define SPA_CONTAINER_OF(p, t, m)
Definition: defs.h:224
pipewire/extensions/session-manager/introspect.h
pipewire/pipewire.h
Definition: introspect.h:70
struct spa_param_info * params
parameters
Definition: introspect.h:95
uint32_t id
the endpoint id (global)
Definition: introspect.h:74
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:91
enum pw_direction direction
direction of the endpoint
Definition: introspect.h:77
uint32_t n_params
number of items in params
Definition: introspect.h:96
uint32_t flags
additional flags
Definition: introspect.h:80
char * media_class
media class of the endpoint
Definition: introspect.h:76
uint32_t session_id
the id of the controlling session
Definition: introspect.h:93
uint32_t n_streams
number of streams available
Definition: introspect.h:92
Definition: introspect.h:99
uint32_t n_params
number of items in params
Definition: introspect.h:118
struct spa_param_info * params
parameters
Definition: introspect.h:117
uint32_t endpoint_id
the endpoint id (global)
Definition: introspect.h:104
struct spa_pod * link_params
information for linking this stream
Definition: introspect.h:115
uint32_t id
the stream id (local or global)
Definition: introspect.h:103
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:114
Definition: properties.h:53
Definition: introspect.h:53
struct spa_param_info * params
parameters
Definition: introspect.h:66
uint64_t change_mask
bitfield of changed fields since last call
Definition: introspect.h:64
uint32_t id
the session id (global)
Definition: introspect.h:57
uint32_t n_params
number of items in params
Definition: introspect.h:67
information about a parameter
Definition: param.h:70