include/avcap/linux/V4L1_VidCapManager.h

Go to the documentation of this file.
00001 /*
00002  * (c) 2005, 2008 Nico Pranke <Nico.Pranke@googlemail.com>, Robin Luedtke <RobinLu@gmx.de> 
00003  *
00004  * This file is part of avcap.
00005  *
00006  * avcap is free software: you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation, either version 3 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * avcap is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with avcap.  If not, see <http://www.gnu.org/licenses/>.
00018  */
00019 
00020 /* avcap is free for non-commercial use.
00021  * To use it in commercial endeavors, please contact Nico Pranke <Nico.Pranke@googlemail.com>.
00022  */
00023 
00024 
00025 #ifndef V4L1_VIDCAPMANAGER_H_
00026 #define V4L1_VIDCAPMANAGER_H_
00027 
00028 #include <sys/types.h>
00029 #include <list>
00030 #include <time.h>
00031 
00032 #include "CaptureManager.h"
00033 
00034 namespace avcap
00035 {
00036         class V4L1_DeviceDescriptor;
00037         class V4L1_FormatManager;
00038         class IOBuffer;
00039         class CaptureHandler;
00040 
00042 
00043         class V4L1_VidCapManager: public CaptureManager
00044         {
00045         private:
00046                 typedef std::list<IOBuffer*> IOBufList_t;
00047                 typedef std::list<int>           IndexList_t;
00048                                 
00049                 V4L1_DeviceDescriptor   *mDeviceDescriptor;
00050                 V4L1_FormatManager              *mFormatMgr;
00051                 
00052                 IOBufList_t                     mBuffers;
00053                 IndexList_t                     mCaptureIndices;
00054                 
00055                 int                                     mNumBufs;
00056                 int                                     mMethod;
00057                 int                                     mState;
00058 
00059                 pthread_t*                      mThread;
00060                 int                                     mFinish;
00061                 pthread_mutex_t         mLock;
00062                 timeval                         mStartTime;
00063 
00064                 long                            mSequence;
00065 
00066                 unsigned char*          mVideobuf;
00067                 size_t                          mVideobufSize;
00068                 int                                     mWidth;
00069                 int                                     mHeight;
00070                 unsigned int            mPalette;
00071                 int                                     mAvailableBuffers;
00072                 
00073         public:
00074         
00075                 V4L1_VidCapManager(V4L1_DeviceDescriptor* dd, V4L1_FormatManager* fmt_mgr, int nbufs = DEFAULT_BUFFERS);
00076                 
00077                 virtual ~V4L1_VidCapManager();
00078                 
00079                 int init();
00080                 
00081                 int destroy();
00082                 
00083                 int startCapture();
00084 
00085                 int stopCapture();
00086                 
00087                 int getNumIOBuffers();
00088                 
00089         private:
00090                 int start_read();
00091 
00092                 int start_mmap();
00093 
00094                 int stop_read();
00095                 
00096                 int stop_mmap();
00097 
00098                 IOBuffer* dequeue();
00099                 
00100                 int enqueue(IOBuffer* buf);
00101                 
00102                 IOBuffer* findBuffer(int index);
00103                 
00104                 static void run(void* mgr);
00105                 
00106                 void clearBuffers();
00107                 
00108                 int getUsedBufferCount();
00109         };
00110 };
00111 #endif // V4L1_VIDCAPMANAGER_H_

Generated on Mon Nov 30 11:10:30 2009 for avcap-0.1 by  doxygen 1.5.1