Refactor MediaFoundation (Part 2)

This commit is contained in:
Paulchen Panther
2021-01-31 13:49:31 +01:00
parent 07a6d5e5b1
commit 878d4fe0a1
9 changed files with 198 additions and 179 deletions

View File

@@ -40,20 +40,16 @@ class MFGrabber : public Grabber
friend class SourceReaderCB;
public:
struct DevicePropertiesItem
{
int x, y,fps,fps_a,fps_b;
PixelFormat pf;
GUID guid;
};
struct DeviceProperties
{
QString name = QString();
QMultiMap<QString, int> inputs = QMultiMap<QString, int>();
QStringList displayResolutions = QStringList();
QStringList framerates = QStringList();
QList<DevicePropertiesItem> valid = QList<DevicePropertiesItem>();
QString symlink = QString();
int width = 0;
int height = 0;
int fps = 0;
int numerator = 0;
int denominator = 0;
PixelFormat pf = PixelFormat::NO_CHANGE;
GUID guid = GUID_NULL;
};
MFGrabber(const QString & device, const unsigned width, const unsigned height, const unsigned fps, int pixelDecimation, QString flipMode);
@@ -63,12 +59,11 @@ public:
QRectF getSignalDetectionOffset() const { return QRectF(_x_frac_min, _y_frac_min, _x_frac_max, _y_frac_max); }
bool getSignalDetectionEnabled() const { return _signalDetectionEnabled; }
bool getCecDetectionEnabled() const { return _cecDetectionEnabled; }
QStringList getV4L2devices() const override;
QString getV4L2deviceName(const QString& devicePath) const override { return devicePath; }
QMultiMap<QString, int> getV4L2deviceInputs(const QString& devicePath) const override { return _deviceProperties.value(devicePath).inputs; }
QStringList getResolutions(const QString& devicePath) const override { return _deviceProperties.value(devicePath).displayResolutions; }
QStringList getFramerates(const QString& devicePath) const override { return _deviceProperties.value(devicePath).framerates; }
QStringList getV4L2EncodingFormats(const QString& devicePath) const override;
QStringList getDevices() const override;
QString getDeviceName(const QString& devicePath) const override { return devicePath; }
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;
void setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold) override;
void setSignalDetectionOffset( double verticalMin, double horizontalMin, double verticalMax, double horizontalMax) override;
void setSignalDetectionEnable(bool enable) override;
@@ -95,7 +90,7 @@ signals:
private:
bool init();
void uninit();
HRESULT init_device(QString device, DevicePropertiesItem props);
HRESULT init_device(QString device, DeviceProperties props);
void uninit_device();
void enumVideoCaptureDevices();
void start_capturing();
@@ -103,7 +98,7 @@ private:
void checkSignalDetectionEnabled(Image<ColorRgb> image);
QString _currentDeviceName, _newDeviceName;
QMap<QString, MFGrabber::DeviceProperties> _deviceProperties;
QMap<QString, QList<DeviceProperties>> _deviceProperties;
HRESULT _hr;
SourceReaderCB* _sourceReaderCB;
PixelFormat _pixelFormat, _pixelFormatConfig;

View File

@@ -15,8 +15,7 @@
///
/// @brief The Grabber class is responsible to apply image resizes (with or without ImageResampler)
/// Overwrite the videoMode with setVideoMode()
/// Overwrite setCropping()
class Grabber : public QObject
{
Q_OBJECT
@@ -127,45 +126,52 @@ public:
void setEnabled(bool enable);
///
/// @brief Get a list of all available V4L devices
/// @return List of all available V4L devices on success else empty List
/// @brief Get a list of all available devices
/// @return List of all available devices on success else empty List
///
virtual QStringList getV4L2devices() const { return QStringList(); }
virtual QStringList getDevices() const { return QStringList(); }
///
/// @brief Get the V4L device name
/// @brief Get the device name by path
/// @param devicePath The device path
/// @return The name of the V4L device on success else empty String
/// @return The name of the device on success else empty String
///
virtual QString getV4L2deviceName(const QString& /*devicePath*/) const { return QString(); }
virtual QString getDeviceName(const QString& /*devicePath*/) const { return QString(); }
///
/// @brief Get a name/index pair of supported device inputs
/// @param devicePath The device path
/// @return multi pair of name/index on success else empty pair
///
virtual QMultiMap<QString, int> getV4L2deviceInputs(const QString& /*devicePath*/) const { return QMultiMap<QString, int>(); }
virtual QMultiMap<QString, int> getDeviceInputs(const QString& /*devicePath*/) const { return {{ "", 0}}; }
///
/// @brief Get a list of supported hardware encoding formats
/// @brief Get a list of all available device encoding formats depends on device input
/// @param devicePath The device path
/// @return List of hardware encoding formats on success else empty List
/// @param inputIndex The device input index
/// @return List of device encoding formats on success else empty List
///
virtual QStringList getV4L2EncodingFormats(const QString& /*devicePath*/) const { return QStringList(); }
virtual QStringList getAvailableEncodingFormats(const QString& /*devicePath*/, const int& /*deviceInput*/) const { return QStringList(); }
///
/// @brief Get a list of supported device resolutions
/// @brief Get a list of available device resolutions 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
///
virtual QStringList getResolutions(const QString& /*devicePath*/) const { return QStringList(); }
virtual QStringList getAvailableDeviceResolutions(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/) const { return QStringList(); }
///
/// @brief Get a list of supported device framerates
/// @brief Get a list of available device framerates depends on device input, encoding format and resolution
/// @param devicePath The device path
/// @param inputIndex The device input index
/// @param encFormat The device encoding format
/// @param width The device width
/// @param heigth The device heigth
/// @return List of framerates on success else empty List
///
virtual QStringList getFramerates(const QString& devicePath) const { return QStringList(); }
virtual QStringList getAvailableDeviceFramerates(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/, const unsigned /*width*/, const unsigned /*height*/) const { return QStringList(); }
protected:
ImageResampler _imageResampler;

View File

@@ -12,6 +12,7 @@
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/VideoMode.h>
#include <utils/PixelFormat.h>
#include <utils/settings.h>
class Grabber;
@@ -57,45 +58,52 @@ public:
virtual bool isActive() const;
///
/// @brief Get a list of all available V4L devices
/// @return List of all available V4L devices on success else empty List
/// @brief Get a list of all available devices
/// @return List of all available devices on success else empty List
///
virtual QStringList getV4L2devices() const;
virtual QStringList getDevices() const;
///
/// @brief Get the V4L device name
/// @brief Get the device name by path
/// @param devicePath The device path
/// @return The name of the V4L device on success else empty String
/// @return The name of the device on success else empty String
///
virtual QString getV4L2deviceName(const QString& devicePath) const;
virtual QString getDeviceName(const QString& devicePath) const;
///
/// @brief Get a name/index pair of supported device inputs
/// @param devicePath The device path
/// @return multi pair of name/index on success else empty pair
///
virtual QMultiMap<QString, int> getV4L2deviceInputs(const QString& devicePath) const;
virtual QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const;
///
/// @brief Get a list of supported hardware encoding formats
/// @brief Get a list of all available device encoding formats depends on device input
/// @param devicePath The device path
/// @return List of hardware encoding formats on success else empty List
/// @param inputIndex The device input index
/// @return List of device encoding formats on success else empty List
///
virtual QStringList getV4L2EncodingFormats(const QString& devicePath) const;
virtual QStringList getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const;
///
/// @brief Get a list of supported device resolutions
/// @brief Get a list of available device resolutions 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
///
virtual QStringList getResolutions(const QString& devicePath) const;
virtual QStringList getAvailableDeviceResolutions(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat) const;
///
/// @brief Get a list of supported device framerates
/// @brief Get a list of available device framerates depends on encoding format and resolution
/// @param devicePath The device path
/// @param inputIndex The device input index
/// @param encFormat The device encoding format
/// @param width The device width
/// @param heigth The device heigth
/// @return List of framerates on success else empty List
///
virtual QStringList getFramerates(const QString& devicePath) const;
virtual QStringList getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const;
///
/// @brief Get active grabber name

View File

@@ -192,7 +192,7 @@ public slots:
bool clear(int priority, bool forceClearAll=false);
/// #############
// EFFECTENGINE
/// EFFECTENGINE
///
/// @brief Get a pointer to the effect engine
/// @return EffectEngine instance pointer