include/avcap/linux/V4L2_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 V4L2_VIDCAPMANAGER_H_
00026 #define V4L2_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 V4L2_DeviceDescriptor;
00037         class FormatManager;
00038         class IOBuffer;
00039         class CaptureHandler;
00040 
00042         
00053         class V4L2_VidCapManager: public CaptureManager
00054         {
00055         public:
00056                 enum
00057                 {
00058                         MAX_BUFFERS = 32,       
00059                         DEFAULT_BUFFERS = 16    
00060                 };
00061                 
00062                 enum IOMethod
00063                 {
00064                         IO_METHOD_NOCAP = 0,
00065                 IO_METHOD_READ,
00066                 IO_METHOD_MMAP,
00067                 IO_METHOD_USERPTR,
00068                 };
00069 
00070         private:
00071                 typedef std::list<IOBuffer*> IOBufList;
00072                 
00073                 V4L2_DeviceDescriptor   *mDeviceDescriptor;
00074                 FormatManager           *mFormatMgr;
00075 
00076                 IOBufList                       mBuffers;
00077                 int                                     mNumBufs;
00078                 int                                     mMethod;
00079                 int                                     mState;
00080                 pthread_t*                      mThread;
00081                 int                             mFinish;
00082                 pthread_mutex_t         mLock;
00083                 timeval                         mStartTime;
00084 
00085                 int                             mSequence;
00086                 int                                     mDTNumerator;
00087                 int                                     mDTDenominator;
00088                 int                                     mAvailableBuffers;
00089         
00090         public:
00091                 V4L2_VidCapManager(V4L2_DeviceDescriptor* dd, FormatManager* fmt_mgr, int nbufs = DEFAULT_BUFFERS);
00092                 
00093                 virtual ~V4L2_VidCapManager();
00094                 
00095                 int init();
00096                 
00097                 int destroy();
00098                 
00099                 int startCapture();
00100 
00101                 int stopCapture();
00102                 
00103                 int getNumIOBuffers();
00104 
00105         private:
00106                 int start_read();
00107                 int start_mmap();
00108                 int start_userptr();
00109 
00110                 int stop_read();
00111                 int stop_mmap();
00112                 int stop_userptr();
00113 
00114                 IOBuffer* dequeue();
00115                 int enqueue(IOBuffer* buf);
00116                 
00117                 IOBuffer* findBuffer(int index);
00118                 static void run(void* mgr);
00119                 
00120                 void clearBuffers();
00121                 int getUsedBufferCount();
00122         };
00123 }
00124 
00125 #endif // V4L2_VIDCAPMANAGER_H_

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