OpenMAX Bellagio  0.9.3
omx_base_component.c
Go to the documentation of this file.
1 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <OMX_Core.h>
32 #include <OMX_Component.h>
33 
34 #include "omx_base_component.h"
36 
37 #include "tsemaphore.h"
38 #include "queue.h"
39 
45  if (omx_base_component_Private->flush_condition) {
46  tsem_deinit(omx_base_component_Private->flush_condition);
47  free(omx_base_component_Private->flush_condition);
48  }
49  if (omx_base_component_Private->flush_all_condition) {
50  tsem_deinit(omx_base_component_Private->flush_all_condition);
51  free(omx_base_component_Private->flush_all_condition);
52  }
53  if (omx_base_component_Private->bellagioThreads) {
54  free(omx_base_component_Private->bellagioThreads);
55  }
56  if (omx_base_component_Private->name) {
57  free(omx_base_component_Private->name);
58  }
59  if (omx_base_component_Private->bStateSem) {
60  tsem_deinit(omx_base_component_Private->bStateSem);
61  free(omx_base_component_Private->bStateSem);
62  }
63  if (omx_base_component_Private->bMgmtSem) {
64  tsem_deinit(omx_base_component_Private->bMgmtSem);
65  free(omx_base_component_Private->bMgmtSem);
66  }
67  if (omx_base_component_Private->messageSem) {
68  tsem_deinit(omx_base_component_Private->messageSem);
69  free(omx_base_component_Private->messageSem);
70  }
71  if (omx_base_component_Private->messageQueue) {
72  queue_deinit(omx_base_component_Private->messageQueue);
73  free(omx_base_component_Private->messageQueue);
74  }
75  if (omx_base_component_Private) {
76  free(omx_base_component_Private);
77  }
78 }
96  omx_base_component_PrivateType* omx_base_component_Private;
97  OMX_U32 i;
98  int err;
99 
100  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, openmaxStandComp);
101 
102  if (openmaxStandComp->pComponentPrivate) {
103  omx_base_component_Private = (omx_base_component_PrivateType*)openmaxStandComp->pComponentPrivate;
104  } else {
105  omx_base_component_Private = calloc(1,sizeof(omx_base_component_PrivateType));
106  if (!omx_base_component_Private) {
108  }
109  }
110 
111  if(!omx_base_component_Private->messageQueue) {
112  omx_base_component_Private->messageQueue = calloc(1,sizeof(queue_t));
113  if (!omx_base_component_Private->messageQueue) {
114  base_constructor_remove_garbage_collected(omx_base_component_Private);
116  }
117  err = queue_init(omx_base_component_Private->messageQueue);
118  if (err != 0) {
119  base_constructor_remove_garbage_collected(omx_base_component_Private);
121  }
122  }
123 
124  if(!omx_base_component_Private->messageSem) {
125  omx_base_component_Private->messageSem = calloc(1,sizeof(tsem_t));
126  if (!omx_base_component_Private->messageSem) {
127  base_constructor_remove_garbage_collected(omx_base_component_Private);
129  }
130  err = tsem_init(omx_base_component_Private->messageSem, 0);
131  if (err != 0) {
132  base_constructor_remove_garbage_collected(omx_base_component_Private);
134  }
135  }
136  if(!omx_base_component_Private->bMgmtSem) {
137  omx_base_component_Private->bMgmtSem = calloc(1,sizeof(tsem_t));
138  if (!omx_base_component_Private->bMgmtSem) {
139  base_constructor_remove_garbage_collected(omx_base_component_Private);
141  }
142  err = tsem_init(omx_base_component_Private->bMgmtSem, 0);
143  if (err != 0) {
144  base_constructor_remove_garbage_collected(omx_base_component_Private);
146  }
147  }
148 
149  if(!omx_base_component_Private->bStateSem) {
150  omx_base_component_Private->bStateSem = calloc(1,sizeof(tsem_t));
151  if (!omx_base_component_Private->bStateSem) {
152  base_constructor_remove_garbage_collected(omx_base_component_Private);
154  }
155  err = tsem_init(omx_base_component_Private->bStateSem, 0);
156  if (err != 0) {
157  base_constructor_remove_garbage_collected(omx_base_component_Private);
159  }
160  }
161 
162  openmaxStandComp->nSize = sizeof(OMX_COMPONENTTYPE);
163  openmaxStandComp->pApplicationPrivate = NULL;
165  openmaxStandComp->SendCommand = omx_base_component_SendCommand;
166  openmaxStandComp->GetParameter = omx_base_component_GetParameter;
167  openmaxStandComp->SetParameter = omx_base_component_SetParameter;
168  openmaxStandComp->GetConfig = omx_base_component_GetConfig;
169  openmaxStandComp->SetConfig = omx_base_component_SetConfig;
171  openmaxStandComp->GetState = omx_base_component_GetState;
172  openmaxStandComp->SetCallbacks = omx_base_component_SetCallbacks;
176 
177  /*Will make Specific port Allocate buffer call*/
179  openmaxStandComp->UseBuffer = omx_base_component_UseBuffer;
180  openmaxStandComp->UseEGLImage = omx_base_component_UseEGLImage;
181  openmaxStandComp->FreeBuffer = omx_base_component_FreeBuffer;
184 
185  openmaxStandComp->nVersion.s.nVersionMajor = SPECVERSIONMAJOR;
186  openmaxStandComp->nVersion.s.nVersionMinor = SPECVERSIONMINOR;
187  openmaxStandComp->nVersion.s.nRevision = SPECREVISION;
188  openmaxStandComp->nVersion.s.nStep = SPECSTEP;
189 
190  omx_base_component_Private->name = calloc(1,OMX_MAX_STRINGNAME_SIZE);
191  if (!omx_base_component_Private->name) {
192  base_constructor_remove_garbage_collected(omx_base_component_Private);
194  }
195  strcpy(omx_base_component_Private->name,cComponentName);
196  omx_base_component_Private->state = OMX_StateLoaded;
197  omx_base_component_Private->transientState = OMX_TransStateMax;
198  omx_base_component_Private->callbacks = NULL;
199  omx_base_component_Private->callbackData = NULL;
200  omx_base_component_Private->nGroupPriority = 100;
201  omx_base_component_Private->nGroupID = 0;
202  omx_base_component_Private->pMark.hMarkTargetComponent = NULL;
203  omx_base_component_Private->pMark.pMarkData = NULL;
204  omx_base_component_Private->openmaxStandComp = openmaxStandComp;
205  omx_base_component_Private->DoStateSet = &omx_base_component_DoStateSet;
206  omx_base_component_Private->messageHandler = omx_base_component_MessageHandler;
207  omx_base_component_Private->destructor = omx_base_component_Destructor;
208  omx_base_component_Private->getQualityLevel = omx_base_getQualityLevel;
209  omx_base_component_Private->setQualityLevel = omx_base_setQualityLevel;
210  omx_base_component_Private->currentQualityLevel = 0;
211  omx_base_component_Private->nqualitylevels = 0;
212  omx_base_component_Private->bufferMgmtThreadID = -1;
213  omx_base_component_Private->bellagioThreads = calloc(1, sizeof(OMX_PARAM_BELLAGIOTHREADS_ID));
214  if (omx_base_component_Private->bellagioThreads == NULL) {
215  base_constructor_remove_garbage_collected(omx_base_component_Private);
217  }
218  omx_base_component_Private->bellagioThreads->nThreadBufferMngtID = 0;
219  omx_base_component_Private->bellagioThreads->nThreadMessageID = 0;
220  omx_base_component_Private->bIsEOSReached = OMX_FALSE;
221 
222  pthread_mutex_init(&omx_base_component_Private->flush_mutex, NULL);
223 
224  if(!omx_base_component_Private->flush_all_condition) {
225  omx_base_component_Private->flush_all_condition = calloc(1,sizeof(tsem_t));
226  if(!omx_base_component_Private->flush_all_condition) {
227  base_constructor_remove_garbage_collected(omx_base_component_Private);
229  }
230  err = tsem_init(omx_base_component_Private->flush_all_condition, 0);
231  if (err != 0) {
232  base_constructor_remove_garbage_collected(omx_base_component_Private);
234  }
235  }
236 
237  if(!omx_base_component_Private->flush_condition) {
238  omx_base_component_Private->flush_condition = calloc(1,sizeof(tsem_t));
239  if(!omx_base_component_Private->flush_condition) {
240  base_constructor_remove_garbage_collected(omx_base_component_Private);
242  }
243  err = tsem_init(omx_base_component_Private->flush_condition, 0);
244  if (err != 0) {
245  base_constructor_remove_garbage_collected(omx_base_component_Private);
247  }
248  }
249 
250  for(i=0;i<NUM_DOMAINS;i++) {
251  memset(&omx_base_component_Private->sPortTypesParam[i], 0, sizeof(OMX_PORT_PARAM_TYPE));
252  setHeader(&omx_base_component_Private->sPortTypesParam[i], sizeof(OMX_PORT_PARAM_TYPE));
253  }
254 
255  err = pthread_create(&omx_base_component_Private->messageHandlerThread, NULL, compMessageHandlerFunction, openmaxStandComp);
256  if (err) {
257  base_constructor_remove_garbage_collected(omx_base_component_Private);
259  }
260  DEBUG(DEB_LEV_FUNCTION_NAME,"Out of %s for component %p\n", __func__, openmaxStandComp);
261  return OMX_ErrorNone;
262 }
263 
272  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)openmaxStandComp->pComponentPrivate;
273  int err;
274  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, openmaxStandComp);
275  omx_base_component_Private->state = OMX_StateInvalid;
276  omx_base_component_Private->callbacks=NULL;
277 
278  /*Send Dummy signal to Component Message handler to exit*/
279  tsem_up(omx_base_component_Private->messageSem);
280 
281  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s before pthread_detach\n", __func__);
282  err = pthread_detach(omx_base_component_Private->messageHandlerThread);
283  if(err!=0) {
284  DEBUG(DEB_LEV_FUNCTION_NAME,"In %s pthread_detach returned err=%d\n", __func__, err);
285  }
286  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s after pthread_detach\n", __func__);
287  /*Deinitialize and free message queue*/
288  if(omx_base_component_Private->messageQueue) {
289  queue_deinit(omx_base_component_Private->messageQueue);
290  free(omx_base_component_Private->messageQueue);
291  omx_base_component_Private->messageQueue=NULL;
292  }
293 
294 
295  /*Deinitialize and free buffer management semaphore*/
296  if(omx_base_component_Private->bMgmtSem){
297  tsem_deinit(omx_base_component_Private->bMgmtSem);
298  free(omx_base_component_Private->bMgmtSem);
299  omx_base_component_Private->bMgmtSem=NULL;
300  }
301 
302  /*Deinitialize and free message semaphore*/
303  if(omx_base_component_Private->messageSem) {
304  tsem_deinit(omx_base_component_Private->messageSem);
305  free(omx_base_component_Private->messageSem);
306  omx_base_component_Private->messageSem=NULL;
307  }
308 
309  if(omx_base_component_Private->bStateSem){
310  tsem_deinit(omx_base_component_Private->bStateSem);
311  free(omx_base_component_Private->bStateSem);
312  omx_base_component_Private->bStateSem=NULL;
313  }
314 
315  if(omx_base_component_Private->name){
316  free(omx_base_component_Private->name);
317  omx_base_component_Private->name=NULL;
318  }
319 
320  pthread_mutex_destroy(&omx_base_component_Private->flush_mutex);
321 
322  if(omx_base_component_Private->flush_all_condition){
323  tsem_deinit(omx_base_component_Private->flush_all_condition);
324  free(omx_base_component_Private->flush_all_condition);
325  omx_base_component_Private->flush_all_condition=NULL;
326  }
327 
328  if(omx_base_component_Private->flush_condition){
329  tsem_deinit(omx_base_component_Private->flush_condition);
330  free(omx_base_component_Private->flush_condition);
331  omx_base_component_Private->flush_condition=NULL;
332  }
333 
334  DEBUG(DEB_LEV_FUNCTION_NAME,"Out of %s for component %p\n", __func__, openmaxStandComp);
335  return OMX_ErrorNone;
336 }
337 
347  OMX_HANDLETYPE hComponent) {
348  OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)hComponent;
349  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)openmaxStandComp->pComponentPrivate;
350  DEBUG(DEB_LEV_FUNCTION_NAME,"In %s for component %p\n", __func__, openmaxStandComp);
351 
352  omx_base_component_Private->destructor(openmaxStandComp);
353 
354  free(openmaxStandComp->pComponentPrivate);
355  openmaxStandComp->pComponentPrivate=NULL;
356  DEBUG(DEB_LEV_FUNCTION_NAME,"Out of %s for component %p\n", __func__, openmaxStandComp);
357  return OMX_ErrorNone;
358 }
359 
371  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)openmaxStandComp->pComponentPrivate;
372  omx_base_PortType *pPort;
373  OMX_U32 i,j,k;
375  OMX_BOOL bExit = OMX_FALSE;
376 
377  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, openmaxStandComp);
378  DEBUG(DEB_LEV_PARAMS, "Changing state from %i to %i\n", omx_base_component_Private->state, (int)destinationState);
379 
380  if (omx_base_component_Private->state == OMX_StateLoaded && destinationState == OMX_StateIdle) {
381  err = RM_getResource(openmaxStandComp);
382  if (err != OMX_ErrorNone) {
384  }
385  }
386  if (omx_base_component_Private->state == OMX_StateIdle && destinationState == OMX_StateLoaded) {
387  RM_releaseResource(openmaxStandComp);
388  }
389 
390  if(destinationState == OMX_StateLoaded){
391  switch(omx_base_component_Private->state){
392  case OMX_StateInvalid:
394  break;
396  /* return back from wait for resources */
397  RM_removeFromWaitForResource(openmaxStandComp);
398  omx_base_component_Private->state = OMX_StateLoaded;
399  break;
400  case OMX_StateLoaded:
402  break;
403  case OMX_StateIdle:
404  /* for all ports */
405  for(j = 0; j < NUM_DOMAINS; j++) {
406  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
407  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
408  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
409 
410  pPort = omx_base_component_Private->ports[i];
411  if (PORT_IS_TUNNELED(pPort) && PORT_IS_BUFFER_SUPPLIER(pPort)) {
412  while(pPort->pBufferQueue->nelem > 0) {
413  DEBUG(DEB_LEV_PARAMS, "In %s Buffer %d remained in the port %d queue of comp%s\n",
414  __func__,(int)pPort->pBufferQueue->nelem,(int)i,omx_base_component_Private->name);
415  dequeue(pPort->pBufferQueue);
416  }
417  /* Freeing here the buffers allocated for the tunneling:*/
418  err = pPort->Port_FreeTunnelBuffer(pPort,i);
419  if(err!=OMX_ErrorNone) {
420  DEBUG(DEB_LEV_ERR, "In %s Freeing Tunnel Buffer Error=%x\n",__func__,err);
421  return err;
422  }
423  } else {
424  DEBUG(DEB_LEV_FULL_SEQ, "In %s nPortIndex=%d pAllocSem Semval=%x\n", __func__,(int)i,(int)pPort->pAllocSem->semval);
425 
426  /*If ports are enabled then wait till all buffers are freed*/
427  if(PORT_IS_ENABLED(pPort)) {
428  tsem_down(pPort->pAllocSem);
429  }
430  }
431  pPort->sPortParam.bPopulated = OMX_FALSE;
432 
433  if(pPort->pInternalBufferStorage != NULL) {
434  free(pPort->pInternalBufferStorage);
435  pPort->pInternalBufferStorage=NULL;
436  }
437 
438  if(pPort->bBufferStateAllocated != NULL) {
439  free(pPort->bBufferStateAllocated);
440  pPort->bBufferStateAllocated=NULL;
441  }
442  }
443  }
444  omx_base_component_Private->state = OMX_StateLoaded;
445 
446  if(omx_base_component_Private->bufferMgmtThreadID == 0 ){
447  /*Signal Buffer Management thread to exit*/
448  tsem_up(omx_base_component_Private->bMgmtSem);
449  pthread_join(omx_base_component_Private->bufferMgmtThread, NULL);
450  omx_base_component_Private->bufferMgmtThreadID = -1;
451  if(err != 0) {
452  DEBUG(DEB_LEV_ERR,"In %s pthread_join returned err=%d\n",__func__,err);
453  }
454  }
455 
456  break;
457  default:
458  DEBUG(DEB_LEV_ERR, "In %s: state transition not allowed\n", __func__);
460  break;
461  }
462  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p with err %i\n", __func__, openmaxStandComp, err);
463  return err;
464  }
465 
466  if(destinationState == OMX_StateWaitForResources){
467  switch(omx_base_component_Private->state){
468  case OMX_StateInvalid:
470  break;
471  case OMX_StateLoaded:
472  omx_base_component_Private->state = OMX_StateWaitForResources;
473  err = RM_waitForResource(openmaxStandComp);
474  break;
477  break;
478  default:
479  DEBUG(DEB_LEV_ERR, "In %s: state transition not allowed\n", __func__);
481  break;
482  }
483  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p with err %i\n", __func__, openmaxStandComp, err);
484  return err;
485  }
486 
487  if(destinationState == OMX_StateIdle){
488  switch(omx_base_component_Private->state){
489  case OMX_StateInvalid:
491  break;
493  omx_base_component_Private->state = OMX_StateIdle;
494  break;
495  case OMX_StateLoaded:
496  /* for all ports */
497  for(j = 0; j < NUM_DOMAINS; j++) {
498  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
499  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
500  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
501  pPort = omx_base_component_Private->ports[i];
502  if (PORT_IS_TUNNELED(pPort) && PORT_IS_BUFFER_SUPPLIER(pPort)) {
503  if(PORT_IS_ENABLED(pPort)) {
505  err= pPort->Port_AllocateTunnelBuffer(pPort, i);
506  if(err!=OMX_ErrorNone) {
507  DEBUG(DEB_LEV_ERR, "In %s Allocating Tunnel Buffer Error=%x\n",__func__,err);
508  return err;
509  }
510  }
511  } else {
512  if(PORT_IS_ENABLED(pPort)) {
513  DEBUG(DEB_LEV_FULL_SEQ, "In %s: wait for buffers. port enabled %i, port populated %i\n",
514  __func__, pPort->sPortParam.bEnabled,pPort->sPortParam.bPopulated);
515  if (pPort->sPortParam.nBufferCountActual > 0) {
516  tsem_down(pPort->pAllocSem);
517  pthread_mutex_lock(&pPort->exitMutex);
518  if (pPort->bIsDestroying) {
519  bExit = OMX_TRUE;
520  pthread_mutex_unlock(&pPort->exitMutex);
521  continue;
522  }
523  pthread_mutex_unlock(&pPort->exitMutex);
524  }
525  pPort->sPortParam.bPopulated = OMX_TRUE;
526  }
527  else {
528  DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s: Port %i Disabled So no wait\n",__func__,(int)i);
529  }
530  }
531  DEBUG(DEB_LEV_SIMPLE_SEQ, "Tunnel status : port %d flags 0x%x\n",(int)i, (int)pPort->nTunnelFlags);
532  }
533  }
534  if (bExit) {
535  break;
536  }
537  omx_base_component_Private->state = OMX_StateIdle;
539  omx_base_component_Private->bufferMgmtThreadID = pthread_create(&omx_base_component_Private->bufferMgmtThread,
540  NULL,
541  omx_base_component_Private->BufferMgmtFunction,
542  openmaxStandComp);
543  if(omx_base_component_Private->bufferMgmtThreadID < 0){
544  DEBUG(DEB_LEV_ERR, "Starting buffer management thread failed\n");
545  return OMX_ErrorUndefined;
546  }
547  break;
548  case OMX_StateIdle:
550  break;
551  case OMX_StateExecuting:
552  /*Flush Ports*/
553  /* for all ports */
554  for(j = 0; j < NUM_DOMAINS; j++) {
555  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
556  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
557  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
558  DEBUG(DEB_LEV_FULL_SEQ, "Flushing Port %i\n",(int)i);
559  pPort = omx_base_component_Private->ports[i];
560  if(PORT_IS_ENABLED(pPort)) {
561  pPort->FlushProcessingBuffers(pPort);
562  }
563  }
564  }
565  omx_base_component_Private->state = OMX_StateIdle;
566  break;
567  case OMX_StatePause:
568  /*Flush Ports*/
569  /* for all ports */
570  for(j = 0; j < NUM_DOMAINS; j++) {
571  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
572  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
573  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
574  DEBUG(DEB_LEV_FULL_SEQ, "Flushing Port %i\n",(int)i);
575  pPort = omx_base_component_Private->ports[i];
576  if(PORT_IS_ENABLED(pPort)) {
577  pPort->FlushProcessingBuffers(pPort);
578  }
579  }
580  }
581  omx_base_component_Private->state = OMX_StateIdle;
582  /*Signal buffer management thread if waiting at paused state*/
583  tsem_signal(omx_base_component_Private->bStateSem);
584  break;
585  default:
586  DEBUG(DEB_LEV_ERR, "In %s: state transition not allowed\n", __func__);
588  break;
589  }
590  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p with err %i\n", __func__, openmaxStandComp, err);
591  return err;
592  }
593 
594  if(destinationState == OMX_StatePause) {
595  switch(omx_base_component_Private->state) {
596  case OMX_StateInvalid:
598  break;
599  case OMX_StatePause:
601  break;
602  case OMX_StateIdle:
603  omx_base_component_Private->bIsEOSReached = OMX_FALSE;
604  case OMX_StateExecuting:
605  omx_base_component_Private->state = OMX_StatePause;
606  break;
607  default:
608  DEBUG(DEB_LEV_ERR, "In %s: state transition not allowed\n", __func__);
610  break;
611  }
612  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p with err %i\n", __func__, openmaxStandComp, err);
613  return err;
614  }
615 
616  if(destinationState == OMX_StateExecuting) {
617  switch(omx_base_component_Private->state) {
618  case OMX_StateInvalid:
620  break;
621  case OMX_StateIdle:
622  omx_base_component_Private->state = OMX_StateExecuting;
623  omx_base_component_Private->bIsEOSReached = OMX_FALSE;
624  /*Send Tunneled Buffer to the Neighbouring Components*/
625  /* for all ports */
626  for(j = 0; j < NUM_DOMAINS; j++) {
627  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
628  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
629  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
630  pPort = omx_base_component_Private->ports[i];
631  if (PORT_IS_TUNNELED(pPort) && PORT_IS_BUFFER_SUPPLIER(pPort) && PORT_IS_ENABLED(pPort)) {
632  for(k=0;k<pPort->nNumTunnelBuffer;k++) {
633  tsem_up(pPort->pBufferSem);
634  /*signal buffer management thread availability of buffers*/
635  tsem_up(omx_base_component_Private->bMgmtSem);
636  }
637  }
638  }
639  }
640  omx_base_component_Private->transientState = OMX_TransStateMax;
641  err = OMX_ErrorNone;
642  break;
643  case OMX_StatePause:
644  omx_base_component_Private->state=OMX_StateExecuting;
645 
646  /* Tunneled Supplier Ports were enabled in paused state. So signal buffer managment thread*/
647  /* for all ports */
648  for(j = 0; j < NUM_DOMAINS; j++) {
649  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
650  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
651  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
652 
653  pPort=omx_base_component_Private->ports[i];
654  DEBUG(DEB_LEV_PARAMS, "In %s: state transition Paused 2 Executing, nelem=%d,semval=%d,Buf Count Actual=%d\n", __func__,
655  pPort->pBufferQueue->nelem,pPort->pBufferSem->semval,(int)pPort->sPortParam.nBufferCountActual);
656 
658  (pPort->pBufferQueue->nelem == (pPort->pBufferSem->semval + pPort->sPortParam.nBufferCountActual))) {
659  for(k=0; k < pPort->sPortParam.nBufferCountActual;k++) {
660  tsem_up(pPort->pBufferSem);
661  tsem_up(omx_base_component_Private->bMgmtSem);
662  }
663  }
664  }
665  }
666  /*Signal buffer management thread if waiting at paused state*/
667  tsem_signal(omx_base_component_Private->bStateSem);
668  break;
669  case OMX_StateExecuting:
671  break;
672  default:
673  DEBUG(DEB_LEV_ERR, "In %s: state transition not allowed\n", __func__);
675  break;
676  }
677  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p with err %i\n", __func__, openmaxStandComp, err);
678  return err;
679  }
680 
681  if(destinationState == OMX_StateInvalid) {
682  switch(omx_base_component_Private->state) {
683  case OMX_StateInvalid:
685  break;
686  default:
687  omx_base_component_Private->state = OMX_StateInvalid;
688 
689  if(omx_base_component_Private->bufferMgmtThreadID == 0 ){
690  tsem_signal(omx_base_component_Private->bStateSem);
691  /*Signal Buffer Management Thread to Exit*/
692  tsem_up(omx_base_component_Private->bMgmtSem);
693  pthread_join(omx_base_component_Private->bufferMgmtThread, NULL);
694  omx_base_component_Private->bufferMgmtThreadID = -1;
695  if(err!=0) {
696  DEBUG(DEB_LEV_FUNCTION_NAME,"In %s pthread_join returned err=%d\n",__func__,err);
697  }
698  }
700  break;
701  }
702  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p with err %i\n", __func__, openmaxStandComp, err);
703  return err;
704  }
705  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, openmaxStandComp);
706  return OMX_ErrorNone;
707 }
708 
721  OMX_VERSIONTYPE* ver;
722  if (header == NULL) {
723  DEBUG(DEB_LEV_ERR, "In %s the header is null\n",__func__);
724  return OMX_ErrorBadParameter;
725  }
726  ver = (OMX_VERSIONTYPE*)((char*)header + sizeof(OMX_U32));
727  if(*((OMX_U32*)header) != size) {
728  DEBUG(DEB_LEV_ERR, "In %s the header has a wrong size %i should be %i\n",__func__,(int)*((OMX_U32*)header),(int)size);
729  return OMX_ErrorBadParameter;
730  }
731  if(ver->s.nVersionMajor != SPECVERSIONMAJOR ||
732  ver->s.nVersionMinor != SPECVERSIONMINOR) {
733  DEBUG(DEB_LEV_ERR, "The version does not match\n");
735  }
736  return OMX_ErrorNone;
737 }
738 
746 void setHeader(OMX_PTR header, OMX_U32 size) {
747  OMX_VERSIONTYPE* ver = (OMX_VERSIONTYPE*)((char*)header + sizeof(OMX_U32));
748  *((OMX_U32*)header) = size;
749 
752  ver->s.nRevision = SPECREVISION;
753  ver->s.nStep = SPECSTEP;
754 }
755 
760  OMX_U32 nPortIndex,
761  OMX_PTR pStructure,
762  size_t size) {
763  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)(((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate);
764  omx_base_PortType *pPort;
765  int nNumPorts;
767 
768  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
769  nNumPorts = omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
770  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
771  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
772  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts;
773 
774  if (nPortIndex >= nNumPorts) {
775  DEBUG(DEB_LEV_ERR, "Bad Port index %i when the component has %i ports\n", (int)nPortIndex, (int)nNumPorts);
776  return OMX_ErrorBadPortIndex;
777  }
778 
779  pPort = omx_base_component_Private->ports[nPortIndex];
780 
781  if (omx_base_component_Private->state != OMX_StateLoaded && omx_base_component_Private->state != OMX_StateWaitForResources) {
782  if(PORT_IS_ENABLED(pPort) && !pPort->bIsTransientToEnabled) {
783  DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x lineno=%d\n",__func__,omx_base_component_Private->state,__LINE__);
785  }
786  }
787 
788  err = checkHeader(pStructure, size);
789  if (err != OMX_ErrorNone) {
790  DEBUG(DEB_LEV_ERR, "In %s failing the checkHeader with err %i\n", __func__, (int)err);
791  return err;
792  }
793  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
794  return OMX_ErrorNone;
795 }
796 
802  OMX_STRING pComponentName,
803  OMX_VERSIONTYPE* pComponentVersion,
804  OMX_VERSIONTYPE* pSpecVersion,
805  OMX_UUIDTYPE* pComponentUUID) {
806 
807  OMX_COMPONENTTYPE* omx_component = (OMX_COMPONENTTYPE*)hComponent;
808  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omx_component->pComponentPrivate;
809 
810  OMX_U32 uuid[3];
811 
812  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
813  /* Fill component name */
814  strcpy(pComponentName, omx_base_component_Private->name);
815 
816  /* Fill component version */
817  pComponentVersion->s.nVersionMajor = SPECVERSIONMAJOR;
818  pComponentVersion->s.nVersionMinor = SPECVERSIONMINOR;
819  pComponentVersion->s.nRevision = SPECREVISION;
820  pComponentVersion->s.nStep = SPECSTEP;
821 
822  /* Fill spec version (copy from component field) */
823  memcpy(pSpecVersion, &omx_component->nVersion, sizeof(OMX_VERSIONTYPE));
824 
825  /* Fill UUID with handle address, PID and UID.
826  * This should guarantee uiniqness */
827  uuid[0] = (OMX_U32)omx_component;
828  uuid[1] = getpid();
829  uuid[2] = getuid();
830  memcpy(*pComponentUUID, uuid, sizeof(uuid));
831 
832  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
833  return OMX_ErrorNone;
834 }
835 
845  OMX_HANDLETYPE hComponent,
846  OMX_U8 *cRole,
847  OMX_U32 nIndex) {
848  strcat((char*)cRole, "\0");
849  return OMX_ErrorNoMore;
850 }
851 
858  OMX_HANDLETYPE hComponent,
859  OMX_CALLBACKTYPE* pCallbacks,
860  OMX_PTR pAppData) {
861 
862  OMX_COMPONENTTYPE *omxcomponent = (OMX_COMPONENTTYPE*)hComponent;
863  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omxcomponent->pComponentPrivate;
864  omx_base_PortType *pPort;
865  OMX_U32 i,j;
866 
867  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
868  omx_base_component_Private->callbacks = pCallbacks;
869  omx_base_component_Private->callbackData = pAppData;
870 
871  /* for all ports */
872  for(j = 0; j < NUM_DOMAINS; j++) {
873  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
874  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
875  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
876  pPort = omx_base_component_Private->ports[i];
877  if (pPort->sPortParam.eDir == OMX_DirInput) {
878  pPort->BufferProcessedCallback = omx_base_component_Private->callbacks->EmptyBufferDone;
879  } else {
880  pPort->BufferProcessedCallback = omx_base_component_Private->callbacks->FillBufferDone;
881  }
882  }
883  }
884  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
885  return OMX_ErrorNone;
886 }
887 
897  OMX_HANDLETYPE hComponent,
898  OMX_INDEXTYPE nParamIndex,
899  OMX_PTR ComponentParameterStructure) {
900 
901  OMX_COMPONENTTYPE *omxcomponent = (OMX_COMPONENTTYPE*)hComponent;
902  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omxcomponent->pComponentPrivate;
903  OMX_PRIORITYMGMTTYPE* pPrioMgmt;
905  OMX_PARAM_BUFFERSUPPLIERTYPE *pBufferSupplier;
906  omx_base_PortType *pPort;
907  OMX_PORT_PARAM_TYPE* pPortDomains;
909  OMX_VENDOR_PROP_TUNNELSETUPTYPE *pPropTunnelSetup;
911 
912  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
913  DEBUG(DEB_LEV_PARAMS, "Getting parameter %i\n", nParamIndex);
914  if (ComponentParameterStructure == NULL) {
915  return OMX_ErrorBadParameter;
916  }
917  switch((int) nParamIndex) {
919  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_BELLAGIOTHREADS_ID))) != OMX_ErrorNone) {
920  break;
921  }
922  threadID = (OMX_PARAM_BELLAGIOTHREADS_ID *)ComponentParameterStructure;
923  threadID->nThreadBufferMngtID = omx_base_component_Private->bellagioThreads->nThreadBufferMngtID;
924  threadID->nThreadMessageID = omx_base_component_Private->bellagioThreads->nThreadMessageID;
925  break;
930  pPortDomains = (OMX_PORT_PARAM_TYPE*)ComponentParameterStructure;
931  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) {
932  break;
933  }
934  pPortDomains->nPorts = 0;
935  pPortDomains->nStartPortNumber = 0;
936  break;
938  pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
939  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_PORTDEFINITIONTYPE))) != OMX_ErrorNone) {
940  break;
941  }
942  if (pPortDef->nPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
943  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
944  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
945  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
946  return OMX_ErrorBadPortIndex;
947  }
948 
949  memcpy(pPortDef, &omx_base_component_Private->ports[pPortDef->nPortIndex]->sPortParam, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
950  break;
952  pPrioMgmt = (OMX_PRIORITYMGMTTYPE*)ComponentParameterStructure;
953  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone) {
954  break;
955  }
956  pPrioMgmt->nGroupPriority = omx_base_component_Private->nGroupPriority;
957  pPrioMgmt->nGroupID = omx_base_component_Private->nGroupID;
958  break;
960  pBufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE*)ComponentParameterStructure;
961  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE))) != OMX_ErrorNone) {
962  break;
963  }
964  if (pBufferSupplier->nPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
965  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
966  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
967  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
968  return OMX_ErrorBadPortIndex;
969  }
970 
971  pPort = omx_base_component_Private->ports[pBufferSupplier->nPortIndex];
972 
973  if (pPort->sPortParam.eDir == OMX_DirInput) {
974  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
975  pBufferSupplier->eBufferSupplier = OMX_BufferSupplyInput;
976  } else if (PORT_IS_TUNNELED(pPort)) {
977  pBufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput;
978  } else {
979  pBufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified;
980  }
981  } else {
982  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
983  pBufferSupplier->eBufferSupplier = OMX_BufferSupplyOutput;
984  } else if (PORT_IS_TUNNELED(pPort)) {
985  pBufferSupplier->eBufferSupplier = OMX_BufferSupplyInput;
986  } else {
987  pBufferSupplier->eBufferSupplier = OMX_BufferSupplyUnspecified;
988  }
989  }
990  break;
992  pPropTunnelSetup = (OMX_VENDOR_PROP_TUNNELSETUPTYPE*)ComponentParameterStructure;
993 
994  if (pPropTunnelSetup->nPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
995  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
996  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
997  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
998 
999  DEBUG(DEB_LEV_ERR,"In %s OMX_IndexVendorCompPropTunnelFlags nPortIndex=%d Line=%d \n",
1000  __func__,(int)pPropTunnelSetup->nPortIndex,__LINE__);
1001 
1002  return OMX_ErrorBadPortIndex;
1003  }
1004 
1005  pPort = omx_base_component_Private->ports[pPropTunnelSetup->nPortIndex];
1006 
1007  pPropTunnelSetup->nTunnelSetup.nTunnelFlags = pPort->nTunnelFlags;
1008  pPropTunnelSetup->nTunnelSetup.eSupplier = pPort->eBufferSupplier;
1009  break;
1010  default:
1012  break;
1013  }
1014  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1015  return err;
1016 }
1017 
1027  OMX_HANDLETYPE hComponent,
1028  OMX_INDEXTYPE nParamIndex,
1029  OMX_PTR ComponentParameterStructure) {
1030 
1031  OMX_PRIORITYMGMTTYPE* pPrioMgmt;
1032  OMX_PARAM_PORTDEFINITIONTYPE *pPortDef;
1034  OMX_COMPONENTTYPE *omxcomponent = (OMX_COMPONENTTYPE*)hComponent;
1035  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omxcomponent->pComponentPrivate;
1036  OMX_PARAM_BUFFERSUPPLIERTYPE *pBufferSupplier;
1037  omx_base_PortType *pPort;
1038 
1039  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1040  DEBUG(DEB_LEV_PARAMS, "Setting parameter %x\n", nParamIndex);
1041  if (ComponentParameterStructure == NULL) {
1042  DEBUG(DEB_LEV_ERR, "In %s parameter provided is null! err = %x\n", __func__, err);
1043  return OMX_ErrorBadParameter;
1044  }
1045 
1046  switch(nParamIndex) {
1051  /* pPortParam = (OMX_PORT_PARAM_TYPE* ) ComponentParameterStructure;*/
1052  if (omx_base_component_Private->state != OMX_StateLoaded &&
1053  omx_base_component_Private->state != OMX_StateWaitForResources) {
1055  }
1056  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PORT_PARAM_TYPE))) != OMX_ErrorNone) {
1057  break;
1058  }
1060  break;
1062  pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE*) ComponentParameterStructure;
1063  err = omx_base_component_ParameterSanityCheck(hComponent, pPortDef->nPortIndex, pPortDef, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
1064  if(err!=OMX_ErrorNone) {
1065  DEBUG(DEB_LEV_ERR, "In %s Parameter Check Error=%x\n",__func__,err);
1066  break;
1067  }
1068  {
1069  OMX_PARAM_PORTDEFINITIONTYPE *pPortParam;
1070  OMX_U32 j,old_nBufferCountActual=0;
1071  pPortParam = &omx_base_component_Private->ports[pPortDef->nPortIndex]->sPortParam;
1072  if(pPortDef->nBufferCountActual < pPortParam->nBufferCountMin) {
1073  DEBUG(DEB_LEV_ERR, "In %s nBufferCountActual of param (%i) is < of nBufferCountMin of port(%i)\n",__func__, (int)pPortDef->nBufferCountActual, (int)pPortParam->nBufferCountMin);
1075  break;
1076  }
1077  old_nBufferCountActual = pPortParam->nBufferCountActual;
1078  pPortParam->nBufferCountActual = pPortDef->nBufferCountActual;
1079 
1080  switch(pPortDef->eDomain) {
1081  case OMX_PortDomainAudio:
1082  memcpy(&pPortParam->format.audio, &pPortDef->format.audio, sizeof(OMX_AUDIO_PORTDEFINITIONTYPE));
1083  break;
1084  case OMX_PortDomainVideo:
1085  pPortParam->format.video.pNativeRender = pPortDef->format.video.pNativeRender;
1086  pPortParam->format.video.nFrameWidth = pPortDef->format.video.nFrameWidth;
1087  pPortParam->format.video.nFrameHeight = pPortDef->format.video.nFrameHeight;
1088  pPortParam->format.video.nStride = pPortDef->format.video.nStride;
1089  pPortParam->format.video.xFramerate = pPortDef->format.video.xFramerate;
1092  pPortParam->format.video.eColorFormat = pPortDef->format.video.eColorFormat;
1093  pPortParam->format.video.pNativeWindow = pPortDef->format.video.pNativeWindow;
1094  break;
1095  case OMX_PortDomainImage:
1096  pPortParam->format.image.nFrameWidth = pPortDef->format.image.nFrameWidth;
1097  pPortParam->format.image.nFrameHeight = pPortDef->format.image.nFrameHeight;
1098  pPortParam->format.image.nStride = pPortDef->format.image.nStride;
1101  pPortParam->format.image.eColorFormat = pPortDef->format.image.eColorFormat;
1102  pPortParam->format.image.pNativeWindow = pPortDef->format.image.pNativeWindow;
1103  break;
1104  case OMX_PortDomainOther:
1105  memcpy(&pPortParam->format.other, &pPortDef->format.other, sizeof(OMX_OTHER_PORTDEFINITIONTYPE));
1106  break;
1107  default:
1108  DEBUG(DEB_LEV_ERR, "In %s wrong port domain. Out of OpenMAX scope\n",__func__);
1110  break;
1111  }
1112 
1113  /*If component state Idle/Pause/Executing and re-alloc the following private variables */
1114  if ((omx_base_component_Private->state == OMX_StateIdle ||
1115  omx_base_component_Private->state == OMX_StatePause ||
1116  omx_base_component_Private->state == OMX_StateExecuting) &&
1117  (pPortParam->nBufferCountActual > old_nBufferCountActual)) {
1118 // todo check if here it is not better != instead of >
1119  pPort = omx_base_component_Private->ports[pPortDef->nPortIndex];
1120  if(pPort->pInternalBufferStorage) {
1121  pPort->pInternalBufferStorage = realloc(pPort->pInternalBufferStorage,pPort->sPortParam.nBufferCountActual*sizeof(OMX_BUFFERHEADERTYPE *));
1122  }
1123 
1124  if(pPort->bBufferStateAllocated) {
1125  pPort->bBufferStateAllocated = realloc(pPort->bBufferStateAllocated,pPort->sPortParam.nBufferCountActual*sizeof(BUFFER_STATUS_FLAG));
1126  for(j=0; j < pPort->sPortParam.nBufferCountActual; j++) {
1127  pPort->bBufferStateAllocated[j] = BUFFER_FREE;
1128  }
1129  }
1130  }
1131  }
1132  break;
1134  if (omx_base_component_Private->state != OMX_StateLoaded &&
1135  omx_base_component_Private->state != OMX_StateWaitForResources) {
1137  }
1138  pPrioMgmt = (OMX_PRIORITYMGMTTYPE*)ComponentParameterStructure;
1139  if ((err = checkHeader(ComponentParameterStructure, sizeof(OMX_PRIORITYMGMTTYPE))) != OMX_ErrorNone) {
1140  break;
1141  }
1142  omx_base_component_Private->nGroupPriority = pPrioMgmt->nGroupPriority;
1143  omx_base_component_Private->nGroupID = pPrioMgmt->nGroupID;
1144  break;
1146  pBufferSupplier = (OMX_PARAM_BUFFERSUPPLIERTYPE*)ComponentParameterStructure;
1147 
1148  DEBUG(DEB_LEV_PARAMS, "In %s Buf Sup Port index=%d\n", __func__,(int)pBufferSupplier->nPortIndex);
1149 
1150  if(pBufferSupplier == NULL) {
1151  DEBUG(DEB_LEV_ERR, "In %s pBufferSupplier is null!\n",__func__);
1152  return OMX_ErrorBadParameter;
1153  }
1154  if(pBufferSupplier->nPortIndex > (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1155  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1156  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1157  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1158  return OMX_ErrorBadPortIndex;
1159  }
1160  err = omx_base_component_ParameterSanityCheck(hComponent, pBufferSupplier->nPortIndex, pBufferSupplier, sizeof(OMX_PARAM_BUFFERSUPPLIERTYPE));
1162  if (PORT_IS_ENABLED(omx_base_component_Private->ports[pBufferSupplier->nPortIndex])) {
1163  DEBUG(DEB_LEV_ERR, "In %s Incorrect State=%x\n",__func__,omx_base_component_Private->state);
1165  }
1166  } else if (err != OMX_ErrorNone) {
1167  break;
1168  }
1169 
1170  if (pBufferSupplier->eBufferSupplier == OMX_BufferSupplyUnspecified) {
1171  DEBUG(DEB_LEV_PARAMS, "In %s: port is already buffer supplier unspecified\n", __func__);
1172  return OMX_ErrorNone;
1173  }
1174  if ((PORT_IS_TUNNELED(omx_base_component_Private->ports[pBufferSupplier->nPortIndex])) == 0) {
1175  return OMX_ErrorNone;
1176  }
1177 
1178  pPort = omx_base_component_Private->ports[pBufferSupplier->nPortIndex];
1179 
1180  if ((pBufferSupplier->eBufferSupplier == OMX_BufferSupplyInput) &&
1181  (pPort->sPortParam.eDir == OMX_DirInput)) {
1183  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
1184  err = OMX_ErrorNone;
1185  }
1186  pPort->nTunnelFlags |= TUNNEL_IS_SUPPLIER;
1187  pBufferSupplier->nPortIndex = pPort->nTunneledPort;
1188  err = OMX_SetParameter(pPort->hTunneledComponent, OMX_IndexParamCompBufferSupplier, pBufferSupplier);
1189  } else if ((pBufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) &&
1190  (pPort->sPortParam.eDir == OMX_DirInput)) {
1191  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
1192  pPort->nTunnelFlags &= ~TUNNEL_IS_SUPPLIER;
1193  pBufferSupplier->nPortIndex = pPort->nTunneledPort;
1194  err = OMX_SetParameter(pPort->hTunneledComponent, OMX_IndexParamCompBufferSupplier, pBufferSupplier);
1195  }
1196  err = OMX_ErrorNone;
1197  } else if ((pBufferSupplier->eBufferSupplier == OMX_BufferSupplyOutput) &&
1198  (pPort->sPortParam.eDir == OMX_DirOutput)) {
1200  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
1201  err = OMX_ErrorNone;
1202  }
1203  pPort->nTunnelFlags |= TUNNEL_IS_SUPPLIER;
1204  } else {
1205  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
1206  pPort->nTunnelFlags &= ~TUNNEL_IS_SUPPLIER;
1207  err = OMX_ErrorNone;
1208  }
1209  err = OMX_ErrorNone;
1210  }
1211  DEBUG(DEB_LEV_PARAMS, "In %s port %d Tunnel flag=%x \n", __func__,(int)pBufferSupplier->nPortIndex, (int)pPort->nTunnelFlags);
1212  break;
1213  default:
1215  break;
1216  }
1217  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1218  return err;
1219 }
1220 
1229  OMX_HANDLETYPE hComponent,
1230  OMX_INDEXTYPE nIndex,
1231  OMX_PTR pComponentConfigStructure) {
1232  return OMX_ErrorNone;
1233 }
1234 
1243  OMX_HANDLETYPE hComponent,
1244  OMX_INDEXTYPE nIndex,
1245  OMX_PTR pComponentConfigStructure) {
1246  return OMX_ErrorNone;
1247 }
1248 
1255  OMX_HANDLETYPE hComponent,
1256  OMX_STRING cParameterName,
1257  OMX_INDEXTYPE* pIndexType) {
1258 
1259  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1260  if(strcmp(cParameterName,"OMX.st.index.param.BellagioThreadsID") == 0) {
1261  *pIndexType = OMX_IndexParameterThreadsID;
1262  } else {
1263  return OMX_ErrorBadParameter;
1264  }
1265  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1266  return OMX_ErrorNone;
1267 }
1268 
1274  OMX_HANDLETYPE hComponent,
1275  OMX_STATETYPE* pState) {
1276  OMX_COMPONENTTYPE *omxcomponent = (OMX_COMPONENTTYPE*)hComponent;
1277  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omxcomponent->pComponentPrivate;
1278  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1279  *pState = omx_base_component_Private->state;
1280  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1281  return OMX_ErrorNone;
1282 }
1283 
1290  OMX_HANDLETYPE hComponent,
1291  OMX_COMMANDTYPE Cmd,
1292  OMX_U32 nParam,
1293  OMX_PTR pCmdData) {
1294  OMX_COMPONENTTYPE* omxComponent = (OMX_COMPONENTTYPE*)hComponent;
1295  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)omxComponent->pComponentPrivate;
1296  internalRequestMessageType *message;
1297  queue_t* messageQueue;
1298  tsem_t* messageSem;
1299  OMX_U32 i,j,k;
1300  omx_base_PortType *pPort;
1302  int errQue;
1303  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1304 
1305  messageQueue = omx_base_component_Private->messageQueue;
1306  messageSem = omx_base_component_Private->messageSem;
1307 
1308  if (omx_base_component_Private->state == OMX_StateInvalid) {
1309  return OMX_ErrorInvalidState;
1310  }
1311 
1312  message = calloc(1,sizeof(internalRequestMessageType));
1313  message->messageParam = nParam;
1314  message->pCmdData=pCmdData;
1316  switch (Cmd) {
1317  case OMX_CommandStateSet:
1318  message->messageType = OMX_CommandStateSet;
1319  if ((nParam == OMX_StateIdle) && (omx_base_component_Private->state == OMX_StateLoaded)) {
1320  /*Allocate Internal Buffer Storage and Buffer Allocation State flags*/
1321  /* for all ports */
1322  for(j = 0; j < NUM_DOMAINS; j++) {
1323  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1324  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1325  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1326 
1327  pPort = omx_base_component_Private->ports[i];
1328 
1329  if(pPort->pInternalBufferStorage == NULL) {
1330  pPort->pInternalBufferStorage = calloc(pPort->sPortParam.nBufferCountActual,sizeof(OMX_BUFFERHEADERTYPE *));
1331  }
1332 
1333  if(pPort->bBufferStateAllocated == NULL) {
1334  pPort->bBufferStateAllocated = calloc(pPort->sPortParam.nBufferCountActual,sizeof(BUFFER_STATUS_FLAG));
1335  }
1336 
1337  for(k=0; k < pPort->sPortParam.nBufferCountActual; k++) {
1338  pPort->bBufferStateAllocated[k] = BUFFER_FREE;
1339  }
1340  }
1341  }
1342 
1343  omx_base_component_Private->transientState = OMX_TransStateLoadedToIdle;
1344  } else if ((nParam == OMX_StateLoaded) && (omx_base_component_Private->state == OMX_StateIdle)) {
1345  omx_base_component_Private->transientState = OMX_TransStateIdleToLoaded;
1346  } else if ((nParam == OMX_StateIdle) && (omx_base_component_Private->state == OMX_StateExecuting)) {
1347  omx_base_component_Private->transientState = OMX_TransStateExecutingToIdle;
1348  } else if ((nParam == OMX_StateIdle) && (omx_base_component_Private->state == OMX_StatePause)) {
1349  omx_base_component_Private->transientState = OMX_TransStatePauseToIdle;
1350  }
1351  break;
1352  case OMX_CommandFlush:
1353  if (nParam >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1354  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1355  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1356  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) && nParam != OMX_ALL) {
1357  return OMX_ErrorBadPortIndex;
1358  }
1359  message->messageType = OMX_CommandFlush;
1360  break;
1362  if (nParam >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1363  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1364  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1365  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) && nParam != OMX_ALL) {
1366  return OMX_ErrorBadPortIndex;
1367  }
1368  message->messageType = OMX_CommandPortDisable;
1369  if(message->messageParam == OMX_ALL) {
1370  /* for all ports */
1371  for(j = 0; j < NUM_DOMAINS; j++) {
1372  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1373  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1374  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1375  omx_base_component_Private->ports[i]->bIsTransientToDisabled = OMX_TRUE;
1376  }
1377  }
1378  } else {
1379  omx_base_component_Private->ports[message->messageParam]->bIsTransientToDisabled = OMX_TRUE;
1380  }
1381  break;
1382  case OMX_CommandPortEnable:
1383  if (nParam >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1384  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1385  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1386  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) && nParam != OMX_ALL) {
1387  return OMX_ErrorBadPortIndex;
1388  }
1389  message->messageType = OMX_CommandPortEnable;
1390  if(message->messageParam == OMX_ALL) {
1391  /* for all ports */
1392  for(j = 0; j < NUM_DOMAINS; j++) {
1393  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1394  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1395  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1396  omx_base_component_Private->ports[i]->bIsTransientToEnabled = OMX_TRUE;
1397  }
1398  }
1399  } else {
1400  omx_base_component_Private->ports[message->messageParam]->bIsTransientToEnabled = OMX_TRUE;
1401  }
1402  break;
1403  case OMX_CommandMarkBuffer:
1404  if (nParam >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1405  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1406  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1407  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts) && nParam != OMX_ALL) {
1408  return OMX_ErrorBadPortIndex;
1409  }
1410  message->messageType = OMX_CommandMarkBuffer;
1411  break;
1412  default:
1414  break;
1415  }
1416 
1417  if (err == OMX_ErrorNone) {
1418  errQue = queue(messageQueue, message);
1419  if (errQue) {
1420  /* /TODO the queue is full. This can be handled in a fine way with
1421  * some retrials, or other checking. For the moment this is a critical error
1422  * and simply causes the failure of this call
1423  */
1425  }
1426  tsem_up(messageSem);
1427  }
1428  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1429  return err;
1430 }
1431 
1438 void* compMessageHandlerFunction(void* param) {
1439  OMX_COMPONENTTYPE *openmaxStandComp = (OMX_COMPONENTTYPE *)param;
1440  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)openmaxStandComp->pComponentPrivate;
1441  internalRequestMessageType *message;
1442 
1443 #if defined(__linux__)
1444  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, openmaxStandComp);
1445  omx_base_component_Private->bellagioThreads->nThreadMessageID = (long int)syscall(__NR_gettid);
1446  DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s the thread ID is %i\n", __func__, (int)omx_base_component_Private->bellagioThreads->nThreadMessageID);
1447 #endif
1448 
1449  while(1){
1450  /* Wait for an incoming message */
1451  if (omx_base_component_Private == NULL) {
1452  break;
1453  }
1454  tsem_down(omx_base_component_Private->messageSem);
1455  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s new message\n", __func__);
1456  /*Destructor has been called. So exit from the loop*/
1457  if(omx_base_component_Private->state == OMX_StateInvalid) {
1458  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s Destructor has been called. So exit from the loop\n", __func__);
1459  break;
1460  }
1461  /* Dequeue it */
1462  message = dequeue(omx_base_component_Private->messageQueue);
1463  if(message == NULL){
1464  DEBUG(DEB_LEV_ERR, "In %s: ouch!! had null message!\n", __func__);
1465  break;
1466  }
1467  /* Process it by calling component's message handler method */
1468  omx_base_component_Private->messageHandler(openmaxStandComp, message);
1469  /* Message ownership has been transferred to us
1470  * so we gonna free it when finished.
1471  */
1472  free(message);
1473  message = NULL;
1474  }
1475  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, openmaxStandComp);
1476  return NULL;
1477 }
1478 
1491  omx_base_component_PrivateType* omx_base_component_Private=openmaxStandComp->pComponentPrivate;
1492  OMX_U32 i,j,k;
1494  omx_base_PortType* pPort;
1495 
1496  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p with message %i\n", __func__, openmaxStandComp, message->messageType);
1497 
1498  /* Dealing with a SendCommand call.
1499  * -messageType contains the command to execute
1500  * -messageParam contains the parameter of the command
1501  * (destination state in case of a state change command).
1502  */
1503  switch(message->messageType){
1504  case OMX_CommandStateSet: {
1505  /* Do the actual state change */
1506  err = (*(omx_base_component_Private->DoStateSet))(openmaxStandComp, message->messageParam);
1507  if (err != OMX_ErrorNone) {
1508  (*(omx_base_component_Private->callbacks->EventHandler))
1509  (openmaxStandComp,
1510  omx_base_component_Private->callbackData,
1511  OMX_EventError, /* The command was completed */
1512  err, /* The commands was a OMX_CommandStateSet */
1513  0, /* The state has been changed in message->messageParam */
1514  NULL);
1515  } else {
1516  /* And run the callback */
1517  if (omx_base_component_Private->callbacks) {
1518  DEBUG(DEB_LEV_SIMPLE_SEQ, "running callback in %s\n", __func__);
1519  (*(omx_base_component_Private->callbacks->EventHandler))
1520  (openmaxStandComp,
1521  omx_base_component_Private->callbackData,
1522  OMX_EventCmdComplete, /* The command was completed */
1523  OMX_CommandStateSet, /* The commands was a OMX_CommandStateSet */
1524  message->messageParam, /* The state has been changed in message->messageParam */
1525  NULL);
1526  }
1527  }
1528  }
1529  break;
1530  case OMX_CommandFlush: {
1531  /*Flush port/s*/
1532  if(message->messageParam == OMX_ALL) {
1533  /* for all ports */
1534  for(j = 0; j < NUM_DOMAINS; j++) {
1535  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1536  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1537  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1538  omx_base_component_Private->ports[i]->bIsPortFlushed = OMX_TRUE;
1539  }
1540  }
1541  /* for all ports */
1542  for(j = 0; j < NUM_DOMAINS; j++) {
1543  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1544  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1545  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1546  pPort=omx_base_component_Private->ports[i];
1547  err = pPort->FlushProcessingBuffers(pPort);
1548  }
1549  }
1550  }
1551  else {
1552  pPort=omx_base_component_Private->ports[message->messageParam];
1553  err = pPort->FlushProcessingBuffers(pPort);
1554  }
1555  if (err != OMX_ErrorNone) {
1556  (*(omx_base_component_Private->callbacks->EventHandler))
1557  (openmaxStandComp,
1558  omx_base_component_Private->callbackData,
1559  OMX_EventError, /* The command was completed */
1560  err, /* The commands was a OMX_CommandStateSet */
1561  0, /* The state has been changed in message->messageParam */
1562  NULL);
1563  } else {
1564  if(message->messageParam == OMX_ALL){ /*Flush all port*/
1565  /* for all ports */
1566  for(j = 0; j < NUM_DOMAINS; j++) {
1567  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1568  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1569  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1570  (*(omx_base_component_Private->callbacks->EventHandler))
1571  (openmaxStandComp,
1572  omx_base_component_Private->callbackData,
1573  OMX_EventCmdComplete, /* The command was completed */
1574  OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
1575  i, /* The state has been changed in message->messageParam */
1576  NULL);
1577 
1578  pPort=omx_base_component_Private->ports[i];
1579  /* Signal the buffer Semaphore and the buffer managment semaphore, to restart the exchange of buffers after flush */
1580  if (PORT_IS_TUNNELED(pPort) && PORT_IS_BUFFER_SUPPLIER(pPort)) {
1581  for(k=0;k<pPort->nNumTunnelBuffer;k++) {
1582  tsem_up(pPort->pBufferSem);
1583  /*signal buffer management thread availability of buffers*/
1584  tsem_up(omx_base_component_Private->bMgmtSem);
1585  }
1586  }
1587  }
1588  }
1589  } else {/*Flush input/output port*/
1590  (*(omx_base_component_Private->callbacks->EventHandler))
1591  (openmaxStandComp,
1592  omx_base_component_Private->callbackData,
1593  OMX_EventCmdComplete, /* The command was completed */
1594  OMX_CommandFlush, /* The commands was a OMX_CommandStateSet */
1595  message->messageParam, /* The state has been changed in message->messageParam */
1596  NULL);
1597  /* Signal the buffer Semaphore and the buffer managment semaphore, to restart the exchange of buffers after flush */
1598  if (PORT_IS_TUNNELED(omx_base_component_Private->ports[message->messageParam])
1599  && PORT_IS_BUFFER_SUPPLIER(omx_base_component_Private->ports[message->messageParam])) {
1600  for(j=0;j<omx_base_component_Private->ports[message->messageParam]->nNumTunnelBuffer;j++) {
1601  tsem_up(omx_base_component_Private->ports[message->messageParam]->pBufferSem);
1602  /*signal buffer management thread availability of buffers*/
1603  tsem_up(omx_base_component_Private->bMgmtSem);
1604  }
1605  }
1606  }
1607  }
1608  }
1609  break;
1610  case OMX_CommandPortDisable: {
1611  /*Flush port/s*/
1612  if(message->messageParam == OMX_ALL) {
1613  /*If Component is not in loaded state,then First Flush all buffers then disable the port*/
1614  if(omx_base_component_Private->state!=OMX_StateLoaded) {
1615  /* for all ports */
1616  for(j = 0; j < NUM_DOMAINS; j++) {
1617  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1618  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1619  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1620  pPort=omx_base_component_Private->ports[i];
1621  err = pPort->FlushProcessingBuffers(pPort);
1622  }
1623  }
1624  }
1625  /* for all ports */
1626  for(j = 0; j < NUM_DOMAINS; j++) {
1627  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1628  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1629  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1630  pPort=omx_base_component_Private->ports[i];
1631  err = pPort->Port_DisablePort(pPort);
1632  }
1633  }
1634  }
1635  else {
1636  pPort=omx_base_component_Private->ports[message->messageParam];
1637  if(omx_base_component_Private->state!=OMX_StateLoaded) {
1638  err = pPort->FlushProcessingBuffers(pPort);
1639  DEBUG(DEB_LEV_FULL_SEQ, "In %s: Port Flush completed for Comp %s\n",__func__,omx_base_component_Private->name);
1640  }
1641  err = pPort->Port_DisablePort(pPort);
1642  }
1644  if (err != OMX_ErrorNone) {
1645  (*(omx_base_component_Private->callbacks->EventHandler))
1646  (openmaxStandComp,
1647  omx_base_component_Private->callbackData,
1648  OMX_EventError, /* The command was completed */
1649  err, /* The commands was a OMX_CommandStateSet */
1650  0, /* The state has been changed in message->messageParam */
1651  NULL);
1652  } else {
1653  if(message->messageParam == OMX_ALL){ /*Disable all ports*/
1654  /* for all ports */
1655  for(j = 0; j < NUM_DOMAINS; j++) {
1656  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1657  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1658  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1659  (*(omx_base_component_Private->callbacks->EventHandler))
1660  (openmaxStandComp,
1661  omx_base_component_Private->callbackData,
1662  OMX_EventCmdComplete, /* The command was completed */
1663  OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
1664  i, /* The state has been changed in message->messageParam */
1665  NULL);
1666  }
1667  }
1668  } else {
1669  (*(omx_base_component_Private->callbacks->EventHandler))
1670  (openmaxStandComp,
1671  omx_base_component_Private->callbackData,
1672  OMX_EventCmdComplete, /* The command was completed */
1673  OMX_CommandPortDisable, /* The commands was a OMX_CommandStateSet */
1674  message->messageParam, /* The state has been changed in message->messageParam */
1675  NULL);
1676  }
1677  }
1678  }
1679  break;
1680  case OMX_CommandPortEnable:{
1681  /*Flush port/s*/
1682  if(message->messageParam == OMX_ALL) {
1683  /* for all ports */
1684  for(j = 0; j < NUM_DOMAINS; j++) {
1685  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1686  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1687  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1688  pPort=omx_base_component_Private->ports[i];
1689  err = pPort->Port_EnablePort(pPort);
1690  }
1691  }
1692  } else {
1693  pPort=omx_base_component_Private->ports[message->messageParam];
1694  err = pPort->Port_EnablePort(pPort);
1695  }
1696  if (err != OMX_ErrorNone) {
1697  (*(omx_base_component_Private->callbacks->EventHandler))
1698  (openmaxStandComp,
1699  omx_base_component_Private->callbackData,
1700  OMX_EventError, /* The command was completed */
1701  err, /* The commands was a OMX_CommandStateSet */
1702  0, /* The state has been changed in message->messageParam */
1703  NULL);
1704  } else {
1705  if(message->messageParam != OMX_ALL) {
1706  (*(omx_base_component_Private->callbacks->EventHandler))
1707  (openmaxStandComp,
1708  omx_base_component_Private->callbackData,
1709  OMX_EventCmdComplete, /* The command was completed */
1710  OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
1711  message->messageParam, /* The state has been changed in message->messageParam */
1712  NULL);
1713 
1714  if (omx_base_component_Private->state==OMX_StateExecuting) {
1715  pPort=omx_base_component_Private->ports[message->messageParam];
1716  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
1717  for(i=0; i < pPort->sPortParam.nBufferCountActual;i++) {
1718  tsem_up(pPort->pBufferSem);
1719  tsem_up(omx_base_component_Private->bMgmtSem);
1720  }
1721  }
1722  }
1723 
1724  } else {
1725  /* for all ports */
1726  for(j = 0; j < NUM_DOMAINS; j++) {
1727  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1728  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1729  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1730  (*(omx_base_component_Private->callbacks->EventHandler))
1731  (openmaxStandComp,
1732  omx_base_component_Private->callbackData,
1733  OMX_EventCmdComplete, /* The command was completed */
1734  OMX_CommandPortEnable, /* The commands was a OMX_CommandStateSet */
1735  i, /* The state has been changed in message->messageParam */
1736  NULL);
1737  }
1738  }
1739 
1740  if (omx_base_component_Private->state==OMX_StateExecuting) {
1741  /* for all ports */
1742  for(j = 0; j < NUM_DOMAINS; j++) {
1743  for(i = omx_base_component_Private->sPortTypesParam[j].nStartPortNumber;
1744  i < omx_base_component_Private->sPortTypesParam[j].nStartPortNumber +
1745  omx_base_component_Private->sPortTypesParam[j].nPorts; i++) {
1746  pPort=omx_base_component_Private->ports[i];
1747  if (PORT_IS_BUFFER_SUPPLIER(pPort)) {
1748  for(k=0; k < pPort->sPortParam.nBufferCountActual;k++) {
1749  tsem_up(pPort->pBufferSem);
1750  tsem_up(omx_base_component_Private->bMgmtSem);
1751  }
1752  }
1753  }
1754  }
1755  }
1756  }
1757  }
1758  }
1759  break;
1760  case OMX_CommandMarkBuffer: {
1761  omx_base_component_Private->pMark.hMarkTargetComponent = ((OMX_MARKTYPE *)message->pCmdData)->hMarkTargetComponent;
1762  omx_base_component_Private->pMark.pMarkData = ((OMX_MARKTYPE *)message->pCmdData)->pMarkData;
1763  }
1764  break;
1765  default:
1766  DEBUG(DEB_LEV_ERR, "In %s: Unrecognized command %i\n", __func__, message->messageType);
1767  break;
1768  }
1769  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, openmaxStandComp);
1770  return OMX_ErrorNone;
1771 }
1772 
1774  OMX_HANDLETYPE hComponent,
1775  OMX_BUFFERHEADERTYPE** ppBuffer,
1776  OMX_U32 nPortIndex,
1777  OMX_PTR pAppPrivate,
1778  OMX_U32 nSizeBytes) {
1779  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
1780  omx_base_PortType *pPort;
1782 
1783  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1784 
1785  if (nPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1786  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1787  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1788  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1789  DEBUG(DEB_LEV_ERR, "In %s: wrong port index\n", __func__);
1790  return OMX_ErrorBadPortIndex;
1791  }
1792  pPort = omx_base_component_Private->ports[nPortIndex];
1793  err = pPort->Port_AllocateBuffer(pPort, ppBuffer, nPortIndex, pAppPrivate, nSizeBytes);
1794  if (err != OMX_ErrorNone) {
1795  DEBUG(DEB_LEV_ERR, "Out of %s for component %p with err %i\n", __func__, hComponent, (int)err);
1796  return err;
1797  }
1798  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p buffer %p\n", __func__, hComponent, ppBuffer);
1799  return OMX_ErrorNone;
1800 }
1801 
1803  OMX_HANDLETYPE hComponent,
1804  OMX_BUFFERHEADERTYPE** ppBufferHdr,
1805  OMX_U32 nPortIndex,
1806  OMX_PTR pAppPrivate,
1807  OMX_U32 nSizeBytes,
1808  OMX_U8* pBuffer) {
1809  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
1810  omx_base_PortType *pPort;
1812 
1813  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1814  if (nPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1815  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1816  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1817  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1818  DEBUG(DEB_LEV_ERR, "In %s: wrong port index\n", __func__);
1819  return OMX_ErrorBadPortIndex;
1820  }
1821  pPort = omx_base_component_Private->ports[nPortIndex];
1822  err = pPort->Port_UseBuffer(pPort, ppBufferHdr, nPortIndex, pAppPrivate, nSizeBytes, pBuffer);
1823  if (err != OMX_ErrorNone) {
1824  DEBUG(DEB_LEV_ERR, "Out of %s for component %p with err %i\n", __func__, hComponent, (int)err);
1825  return err;
1826  }
1827  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1828  return OMX_ErrorNone;
1829 }
1830 
1832  OMX_HANDLETYPE hComponent,
1833  OMX_BUFFERHEADERTYPE** ppBufferHdr,
1834  OMX_U32 nPortIndex,
1835  OMX_PTR pAppPrivate,
1836  void* eglImage) {
1837  return OMX_ErrorNotImplemented;
1838 }
1839 
1841  OMX_HANDLETYPE hComponent,
1842  OMX_U32 nPortIndex,
1843  OMX_BUFFERHEADERTYPE* pBuffer) {
1844  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
1845  omx_base_PortType *pPort;
1847 
1848  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1849  if (nPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1850  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1851  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1852  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1853  DEBUG(DEB_LEV_ERR, "In %s: wrong port index\n", __func__);
1854  return OMX_ErrorBadPortIndex;
1855  }
1856 
1857  pPort = omx_base_component_Private->ports[nPortIndex];
1858  err = pPort->Port_FreeBuffer(pPort, nPortIndex, pBuffer);
1859  if (err != OMX_ErrorNone) {
1860  DEBUG(DEB_LEV_ERR, "Out of %s for component %p with err %i\n", __func__, hComponent, (int)err);
1861  return err;
1862  }
1863  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1864  return OMX_ErrorNone;
1865 }
1866 
1868  OMX_HANDLETYPE hComponent,
1869  OMX_BUFFERHEADERTYPE* pBuffer) {
1870  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
1871  omx_base_PortType *pPort;
1873 
1874  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1875 
1876  if (pBuffer->nInputPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1877  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1878  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1879  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1880  DEBUG(DEB_LEV_ERR, "In %s: wrong port index\n", __func__);
1881  return OMX_ErrorBadPortIndex;
1882  }
1883  pPort = omx_base_component_Private->ports[pBuffer->nInputPortIndex];
1884  if (pPort->sPortParam.eDir != OMX_DirInput) {
1885  DEBUG(DEB_LEV_ERR, "In %s: wrong port direction in Component %s\n", __func__,omx_base_component_Private->name);
1886  return OMX_ErrorBadPortIndex;
1887  }
1888  err = pPort->Port_SendBufferFunction(pPort, pBuffer);
1889  if (err != OMX_ErrorNone) {
1890  DEBUG(DEB_LEV_ERR, "Out of %s for component %p with err %s\n", __func__, hComponent, errorName(err));
1891  return err;
1892  }
1893  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1894  return OMX_ErrorNone;
1895 }
1896 
1898  OMX_HANDLETYPE hComponent,
1899  OMX_BUFFERHEADERTYPE* pBuffer) {
1900 
1901  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
1902  omx_base_PortType *pPort;
1904 
1905  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1906  if (pBuffer->nOutputPortIndex >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1907  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1908  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1909  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1910  DEBUG(DEB_LEV_ERR, "In %s: wrong port index\n", __func__);
1911  return OMX_ErrorBadPortIndex;
1912  }
1913  pPort = omx_base_component_Private->ports[pBuffer->nOutputPortIndex];
1914  if (pPort->sPortParam.eDir != OMX_DirOutput) {
1915  DEBUG(DEB_LEV_ERR, "In %s: wrong port(%d) direction(%x) pBuffer=%p in Component %s\n", __func__,
1916  (int)pBuffer->nOutputPortIndex, (int)pPort->sPortParam.eDir, pBuffer, omx_base_component_Private->name);
1917  return OMX_ErrorBadPortIndex;
1918  }
1919  err = pPort->Port_SendBufferFunction(pPort, pBuffer);
1920  if (err != OMX_ErrorNone) {
1921  DEBUG(DEB_LEV_ERR, "Out of %s for component %p with err %s\n", __func__, hComponent, errorName(err));
1922  return err;
1923  }
1924  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1925  return OMX_ErrorNone;
1926 }
1927 
1929  OMX_HANDLETYPE hComponent,
1930  OMX_U32 nPort,
1931  OMX_HANDLETYPE hTunneledComp,
1932  OMX_U32 nTunneledPort,
1933  OMX_TUNNELSETUPTYPE* pTunnelSetup) {
1934 
1935  omx_base_component_PrivateType* omx_base_component_Private = (omx_base_component_PrivateType*)((OMX_COMPONENTTYPE*)hComponent)->pComponentPrivate;
1936  omx_base_PortType *pPort;
1938 
1939  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s for component %p\n", __func__, hComponent);
1940  if (nPort >= (omx_base_component_Private->sPortTypesParam[OMX_PortDomainAudio].nPorts +
1941  omx_base_component_Private->sPortTypesParam[OMX_PortDomainVideo].nPorts +
1942  omx_base_component_Private->sPortTypesParam[OMX_PortDomainImage].nPorts +
1943  omx_base_component_Private->sPortTypesParam[OMX_PortDomainOther].nPorts)) {
1944  return OMX_ErrorBadPortIndex;
1945  }
1946 
1947  pPort = omx_base_component_Private->ports[nPort];
1948  err = pPort->ComponentTunnelRequest(pPort, hTunneledComp, nTunneledPort, pTunnelSetup);
1949  if (err != OMX_ErrorNone) {
1950  DEBUG(DEB_LEV_ERR, "Out of %s for component %p with err %i\n", __func__, hComponent, (int)err);
1951  return err;
1952  }
1953  DEBUG(DEB_LEV_FUNCTION_NAME, "Out of %s for component %p\n", __func__, hComponent);
1954  return OMX_ErrorNone;
1955 }
1956 
1958  omx_base_component_PrivateType* omx_base_component_Private = openmaxStandComp->pComponentPrivate;
1959  DEBUG(DEB_LEV_FUNCTION_NAME, "In %s\n", __func__);
1960  *pQualityLevel = omx_base_component_Private->currentQualityLevel;
1961  return OMX_ErrorNone;
1962 }
1963 
1965  omx_base_component_PrivateType* omx_base_component_Private = openmaxStandComp->pComponentPrivate;
1966  /* this change is done regardless to the state. When the way to change effectively quality in a component is known
1967  * change this function adding state checks
1968  */
1969  DEBUG(DEB_LEV_SIMPLE_SEQ, "In %s setting %i of %i\n", __func__, (int)nQualityLevel, (int)omx_base_component_Private->nqualitylevels);
1970  if ((nQualityLevel > 0) && (nQualityLevel <= omx_base_component_Private->nqualitylevels)) {
1971  omx_base_component_Private->currentQualityLevel = nQualityLevel;
1972  return OMX_ErrorNone;
1973  } else {
1974  return OMX_ErrorBadParameter;
1975  }
1976 }
1977 
1978 #ifdef __cplusplus
1979 }
1980 #endif
1981 
#define OMX_MAX_STRINGNAME_SIZE
Definition: OMX_Core.h:281
OMX_ERRORTYPE
Definition: OMX_Core.h:127
@ OMX_ErrorInvalidState
Definition: OMX_Core.h:162
@ OMX_ErrorInsufficientResources
Definition: OMX_Core.h:131
@ OMX_ErrorSameState
Definition: OMX_Core.h:187
@ OMX_ErrorNotImplemented
Definition: OMX_Core.h:150
@ OMX_ErrorBadPortIndex
Definition: OMX_Core.h:224
@ OMX_ErrorNoMore
Definition: OMX_Core.h:175
@ OMX_ErrorNone
Definition: OMX_Core.h:128
@ OMX_ErrorUndefined
Definition: OMX_Core.h:134
@ OMX_ErrorUnsupportedIndex
Definition: OMX_Core.h:221
@ OMX_ErrorBadParameter
Definition: OMX_Core.h:147
@ OMX_ErrorIncorrectStateTransition
Definition: OMX_Core.h:212
@ OMX_ErrorVersionMismatch
Definition: OMX_Core.h:178
@ OMX_ErrorIncorrectStateOperation
Definition: OMX_Core.h:215
OMX_INDEXTYPE
Definition: OMX_Index.h:60
@ OMX_IndexParamPriorityMgmt
Definition: OMX_Index.h:63
@ OMX_IndexParamVideoInit
Definition: OMX_Index.h:66
@ OMX_IndexParamImageInit
Definition: OMX_Index.h:65
@ OMX_IndexParamAudioInit
Definition: OMX_Index.h:64
@ OMX_IndexParamCompBufferSupplier
Definition: OMX_Index.h:89
@ OMX_IndexParamPortDefinition
Definition: OMX_Index.h:88
@ OMX_IndexParamOtherInit
Definition: OMX_Index.h:67
#define OMX_ALL
Definition: OMX_Types.h:99
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
OMX_BOOL
Definition: OMX_Types.h:189
@ OMX_TRUE
Definition: OMX_Types.h:191
@ OMX_FALSE
Definition: OMX_Types.h:190
void * OMX_PTR
Definition: OMX_Types.h:199
void * OMX_HANDLETYPE
Definition: OMX_Types.h:295
unsigned char OMX_UUIDTYPE[128]
Definition: OMX_Types.h:219
@ OMX_DirInput
Definition: OMX_Types.h:226
@ OMX_DirOutput
Definition: OMX_Types.h:227
OMX_ERRORTYPE(* AllocateBuffer)(OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE **ppBuffer, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes)
OMX_ERRORTYPE(* FillBufferDone)(OMX_OUT OMX_HANDLETYPE hComponent, OMX_OUT OMX_PTR pAppData, OMX_OUT OMX_BUFFERHEADERTYPE *pBuffer)
Definition: OMX_Core.h:589
OMX_ERRORTYPE(* FillThisBuffer)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE(* FreeBuffer)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE(* UseEGLImage)(OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN void *eglImage)
OMX_ERRORTYPE(* UseBuffer)(OMX_IN OMX_HANDLETYPE hComponent, OMX_INOUT OMX_BUFFERHEADERTYPE **ppBufferHdr, OMX_IN OMX_U32 nPortIndex, OMX_IN OMX_PTR pAppPrivate, OMX_IN OMX_U32 nSizeBytes, OMX_IN OMX_U8 *pBuffer)
OMX_ERRORTYPE(* EmptyThisBuffer)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE(* EmptyBufferDone)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_BUFFERHEADERTYPE *pBuffer)
Definition: OMX_Core.h:560
@ OMX_BufferSupplyOutput
Definition: OMX_Core.h:605
@ OMX_BufferSupplyInput
Definition: OMX_Core.h:604
@ OMX_BufferSupplyUnspecified
Definition: OMX_Core.h:602
struct OMX_COMPONENTTYPE OMX_COMPONENTTYPE
OMX_STATETYPE
Definition: OMX_Core.h:93
#define OMX_SetParameter( hComponent, nParamIndex, pComponentParameterStructure)
Definition: OMX_Core.h:825
@ OMX_PortDomainAudio
Definition: OMX_Component.h:51
@ OMX_PortDomainVideo
Definition: OMX_Component.h:52
@ OMX_PortDomainOther
Definition: OMX_Component.h:54
@ OMX_PortDomainImage
Definition: OMX_Component.h:53
@ OMX_StateExecuting
Definition: OMX_Core.h:105
@ OMX_StateWaitForResources
Definition: OMX_Core.h:108
@ OMX_StateLoaded
Definition: OMX_Core.h:97
@ OMX_StateInvalid
Definition: OMX_Core.h:94
@ OMX_StateIdle
Definition: OMX_Core.h:102
@ OMX_StatePause
Definition: OMX_Core.h:107
@ OMX_EventCmdComplete
Definition: OMX_Core.h:481
@ OMX_EventError
Definition: OMX_Core.h:482
OMX_COMMANDTYPE
Definition: OMX_Core.h:50
@ OMX_CommandMarkBuffer
Definition: OMX_Core.h:55
@ OMX_CommandPortDisable
Definition: OMX_Core.h:53
@ OMX_CommandPortEnable
Definition: OMX_Core.h:54
@ OMX_CommandFlush
Definition: OMX_Core.h:52
@ OMX_CommandStateSet
Definition: OMX_Core.h:51
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)
OMX_ERRORTYPE omx_base_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp, OMX_STRING cComponentName)
The base constructor for the OpenMAX ST components.
OMX_ERRORTYPE omx_base_component_EmptyThisBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE omx_base_component_GetState(OMX_HANDLETYPE hComponent, OMX_STATETYPE *pState)
OMX_ERRORTYPE omx_base_component_ComponentDeInit(OMX_HANDLETYPE hComponent)
This standard functionality is called when the component is destroyed in the FreeHandle standard call...
OMX_ERRORTYPE omx_base_component_MessageHandler(OMX_COMPONENTTYPE *openmaxStandComp, internalRequestMessageType *message)
OMX_ERRORTYPE omx_base_component_AllocateBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE **ppBuffer, OMX_U32 nPortIndex, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes)
OMX_ERRORTYPE omx_base_component_GetComponentVersion(OMX_HANDLETYPE hComponent, OMX_STRING pComponentName, OMX_VERSIONTYPE *pComponentVersion, OMX_VERSIONTYPE *pSpecVersion, OMX_UUIDTYPE *pComponentUUID)
Standard OpenMAX function.
OMX_ERRORTYPE omx_base_component_SendCommand(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData)
standard SendCommand function
OMX_ERRORTYPE omx_base_component_ComponentTunnelRequest(OMX_HANDLETYPE hComponent, OMX_U32 nPort, OMX_HANDLETYPE hTunneledComp, OMX_U32 nTunneledPort, OMX_TUNNELSETUPTYPE *pTunnelSetup)
OMX_ERRORTYPE omx_base_component_SetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
Part of the standard OpenMAX function.
OMX_ERRORTYPE omx_base_component_UseBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE **ppBufferHdr, OMX_U32 nPortIndex, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, OMX_U8 *pBuffer)
OMX_ERRORTYPE omx_base_component_FillThisBuffer(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE omx_base_component_DoStateSet(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32 destinationState)
OMX_ERRORTYPE omx_base_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp)
The base destructor for ST OpenMAX components.
OMX_ERRORTYPE omx_base_component_ParameterSanityCheck(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_PTR pStructure, size_t size)
OMX_ERRORTYPE omx_base_getQualityLevel(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32 *pQualityLevel)
void setHeader(OMX_PTR header, OMX_U32 size)
Simply fills the first two fields in any OMX structure with the size and the version.
OMX_ERRORTYPE omx_base_component_SetCallbacks(OMX_HANDLETYPE hComponent, OMX_CALLBACKTYPE *pCallbacks, OMX_PTR pAppData)
standard OpenMAX function
OMX_ERRORTYPE omx_base_component_GetParameter(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nParamIndex, OMX_PTR ComponentParameterStructure)
Part of the standard OpenMAX function.
OMX_ERRORTYPE omx_base_component_SetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
base SetConfig function
OMX_ERRORTYPE omx_base_component_GetExtensionIndex(OMX_HANDLETYPE hComponent, OMX_STRING cParameterName, OMX_INDEXTYPE *pIndexType)
base function not implemented
void base_constructor_remove_garbage_collected(omx_base_component_PrivateType *omx_base_component_Private)
OMX_ERRORTYPE omx_base_component_UseEGLImage(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE **ppBufferHdr, OMX_U32 nPortIndex, OMX_PTR pAppPrivate, void *eglImage)
void * compMessageHandlerFunction(void *param)
Component's message handler thread function.
OMX_ERRORTYPE omx_base_component_GetConfig(OMX_HANDLETYPE hComponent, OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure)
base GetConfig function
OMX_ERRORTYPE checkHeader(OMX_PTR header, OMX_U32 size)
Checks the header of a structure for consistency with size and spec version.
OMX_ERRORTYPE omx_base_component_FreeBuffer(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE omx_base_setQualityLevel(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32 nQualityLevel)
OMX_ERRORTYPE omx_base_component_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
Enumerates all the roles of the component.
#define NUM_DOMAINS
#define OSCL_EXPORT_REF
@ OMX_IndexParameterThreadsID
@ OMX_IndexVendorCompPropTunnelFlags
@ OMX_TransStateExecutingToIdle
@ OMX_TransStateIdleToLoaded
@ OMX_TransStatePauseToIdle
@ OMX_TransStateMax
@ OMX_TransStateLoadedToIdle
#define PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(pPort)
Definition: omx_base_port.h:46
BUFFER_STATUS_FLAG
Definition: omx_base_port.h:72
@ BUFFER_FREE
Definition: omx_base_port.h:73
@ TUNNEL_IS_SUPPLIER
Definition: omx_base_port.h:89
#define PORT_IS_BUFFER_SUPPLIER(pPort)
Definition: omx_base_port.h:45
#define PORT_IS_TUNNELED(pPort)
Definition: omx_base_port.h:43
#define PORT_IS_ENABLED(pPort)
Definition: omx_base_port.h:41
#define DEB_LEV_PARAMS
#define DEB_LEV_FUNCTION_NAME
#define DEB_LEV_ERR
#define DEB_LEV_SIMPLE_SEQ
#define DEB_LEV_FULL_SEQ
#define DEBUG(n, fmt, args...)
OMX_ERRORTYPE RM_removeFromWaitForResource(OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE RM_getResource(OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE RM_releaseResource(OMX_COMPONENTTYPE *openmaxStandComp)
OMX_ERRORTYPE RM_waitForResource(OMX_COMPONENTTYPE *openmaxStandComp)
#define SPECVERSIONMINOR
Definition: omxcore.h:52
#define SPECREVISION
Definition: omxcore.h:54
#define SPECSTEP
Definition: omxcore.h:56
#define SPECVERSIONMAJOR
Definition: omxcore.h:50
OMX_ERRORTYPE err
int queue(queue_t *queue, void *data)
Definition: queue.c:103
void queue_deinit(queue_t *queue)
Definition: queue.c:77
int queue_init(queue_t *queue)
Definition: queue.c:38
void * dequeue(queue_t *queue)
Definition: queue.c:122
OMX_U32 nOutputPortIndex
Definition: OMX_Core.h:439
OMX_U32 nInputPortIndex
Definition: OMX_Core.h:441
OMX_ERRORTYPE(* EventHandler)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_PTR pAppData, OMX_IN OMX_EVENTTYPE eEvent, OMX_IN OMX_U32 nData1, OMX_IN OMX_U32 nData2, OMX_IN OMX_PTR pEventData)
Definition: OMX_Core.h:530
OMX_ERRORTYPE(* GetConfig)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_INOUT OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE(* SetConfig)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentConfigStructure)
OMX_ERRORTYPE(* ComponentDeInit)(OMX_IN OMX_HANDLETYPE hComponent)
OMX_ERRORTYPE(* SetParameter)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nIndex, OMX_IN OMX_PTR pComponentParameterStructure)
OMX_ERRORTYPE(* GetParameter)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_INDEXTYPE nParamIndex, OMX_INOUT OMX_PTR pComponentParameterStructure)
OMX_VERSIONTYPE nVersion
OMX_PTR pApplicationPrivate
OMX_ERRORTYPE(* GetComponentVersion)(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STRING pComponentName, OMX_OUT OMX_VERSIONTYPE *pComponentVersion, OMX_OUT OMX_VERSIONTYPE *pSpecVersion, OMX_OUT OMX_UUIDTYPE *pComponentUUID)
OMX_ERRORTYPE(* GetExtensionIndex)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_STRING cParameterName, OMX_OUT OMX_INDEXTYPE *pIndexType)
OMX_PTR pComponentPrivate
OMX_ERRORTYPE(* SetCallbacks)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_CALLBACKTYPE *pCallbacks, OMX_IN OMX_PTR pAppData)
OMX_ERRORTYPE(* ComponentRoleEnum)(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_U8 *cRole, OMX_IN OMX_U32 nIndex)
OMX_ERRORTYPE(* GetState)(OMX_IN OMX_HANDLETYPE hComponent, OMX_OUT OMX_STATETYPE *pState)
OMX_ERRORTYPE(* SendCommand)(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OMX_COMMANDTYPE Cmd, OMX_IN OMX_U32 nParam1, OMX_IN OMX_PTR pCmdData)
OMX_IMAGE_CODINGTYPE eCompressionFormat
Definition: OMX_Image.h:119
OMX_NATIVE_WINDOWTYPE pNativeWindow
Definition: OMX_Image.h:121
OMX_COLOR_FORMATTYPE eColorFormat
Definition: OMX_Image.h:120
OMX_HANDLETYPE hMarkTargetComponent
Definition: OMX_Types.h:299
OMX_PTR pMarkData
Definition: OMX_Types.h:302
union OMX_PARAM_PORTDEFINITIONTYPE::@0 format
OMX_PORTDOMAINTYPE eDomain
Definition: OMX_Component.h:77
OMX_AUDIO_PORTDEFINITIONTYPE audio
Definition: OMX_Component.h:79
OMX_OTHER_PORTDEFINITIONTYPE other
Definition: OMX_Component.h:82
OMX_IMAGE_PORTDEFINITIONTYPE image
Definition: OMX_Component.h:81
OMX_VIDEO_PORTDEFINITIONTYPE video
Definition: OMX_Component.h:80
OMX_U32 nStartPortNumber
Definition: OMX_Core.h:475
OMX_U32 nGroupPriority
Definition: OMX_Core.h:276
OMX_VIDEO_CODINGTYPE eCompressionFormat
Definition: OMX_Video.h:134
OMX_NATIVE_DEVICETYPE pNativeRender
Definition: OMX_Video.h:126
OMX_NATIVE_WINDOWTYPE pNativeWindow
Definition: OMX_Video.h:136
OMX_COLOR_FORMATTYPE eColorFormat
Definition: OMX_Video.h:135
The container of an internal message.
OMX_PARAM_PORTDEFINITIONTYPE sPortParam
OMX_ERRORTYPE(* Port_DisablePort)(omx_base_PortType *openmaxStandPort)
OMX_ERRORTYPE(* BufferProcessedCallback)(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_BOOL bIsTransientToEnabled
OMX_ERRORTYPE(* FlushProcessingBuffers)(omx_base_PortType *openmaxStandPort)
OMX_ERRORTYPE(* Port_EnablePort)(omx_base_PortType *openmaxStandPort)
OMX_ERRORTYPE(* Port_SendBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_BOOL bIsPortFlushed
OMX_ERRORTYPE(* ComponentTunnelRequest)(omx_base_PortType *openmaxStandPort, OMX_HANDLETYPE hTunneledComp, OMX_U32 nTunneledPort, OMX_TUNNELSETUPTYPE *pTunnelSetup)
OMX_U32 nNumTunnelBuffer
OMX_BUFFERSUPPLIERTYPE eBufferSupplier
OMX_ERRORTYPE(* Port_FreeBuffer)(omx_base_PortType *openmaxStandPort, OMX_U32 nPortIndex, OMX_BUFFERHEADERTYPE *pBuffer)
OMX_ERRORTYPE(* Port_UseBuffer)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE **ppBufferHdr, OMX_U32 nPortIndex, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes, OMX_U8 *pBuffer)
OMX_BOOL bIsTransientToDisabled
OMX_BUFFERHEADERTYPE ** pInternalBufferStorage
OMX_ERRORTYPE(* Port_AllocateBuffer)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE **pBuffer, OMX_U32 nPortIndex, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes)
OMX_PARAM_BELLAGIOTHREADS_ID * bellagioThreads
OMX_COMPONENTTYPE * openmaxStandComp
OMX_ERRORTYPE(* messageHandler)(OMX_COMPONENTTYPE *, internalRequestMessageType *)
OMX_ERRORTYPE(* DoStateSet)(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32)
OMX_ERRORTYPE(* getQualityLevel)(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32 *pQualityLevel)
OMX_ERRORTYPE(* setQualityLevel)(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32 nQualityLevel)
void *(* BufferMgmtFunction)(void *param)
OMX_ERRORTYPE(* destructor)(OMX_COMPONENTTYPE *openmaxStandComp)
OMX_PORT_PARAM_TYPE sPortTypesParam[4]
Definition: queue.h:43
void tsem_deinit(tsem_t *tsem)
Definition: tsemaphore.c:57
void tsem_signal(tsem_t *tsem)
Definition: tsemaphore.c:141
void tsem_up(tsem_t *tsem)
Definition: tsemaphore.c:110
int tsem_init(tsem_t *tsem, unsigned int val)
Definition: tsemaphore.c:39
void tsem_down(tsem_t *tsem)
Definition: tsemaphore.c:97
OMX_U8 nVersionMajor
Definition: OMX_Types.h:332
struct OMX_VERSIONTYPE::@1 s
OMX_U8 nVersionMinor
Definition: OMX_Types.h:333
OMX_U8 nRevision
Definition: OMX_Types.h:334
char * errorName(OMX_ERRORTYPE error)
Definition: utils.c:90

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