positioning in videodump playbacks work

master
Steffen Pohle 1 year ago
parent a99e1b52cf
commit 6374acc547

@ -90,7 +90,7 @@ class SER {
void updateHeaderData(void); void updateHeaderData(void);
int64_t differenceLocalUTC(void); int64_t differenceLocalUTC(void);
public: public:
SER(); SER();
~SER(); ~SER();

@ -411,7 +411,7 @@ void cb_video_btnrec (GtkWidget *widget, gpointer data) {
videodev->SetConfig(device, w, h, format, parameter, cb_thread_video); videodev->SetConfig(device, w, h, format, parameter, cb_thread_video);
videodev_thread = g_thread_new(driver.c_str(), videodev_threadprocess_wrapper, NULL); videodev_thread = g_thread_new(driver.c_str(), videodev_threadprocess_wrapper, NULL);
// FIXME: workaround, soltuion should be: create a timer and request all controls // FIXME: workaround, solution should be: create a timer and request all controls
}; };

@ -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;
}; };

@ -39,6 +39,7 @@ private:
uint32_t inframe_nexttime; uint32_t inframe_nexttime;
int inframe_maxsize; int inframe_maxsize;
int inframe_size; int inframe_size;
int fixedframesize;
int Grab(VideoFrameRaw *vf); int Grab(VideoFrameRaw *vf);
int Open(); int Open();

Loading…
Cancel
Save