00001
00030 #ifndef _OMX_BASE_COMPONENT_H_
00031 #define _OMX_BASE_COMPONENT_H_
00032
00033 #include <pthread.h>
00034
00035 #include "tsemaphore.h"
00036 #include "queue.h"
00037 #include "omx_classmagic.h"
00038 #include <omx_base_port.h>
00039
00041 #define DEFAULT_IN_BUFFER_SIZE 4 * 1024
00042
00043 #define DEFAULT_OUT_BUFFER_SIZE 16 * 1024
00044
00045 #define DEFAULT_MIME_STRING_LENGTH 128
00046
00047
00048 #define IS_COMPONENT_DEINIT(component_Private, exit_condition) \
00049 pthread_mutex_lock(&component_Private->exit_mutex) ,\
00050 exit_condition = component_Private->bIsComponentDeinit ,\
00051 pthread_mutex_unlock(&component_Private->exit_mutex) ,\
00052 (exit_condition == OMX_TRUE) ? OMX_TRUE:OMX_FALSE \
00053
00054 typedef struct OMX_VENDOR_EXTRADATATYPE {
00055 OMX_U32 nPortIndex;
00056 OMX_U32 nDataSize;
00057 OMX_U8 *pData;
00058 } OMX_VENDOR_EXTRADATATYPE;
00059
00061 typedef enum OMX_INDEXVENDORTYPE {
00063 OMX_IndexVendorFileReadInputFilename = 0xFF000001,
00064 OMX_IndexVendorParser3gpInputFilename = 0xFF000002,
00065 OMX_IndexVendorVideoExtraData = 0xFF000003,
00066 OMX_IndexVendorAudioExtraData = 0xFF000004,
00067 } OMX_INDEXVENDORTYPE;
00068
00070 typedef enum OMX_TRANS_STATETYPE {
00071 OMX_TransStateInvalid,
00072 OMX_TransStateLoadedToIdle,
00073 OMX_TransStateIdleToExecuting,
00074 OMX_TransStateExecutingToIdle,
00075 OMX_TransStateIdleToLoaded,
00076 OMX_TransStateMax = 0X7FFFFFFF
00077 } OMX_TRANS_STATETYPE;
00078
00082 typedef enum INTERNAL_MESSAGE_TYPE {
00083 SENDCOMMAND_MSG_TYPE = 1,
00084 ERROR_MSG_TYPE,
00085 WARNING_MSG_TYPE
00086 } INTERNAL_MESSAGE_TYPE;
00087
00093 typedef struct internalRequestMessageType {
00094 int messageType;
00095 int messageParam;
00096 OMX_PTR pCmdData;
00097 } internalRequestMessageType;
00098
00102 CLASS(omx_base_component_PrivateType)
00103 #define omx_base_component_PrivateType_FIELDS \
00104 OMX_COMPONENTTYPE *openmaxStandComp; \
00105 omx_base_PortType **ports; \
00106 OMX_PORT_PARAM_TYPE sPortTypesParam; \
00107 char uniqueID; \
00108 char* name; \
00109 OMX_STATETYPE state; \
00110 OMX_TRANS_STATETYPE transientState; \
00115 OMX_CALLBACKTYPE* callbacks; \
00117 OMX_PTR callbackData; \
00119 queue_t* messageQueue;\
00120 tsem_t* messageSem;\
00121 OMX_U32 nGroupPriority; \
00122 OMX_U32 nGroupID; \
00123 OMX_MARKTYPE *pMark; \
00124 pthread_mutex_t flush_mutex; \
00125 pthread_cond_t flush_all_condition; \
00126 pthread_cond_t flush_condition; \
00127 tsem_t* bMgmtSem;\
00128 tsem_t* bStateSem;\
00129 int messageHandlerThreadID; \
00130 pthread_t messageHandlerThread; \
00131 int bufferMgmtThreadID; \
00132 pthread_t bufferMgmtThread; \
00133 void *loader; \
00134 void* (*BufferMgmtFunction)(void* param); \
00135 OMX_ERRORTYPE (*messageHandler)(OMX_COMPONENTTYPE*,internalRequestMessageType*); \
00136 OMX_ERRORTYPE (*DoStateSet)(OMX_COMPONENTTYPE *openmaxStandComp, OMX_U32); \
00137 OMX_ERRORTYPE (*destructor)(OMX_COMPONENTTYPE *openmaxStandComp);
00138 ENDCLASS(omx_base_component_PrivateType)
00139
00155 OMX_ERRORTYPE omx_base_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,OMX_STRING cComponentName);
00156
00164 OMX_ERRORTYPE omx_base_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp);
00165
00176 OMX_ERRORTYPE omx_base_component_DoStateSet(
00177 OMX_COMPONENTTYPE *openmaxStandComp,
00178 OMX_U32 destinationState);
00179
00191 OMX_ERRORTYPE checkHeader(OMX_PTR header, OMX_U32 size);
00192
00200 void setHeader(OMX_PTR header, OMX_U32 size);
00201
00206 OMX_ERRORTYPE omx_base_component_GetComponentVersion(OMX_IN OMX_HANDLETYPE hComponent,
00207 OMX_OUT OMX_STRING pComponentName,
00208 OMX_OUT OMX_VERSIONTYPE* pComponentVersion,
00209 OMX_OUT OMX_VERSIONTYPE* pSpecVersion,
00210 OMX_OUT OMX_UUIDTYPE* pComponentUUID);
00211
00224 OMX_ERRORTYPE omx_base_component_ComponentRoleEnum(
00225 OMX_IN OMX_HANDLETYPE hComponent,
00226 OMX_OUT OMX_U8 *cRole,
00227 OMX_IN OMX_U32 nIndex);
00228
00234 OMX_ERRORTYPE omx_base_component_SetCallbacks(
00235 OMX_IN OMX_HANDLETYPE hComponent,
00236 OMX_IN OMX_CALLBACKTYPE* pCallbacks,
00237 OMX_IN OMX_PTR pAppData);
00238
00245 OMX_ERRORTYPE omx_base_component_GetParameter(
00246 OMX_IN OMX_HANDLETYPE hComponent,
00247 OMX_IN OMX_INDEXTYPE nParamIndex,
00248 OMX_INOUT OMX_PTR ComponentParameterStructure);
00249
00258 OMX_ERRORTYPE omx_base_component_SetParameter(
00259 OMX_IN OMX_HANDLETYPE hComponent,
00260 OMX_IN OMX_INDEXTYPE nParamIndex,
00261 OMX_IN OMX_PTR ComponentParameterStructure);
00262
00270 OMX_ERRORTYPE omx_base_component_GetConfig(
00271 OMX_IN OMX_HANDLETYPE hComponent,
00272 OMX_IN OMX_INDEXTYPE nIndex,
00273 OMX_INOUT OMX_PTR pComponentConfigStructure);
00274
00282 OMX_ERRORTYPE omx_base_component_SetConfig(
00283 OMX_IN OMX_HANDLETYPE hComponent,
00284 OMX_IN OMX_INDEXTYPE nIndex,
00285 OMX_IN OMX_PTR pComponentConfigStructure);
00286
00292 OMX_ERRORTYPE omx_base_component_GetExtensionIndex(
00293 OMX_IN OMX_HANDLETYPE hComponent,
00294 OMX_IN OMX_STRING cParameterName,
00295 OMX_OUT OMX_INDEXTYPE* pIndexType);
00296
00301 OMX_ERRORTYPE omx_base_component_GetState(
00302 OMX_IN OMX_HANDLETYPE hComponent,
00303 OMX_OUT OMX_STATETYPE* pState);
00304
00310 OMX_ERRORTYPE omx_base_component_SendCommand(
00311 OMX_IN OMX_HANDLETYPE hComponent,
00312 OMX_IN OMX_COMMANDTYPE Cmd,
00313 OMX_IN OMX_U32 nParam,
00314 OMX_IN OMX_PTR pCmdData);
00315
00324 OMX_ERRORTYPE omx_base_component_ComponentDeInit(
00325 OMX_IN OMX_HANDLETYPE hComponent);
00326
00333 void* compMessageHandlerFunction(void*);
00334
00346 OMX_ERRORTYPE omx_base_component_MessageHandler(OMX_COMPONENTTYPE *openmaxStandComp,internalRequestMessageType* message);
00347
00351 OMX_ERRORTYPE omx_base_component_ParameterSanityCheck(
00352 OMX_IN OMX_HANDLETYPE hComponent,
00353 OMX_IN OMX_U32 nPortIndex,
00354 OMX_IN OMX_PTR pStructure,
00355 OMX_IN size_t size);
00356
00357 OMX_ERRORTYPE omx_base_component_AllocateBuffer(
00358 OMX_IN OMX_HANDLETYPE hComponent,
00359 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBuffer,
00360 OMX_IN OMX_U32 nPortIndex,
00361 OMX_IN OMX_PTR pAppPrivate,
00362 OMX_IN OMX_U32 nSizeBytes);
00363
00364 OMX_ERRORTYPE omx_base_component_UseBuffer(
00365 OMX_IN OMX_HANDLETYPE hComponent,
00366 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
00367 OMX_IN OMX_U32 nPortIndex,
00368 OMX_IN OMX_PTR pAppPrivate,
00369 OMX_IN OMX_U32 nSizeBytes,
00370 OMX_IN OMX_U8* pBuffer);
00371
00372 OMX_ERRORTYPE omx_base_component_UseEGLImage (
00373 OMX_IN OMX_HANDLETYPE hComponent,
00374 OMX_INOUT OMX_BUFFERHEADERTYPE** ppBufferHdr,
00375 OMX_IN OMX_U32 nPortIndex,
00376 OMX_IN OMX_PTR pAppPrivate,
00377 OMX_IN void* eglImage);
00378
00379 OMX_ERRORTYPE omx_base_component_FreeBuffer(
00380 OMX_IN OMX_HANDLETYPE hComponent,
00381 OMX_IN OMX_U32 nPortIndex,
00382 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
00383
00384 OMX_ERRORTYPE omx_base_component_EmptyThisBuffer(
00385 OMX_IN OMX_HANDLETYPE hComponent,
00386 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
00387
00388 OMX_ERRORTYPE omx_base_component_FillThisBuffer(
00389 OMX_IN OMX_HANDLETYPE hComponent,
00390 OMX_IN OMX_BUFFERHEADERTYPE* pBuffer);
00391
00392 OMX_ERRORTYPE omx_base_component_ComponentTunnelRequest(
00393 OMX_IN OMX_HANDLETYPE hComp,
00394 OMX_IN OMX_U32 nPort,
00395 OMX_IN OMX_HANDLETYPE hTunneledComp,
00396 OMX_IN OMX_U32 nTunneledPort,
00397 OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup);
00398
00399 #endif