PageRenderTime 52ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/codecs_v2/omx/omx_common/include/pv_omxcore.h

https://github.com/CyanogenMod/android_external_opencore
C Header | 335 lines | 227 code | 69 blank | 39 comment | 2 complexity | d491d5311ee22fefa8826bfd05934f2d 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 PV_OMXCORE_H_INCLUDED
  19. #define PV_OMXCORE_H_INCLUDED
  20. #ifndef PV_OMXDEFS_H_INCLUDED
  21. #include "pv_omxdefs.h"
  22. #endif
  23. #ifndef PV_OMX_QUEUE_H_INCLUDED
  24. #include "pv_omx_queue.h"
  25. #endif
  26. #ifndef OMX_Types_h
  27. #include "OMX_Types.h"
  28. #endif
  29. #ifndef OSCL_BASE_INCLUDED_H
  30. #include "oscl_base.h"
  31. #endif
  32. #ifndef OSCL_UUID_H_INCLUDED
  33. #include "oscl_uuid.h"
  34. #endif
  35. #ifndef OMX_Core_h
  36. #include "OMX_Core.h"
  37. #endif
  38. #ifndef OMX_Component_h
  39. #include "OMX_Component.h"
  40. #endif
  41. #if PROXY_INTERFACE
  42. #ifndef OMX_PROXY_INTERFACE_H_INCLUDED
  43. #include "omx_proxy_interface.h"
  44. #endif
  45. #endif
  46. #ifndef USE_CML2_CONFIG
  47. #ifdef ANDROID
  48. // NOTE: if at least one component uses dynamic loading,
  49. // USE_DYNAMIC_LOAD_OMX_COMPONENT needs to be 1
  50. #define USE_DYNAMIC_LOAD_OMX_COMPONENTS 0
  51. #define DYNAMIC_LOAD_OMX_AVC_COMPONENT 0
  52. #define DYNAMIC_LOAD_OMX_M4V_COMPONENT 0
  53. #define DYNAMIC_LOAD_OMX_H263_COMPONENT 0
  54. #define DYNAMIC_LOAD_OMX_WMV_COMPONENT 0
  55. #define DYNAMIC_LOAD_OMX_AAC_COMPONENT 0
  56. #define DYNAMIC_LOAD_OMX_AMR_COMPONENT 0
  57. #define DYNAMIC_LOAD_OMX_MP3_COMPONENT 0
  58. #define DYNAMIC_LOAD_OMX_WMA_COMPONENT 0
  59. #define DYNAMIC_LOAD_OMX_AMRENC_COMPONENT 0
  60. #define DYNAMIC_LOAD_OMX_M4VENC_COMPONENT 0
  61. #define DYNAMIC_LOAD_OMX_H263ENC_COMPONENT 0
  62. #define DYNAMIC_LOAD_OMX_AVCENC_COMPONENT 0
  63. #define DYNAMIC_LOAD_OMX_AACENC_COMPONENT 0
  64. #else
  65. #define USE_DYNAMIC_LOAD_OMX_COMPONENTS 0
  66. #define DYNAMIC_LOAD_OMX_AVC_COMPONENT 0
  67. #define DYNAMIC_LOAD_OMX_M4V_COMPONENT 0
  68. #define DYNAMIC_LOAD_OMX_H263_COMPONENT 0
  69. #define DYNAMIC_LOAD_OMX_WMV_COMPONENT 0
  70. #define DYNAMIC_LOAD_OMX_AAC_COMPONENT 0
  71. #define DYNAMIC_LOAD_OMX_AMR_COMPONENT 0
  72. #define DYNAMIC_LOAD_OMX_MP3_COMPONENT 0
  73. #define DYNAMIC_LOAD_OMX_WMA_COMPONENT 0
  74. #define DYNAMIC_LOAD_OMX_AMRENC_COMPONENT 0
  75. #define DYNAMIC_LOAD_OMX_M4VENC_COMPONENT 0
  76. #define DYNAMIC_LOAD_OMX_H263ENC_COMPONENT 0
  77. #define DYNAMIC_LOAD_OMX_AVCENC_COMPONENT 0
  78. #define DYNAMIC_LOAD_OMX_AACENC_COMPONENT 0
  79. #endif
  80. #endif
  81. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  82. #ifndef OSCL_SHARED_LIBRARY_H_INCLUDED
  83. #include "oscl_shared_library.h"
  84. #endif
  85. #endif
  86. #define MAX_ROLES_SUPPORTED 3
  87. #ifdef __cplusplus
  88. extern "C"
  89. {
  90. #endif
  91. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetComponentsOfRole(
  92. OMX_IN OMX_STRING role,
  93. OMX_INOUT OMX_U32 *pNumComps,
  94. OMX_INOUT OMX_U8 **compNames);
  95. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_ComponentNameEnum(
  96. OMX_OUT OMX_STRING cComponentName,
  97. OMX_IN OMX_U32 nNameLength,
  98. OMX_IN OMX_U32 nIndex);
  99. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_FreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
  100. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_GetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
  101. OMX_IN OMX_STRING cComponentName,
  102. OMX_IN OMX_PTR pAppData,
  103. OMX_IN OMX_CALLBACKTYPE* pCallBacks);
  104. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetRolesOfComponent(
  105. OMX_IN OMX_STRING compName,
  106. OMX_INOUT OMX_U32* pNumRoles,
  107. OMX_OUT OMX_U8** roles);
  108. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_SetupTunnel(
  109. OMX_IN OMX_HANDLETYPE hOutput,
  110. OMX_IN OMX_U32 nPortOutput,
  111. OMX_IN OMX_HANDLETYPE hInput,
  112. OMX_IN OMX_U32 nPortInput);
  113. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_GetContentPipe(
  114. OMX_OUT OMX_HANDLETYPE *hPipe,
  115. OMX_IN OMX_STRING szURI);
  116. OSCL_IMPORT_REF OMX_BOOL OMXConfigParser(
  117. OMX_PTR aInputParameters,
  118. OMX_PTR aOutputParameters);
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #if USE_DYNAMIC_LOAD_OMX_COMPONENTS
  123. //Dynamic loading interface definitions
  124. #define PV_OMX_SHARED_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x67)
  125. #define PV_OMX_CREATE_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x68)
  126. #define PV_OMX_DESTROY_INTERFACE OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x69)
  127. #define PV_OMX_AVCDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6a)
  128. #define PV_OMX_M4VDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6b)
  129. #define PV_OMX_H263DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6c)
  130. #define PV_OMX_WMVDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6d)
  131. #define PV_OMX_AACDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6e)
  132. #define PV_OMX_AMRDEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x6f)
  133. #define PV_OMX_MP3DEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x70)
  134. #define PV_OMX_WMADEC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x71)
  135. #define PV_OMX_AVCENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x72)
  136. #define PV_OMX_M4VENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x73)
  137. #define PV_OMX_H263ENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x74)
  138. #define PV_OMX_AMRENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x75)
  139. #define PV_OMX_AACENC_UUID OsclUuid(0x1d4769f0,0xca0c,0x11dc,0x95,0xff,0x08,0x00,0x20,0x0c,0x9a,0x76)
  140. #define OMX_MAX_LIB_PATH 256
  141. class OmxSharedLibraryInterface
  142. {
  143. public:
  144. virtual OsclAny *QueryOmxComponentInterface(const OsclUuid& aOmxTypeId, const OsclUuid& aInterfaceId) = 0;
  145. };
  146. #endif // USE_DYNAMIC_LOAD_OMX_COMPONENTS
  147. // PV additions to OMX_EXTRADATATYPE enum
  148. #define OMX_ExtraDataNALSizeArray 0x7F123321 // random value above 0x7F000000 (start of the unused range for vendors)
  149. class ComponentRegistrationType
  150. {
  151. public:
  152. // name of the component used as identifier
  153. OMX_STRING ComponentName;
  154. OMX_STRING RoleString[MAX_ROLES_SUPPORTED];
  155. OMX_U32 NumberOfRolesSupported;
  156. // pointer to factory function to be called when component needs to be instantiated
  157. OMX_ERRORTYPE(*FunctionPtrCreateComponent)(OMX_OUT OMX_HANDLETYPE* pHandle, OMX_IN OMX_PTR pAppData,
  158. OMX_PTR pProxy, OMX_STRING aOmxLibName, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  159. // pointer to function that destroys the component and its AO
  160. OMX_ERRORTYPE(*FunctionPtrDestroyComponent)(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  161. //This function will return the role string
  162. void GetRolesOfComponent(OMX_STRING* aRole_string)
  163. {
  164. for (OMX_U32 ii = 0; ii < NumberOfRolesSupported; ii++)
  165. {
  166. aRole_string[ii] = RoleString[ii];
  167. }
  168. }
  169. // for dynamic loading
  170. OMX_STRING SharedLibraryName;
  171. OMX_PTR SharedLibraryPtr;
  172. OMX_PTR SharedLibraryOsclUuid;
  173. OMX_U32 SharedLibraryRefCounter;
  174. };
  175. typedef struct CoreDescriptorType
  176. {
  177. QueueType* pMessageQueue; // The output queue for the messages to be send to the components
  178. } CoreDescriptorType;
  179. /** This structure contains all the fields of a message handled by the core */
  180. struct CoreMessage
  181. {
  182. OMX_COMPONENTTYPE* pComponent; /// A reference to the main structure that defines a component. It represents the target of the message
  183. OMX_S32 MessageType; /// the flag that specifies if the message is a command, a warning or an error
  184. OMX_S32 MessageParam1; /// the first field of the message. Its use is the same as specified for the command in OpenMAX spec
  185. OMX_S32 MessageParam2; /// the second field of the message. Its use is the same as specified for the command in OpenMAX spec
  186. OMX_PTR pCmdData; /// This pointer could contain some proprietary data not covered by the standard
  187. };
  188. typedef struct PV_OMXComponentCapabilityFlagsType
  189. {
  190. ////////////////// OMX COMPONENT CAPABILITY RELATED MEMBERS
  191. OMX_BOOL iIsOMXComponentMultiThreaded;
  192. OMX_BOOL iOMXComponentSupportsExternalOutputBufferAlloc;
  193. OMX_BOOL iOMXComponentSupportsExternalInputBufferAlloc;
  194. OMX_BOOL iOMXComponentSupportsMovableInputBuffers;
  195. OMX_BOOL iOMXComponentSupportsPartialFrames;
  196. OMX_BOOL iOMXComponentUsesNALStartCodes;
  197. OMX_BOOL iOMXComponentCanHandleIncompleteFrames;
  198. OMX_BOOL iOMXComponentUsesFullAVCFrames;
  199. } PV_OMXComponentCapabilityFlagsType;
  200. class OMXGlobalData
  201. {
  202. public:
  203. OMXGlobalData()
  204. : iInstanceCount(1),
  205. iOsclInit(false),
  206. iNumBaseInstance(0),
  207. iComponentIndex(0)
  208. {
  209. for (OMX_S32 ii = 0; ii < MAX_INSTANTIATED_COMPONENTS; ii++)
  210. {
  211. ipInstantiatedComponentReg[ii] = NULL;
  212. }
  213. }
  214. uint32 iInstanceCount;
  215. bool iOsclInit; //did we do OsclInit in OMX_Init? if so we must cleanup in OMX_Deinit.
  216. //Number of base instances
  217. OMX_U32 iNumBaseInstance;
  218. // Array to store component handles for future recognition of components etc.
  219. OMX_HANDLETYPE iComponentHandle[MAX_INSTANTIATED_COMPONENTS];
  220. OMX_U32 iComponentIndex;
  221. // Array of supported component types (e.g. MP4, AVC, AAC, etc.)
  222. // they need to be registered
  223. // For each OMX Component type (e.g. Mp3, AVC, AAC) there is one entry in this table that contains info
  224. // such as component type, factory, destructor functions, library name for dynamic loading etc.
  225. // when the omx component is registered (at OMX_Init)
  226. ComponentRegistrationType* ipRegTemplateList[MAX_SUPPORTED_COMPONENTS];
  227. // Array of pointers - For each OMX component that gets instantiated - the pointer to its registry structure
  228. // is saved here. This information is needed when the component is to be destroyed
  229. ComponentRegistrationType* ipInstantiatedComponentReg[MAX_INSTANTIATED_COMPONENTS];
  230. // array of function pointers. For each component, a destructor function is assigned
  231. //OMX_ERRORTYPE(*ComponentDestructor[MAX_INSTANTIATED_COMPONENTS])(OMX_IN OMX_HANDLETYPE pHandle, OMX_PTR &aOmxLib, OMX_PTR aOsclUuid, OMX_U32 &aRefCount);
  232. #if PROXY_INTERFACE
  233. ProxyApplication_OMX* ipProxyTerm[MAX_INSTANTIATED_COMPONENTS];
  234. #endif
  235. };
  236. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterInit();
  237. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterDeinit();
  238. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetComponentsOfRole(
  239. OMX_IN OMX_STRING role,
  240. OMX_INOUT OMX_U32 *pNumComps,
  241. OMX_INOUT OMX_U8 **compNames);
  242. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterComponentNameEnum(
  243. OMX_OUT OMX_STRING cComponentName,
  244. OMX_IN OMX_U32 nNameLength,
  245. OMX_IN OMX_U32 nIndex);
  246. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterFreeHandle(OMX_IN OMX_HANDLETYPE hComponent);
  247. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_APIENTRY OMX_MasterGetHandle(OMX_OUT OMX_HANDLETYPE* pHandle,
  248. OMX_IN OMX_STRING cComponentName,
  249. OMX_IN OMX_PTR pAppData,
  250. OMX_IN OMX_CALLBACKTYPE* pCallBacks);
  251. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetRolesOfComponent(
  252. OMX_IN OMX_STRING compName,
  253. OMX_INOUT OMX_U32* pNumRoles,
  254. OMX_OUT OMX_U8** roles);
  255. OSCL_IMPORT_REF OMX_BOOL OMX_MasterConfigParser(
  256. OMX_PTR aInputParameters,
  257. OMX_PTR aOutputParameters);
  258. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterSetupTunnel(
  259. OMX_IN OMX_HANDLETYPE hOutput,
  260. OMX_IN OMX_U32 nPortOutput,
  261. OMX_IN OMX_HANDLETYPE hInput,
  262. OMX_IN OMX_U32 nPortInput);
  263. OSCL_IMPORT_REF OMX_ERRORTYPE OMX_MasterGetContentPipe(
  264. OMX_OUT OMX_HANDLETYPE *hPipe,
  265. OMX_IN OMX_STRING szURI);
  266. #endif