📄 capture.h
字号:
// capture.h
// Emmanuel Grolleau (c) 2002
// This file is a part of AviCapTcl
// Describes the class CCapture which uses VFW to implement
// a Tk widget that captures a video or image from a source
// Version 1.0.0.0
// Last modification 01/05/2002
#ifndef _CCAPTURE_H_
#define _CCAPTURE_H_
#include <afxwin.h>
#include <vfw.h>
#include <tk.h>
#include "avifile.h"
#include "avitimer.h"
#define MAXCAPDRIVERS 10
// maximum drivers list size
typedef VOID (CALLBACK *PROGRESSCALLBACK)(LPSTR , DWORD);
typedef LRESULT (CALLBACK *FRAMECALLBACK)(HWND , LPVIDEOHDR);
typedef LRESULT (CALLBACK *ERRORCALLBACK)(HWND , int , LPCSTR);
#define TCL_CALLBK_NOTCOMPRESSED 0
// The tcl frame callbacks are called with uncompressed data
#define TCL_CALLBK_COMPRESSED 1
// The tcl frame callbacks are called with compressed data
#define TCL_CALLBK_BOTH 2
// The tcl frame callbacks are called with both compressed and uncompressed data
class CCapture {
public:
static void GetDriversList(CStringArray &Names);
// Names contains the names of all the drivers
CCapture(const CString name,Tcl_Interp *interp,BOOL &ok,int w=320,int h=240);
// Constructor of a capture widget
// name is yhe tclname
// ok is true iff no error occurred while creating the window
~CCapture();
// Destructor
LPBITMAPINFO GetBitmapInfo();
// returns uncompressed bmihdr
static CCapture *FindFromHwnd(HWND hwnd);
// Connection & deconnection
BOOL Connect(int indx);
//connect by index
BOOL Disconnect();
BOOL Preview(int rate);
// Start/Stop preview: if rate is greater than 0, then starts
// preview at the specified rate in milliseconds, if rate is 0 then
// stops preview
BOOL Overlay(BOOL onoff);
// Start/Stop overlay
//Standard AVICap window Dialogs
BOOL CompressDlg(char fccHandler[4]);
BOOL DisplayDlg();
BOOL FormatDlg();
BOOL VSourceDlg();
// Capture functions
BOOL GetCaptureSetup(CAPTUREPARMS *parms);
BOOL SetCaptureSetup(CAPTUREPARMS *parms);
BOOL SetCaptureFile(LPSTR pathname);
BOOL GetCaptureStatus(CAPSTATUS *stat);
BOOL StartCapture();
BOOL StartSeq();
BOOL StopCapture();
CAVIFile *_avifile; // current avi file for capture
long TimeFrame();
// Compression functions
BOOL BeginCompression(); // Initiates compression
BOOL EndCompression(); // End compression
BOOL IsCompressed(); // Returns true if the user selected a compression format other than "not compressed"
BOOL CompressionStarted(); // Returns true if in context compression
PCOMPVARS GetCompressor();
void SetCompressor(PCOMPVARS compvars);
LPVOID Compress(LPVOID data,long *size,BOOL *isIndex);
LPVOID DefaultCompressCallbackAction(LPVIDEOHDR lpVHdr); // called in order to compress frame into the avifile
// Callback functions, the first parameter is the Tcl_Obj containing the tcl function
// to call on callback, the second is one of TCL_CALLBK_NOTCOMPRESSED
// TCL_CALLBK_COMPRESSED TCL_CALLBK_BOTH
BOOL SetTclVideoStreamCallback(Tcl_Obj *o,int compressed);
BOOL SetTclWaveStreamCallback(Tcl_Obj *o);
BOOL SetTclYieldCallback(Tcl_Obj *o);
BOOL SetTclFrameCallback(Tcl_Obj *o,int compressed);
BOOL SetTclErrorCallback(Tcl_Obj *o);
void Debug(char * txt);
// Calls a tcl function called "Debug", giving it txt as argument
protected:
static LPTOP_LEVEL_EXCEPTION_FILTER _pastExceptionHandler;
// Exception handling functions
static void FreeAllDrivers();
// Called by an exception handler in order to destroy all the Capture objects
// and to free the drivers
friend LONG WINAPI exceptionhandler (LPEXCEPTION_POINTERS arg);
// Exception handler
friend LRESULT PASCAL TclVideoStreamCallback(HWND hWnd, LPVIDEOHDR lpVHdr);
friend LRESULT PASCAL TclWaveStreamCallback(HWND hWnd, LPWAVEHDR lpVHdr);
friend LRESULT CALLBACK TclYieldCallback(HWND hWnd);
friend LRESULT PASCAL TclFrameCallback(HWND hWnd, LPVIDEOHDR lpVHdr);
friend LRESULT CALLBACK TclErrorCallback(HWND hWnd,int nID,LPCSTR lpsz);
BOOL _getBITMAPINFO(); // retrieves the BITMAPINFO associated to capture device
static CCapture *FindCapture(const CString tclname);
// Returns the CCapture instance corresponding to tclname
// null if it does not exist
static void AddCapture(CCapture* cap);
// Adds a CCapture instance to the list of instances
static void RemoveCapture(const CCapture *cap);
// Removes a CCapture instance from the list of instances
static class cell {
// Linked list of all the instances of a CCapture
public:
CCapture *cap;
cell * suiv;
cell(CCapture *c,cell *s):cap(c),suiv(s) {};
};
void _clearAllCb();
// Removes any callback function
static cell *_allCaptures;
// List of all the instances of a CCapture
static nb_capwindow;
Tk_Window tkwin;
void _selfInit();
BOOL _connected;
BOOL _preview;
BOOL _overlay;
BOOL _compressionstarted;
LPBITMAPINFO _bmpInfo;
COMPVARS _compvars;
CString tclname;
Tcl_Interp *tclinterp;
HWND tk_hwnd,capHwnd;
LPVOID _VideoStreamCb;
LPVOID _WavStreamCb;
PROGRESSCALLBACK _YieldCb;
FRAMECALLBACK _FrameCb;
LPVOID _ErrorCb;
AVITimer *_timer;
// Tcl callback functions
Tcl_Obj* _tcl_VideoStreamCb;
int _tcl_VideoStreamCbCompression;
// 0 for uncompressed frames, 1 for compressed frames,
// 2 for both compressed and uncompressed frames
Tcl_Obj* _tcl_WaveStreamCb;
Tcl_Obj* _tcl_YieldCb;
Tcl_Obj* _tcl_FrameCb;
int _tcl_FrameCbCompression;
Tcl_Obj* _tcl_ErrorCb;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -