Loading...
Searching...
No Matches
type.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_TYPE_H
#define SPA_TYPE_H
#include <spa/utils/defs.h>
#include <spa/utils/string.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SPA_API_TYPE
#ifdef SPA_API_IMPL
#define SPA_API_TYPE SPA_API_IMPL
#else
#define SPA_API_TYPE static inline
#endif
#endif
enum {
/* Basic types */
SPA_TYPE_START = 0x00000,
SPA_TYPE_None,
SPA_TYPE_Bool,
SPA_TYPE_Id,
SPA_TYPE_Int,
SPA_TYPE_Long,
SPA_TYPE_Float,
SPA_TYPE_Double,
SPA_TYPE_String,
SPA_TYPE_Bytes,
SPA_TYPE_Rectangle,
SPA_TYPE_Fraction,
SPA_TYPE_Bitmap,
SPA_TYPE_Array,
SPA_TYPE_Struct,
SPA_TYPE_Object,
SPA_TYPE_Sequence,
SPA_TYPE_Pointer,
SPA_TYPE_Fd,
SPA_TYPE_Choice,
SPA_TYPE_Pod,
_SPA_TYPE_LAST,
/* Pointers */
SPA_TYPE_POINTER_START = 0x10000,
SPA_TYPE_POINTER_Buffer,
SPA_TYPE_POINTER_Meta,
SPA_TYPE_POINTER_Dict,
_SPA_TYPE_POINTER_LAST,
/* Events */
SPA_TYPE_EVENT_START = 0x20000,
SPA_TYPE_EVENT_Device,
SPA_TYPE_EVENT_Node,
_SPA_TYPE_EVENT_LAST,
/* Commands */
SPA_TYPE_COMMAND_START = 0x30000,
SPA_TYPE_COMMAND_Device,
SPA_TYPE_COMMAND_Node,
_SPA_TYPE_COMMAND_LAST,
/* Objects */
SPA_TYPE_OBJECT_START = 0x40000,
SPA_TYPE_OBJECT_PropInfo,
SPA_TYPE_OBJECT_Props,
SPA_TYPE_OBJECT_Format,
SPA_TYPE_OBJECT_ParamBuffers,
SPA_TYPE_OBJECT_ParamMeta,
SPA_TYPE_OBJECT_ParamIO,
SPA_TYPE_OBJECT_ParamProfile,
SPA_TYPE_OBJECT_ParamPortConfig,
SPA_TYPE_OBJECT_ParamRoute,
SPA_TYPE_OBJECT_Profiler,
SPA_TYPE_OBJECT_ParamLatency,
SPA_TYPE_OBJECT_ParamProcessLatency,
SPA_TYPE_OBJECT_ParamTag,
SPA_TYPE_OBJECT_PeerParam,
SPA_TYPE_OBJECT_ParamDict,
_SPA_TYPE_OBJECT_LAST,
/* vendor extensions */
SPA_TYPE_VENDOR_PipeWire = 0x02000000,
SPA_TYPE_VENDOR_Other = 0x7f000000,
};
#define SPA_TYPE_INFO_BASE "Spa:"
#define SPA_TYPE_INFO_Flags SPA_TYPE_INFO_BASE "Flags"
#define SPA_TYPE_INFO_FLAGS_BASE SPA_TYPE_INFO_Flags ":"
#define SPA_TYPE_INFO_Enum SPA_TYPE_INFO_BASE "Enum"
#define SPA_TYPE_INFO_ENUM_BASE SPA_TYPE_INFO_Enum ":"
#define SPA_TYPE_INFO_Pod SPA_TYPE_INFO_BASE "Pod"
#define SPA_TYPE_INFO_POD_BASE SPA_TYPE_INFO_Pod ":"
#define SPA_TYPE_INFO_Struct SPA_TYPE_INFO_POD_BASE "Struct"
#define SPA_TYPE_INFO_STRUCT_BASE SPA_TYPE_INFO_Struct ":"
#define SPA_TYPE_INFO_Object SPA_TYPE_INFO_POD_BASE "Object"
#define SPA_TYPE_INFO_OBJECT_BASE SPA_TYPE_INFO_Object ":"
#define SPA_TYPE_INFO_Pointer SPA_TYPE_INFO_BASE "Pointer"
#define SPA_TYPE_INFO_POINTER_BASE SPA_TYPE_INFO_Pointer ":"
#define SPA_TYPE_INFO_Interface SPA_TYPE_INFO_POINTER_BASE "Interface"
#define SPA_TYPE_INFO_INTERFACE_BASE SPA_TYPE_INFO_Interface ":"
#define SPA_TYPE_INFO_Event SPA_TYPE_INFO_OBJECT_BASE "Event"
#define SPA_TYPE_INFO_EVENT_BASE SPA_TYPE_INFO_Event ":"
#define SPA_TYPE_INFO_Command SPA_TYPE_INFO_OBJECT_BASE "Command"
#define SPA_TYPE_INFO_COMMAND_BASE SPA_TYPE_INFO_Command ":"
struct spa_type_info {
uint32_t type;
uint32_t parent;
const char *name;
const struct spa_type_info *values;
};
SPA_API_TYPE bool spa_type_is_a(const char *type, const char *parent)
{
return type != NULL && parent != NULL && strncmp(type, parent, strlen(parent)) == 0;
}
SPA_API_TYPE const char *spa_type_short_name(const char *name)
{
const char *h;
if ((h = strrchr(name, ':')) != NULL)
name = h + 1;
return name;
}
SPA_API_TYPE uint32_t spa_type_from_short_name(const char *name,
const struct spa_type_info *info, uint32_t unknown)
{
int i;
for (i = 0; info[i].name; i++) {
if (spa_streq(name, spa_type_short_name(info[i].name)))
return info[i].type;
}
return unknown;
}
SPA_API_TYPE const char * spa_type_to_name(uint32_t type,
const struct spa_type_info *info, const char *unknown)
{
int i;
for (i = 0; info[i].name; i++) {
if (info[i].type == type)
return info[i].name;
}
return unknown;
}
SPA_API_TYPE const char * spa_type_to_short_name(uint32_t type,
const struct spa_type_info *info, const char *unknown)
{
const char *n = spa_type_to_name(type, info, unknown);
return n ? spa_type_short_name(n) : NULL;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_TYPE_H */
defs.h
spa/utils/defs.h
spa_streq
SPA_API_STRING bool spa_streq(const char *s1, const char *s2)
Definition string.h:52
spa_type_is_a
SPA_API_TYPE bool spa_type_is_a(const char *type, const char *parent)
Definition type.h:163
spa_type_from_short_name
SPA_API_TYPE uint32_t spa_type_from_short_name(const char *name, const struct spa_type_info *info, uint32_t unknown)
Definition type.h:176
spa_type_to_short_name
SPA_API_TYPE const char * spa_type_to_short_name(uint32_t type, const struct spa_type_info *info, const char *unknown)
Definition type.h:197
spa_type_short_name
SPA_API_TYPE const char * spa_type_short_name(const char *name)
Definition type.h:168
spa_type_to_name
SPA_API_TYPE const char * spa_type_to_name(uint32_t type, const struct spa_type_info *info, const char *unknown)
Definition type.h:186
SPA_TYPE_POINTER_Buffer
@ SPA_TYPE_POINTER_Buffer
Definition type.h:66
SPA_TYPE_OBJECT_ParamPortConfig
@ SPA_TYPE_OBJECT_ParamPortConfig
Definition type.h:92
SPA_TYPE_Int
@ SPA_TYPE_Int
Definition type.h:45
SPA_TYPE_OBJECT_ParamProfile
@ SPA_TYPE_OBJECT_ParamProfile
Definition type.h:91
SPA_TYPE_COMMAND_START
@ SPA_TYPE_COMMAND_START
Definition type.h:78
SPA_TYPE_POINTER_START
@ SPA_TYPE_POINTER_START
Definition type.h:65
SPA_TYPE_Rectangle
@ SPA_TYPE_Rectangle
Definition type.h:51
SPA_TYPE_Long
@ SPA_TYPE_Long
Definition type.h:46
SPA_TYPE_Bool
@ SPA_TYPE_Bool
Definition type.h:43
SPA_TYPE_Bytes
@ SPA_TYPE_Bytes
Definition type.h:50
SPA_TYPE_VENDOR_Other
@ SPA_TYPE_VENDOR_Other
Definition type.h:105
SPA_TYPE_EVENT_Device
@ SPA_TYPE_EVENT_Device
Definition type.h:73
SPA_TYPE_Pod
@ SPA_TYPE_Pod
Definition type.h:61
SPA_TYPE_OBJECT_PropInfo
@ SPA_TYPE_OBJECT_PropInfo
Definition type.h:85
SPA_TYPE_OBJECT_START
@ SPA_TYPE_OBJECT_START
Definition type.h:84
SPA_TYPE_OBJECT_ParamDict
@ SPA_TYPE_OBJECT_ParamDict
Definition type.h:99
SPA_TYPE_Bitmap
@ SPA_TYPE_Bitmap
Definition type.h:53
SPA_TYPE_Object
@ SPA_TYPE_Object
Definition type.h:56
SPA_TYPE_POINTER_Dict
@ SPA_TYPE_POINTER_Dict
Definition type.h:68
SPA_TYPE_Float
@ SPA_TYPE_Float
Definition type.h:47
SPA_TYPE_COMMAND_Device
@ SPA_TYPE_COMMAND_Device
Definition type.h:79
SPA_TYPE_OBJECT_ParamBuffers
@ SPA_TYPE_OBJECT_ParamBuffers
Definition type.h:88
SPA_TYPE_Fraction
@ SPA_TYPE_Fraction
Definition type.h:52
SPA_TYPE_None
@ SPA_TYPE_None
Definition type.h:42
SPA_TYPE_OBJECT_ParamIO
@ SPA_TYPE_OBJECT_ParamIO
Definition type.h:90
_SPA_TYPE_LAST
@ _SPA_TYPE_LAST
not part of ABI
Definition type.h:62
SPA_TYPE_OBJECT_Props
@ SPA_TYPE_OBJECT_Props
Definition type.h:86
SPA_TYPE_Sequence
@ SPA_TYPE_Sequence
Definition type.h:57
SPA_TYPE_Double
@ SPA_TYPE_Double
Definition type.h:48
SPA_TYPE_OBJECT_Profiler
@ SPA_TYPE_OBJECT_Profiler
Definition type.h:94
SPA_TYPE_OBJECT_ParamLatency
@ SPA_TYPE_OBJECT_ParamLatency
Definition type.h:95
SPA_TYPE_Id
@ SPA_TYPE_Id
Definition type.h:44
SPA_TYPE_EVENT_START
@ SPA_TYPE_EVENT_START
Definition type.h:72
SPA_TYPE_Choice
@ SPA_TYPE_Choice
Definition type.h:60
SPA_TYPE_EVENT_Node
@ SPA_TYPE_EVENT_Node
Definition type.h:74
SPA_TYPE_Pointer
@ SPA_TYPE_Pointer
Definition type.h:58
_SPA_TYPE_OBJECT_LAST
@ _SPA_TYPE_OBJECT_LAST
not part of ABI
Definition type.h:100
SPA_TYPE_Array
@ SPA_TYPE_Array
Definition type.h:54
_SPA_TYPE_EVENT_LAST
@ _SPA_TYPE_EVENT_LAST
not part of ABI
Definition type.h:75
SPA_TYPE_String
@ SPA_TYPE_String
Definition type.h:49
SPA_TYPE_VENDOR_PipeWire
@ SPA_TYPE_VENDOR_PipeWire
Definition type.h:103
SPA_TYPE_POINTER_Meta
@ SPA_TYPE_POINTER_Meta
Definition type.h:67
_SPA_TYPE_COMMAND_LAST
@ _SPA_TYPE_COMMAND_LAST
not part of ABI
Definition type.h:81
SPA_TYPE_COMMAND_Node
@ SPA_TYPE_COMMAND_Node
Definition type.h:80
SPA_TYPE_OBJECT_ParamProcessLatency
@ SPA_TYPE_OBJECT_ParamProcessLatency
Definition type.h:96
SPA_TYPE_Fd
@ SPA_TYPE_Fd
Definition type.h:59
SPA_TYPE_OBJECT_PeerParam
@ SPA_TYPE_OBJECT_PeerParam
Definition type.h:98
SPA_TYPE_OBJECT_ParamMeta
@ SPA_TYPE_OBJECT_ParamMeta
Definition type.h:89
SPA_TYPE_OBJECT_ParamTag
@ SPA_TYPE_OBJECT_ParamTag
Definition type.h:97
SPA_TYPE_OBJECT_ParamRoute
@ SPA_TYPE_OBJECT_ParamRoute
Definition type.h:93
_SPA_TYPE_POINTER_LAST
@ _SPA_TYPE_POINTER_LAST
not part of ABI
Definition type.h:69
SPA_TYPE_Struct
@ SPA_TYPE_Struct
Definition type.h:55
SPA_TYPE_OBJECT_Format
@ SPA_TYPE_OBJECT_Format
Definition type.h:87
SPA_TYPE_START
@ SPA_TYPE_START
Definition type.h:41
SPA_API_TYPE
#define SPA_API_TYPE
Definition type.h:26
string.h
spa/utils/string.h
spa_type_info
Definition type.h:156
spa_type_info::type
uint32_t type
Definition type.h:157
spa_type_info::parent
uint32_t parent
Definition type.h:158
spa_type_info::values
const struct spa_type_info * values
Definition type.h:160