Go to the documentation of this file.
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);
int spa_pod_get_long(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:195
@ SPA_TYPE_None
Definition: build-12683127/doc/spa/utils/type.h:45
Definition: pod/pod.h:175
@ SPA_TYPE_Float
Definition: build-12683127/doc/spa/utils/type.h:50
@ SPA_TYPE_Long
Definition: build-12683127/doc/spa/utils/type.h:49
Definition: pod/pod.h:191
Definition: pod/pod.h:156
#define spa_return_val_if_fail(expr, val)
Definition: defs.h:251
bool spa_pod_is_object_id(const struct spa_pod *pod, uint32_t id)
Definition: iter.h:392
void * spa_pod_next(const void *iter)
Definition: iter.h:55
#define SPA_POD_PROP_FLAG_DONT_FIXATE
choices need no fixation
Definition: pod/pod.h:210
#define SPA_POD_ARRAY_VALUES(arr)
Definition: pod/pod.h:120
#define SPA_POD_OBJECT_FOREACH(obj, iter)
Definition: iter.h:123
#define SPA_POD_CHOICE_N_VALUES(choice)
Definition: pod/pod.h:137
int spa_pod_copy_string(const struct spa_pod *pod, size_t maxlen, char *dest)
Definition: iter.h:245
@ SPA_TYPE_Id
Definition: build-12683127/doc/spa/utils/type.h:47
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:82
@ SPA_TYPE_Int
Definition: build-12683127/doc/spa/utils/type.h:48
Definition: pod/pod.h:180
int spa_pod_is_id(const struct spa_pod *pod)
Definition: iter.h:164
#define SPA_POD_VALUE(type, pod)
Definition: pod/pod.h:55
user data to add to an object
Definition: filter.c:75
Definition: pod/pod.h:169
Definition: pod/pod.h:199
int spa_pod_is_array(const struct spa_pod *pod)
Definition: iter.h:331
int spa_pod_is_choice(const struct spa_pod *pod)
Definition: iter.h:356
Definition: pod/pod.h:219
int spa_pod_is_rectangle(const struct spa_pod *pod)
Definition: iter.h:298
#define SPA_ROUND_UP_N(num, align)
Definition: defs.h:223
int spa_pod_get_fd(const struct spa_pod *pod, int64_t *value)
Definition: iter.h:290
int spa_pod_get_rectangle(const struct spa_pod *pod, struct spa_rectangle *value)
Definition: iter.h:304
int spa_pod_get_pointer(const struct spa_pod *pod, uint32_t *type, const void **value)
Definition: iter.h:275
int spa_pod_is_int(const struct spa_pod *pod)
Definition: iter.h:177
#define SPA_POD_CHOICE_CHILD(choice)
Definition: pod/pod.h:132
int spa_pod_get_double(const struct spa_pod *pod, double *value)
Definition: iter.h:221
@ SPA_TYPE_Array
Definition: build-12683127/doc/spa/utils/type.h:57
Definition: pod/pod.h:186
#define SPA_POD_TYPE(pod)
Definition: pod/pod.h:41
@ SPA_TYPE_Rectangle
Definition: build-12683127/doc/spa/utils/type.h:54
int spa_pod_object_fixate(struct spa_pod_object *pod)
Definition: iter.h:431
Definition: pod/pod.h:148
int spa_pod_get_int(const struct spa_pod *pod, int32_t *value)
Definition: iter.h:182
bool spa_pod_is_inside(const void *pod, uint32_t size, const void *iter)
Definition: iter.h:49
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
#define SPA_POD_OBJECT_ID(obj)
Definition: pod/pod.h:167
Definition: pod/pod.h:101
@ SPA_TYPE_Pointer
Definition: build-12683127/doc/spa/utils/type.h:61
struct spa_pod_frame * parent
Definition: iter.h:44
Definition: pod/pod.h:226
@ SPA_TYPE_Fd
Definition: build-12683127/doc/spa/utils/type.h:62
int spa_pod_is_sequence(const struct spa_pod *pod)
Definition: iter.h:397
int spa_pod_get_fraction(const struct spa_pod *pod, struct spa_fraction *value)
Definition: iter.h:318
struct spa_pod_prop * spa_pod_prop_next(const struct spa_pod_prop *iter)
Definition: iter.h:72
int spa_pod_get_bool(const struct spa_pod *pod, bool *value)
Definition: iter.h:156
bool spa_pod_is_object_type(const struct spa_pod *pod, uint32_t type)
Definition: iter.h:387
int spa_pod_fixate(struct spa_pod *pod)
Definition: iter.h:442
@ SPA_TYPE_String
Definition: build-12683127/doc/spa/utils/type.h:52
@ SPA_TYPE_Bitmap
Definition: build-12683127/doc/spa/utils/type.h:56
int spa_pod_is_long(const struct spa_pod *pod)
Definition: iter.h:190
int spa_pod_is_bitmap(const struct spa_pod *pod)
Definition: iter.h:325
struct spa_pod_object_body body
Definition: pod/pod.h:177
int spa_pod_get_id(const struct spa_pod *pod, uint32_t *value)
Definition: iter.h:169
uint32_t type
type of control, enum spa_control_type
Definition: pod/pod.h:221
int spa_pod_is_float(const struct spa_pod *pod)
Definition: iter.h:203
void * spa_pod_from_data(void *data, size_t maxsize, off_t offset, size_t size)
Definition: iter.h:135
struct spa_pod_control * spa_pod_control_next(const struct spa_pod_control *iter)
Definition: iter.h:89
uint32_t offset
Definition: iter.h:45
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:65
struct spa_pod * spa_pod_get_values(const struct spa_pod *pod, uint32_t *n_vals, uint32_t *choice)
Definition: iter.h:362
@ SPA_TYPE_Bool
Definition: build-12683127/doc/spa/utils/type.h:46
#define SPA_POD_ARRAY_VALUE_SIZE(arr)
Definition: pod/pod.h:118
Definition: pod/pod.h:122
int spa_pod_is_pointer(const struct spa_pod *pod)
Definition: iter.h:269
#define SPA_POD_BODY(pod)
Definition: pod/pod.h:47
struct spa_pod pod
Definition: pod/pod.h:187
int spa_pod_get_bytes(const struct spa_pod *pod, const void **value, uint32_t *len)
Definition: iter.h:260
uint32_t key
key of property, list of valid keys depends on the object type
Definition: pod/pod.h:200
#define SPA_FLAG_IS_SET(field, flag)
Definition: defs.h:73
uint32_t size
Definition: pod/pod.h:51
int spa_pod_is_none(const struct spa_pod *pod)
Definition: iter.h:146
@ SPA_TYPE_Bytes
Definition: build-12683127/doc/spa/utils/type.h:53
struct spa_pod_control * spa_pod_control_first(const struct spa_pod_sequence_body *body)
Definition: iter.h:77
int spa_pod_is_fraction(const struct spa_pod *pod)
Definition: iter.h:312
@ SPA_TYPE_Double
Definition: build-12683127/doc/spa/utils/type.h:51
#define SPA_POD_BODY_SIZE(pod)
Definition: pod/pod.h:40
@ SPA_TYPE_Object
Definition: build-12683127/doc/spa/utils/type.h:59
@ SPA_TYPE_Sequence
Definition: build-12683127/doc/spa/utils/type.h:60
struct spa_pod value
control value, depends on type
Definition: pod/pod.h:222
struct spa_pod_prop * spa_pod_prop_first(const struct spa_pod_object_body *body)
Definition: iter.h:60
#define SPA_POD_OBJECT_TYPE(obj)
Definition: pod/pod.h:166
void * spa_pod_get_array(const struct spa_pod *pod, uint32_t *n_values)
Definition: iter.h:337
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:423
int spa_pod_is_double(const struct spa_pod *pod)
Definition: iter.h:216
struct spa_pod pod
Definition: pod/pod.h:176
int spa_pod_is_bytes(const struct spa_pod *pod)
Definition: iter.h:255
@ SPA_TYPE_Fraction
Definition: build-12683127/doc/spa/utils/type.h:55
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
int spa_pod_get_float(const struct spa_pod *pod, float *value)
Definition: iter.h:208
@ SPA_CHOICE_None
no choice, first value is current
Definition: pod/pod.h:141
#define SPA_MIN(a, b)
Definition: defs.h:123
uint32_t flags
Definition: iter.h:46
int spa_pod_is_string(const struct spa_pod *pod)
Definition: iter.h:229
struct spa_pod pod
Definition: pod/pod.h:157
uint32_t type
Definition: pod/pod.h:52
uint32_t spa_pod_copy_array(const struct spa_pod *pod, uint32_t type, void *values, uint32_t max_values)
Definition: iter.h:344
uint32_t flags
flags for property
Definition: pod/pod.h:211
int spa_pod_is_struct(const struct spa_pod *pod)
Definition: iter.h:376
struct spa_pod pod
Definition: iter.h:43
#define SPA_POD_SIZE(pod)
Definition: pod/pod.h:42
@ SPA_TYPE_Choice
Definition: build-12683127/doc/spa/utils/type.h:63
int spa_pod_get_string(const struct spa_pod *pod, const char **value)
Definition: iter.h:237
int spa_pod_is_bool(const struct spa_pod *pod)
Definition: iter.h:151
#define SPA_POD_CONTENTS(type, pod)
Definition: pod/pod.h:45
struct spa_pod value
Definition: pod/pod.h:212
#define SPA_POD_ARRAY_VALUE_TYPE(arr)
Definition: pod/pod.h:117
#define SPA_POD_ARRAY_N_VALUES(arr)
Definition: pod/pod.h:119
int spa_pod_is_object(const struct spa_pod *pod)
Definition: iter.h:381
#define SPA_POD_CHOICE_TYPE(choice)
Definition: pod/pod.h:133
uint32_t offset
media offset
Definition: pod/pod.h:220
int spa_pod_is_fd(const struct spa_pod *pod)
Definition: iter.h:284
#define SPA_POD_PROP_SIZE(prop)
Definition: pod/pod.h:196
@ SPA_TYPE_Struct
Definition: build-12683127/doc/spa/utils/type.h:58
Definition: pod/pod.h:106
#define SPA_POD_CONTROL_SIZE(ev)
Definition: pod/pod.h:216