/codecs_v2/omx/omx_common/src/pv_omxregistry.cpp

https://github.com/liudidi/android_external_opencore · C++ · 1056 lines · 805 code · 162 blank · 89 comment · 125 complexity · 670045f3f98699d739d97928e2ab7b05 MD5 · raw file

  1. /* ------------------------------------------------------------------
  2. * Copyright (C) 1998-2009 PacketVideo
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied.
  14. * See the License for the specific language governing permissions
  15. * and limitations under the License.
  16. * -------------------------------------------------------------------
  17. */
  18. #ifndef OSCL_BASE_H_INCLUDED
  19. #include "oscl_base.h"
  20. #endif
  21. #ifndef PV_OMXDEFS_H_INCLUDED
  22. #include "pv_omxdefs.h"
  23. #endif
  24. #ifndef OSCL_ERROR_H_INCLUDED
  25. #include "oscl_error.h"
  26. #endif
  27. #include "OMX_Component.h"
  28. #include "pv_omxcore.h"
  29. // pv_omxregistry.h is only needed if NOT using CML2
  30. #ifndef USE_CML2_CONFIG
  31. #include "pv_omxregistry.h"
  32. #endif
  33. // Use default DLL entry point
  34. #ifndef OSCL_DLL_H_INCLUDED
  35. #include "oscl_dll.h"
  36. #endif
  37. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  38. OMX_ERRORTYPE OmxComponentFactoryDynamicCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  39. OMX_ERRORTYPE OmxComponentFactoryDynamicDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  40. #endif
  41. OMX_ERRORTYPE ComponentRegister(ComponentRegistrationType *pCRT)
  42. {
  43. int32 error;
  44. OMX_S32 ii;
  45. OMXGlobalData* data = (OMXGlobalData*)OsclSingletonRegistry::lockAndGetInstance(OSCL_SINGLETON_ID_OMX, error);
  46. if (error) // can't access registry
  47. {
  48. return OMX_ErrorInvalidState;
  49. }
  50. else if (!data) // singleton object has been destroyed
  51. {
  52. OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
  53. return OMX_ErrorInvalidState;
  54. }
  55. for (ii = 0; ii < MAX_SUPPORTED_COMPONENTS; ii++)
  56. {
  57. if (NULL == data->ipRegTemplateList[ii])
  58. {
  59. data->ipRegTemplateList[ii] = pCRT;
  60. break;
  61. }
  62. }
  63. OsclSingletonRegistry::registerInstanceAndUnlock(data, OSCL_SINGLETON_ID_OMX, error);
  64. if (error)
  65. {
  66. //registry error
  67. return OMX_ErrorUndefined;
  68. }
  69. if (MAX_SUPPORTED_COMPONENTS == ii)
  70. {
  71. return OMX_ErrorInsufficientResources;
  72. }
  73. return OMX_ErrorNone;
  74. }
  75. #if REGISTER_OMX_M4V_COMPONENT
  76. #if (DYNAMIC_LOAD_OMX_M4V_COMPONENT == 0)
  77. // external factory functions needed for creation of each component (or stubs for testing)
  78. extern OMX_ERRORTYPE Mpeg4OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  79. extern OMX_ERRORTYPE Mpeg4OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  80. #endif
  81. #endif
  82. #if (REGISTER_OMX_M4V_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  83. /////////////////////////////////////////////////////////////////////////////
  84. OMX_ERRORTYPE Mpeg4Register()
  85. {
  86. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  87. if (pCRT)
  88. {
  89. pCRT->ComponentName = (OMX_STRING)"OMX.PV.mpeg4dec";
  90. pCRT->RoleString[0] = (OMX_STRING)"video_decoder.mpeg4";
  91. pCRT->NumberOfRolesSupported = 1;
  92. pCRT->SharedLibraryOsclUuid = NULL;
  93. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  94. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  95. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  96. pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4vdec_sharedlibrary.so";
  97. pCRT->SharedLibraryPtr = NULL;
  98. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  99. if (temp == NULL)
  100. {
  101. oscl_free(pCRT); // free allocated memory
  102. return OMX_ErrorInsufficientResources;
  103. }
  104. OSCL_PLACEMENT_NEW(temp, PV_OMX_M4VDEC_UUID);
  105. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  106. pCRT->SharedLibraryRefCounter = 0;
  107. #endif
  108. #if REGISTER_OMX_M4V_COMPONENT
  109. #if (DYNAMIC_LOAD_OMX_M4V_COMPONENT == 0)
  110. pCRT->FunctionPtrCreateComponent = &Mpeg4OmxComponentFactory;
  111. pCRT->FunctionPtrDestroyComponent = &Mpeg4OmxComponentDestructor;
  112. pCRT->SharedLibraryName = NULL;
  113. pCRT->SharedLibraryPtr = NULL;
  114. if (pCRT->SharedLibraryOsclUuid)
  115. oscl_free(pCRT->SharedLibraryOsclUuid);
  116. pCRT->SharedLibraryOsclUuid = NULL;
  117. pCRT->SharedLibraryRefCounter = 0;
  118. #endif
  119. #endif
  120. }
  121. else
  122. {
  123. return OMX_ErrorInsufficientResources;
  124. }
  125. return ComponentRegister(pCRT);
  126. }
  127. #endif
  128. //////////////////////////////////////////////////////////////////////////////
  129. #if REGISTER_OMX_H263_COMPONENT
  130. // external factory functions needed for creation of each component (or stubs for testing)
  131. #if (DYNAMIC_LOAD_OMX_H263_COMPONENT == 0)
  132. extern OMX_ERRORTYPE H263OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  133. extern OMX_ERRORTYPE H263OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  134. #endif
  135. #endif
  136. #if (REGISTER_OMX_H263_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  137. /////////////////////////////////////////////////////////////////////////////
  138. OMX_ERRORTYPE H263Register()
  139. {
  140. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  141. if (pCRT)
  142. {
  143. pCRT->ComponentName = (OMX_STRING)"OMX.PV.h263dec";
  144. pCRT->RoleString[0] = (OMX_STRING)"video_decoder.h263";
  145. pCRT->NumberOfRolesSupported = 1;
  146. pCRT->SharedLibraryOsclUuid = NULL;
  147. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  148. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  149. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  150. pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4vdec_sharedlibrary.so";
  151. pCRT->SharedLibraryPtr = NULL;
  152. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  153. if (temp == NULL)
  154. {
  155. oscl_free(pCRT); // free allocated memory
  156. return OMX_ErrorInsufficientResources;
  157. }
  158. OSCL_PLACEMENT_NEW(temp, PV_OMX_H263DEC_UUID);
  159. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  160. pCRT->SharedLibraryRefCounter = 0;
  161. #endif
  162. #if REGISTER_OMX_H263_COMPONENT
  163. #if (DYNAMIC_LOAD_OMX_H263_COMPONENT == 0)
  164. pCRT->FunctionPtrCreateComponent = &H263OmxComponentFactory;
  165. pCRT->FunctionPtrDestroyComponent = &H263OmxComponentDestructor;
  166. pCRT->SharedLibraryName = NULL;
  167. pCRT->SharedLibraryPtr = NULL;
  168. if (pCRT->SharedLibraryOsclUuid)
  169. oscl_free(pCRT->SharedLibraryOsclUuid);
  170. pCRT->SharedLibraryOsclUuid = NULL;
  171. pCRT->SharedLibraryRefCounter = 0;
  172. #endif
  173. #endif
  174. }
  175. else
  176. {
  177. return OMX_ErrorInsufficientResources;
  178. }
  179. return ComponentRegister(pCRT);
  180. }
  181. #endif
  182. ////////////////////////////////////////////////////////////////////////////////////
  183. #if REGISTER_OMX_AVC_COMPONENT
  184. #if (DYNAMIC_LOAD_OMX_AVC_COMPONENT == 0)
  185. extern OMX_ERRORTYPE AvcOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  186. extern OMX_ERRORTYPE AvcOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  187. #endif
  188. #endif
  189. #if (REGISTER_OMX_AVC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  190. /////////////////////////////////////////////////////////////////////
  191. OMX_ERRORTYPE AvcRegister()
  192. {
  193. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  194. if (pCRT)
  195. {
  196. pCRT->ComponentName = (OMX_STRING)"OMX.PV.avcdec";
  197. pCRT->RoleString[0] = (OMX_STRING)"video_decoder.avc";
  198. pCRT->NumberOfRolesSupported = 1;
  199. pCRT->SharedLibraryOsclUuid = NULL;
  200. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  201. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  202. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  203. pCRT->SharedLibraryName = (OMX_STRING)"libomx_avcdec_sharedlibrary.so";
  204. pCRT->SharedLibraryPtr = NULL;
  205. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  206. if (temp == NULL)
  207. {
  208. oscl_free(pCRT); // free allocated memory
  209. return OMX_ErrorInsufficientResources;
  210. }
  211. OSCL_PLACEMENT_NEW(temp, PV_OMX_AVCDEC_UUID);
  212. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  213. pCRT->SharedLibraryRefCounter = 0;
  214. #endif
  215. #if REGISTER_OMX_AVC_COMPONENT
  216. #if (DYNAMIC_LOAD_OMX_AVC_COMPONENT == 0)
  217. pCRT->FunctionPtrCreateComponent = &AvcOmxComponentFactory;
  218. pCRT->FunctionPtrDestroyComponent = &AvcOmxComponentDestructor;
  219. pCRT->SharedLibraryName = NULL;
  220. pCRT->SharedLibraryPtr = NULL;
  221. if (pCRT->SharedLibraryOsclUuid)
  222. oscl_free(pCRT->SharedLibraryOsclUuid);
  223. pCRT->SharedLibraryOsclUuid = NULL;
  224. pCRT->SharedLibraryRefCounter = 0;
  225. #endif
  226. #endif
  227. }
  228. else
  229. {
  230. return OMX_ErrorInsufficientResources;
  231. }
  232. return ComponentRegister(pCRT);
  233. }
  234. #endif
  235. ////////////////////////////////////////////////////////////////////////////////////
  236. #if REGISTER_OMX_WMV_COMPONENT
  237. #if (DYNAMIC_LOAD_OMX_WMV_COMPONENT == 0)
  238. extern OMX_ERRORTYPE WmvOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  239. extern OMX_ERRORTYPE WmvOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  240. #endif
  241. #endif
  242. #if (REGISTER_OMX_WMV_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  243. /////////////////////////////////////////////////////////////////////
  244. OMX_ERRORTYPE WmvRegister()
  245. {
  246. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  247. if (pCRT)
  248. {
  249. pCRT->ComponentName = (OMX_STRING)"OMX.PV.wmvdec";
  250. pCRT->RoleString[0] = (OMX_STRING)"video_decoder.wmv";
  251. pCRT->NumberOfRolesSupported = 1;
  252. pCRT->SharedLibraryOsclUuid = NULL;
  253. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  254. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  255. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  256. pCRT->SharedLibraryName = (OMX_STRING)"libomx_wmvdec_sharedlibrary.so";
  257. pCRT->SharedLibraryPtr = NULL;
  258. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  259. if (temp == NULL)
  260. {
  261. oscl_free(pCRT); // free allocated memory
  262. return OMX_ErrorInsufficientResources;
  263. }
  264. OSCL_PLACEMENT_NEW(temp, PV_OMX_WMVDEC_UUID);
  265. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  266. pCRT->SharedLibraryRefCounter = 0;
  267. #endif
  268. #if REGISTER_OMX_WMV_COMPONENT
  269. #if (DYNAMIC_LOAD_OMX_WMV_COMPONENT == 0)
  270. pCRT->FunctionPtrCreateComponent = &WmvOmxComponentFactory;
  271. pCRT->FunctionPtrDestroyComponent = &WmvOmxComponentDestructor;
  272. pCRT->SharedLibraryName = NULL;
  273. pCRT->SharedLibraryPtr = NULL;
  274. if (pCRT->SharedLibraryOsclUuid)
  275. oscl_free(pCRT->SharedLibraryOsclUuid);
  276. pCRT->SharedLibraryOsclUuid = NULL;
  277. pCRT->SharedLibraryRefCounter = 0;
  278. #endif
  279. #endif
  280. }
  281. else
  282. {
  283. return OMX_ErrorInsufficientResources;
  284. }
  285. return ComponentRegister(pCRT);
  286. }
  287. #endif
  288. ///////////////////////////////////////////////////////////////////////////////////////////////
  289. #if REGISTER_OMX_AAC_COMPONENT
  290. // external factory functions needed for creation of each component (or stubs for testing)
  291. #if (DYNAMIC_LOAD_OMX_AAC_COMPONENT == 0)
  292. extern OMX_ERRORTYPE AacOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  293. extern OMX_ERRORTYPE AacOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  294. #endif
  295. #endif
  296. #if (REGISTER_OMX_AAC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  297. /////////////////////////////////////////////////////////////////////////////
  298. OMX_ERRORTYPE AacRegister()
  299. {
  300. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  301. if (pCRT)
  302. {
  303. pCRT->ComponentName = (OMX_STRING)"OMX.PV.aacdec";
  304. pCRT->RoleString[0] = (OMX_STRING)"audio_decoder.aac";
  305. pCRT->NumberOfRolesSupported = 1;
  306. pCRT->SharedLibraryOsclUuid = NULL;
  307. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  308. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  309. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  310. pCRT->SharedLibraryName = (OMX_STRING)"libomx_aacdec_sharedlibrary.so";
  311. pCRT->SharedLibraryPtr = NULL;
  312. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  313. if (temp == NULL)
  314. {
  315. oscl_free(pCRT); // free allocated memory
  316. return OMX_ErrorInsufficientResources;
  317. }
  318. OSCL_PLACEMENT_NEW(temp, PV_OMX_AACDEC_UUID);
  319. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  320. pCRT->SharedLibraryRefCounter = 0;
  321. #endif
  322. #if REGISTER_OMX_AAC_COMPONENT
  323. #if (DYNAMIC_LOAD_OMX_AAC_COMPONENT == 0)
  324. pCRT->FunctionPtrCreateComponent = &AacOmxComponentFactory;
  325. pCRT->FunctionPtrDestroyComponent = &AacOmxComponentDestructor;
  326. pCRT->SharedLibraryName = NULL;
  327. pCRT->SharedLibraryPtr = NULL;
  328. if (pCRT->SharedLibraryOsclUuid)
  329. oscl_free(pCRT->SharedLibraryOsclUuid);
  330. pCRT->SharedLibraryOsclUuid = NULL;
  331. pCRT->SharedLibraryRefCounter = 0;
  332. #endif
  333. #endif
  334. }
  335. else
  336. {
  337. return OMX_ErrorInsufficientResources;
  338. }
  339. return ComponentRegister(pCRT);
  340. }
  341. #endif
  342. ///////////////////////////////////////////////////////////////////////////////////////////////
  343. #if REGISTER_OMX_AMR_COMPONENT
  344. // external factory functions needed for creation of each component (or stubs for testing)
  345. #if (DYNAMIC_LOAD_OMX_AMR_COMPONENT == 0)
  346. extern OMX_ERRORTYPE AmrOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  347. extern OMX_ERRORTYPE AmrOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  348. #endif
  349. #endif
  350. #if (REGISTER_OMX_AMR_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  351. /////////////////////////////////////////////////////////////////////////////
  352. OMX_ERRORTYPE AmrRegister()
  353. {
  354. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  355. if (pCRT)
  356. {
  357. pCRT->ComponentName = (OMX_STRING)"OMX.PV.amrdec";
  358. pCRT->RoleString[0] = (OMX_STRING)"audio_decoder.amr";
  359. pCRT->RoleString[1] = (OMX_STRING)"audio_decoder.amrnb";
  360. pCRT->RoleString[2] = (OMX_STRING)"audio_decoder.amrwb";
  361. pCRT->NumberOfRolesSupported = 3;
  362. pCRT->SharedLibraryOsclUuid = NULL;
  363. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  364. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  365. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  366. pCRT->SharedLibraryName = (OMX_STRING)"libomx_amrdec_sharedlibrary.so";
  367. pCRT->SharedLibraryPtr = NULL;
  368. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  369. if (temp == NULL)
  370. {
  371. oscl_free(pCRT); // free allocated memory
  372. return OMX_ErrorInsufficientResources;
  373. }
  374. OSCL_PLACEMENT_NEW(temp, PV_OMX_AMRDEC_UUID);
  375. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  376. pCRT->SharedLibraryRefCounter = 0;
  377. #endif
  378. #if REGISTER_OMX_AMR_COMPONENT
  379. #if (DYNAMIC_LOAD_OMX_AMR_COMPONENT == 0)
  380. pCRT->FunctionPtrCreateComponent = &AmrOmxComponentFactory;
  381. pCRT->FunctionPtrDestroyComponent = &AmrOmxComponentDestructor;
  382. pCRT->SharedLibraryName = NULL;
  383. pCRT->SharedLibraryPtr = NULL;
  384. if (pCRT->SharedLibraryOsclUuid)
  385. oscl_free(pCRT->SharedLibraryOsclUuid);
  386. pCRT->SharedLibraryOsclUuid = NULL;
  387. pCRT->SharedLibraryRefCounter = 0;
  388. #endif
  389. #endif
  390. }
  391. else
  392. {
  393. return OMX_ErrorInsufficientResources;
  394. }
  395. return ComponentRegister(pCRT);
  396. }
  397. #endif
  398. ///////////////////////////////////////////////////////////////////////////////////////////////
  399. #if REGISTER_OMX_MP3_COMPONENT
  400. // external factory functions needed for creation of each component (or stubs for testing)
  401. #if (DYNAMIC_LOAD_OMX_MP3_COMPONENT == 0)
  402. extern OMX_ERRORTYPE Mp3OmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  403. extern OMX_ERRORTYPE Mp3OmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  404. #endif
  405. #endif
  406. #if (REGISTER_OMX_MP3_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  407. /////////////////////////////////////////////////////////////////////////////
  408. OMX_ERRORTYPE Mp3Register()
  409. {
  410. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  411. if (pCRT)
  412. {
  413. pCRT->ComponentName = (OMX_STRING)"OMX.PV.mp3dec";
  414. pCRT->RoleString[0] = (OMX_STRING)"audio_decoder.mp3";
  415. pCRT->NumberOfRolesSupported = 1;
  416. pCRT->SharedLibraryOsclUuid = NULL;
  417. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  418. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  419. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  420. pCRT->SharedLibraryName = (OMX_STRING)"libomx_mp3dec_sharedlibrary.so";
  421. pCRT->SharedLibraryPtr = NULL;
  422. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  423. if (temp == NULL)
  424. {
  425. oscl_free(pCRT); // free allocated memory
  426. return OMX_ErrorInsufficientResources;
  427. }
  428. OSCL_PLACEMENT_NEW(temp, PV_OMX_MP3DEC_UUID);
  429. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  430. pCRT->SharedLibraryRefCounter = 0;
  431. #endif
  432. #if REGISTER_OMX_MP3_COMPONENT
  433. #if (DYNAMIC_LOAD_OMX_MP3_COMPONENT == 0)
  434. pCRT->FunctionPtrCreateComponent = &Mp3OmxComponentFactory;
  435. pCRT->FunctionPtrDestroyComponent = &Mp3OmxComponentDestructor;
  436. pCRT->SharedLibraryName = NULL;
  437. pCRT->SharedLibraryPtr = NULL;
  438. if (pCRT->SharedLibraryOsclUuid)
  439. oscl_free(pCRT->SharedLibraryOsclUuid);
  440. pCRT->SharedLibraryOsclUuid = NULL;
  441. pCRT->SharedLibraryRefCounter = 0;
  442. #endif
  443. #endif
  444. }
  445. else
  446. {
  447. return OMX_ErrorInsufficientResources;
  448. }
  449. return ComponentRegister(pCRT);
  450. }
  451. #endif
  452. ///////////////////////////////////////////////////////////////////////////////////////////////
  453. #if REGISTER_OMX_WMA_COMPONENT
  454. // external factory functions needed for creation of each component (or stubs for testing)
  455. #if (DYNAMIC_LOAD_OMX_WMA_COMPONENT == 0)
  456. extern OMX_ERRORTYPE WmaOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  457. extern OMX_ERRORTYPE WmaOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  458. #endif
  459. #endif
  460. #if (REGISTER_OMX_WMA_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  461. /////////////////////////////////////////////////////////////////////////////
  462. OMX_ERRORTYPE WmaRegister()
  463. {
  464. ComponentRegistrationType *pCRT = (ComponentRegistrationType *) oscl_malloc(sizeof(ComponentRegistrationType));
  465. if (pCRT)
  466. {
  467. pCRT->ComponentName = (OMX_STRING)"OMX.PV.wmadec";
  468. pCRT->RoleString[0] = (OMX_STRING)"audio_decoder.wma";
  469. pCRT->NumberOfRolesSupported = 1;
  470. pCRT->SharedLibraryOsclUuid = NULL;
  471. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  472. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  473. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  474. pCRT->SharedLibraryName = (OMX_STRING)"libomx_wmadec_sharedlibrary.so";
  475. pCRT->SharedLibraryPtr = NULL;
  476. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  477. if (temp == NULL)
  478. {
  479. oscl_free(pCRT); // free allocated memory
  480. return OMX_ErrorInsufficientResources;
  481. }
  482. OSCL_PLACEMENT_NEW(temp, PV_OMX_WMADEC_UUID);
  483. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  484. pCRT->SharedLibraryRefCounter = 0;
  485. #endif
  486. #if REGISTER_OMX_WMA_COMPONENT
  487. #if (DYNAMIC_LOAD_OMX_WMA_COMPONENT == 0)
  488. pCRT->FunctionPtrCreateComponent = &WmaOmxComponentFactory;
  489. pCRT->FunctionPtrDestroyComponent = &WmaOmxComponentDestructor;
  490. pCRT->SharedLibraryName = NULL;
  491. pCRT->SharedLibraryPtr = NULL;
  492. if (pCRT->SharedLibraryOsclUuid)
  493. oscl_free(pCRT->SharedLibraryOsclUuid);
  494. pCRT->SharedLibraryOsclUuid = NULL;
  495. pCRT->SharedLibraryRefCounter = 0;
  496. #endif
  497. #endif
  498. }
  499. else
  500. {
  501. return OMX_ErrorInsufficientResources;
  502. }
  503. return ComponentRegister(pCRT);
  504. }
  505. #endif
  506. ///////////////////////////////////////////////////////////////////////////////////////////////
  507. #if REGISTER_OMX_AMRENC_COMPONENT
  508. // external factory functions needed for creation of each component (or stubs for testing)
  509. #if (DYNAMIC_LOAD_OMX_AMRENC_COMPONENT == 0)
  510. extern OMX_ERRORTYPE AmrEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  511. extern OMX_ERRORTYPE AmrEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  512. #endif
  513. #endif
  514. #if (REGISTER_OMX_AMRENC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  515. /////////////////////////////////////////////////////////////////////////////
  516. OMX_ERRORTYPE AmrEncRegister()
  517. {
  518. ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
  519. if (pCRT)
  520. {
  521. pCRT->ComponentName = (OMX_STRING)"OMX.PV.amrencnb";
  522. pCRT->RoleString[0] = (OMX_STRING)"audio_encoder.amrnb";
  523. pCRT->NumberOfRolesSupported = 1;
  524. pCRT->SharedLibraryOsclUuid = NULL;
  525. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  526. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  527. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  528. pCRT->SharedLibraryName = (OMX_STRING)"libomx_amrenc_sharedlibrary.so";
  529. pCRT->SharedLibraryPtr = NULL;
  530. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  531. if (temp == NULL)
  532. {
  533. oscl_free(pCRT); // free allocated memory
  534. return OMX_ErrorInsufficientResources;
  535. }
  536. OSCL_PLACEMENT_NEW(temp, PV_OMX_AMRENC_UUID);
  537. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  538. pCRT->SharedLibraryRefCounter = 0;
  539. #endif
  540. #if REGISTER_OMX_AMRENC_COMPONENT
  541. #if (DYNAMIC_LOAD_OMX_AMRENC_COMPONENT == 0)
  542. pCRT->FunctionPtrCreateComponent = &AmrEncOmxComponentFactory;
  543. pCRT->FunctionPtrDestroyComponent = &AmrEncOmxComponentDestructor;
  544. pCRT->SharedLibraryName = NULL;
  545. pCRT->SharedLibraryPtr = NULL;
  546. if (pCRT->SharedLibraryOsclUuid)
  547. oscl_free(pCRT->SharedLibraryOsclUuid);
  548. pCRT->SharedLibraryOsclUuid = NULL;
  549. pCRT->SharedLibraryRefCounter = 0;
  550. #endif
  551. #endif
  552. }
  553. else
  554. {
  555. return OMX_ErrorInsufficientResources;
  556. }
  557. return ComponentRegister(pCRT);
  558. }
  559. #endif
  560. ///////////////////////////////////////////////////////////////////////////////////////////////
  561. #if REGISTER_OMX_M4VENC_COMPONENT
  562. // external factory functions needed for creation of each component (or stubs for testing)
  563. #if (DYNAMIC_LOAD_OMX_M4VENC_COMPONENT == 0)
  564. extern OMX_ERRORTYPE Mpeg4EncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  565. extern OMX_ERRORTYPE Mpeg4EncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  566. #endif
  567. #endif
  568. #if (REGISTER_OMX_M4VENC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  569. /////////////////////////////////////////////////////////////////////////////
  570. OMX_ERRORTYPE Mpeg4EncRegister()
  571. {
  572. ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
  573. if (pCRT)
  574. {
  575. pCRT->ComponentName = (OMX_STRING)"OMX.PV.mpeg4enc";
  576. pCRT->RoleString[0] = (OMX_STRING)"video_encoder.mpeg4";
  577. pCRT->NumberOfRolesSupported = 1;
  578. pCRT->SharedLibraryOsclUuid = NULL;
  579. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  580. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  581. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  582. pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4venc_sharedlibrary.so";
  583. pCRT->SharedLibraryPtr = NULL;
  584. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  585. if (temp == NULL)
  586. {
  587. oscl_free(pCRT); // free allocated memory
  588. return OMX_ErrorInsufficientResources;
  589. }
  590. OSCL_PLACEMENT_NEW(temp, PV_OMX_M4VENC_UUID);
  591. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  592. pCRT->SharedLibraryRefCounter = 0;
  593. #endif
  594. #if REGISTER_OMX_M4VENC_COMPONENT
  595. #if (DYNAMIC_LOAD_OMX_M4VENC_COMPONENT == 0)
  596. pCRT->FunctionPtrCreateComponent = &Mpeg4EncOmxComponentFactory;
  597. pCRT->FunctionPtrDestroyComponent = &Mpeg4EncOmxComponentDestructor;
  598. pCRT->SharedLibraryName = NULL;
  599. pCRT->SharedLibraryPtr = NULL;
  600. if (pCRT->SharedLibraryOsclUuid)
  601. oscl_free(pCRT->SharedLibraryOsclUuid);
  602. pCRT->SharedLibraryOsclUuid = NULL;
  603. pCRT->SharedLibraryRefCounter = 0;
  604. #endif
  605. #endif
  606. }
  607. else
  608. {
  609. return OMX_ErrorInsufficientResources;
  610. }
  611. return ComponentRegister(pCRT);
  612. }
  613. #endif
  614. #if REGISTER_OMX_H263ENC_COMPONENT
  615. // external factory functions needed for creation of each component (or stubs for testing)
  616. #if (DYNAMIC_LOAD_OMX_H263ENC_COMPONENT == 0)
  617. extern OMX_ERRORTYPE H263EncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  618. extern OMX_ERRORTYPE H263EncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  619. #endif
  620. #endif
  621. #if (REGISTER_OMX_H263ENC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  622. /////////////////////////////////////////////////////////////////////////////
  623. OMX_ERRORTYPE H263EncRegister()
  624. {
  625. ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
  626. if (pCRT)
  627. {
  628. pCRT->ComponentName = (OMX_STRING)"OMX.PV.h263enc";
  629. pCRT->RoleString[0] = (OMX_STRING)"video_encoder.h263";
  630. pCRT->NumberOfRolesSupported = 1;
  631. pCRT->SharedLibraryOsclUuid = NULL;
  632. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  633. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  634. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  635. pCRT->SharedLibraryName = (OMX_STRING)"libomx_m4venc_sharedlibrary.so";
  636. pCRT->SharedLibraryPtr = NULL;
  637. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  638. if (temp == NULL)
  639. {
  640. oscl_free(pCRT); // free allocated memory
  641. return OMX_ErrorInsufficientResources;
  642. }
  643. OSCL_PLACEMENT_NEW(temp, PV_OMX_H263ENC_UUID);
  644. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  645. pCRT->SharedLibraryRefCounter = 0;
  646. #endif
  647. #if REGISTER_OMX_H263ENC_COMPONENT
  648. #if (DYNAMIC_LOAD_OMX_H263ENC_COMPONENT == 0)
  649. pCRT->FunctionPtrCreateComponent = &H263EncOmxComponentFactory;
  650. pCRT->FunctionPtrDestroyComponent = &H263EncOmxComponentDestructor;
  651. pCRT->SharedLibraryName = NULL;
  652. pCRT->SharedLibraryPtr = NULL;
  653. if (pCRT->SharedLibraryOsclUuid)
  654. oscl_free(pCRT->SharedLibraryOsclUuid);
  655. pCRT->SharedLibraryOsclUuid = NULL;
  656. pCRT->SharedLibraryRefCounter = 0;
  657. #endif
  658. #endif
  659. }
  660. else
  661. {
  662. return OMX_ErrorInsufficientResources;
  663. }
  664. return ComponentRegister(pCRT);
  665. }
  666. #endif
  667. ///////////////////////////////////////////////////////////////////////////////////////////////
  668. #if REGISTER_OMX_AVCENC_COMPONENT
  669. // external factory functions needed for creation of each component (or stubs for testing)
  670. #if (DYNAMIC_LOAD_OMX_AVCENC_COMPONENT == 0)
  671. extern OMX_ERRORTYPE AvcEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  672. extern OMX_ERRORTYPE AvcEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  673. #endif
  674. #endif
  675. #if (REGISTER_OMX_AVCENC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  676. /////////////////////////////////////////////////////////////////////////////
  677. OMX_ERRORTYPE AvcEncRegister()
  678. {
  679. ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
  680. if (pCRT)
  681. {
  682. pCRT->ComponentName = (OMX_STRING)"OMX.PV.avcenc";
  683. pCRT->RoleString[0] = (OMX_STRING)"video_encoder.avc";
  684. pCRT->NumberOfRolesSupported = 1;
  685. pCRT->SharedLibraryOsclUuid = NULL;
  686. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  687. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  688. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  689. pCRT->SharedLibraryName = (OMX_STRING)"libomx_avcenc_sharedlibrary.so";
  690. pCRT->SharedLibraryPtr = NULL;
  691. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  692. if (temp == NULL)
  693. {
  694. oscl_free(pCRT); // free allocated memory
  695. return OMX_ErrorInsufficientResources;
  696. }
  697. OSCL_PLACEMENT_NEW(temp, PV_OMX_AVCENC_UUID);
  698. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  699. pCRT->SharedLibraryRefCounter = 0;
  700. #endif
  701. #if REGISTER_OMX_AVCENC_COMPONENT
  702. #if (DYNAMIC_LOAD_OMX_AVCENC_COMPONENT == 0)
  703. pCRT->FunctionPtrCreateComponent = &AvcEncOmxComponentFactory;
  704. pCRT->FunctionPtrDestroyComponent = &AvcEncOmxComponentDestructor;
  705. pCRT->SharedLibraryName = NULL;
  706. pCRT->SharedLibraryPtr = NULL;
  707. if (pCRT->SharedLibraryOsclUuid)
  708. oscl_free(pCRT->SharedLibraryOsclUuid);
  709. pCRT->SharedLibraryOsclUuid = NULL;
  710. pCRT->SharedLibraryRefCounter = 0;
  711. #endif
  712. #endif
  713. }
  714. else
  715. {
  716. return OMX_ErrorInsufficientResources;
  717. }
  718. return ComponentRegister(pCRT);
  719. }
  720. #endif
  721. ///////////////////////////////////////////////////////////////////////////////////////////////
  722. #if REGISTER_OMX_AACENC_COMPONENT
  723. // external factory functions needed for creation of each component (or stubs for testing)
  724. #if (DYNAMIC_LOAD_OMX_AACENC_COMPONENT == 0)
  725. extern OMX_ERRORTYPE AacEncOmxComponentFactory(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  726. extern OMX_ERRORTYPE AacEncOmxComponentDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  727. #endif
  728. #endif
  729. #if (REGISTER_OMX_AACENC_COMPONENT) || (USE_DYNAMIC_LOAD_OMX_COMPONENTS)
  730. /////////////////////////////////////////////////////////////////////////////
  731. OMX_ERRORTYPE AacEncRegister()
  732. {
  733. ComponentRegistrationType* pCRT = (ComponentRegistrationType*) oscl_malloc(sizeof(ComponentRegistrationType));
  734. if (pCRT)
  735. {
  736. pCRT->ComponentName = (OMX_STRING)"OMX.PV.aacenc";
  737. pCRT->RoleString[0] = (OMX_STRING)"audio_encoder.aac";
  738. pCRT->NumberOfRolesSupported = 1;
  739. pCRT->SharedLibraryOsclUuid = NULL;
  740. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  741. pCRT->FunctionPtrCreateComponent = &OmxComponentFactoryDynamicCreate;
  742. pCRT->FunctionPtrDestroyComponent = &OmxComponentFactoryDynamicDestructor;
  743. pCRT->SharedLibraryName = (OMX_STRING)"libomx_aacenc_sharedlibrary.so";
  744. pCRT->SharedLibraryPtr = NULL;
  745. OsclUuid *temp = (OsclUuid *) oscl_malloc(sizeof(OsclUuid));
  746. if (temp == NULL)
  747. {
  748. oscl_free(pCRT); // free allocated memory
  749. return OMX_ErrorInsufficientResources;
  750. }
  751. OSCL_PLACEMENT_NEW(temp, PV_OMX_AACENC_UUID);
  752. pCRT->SharedLibraryOsclUuid = (OMX_PTR) temp;
  753. pCRT->SharedLibraryRefCounter = 0;
  754. #endif
  755. #if REGISTER_OMX_AACENC_COMPONENT
  756. #if (DYNAMIC_LOAD_OMX_AACENC_COMPONENT == 0)
  757. pCRT->FunctionPtrCreateComponent = &AacEncOmxComponentFactory;
  758. pCRT->FunctionPtrDestroyComponent = &AacEncOmxComponentDestructor;
  759. pCRT->SharedLibraryName = NULL;
  760. pCRT->SharedLibraryPtr = NULL;
  761. if (pCRT->SharedLibraryOsclUuid)
  762. oscl_free(pCRT->SharedLibraryOsclUuid);
  763. pCRT->SharedLibraryOsclUuid = NULL;
  764. pCRT->SharedLibraryRefCounter = 0;
  765. #endif
  766. #endif
  767. }
  768. else
  769. {
  770. return OMX_ErrorInsufficientResources;
  771. }
  772. return ComponentRegister(pCRT);
  773. }
  774. #endif
  775. // In case of dynamic loading of individual omx components,
  776. // this function is called by OMX_GetHandle (either through proxy or directly).
  777. // The method dynamically loads the library and creates an instance of the omx component AO
  778. // NOTE: This method is called when singleton is locked. Access & modification of various
  779. // variables should be (and is) thread-safe
  780. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  781. OMX_ERRORTYPE OmxComponentFactoryDynamicCreate(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
  782. {
  783. OMX_ERRORTYPE returnStatus = OMX_ErrorUndefined;
  784. //OSCL_StackString<M4V_MAX_LIB_PATH> omxLibName(OMX_M4V_LIB_NAME);
  785. OsclSharedLibrary* lib = NULL;
  786. // If aOmxLib is NULL, this is the first time this method has been called
  787. if (NULL == aOmxLib)
  788. {
  789. OSCL_StackString<OMX_MAX_LIB_PATH> Libname(aOmxLibName);
  790. lib = OSCL_NEW(OsclSharedLibrary, (Libname));
  791. }
  792. else
  793. {
  794. lib = (OsclSharedLibrary *) aOmxLib;
  795. }
  796. // Keep track of the number of times OmxLib is accessed
  797. aRefCount++;
  798. // Load the associated library. If successful, call the corresponding
  799. // create function located inside the loaded library
  800. if (OsclLibSuccess == lib->LoadLib())
  801. {
  802. // look for the interface
  803. OsclAny* interfacePtr = NULL;
  804. if (OsclLibSuccess == lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr))
  805. {
  806. // the interface ptr should be ok, but check just in case
  807. if (interfacePtr != NULL)
  808. {
  809. OmxSharedLibraryInterface* omxIntPtr =
  810. OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
  811. OsclUuid *temp = (OsclUuid*) aOsclUuid;
  812. OsclAny* createCompTemp =
  813. omxIntPtr->QueryOmxComponentInterface(*temp, PV_OMX_CREATE_INTERFACE);
  814. // check if the component contains the correct ptr
  815. if (createCompTemp != NULL)
  816. {
  817. // createComp is the function pointer to store the creation function
  818. // for the omx component located inside the loaded library
  819. OMX_ERRORTYPE(*createComp)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  820. createComp = OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_OUT OMX_HANDLETYPE * pHandle, OMX_IN OMX_PTR pAppData, OMX_IN OMX_PTR , OMX_STRING, OMX_PTR &, OMX_PTR , OMX_U32 &), createCompTemp);
  821. // call the component AO factory inside the loaded library
  822. returnStatus = (*createComp)(pHandle, pAppData, pProxy, aOmxLibName, aOmxLib, aOsclUuid, aRefCount);
  823. // Store the shared library so it can be closed later
  824. aOmxLib = (OMX_PTR) lib;
  825. }
  826. }
  827. }
  828. }
  829. // if everything is OK, the AO factory should have returned OMX_ErrorNone
  830. if (returnStatus != OMX_ErrorNone)
  831. {
  832. lib->Close();
  833. // If this is the last time to close the library, delete the
  834. // OsclSharedLibrary object and be sure to set aOmxLib back to NULL
  835. aRefCount--;
  836. if (0 == aRefCount)
  837. {
  838. OSCL_DELETE(lib);
  839. aOmxLib = NULL;
  840. }
  841. }
  842. return returnStatus;
  843. }
  844. OMX_ERRORTYPE OmxComponentFactoryDynamicDestructor(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount)
  845. {
  846. OsclSharedLibrary* lib = (OsclSharedLibrary *) aOmxLib;
  847. OMX_ERRORTYPE returnStatus = OMX_ErrorUndefined;
  848. // lib must not be NULL at this point. If the omx component has been
  849. // created, lib is necessary to destroy the component correctly and
  850. // cleanup used memory.
  851. OSCL_ASSERT(NULL != lib);
  852. if (lib == NULL)
  853. {
  854. return returnStatus;
  855. }
  856. // Need to get the function pointer for the destroy function through the
  857. // shared library interface.
  858. // first, try to get the interface
  859. OsclAny* interfacePtr = NULL;
  860. if (OsclLibSuccess == lib->QueryInterface(PV_OMX_SHARED_INTERFACE, (OsclAny*&)interfacePtr))
  861. {
  862. if (interfacePtr != NULL)
  863. {
  864. OmxSharedLibraryInterface* omxIntPtr =
  865. OSCL_DYNAMIC_CAST(OmxSharedLibraryInterface*, interfacePtr);
  866. // try to get the function ptr to the omx component AO destructor inside the loaded library
  867. OsclUuid *temp = (OsclUuid*) aOsclUuid;
  868. OsclAny* destroyCompTemp =
  869. omxIntPtr->QueryOmxComponentInterface(*temp, PV_OMX_DESTROY_INTERFACE);
  870. if (destroyCompTemp != NULL)
  871. {
  872. // destroyComp is the function pointer to store the function for
  873. // destroying the omx component AO
  874. OMX_ERRORTYPE(*destroyComp)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  875. destroyComp = OSCL_DYNAMIC_CAST(OMX_ERRORTYPE(*)(OMX_IN OMX_HANDLETYPE, OMX_PTR &, OMX_PTR, OMX_U32 &), destroyCompTemp);
  876. // call the destructor through the function ptr
  877. returnStatus = (*destroyComp)(pHandle, aOmxLib, aOsclUuid, aRefCount);
  878. }
  879. }
  880. }
  881. //Whatever the outcome of the interface queries, this needs to be done
  882. // Finish memory cleanup by closing the shared library and deleting
  883. lib->Close();
  884. // If this is the last time to close the library, delete the
  885. // OsclSharedLibrary object and be sure to set iOmxLib back to NULL
  886. aRefCount--;
  887. if (0 == aRefCount)
  888. {
  889. OSCL_DELETE(lib);
  890. aOmxLib = NULL;
  891. }
  892. return returnStatus;
  893. }
  894. #endif // USE_DYNAMIC_LOAD_OMX_COMPONENTS