Plugable Module functions.
More...
|
GF_ModuleManager * | gf_modules_new (const char *directory, GF_Config *cfgFile) |
| module manager construtcor More...
|
|
void | gf_modules_del (GF_ModuleManager *pm) |
| module manager destructor More...
|
|
GF_Err | gf_module_load_static (GF_ModuleManager *pm, GF_InterfaceRegister *(*register_module)()) |
| load a static module given its interface function More...
|
|
u32 | gf_modules_refresh (GF_ModuleManager *pm) |
| refreshes modules More...
|
|
u32 | gf_modules_get_count (GF_ModuleManager *pm) |
| get module count More...
|
|
const char ** | gf_modules_get_module_directories (GF_ModuleManager *pm, u32 *num_dirs) |
| get all modules directories More...
|
|
const char * | gf_modules_get_file_name (GF_ModuleManager *pm, u32 index) |
| get module file name More...
|
|
const char * | gf_module_get_file_name (GF_BaseInterface *ifce) |
| get module file name More...
|
|
GF_BaseInterface * | gf_modules_load_interface (GF_ModuleManager *pm, u32 index, u32 InterfaceFamily) |
| loads an interface More...
|
|
GF_BaseInterface * | gf_modules_load_interface_by_name (GF_ModuleManager *pm, const char *mod_name, u32 InterfaceFamily) |
| loads an interface by module name More...
|
|
GF_Err | gf_modules_close_interface (GF_BaseInterface *interface_obj) |
| interface shutdown More...
|
|
const char * | gf_modules_get_option (GF_BaseInterface *interface_obj, const char *secName, const char *keyName) |
| interface option query More...
|
|
GF_Err | gf_modules_set_option (GF_BaseInterface *interface_obj, const char *secName, const char *keyName, const char *keyValue) |
| interface option update More...
|
|
GF_Config * | gf_modules_get_config (GF_BaseInterface *ifce) |
| get config file More...
|
|
This section documents the plugable module functions of the GPAC framework. A module is a dynamic/shared library providing one or several interfaces to the GPAC framework. A module cannot provide several interfaces of the same type. Each module must export the following functions:
u32 *QueryInterfaces(
u32 interface_type);
This function is used to query supported interfaces. It returns a zero-terminated array of supported interface types.
This function is used to load an interface. It returns the interface object, NULL if error.
This function is used to destroy an interface.
Each interface must begin with the interface macro in order to be type-casted to the base interface structure.
This structure represent a base interface, e.g. the minimal interface declaration without functionalities. Each interface is type-casted to this structure and shall always be checked against its interface type. API Versioning is taken care of in the interface type itsel, changing at each modification of the interface API
Data Fields |
u32 |
InterfaceType |
|
const char * |
module_name |
|
const char * |
author_name |
|
void * |
HPLUG |
|
#define GF_DECL_MODULE_INTERFACE |
This is the module interface declaration macro. It must be placed first in an interface structure declaration.
#define GF_REGISTER_MODULE_INTERFACE |
( |
|
_ifce, |
|
|
|
_ifce_type, |
|
|
|
_ifce_name, |
|
|
|
_ifce_author |
|
) |
| |
This is the module interface registration macro. A module must call this macro whenever creating a new interface.
- _ifce: interface being registered
- _ifce_type: the four character code defining the interface type.
- _ifce_name: a printable string giving the interface name (const char *).
- _ifce_author: a printable string giving the author name (const char *).
This is a sample GPAC codec interface declaration: 1 GF_BaseInterface *MyDecoderInterfaceLoad() {
3 GF_SAFEALLOC(ifce, GF_MediaDecoder);
4 GF_REGISTER_MODULE_INTERFACE(ifce, GF_MEDIA_DECODER_INTERFACE, "Sample Decoder", "The Author")
5 //follows any initialization private to the decoder
6 return (GF_BaseInterface *)ifce;
#define GPAC_MODULE_EXPORT |
#define GPAC_MODULE_STATIC_DECLARATION |
( |
|
__name | ) |
|
When using GPAC as a static library, if GPAC_MODULE_CUSTOM_LOAD is defined, this macro can be used with GF_MODULE_STATIC_DECLARE() and gf_module_refresh() to load individual modules.
It's first needed to call GF_MODULE_STATIC_DECLARE() with the name of the module you need to load outside of any function. This macro will declare the prototype of the module registration function so it should only be used outside functions.
Then in your GPAC initialization code, you need to call GF_MODULE_LOAD_STATIC() with your GPAC module manager and the module name.
Finally, you'll need to call gf_modules_refresh() with your module manager.
1 GF_MODULE_STATIC_DECLARE(aac_in);
2 GF_MODULE_STATIC_DECLARE(audio_filter);
3 GF_MODULE_STATIC_DECLARE(ffmpeg);
9 user.modules = gf_modules_new("/data/gpac/modules", user.config);
11 GF_MODULE_LOAD_STATIC(user.modules, aac_in);
12 GF_MODULE_LOAD_STATIC(user.modules, audio_filter);
13 GF_MODULE_LOAD_STATIC(user.modules, ffmpeg);
15 gf_modules_refresh(user.modules);
- See also
- GF_MODULE_LOAD_STATIC() gf_modules_refresh()
Constructs a module manager object.
- Parameters
-
directory | absolute path to the directory where the manager shall look for modules |
cfgFile | GPAC configuration file handle. If this is NULL, the modules won't be able to share the configuration file with the rest of the GPAC framework. |
- Returns
- the module manager object
Destroys the module manager
- Parameters
-
- Parameters
-
pm | the module manager |
register_module | the register interface function |
Refreshes all modules in the manager directory and load unloaded ones
- Parameters
-
- Returns
- the number of loaded modules
Gets the number of modules found in the manager directory
- Parameters
-
- Returns
- the number of loaded modules
Update module manager with all modules directories
- Parameters
-
pm | the module manager |
num_dirs | the number of module directories |
- Returns
- The list of modules directories
Gets a module shared library file name based on its index
- Parameters
-
pm | the module manager |
index | the 0-based index of the module to query |
- Returns
- the name of the shared library module
Gets a module shared library file name based on its index
- Parameters
-
ifce | the module instance to query |
- Returns
- the name of the shared library module
Loads an interface in the desired module.
- Parameters
-
pm | the module manager |
index | the 0-based index of the module to load the interface from |
InterfaceFamily | type of the interface to load |
- Returns
- the interface object if found and loaded, NULL otherwise.
Loads an interface in the desired module
- Parameters
-
pm | the module manager |
mod_name | the name of the module (shared library file) or of the interface as declared when registered. |
InterfaceFamily | type of the interface to load |
- Returns
- the interface object if found and loaded, NULL otherwise.
Closes an interface
- Parameters
-
interface_obj | the interface to close |
const char* gf_modules_get_option |
( |
GF_BaseInterface * |
interface_obj, |
|
|
const char * |
secName, |
|
|
const char * |
keyName |
|
) |
| |
Gets an option from the config file associated with the module manager
- Parameters
-
interface_obj | the interface object used |
secName | the desired key parent section name |
keyName | the desired key name |
- Returns
- the desired key value if found, NULL otherwise.
GF_Err gf_modules_set_option |
( |
GF_BaseInterface * |
interface_obj, |
|
|
const char * |
secName, |
|
|
const char * |
keyName, |
|
|
const char * |
keyValue |
|
) |
| |
Sets an option in the config file associated with the module manager
- Parameters
-
interface_obj | the interface object used |
secName | the desired key parent section name |
keyName | the desired key name |
keyValue | the desired key value |
- Note
- this will also create both section and key if they are not found in the configuration file
Gets the configuration file for the module instance
- Parameters
-
ifce | the interface object used |
- Returns
- handle to the config file