summaryrefslogtreecommitdiffstats
path: root/pica-client/videodevice.cpp
diff options
context:
space:
mode:
authorAnton <anton@picapica>2020-05-30 06:18:34 +0400
committerAnton <anton@picapica>2020-05-30 06:18:34 +0400
commit90e2f0ae3bf00e1b9850e1b96b90944d06491532 (patch)
tree83d6ee87062f8ca7391c82dd308eebeff51b9fb7 /pica-client/videodevice.cpp
parent8be5d3e0a1a09f0d4e9c2544ac3293c6dd6f788c (diff)
downloadpica-pica-90e2f0ae3bf00e1b9850e1b96b90944d06491532.tar.gz
pica-pica-90e2f0ae3bf00e1b9850e1b96b90944d06491532.zip
add classes for audio & video devices, implemented video device enumeration for Linux
Diffstat (limited to 'pica-client/videodevice.cpp')
-rw-r--r--pica-client/videodevice.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/pica-client/videodevice.cpp b/pica-client/videodevice.cpp
new file mode 100644
index 0000000..75b516b
--- /dev/null
+++ b/pica-client/videodevice.cpp
@@ -0,0 +1,40 @@
+#include "videodevice.h"
+#include <QFile>
+
+VideoDevice::VideoDevice()
+{
+
+}
+
+VideoDevice::~VideoDevice()
+{
+
+}
+
+QList<MediaDeviceInfo> VideoDevice::Enumerate()
+{
+ QList<MediaDeviceInfo> result;
+ int index = 0;
+#ifdef Q_OS_LINUX
+ for (int i = 0; i < 64; i++)
+ {
+ QString device = QString(QLatin1String("/dev/video%1")).arg(i);
+ if (QFile::exists(device))
+ {
+ MediaDeviceInfo d;
+ d.device = device;
+
+ QFile v4l2_name(QString(QLatin1String("/sys/class/video4linux/video%1/name")).arg(i));
+ if (v4l2_name.open((QIODevice::ReadOnly | QIODevice::Text)))
+ {
+ d.humanReadable = QString(v4l2_name.readLine()).trimmed();
+ v4l2_name.close();
+ }
+ d.index = index++;
+
+ result << d;
+ }
+ }
+#endif
+ return result;
+}