Loading...
Searching...
No Matches
plugin.h
Go to the documentation of this file.
/* Simple Plugin API */
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */
/* SPDX-License-Identifier: MIT */
#ifndef SPA_PLUGIN_H
#define SPA_PLUGIN_H
#ifdef __cplusplus
extern "C" {
#endif
#include <spa/utils/defs.h>
#include <spa/utils/dict.h>
struct spa_handle {
#define SPA_VERSION_HANDLE 0
uint32_t version;
int (*get_interface) (struct spa_handle *handle, const char *type, void **interface);
int (*clear) (struct spa_handle *handle);
};
#define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__)
#define spa_handle_clear(h) (h)->clear((h))
struct spa_interface_info {
const char *type; /*< the type of the interface, can be
* used to get the interface */
};
struct spa_support {
const char *type; /*< the type of the support item */
void *data; /*< specific data for the item */
};
static inline void *spa_support_find(const struct spa_support *support,
uint32_t n_support,
const char *type)
{
uint32_t i;
for (i = 0; i < n_support; i++) {
if (strcmp(support[i].type, type) == 0)
return support[i].data;
}
return NULL;
}
#define SPA_SUPPORT_INIT(type,data) ((struct spa_support) { (type), (data) })
struct spa_handle_factory {
#define SPA_VERSION_HANDLE_FACTORY 1
uint32_t version;
const char *name;
const struct spa_dict *info;
size_t (*get_size) (const struct spa_handle_factory *factory,
const struct spa_dict *params);
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);
int (*enum_interface_info) (const struct spa_handle_factory *factory,
const struct spa_interface_info **info,
uint32_t *index);
};
#define spa_handle_factory_get_size(h,...) (h)->get_size((h),__VA_ARGS__)
#define spa_handle_factory_init(h,...) (h)->init((h),__VA_ARGS__)
#define spa_handle_factory_enum_interface_info(h,...) (h)->enum_interface_info((h),__VA_ARGS__)
typedef int (*spa_handle_factory_enum_func_t) (const struct spa_handle_factory **factory,
uint32_t *index);
#define SPA_HANDLE_FACTORY_ENUM_FUNC_NAME "spa_handle_factory_enum"
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index);
#define SPA_KEY_FACTORY_NAME "factory.name"
#define SPA_KEY_FACTORY_AUTHOR "factory.author"
#define SPA_KEY_FACTORY_DESCRIPTION "factory.description"
#define SPA_KEY_FACTORY_USAGE "factory.usage"
#define SPA_KEY_LIBRARY_NAME "library.name"
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* SPA_PLUGIN_H */
defs.h
spa/utils/defs.h
spa_handle_factory_enum_func_t
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
spa_support_find
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
spa_handle_factory_enum
int spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
The entry point in a plugin.
spa_dict
Definition dict.h:39
spa_handle_factory
Definition plugin.h:97
spa_handle_factory::enum_interface_info
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
spa_handle_factory::version
uint32_t version
Definition plugin.h:101
spa_handle_factory::info
const struct spa_dict * info
Extra information about the handles of this factory.
Definition plugin.h:119
spa_handle_factory::get_size
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
spa_handle_factory::init
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
spa_handle
Definition plugin.h:30
spa_handle::get_interface
int(* get_interface)(struct spa_handle *handle, const char *type, void **interface)
Get the interface provided by handle with type.
Definition plugin.h:49
spa_handle::clear
int(* clear)(struct spa_handle *handle)
Clean up the memory of handle.
Definition plugin.h:57
spa_handle::version
uint32_t version
Definition plugin.h:34
spa_interface_info
This structure lists the information about available interfaces on handles.
Definition plugin.h:67
spa_interface_info::type
const char * type
Definition plugin.h:68
spa_support
Extra supporting infrastructure passed to the init() function of a factory.
Definition plugin.h:76
spa_support::data
void * data
Definition plugin.h:78
spa_support::type
const char * type
Definition plugin.h:77
dict.h
spa/utils/dict.h