2016-05-30 22:38:40 +02:00
|
|
|
#include <unistd.h>
|
2013-08-22 22:06:13 +02:00
|
|
|
|
2013-08-13 11:10:45 +02:00
|
|
|
#include <QCoreApplication>
|
2013-08-24 11:51:52 +02:00
|
|
|
#include <QResource>
|
2014-01-28 22:27:02 +01:00
|
|
|
#include <QLocale>
|
2016-05-24 19:56:43 +02:00
|
|
|
#include <QFile>
|
2016-06-17 01:25:40 +02:00
|
|
|
#include <QHostInfo>
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2013-11-19 23:02:41 +01:00
|
|
|
#include "HyperionConfig.h"
|
|
|
|
|
2013-08-14 10:54:49 +02:00
|
|
|
#include <utils/jsonschema/JsonFactory.h>
|
|
|
|
|
|
|
|
#include <hyperion/Hyperion.h>
|
2013-11-24 16:10:48 +01:00
|
|
|
#include <effectengine/EffectEngine.h>
|
2016-05-31 22:55:11 +02:00
|
|
|
#include <bonjour/bonjourserviceregister.h>
|
|
|
|
#include <bonjour/bonjourrecord.h>
|
2013-08-17 15:39:29 +02:00
|
|
|
#include <jsonserver/JsonServer.h>
|
2016-06-12 22:27:24 +02:00
|
|
|
#include <protoserver/ProtoServer.h>
|
|
|
|
#include <boblightserver/BoblightServer.h>
|
2016-06-20 08:38:12 +02:00
|
|
|
#include <udplistener/UDPListener.h>
|
2016-05-30 22:38:40 +02:00
|
|
|
|
2016-06-17 01:25:40 +02:00
|
|
|
#include "hyperiond.h"
|
2013-11-08 22:18:10 +01:00
|
|
|
|
2013-08-22 22:06:13 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
HyperionDaemon::HyperionDaemon(std::string configFile, QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, _log(Logger::getInstance("MAIN"))
|
|
|
|
, _xbmcVideoChecker(nullptr)
|
|
|
|
, _jsonServer(nullptr)
|
|
|
|
, _protoServer(nullptr)
|
|
|
|
, _boblightServer(nullptr)
|
2016-06-20 08:38:12 +02:00
|
|
|
, _udpListener(nullptr)
|
2016-06-19 00:56:47 +02:00
|
|
|
, _v4l2Grabber(nullptr)
|
|
|
|
, _dispmanx(nullptr)
|
|
|
|
, _amlGrabber(nullptr)
|
|
|
|
, _fbGrabber(nullptr)
|
|
|
|
, _osxGrabber(nullptr)
|
|
|
|
, _webConfig(nullptr)
|
2016-06-20 09:10:23 +02:00
|
|
|
, _hyperion(nullptr)
|
2016-06-19 00:56:47 +02:00
|
|
|
{
|
|
|
|
loadConfig(configFile);
|
2016-06-20 09:10:23 +02:00
|
|
|
_hyperion = Hyperion::initInstance(_config, configFile);
|
2016-06-19 00:56:47 +02:00
|
|
|
Info(_log, "Hyperion started and initialised");
|
|
|
|
}
|
|
|
|
|
|
|
|
HyperionDaemon::~HyperionDaemon()
|
|
|
|
{
|
|
|
|
delete _amlGrabber;
|
|
|
|
delete _dispmanx;
|
|
|
|
delete _fbGrabber;
|
|
|
|
delete _osxGrabber;
|
|
|
|
delete _v4l2Grabber;
|
|
|
|
delete _xbmcVideoChecker;
|
|
|
|
delete _jsonServer;
|
|
|
|
delete _protoServer;
|
|
|
|
delete _boblightServer;
|
2016-06-20 08:38:12 +02:00
|
|
|
delete _udpListener;
|
2016-06-19 00:56:47 +02:00
|
|
|
delete _webConfig;
|
2016-06-20 09:10:23 +02:00
|
|
|
delete _hyperion;
|
2016-06-19 00:56:47 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void HyperionDaemon::run()
|
|
|
|
{
|
|
|
|
startBootsequence();
|
|
|
|
createXBMCVideoChecker();
|
|
|
|
|
|
|
|
// ---- network services -----
|
|
|
|
startNetworkServices();
|
|
|
|
_webConfig = new WebConfig(this);
|
|
|
|
|
|
|
|
// ---- grabber -----
|
|
|
|
createGrabberV4L2();
|
|
|
|
createGrabberDispmanx();
|
|
|
|
createGrabberAmlogic();
|
|
|
|
createGrabberFramebuffer();
|
|
|
|
createGrabberDispmanx();
|
|
|
|
|
|
|
|
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX) && !defined(ENABLE_FB)
|
2016-06-19 17:18:11 +02:00
|
|
|
ErrorIf(_config.isMember("framegrabber"), _log, "No grabber can be instantiated, because all grabbers have been left out from the build");
|
2016-06-19 00:56:47 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void HyperionDaemon::loadConfig(const std::string & configFile)
|
|
|
|
{
|
|
|
|
Info(_log, "Selected configuration file: %s", configFile.c_str() );
|
|
|
|
// 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("ERROR: Json schema wrong: " + jsonReader.getFormattedErrorMessages()) ;
|
|
|
|
}
|
|
|
|
JsonSchemaChecker schemaChecker;
|
|
|
|
schemaChecker.setSchema(schemaJson);
|
|
|
|
|
|
|
|
_config = JsonFactory::readJson(configFile);
|
|
|
|
schemaChecker.validate(_config);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HyperionDaemon::startBootsequence()
|
2013-08-24 11:51:52 +02:00
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
Hyperion *hyperion = Hyperion::getInstance();
|
2013-08-24 11:51:52 +02:00
|
|
|
|
2013-10-13 14:48:59 +02:00
|
|
|
// create boot sequence if the configuration is present
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("bootsequence"))
|
2013-08-25 18:20:19 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value effectConfig = _config["bootsequence"];
|
2013-12-13 15:55:34 +01:00
|
|
|
|
|
|
|
// Get the parameters for the bootsequence
|
|
|
|
const std::string effectName = effectConfig["effect"].asString();
|
|
|
|
const unsigned duration_ms = effectConfig["duration_ms"].asUInt();
|
2016-05-23 11:01:52 +02:00
|
|
|
const int priority = (duration_ms != 0) ? 0 : effectConfig.get("priority",990).asInt();
|
|
|
|
const int bootcolor_priority = (priority > 990) ? priority+1 : 990;
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-03-12 19:21:47 +01:00
|
|
|
// clear the leds
|
|
|
|
ColorRgb boot_color = ColorRgb::BLACK;
|
2016-06-17 01:25:40 +02:00
|
|
|
hyperion->setColor(bootcolor_priority, boot_color, 0, false);
|
2016-01-31 22:38:30 +01:00
|
|
|
|
2016-03-12 19:21:47 +01:00
|
|
|
// start boot effect
|
|
|
|
if ( ! effectName.empty() )
|
2016-01-31 22:38:30 +01:00
|
|
|
{
|
2016-03-12 19:21:47 +01:00
|
|
|
int result;
|
2016-03-23 17:40:34 +01:00
|
|
|
std::cout << "INFO: Boot sequence '" << effectName << "' ";
|
2016-03-12 19:21:47 +01:00
|
|
|
if (effectConfig.isMember("args"))
|
2014-09-22 20:19:58 +02:00
|
|
|
{
|
2016-03-12 19:21:47 +01:00
|
|
|
std::cout << " (with user defined arguments) ";
|
|
|
|
const Json::Value effectConfigArgs = effectConfig["args"];
|
2016-06-17 01:25:40 +02:00
|
|
|
result = hyperion->setEffect(effectName, effectConfigArgs, priority, duration_ms);
|
2014-09-22 20:19:58 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
result = hyperion->setEffect(effectName, priority, duration_ms);
|
2014-09-22 20:19:58 +02:00
|
|
|
}
|
2016-03-12 19:21:47 +01:00
|
|
|
std::cout << ((result == 0) ? "started" : "failed") << std::endl;
|
2013-12-13 19:59:01 +01:00
|
|
|
}
|
2016-03-12 19:21:47 +01:00
|
|
|
|
|
|
|
// static color
|
|
|
|
if ( ! effectConfig["color"].isNull() && effectConfig["color"].isArray() && effectConfig["color"].size() == 3 )
|
2013-12-13 19:59:01 +01:00
|
|
|
{
|
2016-03-12 19:21:47 +01:00
|
|
|
boot_color = {
|
|
|
|
(uint8_t)effectConfig["color"][0].asUInt(),
|
|
|
|
(uint8_t)effectConfig["color"][1].asUInt(),
|
|
|
|
(uint8_t)effectConfig["color"][2].asUInt()
|
|
|
|
};
|
2013-10-16 18:04:43 +02:00
|
|
|
}
|
2016-03-12 19:21:47 +01:00
|
|
|
|
2016-06-17 01:25:40 +02:00
|
|
|
hyperion->setColor(bootcolor_priority, boot_color, 0, false);
|
2013-08-25 18:20:19 +02:00
|
|
|
}
|
2016-05-30 22:38:40 +02:00
|
|
|
}
|
2013-08-23 18:24:10 +02:00
|
|
|
|
2016-05-30 22:38:40 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
// create XBMC video checker if the _configuration is present
|
|
|
|
void HyperionDaemon::createXBMCVideoChecker()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("xbmcVideoChecker"))
|
2013-10-13 14:48:59 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & videoCheckerConfig = _config["xbmcVideoChecker"];
|
|
|
|
_xbmcVideoChecker = XBMCVideoChecker::initInstance(
|
2013-09-24 21:45:27 +02:00
|
|
|
videoCheckerConfig["xbmcAddress"].asString(),
|
|
|
|
videoCheckerConfig["xbmcTcpPort"].asUInt(),
|
|
|
|
videoCheckerConfig["grabVideo"].asBool(),
|
|
|
|
videoCheckerConfig["grabPictures"].asBool(),
|
|
|
|
videoCheckerConfig["grabAudio"].asBool(),
|
2013-12-21 14:32:30 +01:00
|
|
|
videoCheckerConfig["grabMenu"].asBool(),
|
2016-06-07 12:34:50 +02:00
|
|
|
videoCheckerConfig.get("grabPause", true).asBool(),
|
2013-12-21 14:32:30 +01:00
|
|
|
videoCheckerConfig.get("grabScreensaver", true).asBool(),
|
|
|
|
videoCheckerConfig.get("enable3DDetection", true).asBool());
|
2013-10-13 14:48:59 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_xbmcVideoChecker->start();
|
|
|
|
Info(_log, "Kodi checker created and started");
|
2013-08-24 11:51:52 +02:00
|
|
|
}
|
2016-05-30 22:38:40 +02:00
|
|
|
}
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
void HyperionDaemon::startNetworkServices()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
Hyperion *hyperion = Hyperion::getInstance();
|
|
|
|
XBMCVideoChecker* xbmcVideoChecker = XBMCVideoChecker::getInstance();
|
|
|
|
|
2016-02-16 15:41:40 +01:00
|
|
|
// Create Json server if configuration is present
|
2016-06-08 11:53:01 +02:00
|
|
|
unsigned int jsonPort = 19444;
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("jsonServer"))
|
2016-02-16 15:41:40 +01:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & jsonServerConfig = _config["jsonServer"];
|
2016-06-08 11:53:01 +02:00
|
|
|
//jsonEnable = jsonServerConfig.get("enable", true).asBool();
|
2016-06-14 20:14:06 +02:00
|
|
|
jsonPort = jsonServerConfig.get("port", jsonPort).asUInt();
|
2016-02-16 15:41:40 +01:00
|
|
|
}
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_jsonServer = new JsonServer(jsonPort );
|
|
|
|
Info(_log, "Json server created and started on port %d", _jsonServer->getPort());
|
2016-06-08 11:53:01 +02:00
|
|
|
|
2016-02-16 15:41:40 +01:00
|
|
|
// Create Proto server if configuration is present
|
2016-06-08 11:53:01 +02:00
|
|
|
unsigned int protoPort = 19445;
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("protoServer"))
|
2016-02-16 15:41:40 +01:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & protoServerConfig = _config["protoServer"];
|
2016-06-08 11:53:01 +02:00
|
|
|
//protoEnable = protoServerConfig.get("enable", true).asBool();
|
2016-06-14 20:14:06 +02:00
|
|
|
protoPort = protoServerConfig.get("port", protoPort).asUInt();
|
2016-06-08 11:53:01 +02:00
|
|
|
}
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_protoServer = new ProtoServer(protoPort );
|
2016-06-08 11:53:01 +02:00
|
|
|
if (xbmcVideoChecker != nullptr)
|
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _protoServer, SIGNAL(grabbingMode(GrabbingMode)));
|
|
|
|
QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), _protoServer, SIGNAL(videoMode(VideoMode)));
|
2016-06-08 11:53:01 +02:00
|
|
|
}
|
2016-06-19 00:56:47 +02:00
|
|
|
Info(_log, "Proto server created and started on port %d", _protoServer->getPort());
|
2016-06-04 19:26:34 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
// Create Boblight server if configuration is present
|
|
|
|
if (_config.isMember("boblightServer"))
|
|
|
|
{
|
|
|
|
const Json::Value & boblightServerConfig = _config["boblightServer"];
|
|
|
|
_boblightServer = new BoblightServer(hyperion, boblightServerConfig.get("priority",900).asInt(), boblightServerConfig["port"].asUInt());
|
|
|
|
Info(_log, "Boblight server created and started on port %d", _boblightServer->getPort());
|
|
|
|
}
|
2016-06-08 11:53:01 +02:00
|
|
|
|
2016-06-20 08:38:12 +02:00
|
|
|
// Create UDP listener if configuration is present
|
|
|
|
if (_config.isMember("udpListener"))
|
|
|
|
{
|
|
|
|
const Json::Value & udpListenerConfig = _config["udpListener"];
|
|
|
|
_udpListener = new UDPListener(hyperion,
|
|
|
|
udpListenerConfig.get("priority",890).asInt(),
|
|
|
|
udpListenerConfig.get("timeout",10000).asInt(),
|
|
|
|
udpListenerConfig["port"].asUInt()
|
|
|
|
);
|
|
|
|
Info(_log, "UDP listener created and started on port %d", _udpListener->getPort());
|
|
|
|
}
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
// zeroconf
|
|
|
|
const Json::Value & deviceConfig = _config["device"];
|
|
|
|
const std::string deviceName = deviceConfig.get("name", "").asString();
|
2016-06-08 11:53:01 +02:00
|
|
|
const std::string hostname = QHostInfo::localHostName().toStdString();
|
2016-06-19 00:56:47 +02:00
|
|
|
|
|
|
|
// zeroconf json
|
2016-06-14 20:14:06 +02:00
|
|
|
std::string mDNSDescr_json = hostname;
|
|
|
|
std::string mDNSService_json = "_hyperiond_json._tcp";
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("jsonServer"))
|
2016-06-14 20:14:06 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & jsonServerConfig = _config["jsonServer"];
|
2016-06-14 20:14:06 +02:00
|
|
|
mDNSDescr_json = jsonServerConfig.get("mDNSDescr", mDNSDescr_json).asString();
|
|
|
|
mDNSService_json = jsonServerConfig.get("mDNSService", mDNSService_json).asString();
|
|
|
|
}
|
|
|
|
|
|
|
|
BonjourServiceRegister *bonjourRegister_json = new BonjourServiceRegister();
|
|
|
|
bonjourRegister_json->registerService(BonjourRecord((deviceName + " @ " + mDNSDescr_json).c_str(), mDNSService_json.c_str(),
|
2016-06-19 00:56:47 +02:00
|
|
|
QString()), _jsonServer->getPort() );
|
|
|
|
Info(_log, "Json mDNS responder started");
|
2016-06-08 11:53:01 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
// zeroconf proto
|
2016-06-14 20:14:06 +02:00
|
|
|
std::string mDNSDescr_proto = hostname;
|
|
|
|
std::string mDNSService_proto = "_hyperiond_proto._tcp";
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("protoServer"))
|
2016-06-14 20:14:06 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & protoServerConfig = _config["protoServer"];
|
2016-06-14 20:14:06 +02:00
|
|
|
mDNSDescr_proto = protoServerConfig.get("mDNSDescr", mDNSDescr_proto).asString();
|
|
|
|
mDNSService_proto = protoServerConfig.get("mDNSService", mDNSService_proto).asString();
|
|
|
|
}
|
|
|
|
|
|
|
|
BonjourServiceRegister *bonjourRegister_proto = new BonjourServiceRegister();
|
|
|
|
bonjourRegister_proto->registerService(BonjourRecord((deviceName + " @ " + mDNSDescr_proto).c_str(), mDNSService_proto.c_str(),
|
2016-06-19 00:56:47 +02:00
|
|
|
QString()), _protoServer->getPort() );
|
|
|
|
Info(_log, "Proto mDNS responder started");
|
2016-02-16 15:41:40 +01:00
|
|
|
|
2016-05-30 22:38:40 +02:00
|
|
|
}
|
2016-02-16 15:41:40 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
void HyperionDaemon::createGrabberDispmanx()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
#ifdef ENABLE_DISPMANX
|
2013-10-13 14:48:59 +02:00
|
|
|
// Construct and start the frame-grabber if the configuration is present
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("framegrabber"))
|
2013-10-13 14:48:59 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & frameGrabberConfig = _config["framegrabber"];
|
|
|
|
_dispmanx = new DispmanxWrapper(
|
2013-08-25 18:20:19 +02:00
|
|
|
frameGrabberConfig["width"].asUInt(),
|
|
|
|
frameGrabberConfig["height"].asUInt(),
|
|
|
|
frameGrabberConfig["frequency_Hz"].asUInt(),
|
2016-06-17 01:25:40 +02:00
|
|
|
frameGrabberConfig.get("priority",900).asInt());
|
2016-06-19 00:56:47 +02:00
|
|
|
_dispmanx->setCropping(
|
2016-05-18 11:26:25 +02:00
|
|
|
frameGrabberConfig.get("cropLeft", 0).asInt(),
|
|
|
|
frameGrabberConfig.get("cropRight", 0).asInt(),
|
|
|
|
frameGrabberConfig.get("cropTop", 0).asInt(),
|
|
|
|
frameGrabberConfig.get("cropBottom", 0).asInt());
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_xbmcVideoChecker != nullptr)
|
2013-10-13 14:48:59 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _dispmanx, SLOT(setGrabbingMode(GrabbingMode)));
|
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), _dispmanx, SLOT(setVideoMode(VideoMode)));
|
2013-10-13 14:48:59 +02:00
|
|
|
}
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_dispmanx, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
|
2016-02-17 00:44:06 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_dispmanx->start();
|
|
|
|
Info(_log, "Frame grabber created and started");
|
2013-10-13 14:48:59 +02:00
|
|
|
}
|
2016-06-19 00:56:47 +02:00
|
|
|
#else
|
|
|
|
ErrorIf(_config.isMember("framegrabber"), _log, "The dispmanx framegrabber can not be instantiated, because it has been left out from the build");
|
2015-01-18 00:04:45 +01:00
|
|
|
#endif
|
2016-06-17 01:25:40 +02:00
|
|
|
}
|
2013-10-13 14:48:59 +02:00
|
|
|
|
2016-06-17 01:25:40 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
void HyperionDaemon::createGrabberV4L2()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2014-02-21 22:30:34 +01:00
|
|
|
// construct and start the v4l2 grabber if the configuration is present
|
2016-06-17 01:25:40 +02:00
|
|
|
#ifdef ENABLE_V4L2
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("grabber-v4l2"))
|
2014-02-21 22:30:34 +01:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & grabberConfig = _config["grabber-v4l2"];
|
|
|
|
_v4l2Grabber = new V4L2Wrapper(
|
2014-02-21 22:30:34 +01:00
|
|
|
grabberConfig.get("device", "/dev/video0").asString(),
|
|
|
|
grabberConfig.get("input", 0).asInt(),
|
2014-02-23 22:39:23 +01:00
|
|
|
parseVideoStandard(grabberConfig.get("standard", "no-change").asString()),
|
2014-03-31 17:36:36 +02:00
|
|
|
parsePixelFormat(grabberConfig.get("pixelFormat", "no-change").asString()),
|
2014-02-21 22:30:34 +01:00
|
|
|
grabberConfig.get("width", -1).asInt(),
|
|
|
|
grabberConfig.get("height", -1).asInt(),
|
|
|
|
grabberConfig.get("frameDecimation", 2).asInt(),
|
|
|
|
grabberConfig.get("sizeDecimation", 8).asInt(),
|
2014-03-04 22:04:15 +01:00
|
|
|
grabberConfig.get("redSignalThreshold", 0.0).asDouble(),
|
|
|
|
grabberConfig.get("greenSignalThreshold", 0.0).asDouble(),
|
|
|
|
grabberConfig.get("blueSignalThreshold", 0.0).asDouble(),
|
2016-03-08 17:31:56 +01:00
|
|
|
grabberConfig.get("priority", 900).asInt());
|
2016-06-19 00:56:47 +02:00
|
|
|
_v4l2Grabber->set3D(parse3DMode(grabberConfig.get("mode", "2D").asString()));
|
|
|
|
_v4l2Grabber->setCropping(
|
2014-02-21 22:30:34 +01:00
|
|
|
grabberConfig.get("cropLeft", 0).asInt(),
|
|
|
|
grabberConfig.get("cropRight", 0).asInt(),
|
|
|
|
grabberConfig.get("cropTop", 0).asInt(),
|
|
|
|
grabberConfig.get("cropBottom", 0).asInt());
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
|
2016-02-16 15:41:40 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_v4l2Grabber->start();
|
|
|
|
Info(_log, "V4L2 grabber created and started");
|
2014-02-21 22:30:34 +01:00
|
|
|
}
|
2016-06-19 00:56:47 +02:00
|
|
|
#else
|
|
|
|
ErrorIf(_config.isMember("grabber-v4l2"), _log, "The v4l2 grabber can not be instantiated, because it has been left out from the build");
|
2014-02-21 22:30:34 +01:00
|
|
|
#endif
|
2016-06-17 01:25:40 +02:00
|
|
|
}
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
void HyperionDaemon::createGrabberAmlogic()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
#ifdef ENABLE_AMLOGIC
|
2015-08-20 09:51:44 +02:00
|
|
|
// Construct and start the framebuffer grabber if the configuration is present
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("amlgrabber"))
|
2015-08-20 09:51:44 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & grabberConfig = _config["amlgrabber"];
|
|
|
|
_amlGrabber = new AmlogicWrapper(
|
2015-08-20 09:51:44 +02:00
|
|
|
grabberConfig["width"].asUInt(),
|
|
|
|
grabberConfig["height"].asUInt(),
|
|
|
|
grabberConfig["frequency_Hz"].asUInt(),
|
2016-06-17 01:25:40 +02:00
|
|
|
grabberConfig.get("priority",900).asInt());
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_xbmcVideoChecker != nullptr)
|
2015-08-20 09:51:44 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _amlGrabber, SLOT(setGrabbingMode(GrabbingMode)));
|
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), _amlGrabber, SLOT(setVideoMode(VideoMode)));
|
2015-08-20 09:51:44 +02:00
|
|
|
}
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_amlGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
|
2016-02-24 14:42:25 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_amlGrabber->start();
|
|
|
|
Info(_log, "AMLOGIC grabber created and started");
|
2015-08-20 09:51:44 +02:00
|
|
|
}
|
2016-06-19 00:56:47 +02:00
|
|
|
#else
|
|
|
|
ErrorIf(_config.isMember("amlgrabber"), _log, "The AMLOGIC grabber can not be instantiated, because it has been left out from the build");
|
2015-08-20 09:51:44 +02:00
|
|
|
#endif
|
2016-06-17 01:25:40 +02:00
|
|
|
}
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-05-30 22:38:40 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
void HyperionDaemon::createGrabberFramebuffer()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
#ifdef ENABLE_FB
|
2015-01-18 00:04:45 +01:00
|
|
|
// Construct and start the framebuffer grabber if the configuration is present
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("framebuffergrabber") || _config.isMember("framegrabber"))
|
2015-01-18 00:04:45 +01:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & grabberConfig = _config.isMember("framebuffergrabber")? _config["framebuffergrabber"] : _config["framegrabber"];
|
|
|
|
_fbGrabber = new FramebufferWrapper(
|
2015-01-18 00:04:45 +01:00
|
|
|
grabberConfig.get("device", "/dev/fb0").asString(),
|
|
|
|
grabberConfig["width"].asUInt(),
|
|
|
|
grabberConfig["height"].asUInt(),
|
|
|
|
grabberConfig["frequency_Hz"].asUInt(),
|
2016-06-17 01:25:40 +02:00
|
|
|
grabberConfig.get("priority",900).asInt());
|
2015-01-18 00:04:45 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_xbmcVideoChecker != nullptr)
|
2015-01-18 00:04:45 +01:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _fbGrabber, SLOT(setGrabbingMode(GrabbingMode)));
|
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), _fbGrabber, SLOT(setVideoMode(VideoMode)));
|
2015-01-18 00:04:45 +01:00
|
|
|
}
|
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_fbGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
|
2016-02-17 00:44:06 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_fbGrabber->start();
|
|
|
|
Info(_log, "Framebuffer grabber created and started");
|
2015-01-18 00:04:45 +01:00
|
|
|
}
|
2016-06-19 00:56:47 +02:00
|
|
|
#else
|
|
|
|
ErrorIf(_config.isMember("framebuffergrabber"), _log, "The framebuffer grabber can not be instantiated, because it has been left out from the build");
|
2015-01-18 00:04:45 +01:00
|
|
|
#endif
|
2016-06-17 01:25:40 +02:00
|
|
|
}
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-05-30 22:38:40 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
void HyperionDaemon::createGrabberOsx()
|
2016-05-30 22:38:40 +02:00
|
|
|
{
|
2016-06-17 01:25:40 +02:00
|
|
|
#ifdef ENABLE_OSX
|
2015-08-20 09:51:44 +02:00
|
|
|
// Construct and start the osx grabber if the configuration is present
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_config.isMember("framegrabber"))
|
2015-08-20 09:51:44 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
const Json::Value & grabberConfig = _config.isMember("osxgrabber")? _config["osxgrabber"] : _config["framegrabber"];
|
|
|
|
_osxGrabber = new OsxWrapper(
|
2016-03-08 17:31:56 +01:00
|
|
|
grabberConfig.get("display", 0).asUInt(),
|
|
|
|
grabberConfig["width"].asUInt(),
|
|
|
|
grabberConfig["height"].asUInt(),
|
|
|
|
grabberConfig["frequency_Hz"].asUInt(),
|
2016-06-17 01:25:40 +02:00
|
|
|
grabberConfig.get("priority",900).asInt());
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
if (_xbmcVideoChecker != nullptr)
|
2015-08-20 09:51:44 +02:00
|
|
|
{
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _osxGrabber, SLOT(setGrabbingMode(GrabbingMode)));
|
|
|
|
QObject::connect(_xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), _osxGrabber, SLOT(setVideoMode(VideoMode)));
|
2015-08-20 09:51:44 +02:00
|
|
|
}
|
2016-02-17 00:44:06 +01:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
QObject::connect(_osxGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2016-06-19 00:56:47 +02:00
|
|
|
_osxGrabber->start();
|
|
|
|
Info(_log, "OSX grabber created and started");
|
2015-08-20 09:51:44 +02:00
|
|
|
}
|
2016-06-19 00:56:47 +02:00
|
|
|
#else
|
|
|
|
ErrorIf(_config.isMember("osxgrabber"), _log, "The osx grabber can not be instantiated, because it has been left out from the build");
|
2016-05-30 22:38:40 +02:00
|
|
|
#endif
|
2013-08-13 11:10:45 +02:00
|
|
|
}
|