OpenMAXBellagio  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 
49 static int initialized;
50 
53 static 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 
102  if (createComponentLoaders()) {
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;
277  tunnelSetup->eSupplier = OMX_BufferSupplyUnspecified;
278 
279  if (hOutput == NULL && hInput == NULL)
280  return OMX_ErrorBadParameter;
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)
423  err = OMX_ErrorNone;
424  }
425 
426  else if(strncmp(szURI, "inet", 4) == 0) {
427  res = inet_pipe_Constructor((CP_PIPETYPE*) hPipe, szURI);
428  if(res == 0x00000000)
429  err = OMX_ErrorNone;
430  }
431  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s\n", __func__);
432  return err;
433 }
DEB_LEV_FUNCTION_NAME
#define DEB_LEV_FUNCTION_NAME
Definition: omx_comp_debug_levels.h:59
OMX_SetupTunnel
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
DEBUG
#define DEBUG(n, fmt, args...)
Definition: omx_comp_debug_levels.h:77
BOSA_COMPONENTLOADER::BOSA_DestroyComponent
OMX_ERRORTYPE(* BOSA_DestroyComponent)(struct BOSA_COMPONENTLOADER *loader, OMX_HANDLETYPE hComponent)
The component destructor of the current component loader.
Definition: component_loader.h:111
OMX_ERRORTYPE
OMX_ERRORTYPE
Definition: OMX_Core.h:127
OMX_GetComponentsOfRole
OMX_ERRORTYPE OMX_GetComponentsOfRole(OMX_STRING role, OMX_U32 *pNumComps, OMX_U8 **compNames)
the OMX_GetComponentsOfRole standard function
Definition: omxcore.c:358
OMX_GetContentPipe
OMX_ERRORTYPE OMX_GetContentPipe(OMX_HANDLETYPE *hPipe, OMX_STRING szURI)
Definition: omxcore.c:413
OMX_U32
unsigned long OMX_U32
Definition: OMX_Types.h:145
OMX_Core.h
CPstring
char * CPstring
Definition: OMX_ContentPipe.h:67
createComponentLoaders
int createComponentLoaders(void)
Definition: omx_create_loaders_linux.c:58
OMX_GetRolesOfComponent
OMX_ERRORTYPE OMX_GetRolesOfComponent(OMX_STRING CompName, OMX_U32 *pNumRoles, OMX_U8 **roles)
the OMX_GetRolesOfComponent standard function
Definition: omxcore.c:326
OMX_CALLBACKTYPE
Definition: OMX_Core.h:498
DEB_LEV_ERR
#define DEB_LEV_ERR
Definition: omx_comp_debug_levels.h:39
BOSA_AddComponentLoader
OMX_ERRORTYPE BOSA_AddComponentLoader(BOSA_COMPONENTLOADER *pLoader)
Definition: omxcore.c:64
OMX_HANDLETYPE
void * OMX_HANDLETYPE
Definition: OMX_Types.h:295
omxcore.h
BOSA_COMPONENTLOADER::BOSA_CreateComponent
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.
Definition: component_loader.h:84
omx_create_loaders.h
OMX_COMPONENTTYPE::ComponentTunnelRequest
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)
Definition: OMX_Component.h:467
BOSA_COMPONENTLOADER::BOSA_GetComponentsOfRole
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...
Definition: component_loader.h:208
OMX_ErrorUndefined
@ OMX_ErrorUndefined
Definition: OMX_Core.h:134
file_pipe_Constructor
CPresult file_pipe_Constructor(CP_PIPETYPE *pPipe, CPstring szURI)
DEB_LEV_SIMPLE_SEQ
#define DEB_LEV_SIMPLE_SEQ
Definition: omx_comp_debug_levels.h:48
OMX_Init
OMX_ERRORTYPE OMX_Init()
The OMX_Init standard function.
Definition: omxcore.c:94
CP_PIPETYPE
Definition: OMX_ContentPipe.h:136
OMX_GetHandle
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_ErrorBadParameter
@ OMX_ErrorBadParameter
Definition: OMX_Core.h:147
OMX_PTR
void * OMX_PTR
Definition: OMX_Types.h:199
OMX_TUNNELSETUPTYPE
Definition: OMX_Core.h:636
OMX_FreeHandle
OMX_ERRORTYPE OMX_FreeHandle(OMX_HANDLETYPE hComponent)
The OMX_FreeHandle standard function.
Definition: omxcore.c:190
OMX_ErrorInsufficientResources
@ OMX_ErrorInsufficientResources
Definition: OMX_Core.h:131
OMX_COMPONENTTYPE
Definition: OMX_Component.h:308
BOSA_COMPONENTLOADER::BOSA_DeInitComponentLoader
OMX_ERRORTYPE(* BOSA_DeInitComponentLoader)(struct BOSA_COMPONENTLOADER *loader)
The destructor of the component loader.
Definition: component_loader.h:62
OMX_ErrorNoMore
@ OMX_ErrorNoMore
Definition: OMX_Core.h:175
BOSA_COMPONENTLOADER::BOSA_InitComponentLoader
OMX_ERRORTYPE(* BOSA_InitComponentLoader)(struct BOSA_COMPONENTLOADER *loader)
The constructor of the component loader.
Definition: component_loader.h:50
inet_pipe_Constructor
CPresult inet_pipe_Constructor(CP_PIPETYPE *pPipe, CPstring szURI)
OMX_TUNNELSETUPTYPE::nTunnelFlags
OMX_U32 nTunnelFlags
Definition: OMX_Core.h:637
BOSA_COMPONENTLOADER::BOSA_GetRolesOfComponent
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...
Definition: component_loader.h:173
OMX_ContentPipe.h
OSCL_EXPORT_REF
#define OSCL_EXPORT_REF
Definition: omx_base_component.h:41
loadersList
BOSA_COMPONENTLOADER ** loadersList
Definition: omxcore.c:62
err
OMX_ERRORTYPE err
Definition: omxvolcontroltest.c:34
OMX_STRING
char * OMX_STRING
Definition: OMX_Types.h:206
OMX_BufferSupplyUnspecified
@ OMX_BufferSupplyUnspecified
Definition: OMX_Core.h:602
CPresult
OMX_U32 CPresult
Definition: OMX_ContentPipe.h:66
OMX_MAX_STRINGNAME_SIZE
#define OMX_MAX_STRINGNAME_SIZE
Definition: OMX_Core.h:281
OMX_ErrorComponentNotFound
@ OMX_ErrorComponentNotFound
Definition: OMX_Core.h:140
OMX_Deinit
OMX_ERRORTYPE OMX_Deinit()
The OMX_Deinit standard function.
Definition: omxcore.c:123
OMX_ErrorNone
@ OMX_ErrorNone
Definition: OMX_Core.h:128
OMX_U8
unsigned char OMX_U8
Definition: OMX_Types.h:133
OMX_ErrorPortsNotCompatible
@ OMX_ErrorPortsNotCompatible
Definition: OMX_Core.h:168
OMX_ErrorContentPipeCreationFailed
@ OMX_ErrorContentPipeCreationFailed
Definition: OMX_Core.h:246
BOSA_COMPONENTLOADER
Component loader entry points.
Definition: component_loader.h:39
DEB_LEV_PARAMS
#define DEB_LEV_PARAMS
Definition: omx_comp_debug_levels.h:43
OMX_TUNNELSETUPTYPE::eSupplier
OMX_BUFFERSUPPLIERTYPE eSupplier
Definition: OMX_Core.h:638
OMX_ComponentNameEnum
OMX_ERRORTYPE OMX_ComponentNameEnum(OMX_STRING cComponentName, OMX_U32 nNameLength, OMX_U32 nIndex)
the OMX_ComponentNameEnum standard function
Definition: omxcore.c:216

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