PipeWire 1.5.0
Loading...
Searching...
No Matches
pod.h
Go to the documentation of this file.
1/* Simple Plugin API */
2/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3/* SPDX-License-Identifier: MIT */
4
5#ifndef SPA_POD_H
6#define SPA_POD_H
7
8#include <spa/utils/defs.h>
9#include <spa/utils/type.h>
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
20#define SPA_POD_ALIGN 8
21#define SPA_POD_MAX_SIZE (1u<<20)
22
23#define SPA_POD_BODY_SIZE(pod) (((struct spa_pod*)(pod))->size)
24#define SPA_POD_TYPE(pod) (((struct spa_pod*)(pod))->type)
25#define SPA_POD_SIZE(pod) ((uint64_t)sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod))
26#define SPA_POD_CONTENTS_SIZE(type,pod) (SPA_POD_SIZE(pod)-sizeof(type))
27
28#define SPA_POD_CONTENTS(type,pod) SPA_PTROFF((pod),sizeof(type),void)
29#define SPA_POD_CONTENTS_CONST(type,pod) SPA_PTROFF((pod),sizeof(type),const void)
30#define SPA_POD_BODY(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),void)
31#define SPA_POD_BODY_CONST(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),const void)
32
33#define SPA_POD_IS_VALID(pod) \
34 (SPA_POD_BODY_SIZE(pod) < SPA_POD_MAX_SIZE)
35#define SPA_POD_CHECK_TYPE(pod,_type) \
36 (SPA_POD_IS_VALID(pod) && \
37 (pod)->type == (_type))
38#define SPA_POD_CHECK(pod,_type,_size) \
39 (SPA_POD_CHECK_TYPE(pod,_type) && (pod)->size >= (_size))
41
42struct spa_pod {
43 uint32_t size; /* size of the body */
44 uint32_t type; /* a basic id of enum spa_type */
45};
47#define SPA_POD_VALUE(type,pod) (((type*)(pod))->value)
49struct spa_pod_bool {
50 struct spa_pod pod;
51 int32_t value;
52 int32_t _padding;
53};
54
55struct spa_pod_id {
56 struct spa_pod pod;
57 uint32_t value;
58 int32_t _padding;
59};
60
61struct spa_pod_int {
62 struct spa_pod pod;
63 int32_t value;
64 int32_t _padding;
65};
68 struct spa_pod pod;
69 int64_t value;
70};
73 struct spa_pod pod;
74 float value;
75 int32_t _padding;
76};
79 struct spa_pod pod;
80 double value;
81};
82
84 struct spa_pod pod;
85 /* value here */
86};
87
89 struct spa_pod pod;
90 /* value here */
91};
92
93struct spa_pod_rectangle {
94 struct spa_pod pod;
96};
97
98struct spa_pod_fraction {
99 struct spa_pod pod;
101};
102
103struct spa_pod_bitmap {
104 struct spa_pod pod;
105 /* array of uint8_t follows with the bitmap */
106};
107
108#define SPA_POD_ARRAY_CHILD(arr) (&((struct spa_pod_array*)(arr))->body.child)
109#define SPA_POD_ARRAY_VALUE_TYPE(arr) (SPA_POD_ARRAY_CHILD(arr)->type)
110#define SPA_POD_ARRAY_VALUE_SIZE(arr) (SPA_POD_ARRAY_CHILD(arr)->size)
111#define SPA_POD_ARRAY_N_VALUES(arr) (SPA_POD_ARRAY_VALUE_SIZE(arr) ? ((SPA_POD_BODY_SIZE(arr) - sizeof(struct spa_pod_array_body)) / SPA_POD_ARRAY_VALUE_SIZE(arr)) : 0)
112#define SPA_POD_ARRAY_VALUES(arr) SPA_POD_CONTENTS(struct spa_pod_array, arr)
113
116 /* array with elements of child.size follows */
117};
118
120 struct spa_pod pod;
122};
123
124#define SPA_POD_CHOICE_CHILD(choice) (&((struct spa_pod_choice*)(choice))->body.child)
125#define SPA_POD_CHOICE_TYPE(choice) (((struct spa_pod_choice*)(choice))->body.type)
126#define SPA_POD_CHOICE_FLAGS(choice) (((struct spa_pod_choice*)(choice))->body.flags)
127#define SPA_POD_CHOICE_VALUE_TYPE(choice) (SPA_POD_CHOICE_CHILD(choice)->type)
128#define SPA_POD_CHOICE_VALUE_SIZE(choice) (SPA_POD_CHOICE_CHILD(choice)->size)
129#define SPA_POD_CHOICE_N_VALUES(choice) (SPA_POD_CHOICE_VALUE_SIZE(choice) ? ((SPA_POD_BODY_SIZE(choice) - sizeof(struct spa_pod_choice_body)) / SPA_POD_CHOICE_VALUE_SIZE(choice)) : 0)
130#define SPA_POD_CHOICE_VALUES(choice) (SPA_POD_CONTENTS(struct spa_pod_choice, choice))
132enum spa_choice_type {
139
141 uint32_t type;
142 uint32_t flags;
143 struct spa_pod child;
144 /* array with elements of child.size follows. Note that there might be more
145 * elements than required by \a type, which should be ignored. */
147
149 struct spa_pod pod;
151};
153#define SPA_POD_STRUCT_BODY(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),struct spa_pod)
154#define SPA_POD_STRUCT_BODY_CONST(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),const struct spa_pod)
155
157 struct spa_pod pod;
158 /* one or more spa_pod follow */
159};
161#define SPA_POD_OBJECT_TYPE(obj) (((struct spa_pod_object*)(obj))->body.type)
162#define SPA_POD_OBJECT_ID(obj) (((struct spa_pod_object*)(obj))->body.id)
165 uint32_t type;
166 uint32_t id;
167 /* contents follow, series of spa_pod_prop */
171 struct spa_pod pod;
173};
174
176 uint32_t type;
177 uint32_t _padding;
178 const void *value;
179};
180
181struct spa_pod_pointer {
182 struct spa_pod pod;
185
187 struct spa_pod pod;
188 int64_t value;
189};
190
191#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
193/* props can be inside an object */
195 uint32_t key;
197#define SPA_POD_PROP_FLAG_READONLY (1u<<0)
198#define SPA_POD_PROP_FLAG_HARDWARE (1u<<1)
199#define SPA_POD_PROP_FLAG_HINT_DICT (1u<<2)
204#define SPA_POD_PROP_FLAG_MANDATORY (1u<<3)
206#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4)
207#define SPA_POD_PROP_FLAG_DROP (1u<<5)
209 uint32_t flags;
211 /* value follows */
212};
214#define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)
216/* controls can be inside a sequence and mark timed values */
217struct spa_pod_control {
218 uint32_t offset;
219 uint32_t type;
220 struct spa_pod value;
221 /* value contents follow */
222};
223
225 uint32_t unit;
226 uint32_t pad;
227 /* series of struct spa_pod_control follows */
229
232 struct spa_pod pod;
234};
240#ifdef __cplusplus
241} /* extern "C" */
242#endif
243
244#endif /* SPA_POD_H */
spa/utils/defs.h
spa_choice_type
Definition pod.h:160
@ SPA_CHOICE_Step
range with step: default, min, max, step
Definition pod.h:163
@ SPA_CHOICE_None
no choice, first value is current
Definition pod.h:161
@ SPA_CHOICE_Flags
flags: first value is flags
Definition pod.h:165
@ SPA_CHOICE_Range
range: default, min, max
Definition pod.h:162
@ SPA_CHOICE_Enum
list: default, alternative,...
Definition pod.h:164
spa/utils/type.h
Definition defs.h:137
Definition pod.h:135
struct spa_pod child
Definition pod.h:136
Definition pod.h:140
struct spa_pod pod
Definition pod.h:141
struct spa_pod_array_body body
Definition pod.h:142
Definition pod.h:119
struct spa_pod pod
Definition pod.h:120
Definition pod.h:65
int32_t _padding
Definition pod.h:68
int32_t value
Definition pod.h:67
struct spa_pod pod
Definition pod.h:66
Definition pod.h:104
struct spa_pod pod
Definition pod.h:105
Definition pod.h:168
struct spa_pod child
Definition pod.h:171
uint32_t type
type of choice, one of enum spa_choice_type
Definition pod.h:169
uint32_t flags
extra flags
Definition pod.h:170
Definition pod.h:176
struct spa_pod_choice_body body
Definition pod.h:178
struct spa_pod pod
Definition pod.h:177
Definition pod.h:257
struct spa_pod value
control value, depends on type
Definition pod.h:260
uint32_t type
type of control, enum spa_control_type
Definition pod.h:259
uint32_t offset
media offset
Definition pod.h:258
Definition pod.h:94
double value
Definition pod.h:96
struct spa_pod pod
Definition pod.h:95
Definition pod.h:218
int64_t value
Definition pod.h:220
struct spa_pod pod
Definition pod.h:219
Definition pod.h:88
int32_t _padding
Definition pod.h:91
struct spa_pod pod
Definition pod.h:89
float value
Definition pod.h:90
Definition pod.h:114
struct spa_fraction value
Definition pod.h:116
struct spa_pod pod
Definition pod.h:115
Definition pod.h:71
uint32_t value
Definition pod.h:73
int32_t _padding
Definition pod.h:74
struct spa_pod pod
Definition pod.h:72
Definition pod.h:77
struct spa_pod pod
Definition pod.h:78
int32_t _padding
Definition pod.h:80
int32_t value
Definition pod.h:79
Definition pod.h:83
int64_t value
Definition pod.h:85
struct spa_pod pod
Definition pod.h:84
Definition pod.h:196
uint32_t type
one of enum spa_type
Definition pod.h:197
uint32_t id
id of the object, depends on the object type
Definition pod.h:198
Definition pod.h:202
struct spa_pod pod
Definition pod.h:203
struct spa_pod_object_body body
Definition pod.h:204
Definition pod.h:207
const void * value
Definition pod.h:210
uint32_t _padding
Definition pod.h:209
uint32_t type
pointer id, one of enum spa_type
Definition pod.h:208
Definition pod.h:213
struct spa_pod_pointer_body body
Definition pod.h:215
struct spa_pod pod
Definition pod.h:214
Definition pod.h:227
uint32_t key
key of property, list of valid keys depends on the object type
Definition pod.h:228
uint32_t flags
flags for property
Definition pod.h:248
struct spa_pod value
Definition pod.h:249
Definition pod.h:109
struct spa_pod pod
Definition pod.h:110
struct spa_rectangle value
Definition pod.h:111
Definition pod.h:264
uint32_t pad
Definition pod.h:266
uint32_t unit
Definition pod.h:265
a sequence of timed controls
Definition pod.h:271
struct spa_pod pod
Definition pod.h:272
struct spa_pod_sequence_body body
Definition pod.h:273
Definition pod.h:99
struct spa_pod pod
Definition pod.h:100
Definition pod.h:186
struct spa_pod pod
Definition pod.h:187
Definition pod.h:57
uint32_t type
Definition pod.h:59
uint32_t size
Definition pod.h:58
Definition defs.h:116