Merge remote-tracking branch 'refs/remotes/hyperion-project/master' into weba

This commit is contained in:
brindosch
2017-01-24 21:30:00 +01:00
16 changed files with 350 additions and 128 deletions

View File

@@ -1,11 +1,18 @@
SET(Hyperiond_QT_HEADERS
hyperiond.h
)
QT5_WRAP_CPP(Hyperiond_HEADERS_MOC ${Hyperiond_QT_HEADERS})
add_executable(hyperiond
${Hyperiond_QT_HEADERS}
${Hyperiond_HEADERS_MOC}
configMigratorBase.cpp
configMigratorBase.h
configMigrator.cpp
configMigrator.h
hyperiond.cpp
hyperiond.h
main.cpp
)

View File

@@ -79,6 +79,13 @@ HyperionDaemon::HyperionDaemon(QString configFile, QObject *parent)
HyperionDaemon::~HyperionDaemon()
{
freeObjects();
delete _hyperion;
}
void HyperionDaemon::freeObjects()
{
Debug(_log, "destroy grabbers and network stuff");
delete _amlGrabber;
delete _dispmanx;
delete _fbGrabber;
@@ -92,8 +99,17 @@ HyperionDaemon::~HyperionDaemon()
delete _protoServer;
delete _boblightServer;
delete _udpListener;
delete _hyperion;
_v4l2Grabbers.clear();
_amlGrabber = nullptr;
_dispmanx = nullptr;
_fbGrabber = nullptr;
_osxGrabber = nullptr;
_kodiVideoChecker = nullptr;
_jsonServer = nullptr;
_protoServer = nullptr;
_boblightServer = nullptr;
_udpListener = nullptr;
}
void HyperionDaemon::run()
@@ -113,56 +129,33 @@ void HyperionDaemon::run()
#endif
Info(_log, "Hyperion started");
connect(_hyperion,SIGNAL(closing()),this,SLOT(freeObjects()));
}
int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVersion)
{
// make sure the resources are loaded (they may be left out after static linking)
Q_INIT_RESOURCE(resource);
QJsonParseError error;
// read the json schema from the resource
QString schemaFile = ":/hyperion-schema";
if (schemaVersion > 0)
schemaFile += "-" + QString::number(schemaVersion);
QFile schemaData(schemaFile);
if (!schemaData.open(QIODevice::ReadOnly))
{
std::stringstream error;
error << "Schema not found or not supported: " << schemaData.errorString().toStdString();
throw std::runtime_error(error.str());
}
QByteArray schema = schemaData.readAll();
QJsonDocument schemaJson = QJsonDocument::fromJson(schema, &error);
schemaData.close();
if (error.error != QJsonParseError::NoError)
{
// report to the user the failure and their locations in the document.
int errorLine(0), errorColumn(0);
for( int i=0, count=qMin( error.offset,schema.size()); i<count; ++i )
{
++errorColumn;
if(schema.at(i) == '\n' )
{
errorColumn = 0;
++errorLine;
}
}
std::stringstream sstream;
sstream << "ERROR: Json schema wrong: " << error.errorString().toStdString() << " at Line: " << errorLine << ", Column: " << errorColumn;
schemaFile += "-" + QString::number(schemaVersion);
throw std::runtime_error(sstream.str());
QJsonObject schemaJson;
try
{
schemaJson = QJsonFactory::readSchema(schemaFile);
}
catch(const std::runtime_error& error)
{
throw std::runtime_error(error.what());
}
QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson.object());
schemaChecker.setSchema(schemaJson);
_qconfig = QJsonFactory::readJson(configFile);
_qconfig = QJsonFactory::readConfig(configFile);
if (!schemaChecker.validate(_qconfig))
{
for (std::list<std::string>::const_iterator i = schemaChecker.getMessages().begin(); i != schemaChecker.getMessages().end(); ++i)
@@ -177,7 +170,6 @@ int HyperionDaemon::tryLoadConfig(const QString & configFile, const int schemaVe
return generalConfig["configVersion"].toInt(-1);
}
void HyperionDaemon::loadConfig(const QString & configFile, const int neededConfigVersion)
{
Info(_log, "Selected configuration file: %s", configFile.toUtf8().constData());
@@ -472,7 +464,7 @@ void HyperionDaemon::createSystemFrameGrabber()
else if (type == "x11") createGrabberX11(grabberConfig);
else { Warning( _log, "unknown framegrabber type '%s'", type.toUtf8().constData()); grabberCompState = false; }
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_GRABBER, grabberCompState);
// _hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_GRABBER, grabberCompState);
_hyperion->setComponentState(hyperion::COMP_GRABBER, grabberCompState );
}
}

View File

@@ -49,6 +49,7 @@
class HyperionDaemon : public QObject
{
Q_OBJECT
public:
HyperionDaemon(QString configFile, QObject *parent=nullptr);
~HyperionDaemon();
@@ -65,6 +66,9 @@ public:
void createGrabberV4L2();
void createSystemFrameGrabber();
public slots:
void freeObjects();
private:
void createGrabberDispmanx();
void createGrabberAmlogic();