[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libcvd-members] libcvd cvd/Linux/v4lbuffer.h cvd_src/Linux/v4lb...
From: |
Georg Klein |
Subject: |
[libcvd-members] libcvd cvd/Linux/v4lbuffer.h cvd_src/Linux/v4lb... |
Date: |
Thu, 12 Jul 2007 18:15:33 +0000 |
CVSROOT: /cvsroot/libcvd
Module name: libcvd
Changes by: Georg Klein <georgklein> 07/07/12 18:15:32
Modified files:
cvd/Linux : v4lbuffer.h
cvd_src/Linux : v4lbuffer.cc
Log message:
Allow user-selected FPS for v4lbuffer.
This is useful for uvcvideo devices which default to 15 fps for some
reason.
frames_per_second=0 (which is the default) skips the new code.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd/Linux/v4lbuffer.h?cvsroot=libcvd&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/libcvd/cvd_src/Linux/v4lbuffer.cc?cvsroot=libcvd&r1=1.4&r2=1.5
Patches:
Index: cvd/Linux/v4lbuffer.h
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd/Linux/v4lbuffer.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- cvd/Linux/v4lbuffer.h 21 Feb 2006 17:12:40 -0000 1.3
+++ cvd/Linux/v4lbuffer.h 12 Jul 2007 18:15:32 -0000 1.4
@@ -102,7 +102,7 @@
unsigned char* data;
double when;
};
- V4L2Client(int fd, unsigned int fmt, ImageRef size, int input, bool
fields);
+ V4L2Client(int fd, unsigned int fmt, ImageRef size, int input, bool
fields, int frame_per_second);
ImageRef getSize();
Buffer getFrame();
void releaseFrame(int id);
@@ -123,13 +123,13 @@
template <class T> class V4LBuffer : public VideoBuffer<T>
{
public:
- V4LBuffer(const std::string & dev, ImageRef size, int input=-1, bool
fields=false) : devname(dev)
+ V4LBuffer(const std::string & dev, ImageRef size, int input=-1, bool
fields=false, int frames_per_second=0) : devname(dev)
{
int device = open(devname.c_str(), O_RDWR | O_NONBLOCK);
if (device == -1)
throw Exceptions::V4LBuffer::DeviceOpen(dev);
try {
- v4l2 = new V4L::V4L2Client(device, V4L::format<T>::v4l2_fmt, size,
input, fields);
+ v4l2 = new V4L::V4L2Client(device, V4L::format<T>::v4l2_fmt, size,
input, fields,frames_per_second);
}
catch (std::string& s) {
v4l2 = 0;
Index: cvd_src/Linux/v4lbuffer.cc
===================================================================
RCS file: /cvsroot/libcvd/libcvd/cvd_src/Linux/v4lbuffer.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- cvd_src/Linux/v4lbuffer.cc 23 Feb 2006 13:19:39 -0000 1.4
+++ cvd_src/Linux/v4lbuffer.cc 12 Jul 2007 18:15:32 -0000 1.5
@@ -66,7 +66,7 @@
v4l2_buffer refbuf;
};
- V4L2Client::V4L2Client(int fd, unsigned int fmt, ImageRef size, int input,
bool fields)
+ V4L2Client::V4L2Client(int fd, unsigned int fmt, ImageRef size, int input,
bool fields, int frames_per_second)
{
state = 0;
@@ -138,6 +138,25 @@
if (0 != ioctl(fd, VIDIOC_QBUF, &buffer))
throw string("VIDIOC_QBUF");
}
+
+ // Do we want to manually set FPS?
+ if(frames_per_second != 0)
+ {
+ v4l2_streamparm streamparams;
+ streamparams.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (0 != ioctl(fd, VIDIOC_G_PARM, &streamparams))
+ throw string("VIDIOC_G_PARM");
+
+ // Check if the device has the capability to set a frame-rate.
+ if(streamparams.parm.capture.capability & V4L2_CAP_TIMEPERFRAME)
+ {
+ streamparams.parm.capture.timeperframe.denominator =
frames_per_second;
+ streamparams.parm.capture.timeperframe.numerator = 1;
+ if (0 != ioctl(fd, VIDIOC_S_PARM, &streamparams))
+ throw string("VIDIOC_S_PARM");
+ }
+ }
+
if (0 != ioctl(fd, VIDIOC_STREAMON, &reqbufs.type))
throw string("STREAMON");
state = new State;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [libcvd-members] libcvd cvd/Linux/v4lbuffer.h cvd_src/Linux/v4lb...,
Georg Klein <=