00001 /* 00002 * Capture.h 00003 * 00004 * Copyright (c) 2011 Datapath Ltd. 00005 * 00006 * This file forms part of the Vision driver capture 00007 * application sample source code. 00008 * 00009 * Purpose: Declares capture app main defines, structures and 00010 * functions. 00011 * 00012 */ 00013 00014 #include <linux/videodev2.h> 00015 00016 #include <pthread.h> 00017 00018 #include "CaptureTypes.h" 00019 00020 #define NUM_STREAMING_BUFFERS 4 00021 00022 typedef int BOOL; 00023 00024 typedef struct _sBuffer 00025 { 00026 /* Capture Data */ 00027 char *pData; 00028 unsigned int DataLength; 00029 } sBuffer, *psBuffer; 00030 00036 typedef struct _sCapture 00037 { 00038 /* File Descriptors */ 00039 int fd; 00040 int ctrlFd; 00042 /* Internals */ 00043 int inputs; 00044 int standards; 00045 int formats; 00047 unsigned long source_width; 00048 unsigned long source_height; 00050 unsigned long output_width; 00051 unsigned long output_height; 00052 unsigned int output_pixfmt; 00054 eIOType ioType; 00056 float fFrameRate; 00058 BOOL CroppingActive; 00059 int CroppingTop; 00060 int CroppingLeft; 00061 int CroppingWidth; 00062 int CroppingHeight; 00064 int capture_count; 00066 int timestamp; 00068 int livestream; 00070 int delay; 00072 /* video4linux structures */ 00073 struct v4l2_capability caps; 00075 struct v4l2_input *pInputs; 00077 v4l2_std_id standard; 00078 struct v4l2_standard *pStandards; 00080 struct v4l2_fmtdesc *pFormats; 00082 struct v4l2_format src_fmt; 00083 struct v4l2_format fmt; 00085 struct v4l2_streamparm StrmParm; 00087 /* mmap internals */ 00088 struct v4l2_requestbuffers req; 00089 unsigned int buffers; 00090 00091 /* Capture Buffers */ 00092 sBuffer pBuffers[NUM_STREAMING_BUFFERS]; 00093 00094 /* Capture Thread */ 00095 pthread_t CaptureThread; 00096 } sCapture, *psCapture; 00097 00108 int OpenCaptureDevice(char* device, psCapture pCapture, BOOL bBlock); 00109 00116 int OpenCaptureDeviceControl(psCapture pCapture); 00117 00126 void CloseCaptureDevice(int fd, psCapture pCapture); 00127 00133 void CloseCaptureDeviceControl(int fd); 00134 00141 int InitialiseReadCapture(psCapture pCapture, unsigned int buffer_size); 00142 00149 int UninitialiseReadCapture(psCapture pCapture); 00150 00157 int InitialiseMmapCapture(psCapture pCapture, unsigned int buffer_size); 00158 00165 int InitialiseUserPtrCapture(psCapture pCapture, unsigned int buffer_size); 00166 00173 int UninitialiseMmapCapture(psCapture pCapture); 00174 00181 int UninitialiseUserptrCapture(psCapture pCapture); 00182 00190 int InitialiseCapture(psCapture pCapture); 00191 00200 int StartCapture(psCapture pCapture); 00201