00001
00002
00003 #ifndef __DSHOWCB_H
00004 #define __DSHOWCB_H
00005
00006 #include <atlbase.h>
00007 #include <windows.h>
00008 #include <dshow.h>
00009 #include <qedit.h>
00010
00011 #include "videosource.h"
00012
00013 class DShowCB : public VideoSource {
00014 public:
00015 virtual bool initialize();
00016 virtual bool getFrame(IplImage *dst);
00017 virtual void getSize(int &width, int &height);
00018 DShowCB();
00019 virtual ~DShowCB();
00020 virtual void start();
00021 virtual void stop();
00022 virtual bool isPlaying() { return g_psCurrent == Playing; };
00023 virtual int getId() { return (int) lastFrame; };
00024 virtual const char *getStreamName() const { return filename ? filename : "DShow live capture"; }
00025 virtual const char *getStreamType() const { return "DShowCB"; }
00026
00027 private:
00028 enum PLAYSTATE {Stopped, Paused, Playing};
00029
00030 CComPtr< ISampleGrabber > pGrabber;
00031 CComPtr< IGraphBuilder > pGraph;
00032 CComPtr< IVideoWindow > pVideoWindow;
00033 ICaptureGraphBuilder2 * m_pCapture;
00034 IMediaControl * m_pMC;
00035
00036 PLAYSTATE g_psCurrent;
00037 const char *filename;
00038
00039 IplImage *image;
00040
00041 int frameCnt;
00042
00043 LONGLONG duration, lastFrame;
00044
00045 HRESULT FindCaptureDevice(IBaseFilter ** ppSrcFilter);
00046 };
00047
00048 class DShowCBFactory : public ParticularVSFactory {
00049 public:
00050 DShowCBFactory() { name="DShowCB"; };
00051 virtual void registerParameters(ParamSection *sec);
00052 virtual VideoSource *construct();
00053 private:
00054 bool use;
00055 };
00056
00057 void deinterlaceAndResize(IplImage *src, IplImage *dst);
00058
00059 #endif
00060