--- /dev/null
+/*\r
+ * GPAC - Multimedia Framework C SDK\r
+ *\r
+ * Copyright (c) Jean Le Feuvre 2000-2005 \r
+ * All rights reserved\r
+ *\r
+ * This file is part of GPAC / common tools sub-project\r
+ *\r
+ * GPAC is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU Lesser General Public License as published by\r
+ * the Free Software Foundation; either version 2, or (at your option)\r
+ * any later version.\r
+ * \r
+ * GPAC is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU Lesser General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU Lesser General Public\r
+ * License along with this library; see the file COPYING. If not, write to\r
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
+ *\r
+ */\r
+\r
+#ifndef _GF_MODULE_H_\r
+#define _GF_MODULE_H_\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+/*!\r
+ * \file <gpac/module.h>\r
+ * \brief plugable module functions.\r
+ */\r
+\r
+/*!\r
+ * \addtogroup mods_grp plugable modules\r
+ * \ingroup utils_grp\r
+ * \brief Plugable Module functions\r
+ *\r
+ *This section documents the plugable module functions of the GPAC framework.\r
+ *A module is a dynamic/shared library providing one or several interfaces to the GPAC framework.\r
+ *A module cannot provide several interfaces of the same type. Each module must export the following functions:\r
+ \code\r
+ * Bool QueryInterface(u32 interface_type);\r
+ \endcode\r
+ * This function is used to query supported interfaces. It returns non zero if the module handles this interface type, 0 otherwise.\n\r
+ \code\r
+ GF_BaseInterface *LoadInterface(u32 interface_type);\r
+ \endcode\r
+ * This function is used to load an interface. It returns the interface object, NULL if error.\n\r
+ \code\r
+ void ShutdownInterface(GF_BaseInterface *interface);\r
+ \endcode\r
+ *This function is used to destroy an interface.\n\n\r
+ *Each interface must begin with the interface macro in order to be type-casted to the base interface structure.\r
+ \code\r
+ struct {\r
+ GF_DECL_MODULE_INTERFACE\r
+ extensions;\r
+ };\r
+ \endcode\r
+ * @{\r
+ */\r
+\r
+#include <gpac/config_file.h>\r
+\r
+typedef struct __tag_mod_man GF_ModuleManager;\r
+\r
+/*!\r
+ *\brief common module interface\r
+ *\hideinitializer\r
+ *\r
+ *This is the module interface declaration macro. It must be placed first in an interface structure declaration.\r
+*/\r
+#define GF_DECL_MODULE_INTERFACE \\r
+ u32 InterfaceType; \\r
+ const char *module_name; \\r
+ const char *author_name; \\r
+ void *HPLUG; \\r
+\r
+/*!\r
+ *\brief Base Interface\r
+ *\r
+ *This structure represent a base interface, e.g. the minimal interface declaration without functionalities. Each interface is\r
+ *type-casted to this structure and shall always be checked against its interface type. API Versioning is taken care of in the \r
+ *interface type itsel, changing at each modification of the interface API\r
+ */\r
+typedef struct\r
+{\r
+ GF_DECL_MODULE_INTERFACE\r
+} GF_BaseInterface;\r
+\r
+/*!\r
+ *\brief module interface registration\r
+ *\hideinitializer\r
+ *\r
+ *This is the module interface registration macro. A module must call this macro whenever creating a new interface.\r
+ *- \e _ifce: interface being registered\r
+ *- \e _ifce_type: the four character code defining the interface type.\r
+ *- \e _ifce_name: a printable string giving the interface name (const char *).\r
+ *- \e _ifce_author: a printable string giving the author name (const char *).\r
+ *\n\r
+ *This is a sample GPAC codec interface declaration:\r
+ \code\r
+GF_BaseInterface *MyDecoderInterfaceLoad() {\r
+ GF_MediaDecoder *ifce;\r
+ GF_SAFEALLOC(ifce, GF_MediaDecoder);\r
+ GF_REGISTER_MODULE_INTERFACE(ifce, GF_MEDIA_DECODER_INTERFACE, "Sample Decoder", "The Author")\r
+ //follows any initialization private to the decoder\r
+ return (GF_BaseInterface *)ifce;\r
+}\r
+ \endcode\r
+*/\r
+#define GF_REGISTER_MODULE_INTERFACE(_ifce, _ifce_type, _ifce_name, _ifce_author) \\r
+ _ifce->InterfaceType = _ifce_type; \\r
+ _ifce->module_name = _ifce_name ? _ifce_name : "unknown"; \\r
+ _ifce->author_name = _ifce_author ? _ifce_author : "gpac distribution"; \\r
+ \r
+/*!\r
+ *\brief module manager construtcor\r
+ *\r
+ *Constructs a module manager object.\r
+ *\param directory absolute path to the directory where the manager shall look for modules\r
+ *\param cfgFile GPAC configuration file handle. If this is NULL, the modules won't be able to share the configuration\r
+ *file with the rest of the GPAC framework.\r
+ *\return the module manager object\r
+*/\r
+GF_ModuleManager *gf_modules_new(const char *directory, GF_Config *cfgFile);\r
+/*!\r
+ *\brief module manager destructor\r
+ *\r
+ *Destroys the module manager\r
+ *\param pm the module manager\r
+ */\r
+void gf_modules_del(GF_ModuleManager *pm);\r
+/*!\r
+ *\brief refreshes modules\r
+ *\r
+ *Refreshes all modules in the manager directory and load unloaded ones\r
+ *\param pm the module manager\r
+ *\return the number of loaded modules\r
+ */\r
+u32 gf_modules_refresh(GF_ModuleManager *pm);\r
+\r
+/*!\r
+ *\brief get module count\r
+ *\r
+ *Gets the number of modules found in the manager directory\r
+ *\param pm the module manager\r
+ *\return the number of loaded modules\r
+ */\r
+u32 gf_modules_get_count(GF_ModuleManager *pm);\r
+\r
+/*!\r
+ *\brief get module file name\r
+ *\r
+ *Gets a module shared library file name based on its index\r
+ *\param pm the module manager\r
+ *\param index the 0-based index of the module to query\r
+ *\return the name of the shared library module\r
+ */\r
+const char *gf_modules_get_file_name(GF_ModuleManager *pm, u32 index);\r
+\r
+/*!\r
+ *\brief loads an interface\r
+ *\r
+ *Loads an interface in the desired module.\r
+ *\param pm the module manager\r
+ *\param index the 0-based index of the module to load the interface from\r
+ *\param InterfaceFamily type of the interface to load\r
+ *\return the interface object if found and loaded, NULL otherwise.\r
+ */\r
+GF_BaseInterface *gf_modules_load_interface(GF_ModuleManager *pm, u32 index, u32 InterfaceFamily);\r
+\r
+/*!\r
+ *\brief loads an interface by module name\r
+ *\r
+ *Loads an interface in the desired module\r
+ *\param pm the module manager\r
+ *\param mod_name the name of the module (shared library file) or of the interface as declared when registered.\r
+ *\param InterfaceFamily type of the interface to load\r
+ *\return the interface object if found and loaded, NULL otherwise.\r
+ */\r
+GF_BaseInterface *gf_modules_load_interface_by_name(GF_ModuleManager *pm, const char *mod_name, u32 InterfaceFamily);\r
+\r
+/*!\r
+ *\brief interface shutdown\r
+ *\r
+ *Closes an interface\r
+ *\param interface_obj the interface to close\r
+ */\r
+GF_Err gf_modules_close_interface(GF_BaseInterface *interface_obj);\r
+\r
+/*!\r
+ *\brief interface option query\r
+ *\r
+ *Gets an option from the config file associated with the module manager \r
+ *\param interface_obj the interface object used\r
+ *\param secName the desired key parent section name\r
+ *\param keyName the desired key name\r
+ *\return the desired key value if found, NULL otherwise.\r
+ */\r
+const char *gf_modules_get_option(GF_BaseInterface *interface_obj, const char *secName, const char *keyName);\r
+/*!\r
+ *\brief interface option update\r
+ *\r
+ *Sets an option in the config file associated with the module manager \r
+ *\param interface_obj the interface object used\r
+ *\param secName the desired key parent section name\r
+ *\param keyName the desired key name\r
+ *\param keyValue the desired key value\r
+ *\note this will also create both section and key if they are not found in the configuration file\r
+ */\r
+GF_Err gf_modules_set_option(GF_BaseInterface *interface_obj, const char *secName, const char *keyName, const char *keyValue);\r
+\r
+/*!\r
+ *\brief get config fiole\r
+ *\r
+ *Gets the configuration file for the module instance\r
+ *\param interface_obj the interface object used\r
+ *\return handle to the config file\r
+ */\r
+GF_Config *gf_modules_get_config(GF_BaseInterface *ifce);\r
+\r
+/*! @} */\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+\r
+#endif /*_GF_MODULE_H_*/\r
+\r