2016-06-29 11:18:32 +02:00
|
|
|
#include <cassert>
|
2016-07-24 15:18:34 +02:00
|
|
|
#include <stdlib.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-08-04 10:53:26 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QJsonValue>
|
2017-07-30 13:32:10 +02:00
|
|
|
#include <QPair>
|
2016-06-20 23:41:07 +02:00
|
|
|
#include <cstdint>
|
|
|
|
#include <limits>
|
2018-12-28 18:12:45 +01:00
|
|
|
#include <QThread>
|
2013-08-13 11:10:45 +02:00
|
|
|
|
2016-09-07 20:10:37 +02:00
|
|
|
#include <utils/Components.h>
|
2017-10-12 11:55:03 +02:00
|
|
|
#include <utils/JsonUtils.h>
|
2013-08-14 10:54:49 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
#include <HyperionConfig.h> // Required to determine the cmake options
|
|
|
|
|
2019-07-23 22:00:43 +02:00
|
|
|
// bonjour browser
|
2020-05-12 19:51:19 +02:00
|
|
|
#ifdef ENABLE_AVAHI
|
2019-07-23 22:00:43 +02:00
|
|
|
#include <bonjour/bonjourbrowserwrapper.h>
|
2020-05-12 19:51:19 +02:00
|
|
|
#endif
|
2013-08-17 15:39:29 +02:00
|
|
|
#include <jsonserver/JsonServer.h>
|
2018-12-27 23:11:32 +01:00
|
|
|
#include <webserver/WebServer.h>
|
2016-06-17 01:25:40 +02:00
|
|
|
#include "hyperiond.h"
|
2013-08-22 22:06:13 +02:00
|
|
|
|
2019-02-17 15:26:11 +01:00
|
|
|
// Flatbuffer Server
|
2018-12-28 18:12:45 +01:00
|
|
|
#include <flatbufserver/FlatBufferServer.h>
|
|
|
|
|
2019-02-17 15:26:11 +01:00
|
|
|
// Protobuffer Server
|
|
|
|
#include <protoserver/ProtoServer.h>
|
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
// ssdp
|
|
|
|
#include <ssdp/SSDPHandler.h>
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// settings
|
|
|
|
#include <hyperion/SettingsManager.h>
|
|
|
|
|
2019-07-12 16:54:26 +02:00
|
|
|
// AuthManager
|
|
|
|
#include <hyperion/AuthManager.h>
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// InstanceManager Hyperion
|
|
|
|
#include <hyperion/HyperionIManager.h>
|
|
|
|
|
2019-07-12 16:54:26 +02:00
|
|
|
// NetOrigin checks
|
|
|
|
#include <utils/NetOrigin.h>
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// Init Python
|
|
|
|
#include <python/PythonInit.h>
|
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
// EffectFileHandler
|
|
|
|
#include <effectengine/EffectFileHandler.h>
|
|
|
|
|
2020-07-20 20:06:41 +02:00
|
|
|
#ifdef ENABLE_CEC
|
|
|
|
#include <cec/CECHandler.h>
|
|
|
|
#endif
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
HyperionDaemon *HyperionDaemon::daemon = nullptr;
|
|
|
|
|
|
|
|
HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bool &logLvlOverwrite)
|
|
|
|
: QObject(parent), _log(Logger::getInstance("DAEMON"))
|
|
|
|
, _instanceManager(new HyperionIManager(rootPath, this))
|
|
|
|
, _authManager(new AuthManager(this))
|
|
|
|
#ifdef ENABLE_AVAHI
|
|
|
|
, _bonjourBrowserWrapper(new BonjourBrowserWrapper())
|
|
|
|
#endif
|
|
|
|
, _netOrigin(new NetOrigin(this))
|
|
|
|
, _pyInit(new PythonInit())
|
|
|
|
, _webserver(nullptr)
|
|
|
|
, _sslWebserver(nullptr)
|
|
|
|
, _jsonServer(nullptr)
|
|
|
|
, _v4l2Grabber(nullptr)
|
|
|
|
, _dispmanx(nullptr)
|
|
|
|
, _x11Grabber(nullptr)
|
|
|
|
, _amlGrabber(nullptr)
|
|
|
|
, _fbGrabber(nullptr)
|
|
|
|
, _osxGrabber(nullptr)
|
|
|
|
, _qtGrabber(nullptr)
|
|
|
|
, _ssdp(nullptr)
|
2020-07-20 20:06:41 +02:00
|
|
|
, _cecHandler(nullptr)
|
2020-06-28 23:05:32 +02:00
|
|
|
, _currVideoMode(VideoMode::VIDEO_2D)
|
2016-06-19 00:56:47 +02:00
|
|
|
{
|
2018-12-27 23:11:32 +01:00
|
|
|
HyperionDaemon::daemon = this;
|
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
// Register metas for thread queued connection
|
|
|
|
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
|
|
|
|
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
|
|
|
qRegisterMetaType<settings::type>("settings::type");
|
2018-12-30 22:07:53 +01:00
|
|
|
qRegisterMetaType<VideoMode>("VideoMode");
|
2020-05-12 19:51:19 +02:00
|
|
|
qRegisterMetaType<QMap<quint8, QJsonObject>>("QMap<quint8,QJsonObject>");
|
2019-07-02 19:06:36 +02:00
|
|
|
qRegisterMetaType<std::vector<ColorRgb>>("std::vector<ColorRgb>");
|
2018-12-28 18:12:45 +01:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// init settings
|
2020-05-12 19:51:19 +02:00
|
|
|
_settingsManager = new SettingsManager(0, this);
|
2016-10-14 13:52:21 +02:00
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
// set inital log lvl if the loglvl wasn't overwritten by arg
|
2020-05-12 19:51:19 +02:00
|
|
|
if (!logLvlOverwrite)
|
2019-05-03 17:54:43 +02:00
|
|
|
handleSettingsUpdate(settings::LOGGER, getSetting(settings::LOGGER));
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2020-07-20 20:06:41 +02:00
|
|
|
createCecHandler();
|
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
// init EffectFileHandler
|
2020-05-12 19:51:19 +02:00
|
|
|
EffectFileHandler *efh = new EffectFileHandler(rootPath, getSetting(settings::EFFECTS), this);
|
2018-12-31 15:48:29 +01:00
|
|
|
connect(this, &HyperionDaemon::settingsChanged, efh, &EffectFileHandler::handleSettingsUpdate);
|
|
|
|
|
2019-07-12 16:54:26 +02:00
|
|
|
// connect and apply settings for AuthManager
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _authManager, &AuthManager::handleSettingsUpdate);
|
|
|
|
_authManager->handleSettingsUpdate(settings::NETWORK, _settingsManager->getSetting(settings::NETWORK));
|
|
|
|
|
|
|
|
// connect and apply settings for NetOrigin
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _netOrigin, &NetOrigin::handleSettingsUpdate);
|
|
|
|
_netOrigin->handleSettingsUpdate(settings::NETWORK, _settingsManager->getSetting(settings::NETWORK));
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// spawn all Hyperion instances (non blocking)
|
|
|
|
_instanceManager->startAll();
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2019-05-03 17:54:43 +02:00
|
|
|
//connect(_hyperion,SIGNAL(closing()),this,SLOT(freeObjects())); // TODO for app restart, refactor required
|
2019-01-01 19:47:07 +01:00
|
|
|
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
//Cleaning up Hyperion before quit
|
|
|
|
connect(parent, SIGNAL(aboutToQuit()), this, SLOT(freeObjects()));
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// pipe settings changes and component state changes from HyperionIManager to Daemon
|
|
|
|
connect(_instanceManager, &HyperionIManager::settingsChanged, this, &HyperionDaemon::settingsChanged);
|
2020-02-26 18:54:56 +01:00
|
|
|
connect(_instanceManager, &HyperionIManager::compStateChangeRequest, this, &HyperionDaemon::compStateChangeRequest);
|
2019-07-14 22:43:22 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// listen for setting changes of framegrabber and v4l2
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, this, &HyperionDaemon::handleSettingsUpdate);
|
2019-01-01 19:47:07 +01:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// forward videoModes from HyperionIManager to Daemon evaluation
|
|
|
|
connect(_instanceManager, &HyperionIManager::requestVideoMode, this, &HyperionDaemon::setVideoMode);
|
|
|
|
// return videoMode changes from Daemon to HyperionIManager
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _instanceManager, &HyperionIManager::newVideoMode);
|
2018-12-27 23:11:32 +01:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
// ---- grabber -----
|
|
|
|
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX) && !defined(ENABLE_FB) && !defined(ENABLE_X11) && !defined(ENABLE_AMLOGIC) && !defined(ENABLE_QT)
|
|
|
|
Warning(_log, "No platform capture can be instantiated, because all grabbers have been left out from the build");
|
|
|
|
#endif
|
2019-01-01 19:47:07 +01:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// init system capture (framegrabber)
|
2018-12-27 23:11:32 +01:00
|
|
|
handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
|
2019-05-03 17:54:43 +02:00
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// init v4l2 capture
|
2018-12-27 23:11:32 +01:00
|
|
|
handleSettingsUpdate(settings::V4L2, getSetting(settings::V4L2));
|
2019-05-03 17:54:43 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// ---- network services -----
|
|
|
|
startNetworkServices();
|
2016-06-19 00:56:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
HyperionDaemon::~HyperionDaemon()
|
|
|
|
{
|
2018-12-27 23:11:32 +01:00
|
|
|
delete _settingsManager;
|
|
|
|
delete _pyInit;
|
|
|
|
}
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
void HyperionDaemon::setVideoMode(const VideoMode &mode)
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_currVideoMode != mode)
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
|
|
|
_currVideoMode = mode;
|
|
|
|
emit videoMode(mode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const QJsonDocument HyperionDaemon::getSetting(const settings::type &type)
|
|
|
|
{
|
|
|
|
return _settingsManager->getSetting(type);
|
2017-01-22 14:31:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void HyperionDaemon::freeObjects()
|
|
|
|
{
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
Debug(_log, "Cleaning up Hyperion before quit.");
|
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
// destroy network first as a client might want to access hyperion
|
2018-12-27 23:11:32 +01:00
|
|
|
delete _jsonServer;
|
2018-12-28 18:12:45 +01:00
|
|
|
_flatBufferServer->thread()->quit();
|
|
|
|
_flatBufferServer->thread()->wait(1000);
|
2020-07-12 09:22:05 +02:00
|
|
|
delete _flatBufferServer->thread();
|
|
|
|
delete _flatBufferServer;
|
2020-06-28 23:42:57 +02:00
|
|
|
|
2019-02-17 15:26:11 +01:00
|
|
|
_protoServer->thread()->quit();
|
|
|
|
_protoServer->thread()->wait(1000);
|
2020-07-12 09:22:05 +02:00
|
|
|
delete _protoServer->thread();
|
|
|
|
delete _protoServer;
|
2020-06-28 23:42:57 +02:00
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
//ssdp before webserver
|
|
|
|
_ssdp->thread()->quit();
|
|
|
|
_ssdp->thread()->wait(1000);
|
2020-07-12 09:22:05 +02:00
|
|
|
delete _ssdp->thread();
|
|
|
|
delete _ssdp;
|
2020-06-28 23:42:57 +02:00
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
_webserver->thread()->quit();
|
|
|
|
_webserver->thread()->wait(1000);
|
2020-07-12 09:22:05 +02:00
|
|
|
delete _webserver->thread();
|
|
|
|
delete _webserver;
|
2020-06-28 23:42:57 +02:00
|
|
|
|
2019-08-21 16:09:28 +02:00
|
|
|
_sslWebserver->thread()->quit();
|
|
|
|
_sslWebserver->thread()->wait(1000);
|
2020-07-12 09:22:05 +02:00
|
|
|
delete _sslWebserver->thread();
|
|
|
|
delete _sslWebserver;
|
2019-07-14 22:43:22 +02:00
|
|
|
|
2020-07-20 20:06:41 +02:00
|
|
|
#ifdef ENABLE_CEC
|
|
|
|
_cecHandler->thread()->quit();
|
|
|
|
_cecHandler->thread()->wait(1000);
|
|
|
|
delete _cecHandler->thread();
|
|
|
|
delete _cecHandler;
|
|
|
|
#endif
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// stop Hyperions (non blocking)
|
|
|
|
_instanceManager->stopAll();
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
delete _bonjourBrowserWrapper;
|
2016-06-19 00:56:47 +02:00
|
|
|
delete _amlGrabber;
|
|
|
|
delete _dispmanx;
|
|
|
|
delete _fbGrabber;
|
|
|
|
delete _osxGrabber;
|
2019-01-06 19:49:56 +01:00
|
|
|
delete _qtGrabber;
|
2019-05-03 17:54:43 +02:00
|
|
|
delete _v4l2Grabber;
|
2016-06-19 00:56:47 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
_v4l2Grabber = nullptr;
|
2020-07-20 20:06:41 +02:00
|
|
|
_cecHandler = nullptr;
|
2018-12-27 23:11:32 +01:00
|
|
|
_bonjourBrowserWrapper = nullptr;
|
2020-05-12 19:51:19 +02:00
|
|
|
_amlGrabber = nullptr;
|
|
|
|
_dispmanx = nullptr;
|
|
|
|
_fbGrabber = nullptr;
|
|
|
|
_osxGrabber = nullptr;
|
|
|
|
_qtGrabber = nullptr;
|
|
|
|
_flatBufferServer = nullptr;
|
|
|
|
_protoServer = nullptr;
|
|
|
|
_ssdp = nullptr;
|
|
|
|
_webserver = nullptr;
|
|
|
|
_sslWebserver = nullptr;
|
|
|
|
_jsonServer = nullptr;
|
2016-06-19 00:56:47 +02:00
|
|
|
}
|
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
void HyperionDaemon::startNetworkServices()
|
2016-08-04 10:53:26 +02:00
|
|
|
{
|
2018-12-27 23:11:32 +01:00
|
|
|
// Create Json server
|
|
|
|
_jsonServer = new JsonServer(getSetting(settings::JSONSERVER));
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _jsonServer, &JsonServer::handleSettingsUpdate);
|
2017-10-12 11:55:03 +02:00
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
// Create FlatBuffer server in thread
|
2018-12-28 18:12:45 +01:00
|
|
|
_flatBufferServer = new FlatBufferServer(getSetting(settings::FLATBUFSERVER));
|
2020-05-12 19:51:19 +02:00
|
|
|
QThread *fbThread = new QThread(this);
|
2020-06-28 23:43:45 +02:00
|
|
|
fbThread->setObjectName("FlatBufferServerThread");
|
2018-12-28 18:12:45 +01:00
|
|
|
_flatBufferServer->moveToThread(fbThread);
|
2020-05-12 19:51:19 +02:00
|
|
|
connect(fbThread, &QThread::started, _flatBufferServer, &FlatBufferServer::initServer);
|
2018-12-30 22:07:53 +01:00
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _flatBufferServer, &FlatBufferServer::handleSettingsUpdate);
|
2018-12-28 18:12:45 +01:00
|
|
|
fbThread->start();
|
2017-07-30 13:32:10 +02:00
|
|
|
|
2019-02-17 15:26:11 +01:00
|
|
|
// Create Proto server in thread
|
|
|
|
_protoServer = new ProtoServer(getSetting(settings::PROTOSERVER));
|
2020-05-12 19:51:19 +02:00
|
|
|
QThread *pThread = new QThread(this);
|
2020-06-28 23:43:45 +02:00
|
|
|
pThread->setObjectName("ProtoServerThread");
|
2019-02-17 15:26:11 +01:00
|
|
|
_protoServer->moveToThread(pThread);
|
2020-05-12 19:51:19 +02:00
|
|
|
connect(pThread, &QThread::started, _protoServer, &ProtoServer::initServer);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _protoServer, &ProtoServer::handleSettingsUpdate);
|
2019-02-17 15:26:11 +01:00
|
|
|
pThread->start();
|
|
|
|
|
2018-12-30 22:07:53 +01:00
|
|
|
// Create Webserver in thread
|
2019-08-21 16:09:28 +02:00
|
|
|
_webserver = new WebServer(getSetting(settings::WEBSERVER), false);
|
2020-05-12 19:51:19 +02:00
|
|
|
QThread *wsThread = new QThread(this);
|
2020-06-28 23:43:45 +02:00
|
|
|
wsThread->setObjectName("WebServerThread");
|
2018-12-30 22:07:53 +01:00
|
|
|
_webserver->moveToThread(wsThread);
|
2020-05-12 19:51:19 +02:00
|
|
|
connect(wsThread, &QThread::started, _webserver, &WebServer::initServer);
|
2018-12-27 23:11:32 +01:00
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _webserver, &WebServer::handleSettingsUpdate);
|
2018-12-30 22:07:53 +01:00
|
|
|
wsThread->start();
|
|
|
|
|
2019-08-21 16:09:28 +02:00
|
|
|
// Create SSL Webserver in thread
|
|
|
|
_sslWebserver = new WebServer(getSetting(settings::WEBSERVER), true);
|
2020-05-12 19:51:19 +02:00
|
|
|
QThread *sslWsThread = new QThread(this);
|
2020-06-28 23:43:45 +02:00
|
|
|
sslWsThread->setObjectName("SSLWebServerThread");
|
2019-08-21 16:09:28 +02:00
|
|
|
_sslWebserver->moveToThread(sslWsThread);
|
2020-05-12 19:51:19 +02:00
|
|
|
connect(sslWsThread, &QThread::started, _sslWebserver, &WebServer::initServer);
|
2019-08-21 16:09:28 +02:00
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _sslWebserver, &WebServer::handleSettingsUpdate);
|
|
|
|
sslWsThread->start();
|
|
|
|
|
2019-07-14 22:43:22 +02:00
|
|
|
// Create SSDP server in thread
|
2020-05-12 19:51:19 +02:00
|
|
|
_ssdp = new SSDPHandler(_webserver, getSetting(settings::FLATBUFSERVER).object()["port"].toInt(), getSetting(settings::JSONSERVER).object()["port"].toInt(), getSetting(settings::GENERAL).object()["name"].toString());
|
|
|
|
QThread *ssdpThread = new QThread(this);
|
2020-06-28 23:43:45 +02:00
|
|
|
ssdpThread->setObjectName("SSDPThread");
|
2018-12-30 22:07:53 +01:00
|
|
|
_ssdp->moveToThread(ssdpThread);
|
2020-05-12 19:51:19 +02:00
|
|
|
connect(ssdpThread, &QThread::started, _ssdp, &SSDPHandler::initServer);
|
|
|
|
connect(_webserver, &WebServer::stateChange, _ssdp, &SSDPHandler::handleWebServerStateChange);
|
2018-12-30 22:07:53 +01:00
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _ssdp, &SSDPHandler::handleSettingsUpdate);
|
|
|
|
ssdpThread->start();
|
2016-12-23 19:37:35 +01:00
|
|
|
}
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
void HyperionDaemon::handleSettingsUpdate(const settings::type &settingsType, const QJsonDocument &config)
|
2013-08-24 11:51:52 +02:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (settingsType == settings::LOGGER)
|
2018-12-28 18:12:45 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
const QJsonObject &logConfig = config.object();
|
2018-12-28 18:12:45 +01:00
|
|
|
|
|
|
|
std::string level = logConfig["level"].toString("warn").toStdString(); // silent warn verbose debug
|
2020-05-12 19:51:19 +02:00
|
|
|
if (level == "silent")
|
|
|
|
Logger::setLogLevel(Logger::OFF);
|
|
|
|
else if (level == "warn")
|
2020-06-28 23:05:32 +02:00
|
|
|
Logger::setLogLevel(Logger::LogLevel::WARNING);
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (level == "verbose")
|
|
|
|
Logger::setLogLevel(Logger::INFO);
|
|
|
|
else if (level == "debug")
|
|
|
|
Logger::setLogLevel(Logger::DEBUG);
|
2018-12-28 18:12:45 +01:00
|
|
|
}
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
if (settingsType == settings::SYSTEMCAPTURE)
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
const QJsonObject &grabberConfig = config.object();
|
2016-08-06 08:28:42 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
_grabber_width = grabberConfig["width"].toInt(96);
|
|
|
|
_grabber_height = grabberConfig["height"].toInt(96);
|
2018-12-27 23:11:32 +01:00
|
|
|
_grabber_frequency = grabberConfig["frequency_Hz"].toInt(10);
|
2013-08-24 11:51:52 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
_grabber_cropLeft = grabberConfig["cropLeft"].toInt(0);
|
|
|
|
_grabber_cropRight = grabberConfig["cropRight"].toInt(0);
|
|
|
|
_grabber_cropTop = grabberConfig["cropTop"].toInt(0);
|
2018-12-27 23:11:32 +01:00
|
|
|
_grabber_cropBottom = grabberConfig["cropBottom"].toInt(0);
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
_grabber_ge2d_mode = grabberConfig["ge2d_mode"].toInt(0);
|
|
|
|
_grabber_device = grabberConfig["amlogic_grabber"].toString("amvideocap0");
|
2019-02-08 09:38:31 +01:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
#ifdef ENABLE_OSX
|
|
|
|
QString type = "osx";
|
|
|
|
#else
|
|
|
|
QString type = grabberConfig["type"].toString("auto");
|
|
|
|
#endif
|
2016-01-31 22:38:30 +01:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// auto eval of type
|
2020-05-12 19:51:19 +02:00
|
|
|
if (type == "auto")
|
2016-01-31 22:38:30 +01:00
|
|
|
{
|
2018-12-27 23:11:32 +01:00
|
|
|
// dispmanx -> on raspi
|
|
|
|
if (QFile::exists("/dev/vchiq"))
|
|
|
|
{
|
|
|
|
type = "dispmanx";
|
|
|
|
}
|
|
|
|
// amlogic -> /dev/amvideo exists
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (QFile::exists("/dev/amvideo"))
|
2018-12-27 23:11:32 +01:00
|
|
|
{
|
|
|
|
type = "amlogic";
|
2019-02-08 09:38:31 +01:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
if (!QFile::exists("/dev/" + _grabber_device))
|
|
|
|
{
|
|
|
|
Error(_log, "grabber device '%s' for type amlogic not found!", QSTRING_CSTR(_grabber_device));
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-28 23:05:32 +02:00
|
|
|
// x11 -> if DISPLAY is set
|
|
|
|
QByteArray envDisplay = qgetenv("DISPLAY");
|
|
|
|
if ( !envDisplay.isEmpty() )
|
|
|
|
{
|
|
|
|
type = "x11";
|
|
|
|
}
|
|
|
|
// qt -> if nothing other applies
|
|
|
|
else
|
|
|
|
{
|
|
|
|
type = "qt";
|
|
|
|
}
|
2018-12-27 23:11:32 +01:00
|
|
|
}
|
2016-06-20 23:41:07 +02:00
|
|
|
}
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_prevType != type)
|
2018-12-31 15:48:29 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
Info(_log, "set screen capture device to '%s'", QSTRING_CSTR(type));
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
// stop all capture interfaces
|
|
|
|
#ifdef ENABLE_FB
|
2020-03-26 17:49:36 +01:00
|
|
|
if(_fbGrabber != nullptr)
|
2020-05-20 08:36:52 +02:00
|
|
|
{
|
2020-03-26 17:49:36 +01:00
|
|
|
_fbGrabber->stop();
|
|
|
|
delete _fbGrabber;
|
|
|
|
_fbGrabber = nullptr;
|
|
|
|
}
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_DISPMANX
|
2020-03-26 17:49:36 +01:00
|
|
|
if(_dispmanx != nullptr)
|
|
|
|
{
|
|
|
|
_dispmanx->stop();
|
|
|
|
delete _dispmanx;
|
|
|
|
_dispmanx = nullptr;
|
|
|
|
}
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_AMLOGIC
|
2020-03-26 17:49:36 +01:00
|
|
|
if(_amlGrabber != nullptr)
|
|
|
|
{
|
|
|
|
_amlGrabber->stop();
|
|
|
|
delete _amlGrabber;
|
|
|
|
_amlGrabber = nullptr;
|
|
|
|
}
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_OSX
|
2020-03-26 17:49:36 +01:00
|
|
|
if(_osxGrabber != nullptr)
|
|
|
|
{
|
|
|
|
_osxGrabber->stop();
|
|
|
|
delete _osxGrabber;
|
|
|
|
_osxGrabber = nullptr;
|
|
|
|
}
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
#ifdef ENABLE_X11
|
2020-03-26 17:49:36 +01:00
|
|
|
if(_x11Grabber != nullptr)
|
|
|
|
{
|
|
|
|
_x11Grabber->stop();
|
|
|
|
delete _x11Grabber;
|
|
|
|
_x11Grabber = nullptr;
|
|
|
|
}
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
2019-01-06 19:49:56 +01:00
|
|
|
#ifdef ENABLE_QT
|
2020-03-26 17:49:36 +01:00
|
|
|
if(_qtGrabber != nullptr)
|
|
|
|
{
|
|
|
|
_qtGrabber->stop();
|
|
|
|
delete _qtGrabber;
|
|
|
|
_qtGrabber = nullptr;
|
|
|
|
}
|
2019-01-06 19:49:56 +01:00
|
|
|
#endif
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
// create/start capture interface
|
2020-05-12 19:51:19 +02:00
|
|
|
if (type == "framebuffer")
|
2018-12-31 15:48:29 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_fbGrabber == nullptr)
|
2018-12-31 15:48:29 +01:00
|
|
|
createGrabberFramebuffer(grabberConfig);
|
|
|
|
#ifdef ENABLE_FB
|
2020-03-26 17:49:36 +01:00
|
|
|
_fbGrabber->tryStart();
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
}
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (type == "dispmanx")
|
2018-12-31 15:48:29 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_dispmanx == nullptr)
|
2018-12-31 15:48:29 +01:00
|
|
|
createGrabberDispmanx();
|
|
|
|
#ifdef ENABLE_DISPMANX
|
2020-03-26 17:49:36 +01:00
|
|
|
_dispmanx->tryStart();
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
}
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (type == "amlogic")
|
2018-12-31 15:48:29 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_amlGrabber == nullptr)
|
2018-12-31 15:48:29 +01:00
|
|
|
createGrabberAmlogic();
|
|
|
|
#ifdef ENABLE_AMLOGIC
|
2020-03-26 17:49:36 +01:00
|
|
|
_amlGrabber->tryStart();
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
}
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (type == "osx")
|
2018-12-31 15:48:29 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_osxGrabber == nullptr)
|
2018-12-31 15:48:29 +01:00
|
|
|
createGrabberOsx(grabberConfig);
|
|
|
|
#ifdef ENABLE_OSX
|
2020-03-26 17:49:36 +01:00
|
|
|
_osxGrabber->tryStart();
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
}
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (type == "x11")
|
2018-12-31 15:48:29 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_x11Grabber == nullptr)
|
2018-12-31 15:48:29 +01:00
|
|
|
createGrabberX11(grabberConfig);
|
|
|
|
#ifdef ENABLE_X11
|
2020-03-26 17:49:36 +01:00
|
|
|
_x11Grabber->tryStart();
|
2018-12-31 15:48:29 +01:00
|
|
|
#endif
|
|
|
|
}
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (type == "qt")
|
2019-01-06 19:49:56 +01:00
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_qtGrabber == nullptr)
|
2019-01-06 19:49:56 +01:00
|
|
|
createGrabberQt(grabberConfig);
|
|
|
|
#ifdef ENABLE_QT
|
2020-03-26 17:49:36 +01:00
|
|
|
_qtGrabber->tryStart();
|
2019-01-06 19:49:56 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-05-12 19:51:19 +02:00
|
|
|
Error(_log, "Unknown platform capture type: %s", QSTRING_CSTR(type));
|
2019-01-06 19:49:56 +01:00
|
|
|
return;
|
|
|
|
}
|
2018-12-31 15:48:29 +01:00
|
|
|
_prevType = type;
|
|
|
|
}
|
2016-02-16 15:41:40 +01:00
|
|
|
}
|
2020-05-12 19:51:19 +02:00
|
|
|
else if (settingsType == settings::V4L2)
|
2016-02-16 15:41:40 +01:00
|
|
|
{
|
2020-07-20 20:06:41 +02:00
|
|
|
const QJsonObject &grabberConfig = config.object();
|
|
|
|
#ifdef ENABLE_CEC
|
|
|
|
QString operation;
|
|
|
|
if (_cecHandler && grabberConfig["cecDetection"].toBool(false))
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(_cecHandler, "start", Qt::QueuedConnection);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QMetaObject::invokeMethod(_cecHandler, "stop", Qt::QueuedConnection);
|
|
|
|
}
|
|
|
|
#endif
|
2016-08-11 07:13:55 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
if (_v4l2Grabber != nullptr)
|
|
|
|
return;
|
2019-05-03 17:54:43 +02:00
|
|
|
|
2020-07-20 20:06:41 +02:00
|
|
|
#ifdef ENABLE_V4L2
|
2020-05-12 19:51:19 +02:00
|
|
|
_v4l2Grabber = new V4L2Wrapper(
|
2018-12-27 23:11:32 +01:00
|
|
|
grabberConfig["device"].toString("auto"),
|
2020-03-27 23:13:58 +01:00
|
|
|
grabberConfig["width"].toInt(0),
|
|
|
|
grabberConfig["height"].toInt(0),
|
|
|
|
grabberConfig["fps"].toInt(15),
|
2020-06-17 20:55:57 +02:00
|
|
|
grabberConfig["input"].toInt(-1),
|
2018-12-27 23:11:32 +01:00
|
|
|
parseVideoStandard(grabberConfig["standard"].toString("no-change")),
|
|
|
|
parsePixelFormat(grabberConfig["pixelFormat"].toString("no-change")),
|
2020-03-27 23:13:58 +01:00
|
|
|
grabberConfig["sizeDecimation"].toInt(8));
|
2020-05-12 19:51:19 +02:00
|
|
|
|
|
|
|
_v4l2Grabber->setSignalThreshold(
|
|
|
|
grabberConfig["redSignalThreshold"].toDouble(0.0) / 100.0,
|
|
|
|
grabberConfig["greenSignalThreshold"].toDouble(0.0) / 100.0,
|
|
|
|
grabberConfig["blueSignalThreshold"].toDouble(0.0) / 100.0);
|
|
|
|
_v4l2Grabber->setCropping(
|
2018-12-27 23:11:32 +01:00
|
|
|
grabberConfig["cropLeft"].toInt(0),
|
|
|
|
grabberConfig["cropRight"].toInt(0),
|
|
|
|
grabberConfig["cropTop"].toInt(0),
|
|
|
|
grabberConfig["cropBottom"].toInt(0));
|
2020-07-20 20:06:41 +02:00
|
|
|
|
|
|
|
_v4l2Grabber->setCecDetectionEnable(grabberConfig["cecDetection"].toBool(true));
|
2020-05-12 19:51:19 +02:00
|
|
|
_v4l2Grabber->setSignalDetectionEnable(grabberConfig["signalDetection"].toBool(true));
|
|
|
|
_v4l2Grabber->setSignalDetectionOffset(
|
2018-12-27 23:11:32 +01:00
|
|
|
grabberConfig["sDHOffsetMin"].toDouble(0.25),
|
|
|
|
grabberConfig["sDVOffsetMin"].toDouble(0.25),
|
|
|
|
grabberConfig["sDHOffsetMax"].toDouble(0.75),
|
|
|
|
grabberConfig["sDVOffsetMax"].toDouble(0.75));
|
2020-05-12 19:51:19 +02:00
|
|
|
Debug(_log, "V4L2 grabber created");
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2020-07-20 20:06:41 +02:00
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _v4l2Grabber, &V4L2Wrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _v4l2Grabber, &V4L2Wrapper::handleSettingsUpdate);
|
2019-04-28 19:53:45 +02:00
|
|
|
#else
|
|
|
|
Error(_log, "The v4l2 grabber can not be instantiated, because it has been left out from the build");
|
|
|
|
#endif
|
2013-10-13 14:48:59 +02:00
|
|
|
}
|
2016-07-24 15:18:34 +02:00
|
|
|
}
|
|
|
|
|
2016-07-27 22:52:59 +02:00
|
|
|
void HyperionDaemon::createGrabberDispmanx()
|
2016-07-24 15:18:34 +02:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_DISPMANX
|
2018-12-27 23:11:32 +01:00
|
|
|
_dispmanx = new DispmanxWrapper(_grabber_width, _grabber_height, _grabber_frequency);
|
2016-07-27 22:52:59 +02:00
|
|
|
_dispmanx->setCropping(_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _dispmanx, &DispmanxWrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _dispmanx, &DispmanxWrapper::handleSettingsUpdate);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
Info(_log, "DISPMANX frame grabber created");
|
2016-06-19 00:56:47 +02:00
|
|
|
#else
|
2019-04-28 19:53:45 +02:00
|
|
|
Error(_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-07-27 22:52:59 +02:00
|
|
|
void HyperionDaemon::createGrabberAmlogic()
|
2016-07-24 15:18:34 +02:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_AMLOGIC
|
2019-03-27 09:07:20 +01:00
|
|
|
_amlGrabber = new AmlogicWrapper(_grabber_width, _grabber_height);
|
2017-09-01 08:50:37 +02:00
|
|
|
_amlGrabber->setCropping(_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _amlGrabber, &AmlogicWrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _amlGrabber, &AmlogicWrapper::handleSettingsUpdate);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
Info(_log, "AMLOGIC grabber created");
|
2016-07-24 15:18:34 +02:00
|
|
|
#else
|
2019-04-28 19:53:45 +02:00
|
|
|
Error(_log, "The AMLOGIC grabber can not be instantiated, because it has been left out from the build");
|
2016-07-24 15:18:34 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
void HyperionDaemon::createGrabberX11(const QJsonObject &grabberConfig)
|
2016-07-24 15:18:34 +02:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_X11
|
|
|
|
_x11Grabber = new X11Wrapper(
|
2020-05-12 19:51:19 +02:00
|
|
|
_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom,
|
|
|
|
grabberConfig["pixelDecimation"].toInt(8),
|
|
|
|
_grabber_frequency);
|
2017-08-12 07:55:32 +02:00
|
|
|
_x11Grabber->setCropping(_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _x11Grabber, &X11Wrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _x11Grabber, &X11Wrapper::handleSettingsUpdate);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
Info(_log, "X11 grabber created");
|
2016-07-24 15:18:34 +02:00
|
|
|
#else
|
|
|
|
Error(_log, "The X11 grabber can not be instantiated, because it has been left out from the build");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
void HyperionDaemon::createGrabberQt(const QJsonObject &grabberConfig)
|
2019-01-06 19:49:56 +01:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_QT
|
|
|
|
_qtGrabber = new QtWrapper(
|
2020-05-12 19:51:19 +02:00
|
|
|
_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom,
|
|
|
|
grabberConfig["pixelDecimation"].toInt(8),
|
|
|
|
grabberConfig["display"].toInt(0),
|
|
|
|
_grabber_frequency);
|
2019-01-06 19:49:56 +01:00
|
|
|
|
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _qtGrabber, &QtWrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _qtGrabber, &QtWrapper::handleSettingsUpdate);
|
|
|
|
|
|
|
|
Info(_log, "Qt grabber created");
|
|
|
|
#else
|
|
|
|
Error(_log, "The Qt grabber can not be instantiated, because it has been left out from the build");
|
|
|
|
#endif
|
|
|
|
}
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
void HyperionDaemon::createGrabberFramebuffer(const QJsonObject &grabberConfig)
|
2016-07-24 15:18:34 +02:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_FB
|
|
|
|
// Construct and start the framebuffer grabber if the configuration is present
|
|
|
|
_fbGrabber = new FramebufferWrapper(
|
2020-05-12 19:51:19 +02:00
|
|
|
grabberConfig["device"].toString("/dev/fb0"),
|
|
|
|
_grabber_width, _grabber_height, _grabber_frequency);
|
2017-08-12 07:55:32 +02:00
|
|
|
_fbGrabber->setCropping(_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom);
|
2018-12-27 23:11:32 +01:00
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _fbGrabber, &FramebufferWrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _fbGrabber, &FramebufferWrapper::handleSettingsUpdate);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
Info(_log, "Framebuffer grabber created");
|
2016-07-24 15:18:34 +02:00
|
|
|
#else
|
|
|
|
Error(_log, "The framebuffer grabber can not be instantiated, because it has been left out from the build");
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-12 19:51:19 +02:00
|
|
|
void HyperionDaemon::createGrabberOsx(const QJsonObject &grabberConfig)
|
2016-07-24 15:18:34 +02:00
|
|
|
{
|
|
|
|
#ifdef ENABLE_OSX
|
|
|
|
// Construct and start the osx grabber if the configuration is present
|
|
|
|
_osxGrabber = new OsxWrapper(
|
2020-05-12 19:51:19 +02:00
|
|
|
grabberConfig["display"].toInt(0),
|
|
|
|
_grabber_width, _grabber_height, _grabber_frequency);
|
2017-09-04 23:12:59 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// connect to HyperionDaemon signal
|
|
|
|
connect(this, &HyperionDaemon::videoMode, _osxGrabber, &OsxWrapper::setVideoMode);
|
|
|
|
connect(this, &HyperionDaemon::settingsChanged, _osxGrabber, &OsxWrapper::handleSettingsUpdate);
|
2016-07-24 15:18:34 +02:00
|
|
|
|
2018-12-31 15:48:29 +01:00
|
|
|
Info(_log, "OSX grabber created");
|
2016-07-24 15:18:34 +02:00
|
|
|
#else
|
|
|
|
Error(_log, "The osx grabber can not be instantiated, because it has been left out from the build");
|
|
|
|
#endif
|
|
|
|
}
|
2020-07-20 20:06:41 +02:00
|
|
|
|
|
|
|
void HyperionDaemon::createCecHandler()
|
|
|
|
{
|
|
|
|
#ifdef ENABLE_CEC
|
|
|
|
_cecHandler = new CECHandler;
|
|
|
|
|
|
|
|
QThread * thread = new QThread(this);
|
|
|
|
thread->setObjectName("CECThread");
|
|
|
|
_cecHandler->moveToThread(thread);
|
|
|
|
thread->start();
|
|
|
|
|
|
|
|
connect(_cecHandler, &CECHandler::cecEvent, [&] (CECEvent event) {
|
|
|
|
if (_v4l2Grabber)
|
|
|
|
_v4l2Grabber->handleCecEvent(event);
|
|
|
|
});
|
|
|
|
|
|
|
|
Info(_log, "CEC handler created");
|
|
|
|
#else
|
|
|
|
Error(_log, "The CEC handler can not be instantiated, because it has been left out from the build");
|
|
|
|
#endif
|
|
|
|
}
|