Beispiel #1
0
void MpCodecFactory::freeAllLoadedLibsAndCodec()
{
   OsSharedLibMgrBase* pShrMgr = OsSharedLibMgr::getOsSharedLibMgr();

   UtlHashBagIterator iter(mCodecsInfo);
   MpCodecSubInfo* pinfo;

   UtlHashBag libLoaded;
   UtlString* libName;

   while ((pinfo = (MpCodecSubInfo*)iter()))
   {  
      if ((!pinfo->getCodecCall()->isStatic()) && 
         (!libLoaded.find(&pinfo->getCodecCall()->getModuleName()))) {
         libLoaded.insert(const_cast<UtlString*>(&pinfo->getCodecCall()->getModuleName()));
      }    
   }

   UtlHashBagIterator iter2(libLoaded);
   while ((libName = (UtlString*)iter2()))
   {
      pShrMgr->unloadSharedLib(libName->data());
   }

   iter.reset();
   while ((pinfo = (MpCodecSubInfo*)iter()))
   {  
      if (!pinfo->getCodecCall()->isStatic()) {
         mCodecsInfo.remove(pinfo);
         delete pinfo;         
      }
   }

   mCodecInfoCacheValid = FALSE;
}
Beispiel #2
0
OsStatus
PluginXmlParser::loadPlugin (
    TiXmlElement& pluginElement,
    Notifier* notifier,
	SubscribeServerPluginBase** plugin)
{
	OsStatus status = OS_SUCCESS;

	UtlString dllTagName = "load-library";
	TiXmlElement* dllElem = requireElement(pluginElement, dllTagName, &status);
	if (status != OS_SUCCESS)
		return status;
	TiXmlText* dllTxt = requireText(*dllElem, &status);
	if (status != OS_SUCCESS)
		return status;

	// Dynamically load a library
	//OsSharedLibMgr* mgr = OsSharedLibMgr::getOsSharedLibMgr();
	OsSharedLibMgrBase* mgr = OsSharedLibMgr::getOsSharedLibMgr();
	if (!mgr)
		return OS_FAILED;
	OsStatus dllStatus = mgr->loadSharedLib(dllTxt->Value());
	if (dllStatus != OS_SUCCESS)
		return dllStatus;


	// Find the entry point in the library for the factory
	UtlString entryTagName = "plugin-factory";
	TiXmlElement* entryElem = requireElement(pluginElement, entryTagName, &status);
	if (status != OS_SUCCESS)
		return status;
	TiXmlText* entryTxt = requireText(*entryElem, &status);
	if (status != OS_SUCCESS)
		return status;

	OsStatus entryStatus = mgr->getSharedLibSymbol(dllTxt->Value(), entryTxt->Value(),
		    (void*&)PluginFactoryProc);

	if (entryStatus != OS_SUCCESS)
		return entryStatus;

	// Call the factory to construct the plugin
	*plugin = PluginFactoryProc(pluginElement, notifier);
	if (*plugin == NULL)
	{
		OsSysLog::add(FAC_SIP, PRI_ERR, "PluginXmlParser::loadPlugin return null "
	        "SubscribeServerPluginBasemissing %s ", entryTxt->Value());
		return OS_FAILED;
	}


    return OS_SUCCESS;
}
OsStatus MpAndroidAudioTrack::setAudioTrackCreator()
{
    OsStatus res;
    OsSharedLibMgrBase* pShrMgr = OsSharedLibMgr::getOsSharedLibMgr();
    const char* audioDriverLibNames[] =
    {
        "libsipXandroid2_0.so",
        "libsipXandroid2_3.so",
        "libsipXandroid2_3_4.so",
        "libsipXandroid4_0_1.so"
    };

    const char* libName = NULL;
    for(int libIndex = 0; libIndex < sizeof(audioDriverLibNames)/sizeof(const char*); libIndex++)
    {
        libName = audioDriverLibNames[libIndex];
        res = pShrMgr->loadSharedLib(libName);
        LOGD("Trying libs [%d/%d] for platform specific audio driver, loadSharedLib(\"%s\") returned: %d", 
            libIndex, sizeof(audioDriverLibNames)/sizeof(const char*), libName, res);
        if(res == OS_SUCCESS)
        {
            break;
        }
    }

    if(res == OS_SUCCESS)
    {
        void* symbolAddress = NULL;
        const char* symbolName = "createAndroidAudioTrack";

        res = pShrMgr->getSharedLibSymbol(libName, symbolName, symbolAddress);

        if(res == OS_SUCCESS && symbolAddress)
        {
            spAudioTrackCreate = (MpAndroidAudioTrackCreator)symbolAddress;
            LOGD("got symbol: \"%s\" funcPtr: %p res: %d", symbolName, symbolAddress, res);

            // Get the record creator too
            res = MpAndroidAudioRecord::setAudioRecordCreator(libName);
        }
        else
        {
            res = OS_PLATFORM_NOT_SUPPORTED;
            LOGE("get symbol: %s failed: %d", symbolName, res);
        }
    }

    return(res);
}
Beispiel #4
0
   // load the library for a hook and use its factory to get a new instance.
   ConfiguredHook(const UtlString& hookName,
                  const UtlString& hookFactoryName,
                  const UtlString& libName
                  )
      : UtlString(hookName),
        mHook(NULL),
        mLibName(libName)
      {
         OsSharedLibMgrBase* sharedLibMgr = OsSharedLibMgr::getOsSharedLibMgr();

         if (sharedLibMgr)
         {
            Plugin::Factory factory;

            if (OS_SUCCESS == sharedLibMgr->getSharedLibSymbol(libName.data(),
                                                               hookFactoryName,
                                                               (void*&)factory
                                                               )
                )
            {
               // Use the factory to get an instance of the hook
               // and tell the new instance its own name.
               mHook = factory(hookName);

               OsSysLog::add(FAC_KERNEL, PRI_DEBUG,
                             "PluginHooks ConfiguredHook:: created instance '%s' from '%s'",
                             hookName.data(), libName.data()
                             );
            }
            else
            {
               OsSysLog::add(FAC_KERNEL, PRI_ERR,
                             "PluginHooks ConfiguredHook:: "
                             "factory '%s' not found in library '%s' for instance '%s'",
                             hookFactoryName.data(), libName.data(), hookName.data()
                             );
            }
         }
         else
         {
            OsSysLog::add(FAC_KERNEL, PRI_CRIT,
                          "PluginHooks ConfiguredHook:: failed to getOsSharedLibMgr"
                          );
         }
      }
Beispiel #5
0
OsStatus MpCodecFactory::loadDynCodec(const char* name)
{
   OsSysLog::add(FAC_MP, PRI_INFO, "MpCodecFactory::loadDynCodec(\"%s\")", name);

   OsStatus res;
   OsSharedLibMgrBase* pShrMgr = OsSharedLibMgr::getOsSharedLibMgr();

   res = pShrMgr->loadSharedLib(name);
   if (res != OS_SUCCESS)
   {
      return OS_FAILED;
   }
 
   void* address;   
   res = pShrMgr->getSharedLibSymbol(name, MSK_GET_CODEC_NAME_V1, address);
   if (res != OS_SUCCESS)
   {
      pShrMgr->unloadSharedLib(name);
      return OS_FAILED;
   }

   dlGetCodecsV1 getCodecsV1 = (dlGetCodecsV1)address;
   const char* codecName;
   int i, r, count = 0;
   UtlString codecTokens;

   // 100 is a watchdog value, should be enough for everyone.
   for (i = 0; (i < 100); i++) 
   {
      r = getCodecsV1(i, &codecName);
      if ((r != RPLG_SUCCESS) || (codecName == NULL)) 
      {
         if (count == 0)
         {
            pShrMgr->unloadSharedLib(name);
            return OS_FAILED;
         }
         return OS_SUCCESS;
      }

      OsSysLog::add(FAC_MP, PRI_INFO, "found codec: %s", codecName);

      if(i > 0)
      {
         codecTokens.append(' ');
      }
      codecTokens.append(codecName);

      // Obtaining codecs functions
      UtlBoolean st;
      UtlBoolean stGetPacketSamples;
      UtlBoolean stSignaling;

      UtlString strCodecName = codecName;
      UtlString dlNameInit = strCodecName + MSK_INIT_V1_2;
      UtlString dlNameGetInfo = strCodecName + MSK_GET_INFO_V1_1;
      UtlString dlNameGetPacketSamples = strCodecName + MSK_GET_PACKET_SAMPLES_V1_2;
      UtlString dlNameDecode = strCodecName + MSK_DECODE_V1;
      UtlString dlNameEncdoe = strCodecName + MSK_ENCODE_V1;
      UtlString dlNameFree = strCodecName + MSK_FREE_V1;
      UtlString dlNameSignaling = strCodecName + MSK_SIGNALING_V1;
      
      dlPlgInitV1_2 plgInitAddr;
      dlPlgGetInfoV1_1 plgGetInfoAddr;
      dlPlgGetPacketSamplesV1_2 plgGetPacketSamples;
      dlPlgDecodeV1 plgDecodeAddr;
      dlPlgEncodeV1 plgEncodeAddr;
      dlPlgFreeV1 plgFreeAddr;
      dlPlgGetSignalingDataV1 plgSignaling;

      st = TRUE 
         && (pShrMgr->getSharedLibSymbol(name, dlNameInit,
                                         (void*&)plgInitAddr) == OS_SUCCESS)
         && (plgInitAddr != NULL)
         && (pShrMgr->getSharedLibSymbol(name, dlNameGetInfo,
                                         (void*&)plgGetInfoAddr) == OS_SUCCESS)
         && (plgGetInfoAddr != NULL)
         && (pShrMgr->getSharedLibSymbol(name, dlNameDecode,
                                         (void*&)plgDecodeAddr) == OS_SUCCESS)
         && (plgDecodeAddr != NULL)
         && (pShrMgr->getSharedLibSymbol(name, dlNameEncdoe,
                                         (void*&)plgEncodeAddr) == OS_SUCCESS)
         && (plgEncodeAddr != NULL)
         && (pShrMgr->getSharedLibSymbol(name, dlNameFree,
                                         (void*&)plgFreeAddr) == OS_SUCCESS)
         && (plgFreeAddr != NULL);

      if (st)
      {
         stGetPacketSamples = TRUE
            && (pShrMgr->getSharedLibSymbol(name, dlNameGetPacketSamples,
                                            (void*&)plgGetPacketSamples) == OS_SUCCESS)
            && (plgGetPacketSamples != NULL);

         stSignaling = TRUE
            && (pShrMgr->getSharedLibSymbol(name, dlNameSignaling,
                                            (void*&)plgSignaling) == OS_SUCCESS)
            && (plgSignaling != NULL);

         // Add codec to list if all basic (non-signaling) symbols are present.

         MpCodecCallInfoV1* pCallInfo = new MpCodecCallInfoV1(name, codecName, 
                                                              plgInitAddr,
                                                              plgGetInfoAddr,
                                                              plgGetPacketSamples,
                                                              plgDecodeAddr,
                                                              plgEncodeAddr,
                                                              plgFreeAddr,
                                                              plgSignaling,
                                                              FALSE);

         if (!pCallInfo)
            continue;         

         if (addCodecWrapperV1(pCallInfo) != OS_SUCCESS)
         {
            delete pCallInfo;
            continue;
         }

         //Plugin has been added successfully, need to rebuild cache list
         mCodecInfoCacheValid = FALSE;
         count ++;
      }
   }
   if (count == 0) {
      pShrMgr->unloadSharedLib(name);
      return OS_FAILED;
   }
   OsSysLog::add(FAC_MP, PRI_INFO, "Loaded %d codecs (%s) from %s", count, codecTokens.data(), name);

   return OS_SUCCESS;
}