+ +
2da5fe7 OpenAVX v0.2.0 - High-performance open-standard IP audio and video transport suite
saifmukhtar · 2026-11-24
c · 186 lines · 4.3 KB · SPDX: MIT
main
1 /* Simple Plugin API */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4  
5 #ifndef SPA_TYPE_H
6 #define SPA_TYPE_H
7  
8 #include <spa/utils/defs.h>
9 #include <spa/utils/string.h>
10  
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14  
15 #ifndef SPA_API_TYPE
16 #ifdef SPA_API_IMPL
17 #define SPA_API_TYPE SPA_API_IMPL
18 #else
19 #define SPA_API_TYPE static inline
20 #endif
21 #endif
22  
23 /** \defgroup spa_types Types
24 * Data type information enumerations
25 */
26  
27 /**
28 * \addtogroup spa_types
29 * \{
30 */
31  
32 enum {
33 /* Basic types */
34 SPA_TYPE_START = 0x00000,
35 SPA_TYPE_None,
36 SPA_TYPE_Bool,
37 SPA_TYPE_Id,
38 SPA_TYPE_Int,
39 SPA_TYPE_Long,
40 SPA_TYPE_Float,
41 SPA_TYPE_Double,
42 SPA_TYPE_String,
43 SPA_TYPE_Bytes,
44 SPA_TYPE_Rectangle,
45 SPA_TYPE_Fraction,
46 SPA_TYPE_Bitmap,
47 SPA_TYPE_Array,
48 SPA_TYPE_Struct,
49 SPA_TYPE_Object,
50 SPA_TYPE_Sequence,
51 SPA_TYPE_Pointer,
52 SPA_TYPE_Fd,
53 SPA_TYPE_Choice,
54 SPA_TYPE_Pod,
55 _SPA_TYPE_LAST, /**< not part of ABI */
56  
57 /* Pointers */
58 SPA_TYPE_POINTER_START = 0x10000,
59 SPA_TYPE_POINTER_Buffer,
60 SPA_TYPE_POINTER_Meta,
61 SPA_TYPE_POINTER_Dict,
62 _SPA_TYPE_POINTER_LAST, /**< not part of ABI */
63  
64 /* Events */
65 SPA_TYPE_EVENT_START = 0x20000,
66 SPA_TYPE_EVENT_Device,
67 SPA_TYPE_EVENT_Node,
68 _SPA_TYPE_EVENT_LAST, /**< not part of ABI */
69  
70 /* Commands */
71 SPA_TYPE_COMMAND_START = 0x30000,
72 SPA_TYPE_COMMAND_Device,
73 SPA_TYPE_COMMAND_Node,
74 _SPA_TYPE_COMMAND_LAST, /**< not part of ABI */
75  
76 /* Objects */
77 SPA_TYPE_OBJECT_START = 0x40000,
78 SPA_TYPE_OBJECT_PropInfo,
79 SPA_TYPE_OBJECT_Props,
80 SPA_TYPE_OBJECT_Format,
81 SPA_TYPE_OBJECT_ParamBuffers,
82 SPA_TYPE_OBJECT_ParamMeta,
83 SPA_TYPE_OBJECT_ParamIO,
84 SPA_TYPE_OBJECT_ParamProfile,
85 SPA_TYPE_OBJECT_ParamPortConfig,
86 SPA_TYPE_OBJECT_ParamRoute,
87 SPA_TYPE_OBJECT_Profiler,
88 SPA_TYPE_OBJECT_ParamLatency,
89 SPA_TYPE_OBJECT_ParamProcessLatency,
90 SPA_TYPE_OBJECT_ParamTag,
91 SPA_TYPE_OBJECT_PeerParam,
92 SPA_TYPE_OBJECT_ParamDict,
93 _SPA_TYPE_OBJECT_LAST, /**< not part of ABI */
94  
95 /* vendor extensions */
96 SPA_TYPE_VENDOR_PipeWire = 0x02000000,
97  
98 SPA_TYPE_VENDOR_Other = 0x7f000000,
99 };
100  
101 #define SPA_TYPE_INFO_BASE "Spa:"
102  
103 #define SPA_TYPE_INFO_Flags SPA_TYPE_INFO_BASE "Flags"
104 #define SPA_TYPE_INFO_FLAGS_BASE SPA_TYPE_INFO_Flags ":"
105  
106 #define SPA_TYPE_INFO_Enum SPA_TYPE_INFO_BASE "Enum"
107 #define SPA_TYPE_INFO_ENUM_BASE SPA_TYPE_INFO_Enum ":"
108  
109 #define SPA_TYPE_INFO_Pod SPA_TYPE_INFO_BASE "Pod"
110 #define SPA_TYPE_INFO_POD_BASE SPA_TYPE_INFO_Pod ":"
111  
112 #define SPA_TYPE_INFO_Struct SPA_TYPE_INFO_POD_BASE "Struct"
113 #define SPA_TYPE_INFO_STRUCT_BASE SPA_TYPE_INFO_Struct ":"
114  
115 #define SPA_TYPE_INFO_Object SPA_TYPE_INFO_POD_BASE "Object"
116 #define SPA_TYPE_INFO_OBJECT_BASE SPA_TYPE_INFO_Object ":"
117  
118 #define SPA_TYPE_INFO_Pointer SPA_TYPE_INFO_BASE "Pointer"
119 #define SPA_TYPE_INFO_POINTER_BASE SPA_TYPE_INFO_Pointer ":"
120  
121 #define SPA_TYPE_INFO_Interface SPA_TYPE_INFO_POINTER_BASE "Interface"
122 #define SPA_TYPE_INFO_INTERFACE_BASE SPA_TYPE_INFO_Interface ":"
123  
124 #define SPA_TYPE_INFO_Event SPA_TYPE_INFO_OBJECT_BASE "Event"
125 #define SPA_TYPE_INFO_EVENT_BASE SPA_TYPE_INFO_Event ":"
126  
127 #define SPA_TYPE_INFO_Command SPA_TYPE_INFO_OBJECT_BASE "Command"
128 #define SPA_TYPE_INFO_COMMAND_BASE SPA_TYPE_INFO_Command ":"
129  
130 struct spa_type_info {
131 uint32_t type;
132 uint32_t parent;
133 const char *name;
134 const struct spa_type_info *values;
135 };
136  
137 SPA_API_TYPE bool spa_type_is_a(const char *type, const char *parent)
138 {
139 return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
140 }
141  
142 SPA_API_TYPE const char *spa_type_short_name(const char *name)
143 {
144 const char *h;
145 if ((h = strrchr(name, ':')) != NULL)
146 name = h + 1;
147 return name;
148 }
149  
150 SPA_API_TYPE uint32_t spa_type_from_short_name(const char *name,
151 const struct spa_type_info *info, uint32_t unknown)
152 {
153 int i;
154 for (i = 0; info[i].name; i++) {
155 if (spa_streq(name, spa_type_short_name(info[i].name)))
156 return info[i].type;
157 }
158 return unknown;
159 }
160 SPA_API_TYPE const char * spa_type_to_name(uint32_t type,
161 const struct spa_type_info *info, const char *unknown)
162 {
163 int i;
164 for (i = 0; info[i].name; i++) {
165 if (info[i].type == type)
166 return info[i].name;
167 }
168 return unknown;
169 }
170  
171 SPA_API_TYPE const char * spa_type_to_short_name(uint32_t type,
172 const struct spa_type_info *info, const char *unknown)
173 {
174 const char *n = spa_type_to_name(type, info, unknown);
175 return n ? spa_type_short_name(n) : NULL;
176 }
177  
178 /**
179 * \}
180 */
181  
182 #ifdef __cplusplus
183 } /* extern "C" */
184 #endif
185  
186 #endif /* SPA_TYPE_H */