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