#include "windows.h"
#define ESCAPI_DEFINITIONS_ONLY
#include "escapi.h"
#define MAXDEVICES 16
extern struct SimpleCapParams gParams[];
extern int gDoCapture[];
extern HRESULT InitDevice(int device);
extern void CleanupDevice(int device);
extern int CountCaptureDevices();
extern void GetCaptureDeviceName(int deviceno, char * namebuffer, int bufferlength);
extern void CheckForFail(int device);
extern int GetErrorCode(int device);
extern int GetErrorLine(int device);
extern float GetProperty(int device, int prop);
extern int GetPropertyAuto(int device, int prop);
extern int SetProperty(int device, int prop, float value, int autoval);
BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
extern "C" void __declspec(dllexport) getCaptureDeviceName(unsigned int deviceno, char *namebuffer, int bufferlength)
{
if (deviceno > MAXDEVICES)
return;
GetCaptureDeviceName(deviceno, namebuffer, bufferlength);
}
extern "C" int __declspec(dllexport) ESCAPIDLLVersion()
{
return 0x200; }
extern "C" int __declspec(dllexport) ESCAPIVersion()
{
return 0x300; }
extern "C" int __declspec(dllexport) countCaptureDevices()
{
int c = CountCaptureDevices();
return c;
}
extern "C" void __declspec(dllexport) initCOM()
{
CoInitialize(NULL);
}
extern "C" int __declspec(dllexport) initCapture(unsigned int deviceno, struct SimpleCapParams *aParams)
{
if (deviceno > MAXDEVICES)
return 0;
gDoCapture[deviceno] = 0;
gParams[deviceno] = *aParams;
if (FAILED(InitDevice(deviceno))) return 0;
return 1;
}
extern "C" void __declspec(dllexport) deinitCapture(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return;
CleanupDevice(deviceno);
}
extern "C" void __declspec(dllexport) doCapture(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return;
CheckForFail(deviceno);
gDoCapture[deviceno] = -1;
}
extern "C" int __declspec(dllexport) isCaptureDone(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return 0;
CheckForFail(deviceno);
if (gDoCapture[deviceno] == 1)
return 1;
return 0;
}
extern "C" int __declspec(dllexport) getCaptureErrorLine(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return 0;
return GetErrorLine(deviceno);
}
extern "C" int __declspec(dllexport) getCaptureErrorCode(unsigned int deviceno)
{
if (deviceno > MAXDEVICES)
return 0;
return GetErrorCode(deviceno);
}
extern "C" float __declspec(dllexport) getCapturePropertyValue(unsigned int deviceno, int prop)
{
if (deviceno > MAXDEVICES)
return 0;
return GetProperty(deviceno, prop);
}
extern "C" int __declspec(dllexport) getCapturePropertyAuto(unsigned int deviceno, int prop)
{
if (deviceno > MAXDEVICES)
return 0;
return GetPropertyAuto(deviceno, prop);
}
extern "C" int __declspec(dllexport) setCaptureProperty(unsigned int deviceno, int prop, float value, int autoval)
{
if (deviceno > MAXDEVICES)
return 0;
return SetProperty(deviceno, prop, value, autoval);
}