Integrated preliminary implementation of Device class with monitoring of

v4l2 device connected to the machine using GstDeviceMonitor.
This commit is contained in:
brunoherbelin
2020-09-23 23:29:45 +02:00
parent 9e160fec51
commit 84caf2da9a
6 changed files with 233 additions and 72 deletions

View File

@@ -1,35 +1,62 @@
#ifndef DEVICESOURCE_H
#define DEVICESOURCE_H
#include <vector>
#include "GstToolkit.h"
#include "StreamSource.h"
class Device : public Stream
class Device
{
Device();
Device(Rendering const& copy); // Not Implemented
Device& operator=(Rendering const& copy); // Not Implemented
public:
Device();
void open( uint deviceid );
static Device& manager()
{
// The only instance
static Device _instance;
return _instance;
}
glm::ivec2 resolution();
int numDevices () const;
std::string name (int index) const;
bool exists (const std::string &device) const;
std::string pipeline (int index) const;
std::string pipeline (const std::string &device) const;
static gboolean callback_device_monitor (GstBus *, GstMessage *, gpointer);
private:
uint device_;
void remove(const char *device);
std::vector< std::string > names_;
std::vector< std::string > pipelines_;
GstDeviceMonitor *monitor_;
};
class DeviceSource : public StreamSource
{
public:
DeviceSource();
// Source interface
bool failed() const override;
void accept (Visitor& v) override;
// StreamSource interface
Stream *stream() const override { return stream_; }
// specific interface
Device *device() const;
void setDevice(int id);
void setDevice(const std::string &devicename);
inline std::string device() const { return device_; }
private:
std::string device_;
};