PipeWire  0.3.33
parser.h
Go to the documentation of this file.
1 /* Spa
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 SPA_POD_PARSER_H
26 #define SPA_POD_PARSER_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <errno.h>
33 #include <stdarg.h>
34 
35 #include <spa/pod/iter.h>
36 #include <spa/pod/vararg.h>
37 
44  uint32_t offset;
45  uint32_t flags;
47 };
48 
50  const void *data;
51  uint32_t size;
52  uint32_t _padding;
54 };
55 
56 #define SPA_POD_PARSER_INIT(buffer,size) (struct spa_pod_parser){ buffer, size, 0, {} }
57 
58 /* static */ inline void spa_pod_parser_init(struct spa_pod_parser *parser,
59  const void *data, uint32_t size)
60 {
61  *parser = SPA_POD_PARSER_INIT(data, size);
62 }
63 
64 /* static */ inline void spa_pod_parser_pod(struct spa_pod_parser *parser,
65  const struct spa_pod *pod)
66 {
67  spa_pod_parser_init(parser, pod, SPA_POD_SIZE(pod));
68 }
69 
70 /* static */ inline void
72 {
73  *state = parser->state;
74 }
75 
76 /* static */ inline void
78 {
79  parser->state = *state;
80 }
81 
82 /* static */ inline struct spa_pod *
83 spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
84 {
85  if (offset + 8 <= size) {
86  struct spa_pod *pod = SPA_PTROFF(parser->data, offset, struct spa_pod);
87  if (offset + SPA_POD_SIZE(pod) <= size)
88  return pod;
89  }
90  return NULL;
91 }
92 
93 /* static */ inline struct spa_pod *spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
94 {
95  return SPA_PTROFF(parser->data, frame->offset, struct spa_pod);
96 }
97 
98 /* static */ inline void spa_pod_parser_push(struct spa_pod_parser *parser,
99  struct spa_pod_frame *frame, const struct spa_pod *pod, uint32_t offset)
100 {
101  frame->pod = *pod;
102  frame->offset = offset;
103  frame->parent = parser->state.frame;
104  frame->flags = parser->state.flags;
105  parser->state.frame = frame;
106 }
107 
108 /* static */ inline struct spa_pod *spa_pod_parser_current(struct spa_pod_parser *parser)
109 {
110  struct spa_pod_frame *f = parser->state.frame;
111  uint32_t size = f ? f->offset + SPA_POD_SIZE(&f->pod) : parser->size;
112  return spa_pod_parser_deref(parser, parser->state.offset, size);
113 }
114 
115 /* static */ inline void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)
116 {
117  parser->state.offset += SPA_ROUND_UP_N(SPA_POD_SIZE(pod), 8);
118 }
119 
120 /* static */ inline struct spa_pod *spa_pod_parser_next(struct spa_pod_parser *parser)
121 {
122  struct spa_pod *pod = spa_pod_parser_current(parser);
123  if (pod)
124  spa_pod_parser_advance(parser, pod);
125  return pod;
126 }
127 
128 /* static */ inline int spa_pod_parser_pop(struct spa_pod_parser *parser,
129  struct spa_pod_frame *frame)
130 {
131  parser->state.frame = frame->parent;
132  parser->state.offset = frame->offset + SPA_ROUND_UP_N(SPA_POD_SIZE(&frame->pod), 8);
133  return 0;
134 }
135 
136 /* static */ inline int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)
137 {
138  int res = -EPIPE;
139  const struct spa_pod *pod = spa_pod_parser_current(parser);
140  if (pod != NULL && (res = spa_pod_get_bool(pod, value)) >= 0)
141  spa_pod_parser_advance(parser, pod);
142  return res;
143 }
144 
145 /* static */ inline int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)
146 {
147  int res = -EPIPE;
148  const struct spa_pod *pod = spa_pod_parser_current(parser);
149  if (pod != NULL && (res = spa_pod_get_id(pod, value)) >= 0)
150  spa_pod_parser_advance(parser, pod);
151  return res;
152 }
153 
154 /* static */ inline int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)
155 {
156  int res = -EPIPE;
157  const struct spa_pod *pod = spa_pod_parser_current(parser);
158  if (pod != NULL && (res = spa_pod_get_int(pod, value)) >= 0)
159  spa_pod_parser_advance(parser, pod);
160  return res;
161 }
162 
163 /* static */ inline int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)
164 {
165  int res = -EPIPE;
166  const struct spa_pod *pod = spa_pod_parser_current(parser);
167  if (pod != NULL && (res = spa_pod_get_long(pod, value)) >= 0)
168  spa_pod_parser_advance(parser, pod);
169  return res;
170 }
171 
172 /* static */ inline int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)
173 {
174  int res = -EPIPE;
175  const struct spa_pod *pod = spa_pod_parser_current(parser);
176  if (pod != NULL && (res = spa_pod_get_float(pod, value)) >= 0)
177  spa_pod_parser_advance(parser, pod);
178  return res;
179 }
180 
181 /* static */ inline int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)
182 {
183  int res = -EPIPE;
184  const struct spa_pod *pod = spa_pod_parser_current(parser);
185  if (pod != NULL && (res = spa_pod_get_double(pod, value)) >= 0)
186  spa_pod_parser_advance(parser, pod);
187  return res;
188 }
189 
190 /* static */ inline int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)
191 {
192  int res = -EPIPE;
193  const struct spa_pod *pod = spa_pod_parser_current(parser);
194  if (pod != NULL && (res = spa_pod_get_string(pod, value)) >= 0)
195  spa_pod_parser_advance(parser, pod);
196  return res;
197 }
198 
199 /* static */ inline int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)
200 {
201  int res = -EPIPE;
202  const struct spa_pod *pod = spa_pod_parser_current(parser);
203  if (pod != NULL && (res = spa_pod_get_bytes(pod, value, len)) >= 0)
204  spa_pod_parser_advance(parser, pod);
205  return res;
206 }
207 
208 /* static */ inline int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)
209 {
210  int res = -EPIPE;
211  const struct spa_pod *pod = spa_pod_parser_current(parser);
212  if (pod != NULL && (res = spa_pod_get_pointer(pod, type, value)) >= 0)
213  spa_pod_parser_advance(parser, pod);
214  return res;
215 }
216 
217 /* static */ inline int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)
218 {
219  int res = -EPIPE;
220  const struct spa_pod *pod = spa_pod_parser_current(parser);
221  if (pod != NULL && (res = spa_pod_get_fd(pod, value)) >= 0)
222  spa_pod_parser_advance(parser, pod);
223  return res;
224 }
225 
226 /* static */ inline int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)
227 {
228  int res = -EPIPE;
229  const struct spa_pod *pod = spa_pod_parser_current(parser);
230  if (pod != NULL && (res = spa_pod_get_rectangle(pod, value)) >= 0)
231  spa_pod_parser_advance(parser, pod);
232  return res;
233 }
234 
235 /* static */ inline int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)
236 {
237  int res = -EPIPE;
238  const struct spa_pod *pod = spa_pod_parser_current(parser);
239  if (pod != NULL && (res = spa_pod_get_fraction(pod, value)) >= 0)
240  spa_pod_parser_advance(parser, pod);
241  return res;
242 }
243 
244 /* static */ inline int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)
245 {
246  struct spa_pod *pod = spa_pod_parser_current(parser);
247  if (pod == NULL)
248  return -EPIPE;
249  *value = pod;
250  spa_pod_parser_advance(parser, pod);
251  return 0;
252 }
253 /* static */ inline int spa_pod_parser_push_struct(struct spa_pod_parser *parser,
254  struct spa_pod_frame *frame)
255 {
256  const struct spa_pod *pod = spa_pod_parser_current(parser);
257  if (pod == NULL)
258  return -EPIPE;
259  if (!spa_pod_is_struct(pod))
260  return -EINVAL;
261  spa_pod_parser_push(parser, frame, pod, parser->state.offset);
262  parser->state.offset += sizeof(struct spa_pod_struct);
263  return 0;
264 }
265 
266 /* static */ inline int spa_pod_parser_push_object(struct spa_pod_parser *parser,
267  struct spa_pod_frame *frame, uint32_t type, uint32_t *id)
268 {
269  const struct spa_pod *pod = spa_pod_parser_current(parser);
270  if (pod == NULL)
271  return -EPIPE;
272  if (!spa_pod_is_object(pod))
273  return -EINVAL;
274  if (type != SPA_POD_OBJECT_TYPE(pod))
275  return -EPROTO;
276  if (id != NULL)
277  *id = SPA_POD_OBJECT_ID(pod);
278  spa_pod_parser_push(parser, frame, pod, parser->state.offset);
279  parser->state.offset = parser->size;
280  return 0;
281 }
282 
283 /* static */ inline bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)
284 {
285  if (pod == NULL)
286  return false;
287 
288  if (spa_pod_is_choice(pod) &&
291  return true;
292 
293  switch (type) {
294  case 'P':
295  return true;
296  case 'b':
297  return spa_pod_is_bool(pod);
298  case 'I':
299  return spa_pod_is_id(pod);
300  case 'i':
301  return spa_pod_is_int(pod);
302  case 'l':
303  return spa_pod_is_long(pod);
304  case 'f':
305  return spa_pod_is_float(pod);
306  case 'd':
307  return spa_pod_is_double(pod);
308  case 's':
309  return spa_pod_is_string(pod) || spa_pod_is_none(pod);
310  case 'S':
311  return spa_pod_is_string(pod);
312  case 'y':
313  return spa_pod_is_bytes(pod);
314  case 'R':
315  return spa_pod_is_rectangle(pod);
316  case 'F':
317  return spa_pod_is_fraction(pod);
318  case 'B':
319  return spa_pod_is_bitmap(pod);
320  case 'a':
321  return spa_pod_is_array(pod);
322  case 'p':
323  return spa_pod_is_pointer(pod);
324  case 'h':
325  return spa_pod_is_fd(pod);
326  case 'T':
327  return spa_pod_is_struct(pod) || spa_pod_is_none(pod);
328  case 'O':
329  return spa_pod_is_object(pod) || spa_pod_is_none(pod);
330  case 'V':
331  return spa_pod_is_choice(pod);
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  break; \
368  } \
369  case 'y': \
370  *(va_arg(args, void **)) = SPA_POD_CONTENTS(struct spa_pod_bytes, pod); \
371  *(va_arg(args, uint32_t *)) = SPA_POD_BODY_SIZE(pod); \
372  break; \
373  case 'R': \
374  *va_arg(args, struct spa_rectangle*) = \
375  SPA_POD_VALUE(struct spa_pod_rectangle, pod); \
376  break; \
377  case 'F': \
378  *va_arg(args, struct spa_fraction*) = \
379  SPA_POD_VALUE(struct spa_pod_fraction, pod); \
380  break; \
381  case 'B': \
382  *va_arg(args, uint32_t **) = \
383  (uint32_t *) SPA_POD_CONTENTS(struct spa_pod_bitmap, pod); \
384  break; \
385  case 'a': \
386  *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_SIZE(pod); \
387  *va_arg(args, uint32_t*) = SPA_POD_ARRAY_VALUE_TYPE(pod); \
388  *va_arg(args, uint32_t*) = SPA_POD_ARRAY_N_VALUES(pod); \
389  *va_arg(args, void**) = SPA_POD_ARRAY_VALUES(pod); \
390  break; \
391  case 'p': \
392  { \
393  struct spa_pod_pointer_body *b = \
394  (struct spa_pod_pointer_body *) SPA_POD_BODY(pod); \
395  *(va_arg(args, uint32_t *)) = b->type; \
396  *(va_arg(args, const void **)) = b->value; \
397  break; \
398  } \
399  case 'h': \
400  *va_arg(args, int64_t*) = SPA_POD_VALUE(struct spa_pod_fd, pod); \
401  break; \
402  case 'P': \
403  case 'T': \
404  case 'O': \
405  case 'V': \
406  { \
407  const struct spa_pod **d = va_arg(args, const struct spa_pod**); \
408  if (d) \
409  *d = (pod == NULL || (SPA_POD_TYPE(pod) == SPA_TYPE_None) \
410  ? NULL : pod); \
411  break; \
412  } \
413  default: \
414  break; \
415  } \
416 } while(false)
417 
418 #define SPA_POD_PARSER_SKIP(_type,args) \
419 do { \
420  switch (_type) { \
421  case 'S': \
422  va_arg(args, char*); \
423  va_arg(args, uint32_t); \
424  break; \
425  case 'a': \
426  va_arg(args, void*); \
427  va_arg(args, void*); \
428  SPA_FALLTHROUGH \
429  case 'p': \
430  case 'y': \
431  va_arg(args, void*); \
432  SPA_FALLTHROUGH \
433  case 'b': \
434  case 'I': \
435  case 'i': \
436  case 'l': \
437  case 'f': \
438  case 'd': \
439  case 's': \
440  case 'R': \
441  case 'F': \
442  case 'B': \
443  case 'h': \
444  case 'V': \
445  case 'P': \
446  case 'T': \
447  case 'O': \
448  va_arg(args, void*); \
449  break; \
450  } \
451 } while(false)
452 
453 /* static */ inline int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)
454 {
455  struct spa_pod_frame *f = parser->state.frame;
456  uint32_t ftype = f ? f->pod.type : (uint32_t)SPA_TYPE_Struct;
457  const struct spa_pod_prop *prop = NULL;
458  int count = 0;
459 
460  do {
461  bool optional;
462  const struct spa_pod *pod = NULL;
463  const char *format;
464 
465  if (ftype == SPA_TYPE_Object) {
466  uint32_t key = va_arg(args, uint32_t);
467  const struct spa_pod_object *object;
468 
469  if (key == 0)
470  break;
471 
472  object = (const struct spa_pod_object *)spa_pod_parser_frame(parser, f);
473  prop = spa_pod_object_find_prop(object, prop, key);
474  pod = prop ? &prop->value : NULL;
475  }
476 
477  if ((format = va_arg(args, char *)) == NULL)
478  break;
479 
480  if (ftype == SPA_TYPE_Struct)
481  pod = spa_pod_parser_next(parser);
482 
483  if ((optional = (*format == '?')))
484  format++;
485 
486  if (!spa_pod_parser_can_collect(pod, *format)) {
487  if (!optional) {
488  if (pod == NULL)
489  return -ESRCH;
490  else
491  return -EPROTO;
492  }
493  SPA_POD_PARSER_SKIP(*format, args);
494  } else {
495  if (pod->type == SPA_TYPE_Choice && *format != 'V' &&
498 
499  SPA_POD_PARSER_COLLECT(pod, *format, args);
500  count++;
501  }
502  } while (true);
503 
504  return count;
505 }
506 
507 /* static */ inline 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 
578 #ifdef __cplusplus
579 } /* extern "C" */
580 #endif
581 
582 #endif /* SPA_POD_PARSER_H */
spa_pod_get_long
int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:195
spa_pod_parser_push_struct
int spa_pod_parser_push_struct(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition: parser.h:253
spa_pod_object
Definition: pod/pod.h:175
spa_pod_parser_get_fraction
int spa_pod_parser_get_fraction(struct spa_pod_parser *parser, struct spa_fraction *value)
Definition: parser.h:235
spa_pod_parser_get_bytes
int spa_pod_parser_get_bytes(struct spa_pod_parser *parser, const void **value, uint32_t *len)
Definition: parser.h:199
spa_pod_parser_reset
void spa_pod_parser_reset(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
Definition: parser.h:77
spa_pod_parser_get_string
int spa_pod_parser_get_string(struct spa_pod_parser *parser, const char **value)
Definition: parser.h:190
spa_pod_parser_state::flags
uint32_t flags
Definition: parser.h:45
spa_pod_parser_can_collect
bool spa_pod_parser_can_collect(const struct spa_pod *pod, char type)
Definition: parser.h:283
spa_pod_parser_push
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:98
spa_pod_is_id
int spa_pod_is_id(const struct spa_pod *pod)
Definition: iter.h:164
data
user data to add to an object
Definition: filter.c:75
spa_pod_parser::size
uint32_t size
Definition: parser.h:51
spa_pod_prop
Definition: pod/pod.h:199
spa_pod_parser_get_rectangle
int spa_pod_parser_get_rectangle(struct spa_pod_parser *parser, struct spa_rectangle *value)
Definition: parser.h:226
spa_pod_is_array
int spa_pod_is_array(const struct spa_pod *pod)
Definition: iter.h:331
spa_pod_is_choice
int spa_pod_is_choice(const struct spa_pod *pod)
Definition: iter.h:356
spa_pod_is_rectangle
int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition: iter.h:298
spa_pod_parser_pop
int spa_pod_parser_pop(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition: parser.h:128
SPA_ROUND_UP_N
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:223
spa_pod_get_fd
int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:290
spa_pod_parser_get
int spa_pod_parser_get(struct spa_pod_parser *parser,...)
Definition: parser.h:507
spa_pod_get_rectangle
int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
Definition: iter.h:304
spa_pod_parser_get_double
int spa_pod_parser_get_double(struct spa_pod_parser *parser, double *value)
Definition: parser.h:181
spa_pod_get_pointer
int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
Definition: iter.h:275
spa_pod_is_int
int spa_pod_is_int(const struct spa_pod *pod)
Definition: iter.h:177
spa_fraction
Definition: defs.h:104
spa_pod_parser_get_int
int spa_pod_parser_get_int(struct spa_pod_parser *parser, int32_t *value)
Definition: parser.h:154
SPA_POD_CHOICE_CHILD
#define SPA_POD_CHOICE_CHILD(choice)
Definition: pod/pod.h:132
spa_pod_get_double
int spa_pod_get_double(const struct spa_pod *pod, double *value)
Definition: iter.h:221
spa_pod_parser_get_fd
int spa_pod_parser_get_fd(struct spa_pod_parser *parser, int64_t *value)
Definition: parser.h:217
spa_pod_get_int
int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
Definition: iter.h:182
SPA_PTROFF
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
SPA_POD_OBJECT_ID
#define SPA_POD_OBJECT_ID(obj)
Definition: pod/pod.h:167
spa_pod_parser_current
struct spa_pod * spa_pod_parser_current(struct spa_pod_parser *parser)
Definition: parser.h:108
spa_pod_frame::parent
struct spa_pod_frame * parent
Definition: iter.h:44
spa_pod_parser_get_id
int spa_pod_parser_get_id(struct spa_pod_parser *parser, uint32_t *value)
Definition: parser.h:145
spa_rectangle
Definition: defs.h:86
spa_pod
Definition: pod/pod.h:50
spa_pod_parser_state
Definition: parser.h:43
spa_pod_get_fraction
int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
Definition: iter.h:318
spa_pod_get_bool
int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
Definition: iter.h:156
spa_pod_parser_getv
int spa_pod_parser_getv(struct spa_pod_parser *parser, va_list args)
Definition: parser.h:453
spa_pod_is_long
int spa_pod_is_long(const struct spa_pod *pod)
Definition: iter.h:190
spa_pod_is_bitmap
int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition: iter.h:325
spa_pod_get_id
int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
Definition: iter.h:169
spa_pod_parser::state
struct spa_pod_parser_state state
Definition: parser.h:53
spa_pod_is_float
int spa_pod_is_float(const struct spa_pod *pod)
Definition: iter.h:203
spa_pod_parser_get_state
void spa_pod_parser_get_state(struct spa_pod_parser *parser, struct spa_pod_parser_state *state)
Definition: parser.h:71
spa_pod_frame::offset
uint32_t offset
Definition: iter.h:45
SPA_POD_PARSER_INIT
#define SPA_POD_PARSER_INIT(buffer, size)
Definition: parser.h:56
spa_pod_parser_get_bool
int spa_pod_parser_get_bool(struct spa_pod_parser *parser, bool *value)
Definition: parser.h:136
spa_pod_parser_advance
void spa_pod_parser_advance(struct spa_pod_parser *parser, const struct spa_pod *pod)
Definition: parser.h:115
spa_pod_parser_init
void spa_pod_parser_init(struct spa_pod_parser *parser, const void *data, uint32_t size)
Definition: parser.h:58
spa_pod_is_pointer
int spa_pod_is_pointer(const struct spa_pod *pod)
Definition: iter.h:269
spa_pod_get_bytes
int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
Definition: iter.h:260
spa_pod_parser_pod
void spa_pod_parser_pod(struct spa_pod_parser *parser, const struct spa_pod *pod)
Definition: parser.h:64
SPA_POD_PARSER_COLLECT
#define SPA_POD_PARSER_COLLECT(pod, _type, args)
Definition: parser.h:337
spa_pod::size
uint32_t size
Definition: pod/pod.h:51
spa_pod_parser_get_pointer
int spa_pod_parser_get_pointer(struct spa_pod_parser *parser, uint32_t *type, const void **value)
Definition: parser.h:208
spa_pod_parser::_padding
uint32_t _padding
Definition: parser.h:52
spa_pod_parser
Definition: parser.h:49
spa_pod_is_none
int spa_pod_is_none(const struct spa_pod *pod)
Definition: iter.h:146
spa_pod_is_fraction
int spa_pod_is_fraction(const struct spa_pod *pod)
Definition: iter.h:312
spa_pod_parser_get_float
int spa_pod_parser_get_float(struct spa_pod_parser *parser, float *value)
Definition: parser.h:172
SPA_TYPE_Object
@ SPA_TYPE_Object
Definition: build-12683127/doc/spa/utils/type.h:59
spa_pod_frame
Definition: iter.h:42
SPA_POD_OBJECT_TYPE
#define SPA_POD_OBJECT_TYPE(obj)
Definition: pod/pod.h:166
spa_pod_is_double
int spa_pod_is_double(const struct spa_pod *pod)
Definition: iter.h:216
spa_pod_parser_state::frame
struct spa_pod_frame * frame
Definition: parser.h:46
spa_pod_object::pod
struct spa_pod pod
Definition: pod/pod.h:176
spa_pod_is_bytes
int spa_pod_is_bytes(const struct spa_pod *pod)
Definition: iter.h:255
spa_pod_object_find_prop
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:403
spa_pod_get_float
int spa_pod_get_float(const struct spa_pod *pod, float *value)
Definition: iter.h:208
SPA_CHOICE_None
@ SPA_CHOICE_None
no choice, first value is current
Definition: pod/pod.h:141
SPA_POD_PARSER_SKIP
#define SPA_POD_PARSER_SKIP(_type, args)
Definition: parser.h:418
spa_pod_frame::flags
uint32_t flags
Definition: iter.h:46
spa_pod_is_string
int spa_pod_is_string(const struct spa_pod *pod)
Definition: iter.h:229
spa_pod::type
uint32_t type
Definition: pod/pod.h:52
spa_pod_parser_frame
struct spa_pod * spa_pod_parser_frame(struct spa_pod_parser *parser, struct spa_pod_frame *frame)
Definition: parser.h:93
spa_pod_parser::data
const void * data
Definition: parser.h:50
spa_pod_is_struct
int spa_pod_is_struct(const struct spa_pod *pod)
Definition: iter.h:376
iter.h
spa_pod_parser_get_pod
int spa_pod_parser_get_pod(struct spa_pod_parser *parser, struct spa_pod **value)
Definition: parser.h:244
spa_pod_frame::pod
struct spa_pod pod
Definition: iter.h:43
SPA_POD_SIZE
#define SPA_POD_SIZE(pod)
Definition: pod/pod.h:42
spa_pod_parser_get_long
int spa_pod_parser_get_long(struct spa_pod_parser *parser, int64_t *value)
Definition: parser.h:163
SPA_TYPE_Choice
@ SPA_TYPE_Choice
Definition: build-12683127/doc/spa/utils/type.h:63
spa_pod_get_string
int spa_pod_get_string(const struct spa_pod *pod, const char **value)
Definition: iter.h:237
spa_pod_struct
Definition: pod/pod.h:161
spa_pod_is_bool
int spa_pod_is_bool(const struct spa_pod *pod)
Definition: iter.h:151
spa_pod_prop::value
struct spa_pod value
Definition: pod/pod.h:212
spa_pod_parser_next
struct spa_pod * spa_pod_parser_next(struct spa_pod_parser *parser)
Definition: parser.h:120
spa_pod_parser_push_object
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:266
spa_pod_is_object
int spa_pod_is_object(const struct spa_pod *pod)
Definition: iter.h:381
spa_pod_parser_state::offset
uint32_t offset
Definition: parser.h:44
SPA_POD_CHOICE_TYPE
#define SPA_POD_CHOICE_TYPE(choice)
Definition: pod/pod.h:133
spa_pod_is_fd
int spa_pod_is_fd(const struct spa_pod *pod)
Definition: iter.h:284
spa_pod_parser_deref
struct spa_pod * spa_pod_parser_deref(struct spa_pod_parser *parser, uint32_t offset, uint32_t size)
Definition: parser.h:83
vararg.h
SPA_TYPE_Struct
@ SPA_TYPE_Struct
Definition: build-12683127/doc/spa/utils/type.h:58