2 #define LOG_TAG "RegistryLoader"
5 #include "extension_handler_registry.h"
6 #include "PVPlayerExtHandler.h"
8 #include "oscl_shared_library.h"
9 #include "oscl_library_list.h"
10 #include "oscl_configfile_list.h"
11 #include "osclconfig_lib.h"
12 #include "oscl_shared_lib_interface.h"
15 PVPlayerExtensionRegistry::PVPlayerExtensionRegistry()
17 // The default value reserved is 4
19 LOGV("PVPlayerExtensionRegistry::PVPlayerExtensionRegistry OUT");
22 PVPlayerExtensionRegistry::~PVPlayerExtensionRegistry()
25 LOGV("PVPlayerExtensionRegistry::~PVPlayerExtensionRegistry OUT");
28 void PVPlayerExtensionRegistry::loadPVPlayerExtensions(const OSCL_String& configFilePath)
30 LOGV("PVPlayerExtensionRegistry::loadPVPlayerExtensions() IN");
31 OsclLibraryList libList;
32 libList.Populate(PV_EXTN_REGISTRY_POPULATOR_INTERFACE, configFilePath);
34 for (unsigned int i = 0; i < libList.Size(); i++)
36 OsclSharedLibrary* lib = OSCL_NEW(OsclSharedLibrary, ());
37 if (lib->LoadLib(libList.GetLibraryPathAt(i)) == OsclLibSuccess) {
38 OsclAny* interfacePtr = NULL;
39 OsclLibStatus result = lib->QueryInterface(PV_EXTN_REGISTRY_POPULATOR_INTERFACE, (OsclAny*&)interfacePtr);
40 if (result == OsclLibSuccess && interfacePtr != NULL) {
41 PVPlayerExtnSharedLibInfo *libInfo = (PVPlayerExtnSharedLibInfo *)oscl_malloc(sizeof(PVPlayerExtnSharedLibInfo));
42 if (NULL != libInfo) {
44 ExtnRegPopulatorInterface* extnIntPtr = OSCL_DYNAMIC_CAST(ExtnRegPopulatorInterface*, interfacePtr);
45 libInfo->mExtnLibIfacePtr = extnIntPtr;
46 extnIntPtr->registerExtensions(this);
47 // save for depopulation later
48 mExtnIfaceInfoList.push_front(libInfo);
52 LOGV("PVPlayerExtensionRegistry::loadPVPlayerExtensions() QueryInterface() of PV_EXTNIFACE_REGISTRY_POPULATOR_INTERFACE for library %s failed.", libList.GetLibraryPathAt(i).get_cstr());
55 LOGV("PVPlayerExtensionRegistry::loadPVPlayerExtensions() LoadLib() of library %s failed.", libList.GetLibraryPathAt(i).get_cstr());
60 LOGV("PVPlayerExtensionRegistry::loadPVPlayerExtensions() OUT");
63 void PVPlayerExtensionRegistry::removePVPlayerExtensions()
65 LOGV("PVPlayerExtensionRegistry::removePVPlayerExtensions() IN");
67 while (!mExtnIfaceInfoList.empty())
69 PVPlayerExtnSharedLibInfo *libInfo = mExtnIfaceInfoList.front();
70 mExtnIfaceInfoList.erase(mExtnIfaceInfoList.begin());
72 OsclSharedLibrary* lib = libInfo->mLib;
77 LOGV("PVPlayerExtensionRegistry::removePVPlayerExtensions() OUT");
80 IDispatch* PVPlayerExtensionRegistry::createExtension(const String16& extnIfaceUID,PVPlayerExtensionHandler& extnHandler )
82 LOGV("PVPlayerExtensionRegistry::createExtension() IN");
83 bool foundFlag = false;
84 uint32 extnSearchCount = 0;
86 while (extnSearchCount < mType.size())
88 //Search if the UUID's will match
89 if (extnIfaceUID == (String16(mType[extnSearchCount].mExtnUID))) {
90 //Since the UUID's match set the flag to true
98 PVPlayerExtnInfo* extnInfo = &mType[extnSearchCount];
99 IDispatch* extInterface = NULL;
101 if (NULL != extnInfo->mExtnCreateFunc) {
102 extInterface = (*(mType[extnSearchCount].mExtnCreateFunc))(extnHandler);
104 LOGV("PVPlayerExtensionRegistry::createExtension OUT extInterface = %d", (int32_t)extInterface);
107 LOGV("PVPlayerExtensionRegistry::createExtension OUT");
112 void PVPlayerExtnPopulator::populate(PVPlayerExtensionRegistry& extnIfaceRegistry)
114 LOGV("PVPlayerExtnPopulator::populate IN");
115 OsclConfigFileList aCfgList;
116 // collects all config files from the project specified directory
117 if (NULL != PV_DYNAMIC_LOADING_CONFIG_FILE_PATH) {
118 OSCL_HeapString<OsclMemAllocator> configFilePath = PV_DYNAMIC_LOADING_CONFIG_FILE_PATH;
119 aCfgList.Populate(configFilePath);
121 // populate libraries from all config files
122 for (uint k = 0; k < aCfgList.Size(); k++)
124 extnIfaceRegistry.loadPVPlayerExtensions(aCfgList.GetConfigfileAt(k));
126 LOGV("PVPlayerExtnPopulator::populate OUT");
128 void PVPlayerExtnPopulator::depopulate(PVPlayerExtensionRegistry& extnIfaceRegistry)
130 extnIfaceRegistry.removePVPlayerExtensions();
131 LOGV("PVPlayerExtnPopulator::depopulate OUT");