/*************************************************************************************** * * videodev.cc is part of SimpleSkyCam. * *****************************************************************************************/ #include #include #include #include #include #include #include #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 *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; }