mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Refactor V4L2 grabber (part 1) (#62)
This commit is contained in:
@@ -61,6 +61,7 @@ public:
|
||||
bool getCecDetectionEnabled() const { return _cecDetectionEnabled; }
|
||||
QStringList getDevices() const override;
|
||||
QString getDeviceName(const QString& devicePath) const override { return devicePath; }
|
||||
QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const override { return {{ devicePath, 0}}; }
|
||||
QStringList getAvailableEncodingFormats(const QString& devicePath, const int& /*deviceInput*/) const override;
|
||||
QStringList getAvailableDeviceResolutions(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat) const override;
|
||||
QStringList getAvailableDeviceFramerates(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat, const unsigned width, const unsigned height) const override;
|
||||
|
@@ -35,9 +35,10 @@
|
||||
#include <turbojpeg.h>
|
||||
#endif
|
||||
|
||||
///
|
||||
/// Capture class for V4L2 devices
|
||||
///
|
||||
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
|
||||
|
||||
class V4L2Grabber : public Grabber
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -45,10 +46,19 @@ class V4L2Grabber : public Grabber
|
||||
public:
|
||||
struct DeviceProperties
|
||||
{
|
||||
QString name = QString();
|
||||
QMultiMap<QString, int> inputs = QMultiMap<QString, int>();
|
||||
QStringList resolutions = QStringList();
|
||||
QStringList framerates = QStringList();
|
||||
QString name = QString();
|
||||
struct InputProperties
|
||||
{
|
||||
QString inputName = QString();
|
||||
struct EncodingProperties
|
||||
{
|
||||
unsigned int width = 0;
|
||||
unsigned int height = 0;
|
||||
QList<int> framerates = QList<int>();
|
||||
};
|
||||
QMultiMap<PixelFormat, EncodingProperties> encodingFormats = QMultiMap<PixelFormat, EncodingProperties>();
|
||||
};
|
||||
QMap<int, InputProperties> inputs = QMap<int, InputProperties>();
|
||||
};
|
||||
|
||||
V4L2Grabber(const QString & device, const unsigned width, const unsigned height, const unsigned fps, const unsigned input, VideoStandard videoStandard, PixelFormat pixelFormat, int pixelDecimation);
|
||||
@@ -120,27 +130,33 @@ public:
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
QStringList getV4L2devices() const override;
|
||||
QStringList getDevices() const override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
QString getV4L2deviceName(const QString& devicePath) const override;
|
||||
QString getDeviceName(const QString& devicePath) const override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
QMultiMap<QString, int> getV4L2deviceInputs(const QString& devicePath) const override;
|
||||
QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
QStringList getResolutions(const QString& devicePath) const override;
|
||||
QStringList getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
QStringList getFramerates(const QString& devicePath) const override;
|
||||
QMultiMap<int, int> getAvailableDeviceResolutions(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat) const override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
QStringList getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const override;
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
@@ -275,5 +291,5 @@ private:
|
||||
bool _deviceAutoDiscoverEnabled;
|
||||
|
||||
protected:
|
||||
void enumFrameIntervals(QStringList &framerates, int fileDescriptor, int pixelformat, int width, int height);
|
||||
void enumFrameIntervals(QList<int> &framerates, int fileDescriptor, int pixelformat, int width, int height);
|
||||
};
|
||||
|
@@ -143,7 +143,7 @@ public:
|
||||
/// @param devicePath The device path
|
||||
/// @return multi pair of name/index on success else empty pair
|
||||
///
|
||||
virtual QMultiMap<QString, int> getDeviceInputs(const QString& /*devicePath*/) const { return {{ "", 0}}; }
|
||||
virtual QMultiMap<QString, int> getDeviceInputs(const QString& /*devicePath*/) const { return QMultiMap<QString, int>(); }
|
||||
|
||||
///
|
||||
/// @brief Get a list of all available device encoding formats depends on device input
|
||||
@@ -154,13 +154,13 @@ public:
|
||||
virtual QStringList getAvailableEncodingFormats(const QString& /*devicePath*/, const int& /*deviceInput*/) const { return QStringList(); }
|
||||
|
||||
///
|
||||
/// @brief Get a list of available device resolutions depends on device input and encoding format
|
||||
/// @brief Get a map of available device resolutions (width/heigth) depends on device input and encoding format
|
||||
/// @param devicePath The device path
|
||||
/// @param inputIndex The device input index
|
||||
/// @param encFormat The device encoding format
|
||||
/// @return List of resolutions on success else empty List
|
||||
/// @return Map of resolutions (width/heigth) on success else empty List
|
||||
///
|
||||
virtual QStringList getAvailableDeviceResolutions(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/) const { return QStringList(); }
|
||||
virtual QMultiMap<int, int> getAvailableDeviceResolutions(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/) const { return QMultiMap<int, int>(); }
|
||||
|
||||
///
|
||||
/// @brief Get a list of available device framerates depends on device input, encoding format and resolution
|
||||
|
@@ -71,7 +71,7 @@ public:
|
||||
virtual QString getDeviceName(const QString& devicePath) const;
|
||||
|
||||
///
|
||||
/// @brief Get a name/index pair of supported device inputs
|
||||
/// @brief Get a map of name/index pair of supported device inputs
|
||||
/// @param devicePath The device path
|
||||
/// @return multi pair of name/index on success else empty pair
|
||||
///
|
||||
@@ -86,13 +86,13 @@ public:
|
||||
virtual QStringList getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const;
|
||||
|
||||
///
|
||||
/// @brief Get a list of available device resolutions depends on device input and encoding format
|
||||
/// @brief Get a map of available device resolutions (width/heigth) depends on device input and encoding format
|
||||
/// @param devicePath The device path
|
||||
/// @param inputIndex The device input index
|
||||
/// @param encFormat The device encoding format
|
||||
/// @return List of resolutions on success else empty List
|
||||
/// @return Map of resolutions (width/heigth) on success else empty List
|
||||
///
|
||||
virtual QStringList getAvailableDeviceResolutions(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat) const;
|
||||
virtual QMultiMap<int, int> getAvailableDeviceResolutions(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat) const;
|
||||
|
||||
///
|
||||
/// @brief Get a list of available device framerates depends on encoding format and resolution
|
||||
|
Reference in New Issue
Block a user