mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
feat: SchemaChecker & V4L2 enhancement (#734)
* libjpeg-turbo, QJsonSchemaChecker, V4L2 width/height/fps Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com> * Implement hyperion-v4l cli args * Apply v4l2 settings during runtime * feat: Provide minimum values for input restriction * fix: merge mess Co-authored-by: brindosch <edeltraud70@gmx.de>
This commit is contained in:
@@ -15,13 +15,23 @@
|
||||
#include <grabber/VideoStandard.h>
|
||||
#include <utils/Components.h>
|
||||
|
||||
#ifdef HAVE_JPEG
|
||||
// general JPEG decoder includes
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
#include <QImage>
|
||||
#include <QColor>
|
||||
#endif
|
||||
|
||||
// System JPEG decoder
|
||||
#ifdef HAVE_JPEG
|
||||
#include <jpeglib.h>
|
||||
#include <csetjmp>
|
||||
#endif
|
||||
|
||||
// TurboJPEG decoder
|
||||
#ifdef HAVE_TURBO_JPEG
|
||||
#include <turbojpeg.h>
|
||||
#endif
|
||||
|
||||
/// Capture class for V4L2 devices
|
||||
///
|
||||
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
|
||||
@@ -31,6 +41,9 @@ class V4L2Grabber : public Grabber
|
||||
|
||||
public:
|
||||
V4L2Grabber(const QString & device,
|
||||
const unsigned width,
|
||||
const unsigned height,
|
||||
const unsigned fps,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
int pixelDecimation
|
||||
@@ -46,11 +59,6 @@ public:
|
||||
|
||||
int grabFrame(Image<ColorRgb> &);
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation, as v4l doesn't use width/height
|
||||
///
|
||||
virtual void setWidthHeight(){};
|
||||
|
||||
///
|
||||
/// @brief set new PixelDecimation value to ImageResampler
|
||||
/// @param pixelDecimation The new pixelDecimation value
|
||||
@@ -84,6 +92,16 @@ public:
|
||||
///
|
||||
virtual void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
virtual bool setFramerate(int fps);
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
virtual bool setWidthHeight(int width, int height);
|
||||
|
||||
public slots:
|
||||
|
||||
bool start();
|
||||
@@ -173,6 +191,11 @@ private:
|
||||
errorManager* _error;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TURBO_JPEG
|
||||
tjhandle _decompress = nullptr;
|
||||
int _subsamp;
|
||||
#endif
|
||||
|
||||
private:
|
||||
QString _deviceName;
|
||||
std::map<QString,QString> _v4lDevices;
|
||||
|
@@ -9,6 +9,9 @@ class V4L2Wrapper : public GrabberWrapper
|
||||
|
||||
public:
|
||||
V4L2Wrapper(const QString & device,
|
||||
const unsigned grabWidth,
|
||||
const unsigned grabHeight,
|
||||
const unsigned fps,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
int pixelDecimation );
|
||||
|
@@ -40,6 +40,12 @@ public:
|
||||
///
|
||||
virtual bool setWidthHeight(int width, int height);
|
||||
|
||||
///
|
||||
/// @brief Apply new framerate (used from v4l)
|
||||
/// @param fps framesPerSecond
|
||||
///
|
||||
virtual bool setFramerate(int fps);
|
||||
|
||||
///
|
||||
/// @brief Apply new pixelDecimation (used from x11 and qt)
|
||||
///
|
||||
@@ -111,6 +117,8 @@ protected:
|
||||
/// Height of the captured snapshot [pixels]
|
||||
int _height;
|
||||
|
||||
int _fps;
|
||||
|
||||
// number of pixels to crop after capturing
|
||||
int _cropLeft, _cropRight, _cropTop, _cropBottom;
|
||||
|
||||
|
@@ -12,7 +12,7 @@ enum PixelFormat {
|
||||
PIXELFORMAT_BGR24,
|
||||
PIXELFORMAT_RGB32,
|
||||
PIXELFORMAT_BGR32,
|
||||
#ifdef HAVE_JPEG
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
PIXELFORMAT_MJPEG,
|
||||
#endif
|
||||
PIXELFORMAT_NO_CHANGE
|
||||
@@ -47,7 +47,7 @@ inline PixelFormat parsePixelFormat(QString pixelFormat)
|
||||
{
|
||||
return PIXELFORMAT_BGR32;
|
||||
}
|
||||
#ifdef HAVE_JPEG
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
else if (pixelFormat == "mjpeg")
|
||||
{
|
||||
return PIXELFORMAT_MJPEG;
|
||||
|
@@ -187,6 +187,14 @@ private:
|
||||
///
|
||||
void checkEnum(const QJsonValue & value, const QJsonValue & schema, const QJsonValue & defaultValue);
|
||||
|
||||
///
|
||||
/// @brief Return the "default" value as string. If not found, an empty string is output
|
||||
///
|
||||
/// @param value The JSON value to search
|
||||
/// @return The "default" value as string
|
||||
///
|
||||
QString getDefaultValue(const QJsonValue & value);
|
||||
|
||||
private:
|
||||
/// The schema of the entire json-configuration
|
||||
QJsonObject _qSchema;
|
||||
|
@@ -41,6 +41,37 @@ public:
|
||||
return createValue(schema, ignoreRequired);
|
||||
}
|
||||
|
||||
static QString getDefaultValue(const QJsonValue & value)
|
||||
{
|
||||
QString ret;
|
||||
switch (value.type())
|
||||
{
|
||||
case QJsonValue::Array:
|
||||
{
|
||||
for (const QJsonValue &v : value.toArray())
|
||||
{
|
||||
ret = getDefaultValue(v);
|
||||
if (!ret.isEmpty())
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QJsonValue::Object:
|
||||
ret = getDefaultValue(value.toObject().find("default").value());
|
||||
break;
|
||||
case QJsonValue::Bool:
|
||||
return value.toBool() ? "True" : "False";
|
||||
case QJsonValue::Double:
|
||||
return QString::number(value.toDouble());
|
||||
case QJsonValue::String:
|
||||
return value.toString();
|
||||
case QJsonValue::Null:
|
||||
case QJsonValue::Undefined:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static QJsonValue createValue(QJsonValue schema, bool ignoreRequired)
|
||||
|
Reference in New Issue
Block a user