1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
#ifndef AVI_GENERATOR_H
#define AVI_GENERATOR_H
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/utility.hpp>
#include <windows.h>
#include <vfw.h>
#include <string>
#include <list>
class CAVIGenerator : boost::noncopyable {
public:
CAVIGenerator(const std::string& fileName, int videoSizeX, int videoSizeY, DWORD videoFPS);
~CAVIGenerator();
/// Initialize engine and choose codec
bool InitEngine();
/// Returns last error message
std::string GetLastErrorMessage() const {return errorMsg;}
bool readOpenglPixelDataThreaded();
private:
/// name of output file
std::string fileName;
/// Frame rate
DWORD videoFPS;
/// structure contains information for a single stream
BITMAPINFOHEADER bitmapInfo;
/// last error string
std::string errorMsg;
HINSTANCE msvfw32;
HINSTANCE avifil32;
volatile bool quitAVIgen;
boost::thread* AVIThread;
boost::mutex AVIMutex;
boost::condition AVICondition;
std::list<unsigned char*> freeImageBuffers;
std::list<unsigned char*> imageBuffers;
unsigned char* readBuf;
bool initVFW();
HRESULT InitAVICompressionEngine();
/// Release streams allocated for movie compression.
void ReleaseAVICompressionEngine();
/// Adds a frame to the movie.
HRESULT AddFrame(unsigned char* pixelData);
void AVIGeneratorThreadProc();
/// frame counter
long m_lFrame;
/// file interface pointer
PAVIFILE m_pAVIFile;
/// Address of the stream interface
PAVISTREAM m_pStream;
/// Address of the compressed video stream
PAVISTREAM m_pStreamCompressed;
/// Holds compression settings
COMPVARS cv;
typedef DWORD (__stdcall *VideoForWindowsVersion_type)(void);
typedef void (__stdcall *AVIFileInit_type)(void);
typedef HRESULT (__stdcall *AVIFileOpenA_type)(PAVIFILE FAR *, LPCSTR, UINT, LPCLSID);
typedef HRESULT (__stdcall *AVIFileCreateStreamA_type)(PAVIFILE, PAVISTREAM FAR *, AVISTREAMINFOA FAR *);
typedef HRESULT (__stdcall *AVIMakeCompressedStream_type)(PAVISTREAM FAR *, PAVISTREAM, AVICOMPRESSOPTIONS FAR *, CLSID FAR *);
typedef HRESULT (__stdcall *AVIStreamSetFormat_type)(PAVISTREAM, LONG, LPVOID, LONG);
typedef ULONG (__stdcall *AVIStreamRelease_type)(PAVISTREAM);
typedef ULONG (__stdcall *AVIFileRelease_type)(PAVIFILE);
typedef void (__stdcall *AVIFileExit_type)(void);
typedef HRESULT (__stdcall *AVIStreamWrite_type)(PAVISTREAM, LONG, LONG, LPVOID, LONG, DWORD, LONG FAR *, LONG FAR *);
typedef BOOL (__stdcall *ICCompressorChoose_type)(HWND, UINT, LPVOID, LPVOID, PCOMPVARS, LPSTR);
typedef void (__stdcall *ICCompressorFree_type)(PCOMPVARS);
typedef HIC (__stdcall *ICOpen_type)(DWORD, DWORD, UINT);
VideoForWindowsVersion_type VideoForWindowsVersion_ptr;
AVIFileInit_type AVIFileInit_ptr;
AVIFileOpenA_type AVIFileOpenA_ptr;
AVIFileCreateStreamA_type AVIFileCreateStreamA_ptr;
AVIMakeCompressedStream_type AVIMakeCompressedStream_ptr;
AVIStreamSetFormat_type AVIStreamSetFormat_ptr;
AVIStreamRelease_type AVIStreamRelease_ptr;
AVIFileRelease_type AVIFileRelease_ptr;
AVIFileExit_type AVIFileExit_ptr;
AVIStreamWrite_type AVIStreamWrite_ptr;
ICCompressorChoose_type ICCompressorChoose_ptr;
ICCompressorFree_type ICCompressorFree_ptr;
ICOpen_type ICOpen_ptr;
};
#endif /* AVI_GENERATOR_H */
|