00001 00030 #include "tsemaphore.h" 00031 #include "queue.h" 00032 #include "omx_classmagic.h" 00033 00034 #ifndef __OMX_BASE_PORT_H__ 00035 #define __OMX_BASE_PORT_H__ 00036 00037 #define TUNNEL_USE_BUFFER_RETRY 20 00038 #define TUNNEL_USE_BUFFER_RETRY_USLEEP_TIME 50000 00039 00043 #define PORT_IS_BEING_FLUSHED(pPort) (pPort->bIsPortFlushed == OMX_TRUE) 00044 #define PORT_IS_BEING_DISABLED(pPort) (pPort->bIsTransientToDisabled == OMX_TRUE) 00045 #define PORT_IS_ENABLED(pPort) (pPort->sPortParam.bEnabled == OMX_TRUE) 00046 #define PORT_IS_POPULATED(pPort) (pPort->sPortParam.bPopulated == OMX_TRUE) 00047 #define PORT_IS_TUNNELED(pPort) (pPort->nTunnelFlags & TUNNEL_ESTABLISHED) 00048 #define PORT_IS_DEEP_TUNNELED(pPort) (pPort->nTunnelFlags & PROPRIETARY_COMMUNICATION_ESTABLISHED) 00049 #define PORT_IS_BUFFER_SUPPLIER(pPort) (pPort->nTunnelFlags & TUNNEL_IS_SUPPLIER) 00050 #define PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(pPort) (pPort->nTunnelFlags== (TUNNEL_ESTABLISHED | TUNNEL_IS_SUPPLIER)) 00051 00076 typedef enum BUFFER_STATUS_FLAG { 00077 BUFFER_FREE = 0, 00078 BUFFER_ALLOCATED = 0x0001, 00080 BUFFER_ASSIGNED = 0x0002, 00082 HEADER_ALLOCATED = 0x0004 00084 } BUFFER_STATUS_FLAG; 00085 00088 typedef enum TUNNEL_STATUS_FLAG { 00089 NO_TUNNEL = 0, 00090 TUNNEL_ESTABLISHED = 0x0001, 00093 TUNNEL_IS_SUPPLIER = 0x0002, 00096 PROPRIETARY_COMMUNICATION_ESTABLISHED = 0x0004 00100 } TUNNEL_STATUS_FLAG; 00101 00102 00109 CLASS(omx_base_PortType) 00110 #define omx_base_PortType_FIELDS \ 00111 OMX_HANDLETYPE hTunneledComponent; \ 00112 OMX_U32 nTunnelFlags; \ 00113 OMX_U32 nTunneledPort; \ 00114 OMX_BUFFERSUPPLIERTYPE eBufferSupplier; \ 00115 OMX_U32 nNumTunnelBuffer; \ 00116 tsem_t* pAllocSem; \ 00117 OMX_U32 nNumBufferFlushed; \ 00118 OMX_BOOL bIsPortFlushed; \ 00119 queue_t* pBufferQueue; \ 00120 tsem_t* pBufferSem; \ 00121 OMX_U32 nNumAssignedBuffers; \ 00122 OMX_PARAM_PORTDEFINITIONTYPE sPortParam; \ 00123 OMX_BUFFERHEADERTYPE **pInternalBufferStorage; \ 00124 BUFFER_STATUS_FLAG *bBufferStateAllocated; \ 00125 OMX_COMPONENTTYPE *standCompContainer;\ 00126 OMX_BOOL bIsTransientToEnabled; \ 00127 OMX_BOOL bIsTransientToDisabled; \ 00128 OMX_BOOL bIsFullOfBuffers; \ 00129 OMX_BOOL bIsEmptyOfBuffers; \ 00130 OMX_ERRORTYPE (*PortConstructor)(OMX_COMPONENTTYPE *openmaxStandComp,omx_base_PortType **openmaxStandPort,OMX_U32 nPortIndex, OMX_BOOL isInput); \ 00131 OMX_ERRORTYPE (*PortDestructor)(omx_base_PortType *openmaxStandPort); \ 00132 OMX_ERRORTYPE (*Port_DisablePort)(omx_base_PortType *openmaxStandPort); \ 00133 OMX_ERRORTYPE (*Port_EnablePort)(omx_base_PortType *openmaxStandPort); \ 00134 OMX_ERRORTYPE (*Port_SendBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE* pBuffer); \ 00135 OMX_ERRORTYPE (*Port_AllocateBuffer)(omx_base_PortType *openmaxStandPort,OMX_INOUT OMX_BUFFERHEADERTYPE** pBuffer,OMX_IN OMX_U32 nPortIndex,OMX_IN OMX_PTR pAppPrivate,OMX_IN OMX_U32 nSizeBytes); \ 00136 OMX_ERRORTYPE (*Port_UseBuffer)(omx_base_PortType *openmaxStandPort,OMX_BUFFERHEADERTYPE** ppBufferHdr,OMX_U32 nPortIndex,OMX_PTR pAppPrivate,OMX_U32 nSizeBytes,OMX_U8* pBuffer); \ 00137 OMX_ERRORTYPE (*Port_FreeBuffer)(omx_base_PortType *openmaxStandPort,OMX_U32 nPortIndex,OMX_BUFFERHEADERTYPE* pBuffer); \ 00138 OMX_ERRORTYPE (*Port_AllocateTunnelBuffer)(omx_base_PortType *openmaxStandPort,OMX_IN OMX_U32 nPortIndex,OMX_IN OMX_U32 nSizeBytes); \ 00139 OMX_ERRORTYPE (*Port_FreeTunnelBuffer)(omx_base_PortType *openmaxStandPort,OMX_U32 nPortIndex); \ 00140 OMX_ERRORTYPE (*BufferProcessedCallback)(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE* pBuffer); \ 00141 OMX_ERRORTYPE (*FlushProcessingBuffers)(omx_base_PortType *openmaxStandPort); \ 00142 OMX_ERRORTYPE (*ReturnBufferFunction)(omx_base_PortType* openmaxStandPort,OMX_BUFFERHEADERTYPE* pBuffer); \ 00143 OMX_ERRORTYPE (*ComponentTunnelRequest)(omx_base_PortType* openmaxStandPort,OMX_IN OMX_HANDLETYPE hTunneledComp,OMX_IN OMX_U32 nTunneledPort,OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup); 00144 ENDCLASS(omx_base_PortType) 00145 00158 OMX_ERRORTYPE base_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,omx_base_PortType **openmaxStandPort,OMX_U32 nPortIndex, OMX_BOOL isInput); 00159 00169 OMX_ERRORTYPE base_port_Destructor(omx_base_PortType *openmaxStandPort); 00170 00178 OMX_ERRORTYPE base_port_DisablePort(omx_base_PortType *openmaxStandPort); 00179 00187 OMX_ERRORTYPE base_port_EnablePort(omx_base_PortType *openmaxStandPort); 00188 00194 OMX_ERRORTYPE base_port_SendBufferFunction( 00195 omx_base_PortType *openmaxStandPort, 00196 OMX_BUFFERHEADERTYPE* pBuffer); 00197 00206 OMX_ERRORTYPE base_port_AllocateBuffer( 00207 omx_base_PortType *openmaxStandPort, 00208 OMX_BUFFERHEADERTYPE** pBuffer, 00209 OMX_U32 nPortIndex, 00210 OMX_PTR pAppPrivate, 00211 OMX_U32 nSizeBytes); 00212 00221 OMX_ERRORTYPE base_port_UseBuffer( 00222 omx_base_PortType *openmaxStandPort, 00223 OMX_BUFFERHEADERTYPE** ppBufferHdr, 00224 OMX_U32 nPortIndex, 00225 OMX_PTR pAppPrivate, 00226 OMX_U32 nSizeBytes, 00227 OMX_U8* pBuffer); 00228 00234 OMX_ERRORTYPE base_port_FreeBuffer( 00235 omx_base_PortType *openmaxStandPort, 00236 OMX_U32 nPortIndex, 00237 OMX_BUFFERHEADERTYPE* pBuffer); 00238 00244 OMX_ERRORTYPE base_port_FlushProcessingBuffers(omx_base_PortType *openmaxStandPort); 00245 00251 OMX_ERRORTYPE base_port_ReturnBufferFunction( 00252 omx_base_PortType* openmaxStandPort, 00253 OMX_BUFFERHEADERTYPE* pBuffer); 00254 00258 OMX_ERRORTYPE base_port_ComponentTunnelRequest( 00259 omx_base_PortType* openmaxStandPort, 00260 OMX_IN OMX_HANDLETYPE hTunneledComp, 00261 OMX_IN OMX_U32 nTunneledPort, 00262 OMX_INOUT OMX_TUNNELSETUPTYPE* pTunnelSetup); 00263 00266 OMX_ERRORTYPE base_port_AllocateTunnelBuffer( 00267 omx_base_PortType *openmaxStandPort, 00268 OMX_IN OMX_U32 nPortIndex, 00269 OMX_IN OMX_U32 nSizeBytes); 00270 00273 OMX_ERRORTYPE base_port_FreeTunnelBuffer( 00274 omx_base_PortType *openmaxStandPort, 00275 OMX_U32 nPortIndex); 00276 00277 00278 #endif