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