+ +
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_DEBUG_TYPES_H |
| 6 | #define SPA_DEBUG_TYPES_H |
| 7 | |
| 8 | #include <spa/utils/type-info.h> |
| 9 | |
| 10 | #include <string.h> |
| 11 | |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif |
| 15 | |
| 16 | /** |
| 17 | * \addtogroup spa_debug |
| 18 | * \{ |
| 19 | */ |
| 20 | |
| 21 | #ifndef SPA_API_DEBUG_TYPES |
| 22 | #ifdef SPA_API_IMPL |
| 23 | #define SPA_API_DEBUG_TYPES SPA_API_IMPL |
| 24 | #else |
| 25 | #define SPA_API_DEBUG_TYPES static inline |
| 26 | #endif |
| 27 | #endif |
| 28 | |
| 29 | |
| 30 | SPA_API_DEBUG_TYPES const struct spa_type_info *spa_debug_type_find(const struct spa_type_info *info, uint32_t type) |
| 31 | { |
| 32 | const struct spa_type_info *res; |
| 33 | |
| 34 | if (info == NULL) |
| 35 | info = SPA_TYPE_ROOT; |
| 36 | |
| 37 | while (info && info->name) { |
| 38 | if (info->type == SPA_ID_INVALID) { |
| 39 | if (info->values && (res = spa_debug_type_find(info->values, type))) |
| 40 | return res; |
| 41 | } |
| 42 | else if (info->type == type) |
| 43 | return info; |
| 44 | info++; |
| 45 | } |
| 46 | return NULL; |
| 47 | } |
| 48 | |
| 49 | SPA_API_DEBUG_TYPES const char *spa_debug_type_short_name(const char *name) |
| 50 | { |
| 51 | return spa_type_short_name(name); |
| 52 | } |
| 53 | |
| 54 | SPA_API_DEBUG_TYPES const char *spa_debug_type_find_name(const struct spa_type_info *info, uint32_t type) |
| 55 | { |
| 56 | if ((info = spa_debug_type_find(info, type)) == NULL) |
| 57 | return NULL; |
| 58 | return info->name; |
| 59 | } |
| 60 | |
| 61 | SPA_API_DEBUG_TYPES const char *spa_debug_type_find_short_name(const struct spa_type_info *info, uint32_t type) |
| 62 | { |
| 63 | const char *str; |
| 64 | if ((str = spa_debug_type_find_name(info, type)) == NULL) |
| 65 | return NULL; |
| 66 | return spa_debug_type_short_name(str); |
| 67 | } |
| 68 | |
| 69 | SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type(const struct spa_type_info *info, const char *name) |
| 70 | { |
| 71 | if (info == NULL) |
| 72 | info = SPA_TYPE_ROOT; |
| 73 | |
| 74 | while (info && info->name) { |
| 75 | uint32_t res; |
| 76 | if (strcmp(info->name, name) == 0) |
| 77 | return info->type; |
| 78 | if (info->values && (res = spa_debug_type_find_type(info->values, name)) != SPA_ID_INVALID) |
| 79 | return res; |
| 80 | info++; |
| 81 | } |
| 82 | return SPA_ID_INVALID; |
| 83 | } |
| 84 | |
| 85 | SPA_API_DEBUG_TYPES const struct spa_type_info *spa_debug_type_find_short(const struct spa_type_info *info, const char *name) |
| 86 | { |
| 87 | while (info && info->name) { |
| 88 | if (strcmp(spa_debug_type_short_name(info->name), name) == 0) |
| 89 | return info; |
| 90 | if (strcmp(info->name, name) == 0) |
| 91 | return info; |
| 92 | if (info->type != 0 && info->type == (uint32_t)atoi(name)) |
| 93 | return info; |
| 94 | info++; |
| 95 | } |
| 96 | return NULL; |
| 97 | } |
| 98 | |
| 99 | SPA_API_DEBUG_TYPES uint32_t spa_debug_type_find_type_short(const struct spa_type_info *info, const char *name) |
| 100 | { |
| 101 | if ((info = spa_debug_type_find_short(info, name)) == NULL) |
| 102 | return SPA_ID_INVALID; |
| 103 | return info->type; |
| 104 | } |
| 105 | /** |
| 106 | * \} |
| 107 | */ |
| 108 | |
| 109 | #ifdef __cplusplus |
| 110 | } /* extern "C" */ |
| 111 | #endif |
| 112 | |
| 113 | #endif /* SPA_DEBUG_NODE_H */ |