PipeWire  0.3.66
plugin.h
Go to the documentation of this file.
1 /* Simple Plugin API */
2 /* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
3 /* SPDX-License-Identifier: MIT */
4 
5 #ifndef SPA_PLUGIN_H
6 #define SPA_PLUGIN_H
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 #include <spa/utils/defs.h>
13 #include <spa/utils/dict.h>
14 
25 struct spa_handle {
27 #define SPA_VERSION_HANDLE 0
28  uint32_t version;
29 
43  int (*get_interface) (struct spa_handle *handle, const char *type, void **interface);
51  int (*clear) (struct spa_handle *handle);
52 };
53 
54 #define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__)
55 #define spa_handle_clear(h) (h)->clear((h))
56 
62  const char *type; /*< the type of the interface, can be
63  * used to get the interface */
64 };
65 
70 struct spa_support {
71  const char *type; /*< the type of the support item */
72  void *data; /*< specific data for the item */
73 };
74 
76 static inline void *spa_support_find(const struct spa_support *support,
77  uint32_t n_support,
78  const char *type)
79 {
80  uint32_t i;
81  for (i = 0; i < n_support; i++) {
82  if (strcmp(support[i].type, type) == 0)
83  return support[i].data;
84  }
85  return NULL;
86 }
87 
88 #define SPA_SUPPORT_INIT(type,data) ((struct spa_support) { (type), (data) })
89 
90 struct spa_handle_factory {
92 #define SPA_VERSION_HANDLE_FACTORY 1
93  uint32_t version;
107  const char *name;
111  const struct spa_dict *info;
119  size_t (*get_size) (const struct spa_handle_factory *factory,
120  const struct spa_dict *params);
121 
138  int (*init) (const struct spa_handle_factory *factory,
139  struct spa_handle *handle,
140  const struct spa_dict *info,
141  const struct spa_support *support,
142  uint32_t n_support);
143 
156  int (*enum_interface_info) (const struct spa_handle_factory *factory,
157  const struct spa_interface_info **info,
158  uint32_t *index);
159 };
160 
161 #define spa_handle_factory_get_size(h,...) (h)->get_size((h),__VA_ARGS__)
162 #define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
163 #define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__)
164 
174 typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory **factory,
175  uint32_t *index);
176 
177 #define SPA_HANDLE_FACTORY_ENUM_FUNC_NAME "spa_handle_factory_enum"
178 
188 int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index);
189 
190 
191 
192 #define SPA_KEY_FACTORY_NAME "factory.name"
193 #define SPA_KEY_FACTORY_AUTHOR "factory.author"
194 #define SPA_KEY_FACTORY_DESCRIPTION "factory.description"
195 #define SPA_KEY_FACTORY_USAGE "factory.usage"
197 #define SPA_KEY_LIBRARY_NAME "library.name"
205 #ifdef __cplusplus
206 } /* extern "C" */
207 #endif
208 
209 #endif /* SPA_PLUGIN_H */
spa/utils/defs.h
int(* spa_handle_factory_enum_func_t)(const struct spa_handle_factory **factory, uint32_t *index)
The function signature of the entry point in a plugin.
Definition: plugin.h:182
static void * spa_support_find(const struct spa_support *support, uint32_t n_support, const char *type)
Find a support item of the given type.
Definition: plugin.h:82
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
The entry point in a plugin.
Definition: utils/dict.h:39
Definition: plugin.h:97
int(* enum_interface_info)(const struct spa_handle_factory *factory, const struct spa_interface_info **info, uint32_t *index)
spa_handle_factory::enum_interface_info:
Definition: plugin.h:164
uint32_t version
Definition: plugin.h:101
const struct spa_dict * info
Extra information about the handles of this factory.
Definition: plugin.h:119
size_t(* get_size)(const struct spa_handle_factory *factory, const struct spa_dict *params)
Get the size of handles from this factory.
Definition: plugin.h:127
int(* init)(const struct spa_handle_factory *factory, struct spa_handle *handle, const struct spa_dict *info, const struct spa_support *support, uint32_t n_support)
Initialize an instance of this factory.
Definition: plugin.h:146
Definition: plugin.h:30
int(* get_interface)(struct spa_handle *handle, const char *type, void **interface)
Get the interface provided by handle with type.
Definition: plugin.h:49
int(* clear)(struct spa_handle *handle)
Clean up the memory of handle.
Definition: plugin.h:57
uint32_t version
Definition: plugin.h:34
This structure lists the information about available interfaces on handles.
Definition: plugin.h:67
const char * type
Definition: plugin.h:68
Extra supporting infrastructure passed to the init() function of a factory.
Definition: plugin.h:76
void * data
Definition: plugin.h:78
const char * type
Definition: plugin.h:77
spa/utils/dict.h