mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Commits from @MartB and more ...
- Commit: 1d9165f403
- New default QT capture implementation
- UploadHandler added to Effects Configurator to allow uploading GIF files
- Docker compile script and instruction
- Travis Fix
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
//impl
|
||||
PyThreadState* mainThreadState;
|
||||
|
||||
Effect::Effect(Hyperion* hyperion, int priority, int timeout, const QString & script, const QString & name, const QJsonObject & args)
|
||||
Effect::Effect(Hyperion *hyperion, int priority, int timeout, const QString &script, const QString &name, const QJsonObject &args, const QString &imageData)
|
||||
: QThread()
|
||||
, _hyperion(hyperion)
|
||||
, _priority(priority)
|
||||
@@ -33,6 +33,7 @@ Effect::Effect(Hyperion* hyperion, int priority, int timeout, const QString & sc
|
||||
, _script(script)
|
||||
, _name(name)
|
||||
, _args(args)
|
||||
, _imageData(imageData)
|
||||
, _endTime(-1)
|
||||
, _colors()
|
||||
, _imageSize(hyperion->getLedGridSize())
|
||||
|
@@ -136,14 +136,14 @@ int EffectEngine::runEffect(const QString &effectName, int priority, int timeout
|
||||
return runEffect(effectName, QJsonObject(), priority, timeout, "", origin);
|
||||
}
|
||||
|
||||
int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, const QString &pythonScript, const QString &origin, unsigned smoothCfg)
|
||||
int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args, int priority, int timeout, const QString &pythonScript, const QString &origin, unsigned smoothCfg, const QString &imageData)
|
||||
{
|
||||
Info( _log, "run effect %s on channel %d", QSTRING_CSTR(effectName), priority);
|
||||
|
||||
if (pythonScript.isEmpty())
|
||||
{
|
||||
const EffectDefinition * effectDefinition = nullptr;
|
||||
for (const EffectDefinition & e : _availableEffects)
|
||||
const EffectDefinition *effectDefinition = nullptr;
|
||||
for (const EffectDefinition &e : _availableEffects)
|
||||
{
|
||||
if (e.name == effectName)
|
||||
{
|
||||
@@ -160,16 +160,16 @@ int EffectEngine::runEffect(const QString &effectName, const QJsonObject &args,
|
||||
|
||||
return runEffectScript(effectDefinition->script, effectName, (args.isEmpty() ? effectDefinition->args : args), priority, timeout, origin, effectDefinition->smoothCfg);
|
||||
}
|
||||
return runEffectScript(pythonScript, effectName, args, priority, timeout, origin, smoothCfg);
|
||||
return runEffectScript(pythonScript, effectName, args, priority, timeout, origin, smoothCfg, imageData);
|
||||
}
|
||||
|
||||
int EffectEngine::runEffectScript(const QString &script, const QString &name, const QJsonObject &args, int priority, int timeout, const QString & origin, unsigned smoothCfg)
|
||||
int EffectEngine::runEffectScript(const QString &script, const QString &name, const QJsonObject &args, int priority, int timeout, const QString &origin, unsigned smoothCfg, const QString &imageData)
|
||||
{
|
||||
// clear current effect on the channel
|
||||
channelCleared(priority);
|
||||
|
||||
// create the effect
|
||||
Effect * effect = new Effect(_hyperion, priority, timeout, script, name, args);
|
||||
Effect *effect = new Effect(_hyperion, priority, timeout, script, name, args, imageData);
|
||||
connect(effect, &Effect::setInput, _hyperion, &Hyperion::setInput, Qt::QueuedConnection);
|
||||
connect(effect, &Effect::setInputImage, _hyperion, &Hyperion::setInputImage, Qt::QueuedConnection);
|
||||
connect(effect, &QThread::finished, this, &EffectEngine::effectFinished);
|
||||
|
@@ -8,6 +8,7 @@
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
#include <QMap>
|
||||
#include <QByteArray>
|
||||
|
||||
// createEffect helper
|
||||
struct find_schema: std::unary_function<EffectSchema, bool>
|
||||
@@ -69,7 +70,15 @@ const bool EffectFileHandler::deleteEffect(const QString& effectName, QString& r
|
||||
{
|
||||
if (effectConfigurationFile.exists())
|
||||
{
|
||||
if ( (it->script == ":/effects/gif.py") && !it->args.value("image").toString("").isEmpty())
|
||||
{
|
||||
QFileInfo effectImageFile(effectConfigurationFile.absolutePath() + "/" + it->args.value("image").toString());
|
||||
if (effectImageFile.exists())
|
||||
QFile::remove(effectImageFile.absoluteFilePath());
|
||||
}
|
||||
|
||||
bool result = QFile::remove(effectConfigurationFile.absoluteFilePath());
|
||||
|
||||
if (result)
|
||||
{
|
||||
updateEffects();
|
||||
@@ -141,6 +150,17 @@ const bool EffectFileHandler::saveEffect(const QJsonObject& message, QString& re
|
||||
newFileName.setFile(f);
|
||||
}
|
||||
|
||||
//TODO check if filename exist
|
||||
if (!message["imageData"].toString("").isEmpty() && !message["args"].toObject().value("image").toString("").isEmpty())
|
||||
{
|
||||
QFileInfo imageFileName(effectArray[0].toString().replace("$ROOT",_rootPath) + "/" + message["args"].toObject().value("image").toString());
|
||||
if(!FileUtils::writeFile(imageFileName.absoluteFilePath(), QByteArray::fromBase64(message["imageData"].toString("").toUtf8()), _log))
|
||||
{
|
||||
resultMsg = "Error while saving image file '" + message["args"].toObject().value("image").toString() + ", please check the Hyperion Log";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(!JsonUtils::write(newFileName.absoluteFilePath(), effectJson, _log))
|
||||
{
|
||||
resultMsg = "Error while saving effect, please check the Hyperion Log";
|
||||
|
@@ -11,6 +11,7 @@
|
||||
#include <QJsonArray>
|
||||
#include <QDateTime>
|
||||
#include <QImageReader>
|
||||
#include <QBuffer>
|
||||
|
||||
// create the hyperion module
|
||||
struct PyModuleDef EffectModule::moduleDef = {
|
||||
@@ -257,25 +258,42 @@ PyObject* EffectModule::wrapSetImage(PyObject *self, PyObject *args)
|
||||
|
||||
PyObject* EffectModule::wrapGetImage(PyObject *self, PyObject *args)
|
||||
{
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
Effect *effect = getEffect();
|
||||
|
||||
char *source;
|
||||
if(!PyArg_ParseTuple(args, "s", &source))
|
||||
QString file;
|
||||
QBuffer buffer;
|
||||
QImageReader reader;
|
||||
|
||||
if (effect->_imageData.isEmpty())
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "String required");
|
||||
return NULL;
|
||||
Q_INIT_RESOURCE(EffectEngine);
|
||||
|
||||
char *source;
|
||||
if(!PyArg_ParseTuple(args, "s", &source))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, "String required");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
file = QString::fromUtf8(source);
|
||||
|
||||
if (file.mid(0, 1) == ":")
|
||||
file = ":/effects/"+file.mid(1);
|
||||
|
||||
reader.setDecideFormatFromContent(true);
|
||||
reader.setFileName(file);
|
||||
}
|
||||
else
|
||||
{
|
||||
buffer.setData(QByteArray::fromBase64(effect->_imageData.toUtf8()));
|
||||
buffer.open(QBuffer::ReadOnly);
|
||||
reader.setDecideFormatFromContent(true);
|
||||
reader.setDevice(&buffer);
|
||||
}
|
||||
|
||||
QString file = QString::fromUtf8(source);
|
||||
|
||||
if (file.mid(0, 1) == ":")
|
||||
file = ":/effects/"+file.mid(1);
|
||||
|
||||
QImageReader reader(file);
|
||||
|
||||
if (reader.canRead())
|
||||
{
|
||||
PyObject* result = PyList_New(reader.imageCount());
|
||||
PyObject *result = PyList_New(reader.imageCount());
|
||||
|
||||
for (int i = 0; i < reader.imageCount(); ++i)
|
||||
{
|
||||
@@ -290,7 +308,7 @@ PyObject* EffectModule::wrapGetImage(PyObject *self, PyObject *args)
|
||||
QByteArray binaryImage;
|
||||
for (int i = 0; i<height; ++i)
|
||||
{
|
||||
const QRgb * scanline = reinterpret_cast<const QRgb *>(qimage.scanLine(i));
|
||||
const QRgb *scanline = reinterpret_cast<const QRgb *>(qimage.scanLine(i));
|
||||
for (int j = 0; j< width; ++j)
|
||||
{
|
||||
binaryImage.append((char) qRed(scanline[j]));
|
||||
|
Reference in New Issue
Block a user