diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-19 12:53:11 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-19 12:53:11 +0200 |
commit | 13b76c2363e3fd11df30869f48f9b9ee517129cc (patch) | |
tree | c2396f7edfba2b421e0eed09efa8e3e91c9e8966 /opentrack | |
parent | 71d8892c19b6a1dbfac7d40a3bb6717316e872b9 (diff) |
grab Linux camera names
Diffstat (limited to 'opentrack')
-rw-r--r-- | opentrack/camera-names.hpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/opentrack/camera-names.hpp b/opentrack/camera-names.hpp index 6f82ba34..77945171 100644 --- a/opentrack/camera-names.hpp +++ b/opentrack/camera-names.hpp @@ -13,6 +13,12 @@ # include <unistd.h> #endif +#ifdef __linux +#include <fcntl.h> +#include <sys/ioctl.h> +#include <linux/videodev.h> +#endif + template<typename = void> QList<QString> get_camera_names() { QList<QString> ret; @@ -69,12 +75,23 @@ QList<QString> get_camera_names() { qDebug() << "failed CLSID_VideoInputDeviceCategory" << hr; pSysDevEnum->Release(); -#else +#endif +#ifdef __linux for (int i = 0; i < 16; i++) { char buf[128]; sprintf(buf, "/dev/video%d", i); if (access(buf, R_OK | W_OK) == 0) { - ret.append(buf); + int fd = open(buf, O_RDONLY); + if (fd == -1) + continue; + struct video_capability video_cap; + if(ioctl(fd, VIDIOCGCAP, &video_cap) == -1) + { + close(fd); + continue; + } + ret.append(video_cap.name); + close(fd); } else { continue; } |