UvcInterface.h
00001 /* 00002 * Player - One Hell of a Robot Server 00003 * Copyright (C) 2006 00004 * Raymond Sheh, Luke Gumbley 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 */ 00022 00023 #include <linux/types.h> 00024 #include <linux/videodev2.h> 00025 #include <string.h> 00026 00027 class UvcInterface; 00028 00029 #ifndef UVCINTERFACE_H_ 00030 #define UVCINTERFACE_H_ 00031 00032 class UvcInterface 00033 { 00034 public: 00035 UvcInterface(char const *sDevice,int aWidth=320,int aHeight=240):device(sDevice),frame(0),frameSize(0),fd(-1),width(aWidth),height(aHeight){buffer[0]=0;buffer[1]=0;} 00036 ~UvcInterface(void) {device=0;Close();} 00037 00038 int Open(void); 00039 int Close(void); 00040 int Read(void); 00041 00042 int GetWidth(void) const; 00043 int GetHeight(void) const; 00044 00045 int GetFrameSize(void) const {return frameSize;} 00046 void CopyFrame(unsigned char *dest) const {memcpy(dest,frame,frameSize);} 00047 00048 bool IsOpen(void) const {return fd!=-1;} 00049 00050 private: 00051 char const *device; 00052 00053 unsigned char *frame; 00054 int frameSize; 00055 00056 unsigned char *buffer[2]; 00057 int length[2]; 00058 00059 int fd; 00060 00061 v4l2_capability cap; 00062 v4l2_format fmt; 00063 00064 static const int dht_size; 00065 static const unsigned char dht_data[]; 00066 00067 int width; 00068 int height; 00069 }; 00070 00071 #endif /*UVCINTERFACE_H_*/