UvcInterface.h
1/*
2 * Player - One Hell of a Robot Server
3 * Copyright (C) 2006
4 * Raymond Sheh, Luke Gumbley
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 *
21 */
22
23#include <linux/types.h>
24#include <linux/videodev2.h>
25#include <string.h>
26
27class UvcInterface;
28
29#ifndef UVCINTERFACE_H_
30#define UVCINTERFACE_H_
31
33{
34 public:
35 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;}
36 ~UvcInterface(void) {device=0;Close();}
37
38 int Open(void);
39 int Close(void);
40 int Read(void);
41
42 int GetWidth(void) const;
43 int GetHeight(void) const;
44
45 int GetFrameSize(void) const {return frameSize;}
46 void CopyFrame(unsigned char *dest) const {memcpy(dest,frame,frameSize);}
47
48 bool IsOpen(void) const {return fd!=-1;}
49
50 private:
51 char const *device;
52
53 unsigned char *frame;
54 int frameSize;
55
56 unsigned char *buffer[2];
57 int length[2];
58
59 int fd;
60
61 v4l2_capability cap;
62 v4l2_format fmt;
63
64 static const int dht_size;
65 static const unsigned char dht_data[];
66
67 int width;
68 int height;
69};
70
71#endif /*UVCINTERFACE_H_*/
Definition UvcInterface.h:33