You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
76 lines
1.4 KiB
76 lines
1.4 KiB
/***************************************************************************************
|
|
*
|
|
* videodev.cc is part of SimpleSkyCam.
|
|
*
|
|
*****************************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <fcntl.h>
|
|
#include <sys/ioctl.h>
|
|
#include <linux/videodev2.h>
|
|
|
|
#include <list>
|
|
#include <string>
|
|
|
|
#include "video.h"
|
|
|
|
|
|
VideoDev::VideoDev() {
|
|
conf_device = "";
|
|
conf_devicename = "";
|
|
status = VDEV_STATUS_OK;
|
|
callback = NULL;
|
|
};
|
|
|
|
|
|
VideoDev::~VideoDev() {
|
|
Stop();
|
|
}
|
|
|
|
|
|
//
|
|
// return list of devices in form of /dev/videoYY [Name]
|
|
int VideoDev::GetDeviceList(std::list<std::string> *list) {
|
|
std::string device;
|
|
int devnum;
|
|
|
|
if (list == NULL) return 0;
|
|
|
|
list->clear();
|
|
for (devnum = 0; devnum < 255; devnum++) {
|
|
device = "/dev/video"+std::to_string(devnum);
|
|
|
|
if (device.compare (conf_device) != 0) {
|
|
int fd;
|
|
struct v4l2_capability vcap;
|
|
|
|
if((fd = open(device.c_str(), O_RDONLY)) == -1){
|
|
continue;
|
|
}
|
|
|
|
if(ioctl(fd, VIDIOC_QUERYCAP, &vcap) == -1)
|
|
strncpy ((char*)&vcap.card, "unknown", sizeof(vcap.card));
|
|
close(fd);
|
|
device += " [" + (std::string) ((char*)vcap.card) + "]";
|
|
}
|
|
else {
|
|
device += " [" + (std::string) conf_devicename + "]";
|
|
}
|
|
|
|
list->push_back(device);
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
|
|
int VideoDev::Start(std::string dev, gboolean (*callback_func)(gpointer data)) {
|
|
return VDEV_STATUS_ERROR;
|
|
};
|
|
|
|
|
|
int VideoDev::Stop() {
|
|
return VDEV_STATUS_OK;
|
|
}
|