OpenMAX Bellagio 0.9.3
omxcore.c
Go to the documentation of this file.
1
27#define _GNU_SOURCE
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <sys/types.h>
32#include <dirent.h>
33#include <strings.h>
34#include <errno.h>
35#include <assert.h>
36
37#include <OMX_Core.h>
38#include <OMX_ContentPipe.h>
39
40#include "omxcore.h"
41#include "omx_create_loaders.h"
42
45
49static int initialized;
50
53static int bosa_loaders;
54
63
65{
66 BOSA_COMPONENTLOADER **newLoadersList = NULL;
67 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
68
69 assert(pLoader);
70
71 bosa_loaders++;
72 newLoadersList = realloc(loadersList, bosa_loaders * sizeof(BOSA_COMPONENTLOADER *));
73
74 if (!newLoadersList)
76
77 loadersList = newLoadersList;
78
79 loadersList[bosa_loaders - 1] = pLoader;
80
81 DEBUG(DEB_LEV_SIMPLE_SEQ, "Loader added at index %d\n", bosa_loaders - 1);
82
83 return OMX_ErrorNone;
84}
85
95 int i = 0;
97
98 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
99 if(initialized == 0) {
100 initialized = 1;
101
104 }
105
106 for (i = 0; i < bosa_loaders; i++) {
108 if (err != OMX_ErrorNone) {
109 DEBUG(DEB_LEV_ERR, "A Component loader constructor fails. Exiting\n");
111 }
112 }
113 }
114
115 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
116 return OMX_ErrorNone;
117}
118
124 int i = 0;
125 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
126 if(initialized == 1) {
127 for (i = 0; i < bosa_loaders; i++) {
129 free(loadersList[i]);
130 loadersList[i] = 0;
131 }
132 }
133 free(loadersList);
134 loadersList = 0;
135 initialized = 0;
136 bosa_loaders = 0;
137 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
138 return OMX_ErrorNone;
139}
140
154 OMX_STRING cComponentName,
155 OMX_PTR pAppData,
156 OMX_CALLBACKTYPE* pCallBacks) {
157
159 int i;
160 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for %s\n", __func__, cComponentName);
161
162 for (i = 0; i < bosa_loaders; i++) {
164 loadersList[i],
165 pHandle,
166 cComponentName,
167 pAppData,
168 pCallBacks);
169 if (err == OMX_ErrorNone) {
170 // the component has been found
171 return OMX_ErrorNone;
172 }
173 }
174 /*Required to meet conformance test: do not remove*/
177 }
178 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
180}
181
191 int i;
193 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for %p\n", __func__, hComponent);
194
195 for (i = 0; i < bosa_loaders; i++) {
197 loadersList[i],
198 hComponent);
199
200 if (err == OMX_ErrorNone) {
201 // the component has been found and destroyed
202 return OMX_ErrorNone;
203 }
204 }
205 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
207}
208
217 OMX_STRING cComponentName,
218 OMX_U32 nNameLength,
219 OMX_U32 nIndex)
220{
222 int i = 0;
223 int index = 0;
224 int offset = 0;
225
226 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
227
228 for (i = 0; i < bosa_loaders; i++)
229 {
230 offset = 0;
231
232 while((err = loadersList[i]->BOSA_ComponentNameEnum(loadersList[i],
233 cComponentName,
234 nNameLength,
235 offset)) != OMX_ErrorNoMore)
236 {
237 if (index == nIndex)
238 {
239 return err;
240 }
241 offset++;
242 index++;
243 }
244 }
245
246 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
247 return OMX_ErrorNoMore;
248}
249
263 OMX_HANDLETYPE hOutput,
264 OMX_U32 nPortOutput,
265 OMX_HANDLETYPE hInput,
266 OMX_U32 nPortInput) {
267
269 OMX_COMPONENTTYPE* component;
270 OMX_TUNNELSETUPTYPE* tunnelSetup;
271
272 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s the output port is:%p/%i, the input port is %p/%i\n",
273 __func__, hOutput, (int)nPortOutput, hInput, (int)nPortInput);
274 tunnelSetup = malloc(sizeof(OMX_TUNNELSETUPTYPE));
275 component = (OMX_COMPONENTTYPE*)hOutput;
276 tunnelSetup->nTunnelFlags = 0;
278
279 if (hOutput == NULL && hInput == NULL)
281 if (hOutput){
282 err = (component->ComponentTunnelRequest)(hOutput, nPortOutput, hInput, nPortInput, tunnelSetup);
283 if (err != OMX_ErrorNone) {
284 DEBUG(DEB_LEV_ERR, "Tunneling failed: output port rejects it - err = %x\n", err);
285 free(tunnelSetup);
286 tunnelSetup = NULL;
287 return err;
288 }
289 }
290 DEBUG(DEB_LEV_PARAMS, "First stage of tunneling acheived:\n");
291 DEBUG(DEB_LEV_PARAMS, " - supplier proposed = %i\n", tunnelSetup->eSupplier);
292 DEBUG(DEB_LEV_PARAMS, " - flags = %i\n", (int)tunnelSetup->nTunnelFlags);
293
294 component = (OMX_COMPONENTTYPE*)hInput;
295 if (hInput) {
296 err = (component->ComponentTunnelRequest)(hInput, nPortInput, hOutput, nPortOutput, tunnelSetup);
297 if (err != OMX_ErrorNone) {
298 DEBUG(DEB_LEV_ERR, "Tunneling failed: input port rejects it - err = %08x\n", err);
299 // the second stage fails. the tunnel on poutput port has to be removed
300 component = (OMX_COMPONENTTYPE*)hOutput;
301 err = (component->ComponentTunnelRequest)(hOutput, nPortOutput, NULL, 0, tunnelSetup);
302 if (err != OMX_ErrorNone) {
303 // This error should never happen. It is critical, and not recoverable
304 free(tunnelSetup);
305 tunnelSetup = NULL;
306 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s with OMX_ErrorUndefined\n", __func__);
307 return OMX_ErrorUndefined;
308 }
309 free(tunnelSetup);
310 tunnelSetup = NULL;
311 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s with OMX_ErrorPortsNotCompatible\n", __func__);
313 }
314 }
315 DEBUG(DEB_LEV_PARAMS, "Second stage of tunneling acheived:\n");
316 DEBUG(DEB_LEV_PARAMS, " - supplier proposed = %i\n", (int)tunnelSetup->eSupplier);
317 DEBUG(DEB_LEV_PARAMS, " - flags = %i\n", (int)tunnelSetup->nTunnelFlags);
318 free(tunnelSetup);
319 tunnelSetup = NULL;
320 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
321 return OMX_ErrorNone;
322}
323
327 OMX_STRING CompName,
328 OMX_U32 *pNumRoles,
329 OMX_U8 **roles) {
331 int i;
332
333 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
334 for (i = 0; i < bosa_loaders; i++) {
336 loadersList[i],
337 CompName,
338 pNumRoles,
339 roles);
340 if (err == OMX_ErrorNone) {
341 return OMX_ErrorNone;
342 }
343 }
344 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
346}
347
359 OMX_STRING role,
360 OMX_U32 *pNumComps,
361 OMX_U8 **compNames) {
363 int i,j;
364 int only_number_requested = 0, full_number=0;
365 OMX_U32 temp_num_comp = 0;
366
367 OMX_U8 **tempCompNames;
368 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
369 if (compNames == NULL) {
370 only_number_requested = 1;
371 } else {
372 only_number_requested = 0;
373 }
374 for (i = 0; i < bosa_loaders; i++) {
375 temp_num_comp = *pNumComps;
377 loadersList[i],
378 role,
379 &temp_num_comp,
380 NULL);
381 if (err != OMX_ErrorNone) {
382 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
384 }
385 if (only_number_requested == 0) {
386 tempCompNames = malloc(temp_num_comp * sizeof(OMX_STRING));
387 for (j=0; j<temp_num_comp; j++) {
388 tempCompNames[j] = malloc(OMX_MAX_STRINGNAME_SIZE * sizeof(char));
389 }
391 loadersList[i],
392 role,
393 &temp_num_comp,
394 tempCompNames);
395 if (err != OMX_ErrorNone) {
396 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
398 }
399
400 for (j = 0; j<temp_num_comp; j++) {
401 if (full_number + j < *pNumComps) {
402 strncpy((char *)compNames[full_number + j], (const char *)tempCompNames[j], 128);
403 }
404 }
405 }
406 full_number += temp_num_comp;
407 }
408 *pNumComps = full_number;
409 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
410 return OMX_ErrorNone;
411}
412
414 OMX_HANDLETYPE *hPipe,
415 OMX_STRING szURI) {
417 CPresult res;
418 DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
419
420 if(strncmp(szURI, "file", 4) == 0) {
421 res = file_pipe_Constructor((CP_PIPETYPE*) hPipe, szURI);
422 if(res == 0x00000000)
424 }
425
426 else if(strncmp(szURI, "inet", 4) == 0) {
427 res = inet_pipe_Constructor((CP_PIPETYPE*) hPipe, szURI);
428 if(res == 0x00000000)
430 }
431 DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
432 return err;
433}
char * CPstring
OMX_U32 CPresult
#define OMX_MAX_STRINGNAME_SIZE
Definition: OMX_Core.h:281
OMX_ERRORTYPE
Definition: OMX_Core.h:127
@ OMX_ErrorInsufficientResources
Definition: OMX_Core.h:131
@ OMX_ErrorNoMore
Definition: OMX_Core.h:175
@ OMX_ErrorNone
Definition: OMX_Core.h:128
@ OMX_ErrorUndefined
Definition: OMX_Core.h:134
@ OMX_ErrorComponentNotFound
Definition: OMX_Core.h:140
@ OMX_ErrorPortsNotCompatible
Definition: OMX_Core.h:168
@ OMX_ErrorBadParameter
Definition: OMX_Core.h:147
@ OMX_ErrorContentPipeCreationFailed
Definition: OMX_Core.h:246
unsigned long OMX_U32
Definition: OMX_Types.h:145
char * OMX_STRING
Definition: OMX_Types.h:206
unsigned char OMX_U8
Definition: OMX_Types.h:133
void * OMX_PTR
Definition: OMX_Types.h:199
void * OMX_HANDLETYPE
Definition: OMX_Types.h:295
@ OMX_BufferSupplyUnspecified
Definition: OMX_Core.h:602
OMX_ERRORTYPE OMX_Deinit()
The OMX_Deinit standard function.
Definition: omxcore.c:123
OMX_ERRORTYPE OMX_Init()
The OMX_Init standard function.
Definition: omxcore.c:94
OMX_ERRORTYPE(* ComponentTunnelRequest)(OMX_IN OMX_HANDLETYPE hComp, OMX_IN OMX_U32 nPort, OMX_IN OMX_HANDLETYPE hTunneledComp, OMX_IN OMX_U32 nTunneledPort, OMX_INOUT OMX_TUNNELSETUPTYPE *pTunnelSetup)
#define OSCL_EXPORT_REF
#define DEB_LEV_PARAMS
#define DEB_LEV_FUNCTION_NAME
#define DEB_LEV_ERR
#define DEB_LEV_SIMPLE_SEQ
#define DEBUG(n, fmt, args...)
int createComponentLoaders(void)
OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_STRING CompName, OMX_U32 *pNumRoles, OMX_U8 **roles)
the OMX_GetRolesOfComponent standard function
Definition: omxcore.c:326
OMX_ERRORTYPE OMX_SetupTunnel(OMX_HANDLETYPE hOutput, OMX_U32 nPortOutput, OMX_HANDLETYPE hInput, OMX_U32 nPortInput)
the OMX_SetupTunnel standard function
Definition: omxcore.c:262
BOSA_COMPONENTLOADER ** loadersList
Definition: omxcore.c:62
CPresult file_pipe_Constructor(CP_PIPETYPE *pPipe, CPstring szURI)
OMX_ERRORTYPE OMX_ComponentNameEnum(OMX_STRING cComponentName, OMX_U32 nNameLength, OMX_U32 nIndex)
the OMX_ComponentNameEnum standard function
Definition: omxcore.c:216
OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent)
The OMX_FreeHandle standard function.
Definition: omxcore.c:190
OMX_ERRORTYPE OMX_GetContentPipe(OMX_HANDLETYPE *hPipe, OMX_STRING szURI)
Definition: omxcore.c:413
CPresult inet_pipe_Constructor(CP_PIPETYPE *pPipe, CPstring szURI)
OMX_ERRORTYPE BOSA_AddComponentLoader(BOSA_COMPONENTLOADER *pLoader)
Definition: omxcore.c:64
OMX_ERRORTYPE OMX_GetHandle(OMX_HANDLETYPE *pHandle, OMX_STRING cComponentName, OMX_PTR pAppData, OMX_CALLBACKTYPE *pCallBacks)
the OMX_GetHandle standard function
Definition: omxcore.c:153
OMX_ERRORTYPE OMX_GetComponentsOfRole(OMX_STRING role, OMX_U32 *pNumComps, OMX_U8 **compNames)
the OMX_GetComponentsOfRole standard function
Definition: omxcore.c:358
OMX_ERRORTYPE err
Component loader entry points.
OMX_ERRORTYPE(* BOSA_CreateComponent)(struct BOSA_COMPONENTLOADER *loader, OMX_HANDLETYPE *pHandle, OMX_STRING cComponentName, OMX_PTR pAppData, OMX_CALLBACKTYPE *pCallBacks)
The component constructor of the current component loader.
OMX_ERRORTYPE(* BOSA_DeInitComponentLoader)(struct BOSA_COMPONENTLOADER *loader)
The destructor of the component loader.
OMX_ERRORTYPE(* BOSA_InitComponentLoader)(struct BOSA_COMPONENTLOADER *loader)
The constructor of the component loader.
OMX_ERRORTYPE(* BOSA_DestroyComponent)(struct BOSA_COMPONENTLOADER *loader, OMX_HANDLETYPE hComponent)
The component destructor of the current component loader.
OMX_ERRORTYPE(* BOSA_GetComponentsOfRole)(struct BOSA_COMPONENTLOADER *loader, OMX_STRING role, OMX_U32 *pNumComps, OMX_U8 **compNames)
This function implements the OMX_GetComponentsOfRole standard function for the current component load...
OMX_ERRORTYPE(* BOSA_GetRolesOfComponent)(struct BOSA_COMPONENTLOADER *loader, OMX_STRING compName, OMX_U32 *pNumRoles, OMX_U8 **roles)
This function implements the OMX_GetRolesOfComponent standard function for the current component load...
OMX_BUFFERSUPPLIERTYPE eSupplier
Definition: OMX_Core.h:638
OMX_U32 nTunnelFlags
Definition: OMX_Core.h:637

Generated for OpenMAX Bellagio rel. 0.9.3 by  doxygen 1.5.1
SourceForge.net Logo