25 #ifndef SPA_POD_ITER_H
26 #define SPA_POD_ITER_H
33 #include <sys/types.h>
94 #define SPA_POD_ARRAY_BODY_FOREACH(body, _size, iter) \
95 for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_array_body), void); \
96 (iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \
97 (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))
99 #define SPA_POD_ARRAY_FOREACH(obj, iter) \
100 SPA_POD_ARRAY_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
102 #define SPA_POD_CHOICE_BODY_FOREACH(body, _size, iter) \
103 for ((iter) = (__typeof__(iter))SPA_PTROFF((body), sizeof(struct spa_pod_choice_body), void); \
104 (iter) < (__typeof__(iter))SPA_PTROFF((body), (_size), void); \
105 (iter) = (__typeof__(iter))SPA_PTROFF((iter), (body)->child.size, void))
107 #define SPA_POD_CHOICE_FOREACH(obj, iter) \
108 SPA_POD_CHOICE_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
110 #define SPA_POD_FOREACH(pod, size, iter) \
111 for ((iter) = (pod); \
112 spa_pod_is_inside(pod, size, iter); \
113 (iter) = (__typeof__(iter))spa_pod_next(iter))
115 #define SPA_POD_STRUCT_FOREACH(obj, iter) \
116 SPA_POD_FOREACH(SPA_POD_BODY(obj), SPA_POD_BODY_SIZE(obj), iter)
118 #define SPA_POD_OBJECT_BODY_FOREACH(body, size, iter) \
119 for ((iter) = spa_pod_prop_first(body); \
120 spa_pod_prop_is_inside(body, size, iter); \
121 (iter) = spa_pod_prop_next(iter))
123 #define SPA_POD_OBJECT_FOREACH(obj, iter) \
124 SPA_POD_OBJECT_BODY_FOREACH(&(obj)->body, SPA_POD_BODY_SIZE(obj), iter)
126 #define SPA_POD_SEQUENCE_BODY_FOREACH(body, size, iter) \
127 for ((iter) = spa_pod_control_first(body); \
128 spa_pod_control_is_inside(body, size, iter); \
129 (iter) = spa_pod_control_next(iter))
131 #define SPA_POD_SEQUENCE_FOREACH(seq, iter) \
132 SPA_POD_SEQUENCE_BODY_FOREACH(&(seq)->body, SPA_POD_BODY_SIZE(seq), iter)
138 if (size <
sizeof(
struct spa_pod) ||
offset + size > maxsize)
250 strncpy(dest, s, maxlen-1);
251 dest[maxlen-1]=
'\0';
345 void *values, uint32_t max_values)
351 n_values =
SPA_MIN(n_values, max_values);
static int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition: iter.h:330
static struct spa_pod_control * spa_pod_control_first(const struct spa_pod_sequence_body *body)
Definition: iter.h:82
static int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
Definition: iter.h:187
static int spa_pod_is_long(const struct spa_pod *pod)
Definition: iter.h:195
static int spa_pod_is_bytes(const struct spa_pod *pod)
Definition: iter.h:260
static struct spa_pod_prop * spa_pod_prop_next(const struct spa_pod_prop *iter)
Definition: iter.h:77
static int spa_pod_fixate(struct spa_pod *pod)
Definition: iter.h:447
static struct spa_pod * spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
Definition: iter.h:367
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:408
static int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
Definition: iter.h:280
static bool spa_pod_control_is_inside(const struct spa_pod_sequence_body *body, uint32_t size, const struct spa_pod_control *iter)
Definition: iter.h:87
#define SPA_POD_VALUE(type, pod)
Definition: pod.h:69
static int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
Definition: iter.h:323
static int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition: iter.h:303
static int spa_pod_is_fd(const struct spa_pod *pod)
Definition: iter.h:289
#define SPA_POD_OBJECT_FOREACH(obj, iter)
Definition: iter.h:128
#define SPA_POD_BODY(pod)
Definition: pod.h:59
static int spa_pod_is_pointer(const struct spa_pod *pod)
Definition: iter.h:274
#define SPA_POD_TYPE(pod)
Definition: pod.h:48
static void * spa_pod_from_data(void *data, size_t maxsize, off_t offset, size_t size)
Definition: iter.h:140
static int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
Definition: iter.h:174
static bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
Definition: iter.h:397
#define SPA_POD_BODY_SIZE(pod)
Definition: pod.h:46
static int spa_pod_get_float(const struct spa_pod *pod, float *value)
Definition: iter.h:213
static int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest)
Definition: iter.h:250
static uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type, void *values, uint32_t max_values)
Definition: iter.h:349
#define SPA_POD_PROP_FLAG_DONT_FIXATE
choices need no fixation
Definition: pod.h:244
static int spa_pod_object_fixate(struct spa_pod_object *pod)
Definition: iter.h:436
static bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
Definition: iter.h:54
static int spa_pod_is_object(const struct spa_pod *pod)
Definition: iter.h:386
static int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
Definition: iter.h:309
static int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:295
static int spa_pod_is_struct(const struct spa_pod *pod)
Definition: iter.h:381
static int spa_pod_is_sequence(const struct spa_pod *pod)
Definition: iter.h:402
#define SPA_POD_ARRAY_VALUE_SIZE(arr)
Definition: pod.h:135
static struct spa_pod_control * spa_pod_control_next(const struct spa_pod_control *iter)
Definition: iter.h:94
#define SPA_POD_CONTROL_SIZE(ev)
Definition: pod.h:251
static int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:200
#define SPA_POD_CONTENTS(type, pod)
Definition: pod.h:55
static int spa_pod_is_string(const struct spa_pod *pod)
Definition: iter.h:234
static int spa_pod_is_fixated(const struct spa_pod *pod)
Definition: iter.h:465
static void * spa_pod_next(const void *iter)
Definition: iter.h:60
static void * spa_pod_get_array(const struct spa_pod *pod, uint32_t *n_values)
Definition: iter.h:342
static int spa_pod_is_choice(const struct spa_pod *pod)
Definition: iter.h:361
static int spa_pod_get_string(const struct spa_pod *pod, const char **value)
Definition: iter.h:242
#define SPA_POD_PROP_SIZE(prop)
Definition: pod.h:225
static int spa_pod_get_double(const struct spa_pod *pod, double *value)
Definition: iter.h:226
static const struct spa_pod_prop * spa_pod_find_prop(const struct spa_pod *pod, const struct spa_pod_prop *start, uint32_t key)
Definition: iter.h:428
static int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
Definition: iter.h:161
#define SPA_POD_OBJECT_TYPE(obj)
Definition: pod.h:193
#define SPA_POD_OBJECT_ID(obj)
Definition: pod.h:195
static bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
Definition: iter.h:392
#define SPA_POD_ARRAY_VALUE_TYPE(arr)
Definition: pod.h:133
static int spa_pod_is_array(const struct spa_pod *pod)
Definition: iter.h:336
static int spa_pod_is_id(const struct spa_pod *pod)
Definition: iter.h:169
static int spa_pod_is_double(const struct spa_pod *pod)
Definition: iter.h:221
#define SPA_POD_CHOICE_N_VALUES(choice)
Definition: pod.h:162
static int spa_pod_is_int(const struct spa_pod *pod)
Definition: iter.h:182
static int spa_pod_is_none(const struct spa_pod *pod)
Definition: iter.h:151
static struct spa_pod_prop * spa_pod_prop_first(const struct spa_pod_object_body *body)
Definition: iter.h:65
static int spa_pod_object_is_fixated(const struct spa_pod_object *pod)
Definition: iter.h:454
static int spa_pod_is_fraction(const struct spa_pod *pod)
Definition: iter.h:317
#define SPA_POD_SIZE(pod)
Definition: pod.h:50
static int spa_pod_is_float(const struct spa_pod *pod)
Definition: iter.h:208
#define SPA_POD_CHOICE_CHILD(choice)
Definition: pod.h:152
#define SPA_POD_ARRAY_N_VALUES(arr)
Definition: pod.h:137
#define SPA_POD_CHOICE_TYPE(choice)
Definition: pod.h:154
static int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
Definition: iter.h:265
#define SPA_POD_ARRAY_VALUES(arr)
Definition: pod.h:139
static int spa_pod_is_bool(const struct spa_pod *pod)
Definition: iter.h:156
static bool spa_pod_prop_is_inside(const struct spa_pod_object_body *body, uint32_t size, const struct spa_pod_prop *iter)
Definition: iter.h:70
@ SPA_CHOICE_None
no choice, first value is current
Definition: pod.h:167
@ SPA_TYPE_Int
Definition: type.h:54
@ SPA_TYPE_Rectangle
Definition: type.h:60
@ SPA_TYPE_Long
Definition: type.h:55
@ SPA_TYPE_Bool
Definition: type.h:52
@ SPA_TYPE_Bytes
Definition: type.h:59
@ SPA_TYPE_Bitmap
Definition: type.h:62
@ SPA_TYPE_Object
Definition: type.h:65
@ SPA_TYPE_Float
Definition: type.h:56
@ SPA_TYPE_Fraction
Definition: type.h:61
@ SPA_TYPE_None
Definition: type.h:51
@ SPA_TYPE_Sequence
Definition: type.h:66
@ SPA_TYPE_Double
Definition: type.h:57
@ SPA_TYPE_Id
Definition: type.h:53
@ SPA_TYPE_Choice
Definition: type.h:69
@ SPA_TYPE_Pointer
Definition: type.h:67
@ SPA_TYPE_Array
Definition: type.h:63
@ SPA_TYPE_String
Definition: type.h:58
@ SPA_TYPE_Fd
Definition: type.h:68
@ SPA_TYPE_Struct
Definition: type.h:64
#define SPA_MIN(a, b)
Definition: defs.h:167
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:336
#define spa_return_val_if_fail(expr, val)
Definition: defs.h:373
#define SPA_FLAG_IS_SET(field, flag)
Definition: defs.h:92
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:210
struct spa_pod pod
Definition: pod.h:183
struct spa_pod value
control value, depends on type
Definition: pod.h:257
uint32_t type
type of control, enum spa_control_type
Definition: pod.h:256
uint32_t offset
media offset
Definition: pod.h:255
struct spa_pod pod
Definition: iter.h:48
uint32_t offset
Definition: iter.h:50
struct spa_pod_frame * parent
Definition: iter.h:49
uint32_t flags
Definition: iter.h:51
struct spa_pod pod
Definition: pod.h:204
struct spa_pod_object_body body
Definition: pod.h:205
struct spa_pod pod
Definition: pod.h:215
uint32_t key
key of property, list of valid keys depends on the object type
Definition: pod.h:229
uint32_t flags
flags for property
Definition: pod.h:245
struct spa_pod value
Definition: pod.h:246
uint32_t type
Definition: pod.h:65
uint32_t size
Definition: pod.h:64