mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Added config file settings for XBMCVideoChecker
This commit is contained in:
parent
026937d5e1
commit
213545afe7
@ -294,5 +294,10 @@
|
||||
"hscan" : { "minimum" : 52.9412, "maximum" : 58.8235 },
|
||||
"vscan" : { "minimum" : 0, "maximum" : 10 }
|
||||
}
|
||||
]
|
||||
],
|
||||
"xbmcVideoChecker" : {
|
||||
"enable" : true,
|
||||
"xbmcAddress" : "127.0.0.1",
|
||||
"xbmcTcpPort" : 9090
|
||||
}
|
||||
}
|
||||
|
@ -35,11 +35,6 @@ public:
|
||||
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
|
||||
};
|
||||
|
||||
static LedString createLedString(const Json::Value& ledsConfig);
|
||||
|
||||
static Json::Value loadConfig(const std::string& configFile);
|
||||
|
||||
Hyperion(const std::string& configFile);
|
||||
Hyperion(const Json::Value& jsonConfig);
|
||||
|
||||
~Hyperion();
|
||||
@ -62,6 +57,11 @@ public:
|
||||
|
||||
const InputInfo& getPriorityInfo(const int priority) const;
|
||||
|
||||
static LedDevice* constructDevice(const Json::Value & deviceConfig);
|
||||
static LedString createLedString(const Json::Value & ledsConfig);
|
||||
static HsvTransform * createHsvTransform(const Json::Value & hsvConfig);
|
||||
static ColorTransform* createColorTransform(const Json::Value & colorConfig);
|
||||
|
||||
private slots:
|
||||
void update();
|
||||
|
||||
|
@ -23,7 +23,7 @@ class XBMCVideoChecker : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
XBMCVideoChecker(QString address, uint16_t port, uint64_t interval, Hyperion * hyperion, int priority);
|
||||
XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval, Hyperion * hyperion, int priority);
|
||||
|
||||
void start();
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
|
||||
// QT includes
|
||||
#include <QDateTime>
|
||||
#include <QResource>
|
||||
|
||||
// JsonSchema include
|
||||
#include <utils/jsonschema/JsonFactory.h>
|
||||
@ -17,7 +16,7 @@
|
||||
#include <utils/ColorTransform.h>
|
||||
#include <utils/HsvTransform.h>
|
||||
|
||||
LedDevice* constructDevice(const Json::Value& deviceConfig)
|
||||
LedDevice* Hyperion::constructDevice(const Json::Value& deviceConfig)
|
||||
{
|
||||
std::cout << "Device configuration: " << deviceConfig << std::endl;
|
||||
LedDevice* device = nullptr;
|
||||
@ -44,12 +43,12 @@ LedDevice* constructDevice(const Json::Value& deviceConfig)
|
||||
return device;
|
||||
}
|
||||
|
||||
HsvTransform * createHsvTransform(const Json::Value & hsvConfig)
|
||||
HsvTransform * Hyperion::createHsvTransform(const Json::Value & hsvConfig)
|
||||
{
|
||||
return new HsvTransform(hsvConfig["saturationGain"].asDouble(), hsvConfig["valueGain"].asDouble());
|
||||
}
|
||||
|
||||
ColorTransform* createColorTransform(const Json::Value& colorConfig)
|
||||
ColorTransform* Hyperion::createColorTransform(const Json::Value& colorConfig)
|
||||
{
|
||||
const double threshold = colorConfig["threshold"].asDouble();
|
||||
const double gamma = colorConfig["gamma"].asDouble();
|
||||
@ -79,36 +78,6 @@ LedString Hyperion::createLedString(const Json::Value& ledsConfig)
|
||||
return ledString;
|
||||
}
|
||||
|
||||
Json::Value Hyperion::loadConfig(const std::string& configFile)
|
||||
{
|
||||
// make sure the resources are loaded (they may be left out after static linking)
|
||||
Q_INIT_RESOURCE(resource);
|
||||
|
||||
// read the json schema from the resource
|
||||
QResource schemaData(":/hyperion-schema");
|
||||
assert(schemaData.isValid());
|
||||
|
||||
Json::Reader jsonReader;
|
||||
Json::Value schemaJson;
|
||||
if (!jsonReader.parse(reinterpret_cast<const char *>(schemaData.data()), reinterpret_cast<const char *>(schemaData.data()) + schemaData.size(), schemaJson, false))
|
||||
{
|
||||
throw std::runtime_error("Schema error: " + jsonReader.getFormattedErrorMessages()) ;
|
||||
}
|
||||
JsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
|
||||
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
|
||||
schemaChecker.validate(jsonConfig);
|
||||
|
||||
return jsonConfig;
|
||||
}
|
||||
|
||||
Hyperion::Hyperion(const std::string& configFile) :
|
||||
Hyperion(loadConfig(configFile))
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
||||
_ledString(createLedString(jsonConfig["leds"])),
|
||||
_muxer(_ledString.leds().size()),
|
||||
|
@ -164,6 +164,27 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"xbmcVideoChecker" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" : {
|
||||
"enable" : {
|
||||
"type" : "boolean",
|
||||
"required" : true
|
||||
},
|
||||
"xbmcAddress" : {
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"xbmcTcpPort" : {
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
#include <xbmcvideochecker/XBMCVideoChecker.h>
|
||||
|
||||
XBMCVideoChecker::XBMCVideoChecker(QString address, uint16_t port, uint64_t interval_ms, Hyperion * hyperion, int priority) :
|
||||
XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval_ms, Hyperion * hyperion, int priority) :
|
||||
QObject(),
|
||||
_address(address),
|
||||
_address(QString::fromStdString(address)),
|
||||
_port(port),
|
||||
_request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"),
|
||||
_timer(),
|
||||
@ -48,7 +48,7 @@ void XBMCVideoChecker::sendRequest()
|
||||
|
||||
void XBMCVideoChecker::receiveReply()
|
||||
{
|
||||
// expect that the reply is received as a single message. Probaly oke considering the size of the expected reply
|
||||
// expect that the reply is received as a single message. Probably oke considering the size of the expected reply
|
||||
QString reply(_socket.readAll());
|
||||
|
||||
if (reply.contains("playerid"))
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
// QT includes
|
||||
#include <QCoreApplication>
|
||||
#include <QResource>
|
||||
|
||||
// Json-Schema includes
|
||||
#include <utils/jsonschema/JsonFactory.h>
|
||||
@ -26,6 +27,30 @@ void signal_handler(const int signum)
|
||||
QCoreApplication::quit();
|
||||
}
|
||||
|
||||
Json::Value loadConfig(const std::string & configFile)
|
||||
{
|
||||
// make sure the resources are loaded (they may be left out after static linking)
|
||||
Q_INIT_RESOURCE(resource);
|
||||
|
||||
// read the json schema from the resource
|
||||
QResource schemaData(":/hyperion-schema");
|
||||
assert(schemaData.isValid());
|
||||
|
||||
Json::Reader jsonReader;
|
||||
Json::Value schemaJson;
|
||||
if (!jsonReader.parse(reinterpret_cast<const char *>(schemaData.data()), reinterpret_cast<const char *>(schemaData.data()) + schemaData.size(), schemaJson, false))
|
||||
{
|
||||
throw std::runtime_error("Schema error: " + jsonReader.getFormattedErrorMessages()) ;
|
||||
}
|
||||
JsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
|
||||
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
|
||||
schemaChecker.validate(jsonConfig);
|
||||
|
||||
return jsonConfig;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Initialising QCoreApplication
|
||||
@ -44,15 +69,21 @@ int main(int argc, char** argv)
|
||||
|
||||
const std::string configFile = argv[1];
|
||||
std::cout << "Selected configuration file: " << configFile.c_str() << std::endl;
|
||||
const Json::Value config = loadConfig(configFile);
|
||||
|
||||
Hyperion hyperion(configFile);
|
||||
Hyperion hyperion(config);
|
||||
std::cout << "Hyperion created and initialised" << std::endl;
|
||||
|
||||
RainbowBootSequence bootSequence(&hyperion);
|
||||
bootSequence.start();
|
||||
|
||||
XBMCVideoChecker xbmcVideoChecker("127.0.0.1", 9090, 1000, &hyperion, 999);
|
||||
const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"];
|
||||
XBMCVideoChecker xbmcVideoChecker(videoCheckerConfig["xbmcAddress"].asString(), videoCheckerConfig["xbmcTcpPort"].asUInt(), 1000, &hyperion, 999);
|
||||
if (videoCheckerConfig["enable"].asBool())
|
||||
{
|
||||
xbmcVideoChecker.start();
|
||||
std::cout << "XBMC video checker created and started" << std::endl;
|
||||
}
|
||||
|
||||
DispmanxWrapper dispmanx(64, 64, 10, &hyperion);
|
||||
dispmanx.start();
|
||||
@ -61,11 +92,14 @@ int main(int argc, char** argv)
|
||||
JsonServer jsonServer(&hyperion);
|
||||
std::cout << "Json server created and started on port " << jsonServer.getPort() << std::endl;
|
||||
|
||||
app.exec();
|
||||
std::cout << "Application closed" << std::endl;
|
||||
// run the application
|
||||
int rc = app.exec();
|
||||
|
||||
std::cout << "Application closed" << std::endl;
|
||||
// Stop the frame grabber
|
||||
dispmanx.stop();
|
||||
// Clear all colors (switchting off all leds)
|
||||
hyperion.clearall();
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user