#ifndef _QT_VIDEO_GRABBER
#define _QT_VIDEO_GRABBER

#include "ofConstants.h"
#include "ofQtUtils.h"
#include "ofTexture.h"

//-----------------------------------------
// 		windows users check out winvdig:
//
// 		-[wvdig free]-
// 		http://www.vdig.com/WinVDIG/
// 		but maybe older versions are better (at least w/ quicktime < 7.0)
//		try this one: (v 0.99)
//		www.vjshow.net/vart/WinVDIG_099.exe 
//		uninstall instructions for winvdig in the winvdig forum
//		http://www.videoscript.com/forum/viewtopic.php?t=21
// 		
// 		-[wvdig $]-
// 		(also, www.abstractplane.com/products/vdig.jsp)
//		never tried...
// 		30 day demo available
// 	
//  	you will need a vdig to see video
//  	try "hackTv" to test if you can use 
//  	quicktime to grab video
//		(pc) 		ftp://ftp.apple.com/developer/Quicktime/Windows_Tools/Programmers_Tools/Hack_TV/Hack_TV.zip
//		(mac)		ftp://ftp.apple.com/developer/Quicktime/Tools/Programmers_Tools/Hack_TV.sit.hqx
// 
//		very good info here: 
//		http://www.proce55ing.net/reference/libraries/video/
//		(java stuff doesn't apply, but info on winvdig, vdig, etc)
// 		
//		windows / direct show thoughts:
// 		dShow capture via dsVideoLib coming soon ...
//		it's a c++ compiled lib, and tremendously difficult to work
// 		in different c++ compilers. dope lib, but trouble with dev-c++...
//		look also at the reactable video input, useful?
//		wraps also v4l...
// 		other cross platform video input options?
//		- opencv (cvAux?)
//-----------------------------------------

// todo:
//		-enumerate devices (ala wengo?)
//		-enumerate inputs
//		-allow input selection
// 		-ntsc, pal format options...
// 		-callback, via SGSetDataProc - couldn't get this to work yet
// 		image decompress options ala mung...



//---------------------------------------------
// this struct has all the info we need to grab pixels
// 
typedef struct {
	unsigned char * 	offscreenGWorldPixels;	// 32 bit: argb (qt k32ARGBPixelFormat)	
	unsigned char * 	pixels;					// 24 bit: rgb
	int 				w,h;
	bool 				bHavePixelsChanged;
	GWorldPtr 			videogworld;
	SeqGrabComponent	gSeqGrabber;
	SGChannel 			gVideoChannel;
	Rect				videoRect;	
} videoGrabberData;
//---------------------------------------------


class ofQtVideoGrabber{

	public :
	
		ofQtVideoGrabber();		
		
		bool 			isFrameNew();
		void			grabFrame();
		void			close();
		void 			initGrabber(int w, int h);
		void			initGrabber(int w, int h, bool bTexture);
		void			videoSettings();
		unsigned char 	* getPixels();
		void 			setVerbose(bool bTalkToMe);
		void 			setShowDialog(bool bTalkToMe);
		
		void 			setUseTexture(bool bUse);
		void 			draw(float x, float y, float w, float h);	
		void 			draw(float x, float y);	
		
		int 			width, height;
		
	private:
		
		bool 					bSgGrabberInited;
        videoGrabberData * 		vgd;
        bool 					bVerbose;
        bool					bShowDialog;
			
        ofTexture 				tex;
		bool					bUseTexture;
	
		
}; 




#endif
