PipeWire 1.4.10

Loading...
Searching...
No Matches
parser.h
Go to the documentation of this file.
1/* Spa */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_POD_PARSER_H
6#define SPA_POD_PARSER_H
7
8#ifdef __cplusplus
9 extern "C" {
10#endif
11
12#include <errno.h>
13#include <stdarg.h>
14
15#include <spa/pod/iter.h>
16#include <spa/pod/vararg.h>
17
18#ifndef SPA_API_POD_PARSER
19 #ifdef SPA_API_IMPL
20 #define SPA_API_POD_PARSER SPA_API_IMPL
21 #else
22 #define SPA_API_POD_PARSER static inline
23 #endif
24#endif
25
30
31 struct spa_pod_parser_state {
32 uint32_t offset;
33 uint32_t flags;
34 struct spa_pod_frame *frame;
35};
36
37 struct spa_pod_parser {
38 const void *data;
39 uint32_t size;
40 uint32_t _padding;
41 struct spa_pod_parser_state state;
42};
43
44#define SPA_POD_PARSER_INIT(buffer,size) ((struct spa_pod_parser){ (buffer), (size), 0, {0,0,NULL}})
45
46 SPA_API_POD_PARSER void spa_pod_parser_init(struct spa_pod_parser *parser,
47 const void *data, uint32_t size)
48{
49 *parser = SPA_POD_PARSER_INIT(data, size);
50}
51
52 SPA_API_POD_PARSER void spa_pod_parser_pod(struct spa_pod_parser *parser,
53 const struct spa_pod *pod)
54{
55 spa_pod_parser_init(parser, pod, SPA_POD_SIZE(pod));
56}
57
58 SPA_API_POD_PARSER void
59 spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
60{
61 *state = parser->state;
62}
63
64 SPA_API_POD_PARSER void
65 spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
66{
67 parser->state = *state;
68}
69
70 SPA_API_POD_PARSER struct spa_pod *
71 spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
72{
73 /* Cast to uint64_t to avoid wraparound. Add 8 for the pod itself. */
74 const uint64_t long_offset = (uint64_t)offset + 8;
75 if (long_offset <= size && (offset & 7) == 0) {
76 /* Use void* because creating a misaligned pointer is undefined. */
77 void *pod = SPA_PTROFF(parser->data, offset, void);
78 /*
79 * Check that the pointer is aligned and that the size (rounded
80 * to the next multiple of 8) is in bounds.
81 */
82 if (SPA_IS_ALIGNED(pod, __alignof__(struct spa_pod)) &&
83 long_offset + SPA_ROUND_UP_N((uint64_t)SPA_POD_BODY_SIZE(pod), 8) <= size)
84 return (struct spa_pod *)pod;
85 }
86 return NULL;
87}
88
89 SPA_API_POD_PARSER struct spa_pod *spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
90{
91 return SPA_PTROFF(parser->data, frame->offset, struct spa_pod);
92}
93
94 SPA_API_POD_PARSER void spa_pod_parser_push(struct spa_pod_parser *parser,
95 struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset)
96{
97 frame->pod = *pod;
98 frame->offset = offset;
99 frame->parent = parser->state.frame;
100 frame->flags = parser->state.flags;
101 parser->state.frame = frame;
102}
103
104 SPA_API_POD_PARSER struct spa_pod *spa_pod_parser_current(struct spa_pod_parser *parser)
105{
106 struct spa_pod_frame *f = parser->state.frame;
107 uint32_t size = f ? f->offset + SPA_POD_SIZE(&f->pod) : parser->size;
108 return spa_pod_parser_deref(parser, parser->state.offset, size);
109}
110
111 SPA_API_POD_PARSER void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)
112{
113 parser->state.offset += SPA_ROUND_UP_N(SPA_POD_SIZE(pod), 8);
114}
115
116 SPA_API_POD_PARSER struct spa_pod *spa_pod_parser_next(struct spa_pod_parser *parser)
117{
118 struct spa_pod *pod = spa_pod_parser_current(parser);
119 if (pod)
120 spa_pod_parser_advance(parser, pod);
121 return pod;
122}
123
124 SPA_API_POD_PARSER int spa_pod_parser_pop(struct spa_pod_parser *parser,
125 struct spa_pod_frame *frame)
126{
127 parser->state.frame = frame->parent;
128 parser->state.offset = frame->offset + SPA_ROUND_UP_N(SPA_POD_SIZE(&frame->pod), 8);
129 return 0;
130}
131
132 SPA_API_POD_PARSER int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)
133{
134 int res = -EPIPE;
135 const struct spa_pod *pod = spa_pod_parser_current(parser);
136 if (pod != NULL && (res = spa_pod_get_bool(pod, value)) >= 0)
137 spa_pod_parser_advance(parser, pod);
138 return res;
139}
140
141 SPA_API_POD_PARSER int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)
142{
143 int res = -EPIPE;
144 const struct spa_pod *pod = spa_pod_parser_current(parser);
145 if (pod != NULL && (res = spa_pod_get_id(pod, value)) >= 0)
146 spa_pod_parser_advance(parser, pod);
147 return res;
148}
149
150 SPA_API_POD_PARSER int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)
151{
152 int res = -EPIPE;
153 const struct spa_pod *pod = spa_pod_parser_current(parser);
154 if (pod != NULL && (res = spa_pod_get_int(pod, value)) >= 0)
155 spa_pod_parser_advance(parser, pod);
156 return res;
157}
158
159 SPA_API_POD_PARSER int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)
160{
161 int res = -EPIPE;
162 const struct spa_pod *pod = spa_pod_parser_current(parser);
163 if (pod != NULL && (res = spa_pod_get_long(pod, value)) >= 0)
164 spa_pod_parser_advance(parser, pod);
165 return res;
166}
167
168 SPA_API_POD_PARSER int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)
169{
170 int res = -EPIPE;
171 const struct spa_pod *pod = spa_pod_parser_current(parser);
172 if (pod != NULL && (res = spa_pod_get_float(pod, value)) >= 0)
173 spa_pod_parser_advance(parser, pod);
174 return res;
175}
176
177 SPA_API_POD_PARSER int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)
178{
179 int res = -EPIPE;
180 const struct spa_pod *pod = spa_pod_parser_current(parser);
181 if (pod != NULL && (res = spa_pod_get_double(pod, value)) >= 0)
182 spa_pod_parser_advance(parser, pod);
183 return res;
184}
185
186 SPA_API_POD_PARSER int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)
187{
188 int res = -EPIPE;
189 const struct spa_pod *pod = spa_pod_parser_current(parser);
190 if (pod != NULL && (res = spa_pod_get_string(pod, value)) >= 0)
191 spa_pod_parser_advance(parser, pod);
192 return res;
193}
194
195 SPA_API_POD_PARSER int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)
196{
197 int res = -EPIPE;
198 const struct spa_pod *pod = spa_pod_parser_current(parser);
199 if (pod != NULL && (res = spa_pod_get_bytes(pod, value, len)) >= 0)
200 spa_pod_parser_advance(parser, pod);
201 return res;
202}
203
204 SPA_API_POD_PARSER int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)
205{
206 int res = -EPIPE;
207 const struct spa_pod *pod = spa_pod_parser_current(parser);
208 if (pod != NULL && (res = spa_pod_get_pointer(pod, type, value)) >= 0)
209 spa_pod_parser_advance(parser, pod);
210 return res;
211}
212
213 SPA_API_POD_PARSER int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)
214{
215 int res = -EPIPE;
216 const struct spa_pod *pod = spa_pod_parser_current(parser);
217 if (pod != NULL && (res = spa_pod_get_fd(pod, value)) >= 0)
218 spa_pod_parser_advance(parser, pod);
219 return res;
220}
221
222 SPA_API_POD_PARSER int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)
223{
224 int res = -EPIPE;
225 const struct spa_pod *pod = spa_pod_parser_current(parser);
226 if (pod != NULL && (res = spa_pod_get_rectangle(pod, value)) >= 0)
227 spa_pod_parser_advance(parser, pod);
228 return res;
229}
230
231 SPA_API_POD_PARSER int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)
232{
233 int res = -EPIPE;
234 const struct spa_pod *pod = spa_pod_parser_current(parser);
235 if (pod != NULL && (res = spa_pod_get_fraction(pod, value)) >= 0)
236 spa_pod_parser_advance(parser, pod);
237 return res;
238}
239
240 SPA_API_POD_PARSER int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)
241{
242 struct spa_pod *pod = spa_pod_parser_current(parser);
243 if (pod == NULL)
244 return -EPIPE;
245 *value = pod;
246 spa_pod_parser_advance(parser, pod);
247 return 0;
248}
249 SPA_API_POD_PARSER int spa_pod_parser_push_struct(struct spa_pod_parser *parser,
250 struct spa_pod_frame *frame)
251{
252 const struct spa_pod *pod = spa_pod_parser_current(parser);
253 if (pod == NULL)
254 return -EPIPE;
255 if (!spa_pod_is_struct(pod))
256 return -EINVAL;
257 spa_pod_parser_push(parser, frame, pod, parser->state.offset);
258 parser->state.offset += sizeof(struct spa_pod_struct);
259 return 0;
260}
261
262 SPA_API_POD_PARSER int spa_pod_parser_push_object(struct spa_pod_parser *parser,
263 struct spa_pod_frame *frame, uint32_t type, uint32_t *id)
264{
265 const struct spa_pod *pod = spa_pod_parser_current(parser);
266 if (pod == NULL)
267 return -EPIPE;
268 if (!spa_pod_is_object(pod))
269 return -EINVAL;
270 if (type != SPA_POD_OBJECT_TYPE(pod))
271 return -EPROTO;
272 if (id != NULL)
273 *id = SPA_POD_OBJECT_ID(pod);
274 spa_pod_parser_push(parser, frame, pod, parser->state.offset);
275 parser->state.offset = parser->size;
276 return 0;
277}
278
279 SPA_API_POD_PARSER bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)
280{
281 if (pod == NULL)
282 return false;
283
284 if (SPA_POD_TYPE(pod) == SPA_TYPE_Choice) {
285 if (!spa_pod_is_choice(pod))
286 return false;
287 if (type == 'V')
288 return true;
289 if (SPA_POD_CHOICE_TYPE(pod) != SPA_CHOICE_None)
290 return false;
291 pod = SPA_POD_CHOICE_CHILD(pod);
292 }
293
294 switch (type) {
295 case 'P':
296 return true;
297 case 'b':
298 return spa_pod_is_bool(pod);
299 case 'I':
300 return spa_pod_is_id(pod);
301 case 'i':
302 return spa_pod_is_int(pod);
303 case 'l':
304 return spa_pod_is_long(pod);
305 case 'f':
306 return spa_pod_is_float(pod);
307 case 'd':
308 return spa_pod_is_double(pod);
309 case 's':
310 return spa_pod_is_string(pod) || spa_pod_is_none(pod);
311 case 'S':
312 return spa_pod_is_string(pod);
313 case 'y':
314 return spa_pod_is_bytes(pod);
315 case 'R':
316 return spa_pod_is_rectangle(pod);
317 case 'F':
318 return spa_pod_is_fraction(pod);
319 case 'B':
320 return spa_pod_is_bitmap(pod);
321 case 'a':
322 return spa_pod_is_array(pod);
323 case 'p':
324 return spa_pod_is_pointer(pod);
325 case 'h':
326 return spa_pod_is_fd(pod);
327 case 'T':
328 return spa_pod_is_struct(pod) || spa_pod_is_none(pod);
329 case 'O':
330 return spa_pod_is_object(pod) || spa_pod_is_none(pod);
331 case 'V':
332 default:
333 return false;
334 }
335}
336
337#define SPA_POD_PARSER_COLLECT(pod,_type,args) \
338 do { \
339 switch (_type) { \
340 case 'b': \
341 *va_arg(args, bool*) = SPA_POD_VALUE(struct spa_pod_bool, pod); \
342 break; \
343 case 'I': \
344 case 'i': \
345 *va_arg(args, int32_t*) = SPA_POD_VALUE(struct spa_pod_int, pod); \
346 break; \
347 case 'l': \
348 *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_long, pod); \
349 break; \
350 case 'f': \
351 *va_arg(args, float*) = SPA_POD_VALUE(struct spa_pod_float, pod); \
352 break; \
353 case 'd': \
354 *va_arg(args, double*) = SPA_POD_VALUE(struct spa_pod_double, pod); \
355 break; \
356 case 's': \
357 *va_arg(args, char**) = \
358 ((pod) == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
359 ? NULL \
360 : (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod)); \
361 break; \
362 case 'S': \
363 { \
364 char *dest = va_arg(args, char*); \
365 uint32_t maxlen = va_arg(args, uint32_t); \
366 strncpy(dest, (char *)SPA_POD_CONTENTS(struct spa_pod_string, pod), maxlen-1); \
367 dest[maxlen-1] = '\0'; \
368 break; \
369 } \
370 case 'y': \
371 *(va_arg(args, void **)) = SPA_POD_CONTENTS(struct spa_pod_bytes, pod); \
372 *(va_arg(args, uint32_t *)) = SPA_POD_BODY_SIZE(pod); \
373 break; \
374 case 'R': \
375 *va_arg(args, struct spa_rectangle*) = \
376 SPA_POD_VALUE(struct spa_pod_rectangle, pod); \
377 break; \
378 case 'F': \
379 *va_arg(args, struct spa_fraction*) = \
380 SPA_POD_VALUE(struct spa_pod_fraction, pod); \
381 break; \
382 case 'B': \
383 *va_arg(args, uint32_t **) = \
384 (uint32_t *) SPA_POD_CONTENTS(struct spa_pod_bitmap, pod); \
385 break; \
386 case 'a': \
387 *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_SIZE(pod); \
388 *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_TYPE(pod); \
389 *va_arg(args, uint32_t*) = SPA_POD_ARRAY_N_VALUES(pod); \
390 *va_arg(args, void**) = SPA_POD_ARRAY_VALUES(pod); \
391 break; \
392 case 'p': \
393 { \
394 struct spa_pod_pointer_body *b = \
395 (struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \
396 *(va_arg(args, uint32_t *)) = b->type; \
397 *(va_arg(args, const void **)) = b->value; \
398 break; \
399 } \
400 case 'h': \
401 *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_fd, pod); \
402 break; \
403 case 'P': \
404 case 'T': \
405 case 'O': \
406 case 'V': \
407 { \
408 const struct spa_pod **d = va_arg(args, const struct spa_pod**); \
409 if (d) \
410 *d = ((pod) == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
411 ? NULL : (pod)); \
412 break; \
413 } \
414 default: \
415 break; \
416 } \
417} while(false)
418
419#define SPA_POD_PARSER_SKIP(_type,args) \
420 do { \
421 switch (_type) { \
422 case 'S': \
423 va_arg(args, char*); \
424 va_arg(args, uint32_t); \
425 break; \
426 case 'a': \
427 va_arg(args, void*); \
428 va_arg(args, void*); \
429 SPA_FALLTHROUGH \
430 case 'p': \
431 case 'y': \
432 va_arg(args, void*); \
433 SPA_FALLTHROUGH \
434 case 'b': \
435 case 'I': \
436 case 'i': \
437 case 'l': \
438 case 'f': \
439 case 'd': \
440 case 's': \
441 case 'R': \
442 case 'F': \
443 case 'B': \
444 case 'h': \
445 case 'V': \
446 case 'P': \
447 case 'T': \
448 case 'O': \
449 va_arg(args, void*); \
450 break; \
451 } \
452} while(false)
453
454 SPA_API_POD_PARSER int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)
455{
456 struct spa_pod_frame *f = parser->state.frame;
457 uint32_t ftype = f ? f->pod.type : (uint32_t)SPA_TYPE_Struct;
458 const struct spa_pod_prop *prop = NULL;
459 int count = 0;
460
461 do {
462 bool optional;
463 const struct spa_pod *pod = NULL;
464 const char *format;
465
466 if (f && ftype == SPA_TYPE_Object) {
467 uint32_t key = va_arg(args, uint32_t);
468 const struct spa_pod_object *object;
469
470 if (key == 0)
471 break;
472
473 object = (const struct spa_pod_object *)spa_pod_parser_frame(parser, f);
474 prop = spa_pod_object_find_prop(object, prop, key);
475 pod = prop ? &prop->value : NULL;
476 }
477
478 if ((format = va_arg(args, char *)) == NULL)
479 break;
480
481 if (ftype == SPA_TYPE_Struct)
482 pod = spa_pod_parser_next(parser);
483
484 if ((optional = (*format == '?')))
485 format++;
486
487 if (!spa_pod_parser_can_collect(pod, *format)) {
488 if (!optional) {
489 if (pod == NULL)
490 return -ESRCH;
491 else
492 return -EPROTO;
493 }
494 SPA_POD_PARSER_SKIP(*format, args);
495 } else {
496 if (pod->type == SPA_TYPE_Choice && *format != 'V')
497 pod = SPA_POD_CHOICE_CHILD(pod);
498
499 SPA_POD_PARSER_COLLECT(pod, *format, args);
500 count++;
501 }
502 } while (true);
503
504 return count;
505}
506
507 SPA_API_POD_PARSER int spa_pod_parser_get(struct spa_pod_parser *parser, ...)
508{
509 int res;
510 va_list args;
511
512 va_start(args, parser);
513 res = spa_pod_parser_getv(parser, args);
514 va_end(args);
515
516 return res;
517}
518
519#define SPA_POD_OPT_Bool(val) "?" SPA_POD_Bool(val)
520#define SPA_POD_OPT_Id(val) "?" SPA_POD_Id(val)
521#define SPA_POD_OPT_Int(val) "?" SPA_POD_Int(val)
522#define SPA_POD_OPT_Long(val) "?" SPA_POD_Long(val)
523#define SPA_POD_OPT_Float(val) "?" SPA_POD_Float(val)
524#define SPA_POD_OPT_Double(val) "?" SPA_POD_Double(val)
525#define SPA_POD_OPT_String(val) "?" SPA_POD_String(val)
526#define SPA_POD_OPT_Stringn(val,len) "?" SPA_POD_Stringn(val,len)
527#define SPA_POD_OPT_Bytes(val,len) "?" SPA_POD_Bytes(val,len)
528#define SPA_POD_OPT_Rectangle(val) "?" SPA_POD_Rectangle(val)
529#define SPA_POD_OPT_Fraction(val) "?" SPA_POD_Fraction(val)
530#define SPA_POD_OPT_Array(csize,ctype,n_vals,vals) "?" SPA_POD_Array(csize,ctype,n_vals,vals)
531#define SPA_POD_OPT_Pointer(type,val) "?" SPA_POD_Pointer(type,val)
532#define SPA_POD_OPT_Fd(val) "?" SPA_POD_Fd(val)
533#define SPA_POD_OPT_Pod(val) "?" SPA_POD_Pod(val)
534#define SPA_POD_OPT_PodObject(val) "?" SPA_POD_PodObject(val)
535#define SPA_POD_OPT_PodStruct(val) "?" SPA_POD_PodStruct(val)
536#define SPA_POD_OPT_PodChoice(val) "?" SPA_POD_PodChoice(val)
537
538#define spa_pod_parser_get_object(p,type,id,...) \
539({ \
540 struct spa_pod_frame _f; \
541 int _res; \
542 if ((_res = spa_pod_parser_push_object(p, &_f, type, id)) == 0) { \
543 _res = spa_pod_parser_get(p,##__VA_ARGS__, 0); \
544 spa_pod_parser_pop(p, &_f); \
545 } \
546 _res; \
547})
548
549#define spa_pod_parser_get_struct(p,...) \
550({ \
551 struct spa_pod_frame _f; \
552 int _res; \
553 if ((_res = spa_pod_parser_push_struct(p, &_f)) == 0) { \
554 _res = spa_pod_parser_get(p,##__VA_ARGS__, NULL); \
555 spa_pod_parser_pop(p, &_f); \
556 } \
557 _res; \
558})
559
560#define spa_pod_parse_object(pod,type,id,...) \
561({ \
562 struct spa_pod_parser _p; \
563 spa_pod_parser_pod(&_p, pod); \
564 spa_pod_parser_get_object(&_p,type,id,##__VA_ARGS__); \
565})
566
567#define spa_pod_parse_struct(pod,...) \
568({ \
569 struct spa_pod_parser _p; \
570 spa_pod_parser_pod(&_p, pod); \
571 spa_pod_parser_get_struct(&_p,##__VA_ARGS__); \
572})
573
574
575 * \}
576 */
577
578#ifdef __cplusplus
579} /* extern "C" */
580#endif
581
582#endif /* SPA_POD_PARSER_H */
args
uint32_t int int const char va_list args
Definition core.h:434
va_end
va_end(args)
res
uint32_t int int res
Definition core.h:433
va_start
va_start(args, message)
spa_pod_parser_push
SPA_API_POD_PARSER void spa_pod_parser_push(struct spa_pod_parser *parser, struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset)
Definition parser.h:102
spa_pod_parser_get_long
SPA_API_POD_PARSER int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)
Definition parser.h:167
spa_pod_is_long
SPA_API_POD_ITER int spa_pod_is_long(const struct spa_pod *pod)
Definition iter.h:191
spa_pod_get_int
SPA_API_POD_ITER int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
Definition iter.h:183
spa_pod_parser_get_int
SPA_API_POD_PARSER int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)
Definition parser.h:158
spa_pod_parser_pop
SPA_API_POD_PARSER int spa_pod_parser_pop(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition parser.h:132
spa_pod_is_int
SPA_API_POD_ITER int spa_pod_is_int(const struct spa_pod *pod)
Definition iter.h:178
spa_pod_is_fraction
SPA_API_POD_ITER int spa_pod_is_fraction(const struct spa_pod *pod)
Definition iter.h:313
spa_pod_parser_deref
SPA_API_POD_PARSER struct spa_pod * spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
Definition parser.h:79
spa_pod_parser_pod
SPA_API_POD_PARSER void spa_pod_parser_pod(struct spa_pod_parser *parser, const struct spa_pod *pod)
Definition parser.h:60
spa_pod_parser_next
SPA_API_POD_PARSER struct spa_pod * spa_pod_parser_next(struct spa_pod_parser *parser)
Definition parser.h:124
spa_pod_parser_current
SPA_API_POD_PARSER struct spa_pod * spa_pod_parser_current(struct spa_pod_parser *parser)
Definition parser.h:112
spa_pod_parser_get_pointer
SPA_API_POD_PARSER int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)
Definition parser.h:212
spa_pod_parser_get_fraction
SPA_API_POD_PARSER int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)
Definition parser.h:239
spa_pod_get_pointer
SPA_API_POD_ITER int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
Definition iter.h:276
spa_pod_is_choice
SPA_API_POD_ITER int spa_pod_is_choice(const struct spa_pod *pod)
Definition iter.h:357
spa_pod_get_id
SPA_API_POD_ITER int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
Definition iter.h:170
spa_pod_parser_advance
SPA_API_POD_PARSER void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)
Definition parser.h:119
spa_pod_get_bytes
SPA_API_POD_ITER int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
Definition iter.h:261
spa_pod_is_float
SPA_API_POD_ITER int spa_pod_is_float(const struct spa_pod *pod)
Definition iter.h:204
spa_pod_is_id
SPA_API_POD_ITER int spa_pod_is_id(const struct spa_pod *pod)
Definition iter.h:165
spa_pod_object_find_prop
SPA_API_POD_ITER const struct spa_pod_prop * spa_pod_object_find_prop(const struct spa_pod_object *pod, const struct spa_pod_prop *start, uint32_t key)
Definition iter.h:404
spa_pod_parser_get_bytes
SPA_API_POD_PARSER int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)
Definition parser.h:203
spa_pod_parser_reset
SPA_API_POD_PARSER void spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
Definition parser.h:73
SPA_POD_TYPE
#define SPA_POD_TYPE(pod)
Definition pod.h:28
spa_pod_parser_getv
SPA_API_POD_PARSER int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)
Definition parser.h:462
spa_pod_is_pointer
SPA_API_POD_ITER int spa_pod_is_pointer(const struct spa_pod *pod)
Definition iter.h:270
spa_pod_parser_push_object
SPA_API_POD_PARSER int spa_pod_parser_push_object(struct spa_pod_parser *parser, struct spa_pod_frame *frame, uint32_t type, uint32_t *id)
Definition parser.h:270
spa_pod_parser_get_double
SPA_API_POD_PARSER int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)
Definition parser.h:185
spa_pod_get_fd
SPA_API_POD_ITER int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
Definition iter.h:291
spa_pod_is_none
SPA_API_POD_ITER int spa_pod_is_none(const struct spa_pod *pod)
Definition iter.h:147
SPA_POD_BODY_SIZE
#define SPA_POD_BODY_SIZE(pod)
Definition pod.h:26
spa_pod_get_long
SPA_API_POD_ITER int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
Definition iter.h:196
spa_pod_get_float
SPA_API_POD_ITER int spa_pod_get_float(const struct spa_pod *pod, float *value)
Definition iter.h:209
spa_pod_parser_can_collect
SPA_API_POD_PARSER bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)
Definition parser.h:287
spa_pod_parser_get_fd
SPA_API_POD_PARSER int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)
Definition parser.h:221
spa_pod_get_bool
SPA_API_POD_ITER int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
Definition iter.h:157
SPA_POD_PARSER_COLLECT
#define SPA_POD_PARSER_COLLECT(pod, _type, args)
Definition parser.h:345
spa_pod_parser_get_bool
SPA_API_POD_PARSER int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)
Definition parser.h:140
spa_pod_is_object
SPA_API_POD_ITER int spa_pod_is_object(const struct spa_pod *pod)
Definition iter.h:382
spa_pod_parser_get_pod
SPA_API_POD_PARSER int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)
Definition parser.h:248
spa_pod_parser_push_struct
SPA_API_POD_PARSER int spa_pod_parser_push_struct(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition parser.h:257
spa_pod_get_rectangle
SPA_API_POD_ITER int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
Definition iter.h:305
spa_pod_get_double
SPA_API_POD_ITER int spa_pod_get_double(const struct spa_pod *pod, double *value)
Definition iter.h:222
SPA_POD_PARSER_SKIP
#define SPA_POD_PARSER_SKIP(_type, args)
Definition parser.h:427
spa_pod_parser_get_float
SPA_API_POD_PARSER int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)
Definition parser.h:176
spa_pod_is_struct
SPA_API_POD_ITER int spa_pod_is_struct(const struct spa_pod *pod)
Definition iter.h:377
spa_pod_parser_frame
SPA_API_POD_PARSER struct spa_pod * spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition parser.h:97
spa_pod_is_fd
SPA_API_POD_ITER int spa_pod_is_fd(const struct spa_pod *pod)
Definition iter.h:285
spa_pod_is_string
SPA_API_POD_ITER int spa_pod_is_string(const struct spa_pod *pod)
Definition iter.h:230
spa_pod_parser_get_state
SPA_API_POD_PARSER void spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
Definition parser.h:67
spa_pod_parser_get_string
SPA_API_POD_PARSER int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)
Definition parser.h:194
SPA_POD_PARSER_INIT
#define SPA_POD_PARSER_INIT(buffer, size)
Definition parser.h:52
spa_pod_is_bool
SPA_API_POD_ITER int spa_pod_is_bool(const struct spa_pod *pod)
Definition iter.h:152
spa_pod_is_bitmap
SPA_API_POD_ITER int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition iter.h:326
spa_pod_parser_get
SPA_API_POD_PARSER int spa_pod_parser_get(struct spa_pod_parser *parser,...)
Definition parser.h:515
SPA_POD_OBJECT_TYPE
#define SPA_POD_OBJECT_TYPE(obj)
Definition pod.h:173
SPA_POD_OBJECT_ID
#define SPA_POD_OBJECT_ID(obj)
Definition pod.h:175
spa_pod_parser_init
SPA_API_POD_PARSER void spa_pod_parser_init(struct spa_pod_parser *parser, const void *data, uint32_t size)
Definition parser.h:54
spa_pod_get_string
SPA_API_POD_ITER int spa_pod_get_string(const struct spa_pod *pod, const char **value)
Definition iter.h:238
spa_pod_parser_get_rectangle
SPA_API_POD_PARSER int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)
Definition parser.h:230
spa_pod_is_bytes
SPA_API_POD_ITER int spa_pod_is_bytes(const struct spa_pod *pod)
Definition iter.h:256
SPA_POD_SIZE
#define SPA_POD_SIZE(pod)
Definition pod.h:30
spa_pod_is_double
SPA_API_POD_ITER int spa_pod_is_double(const struct spa_pod *pod)
Definition iter.h:217
spa_pod_parser_get_id
SPA_API_POD_PARSER int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)
Definition parser.h:149
SPA_POD_CHOICE_CHILD
#define SPA_POD_CHOICE_CHILD(choice)
Definition pod.h:132
spa_pod_get_fraction
SPA_API_POD_ITER int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
Definition iter.h:319
SPA_POD_CHOICE_TYPE
#define SPA_POD_CHOICE_TYPE(choice)
Definition pod.h:134
spa_pod_is_array
SPA_API_POD_ITER int spa_pod_is_array(const struct spa_pod *pod)
Definition iter.h:332
spa_pod_is_rectangle
SPA_API_POD_ITER int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition iter.h:299
SPA_CHOICE_None
@ SPA_CHOICE_None
no choice, first value is current
Definition pod.h:147
SPA_TYPE_Object
@ SPA_TYPE_Object
Definition type.h:56
SPA_TYPE_Choice
@ SPA_TYPE_Choice
Definition type.h:60
SPA_TYPE_Struct
@ SPA_TYPE_Struct
Definition type.h:55
SPA_ROUND_UP_N
#define SPA_ROUND_UP_N(num, align)
Definition defs.h:360
SPA_IS_ALIGNED
#define SPA_IS_ALIGNED(p, align)
Definition defs.h:380
SPA_PTROFF
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition defs.h:222
iter.h
spa/pod/iter.h
SPA_API_POD_PARSER
#define SPA_API_POD_PARSER
Definition parser.h:29
spa_fraction
Definition defs.h:137
spa_pod_frame
Definition iter.h:37
spa_pod_frame::pod
struct spa_pod pod
Definition iter.h:38
spa_pod_frame::offset
uint32_t offset
Definition iter.h:40
spa_pod_frame::parent
struct spa_pod_frame * parent
Definition iter.h:39
spa_pod_frame::flags
uint32_t flags
Definition iter.h:41
spa_pod_object
Definition pod.h:183
spa_pod_object::pod
struct spa_pod pod
Definition pod.h:184
spa_pod_parser_state
Definition parser.h:38
spa_pod_parser_state::offset
uint32_t offset
Definition parser.h:39
spa_pod_parser_state::flags
uint32_t flags
Definition parser.h:40
spa_pod_parser_state::frame
struct spa_pod_frame * frame
Definition parser.h:41
spa_pod_parser
Definition parser.h:44
spa_pod_parser::size
uint32_t size
Definition parser.h:46
spa_pod_parser::state
struct spa_pod_parser_state state
Definition parser.h:48
spa_pod_parser::data
const void * data
Definition parser.h:45
spa_pod_parser::_padding
uint32_t _padding
Definition parser.h:47
spa_pod_prop
Definition pod.h:208
spa_pod_prop::value
struct spa_pod value
Definition pod.h:226
spa_pod_struct
Definition pod.h:167
spa_pod
Definition pod.h:43
spa_pod::type
uint32_t type
Definition pod.h:45
spa_pod::size
uint32_t size
Definition pod.h:44
spa_rectangle
Definition defs.h:116
vararg.h
spa/pod/vararg.h