|
|
@ -249,6 +249,8 @@ int VideoDev_Dumpfile::Grab(VideoFrameRaw *vf) {
|
|
|
|
|
|
|
|
|
|
|
|
LockMutex();
|
|
|
|
LockMutex();
|
|
|
|
vf->CopyFrom(pixformat, w, h, inframe_size, inframe);
|
|
|
|
vf->CopyFrom(pixformat, w, h, inframe_size, inframe);
|
|
|
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
|
|
|
|
|
|
|
ctrl = vidctrls.begin();
|
|
|
|
ctrl = vidctrls.begin();
|
|
|
|
if (ctrl->value == 0) {
|
|
|
|
if (ctrl->value == 0) {
|
|
|
|
// fixed framesize -> calculate frames
|
|
|
|
// fixed framesize -> calculate frames
|
|
|
@ -262,10 +264,10 @@ int VideoDev_Dumpfile::Grab(VideoFrameRaw *vf) {
|
|
|
|
fixedframesize = 4 * w * h;
|
|
|
|
fixedframesize = 4 * w * h;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case(V4L2_PIX_FMT_SGRBG8):
|
|
|
|
case(V4L2_PIX_FMT_SGRBG8):
|
|
|
|
fixedframesize = 2 * w * h;
|
|
|
|
fixedframesize = 1 * w * h;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case(V4L2_PIX_FMT_SGRBG16):
|
|
|
|
case(V4L2_PIX_FMT_SGRBG16):
|
|
|
|
fixedframesize = 4 * w * h;
|
|
|
|
fixedframesize = 2 * w * h;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
ctrl->max = 0;
|
|
|
|
ctrl->max = 0;
|
|
|
@ -279,11 +281,11 @@ int VideoDev_Dumpfile::Grab(VideoFrameRaw *vf) {
|
|
|
|
|
|
|
|
|
|
|
|
if (ctrl->value != -1) ctrl->value++;
|
|
|
|
if (ctrl->value != -1) ctrl->value++;
|
|
|
|
|
|
|
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// read next frame
|
|
|
|
// read next frame
|
|
|
|
|
|
|
|
LockMutex();
|
|
|
|
ReadFrame();
|
|
|
|
ReadFrame();
|
|
|
|
|
|
|
|
UnLockMutex();
|
|
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -337,7 +339,7 @@ int VideoDev_Dumpfile::ReadFrame() {
|
|
|
|
// allocate memory and read frame
|
|
|
|
// allocate memory and read frame
|
|
|
|
if (inframe == NULL) {
|
|
|
|
if (inframe == NULL) {
|
|
|
|
Close();
|
|
|
|
Close();
|
|
|
|
printf ("%s:%d cloud not allocate enought memory\n", __FILE__, __LINE__);
|
|
|
|
printf ("%s:%d could not allocate enough memory\n", __FILE__, __LINE__);
|
|
|
|
return VDEV_CBSTATUS_ERROR;
|
|
|
|
return VDEV_CBSTATUS_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (read (fd, inframe, inframe_size) != inframe_size) {
|
|
|
|
if (read (fd, inframe, inframe_size) != inframe_size) {
|
|
|
@ -360,20 +362,40 @@ int VideoDev_Dumpfile::ReadFrame() {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int VideoDev_Dumpfile::SetDevCtrl(unsigned int id, int value) {
|
|
|
|
int VideoDev_Dumpfile::SetDevCtrl(unsigned int id, int value) {
|
|
|
|
std::list<VideoDevCtrl>::iterator ctrl;
|
|
|
|
std::list<VideoDevCtrl>::iterator ctrl;
|
|
|
|
|
|
|
|
int framerest;
|
|
|
|
|
|
|
|
off_t newfilepos = 0;
|
|
|
|
printf ("%s:%d VideoDev_Dumpfile::SetDevCtrl Set Offset to %d id:%d fixedframesize:%d\n", __FILE__, __LINE__, value, id, fixedframesize);
|
|
|
|
printf ("%s:%d VideoDev_Dumpfile::SetDevCtrl Set Offset to %d id:%d fixedframesize:%d\n", __FILE__, __LINE__, value, id, fixedframesize);
|
|
|
|
|
|
|
|
struct timeval curtv;
|
|
|
|
|
|
|
|
|
|
|
|
if (id == 1) {
|
|
|
|
if (id == 1) {
|
|
|
|
ctrl = vidctrls.begin();
|
|
|
|
ctrl = vidctrls.begin();
|
|
|
|
if (value != ctrl->value && value < ctrl->max) {
|
|
|
|
if (value != ctrl->value && value < ctrl->max) {
|
|
|
|
filepos = SIZE_DUMPHEADER + (value * (SIZE_FRAMEHEADER + fixedframesize));
|
|
|
|
filepos = SIZE_DUMPHEADER + ((off_t)value * (SIZE_FRAMEHEADER + (off_t)fixedframesize));
|
|
|
|
ctrl->value = value;
|
|
|
|
printf ("%s:%d filepos:%ld\n", __FILE__, __LINE__, filepos);
|
|
|
|
if (lseek (fd, filepos, SEEK_SET) < 0) {
|
|
|
|
|
|
|
|
|
|
|
|
if ((newfilepos = lseek (fd, filepos, SEEK_SET)) < 0) {
|
|
|
|
printf ("%s:%d ******* lseek error:%s\n", __FILE__, __LINE__, strerror(errno));
|
|
|
|
printf ("%s:%d ******* lseek error:%s\n", __FILE__, __LINE__, strerror(errno));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
framerest = (newfilepos - SIZE_DUMPHEADER)%(SIZE_FRAMEHEADER + fixedframesize);
|
|
|
|
|
|
|
|
ctrl->value = (newfilepos - SIZE_DUMPHEADER)/(SIZE_FRAMEHEADER + fixedframesize);
|
|
|
|
|
|
|
|
if (ctrl->value != value || framerest != 0) {
|
|
|
|
|
|
|
|
printf ("%s:%d could not set file to correct position. ctrl->value:%d value:%d Framerest:%d\n", __FILE__, __LINE__, ctrl->value, value, framerest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// read first frame
|
|
|
|
|
|
|
|
ReadFrame();
|
|
|
|
|
|
|
|
gettimeofday(&curtv, NULL);
|
|
|
|
|
|
|
|
starttv.tv_sec = curtv.tv_sec - (inframe_nexttime/1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else printf ("%s:%d could not set video position (ctrl->value:%d value:%d max:%d)\n",
|
|
|
|
|
|
|
|
__FILE__, __LINE__, ctrl->value, value, ctrl->max);
|
|
|
|
// else printf ("%s:%d could not set video position (ctrl->value:%d value:%d max:%d)\n",
|
|
|
|
|
|
|
|
// __FILE__, __LINE__, ctrl->value, value, ctrl->max);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|