PipeWire 0.3.36
pod/pod.h
Go to the documentation of this file.
1/* Simple Plugin API
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_H
26#define SPA_POD_H
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
32#include <spa/utils/defs.h>
33#include <spa/utils/type.h>
34
40#define SPA_POD_BODY_SIZE(pod) (((struct spa_pod*)(pod))->size)
41#define SPA_POD_TYPE(pod) (((struct spa_pod*)(pod))->type)
42#define SPA_POD_SIZE(pod) (sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod))
43#define SPA_POD_CONTENTS_SIZE(type,pod) (SPA_POD_SIZE(pod)-sizeof(type))
44
45#define SPA_POD_CONTENTS(type,pod) SPA_PTROFF((pod),sizeof(type),void)
46#define SPA_POD_CONTENTS_CONST(type,pod) SPA_PTROFF((pod),sizeof(type),const void)
47#define SPA_POD_BODY(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),void)
48#define SPA_POD_BODY_CONST(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),const void)
49
50struct spa_pod {
51 uint32_t size; /* size of the body */
52 uint32_t type; /* a basic id of enum spa_type */
53};
54
55#define SPA_POD_VALUE(type,pod) (((type*)pod)->value)
56
58 struct spa_pod pod;
59 int32_t value;
60 int32_t _padding;
61};
62
63struct spa_pod_id {
64 struct spa_pod pod;
65 uint32_t value;
66 int32_t _padding;
67};
68
70 struct spa_pod pod;
71 int32_t value;
72 int32_t _padding;
73};
74
76 struct spa_pod pod;
77 int64_t value;
78};
79
81 struct spa_pod pod;
82 float value;
83 int32_t _padding;
84};
85
87 struct spa_pod pod;
88 double value;
89};
90
92 struct spa_pod pod;
93 /* value here */
94};
95
97 struct spa_pod pod;
98 /* value here */
99};
100
102 struct spa_pod pod;
104};
105
107 struct spa_pod pod;
109};
110
112 struct spa_pod pod;
113 /* array of uint8_t follows with the bitmap */
114};
115
116#define SPA_POD_ARRAY_CHILD(arr) (&((struct spa_pod_array*)(arr))->body.child)
117#define SPA_POD_ARRAY_VALUE_TYPE(arr) (SPA_POD_TYPE(SPA_POD_ARRAY_CHILD(arr)))
118#define SPA_POD_ARRAY_VALUE_SIZE(arr) (SPA_POD_BODY_SIZE(SPA_POD_ARRAY_CHILD(arr)))
119#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)
120#define SPA_POD_ARRAY_VALUES(arr) SPA_POD_CONTENTS(struct spa_pod_array, arr)
121
124 /* array with elements of child.size follows */
125};
126
128 struct spa_pod pod;
130};
131
132#define SPA_POD_CHOICE_CHILD(choice) (&((struct spa_pod_choice*)(choice))->body.child)
133#define SPA_POD_CHOICE_TYPE(choice) (((struct spa_pod_choice*)(choice))->body.type)
134#define SPA_POD_CHOICE_FLAGS(choice) (((struct spa_pod_choice*)(choice))->body.flags)
135#define SPA_POD_CHOICE_VALUE_TYPE(choice) (SPA_POD_TYPE(SPA_POD_CHOICE_CHILD(choice)))
136#define SPA_POD_CHOICE_VALUE_SIZE(choice) (SPA_POD_BODY_SIZE(SPA_POD_CHOICE_CHILD(choice)))
137#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)
138#define SPA_POD_CHOICE_VALUES(choice) (SPA_POD_CONTENTS(struct spa_pod_choice, choice))
139
146};
147
149 uint32_t type;
150 uint32_t flags;
152 /* array with elements of child.size follows. Note that there might be more
153 * elements than required by \a type, which should be ignored. */
154};
155
157 struct spa_pod pod;
159};
160
162 struct spa_pod pod;
163 /* one or more spa_pod follow */
164};
165
166#define SPA_POD_OBJECT_TYPE(obj) (((struct spa_pod_object*)(obj))->body.type)
167#define SPA_POD_OBJECT_ID(obj) (((struct spa_pod_object*)(obj))->body.id)
168
170 uint32_t type;
171 uint32_t id;
172 /* contents follow, series of spa_pod_prop */
173};
174
176 struct spa_pod pod;
178};
179
181 uint32_t type;
182 uint32_t _padding;
183 const void *value;
184};
185
187 struct spa_pod pod;
189};
190
192 struct spa_pod pod;
193 int64_t value;
194};
195
196#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
197
198/* props can be inside an object */
200 uint32_t key;
202#define SPA_POD_PROP_FLAG_READONLY (1u<<0)
203#define SPA_POD_PROP_FLAG_HARDWARE (1u<<1)
204#define SPA_POD_PROP_FLAG_HINT_DICT (1u<<2)
209#define SPA_POD_PROP_FLAG_MANDATORY (1u<<3)
210#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4)
211 uint32_t flags;
213 /* value follows */
214};
215
216#define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)
217
218/* controls can be inside a sequence and mark timed values */
220 uint32_t offset;
221 uint32_t type;
222 struct spa_pod value;
223 /* value contents follow */
224};
225
227 uint32_t unit;
228 uint32_t pad;
229 /* series of struct spa_pod_control follows */
230};
231
234 struct spa_pod pod;
236};
237
242#ifdef __cplusplus
243} /* extern "C" */
244#endif
245
246#endif /* SPA_POD_H */
spa_choice_type
Definition: pod/pod.h:140
@ SPA_CHOICE_Step
range with step: default, min, max, step
Definition: pod/pod.h:143
@ SPA_CHOICE_None
no choice, first value is current
Definition: pod/pod.h:141
@ SPA_CHOICE_Flags
flags: default, possible flags,...
Definition: pod/pod.h:145
@ SPA_CHOICE_Range
range: default, min, max
Definition: pod/pod.h:142
@ SPA_CHOICE_Enum
list: default, alternative,...
Definition: pod/pod.h:144
Definition: defs.h:104
Definition: pod/pod.h:122
struct spa_pod child
Definition: pod/pod.h:123
Definition: pod/pod.h:127
struct spa_pod pod
Definition: pod/pod.h:128
struct spa_pod_array_body body
Definition: pod/pod.h:129
Definition: pod/pod.h:111
struct spa_pod pod
Definition: pod/pod.h:112
Definition: pod/pod.h:57
int32_t _padding
Definition: pod/pod.h:60
int32_t value
Definition: pod/pod.h:59
struct spa_pod pod
Definition: pod/pod.h:58
Definition: pod/pod.h:96
struct spa_pod pod
Definition: pod/pod.h:97
Definition: pod/pod.h:148
struct spa_pod child
Definition: pod/pod.h:151
uint32_t type
type of choice, one of enum spa_choice_type
Definition: pod/pod.h:149
uint32_t flags
extra flags
Definition: pod/pod.h:150
Definition: pod/pod.h:156
struct spa_pod_choice_body body
Definition: pod/pod.h:158
struct spa_pod pod
Definition: pod/pod.h:157
Definition: pod/pod.h:219
struct spa_pod value
control value, depends on type
Definition: pod/pod.h:222
uint32_t type
type of control, enum spa_control_type
Definition: pod/pod.h:221
uint32_t offset
media offset
Definition: pod/pod.h:220
Definition: pod/pod.h:86
double value
Definition: pod/pod.h:88
struct spa_pod pod
Definition: pod/pod.h:87
Definition: pod/pod.h:191
int64_t value
Definition: pod/pod.h:193
struct spa_pod pod
Definition: pod/pod.h:192
Definition: pod/pod.h:80
int32_t _padding
Definition: pod/pod.h:83
struct spa_pod pod
Definition: pod/pod.h:81
float value
Definition: pod/pod.h:82
Definition: pod/pod.h:106
struct spa_fraction value
Definition: pod/pod.h:108
struct spa_pod pod
Definition: pod/pod.h:107
Definition: pod/pod.h:63
uint32_t value
Definition: pod/pod.h:65
int32_t _padding
Definition: pod/pod.h:66
struct spa_pod pod
Definition: pod/pod.h:64
Definition: pod/pod.h:69
struct spa_pod pod
Definition: pod/pod.h:70
int32_t _padding
Definition: pod/pod.h:72
int32_t value
Definition: pod/pod.h:71
Definition: pod/pod.h:75
int64_t value
Definition: pod/pod.h:77
struct spa_pod pod
Definition: pod/pod.h:76
Definition: pod/pod.h:169
uint32_t type
one of enum spa_type
Definition: pod/pod.h:170
uint32_t id
id of the object, depends on the object type
Definition: pod/pod.h:171
Definition: pod/pod.h:175
struct spa_pod pod
Definition: pod/pod.h:176
struct spa_pod_object_body body
Definition: pod/pod.h:177
Definition: pod/pod.h:180
const void * value
Definition: pod/pod.h:183
uint32_t _padding
Definition: pod/pod.h:182
uint32_t type
pointer id, one of enum spa_type
Definition: pod/pod.h:181
Definition: pod/pod.h:186
struct spa_pod_pointer_body body
Definition: pod/pod.h:188
struct spa_pod pod
Definition: pod/pod.h:187
Definition: pod/pod.h:199
uint32_t key
key of property, list of valid keys depends on the object type
Definition: pod/pod.h:200
uint32_t flags
flags for property
Definition: pod/pod.h:211
struct spa_pod value
Definition: pod/pod.h:212
Definition: pod/pod.h:101
struct spa_pod pod
Definition: pod/pod.h:102
struct spa_rectangle value
Definition: pod/pod.h:103
Definition: pod/pod.h:226
uint32_t pad
Definition: pod/pod.h:228
uint32_t unit
Definition: pod/pod.h:227
a sequence of timed controls
Definition: pod/pod.h:233
struct spa_pod pod
Definition: pod/pod.h:234
struct spa_pod_sequence_body body
Definition: pod/pod.h:235
Definition: pod/pod.h:91
struct spa_pod pod
Definition: pod/pod.h:92
Definition: pod/pod.h:161
struct spa_pod pod
Definition: pod/pod.h:162
Definition: pod/pod.h:50
uint32_t type
Definition: pod/pod.h:52
uint32_t size
Definition: pod/pod.h:51
Definition: defs.h:86