Loading...
Searching...
No Matches
pod.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_POD_H
#define SPA_POD_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/type.h>
#define SPA_POD_BODY_SIZE(pod) (((struct spa_pod*)(pod))->size)
#define SPA_POD_TYPE(pod) (((struct spa_pod*)(pod))->type)
#define SPA_POD_SIZE(pod) ((uint64_t)sizeof(struct spa_pod) + SPA_POD_BODY_SIZE(pod))
#define SPA_POD_CONTENTS_SIZE(type,pod) (SPA_POD_SIZE(pod)-sizeof(type))
#define SPA_POD_CONTENTS(type,pod) SPA_PTROFF((pod),sizeof(type),void)
#define SPA_POD_CONTENTS_CONST(type,pod) SPA_PTROFF((pod),sizeof(type),const void)
#define SPA_POD_BODY(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),void)
#define SPA_POD_BODY_CONST(pod) SPA_PTROFF((pod),sizeof(struct spa_pod),const void)
struct spa_pod {
uint32_t size; /* size of the body */
uint32_t type; /* a basic id of enum spa_type */
};
#define SPA_POD_VALUE(type,pod) (((type*)(pod))->value)
struct spa_pod_bool {
struct spa_pod pod;
int32_t value;
int32_t _padding;
};
struct spa_pod_id {
struct spa_pod pod;
uint32_t value;
int32_t _padding;
};
struct spa_pod_int {
struct spa_pod pod;
int32_t value;
int32_t _padding;
};
struct spa_pod_long {
struct spa_pod pod;
int64_t value;
};
struct spa_pod_float {
struct spa_pod pod;
float value;
int32_t _padding;
};
struct spa_pod_double {
struct spa_pod pod;
double value;
};
struct spa_pod_string {
struct spa_pod pod;
/* value here */
};
struct spa_pod_bytes {
struct spa_pod pod;
/* value here */
};
struct spa_pod_rectangle {
struct spa_pod pod;
struct spa_rectangle value;
};
struct spa_pod_fraction {
struct spa_pod pod;
struct spa_fraction value;
};
struct spa_pod_bitmap {
struct spa_pod pod;
/* array of uint8_t follows with the bitmap */
};
#define SPA_POD_ARRAY_CHILD(arr) (&((struct spa_pod_array*)(arr))->body.child)
#define SPA_POD_ARRAY_VALUE_TYPE(arr) (SPA_POD_TYPE(SPA_POD_ARRAY_CHILD(arr)))
#define SPA_POD_ARRAY_VALUE_SIZE(arr) (SPA_POD_BODY_SIZE(SPA_POD_ARRAY_CHILD(arr)))
#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)
#define SPA_POD_ARRAY_VALUES(arr) SPA_POD_CONTENTS(struct spa_pod_array, arr)
struct spa_pod_array_body {
struct spa_pod child;
/* array with elements of child.size follows */
};
struct spa_pod_array {
struct spa_pod pod;
struct spa_pod_array_body body;
};
#define SPA_POD_CHOICE_CHILD(choice) (&((struct spa_pod_choice*)(choice))->body.child)
#define SPA_POD_CHOICE_TYPE(choice) (((struct spa_pod_choice*)(choice))->body.type)
#define SPA_POD_CHOICE_FLAGS(choice) (((struct spa_pod_choice*)(choice))->body.flags)
#define SPA_POD_CHOICE_VALUE_TYPE(choice) (SPA_POD_TYPE(SPA_POD_CHOICE_CHILD(choice)))
#define SPA_POD_CHOICE_VALUE_SIZE(choice) (SPA_POD_BODY_SIZE(SPA_POD_CHOICE_CHILD(choice)))
#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)
#define SPA_POD_CHOICE_VALUES(choice) (SPA_POD_CONTENTS(struct spa_pod_choice, choice))
enum spa_choice_type {
SPA_CHOICE_None,
SPA_CHOICE_Range,
SPA_CHOICE_Step,
SPA_CHOICE_Enum,
SPA_CHOICE_Flags,
};
struct spa_pod_choice_body {
uint32_t type;
uint32_t flags;
struct spa_pod child;
/* array with elements of child.size follows. Note that there might be more
* elements than required by \a type, which should be ignored. */
};
struct spa_pod_choice {
struct spa_pod pod;
struct spa_pod_choice_body body;
};
struct spa_pod_struct {
struct spa_pod pod;
/* one or more spa_pod follow */
};
#define SPA_POD_OBJECT_TYPE(obj) (((struct spa_pod_object*)(obj))->body.type)
#define SPA_POD_OBJECT_ID(obj) (((struct spa_pod_object*)(obj))->body.id)
struct spa_pod_object_body {
uint32_t type;
uint32_t id;
/* contents follow, series of spa_pod_prop */
};
struct spa_pod_object {
struct spa_pod pod;
struct spa_pod_object_body body;
};
struct spa_pod_pointer_body {
uint32_t type;
uint32_t _padding;
const void *value;
};
struct spa_pod_pointer {
struct spa_pod pod;
struct spa_pod_pointer_body body;
};
struct spa_pod_fd {
struct spa_pod pod;
int64_t value;
};
#define SPA_POD_PROP_SIZE(prop) (sizeof(struct spa_pod_prop) + (prop)->value.size)
/* props can be inside an object */
struct spa_pod_prop {
uint32_t key;
#define SPA_POD_PROP_FLAG_READONLY (1u<<0)
#define SPA_POD_PROP_FLAG_HARDWARE (1u<<1)
#define SPA_POD_PROP_FLAG_HINT_DICT (1u<<2)
#define SPA_POD_PROP_FLAG_MANDATORY (1u<<3)
#define SPA_POD_PROP_FLAG_DONT_FIXATE (1u<<4)
uint32_t flags;
struct spa_pod value;
/* value follows */
};
#define SPA_POD_CONTROL_SIZE(ev) (sizeof(struct spa_pod_control) + (ev)->value.size)
/* controls can be inside a sequence and mark timed values */
struct spa_pod_control {
uint32_t offset;
uint32_t type;
struct spa_pod value;
/* value contents follow */
};
struct spa_pod_sequence_body {
uint32_t unit;
uint32_t pad;
/* series of struct spa_pod_control follows */
};
struct spa_pod_sequence {
struct spa_pod pod;
struct spa_pod_sequence_body body;
};
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_POD_H */
defs.h
spa/utils/defs.h
spa_choice_type
spa_choice_type
Definition pod.h:146
SPA_CHOICE_Step
@ SPA_CHOICE_Step
range with step: default, min, max, step
Definition pod.h:149
SPA_CHOICE_None
@ SPA_CHOICE_None
no choice, first value is current
Definition pod.h:147
SPA_CHOICE_Flags
@ SPA_CHOICE_Flags
flags: default, possible flags,...
Definition pod.h:151
SPA_CHOICE_Range
@ SPA_CHOICE_Range
range: default, min, max
Definition pod.h:148
SPA_CHOICE_Enum
@ SPA_CHOICE_Enum
list: default, alternative,...
Definition pod.h:150
type.h
spa/utils/type.h
spa_fraction
Definition defs.h:123
spa_pod_array_body
Definition pod.h:121
spa_pod_array_body::child
struct spa_pod child
Definition pod.h:122
spa_pod_array
Definition pod.h:126
spa_pod_array::pod
struct spa_pod pod
Definition pod.h:127
spa_pod_array::body
struct spa_pod_array_body body
Definition pod.h:128
spa_pod_bitmap
Definition pod.h:105
spa_pod_bitmap::pod
struct spa_pod pod
Definition pod.h:106
spa_pod_bool
Definition pod.h:51
spa_pod_bool::_padding
int32_t _padding
Definition pod.h:54
spa_pod_bool::value
int32_t value
Definition pod.h:53
spa_pod_bool::pod
struct spa_pod pod
Definition pod.h:52
spa_pod_bytes
Definition pod.h:90
spa_pod_bytes::pod
struct spa_pod pod
Definition pod.h:91
spa_pod_choice_body
Definition pod.h:154
spa_pod_choice_body::child
struct spa_pod child
Definition pod.h:157
spa_pod_choice_body::type
uint32_t type
type of choice, one of enum spa_choice_type
Definition pod.h:155
spa_pod_choice_body::flags
uint32_t flags
extra flags
Definition pod.h:156
spa_pod_choice
Definition pod.h:162
spa_pod_choice::body
struct spa_pod_choice_body body
Definition pod.h:164
spa_pod_choice::pod
struct spa_pod pod
Definition pod.h:163
spa_pod_control
Definition pod.h:234
spa_pod_control::value
struct spa_pod value
control value, depends on type
Definition pod.h:237
spa_pod_control::type
uint32_t type
type of control, enum spa_control_type
Definition pod.h:236
spa_pod_control::offset
uint32_t offset
media offset
Definition pod.h:235
spa_pod_double
Definition pod.h:80
spa_pod_double::value
double value
Definition pod.h:82
spa_pod_double::pod
struct spa_pod pod
Definition pod.h:81
spa_pod_fd
Definition pod.h:199
spa_pod_fd::value
int64_t value
Definition pod.h:201
spa_pod_fd::pod
struct spa_pod pod
Definition pod.h:200
spa_pod_float
Definition pod.h:74
spa_pod_float::_padding
int32_t _padding
Definition pod.h:77
spa_pod_float::pod
struct spa_pod pod
Definition pod.h:75
spa_pod_float::value
float value
Definition pod.h:76
spa_pod_fraction
Definition pod.h:100
spa_pod_fraction::value
struct spa_fraction value
Definition pod.h:102
spa_pod_fraction::pod
struct spa_pod pod
Definition pod.h:101
spa_pod_id
Definition pod.h:57
spa_pod_id::value
uint32_t value
Definition pod.h:59
spa_pod_id::_padding
int32_t _padding
Definition pod.h:60
spa_pod_id::pod
struct spa_pod pod
Definition pod.h:58
spa_pod_int
Definition pod.h:63
spa_pod_int::pod
struct spa_pod pod
Definition pod.h:64
spa_pod_int::_padding
int32_t _padding
Definition pod.h:66
spa_pod_int::value
int32_t value
Definition pod.h:65
spa_pod_long
Definition pod.h:69
spa_pod_long::value
int64_t value
Definition pod.h:71
spa_pod_long::pod
struct spa_pod pod
Definition pod.h:70
spa_pod_object_body
Definition pod.h:177
spa_pod_object_body::type
uint32_t type
one of enum spa_type
Definition pod.h:178
spa_pod_object_body::id
uint32_t id
id of the object, depends on the object type
Definition pod.h:179
spa_pod_object
Definition pod.h:183
spa_pod_object::pod
struct spa_pod pod
Definition pod.h:184
spa_pod_object::body
struct spa_pod_object_body body
Definition pod.h:185
spa_pod_pointer_body
Definition pod.h:188
spa_pod_pointer_body::value
const void * value
Definition pod.h:191
spa_pod_pointer_body::_padding
uint32_t _padding
Definition pod.h:190
spa_pod_pointer_body::type
uint32_t type
pointer id, one of enum spa_type
Definition pod.h:189
spa_pod_pointer
Definition pod.h:194
spa_pod_pointer::body
struct spa_pod_pointer_body body
Definition pod.h:196
spa_pod_pointer::pod
struct spa_pod pod
Definition pod.h:195
spa_pod_prop
Definition pod.h:208
spa_pod_prop::key
uint32_t key
key of property, list of valid keys depends on the object type
Definition pod.h:209
spa_pod_prop::flags
uint32_t flags
flags for property
Definition pod.h:225
spa_pod_prop::value
struct spa_pod value
Definition pod.h:226
spa_pod_rectangle
Definition pod.h:95
spa_pod_rectangle::pod
struct spa_pod pod
Definition pod.h:96
spa_pod_rectangle::value
struct spa_rectangle value
Definition pod.h:97
spa_pod_sequence_body
Definition pod.h:241
spa_pod_sequence_body::pad
uint32_t pad
Definition pod.h:243
spa_pod_sequence_body::unit
uint32_t unit
Definition pod.h:242
spa_pod_sequence
a sequence of timed controls
Definition pod.h:248
spa_pod_sequence::pod
struct spa_pod pod
Definition pod.h:249
spa_pod_sequence::body
struct spa_pod_sequence_body body
Definition pod.h:250
spa_pod_string
Definition pod.h:85
spa_pod_string::pod
struct spa_pod pod
Definition pod.h:86
spa_pod_struct
Definition pod.h:167
spa_pod_struct::pod
struct spa_pod pod
Definition pod.h:168
spa_pod
Definition pod.h:43
spa_pod::type
uint32_t type
Definition pod.h:45
spa_pod::size
uint32_t size
Definition pod.h:44
spa_rectangle
Definition defs.h:102