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