|
|
|
@ -21,6 +21,7 @@ VideoDevice_V4L2::VideoDevice_V4L2() {
|
|
|
|
conf_width = 0;
|
|
|
|
conf_width = 0;
|
|
|
|
conf_videodev = "";
|
|
|
|
conf_videodev = "";
|
|
|
|
conf_iomode = 0;
|
|
|
|
conf_iomode = 0;
|
|
|
|
|
|
|
|
conf_videofmt = 0;
|
|
|
|
fd = -1;
|
|
|
|
fd = -1;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -31,7 +32,7 @@ VideoDevice_V4L2::~VideoDevice_V4L2() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight) {
|
|
|
|
int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight, uint32_t pixfmt) {
|
|
|
|
int isrunning = 0;
|
|
|
|
int isrunning = 0;
|
|
|
|
|
|
|
|
|
|
|
|
if (fd != -1) {
|
|
|
|
if (fd != -1) {
|
|
|
|
@ -42,6 +43,7 @@ int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight)
|
|
|
|
conf_videodev = newdevice;
|
|
|
|
conf_videodev = newdevice;
|
|
|
|
conf_width = nwidth;
|
|
|
|
conf_width = nwidth;
|
|
|
|
conf_height = nheight;
|
|
|
|
conf_height = nheight;
|
|
|
|
|
|
|
|
conf_videofmt = pixfmt;
|
|
|
|
|
|
|
|
|
|
|
|
if (isrunning) {
|
|
|
|
if (isrunning) {
|
|
|
|
if (Start() == 0) return 0;
|
|
|
|
if (Start() == 0) return 0;
|
|
|
|
@ -73,7 +75,6 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
struct v4l2_capability vcap;
|
|
|
|
struct v4l2_capability vcap;
|
|
|
|
VideoDevCtrl vctl;
|
|
|
|
VideoDevCtrl vctl;
|
|
|
|
char txt[32];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
debug ("Device: '%s'", conf_videodev.c_str());
|
|
|
|
debug ("Device: '%s'", conf_videodev.c_str());
|
|
|
|
if (fd != -1) return 0;
|
|
|
|
if (fd != -1) return 0;
|
|
|
|
@ -151,7 +152,7 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// fixme: hardcoded video format?????
|
|
|
|
// fixme: hardcoded video format?????
|
|
|
|
fmt.fmt.pix.pixelformat = convert_to_pixelformat(conf_videofmt);
|
|
|
|
fmt.fmt.pix.pixelformat = conf_videofmt;
|
|
|
|
fmt.fmt.pix.field = V4L2_FIELD_NONE;
|
|
|
|
fmt.fmt.pix.field = V4L2_FIELD_NONE;
|
|
|
|
if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) {
|
|
|
|
if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) {
|
|
|
|
debug ("VIDIOC_S_FMT : %s", strerror (errno));
|
|
|
|
debug ("VIDIOC_S_FMT : %s", strerror (errno));
|
|
|
|
@ -170,11 +171,7 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
fmt.fmt.pix.sizeimage = min;
|
|
|
|
fmt.fmt.pix.sizeimage = min;
|
|
|
|
conf_width = fmt.fmt.pix.width;
|
|
|
|
conf_width = fmt.fmt.pix.width;
|
|
|
|
conf_height = fmt.fmt.pix.height;
|
|
|
|
conf_height = fmt.fmt.pix.height;
|
|
|
|
snprintf (txt, 32, "%c%c%c%c", ((char*)&fmt.fmt.pix.pixelformat)[0],
|
|
|
|
conf_videofmt = fmt.fmt.pix.pixelformat;
|
|
|
|
((char*)&fmt.fmt.pix.pixelformat)[1],
|
|
|
|
|
|
|
|
((char*)&fmt.fmt.pix.pixelformat)[2],
|
|
|
|
|
|
|
|
((char*)&fmt.fmt.pix.pixelformat)[3]);
|
|
|
|
|
|
|
|
conf_videofmt = txt;
|
|
|
|
|
|
|
|
PrintFmt (&fmt);
|
|
|
|
PrintFmt (&fmt);
|
|
|
|
|
|
|
|
|
|
|
|
// init buffers
|
|
|
|
// init buffers
|
|
|
|
|