|
|
@ -98,6 +98,7 @@ int VideoDev_Dumpfile::GetDeviceList(std::list<std::string> *list) {
|
|
|
|
int VideoDev_Dumpfile::Open() {
|
|
|
|
int VideoDev_Dumpfile::Open() {
|
|
|
|
if (config.readdumppath == NULL) return VDEV_STATUS_ERROR;
|
|
|
|
if (config.readdumppath == NULL) return VDEV_STATUS_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VideoDevCtrl vctl;
|
|
|
|
uint32_t inbuf[3];
|
|
|
|
uint32_t inbuf[3];
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
struct stat s;
|
|
|
|
struct stat s;
|
|
|
@ -145,6 +146,14 @@ int VideoDev_Dumpfile::Open() {
|
|
|
|
pixformat = ntohl(inbuf[i++]);
|
|
|
|
pixformat = ntohl(inbuf[i++]);
|
|
|
|
conf_format = convert_from_pixelformat (pixformat);
|
|
|
|
conf_format = convert_from_pixelformat (pixformat);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vidctrls.clear();
|
|
|
|
|
|
|
|
vctl.name = "FilePosition";
|
|
|
|
|
|
|
|
vctl.id = 1;
|
|
|
|
|
|
|
|
vctl.min = 0;
|
|
|
|
|
|
|
|
vctl.max = 255;
|
|
|
|
|
|
|
|
vctl.value = 0;
|
|
|
|
|
|
|
|
vidctrls.push_back(vctl);
|
|
|
|
|
|
|
|
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -213,9 +222,12 @@ int VideoDev_Dumpfile::CaptureStop() {
|
|
|
|
* If something goes wrong return an error code.
|
|
|
|
* If something goes wrong return an error code.
|
|
|
|
* Return code VDEV_STATUS_AGAIN is not an error. There was no video image ready to read.
|
|
|
|
* Return code VDEV_STATUS_AGAIN is not an error. There was no video image ready to read.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define SIZE_FRAMEHEADER 8
|
|
|
|
|
|
|
|
#define SIZE_DUMPHEADER 12
|
|
|
|
int VideoDev_Dumpfile::Grab(VideoFrameRaw *vf) {
|
|
|
|
int VideoDev_Dumpfile::Grab(VideoFrameRaw *vf) {
|
|
|
|
struct timeval curtv;
|
|
|
|
struct timeval curtv;
|
|
|
|
unsigned int diff = 0;
|
|
|
|
unsigned int diff = 0;
|
|
|
|
|
|
|
|
std::list<VideoDevCtrl>::iterator ctrl;
|
|
|
|
|
|
|
|
|
|
|
|
if (fd == -1) return VDEV_STATUS_ERROR;
|
|
|
|
if (fd == -1) return VDEV_STATUS_ERROR;
|
|
|
|
|
|
|
|
|
|
|
@ -236,6 +248,36 @@ int VideoDev_Dumpfile::Grab(VideoFrameRaw *vf) {
|
|
|
|
|
|
|
|
|
|
|
|
LockMutex();
|
|
|
|
LockMutex();
|
|
|
|
vf->CopyFrom(pixformat, w, h, inframe_size, inframe);
|
|
|
|
vf->CopyFrom(pixformat, w, h, inframe_size, inframe);
|
|
|
|
|
|
|
|
ctrl = vidctrls.begin();
|
|
|
|
|
|
|
|
if (ctrl->value == 0) {
|
|
|
|
|
|
|
|
// fixed framesize -> calculate frames
|
|
|
|
|
|
|
|
switch (pixformat) {
|
|
|
|
|
|
|
|
case(V4L2_PIX_FMT_RGB24):
|
|
|
|
|
|
|
|
case(V4L2_PIX_FMT_BGR24):
|
|
|
|
|
|
|
|
fixedframesize = 3 * w * h;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case(V4L2_PIX_FMT_RGB32):
|
|
|
|
|
|
|
|
case(V4L2_PIX_FMT_BGR32):
|
|
|
|
|
|
|
|
fixedframesize = 4 * w * h;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case(V4L2_PIX_FMT_SGRBG8):
|
|
|
|
|
|
|
|
fixedframesize = 2 * w * h;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case(V4L2_PIX_FMT_SGRBG16):
|
|
|
|
|
|
|
|
fixedframesize = 4 * w * h;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
ctrl->max = 0;
|
|
|
|
|
|
|
|
ctrl->value = -1;
|
|
|
|
|
|
|
|
fixedframesize = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fixedframesize > 0)
|
|
|
|
|
|
|
|
ctrl->max = (filesize-SIZE_DUMPHEADER) / (fixedframesize + SIZE_FRAMEHEADER);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ctrl->value != -1) ctrl->value++;
|
|
|
|
|
|
|
|
|
|
|
|
UnLockMutex();
|
|
|
|
UnLockMutex();
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -313,6 +355,16 @@ int VideoDev_Dumpfile::ReadFrame() {
|
|
|
|
* set video control identified by id
|
|
|
|
* set video control identified by id
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
int VideoDev_Dumpfile::SetDevCtrl(unsigned int id, int value) {
|
|
|
|
int VideoDev_Dumpfile::SetDevCtrl(unsigned int id, int value) {
|
|
|
|
|
|
|
|
std::list<VideoDevCtrl>::iterator ctrl;
|
|
|
|
|
|
|
|
printf ("%s:%d VideoDev_Dumpfile::SetDevCtrl Set Offset to %d id:%d\n", __FILE__, __LINE__, value, id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (id == 1) {
|
|
|
|
|
|
|
|
ctrl = vidctrls.begin();
|
|
|
|
|
|
|
|
if (value != ctrl->value && value < ctrl->max) {
|
|
|
|
|
|
|
|
ctrl->value = value;
|
|
|
|
|
|
|
|
lseek (fd, SEEK_SET, SIZE_DUMPHEADER + (value * (SIZE_FRAMEHEADER + fixedframesize)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
return VDEV_STATUS_OK;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|