From 90e2f0ae3bf00e1b9850e1b96b90944d06491532 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 30 May 2020 06:18:34 +0400 Subject: add classes for audio & video devices, implemented video device enumeration for Linux --- Makefile.am | 6 ++++++ pica-client/audiodevice.cpp | 16 ++++++++++++++++ pica-client/audiodevice.h | 14 ++++++++++++++ pica-client/mediadevice.cpp | 12 ++++++++++++ pica-client/mediadevice.h | 22 ++++++++++++++++++++++ pica-client/pica-client.pro | 10 ++++++++-- pica-client/videodevice.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ pica-client/videodevice.h | 14 ++++++++++++++ 8 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 pica-client/audiodevice.cpp create mode 100644 pica-client/audiodevice.h create mode 100644 pica-client/mediadevice.cpp create mode 100644 pica-client/mediadevice.h create mode 100644 pica-client/videodevice.cpp create mode 100644 pica-client/videodevice.h diff --git a/Makefile.am b/Makefile.am index 6edec67..c07f396 100644 --- a/Makefile.am +++ b/Makefile.am @@ -93,6 +93,12 @@ pica-client/sound.cpp \ pica-client/sound.h \ pica-client/settings.cpp \ pica-client/settings.h \ +pica-client/mediadevice.cpp \ +pica-client/mediadevice.h \ +pica-client/audiodevice.cpp \ +pica-client/audiodevice.h \ +pica-client/videodevice.cpp \ +pica-client/videodevice.h \ \ pica-client/dialogs/addaccountdialog.cpp \ pica-client/dialogs/addaccountdialog.h \ diff --git a/pica-client/audiodevice.cpp b/pica-client/audiodevice.cpp new file mode 100644 index 0000000..16bf0b1 --- /dev/null +++ b/pica-client/audiodevice.cpp @@ -0,0 +1,16 @@ +#include "audiodevice.h" + +AudioDevice::AudioDevice() +{ + +} + +AudioDevice::~AudioDevice() +{ + +} + +QList AudioDevice::Enumerate() +{ + +} diff --git a/pica-client/audiodevice.h b/pica-client/audiodevice.h new file mode 100644 index 0000000..9c8cec5 --- /dev/null +++ b/pica-client/audiodevice.h @@ -0,0 +1,14 @@ +#ifndef AUDIODEVICE_H +#define AUDIODEVICE_H + +#include "mediadevice.h" + +class AudioDevice : public MediaDevice +{ +public: + AudioDevice(); + ~AudioDevice(); + virtual QList Enumerate(); +}; + +#endif // AUDIODEVICE_H diff --git a/pica-client/mediadevice.cpp b/pica-client/mediadevice.cpp new file mode 100644 index 0000000..42a661b --- /dev/null +++ b/pica-client/mediadevice.cpp @@ -0,0 +1,12 @@ +#include "mediadevice.h" + +MediaDevice::MediaDevice() +{ + +} + +MediaDevice::~MediaDevice() +{ + +} + diff --git a/pica-client/mediadevice.h b/pica-client/mediadevice.h new file mode 100644 index 0000000..d8660f6 --- /dev/null +++ b/pica-client/mediadevice.h @@ -0,0 +1,22 @@ +#ifndef MEDIADEVICE_H +#define MEDIADEVICE_H + +#include +#include + +struct MediaDeviceInfo +{ + QString device; + QString humanReadable; + int index; +}; + +class MediaDevice +{ +public: + MediaDevice(); + virtual ~MediaDevice(); + virtual QList Enumerate() = 0; +}; + +#endif // MEDIADEVICE_H diff --git a/pica-client/pica-client.pro b/pica-client/pica-client.pro index 61662fc..a701d12 100644 --- a/pica-client/pica-client.pro +++ b/pica-client/pica-client.pro @@ -11,12 +11,14 @@ TEMPLATE = app SOURCES += main.cpp\ + audiodevice.cpp \ mainwindow.cpp \ chatwindow.cpp \ contacts.cpp \ ../PICA_client.c \ ../PICA_msgproc.c \ contactlistwidget.cpp \ + mediadevice.cpp \ skynet.cpp \ nodes.cpp \ accountswindow.cpp \ @@ -41,15 +43,18 @@ SOURCES += main.cpp\ settings.cpp \ ../PICA_netconf.c \ ../PICA_signverify.c \ - dialogs/nodesdialog.cpp + dialogs/nodesdialog.cpp \ + videodevice.cpp HEADERS += mainwindow.h \ + audiodevice.h \ chatwindow.h \ contacts.h \ globals.h \ ../PICA_client.h \ ../PICA_msgproc.h \ contactlistwidget.h \ + mediadevice.h \ skynet.h \ nodes.h \ accountswindow.h \ @@ -77,7 +82,8 @@ HEADERS += mainwindow.h \ ../PICA_netconf.h \ ../PICA_security.h \ ../PICA_signverify.h \ - dialogs/nodesdialog.h + dialogs/nodesdialog.h \ + videodevice.h DEFINES = PICA_MULTITHREADED 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 + +VideoDevice::VideoDevice() +{ + +} + +VideoDevice::~VideoDevice() +{ + +} + +QList VideoDevice::Enumerate() +{ + QList 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; +} diff --git a/pica-client/videodevice.h b/pica-client/videodevice.h new file mode 100644 index 0000000..0b714c7 --- /dev/null +++ b/pica-client/videodevice.h @@ -0,0 +1,14 @@ +#ifndef VIDEODEVICE_H +#define VIDEODEVICE_H + +#include "mediadevice.h" + +class VideoDevice : public MediaDevice +{ +public: + VideoDevice(); + ~VideoDevice(); + virtual QList Enumerate(); +}; + +#endif // VIDEODEVICE_H -- cgit v1.2.1