forked from jarikomppa/escapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathescapi_dll.cpp
140 lines (116 loc) · 2.76 KB
/
escapi_dll.cpp
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#include "windows.h"
#define ESCAPI_DEFINITIONS_ONLY
#include "escapi/escapi.h"
#define MAXDEVICES 16
extern struct SimpleCapParams gParams[];
extern int gDoCapture[];
extern int gOptions[];
HRESULT InitDevice(int device);
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
void getCaptureDeviceName(unsigned int deviceno, char *namebuffer, int bufferlength)
{
if (deviceno > MAXDEVICES)
return;
GetCaptureDeviceName(deviceno, namebuffer, bufferlength);
}
int ESCAPIDLLVersion()
{
return 0x200; // due to mess up, earlier programs check for exact version; this needs to stay constant
}
int ESCAPIVersion()
{
return 0x301; // ...and let's hope this one works better
}
int countCaptureDevices()
{
int c = CountCaptureDevices();
return c;
}
void initCOM()
{
CoInitialize(NULL);
}
int initCapture(unsigned int deviceno, struct SimpleCapParams *aParams)
{
if (deviceno > MAXDEVICES)
return 0;
if (aParams == NULL || aParams->mHeight <= 0 || aParams->mWidth <= 0 || aParams->mTargetBuf == 0)
return 0;
gDoCapture[deviceno] = 0;
gParams[deviceno] = *aParams;
gOptions[deviceno] = 0;
if (FAILED(InitDevice(deviceno))) return 0;
return 1;
}
void deinitCapture(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return;
CleanupDevice(deviceno);
}
void doCapture(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return;
CheckForFail(deviceno);
gDoCapture[deviceno] = -1;
}
int isCaptureDone(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return 0;
CheckForFail(deviceno);
if (gDoCapture[deviceno] == 1)
return 1;
return 0;
}
int getCaptureErrorLine(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return 0;
return GetErrorLine(deviceno);
}
int getCaptureErrorCode(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return 0;
return GetErrorCode(deviceno);
}
float getCapturePropertyValue(unsigned int deviceno, int prop)
{
if (deviceno > MAXDEVICES)
return 0;
return GetProperty(deviceno, prop);
}
int getCapturePropertyAuto(unsigned int deviceno, int prop)
{
if (deviceno > MAXDEVICES)
return 0;
return GetPropertyAuto(deviceno, prop);
}
int setCaptureProperty(unsigned int deviceno, int prop, float value, int autoval)
{
if (deviceno > MAXDEVICES)
return 0;
return SetProperty(deviceno, prop, value, autoval);
}
int initCaptureWithOptions(unsigned int deviceno, struct SimpleCapParams *aParams, unsigned int aOptions)
{
if (deviceno > MAXDEVICES)
return 0;
if (aParams == NULL || aParams->mHeight <= 0 || aParams->mWidth <= 0 || aParams->mTargetBuf == 0)
return 0;
if ((aOptions & CAPTURE_OPTIONS_MASK) != aOptions)
return 0;
gDoCapture[deviceno] = 0;
gParams[deviceno] = *aParams;
gOptions[deviceno] = aOptions;
if (FAILED(InitDevice(deviceno))) return 0;
return 1;
}