|
|
|
@ -18,6 +18,7 @@
|
|
|
|
|
VideoDev_VFW::VideoDev_VFW() {
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
cap = NULL;
|
|
|
|
|
camid = -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -40,7 +41,8 @@ int VideoDev_VFW::GetDeviceList(std::list<std::string> *list) {
|
|
|
|
|
for(int i=0; i < 10; i++)
|
|
|
|
|
if(capGetDriverDescription(i, name, sizeof(name), desc, sizeof(desc))) {
|
|
|
|
|
std::string device;
|
|
|
|
|
device = "VfW " + to_string(i) + " " + (string)name + " [" + (string)desc + "]";
|
|
|
|
|
device = "VFW " + to_string(i) + " " + (string)name + " [" + (string)desc + "]";
|
|
|
|
|
printf ("%s:%d %s Found device '%s'\n", __FILE__, __LINE__, __FUNCTION__, device.c_str());
|
|
|
|
|
list->push_back(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -56,20 +58,22 @@ int VideoDev_VFW::GetDeviceList(std::list<std::string> *list) {
|
|
|
|
|
int VideoDev_VFW::Open() {
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
camid = atoi (conf_device.c_str());
|
|
|
|
|
printf ("%s:%d %s Opening VfW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
printf ("%s:%d %s Opening VFW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
|
|
|
|
|
cap = capCreateCaptureWindow("VfW", /*WS_CHILD|WS_VISIBLE*/0, 0, 0, 0, 0, 0/*HWND_MESSAGE*/, camid);
|
|
|
|
|
// connect to driver
|
|
|
|
|
cap = capCreateCaptureWindow("VFW", WS_CHILD|WS_VISIBLE, 0, 0, 700, 700, HWND_MESSAGE, camid);
|
|
|
|
|
if(!cap) {
|
|
|
|
|
printf ("%s:%d %s Could not open VfW id %d window\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
printf ("%s:%d %s Could not open VFW id %d window\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!capDriverConnect(cap, camid)) {
|
|
|
|
|
printf ("%s:%d %s Could not connect to VfW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
printf ("%s:%d %s Could not connect to VFW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// set capture format and size
|
|
|
|
|
capDlgVideoFormat(cap);
|
|
|
|
|
|
|
|
|
|
// get current valid width/height
|
|
|
|
@ -79,7 +83,9 @@ int VideoDev_VFW::Open() {
|
|
|
|
|
w = bi.bmiHeader.biWidth;
|
|
|
|
|
h = bi.bmiHeader.biHeight;
|
|
|
|
|
printf ("%s:%d %s Current capture size is %dx%d\n", __FILE__, __LINE__, __FUNCTION__, w, h);
|
|
|
|
|
inframe_pixfmt = convert_to_pixelformat(conf_format);
|
|
|
|
|
conf_format = convert_from_pixelformat(bi.bmiHeader.biCompression);
|
|
|
|
|
inframe_pixfmt = bi.bmiHeader.biCompression;
|
|
|
|
|
printf ("%s:%d %s Current capture format is %s\n", __FILE__, __LINE__, __FUNCTION__, conf_format.c_str());
|
|
|
|
|
|
|
|
|
|
// try to set the configured width/height
|
|
|
|
|
if(conf_width != -1) {
|
|
|
|
@ -110,8 +116,6 @@ int VideoDev_VFW::Open() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s Current capture format is %s\n", __FILE__, __LINE__, __FUNCTION__, conf_format.c_str());
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -123,7 +127,11 @@ int VideoDev_VFW::Open() {
|
|
|
|
|
int VideoDev_VFW::Close() {
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
capDriverDisconnect(cap);
|
|
|
|
|
if(cap) {
|
|
|
|
|
capDriverDisconnect(cap);
|
|
|
|
|
DestroyWindow(cap);
|
|
|
|
|
cap = NULL;
|
|
|
|
|
}
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -157,12 +165,15 @@ int VideoDev_VFW::CaptureStart() {
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
capPreviewRate(cap, 50); // rate in ms
|
|
|
|
|
capPreview(cap, TRUE);
|
|
|
|
|
|
|
|
|
|
if(!capSetCallbackOnError(cap, VFW_error_callback)) {
|
|
|
|
|
printf ("%s:%d %s Could not set error callback to VfW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
printf ("%s:%d %s Could not set error callback to VFW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!capSetCallbackOnFrame(cap, VFW_frame_callback)) {
|
|
|
|
|
printf ("%s:%d %s Could not set frame callback to VfW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
printf ("%s:%d %s Could not set frame callback to VFW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConvertStart(&cdata, inframe_pixfmt);
|
|
|
|
@ -207,51 +218,6 @@ int VideoDev_VFW::GetDeviceFormats(string device, std::list<string> *formats) {
|
|
|
|
|
|
|
|
|
|
printf ("%s:%d %s\n", __FILE__, __LINE__, __FUNCTION__);
|
|
|
|
|
|
|
|
|
|
camid = atoi (conf_device.c_str());
|
|
|
|
|
cap = capCreateCaptureWindow("VfW", /*WS_CHILD|WS_VISIBLE*/0, 0, 0, 0, 0, 0/*HWND_MESSAGE*/, camid);
|
|
|
|
|
if(!cap) {
|
|
|
|
|
printf ("%s:%d %s Could not open VfW id %d window\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!capDriverConnect(cap, camid)) {
|
|
|
|
|
printf ("%s:%d %s Could not connect to VfW id %d\n", __FILE__, __LINE__, __FUNCTION__, camid);
|
|
|
|
|
return VDEV_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BITMAPINFO bi;
|
|
|
|
|
capGetVideoFormat(cap, &bi, sizeof(BITMAPINFO));
|
|
|
|
|
|
|
|
|
|
string vfwformat;
|
|
|
|
|
DWORD f = bi.bmiHeader.biCompression;
|
|
|
|
|
vfwformat = convert_from_pixelformat(f);
|
|
|
|
|
printf ("%s:%d %s Current capture format is %s\n", __FILE__, __LINE__, __FUNCTION__, vfwformat.c_str());
|
|
|
|
|
formats->push_back(vfwformat);
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
int i = 0;
|
|
|
|
|
DWORD vfwformats[][2] = {{MAKEFOURCC('M','J','P','G'), V4L2_PIX_FMT_MJPEG},
|
|
|
|
|
{MAKEFOURCC('Y','U','V','2'), V4L2_PIX_FMT_YUV2},
|
|
|
|
|
{0, 0}};
|
|
|
|
|
|
|
|
|
|
while(vfwformats[i][0] != 0) {
|
|
|
|
|
bi.bmiHeader.biCompression = vfwformats[i][0];
|
|
|
|
|
if(capSetVideoFormat(cap, &bi, sizeof(BITMAPINFO))) {
|
|
|
|
|
vfwformat = convert_from_pixelformat(vfwformats[i][1]);
|
|
|
|
|
printf ("%s:%d %s Capture format %s works\n", __FILE__, __LINE__, __FUNCTION__, vfwformat.c_str());
|
|
|
|
|
formats->push_back(vfwformat.c_str());
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
vfwformat = convert_from_pixelformat(vfwformats[i][1]);
|
|
|
|
|
printf ("%s:%d %s Capture format %s does not work\n", __FILE__, __LINE__, __FUNCTION__, vfwformat.c_str());
|
|
|
|
|
}
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
capDriverDisconnect(cap);
|
|
|
|
|
cap = NULL;
|
|
|
|
|
camid = -1;
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|