OpenMAXBellagio 0.9.3
omx_base_port.h
Go to the documentation of this file.
00001 
00026 #include "tsemaphore.h"
00027 #include "queue.h"
00028 #include "omx_classmagic.h"
00029 
00030 #ifndef __OMX_BASE_PORT_H__
00031 #define __OMX_BASE_PORT_H__
00032 
00033 #define TUNNEL_USE_BUFFER_RETRY 20
00034 #define TUNNEL_USE_BUFFER_RETRY_USLEEP_TIME 50000
00035 
00039 #define PORT_IS_BEING_FLUSHED(pPort)                             (pPort->bIsPortFlushed == OMX_TRUE)
00040 #define PORT_IS_BEING_DISABLED(pPort)                            (pPort->bIsTransientToDisabled == OMX_TRUE)
00041 #define PORT_IS_ENABLED(pPort)                                   (pPort->sPortParam.bEnabled == OMX_TRUE)
00042 #define PORT_IS_POPULATED(pPort)                                 (pPort->sPortParam.bPopulated == OMX_TRUE)
00043 #define PORT_IS_TUNNELED(pPort)                                  (pPort->nTunnelFlags & TUNNEL_ESTABLISHED)
00044 #define PORT_IS_DEEP_TUNNELED(pPort)                             (pPort->nTunnelFlags & PROPRIETARY_COMMUNICATION_ESTABLISHED)
00045 #define PORT_IS_BUFFER_SUPPLIER(pPort)                           (pPort->nTunnelFlags & TUNNEL_IS_SUPPLIER)
00046 #define PORT_IS_TUNNELED_N_BUFFER_SUPPLIER(pPort)                ((pPort->nTunnelFlags & TUNNEL_ESTABLISHED) && (pPort->nTunnelFlags & TUNNEL_IS_SUPPLIER))
00047 
00072 typedef enum BUFFER_STATUS_FLAG {
00073   BUFFER_FREE = 0,
00074   BUFFER_ALLOCATED = 0x0001,  
00076   BUFFER_ASSIGNED = 0x0002, 
00078   HEADER_ALLOCATED = 0x0004 
00080   } BUFFER_STATUS_FLAG;
00081 
00084 typedef enum TUNNEL_STATUS_FLAG {
00085   NO_TUNNEL = 0, 
00086   TUNNEL_ESTABLISHED = 0x0001, 
00089   TUNNEL_IS_SUPPLIER = 0x0002, 
00092   PROPRIETARY_COMMUNICATION_ESTABLISHED = 0x0004 
00096 } TUNNEL_STATUS_FLAG;
00097 
00098 
00105 CLASS(omx_base_PortType)
00106 #define omx_base_PortType_FIELDS \
00107   OMX_HANDLETYPE hTunneledComponent; \
00108   OMX_U32 nTunnelFlags; \
00109   OMX_U32 nTunneledPort;  \
00110   OMX_BUFFERSUPPLIERTYPE eBufferSupplier; \
00111   OMX_U32 nNumTunnelBuffer; \
00112   tsem_t* pAllocSem;  \
00113   pthread_mutex_t exitMutex;  \
00114   OMX_BOOL bIsDestroying;  \
00115   OMX_U32 nNumBufferFlushed; \
00116   OMX_BOOL bIsPortFlushed; \
00117   queue_t* pBufferQueue; \
00118   tsem_t* pBufferSem; \
00119   OMX_U32 nNumAssignedBuffers; \
00120   OMX_PARAM_PORTDEFINITIONTYPE sPortParam; \
00121   OMX_BUFFERHEADERTYPE **pInternalBufferStorage; \
00122   BUFFER_STATUS_FLAG *bBufferStateAllocated; \
00123   OMX_COMPONENTTYPE *standCompContainer;\
00124   OMX_BOOL bIsTransientToEnabled; \
00125   OMX_BOOL bIsTransientToDisabled; \
00126   OMX_BOOL bIsFullOfBuffers;  \
00127   OMX_BOOL bIsEmptyOfBuffers; \
00128   OMX_ERRORTYPE (*PortConstructor)(OMX_COMPONENTTYPE *openmaxStandComp,omx_base_PortType **openmaxStandPort,OMX_U32 nPortIndex, OMX_BOOL isInput);  \
00129   OMX_ERRORTYPE (*PortDestructor)(omx_base_PortType *openmaxStandPort);  \
00130   OMX_ERRORTYPE (*Port_DisablePort)(omx_base_PortType *openmaxStandPort);  \
00131   OMX_ERRORTYPE (*Port_EnablePort)(omx_base_PortType *openmaxStandPort);  \
00132   OMX_ERRORTYPE (*Port_SendBufferFunction)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE* pBuffer);   \
00133   OMX_ERRORTYPE (*Port_AllocateBuffer)(omx_base_PortType *openmaxStandPort, OMX_BUFFERHEADERTYPE** pBuffer, OMX_U32 nPortIndex, OMX_PTR pAppPrivate, OMX_U32 nSizeBytes);   \
00134   OMX_ERRORTYPE (*Port_UseBuffer)(omx_base_PortType *openmaxStandPort,OMX_BUFFERHEADERTYPE** ppBufferHdr,OMX_U32 nPortIndex,OMX_PTR pAppPrivate,OMX_U32 nSizeBytes,OMX_U8* pBuffer); \
00135   OMX_ERRORTYPE (*Port_FreeBuffer)(omx_base_PortType *openmaxStandPort,OMX_U32 nPortIndex,OMX_BUFFERHEADERTYPE* pBuffer);  \
00136   OMX_ERRORTYPE (*Port_AllocateTunnelBuffer)(omx_base_PortType *openmaxStandPort,OMX_U32 nPortIndex);   \
00137   OMX_ERRORTYPE (*Port_FreeTunnelBuffer)(omx_base_PortType *openmaxStandPort,OMX_U32 nPortIndex);  \
00138   OMX_ERRORTYPE (*BufferProcessedCallback)(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_BUFFERHEADERTYPE* pBuffer); \
00139   OMX_ERRORTYPE (*FlushProcessingBuffers)(omx_base_PortType *openmaxStandPort);  \
00140   OMX_ERRORTYPE (*ReturnBufferFunction)(omx_base_PortType* openmaxStandPort,OMX_BUFFERHEADERTYPE* pBuffer);  \
00141   OMX_ERRORTYPE (*ComponentTunnelRequest)(omx_base_PortType* openmaxStandPort, OMX_HANDLETYPE hTunneledComp, OMX_U32 nTunneledPort, OMX_TUNNELSETUPTYPE* pTunnelSetup); 
00142 ENDCLASS(omx_base_PortType)
00143 
00156 OMX_ERRORTYPE base_port_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,omx_base_PortType **openmaxStandPort,OMX_U32 nPortIndex, OMX_BOOL isInput);
00157 
00167 OMX_ERRORTYPE base_port_Destructor(omx_base_PortType *openmaxStandPort);
00168 
00176 OMX_ERRORTYPE base_port_DisablePort(omx_base_PortType *openmaxStandPort);
00177 
00185 OMX_ERRORTYPE base_port_EnablePort(omx_base_PortType *openmaxStandPort);
00186 
00192 OMX_ERRORTYPE base_port_SendBufferFunction(
00193   omx_base_PortType *openmaxStandPort,
00194   OMX_BUFFERHEADERTYPE* pBuffer);
00195 
00204 OMX_ERRORTYPE base_port_AllocateBuffer(
00205   omx_base_PortType *openmaxStandPort,
00206   OMX_BUFFERHEADERTYPE** pBuffer,
00207   OMX_U32 nPortIndex,
00208   OMX_PTR pAppPrivate,
00209   OMX_U32 nSizeBytes);
00210 
00219 OMX_ERRORTYPE base_port_UseBuffer(
00220   omx_base_PortType *openmaxStandPort,
00221   OMX_BUFFERHEADERTYPE** ppBufferHdr,
00222   OMX_U32 nPortIndex,
00223   OMX_PTR pAppPrivate,
00224   OMX_U32 nSizeBytes,
00225   OMX_U8* pBuffer);
00226 
00232 OMX_ERRORTYPE base_port_FreeBuffer(
00233   omx_base_PortType *openmaxStandPort,
00234   OMX_U32 nPortIndex,
00235   OMX_BUFFERHEADERTYPE* pBuffer);
00236 
00242 OMX_ERRORTYPE base_port_FlushProcessingBuffers(omx_base_PortType *openmaxStandPort);
00243 
00249 OMX_ERRORTYPE base_port_ReturnBufferFunction(
00250   omx_base_PortType* openmaxStandPort,
00251   OMX_BUFFERHEADERTYPE* pBuffer);
00252 
00256 OMX_ERRORTYPE base_port_ComponentTunnelRequest(
00257   omx_base_PortType* openmaxStandPort,
00258   OMX_HANDLETYPE hTunneledComp,
00259   OMX_U32 nTunneledPort,
00260   OMX_TUNNELSETUPTYPE* pTunnelSetup);
00261 
00264 OMX_ERRORTYPE base_port_AllocateTunnelBuffer(
00265   omx_base_PortType *openmaxStandPort,
00266   OMX_U32 nPortIndex);
00267 
00270 OMX_ERRORTYPE base_port_FreeTunnelBuffer(
00271   omx_base_PortType *openmaxStandPort,
00272   OMX_U32 nPortIndex);
00273 
00274 
00275 #endif