Knowledge Base Nr: 00194 VideoSupport.cpp - http://www.swe-kaiser.de

Downloads:

Win32: Video for Windows (VfW) Unterstützung
(u.a. Grabben und als JPG speichern)

  
#include <vfw.h>

enum VS_MODE { VS_NONE,
VS_768x576, VS_384x288, VS_192x144, //Hauppauge WinTV Go
VS_640x480, VS_352x288, VS_320x240, VS_176x144, VS_160x120, VS_128x96, //DEXXA WebCam
VS_ILLEGAL
};

class CVideoSupport
{
public:
CVideoSupport();
virtual ~CVideoSupport();

const char* GetLastError();
void SetDebug(bool bDebug) { m_bDebug = bDebug; }

int Init(CWnd* pWnd, int nDeviceIndex = 0, BOOL bVisible = TRUE, BOOL bPreview = FALSE);
int Exit();

int RecordAVIStart(const char* lpszFilename);
int RecordAVIAddFrame();
int RecordAVIEnd();

int DoOverlay(BOOL bDo);
int DoPreview(BOOL bDo);
int DoStopDisplay();

//interface zu videoserver
//source: 0:tv 1:composite
static int ServerOnOff(bool bOn, VS_MODE eMode, int nSource);
static int GetServerPicture(CString* pstrFilename);
static int GetServerPicture(CImageSupport* pImage);

int InfoDialog();
int DoSettings();
int SetFrameSize(VS_MODE eMode);

int SetVideoSource(const char* szKeys);
int SetVideoFormat(const char* szKeys);

//ein hash als letztes zeichen in lpszFileName blendet setup-dialoge ein
int GrabFrame(const char* lpszFilename, BOOL bStop = FALSE);
int GrabAndSaveSingleFrame(CWnd* pWnd, BOOL bVisible, BOOL bPreview
, char* szFileName, VS_MODE eMode);

CImageSupport* GetImage() { return &s_image; }

protected:
static HWND s_hWndC;

static CString s_strJPGfile;
static CImageSupport s_image;
static bool volatile s_bGrabbed;

CString m_strLastError;
bool m_bDebug;

static CString s_strSetupDlg;
static LRESULT PASCAL FrameCallbackProc(HWND hWnd, LPVIDEOHDR lpVHdr);

static DWORD WINAPI SetupDialog(LPVOID lpParameter);
void WaitForInputIdle();
};