mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 02:40:00 +01:00
Integrated preliminary implementation of Device class with monitoring of
v4l2 device connected to the machine using GstDeviceMonitor.
This commit is contained in:
@@ -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_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user