PipeWire: spa/pod/pod.h Source File

PipeWire 1.6.7

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
19
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))
40
41
42 struct spa_pod {
43 uint32_t size; /* size of the body */
44 uint32_t type; /* a basic id of enum spa_type */
45};
46
47#define SPA_POD_VALUE(type,pod) (((type*)(pod))->value)
48
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};
66
67 struct spa_pod_long {
68 struct spa_pod pod;
69 int64_t value;
70};
71
72 struct spa_pod_float {
73 struct spa_pod pod;
74 float value;
75 int32_t _padding;
76};
77
78 struct spa_pod_double {
79 struct spa_pod pod;
80 double value;
81};
82
83 struct spa_pod_string {
84 struct spa_pod pod;
85 /* value here */
86};
87
88 struct spa_pod_bytes {
89 struct spa_pod pod;
90 /* value here */
91};
92
93struct spa_pod_rectangle {
94 struct spa_pod pod;
95 struct spa_rectangle value;
96};
97
98struct spa_pod_fraction {
99 struct spa_pod pod;
100 struct spa_fraction value;
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
114 struct spa_pod_array_body {
115 struct spa_pod child;
116 /* array with elements of child.size follows */
117};
118
119 struct spa_pod_array {
120 struct spa_pod pod;
121 struct spa_pod_array_body body;
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))
131
132enum spa_choice_type {
133 SPA_CHOICE_None,
134 SPA_CHOICE_Range,
135 SPA_CHOICE_Step,
136 SPA_CHOICE_Enum,
137 SPA_CHOICE_Flags,
138};
139
140 struct spa_pod_choice_body {
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. */
146};
147
148 struct spa_pod_choice {
149 struct spa_pod pod;
150 struct spa_pod_choice_body body;
151};
152
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
156 struct spa_pod_struct {
157 struct spa_pod pod;
158 /* one or more spa_pod follow */
159};
160
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)
163
164 struct spa_pod_object_body {
165 uint32_t type;
166 uint32_t id;
167 /* contents follow, series of spa_pod_prop */
168};
169
170 struct spa_pod_object {
171 struct spa_pod pod;
172 struct spa_pod_object_body body;
173};
174
175struct spa_pod_pointer_body {
176 uint32_t type;
177 uint32_t _padding;
178 const void *value;
179};
180
181struct spa_pod_pointer {
182 struct spa_pod pod;
183 struct spa_pod_pointer_body body;
184};
185
186 struct spa_pod_fd {
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)
192
193/* props can be inside an object */
194 struct spa_pod_prop {
195 uint32_t key;
196 * object type */
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)
201
202 * (String : key,
203 * String : value)*)) */
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;
210 struct spa_pod value;
211 /* value follows */
212};
213
214#define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)
215
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
224 struct spa_pod_sequence_body {
225 uint32_t unit;
226 uint32_t pad;
227 /* series of struct spa_pod_control follows */
228};
229
231 struct spa_pod_sequence {
232 struct spa_pod pod;
233 struct spa_pod_sequence_body body;
234};
235
239
240#ifdef __cplusplus
241} /* extern "C" */
242#endif
243
244#endif /* SPA_POD_H */
defs.h
spa/utils/defs.h
id
uint32_t id
Definition core.h:432
spa_choice_type
spa_choice_type
Definition pod.h:160
SPA_CHOICE_Step
@ SPA_CHOICE_Step
range with step: default, min, max, step
Definition pod.h:163
SPA_CHOICE_None
@ SPA_CHOICE_None
no choice, first value is current
Definition pod.h:161
SPA_CHOICE_Flags
@ SPA_CHOICE_Flags
flags: first value is flags
Definition pod.h:165
SPA_CHOICE_Range
@ SPA_CHOICE_Range
range: default, min, max
Definition pod.h:162
SPA_CHOICE_Enum
@ SPA_CHOICE_Enum
list: default, alternative,...
Definition pod.h:164
type.h
spa/utils/type.h
spa_fraction
Definition defs.h:137
spa_pod_array_body
Definition pod.h:135
spa_pod_array_body::child
struct spa_pod child
Definition pod.h:136
spa_pod_array
Definition pod.h:140
spa_pod_array::body
struct spa_pod_array_body body
Definition pod.h:142
spa_pod_bitmap
Definition pod.h:119
spa_pod_bitmap::pod
struct spa_pod pod
Definition pod.h:120
spa_pod_bool
Definition pod.h:65
spa_pod_bool::_padding
int32_t _padding
Definition pod.h:68
spa_pod_bool::value
int32_t value
Definition pod.h:67
spa_pod_bool::pod
struct spa_pod pod
Definition pod.h:66
spa_pod_bytes
Definition pod.h:104
spa_pod_bytes::pod
struct spa_pod pod
Definition pod.h:105
spa_pod_choice_body
Definition pod.h:168
spa_pod_choice_body::child
struct spa_pod child
Definition pod.h:171
spa_pod_choice_body::type
uint32_t type
type of choice, one of enum spa_choice_type
Definition pod.h:169
spa_pod_choice_body::flags
uint32_t flags
extra flags
Definition pod.h:170
spa_pod_choice
Definition pod.h:176
spa_pod_choice::body
struct spa_pod_choice_body body
Definition pod.h:178
spa_pod_choice::pod
struct spa_pod pod
Definition pod.h:177
spa_pod_control
Definition pod.h:257
spa_pod_control::type
uint32_t type
type of control, enum spa_control_type
Definition pod.h:259
spa_pod_control::offset
uint32_t offset
media offset
Definition pod.h:258
spa_pod_double
Definition pod.h:94
spa_pod_double::value
double value
Definition pod.h:96
spa_pod_double::pod
struct spa_pod pod
Definition pod.h:95
spa_pod_fd
Definition pod.h:218
spa_pod_fd::value
int64_t value
Definition pod.h:220
spa_pod_float
Definition pod.h:88
spa_pod_float::pod
struct spa_pod pod
Definition pod.h:89
spa_pod_fraction
Definition pod.h:114
spa_pod_fraction::value
struct spa_fraction value
Definition pod.h:116
spa_pod_id
Definition pod.h:71
spa_pod_id::value
uint32_t value
Definition pod.h:73
spa_pod_id::_padding
int32_t _padding
Definition pod.h:74
spa_pod_id::pod
struct spa_pod pod
Definition pod.h:72
spa_pod_int
Definition pod.h:77
spa_pod_int::pod
struct spa_pod pod
Definition pod.h:78
spa_pod_int::_padding
int32_t _padding
Definition pod.h:80
spa_pod_int::value
int32_t value
Definition pod.h:79
spa_pod_long
Definition pod.h:83
spa_pod_long::pod
struct spa_pod pod
Definition pod.h:84
spa_pod_object_body
Definition pod.h:196
spa_pod_object_body::type
uint32_t type
one of enum spa_type
Definition pod.h:197
spa_pod_object
Definition pod.h:202
spa_pod_object::pod
struct spa_pod pod
Definition pod.h:203
spa_pod_object::body
struct spa_pod_object_body body
Definition pod.h:204
spa_pod_pointer_body
Definition pod.h:207
spa_pod_pointer_body::value
const void * value
Definition pod.h:210
spa_pod_pointer_body::_padding
uint32_t _padding
Definition pod.h:209
spa_pod_pointer_body::type
uint32_t type
pointer id, one of enum spa_type
Definition pod.h:208
spa_pod_pointer
Definition pod.h:213
spa_pod_pointer::body
struct spa_pod_pointer_body body
Definition pod.h:215
spa_pod_pointer::pod
struct spa_pod pod
Definition pod.h:214
spa_pod_prop
Definition pod.h:227
spa_pod_prop::key
uint32_t key
key of property, list of valid keys depends on the object type
Definition pod.h:228
spa_pod_prop::flags
uint32_t flags
flags for property
Definition pod.h:248
spa_pod_rectangle
Definition pod.h:109
spa_pod_sequence_body
Definition pod.h:264
spa_pod_sequence_body::pad
uint32_t pad
Definition pod.h:266
spa_pod_sequence_body::unit
uint32_t unit
Definition pod.h:265
spa_pod_sequence
a sequence of timed controls
Definition pod.h:271
spa_pod_sequence::pod
struct spa_pod pod
Definition pod.h:272
spa_pod_sequence::body
struct spa_pod_sequence_body body
Definition pod.h:273
spa_pod_string
Definition pod.h:99
spa_pod_string::pod
struct spa_pod pod
Definition pod.h:100
spa_pod_struct
Definition pod.h:186
spa_pod_struct::pod
struct spa_pod pod
Definition pod.h:187
spa_pod
Definition pod.h:57
spa_pod::type
uint32_t type
Definition pod.h:59
spa_pod::size
uint32_t size
Definition pod.h:58
spa_rectangle
Definition defs.h:116