-
Notifications
You must be signed in to change notification settings - Fork 0
/
escapi.h
105 lines (84 loc) · 3.39 KB
/
escapi.h
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
/* Extremely Simple Capture API */
struct SimpleCapParams
{
/* Target buffer.
* Must be at least mWidth * mHeight * sizeof(int) of size!
*/
int * mTargetBuf;
/* Buffer width */
int mWidth;
/* Buffer height */
int mHeight;
};
/* Sets up the ESCAPI DLL and the function pointers below. Call this first! */
/* Returns number of capture devices found (same as countCaptureDevices, below) */
//extern int setupESCAPI();
/* return the number of capture devices found */
typedef int (*countCaptureDevicesProc)();
extern countCaptureDevicesProc countCaptureDevices;
/* initCapture tries to open the video capture device.
* Returns 0 on failure, 1 on success.
* Note: Capture parameter values must not change while capture device
* is in use (i.e. between initCapture and deinitCapture).
* Do *not* free the target buffer, or change its pointer!
*/
typedef int (*initCaptureProc)(unsigned int deviceno, struct SimpleCapParams *aParams);
extern initCaptureProc initCapture;
/* deinitCapture closes the video capture device. */
typedef void (*deinitCaptureProc)(unsigned int deviceno);
extern deinitCaptureProc deinitCapture;
/* doCapture requests video frame to be captured. */
typedef void (*doCaptureProc)(unsigned int deviceno);
extern doCaptureProc doCapture;
/* isCaptureDone returns 1 when the requested frame has been captured.*/
typedef int (*isCaptureDoneProc)(unsigned int deviceno);
extern isCaptureDoneProc isCaptureDone;
/* Get the user-friendly name of a capture device. */
typedef void (*getCaptureDeviceNameProc)(unsigned int deviceno, char *namebuffer, int bufferlength);
extern getCaptureDeviceNameProc getCaptureDeviceName;
/* Returns the ESCAPI DLL version. 0x200 for 2.0 */
typedef int (*ESCAPIDLLVersionProc)();
extern ESCAPIDLLVersionProc ESCAPIDLLVersion;
countCaptureDevicesProc countCaptureDevices;
initCaptureProc initCapture;
deinitCaptureProc deinitCapture;
doCaptureProc doCapture;
isCaptureDoneProc isCaptureDone;
getCaptureDeviceNameProc getCaptureDeviceName;
ESCAPIDLLVersionProc ESCAPIDLLVersion;
/* Internal: initialize COM */
typedef void (*initCOMProc)();
initCOMProc initCOM;
int setupESCAPI()
{
/* Load DLL dynamically */
HMODULE capdll = LoadLibrary("escapi.dll");
if (capdll == NULL)
return 0;
/* Fetch function entry points */
countCaptureDevices = (countCaptureDevicesProc)GetProcAddress(capdll, "countCaptureDevices");
initCapture = (initCaptureProc)GetProcAddress(capdll, "initCapture");
deinitCapture = (deinitCaptureProc)GetProcAddress(capdll, "deinitCapture");
doCapture = (doCaptureProc)GetProcAddress(capdll, "doCapture");
isCaptureDone = (isCaptureDoneProc)GetProcAddress(capdll, "isCaptureDone");
initCOM = (initCOMProc)GetProcAddress(capdll, "initCOM");
getCaptureDeviceName = (getCaptureDeviceNameProc)GetProcAddress(capdll, "getCaptureDeviceName");
ESCAPIDLLVersion = (ESCAPIDLLVersionProc)GetProcAddress(capdll, "ESCAPIDLLVersion");
/* Check that we got all the entry points */
if (initCOM == NULL ||
ESCAPIDLLVersion == NULL ||
getCaptureDeviceName == NULL ||
countCaptureDevices == NULL ||
initCapture == NULL ||
deinitCapture == NULL ||
doCapture == NULL ||
isCaptureDone == NULL)
return 0;
/* Verify DLL version */
if (ESCAPIDLLVersion() != 0x200)
return 0;
/* Initialize COM.. */
initCOM();
/* and return the number of capture devices found. */
return countCaptureDevices();
}