00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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