00001
00031 #ifndef _OMX_VIDEOSRC_COMPONENT_H_
00032 #define _OMX_VIDEOSRC_COMPONENT_H_
00033
00034 #include <OMX_Types.h>
00035 #include <OMX_Component.h>
00036 #include <OMX_Core.h>
00037 #include <OMX_Video.h>
00038 #include <pthread.h>
00039 #include <omx_base_source.h>
00040 #include <string.h>
00041 #include <linux/videodev2.h>
00042 #include <sys/types.h>
00043 #include <sys/stat.h>
00044 #include <sys/ioctl.h>
00045 #include <sys/mman.h>
00046 #include <fcntl.h>
00047 #include <unistd.h>
00048 #include <errno.h>
00049 #include <sys/time.h>
00050
00052 #define MAX_NUM_OF_videosrc_component_INSTANCES 1
00053
00054 #define VIDEO_DEV_NAME "/dev/video"
00055
00056 struct buffer
00057 {
00058 void *start;
00059 unsigned int length;
00060 };
00061
00062
00066 DERIVEDCLASS(omx_videosrc_component_PrivateType, omx_base_source_PrivateType)
00067 #define omx_videosrc_component_PrivateType_FIELDS omx_base_source_PrivateType_FIELDS \
00068 \
00069 tsem_t* videoSyncSem; \
00070 \
00071 OMX_BOOL videoReady; \
00072 \
00073 OMX_BOOL bIsEOSSent; \
00074 \
00075 OMX_S32 deviceHandle; \
00076 \
00077 struct v4l2_capability cap; \
00078 \
00079 OMX_U32 iFrameSize; \
00080 \
00081 OMX_BOOL bOutBufferMemoryMapped; \
00082 \
00083 struct v4l2_cropcap cropcap; \
00084 struct v4l2_crop crop; \
00085 \
00086 struct v4l2_format fmt; \
00087 struct buffer *buffers; \
00088 \
00089 int pixel_format;
00090 ENDCLASS(omx_videosrc_component_PrivateType)
00091
00092
00093 OMX_ERRORTYPE omx_videosrc_component_Constructor(OMX_COMPONENTTYPE *openmaxStandComp,OMX_STRING cComponentName);
00094 OMX_ERRORTYPE omx_videosrc_component_Destructor(OMX_COMPONENTTYPE *openmaxStandComp);
00095 OMX_ERRORTYPE omx_videosrc_component_MessageHandler(OMX_COMPONENTTYPE*,internalRequestMessageType*);
00096 OMX_ERRORTYPE omx_videosrc_component_Init(OMX_COMPONENTTYPE *openmaxStandComp);
00097 OMX_ERRORTYPE omx_videosrc_component_Deinit(OMX_COMPONENTTYPE *openmaxStandComp);
00098
00099 void omx_videosrc_component_BufferMgmtCallback(
00100 OMX_COMPONENTTYPE *openmaxStandComp,
00101 OMX_BUFFERHEADERTYPE* outputbuffer);
00102
00103 OMX_ERRORTYPE omx_videosrc_component_GetParameter(
00104 OMX_IN OMX_HANDLETYPE hComponent,
00105 OMX_IN OMX_INDEXTYPE nParamIndex,
00106 OMX_INOUT OMX_PTR ComponentParameterStructure);
00107
00108 OMX_ERRORTYPE omx_videosrc_component_SetParameter(
00109 OMX_IN OMX_HANDLETYPE hComponent,
00110 OMX_IN OMX_INDEXTYPE nParamIndex,
00111 OMX_IN OMX_PTR ComponentParameterStructure);
00112
00113 OMX_ERRORTYPE videosrc_port_AllocateBuffer(
00114 omx_base_PortType *openmaxStandPort,
00115 OMX_BUFFERHEADERTYPE** pBuffer,
00116 OMX_U32 nPortIndex,
00117 OMX_PTR pAppPrivate,
00118 OMX_U32 nSizeBytes);
00119
00120 OMX_ERRORTYPE videosrc_port_FreeBuffer(
00121 omx_base_PortType *openmaxStandPort,
00122 OMX_U32 nPortIndex,
00123 OMX_BUFFERHEADERTYPE* pBuffer);
00124
00125 OMX_ERRORTYPE videosrc_port_AllocateTunnelBuffer(
00126 omx_base_PortType *openmaxStandPort,
00127 OMX_IN OMX_U32 nPortIndex,
00128 OMX_IN OMX_U32 nSizeBytes);
00129
00130 OMX_ERRORTYPE videosrc_port_FreeTunnelBuffer(
00131 omx_base_PortType *openmaxStandPort,
00132 OMX_U32 nPortIndex);
00133
00134 #endif
00135