From 13b76c2363e3fd11df30869f48f9b9ee517129cc Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 19 Jul 2015 12:53:11 +0200 Subject: grab Linux camera names --- opentrack/camera-names.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'opentrack') 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 #endif +#ifdef __linux +#include +#include +#include +#endif + template QList get_camera_names() { QList ret; @@ -69,12 +75,23 @@ QList 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; } -- cgit v1.2.3