#ifndef __MODULE_H #define __MODULE_H #include #include #include #include using namespace std; class VideoCodecControl; struct DRVR { UINT uDriverSignature; HINSTANCE hDriverModule; DRIVERPROC DriverProc; DWORD dwDriverID; }; typedef int __attribute__((__stdcall__)) (*DRIVER_PROC)(int,int,int,int,int); class Module { VideoCodecControl& _parent; int forgotten; int _handle; DRVR driver; int _refcount; DRIVER_PROC DriverProc; string _name; string _fullname; public: enum Mode {Compress, Decompress}; Module(string name, VideoCodecControl& parent);//loads module ~Module(); string Name(){return _name;} // int AddRef(){return _refcount++;} int CreateHandle(int compressor, Mode mode); int CloseHandle(int); void ForgetParent(){forgotten=1;} // int Release(); //decreases _refcount, unloads module and erases itself from control if needed int Message(int handle, int message, int arg1, int arg2); }; class VideoCodec { Module* _module; int _handle; public: VideoCodec(Module* module, int compressor, Module::Mode mode); ~VideoCodec(); HRESULT GetFormat(BITMAPINFOHEADER*,BITMAPINFOHEADER*); HRESULT GetDefaultKeyFrameRate(int* lpint); HRESULT GetDefaultQuality(int* lpint); HRESULT CompressBegin( BITMAPINFOHEADER* lpbiInput, BITMAPINFOHEADER* lpbiOutput); HRESULT CompressGetSize( BITMAPINFOHEADER* lpbiInput, BITMAPINFOHEADER* lpbiOutput); HRESULT CompressQuery( BITMAPINFOHEADER* lpbiInput, BITMAPINFOHEADER* lpbiOutput); HRESULT CompressEnd(); HRESULT Compress(long dwFlags,LPBITMAPINFOHEADER lpbiOutput,void* lpData, LPBITMAPINFOHEADER lpbiInput,void* lpBits,long* lpckid, long* lpdwFlags,long lFrameNum,long dwFrameSize,long dwQuality, LPBITMAPINFOHEADER lpbiPrev,void* lpPrev); HRESULT DecompressBegin(BITMAPINFOHEADER* lpbiInput, BITMAPINFOHEADER* lpbiOutput); HRESULT DecompressQuery(BITMAPINFOHEADER* lpbiInput, BITMAPINFOHEADER* lpbiOutput); HRESULT DecompressGetFormat(BITMAPINFOHEADER* lpbiInput, BITMAPINFOHEADER* lpbiOutput); HRESULT DecompressEnd(); HRESULT Decompress(long dwFlags,LPBITMAPINFOHEADER lpbiFormat,void* lpData, const LPBITMAPINFOHEADER lpbi,void* lpBits); }; class VideoCodecControl { friend class Module; std::list _modules; public: VideoCodecControl(){_modules.clear();} VideoCodec* Create(int compressor, const CodecInfo& info, Module::Mode mode); ~VideoCodecControl(); protected: void Erase(Module*); }; extern VideoCodecControl control; #endif