|
|
|
|
@ -5,12 +5,14 @@
|
|
|
|
|
|
|
|
|
|
VideoDevice_V4L2::VideoDevice_V4L2() {
|
|
|
|
|
debug ("");
|
|
|
|
|
conf_height = 0;
|
|
|
|
|
conf_width = 0;
|
|
|
|
|
conf_height = -1;
|
|
|
|
|
conf_width = -1;
|
|
|
|
|
conf_videodev = "";
|
|
|
|
|
conf_videocdev = "";
|
|
|
|
|
conf_iomode = 0;
|
|
|
|
|
conf_videofmt = 0;
|
|
|
|
|
fd = -1;
|
|
|
|
|
cfd = -1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -21,7 +23,7 @@ VideoDevice_V4L2::~VideoDevice_V4L2() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight, uint32_t pixfmt) {
|
|
|
|
|
int VideoDevice_V4L2::SetDevice(std::string newdevice, std::string newcdevice, int nwidth, int nheight, uint32_t pixfmt) {
|
|
|
|
|
int isrunning = 0;
|
|
|
|
|
|
|
|
|
|
if (fd != -1) {
|
|
|
|
|
@ -30,6 +32,7 @@ int VideoDevice_V4L2::SetDevice(std::string newdevice, int nwidth, int nheight,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
conf_videodev = newdevice;
|
|
|
|
|
conf_videocdev = newcdevice;
|
|
|
|
|
conf_width = nwidth;
|
|
|
|
|
conf_height = nheight;
|
|
|
|
|
conf_videofmt = pixfmt;
|
|
|
|
|
@ -65,8 +68,9 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
|
struct v4l2_capability vcap;
|
|
|
|
|
VideoDevCtrl vctl;
|
|
|
|
|
|
|
|
|
|
debug ("Device: '%s'", conf_videodev.c_str());
|
|
|
|
|
debug ("Device: '%s' Ctrl Device: '%s'", conf_videodev.c_str(), conf_videocdev.c_str());
|
|
|
|
|
if (fd != -1) return 0;
|
|
|
|
|
if (cfd != -1) return 0;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// open device and get device name and capabilities | O_NONBLOCK
|
|
|
|
|
@ -75,6 +79,15 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// open device and get device name and capabilities | O_NONBLOCK
|
|
|
|
|
if (conf_videocdev.length() > 0) {
|
|
|
|
|
if((cfd = open(conf_videocdev.c_str(), O_RDWR)) == -1){
|
|
|
|
|
debug ("could not open ctrl device error: %s", strerror(errno));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(ioctl(fd, VIDIOC_QUERYCAP, &vcap) == -1)
|
|
|
|
|
strncpy ((char*)&vcap.card, "unknown", sizeof(vcap.card));
|
|
|
|
|
debug ("VideoDevice_V4L2::Open Devicefile:%s Card:%s fd:%d", conf_videodev.c_str(), vcap.card, fd);
|
|
|
|
|
@ -100,11 +113,13 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
|
memset (&queryctrl, 0, sizeof (queryctrl));
|
|
|
|
|
for (i = V4L2_CID_BASE; i < V4L2_CID_DETECT_CLASS_BASE+0x1000; i++) {
|
|
|
|
|
queryctrl.id = i;
|
|
|
|
|
if (0 == ioctl (fd, VIDIOC_QUERYCTRL, &queryctrl)) {
|
|
|
|
|
if (0 == ioctl (cfd != -1 ? cfd : fd, VIDIOC_QUERYCTRL, &queryctrl)) {
|
|
|
|
|
vctl.name = (char*)queryctrl.name;
|
|
|
|
|
vctl.id = queryctrl.id;
|
|
|
|
|
vctl.min = queryctrl.minimum;
|
|
|
|
|
vctl.max = queryctrl.maximum;
|
|
|
|
|
debug ("CTRL: id:%p name:%s range:%d %d step:%d type:%d", queryctrl.id, queryctrl.name,
|
|
|
|
|
queryctrl.minimum, queryctrl.maximum, queryctrl.step, queryctrl.type);
|
|
|
|
|
GetDevCtrl(queryctrl.id, &vctl.value);
|
|
|
|
|
vidctrls.push_back(vctl);
|
|
|
|
|
}
|
|
|
|
|
@ -147,6 +162,10 @@ int VideoDevice_V4L2::Open() {
|
|
|
|
|
debug ("VIDIOC_S_FMT : %s", strerror (errno));
|
|
|
|
|
close (fd);
|
|
|
|
|
fd = -1;
|
|
|
|
|
if (cfd != -1) {
|
|
|
|
|
close (cfd);
|
|
|
|
|
cfd = -1;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|