+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
main
| 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 |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | /** |
| 16 | * \addtogroup spa_pod |
| 17 | * \{ |
| 18 | */ |
| 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 | |
| 49 | struct spa_pod_bool { |
| 50 | struct spa_pod pod; |
| 51 | int32_t value; |
| 52 | int32_t _padding; |
| 53 | }; |
| 54 | |
| 55 | struct spa_pod_id { |
| 56 | struct spa_pod pod; |
| 57 | uint32_t value; |
| 58 | int32_t _padding; |
| 59 | }; |
| 60 | |
| 61 | struct 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 | |
| 93 | struct spa_pod_rectangle { |
| 94 | struct spa_pod pod; |
| 95 | struct spa_rectangle value; |
| 96 | }; |
| 97 | |
| 98 | struct spa_pod_fraction { |
| 99 | struct spa_pod pod; |
| 100 | struct spa_fraction value; |
| 101 | }; |
| 102 | |
| 103 | struct 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 | |
| 132 | enum spa_choice_type { |
| 133 | SPA_CHOICE_None, /**< no choice, first value is current */ |
| 134 | SPA_CHOICE_Range, /**< range: default, min, max */ |
| 135 | SPA_CHOICE_Step, /**< range with step: default, min, max, step */ |
| 136 | SPA_CHOICE_Enum, /**< list: default, alternative,... */ |
| 137 | SPA_CHOICE_Flags, /**< flags: first value is flags */ |
| 138 | }; |
| 139 | |
| 140 | struct spa_pod_choice_body { |
| 141 | uint32_t type; /**< type of choice, one of enum spa_choice_type */ |
| 142 | uint32_t flags; /**< extra 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; /**< one of enum spa_type */ |
| 166 | uint32_t id; /**< id of the object, depends on the object type */ |
| 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 | |
| 175 | struct spa_pod_pointer_body { |
| 176 | uint32_t type; /**< pointer id, one of enum spa_type */ |
| 177 | uint32_t _padding; |
| 178 | const void *value; |
| 179 | }; |
| 180 | |
| 181 | struct 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; /**< key of property, list of valid keys depends on the |
| 196 | * object type */ |
| 197 | #define SPA_POD_PROP_FLAG_READONLY (1u<<0) /**< is read-only */ |
| 198 | #define SPA_POD_PROP_FLAG_HARDWARE (1u<<1) /**< some sort of hardware parameter */ |
| 199 | #define SPA_POD_PROP_FLAG_HINT_DICT (1u<<2) /**< contains a dictionary struct as |
| 200 | * (Struct( |
| 201 | * Int : n_items, |
| 202 | * (String : key, |
| 203 | * String : value)*)) */ |
| 204 | #define SPA_POD_PROP_FLAG_MANDATORY (1u<<3) /**< is mandatory, when filtering, both sides |
| 205 | * need this property or filtering fails. */ |
| 206 | #define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4) /**< choices need no fixation */ |
| 207 | #define SPA_POD_PROP_FLAG_DROP (1u<<5) /**< drop property, when filtering, both sides |
| 208 | * need the property or it will be dropped. */ |
| 209 | uint32_t flags; /**< flags for property */ |
| 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 */ |
| 217 | struct spa_pod_control { |
| 218 | uint32_t offset; /**< media offset */ |
| 219 | uint32_t type; /**< type of control, enum spa_control_type */ |
| 220 | struct spa_pod value; /**< control value, depends on type */ |
| 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 | |
| 230 | /** a sequence of timed controls */ |
| 231 | struct spa_pod_sequence { |
| 232 | struct spa_pod pod; |
| 233 | struct spa_pod_sequence_body body; |
| 234 | }; |
| 235 | |
| 236 | /** |
| 237 | * \} |
| 238 | */ |
| 239 | |
| 240 | #ifdef __cplusplus |
| 241 | } /* extern "C" */ |
| 242 | #endif |
| 243 | |
| 244 | #endif /* SPA_POD_H */ |