2016-06-28 12:21:56 +02:00
|
|
|
/* Simple Plugin API
|
|
|
|
|
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Library General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef __SPA_PLUGIN_H__
|
|
|
|
|
#define __SPA_PLUGIN_H__
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <spa/defs.h>
|
2016-09-15 11:49:34 +02:00
|
|
|
#include <spa/dict.h>
|
2016-06-28 12:21:56 +02:00
|
|
|
|
|
|
|
|
typedef struct _SpaHandle SpaHandle;
|
|
|
|
|
typedef struct _SpaHandleFactory SpaHandleFactory;
|
|
|
|
|
|
|
|
|
|
struct _SpaHandle {
|
|
|
|
|
/* user_data that can be set by the application */
|
|
|
|
|
void * user_data;
|
|
|
|
|
/**
|
|
|
|
|
* SpaHandle::get_interface:
|
|
|
|
|
* @handle: a #SpaHandle
|
|
|
|
|
* @interface_id: the interface id
|
|
|
|
|
* @interface: result to hold the interface.
|
|
|
|
|
*
|
|
|
|
|
* Get the interface provided by @handle with @interface_id.
|
|
|
|
|
*
|
|
|
|
|
* Returns: #SPA_RESULT_OK on success
|
|
|
|
|
* #SPA_RESULT_NOT_IMPLEMENTED when there are no extensions
|
|
|
|
|
* #SPA_RESULT_INVALID_ARGUMENTS when handle or info is %NULL
|
|
|
|
|
*/
|
|
|
|
|
SpaResult (*get_interface) (SpaHandle *handle,
|
|
|
|
|
uint32_t interface_id,
|
2016-07-30 20:35:34 +02:00
|
|
|
void **interface);
|
2016-09-01 10:04:25 +02:00
|
|
|
/**
|
|
|
|
|
* SpaHandle::clear
|
|
|
|
|
* @handle: a pointer to memory
|
|
|
|
|
*
|
|
|
|
|
* Clean up the memory of @handle. After this, @handle should not be used
|
|
|
|
|
* anymore.
|
|
|
|
|
*
|
|
|
|
|
* Returns: #SPA_RESULT_OK on success
|
|
|
|
|
*/
|
|
|
|
|
SpaResult (*clear) (SpaHandle *handle);
|
2016-06-28 12:21:56 +02:00
|
|
|
};
|
|
|
|
|
|
2016-09-01 10:04:25 +02:00
|
|
|
#define spa_handle_get_interface(h,...) (h)->get_interface((h),__VA_ARGS__)
|
|
|
|
|
#define spa_handle_clear(h) (h)->clear((h))
|
|
|
|
|
|
2016-06-28 12:21:56 +02:00
|
|
|
/**
|
|
|
|
|
* SpaInterfaceInfo:
|
|
|
|
|
* @interface_id: the id of the interface, can be used to get the interface
|
|
|
|
|
* @name: name of the interface
|
|
|
|
|
* @description: Human readable description of the interface.
|
|
|
|
|
*
|
|
|
|
|
* This structure lists the information about available interfaces on
|
|
|
|
|
* handles.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint32_t interface_id;
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *description;
|
|
|
|
|
} SpaInterfaceInfo;
|
|
|
|
|
|
|
|
|
|
struct _SpaHandleFactory {
|
|
|
|
|
/**
|
|
|
|
|
* SpaHandleFactory::name
|
|
|
|
|
*
|
|
|
|
|
* The name
|
|
|
|
|
*/
|
|
|
|
|
const char * name;
|
|
|
|
|
/**
|
|
|
|
|
* SpaHandleFactory::info
|
|
|
|
|
*
|
|
|
|
|
* Extra information about the handles of this factory.
|
|
|
|
|
*/
|
2016-09-15 11:49:34 +02:00
|
|
|
const SpaDict * info;
|
2016-07-13 18:29:55 +02:00
|
|
|
/**
|
|
|
|
|
* SpaHandleFactory::size
|
|
|
|
|
*
|
|
|
|
|
* The size of handles from this factory
|
|
|
|
|
*/
|
|
|
|
|
const size_t size;
|
2016-06-28 12:21:56 +02:00
|
|
|
|
|
|
|
|
/**
|
2016-07-13 18:29:55 +02:00
|
|
|
* SpaHandleFactory::init
|
2016-06-28 12:21:56 +02:00
|
|
|
* @factory: a #SpaHandleFactory
|
2016-07-13 18:29:55 +02:00
|
|
|
* @handle: a pointer to memory
|
2016-09-15 11:49:34 +02:00
|
|
|
* @config: extra handle specific config information, usually obtained from
|
|
|
|
|
* a #SpaMonitor.
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
2016-07-13 18:29:55 +02:00
|
|
|
* Initialize an instance of this factory. The caller should allocate
|
|
|
|
|
* memory at least SpaHandleFactory::size bytes and pass this as @handle.
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
|
|
|
|
* Returns: #SPA_RESULT_OK on success
|
|
|
|
|
* #SPA_RESULT_NOT_IMPLEMENTED when an instance can't be made
|
|
|
|
|
* #SPA_RESULT_INVALID_ARGUMENTS when factory or handle are %NULL
|
|
|
|
|
*/
|
2016-07-13 18:29:55 +02:00
|
|
|
SpaResult (*init) (const SpaHandleFactory *factory,
|
2016-09-15 11:49:34 +02:00
|
|
|
SpaHandle *handle,
|
|
|
|
|
const void *config);
|
2016-09-01 10:04:25 +02:00
|
|
|
|
2016-06-28 12:21:56 +02:00
|
|
|
/**
|
|
|
|
|
* SpaHandle::enum_interface_info:
|
|
|
|
|
* @factory: a #SpaHandleFactory
|
|
|
|
|
* @info: result to hold SpaInterfaceInfo.
|
2016-07-15 18:22:29 +02:00
|
|
|
* @state: state to keep track of the enumeration, %NULL for first item
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
2016-07-15 18:22:29 +02:00
|
|
|
* Enumerate the interface information for @factory.
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
|
|
|
|
* Returns: #SPA_RESULT_OK on success
|
|
|
|
|
* #SPA_RESULT_NOT_IMPLEMENTED when there are no interfaces
|
|
|
|
|
* #SPA_RESULT_INVALID_ARGUMENTS when handle or info is %NULL
|
|
|
|
|
* #SPA_RESULT_ENUM_END when there are no more infos
|
|
|
|
|
*/
|
|
|
|
|
SpaResult (*enum_interface_info) (const SpaHandleFactory *factory,
|
2016-07-15 18:22:29 +02:00
|
|
|
const SpaInterfaceInfo **info,
|
|
|
|
|
void **state);
|
2016-06-28 12:21:56 +02:00
|
|
|
};
|
|
|
|
|
|
2016-09-01 10:04:25 +02:00
|
|
|
#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__)
|
|
|
|
|
|
2016-06-28 12:21:56 +02:00
|
|
|
/**
|
|
|
|
|
* SpaEnumHandleFactoryFunc:
|
|
|
|
|
* @factory: a location to hold the factory result
|
2016-07-15 18:22:29 +02:00
|
|
|
* @state: state to keep track of the enumeration
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
|
|
|
|
* The function signature of the entry point in a plugin.
|
|
|
|
|
*
|
|
|
|
|
* Returns: #SPA_RESULT_OK on success
|
|
|
|
|
* #SPA_RESULT_INVALID_ARGUMENTS when factory is %NULL
|
|
|
|
|
* #SPA_RESULT_ENUM_END when there are no more factories
|
|
|
|
|
*/
|
2016-07-15 18:22:29 +02:00
|
|
|
typedef SpaResult (*SpaEnumHandleFactoryFunc) (const SpaHandleFactory **factory,
|
|
|
|
|
void **state);
|
2016-06-28 12:21:56 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* spa_enum_handle_factory:
|
|
|
|
|
* @factory: a location to hold the factory result
|
2016-07-15 18:22:29 +02:00
|
|
|
* @state: state to keep track of the enumeration
|
2016-06-28 12:21:56 +02:00
|
|
|
*
|
|
|
|
|
* The entry point in a plugin.
|
|
|
|
|
*
|
|
|
|
|
* Returns: #SPA_RESULT_OK on success
|
|
|
|
|
* #SPA_RESULT_INVALID_ARGUMENTS when factory is %NULL
|
|
|
|
|
* #SPA_RESULT_ENUM_END when there are no more factories
|
|
|
|
|
*/
|
2016-07-15 18:22:29 +02:00
|
|
|
SpaResult spa_enum_handle_factory (const SpaHandleFactory **factory,
|
|
|
|
|
void **state);
|
2016-06-28 12:21:56 +02:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
} /* extern "C" */
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif /* __SPA_PLUGIN_H__ */
|