include/avcap/osx/QT_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 #ifndef QT_VIDCAPMANAGER_H_
00025 #define QT_VIDCAPMANAGER_H_
00026 
00027 #include <sys/types.h>
00028 #include <list>
00029 #include <time.h>
00030 #include <pthread.h>
00031 
00032 #include <QuickTime/QuickTime.h>
00033 
00034 #include "CaptureManager.h"
00035 
00036 namespace avcap
00037 {
00038         class QT_DeviceDescriptor;
00039         class QT_FormatManager;
00040         class IOBuffer;
00041         class CaptureHandler;
00042         
00044 
00048         class QT_VidCapManager: public CaptureManager
00049         {
00050         public:
00051 
00052         private:                
00053                 typedef std::list<IOBuffer*> IOBufList_t;
00054 
00055                 QT_DeviceDescriptor     *mQTDeviceDescriptor;
00056                 QT_FormatManager        *mFormatMgr;
00057                 IOBufList_t                     mBuffers;
00058                 TimeScale                       mTimeScale;
00059                 TimeScale                       mLastTime;
00060                 pthread_t*                      mThread;
00061                 pthread_mutex_t         mLock;
00062                 int                                     mFinish;
00063                 long                            mSequence;
00064                 int                                     mNumBufs;
00065                 int                                     mAvailableBuffers;
00066                 ICMDecompressionSessionRef      mDecompSession;
00067 
00068         public:
00069                 QT_VidCapManager(QT_DeviceDescriptor* dd, QT_FormatManager* fmt_mgr, int nbufs);
00070                 
00071                 virtual ~QT_VidCapManager();
00072                 
00073                 int init();
00074                 
00075                 int destroy();
00076                 
00077                 int startCapture();
00078 
00079                 int stopCapture();
00080                 
00081                 virtual IOBuffer* dequeue();
00082 
00083                 virtual int enqueue(IOBuffer* buf);
00084                 
00085                 virtual int getNumIOBuffers();
00086                 
00087         private:
00088                 int startCaptureImpl();
00089                 
00090                 int stopCaptureImpl();
00091 
00092                 void notifyCaptureHandler(void* data, size_t length, size_t bytes_per_row, TimeValue time);
00093 
00094                 int poll();
00095 
00096                 struct timespec getPollTimespec(double fps);
00097 
00098                 int decompressData(void* data, long length, TimeValue timeValue);
00099 
00100                 static OSErr captureCallback(SGChannel ch, Ptr data, long data_len, long * offset, 
00101                         long ch_ref_con, TimeValue time_value, short write_type, long priv);
00102 
00103                 OSErr captureCallbackImpl(SGChannel ch, Ptr data, long data_len, long * offset, 
00104                         long ch_ref_con, TimeValue time_value, short write_type);
00105 
00106                 int createDecompSession();
00107                 
00108                 static void* threadFunc(void* arg);
00109         
00110                 static void decompTrackingCallback(void *decompressionTrackingRefCon, OSStatus result,
00111                         ICMDecompressionTrackingFlags decompressionTrackingFlags, CVPixelBufferRef pixelBuffer,
00112                         TimeValue64 displayTime, TimeValue64 displayDuration, ICMValidTimeFlags validTimeFlags,
00113                         void *reserved, void *sourceFrameRefCon );
00114 
00115                 void threadFuncImpl();
00116                 
00117                 void clearBuffers();
00118         };
00119 }
00120 
00121 #endif // QT_VIDCAPMANAGER_H
00122 

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