Hyperion "Light", Build improvements and minor fixes (#1400)

* Allow build, if no grabbers are enabled

* Align available functions to right Qt version

* Update to next development version

* Align available functions to right Qt version

* fix workflows (apt/nightly)

* Disable QNetworkConfigurationManager deprecation warnings

* Initial go on Smart Pointers

* Add Deallocation

* Correct QT_WARNING_DISABLE_DEPRECATED (available since 5.9)

* Cluster Build Variables

* Hyperion Light

* Address build warnings

* Hyperion Light - UI

* Update Protobuf to latest master

* Removed compiler warnings

* Added restart ability to systray

* Correct Protobuf

* Ignore 'no-return' warning on protobuf build

* hyperion-remote: Fix auto discovery of hyperion server

* Fix Qt version override

* Update changelog

* Remove Grabber Components, if no Grabber exists

* Standalone Grabber - Fix fps default

* Remote Control - Have Source Selction accrosswhole screen

* Enable Blackborder detection only, if relevant input sources available

* Enable Blackborder detection only, if relevant input sources available

* Remote UI - rearrange containers

* - QT5/6 path for arm64 added
- Remove ZLib Dependency
- Fix macOS bundle info details
- Cleanup

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
LordGrey
2022-01-07 14:47:51 +01:00
committed by GitHub
parent c38ec60208
commit 2f573a117f
83 changed files with 1785 additions and 1284 deletions

View File

@@ -7,12 +7,23 @@ add_subdirectory(hyperion)
add_subdirectory(commandline)
add_subdirectory(blackborder)
add_subdirectory(jsonserver)
add_subdirectory(flatbufserver)
add_subdirectory(protoserver)
add_subdirectory(ssdp)
if(ENABLE_BOBLIGHT)
if(ENABLE_BOBLIGHT_SERVER)
add_subdirectory(boblightserver)
endif()
if(ENABLE_FLATBUF_SERVER OR ENABLE_FLATBUF_CONNECT)
add_subdirectory(flatbufserver)
endif()
if(ENABLE_PROTOBUF_SERVER)
add_subdirectory(protoserver)
endif()
if(ENABLE_FORWARDER)
add_subdirectory(forwarder)
endif()
add_subdirectory(leddevice)
add_subdirectory(utils)
add_subdirectory(effectengine)
@@ -22,14 +33,15 @@ add_subdirectory(db)
add_subdirectory(api)
add_subdirectory(python)
if(ENABLE_CEC)
add_subdirectory(cec)
endif()
add_subdirectory(ssdp)
if(ENABLE_AVAHI)
add_subdirectory(bonjour)
endif()
if(ENABLE_CEC)
add_subdirectory(cec)
endif()
if(ENABLE_EXPERIMENTAL)
add_subdirectory(experimental)
endif()

View File

@@ -512,34 +512,71 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
info["ledDevices"] = ledDevices;
QJsonObject grabbers;
QJsonArray availableGrabbers;
#if defined(ENABLE_DISPMANX) || defined(ENABLE_V4L2) || defined(ENABLE_MF) || defined(ENABLE_FB) || defined(ENABLE_AMLOGIC) || defined(ENABLE_OSX) || defined(ENABLE_X11) || defined(ENABLE_XCB) || defined(ENABLE_QT)
// *** Deprecated ***
//QJsonArray availableGrabbers;
//if ( GrabberWrapper::getInstance() != nullptr )
//{
// QStringList activeGrabbers = GrabberWrapper::getInstance()->getActive(_hyperion->getInstanceIndex());
// QJsonArray activeGrabberNames;
// for (auto grabberName : activeGrabbers)
// {
// activeGrabberNames.append(grabberName);
// }
if ( GrabberWrapper::getInstance() != nullptr )
// grabbers["active"] = activeGrabberNames;
//}
//for (auto grabber : GrabberWrapper::availableGrabbers(GrabberTypeFilter::ALL))
//{
// availableGrabbers.append(grabber);
//}
//grabbers["available"] = availableGrabbers;
QJsonObject screenGrabbers;
if (GrabberWrapper::getInstance() != nullptr)
{
QStringList activeGrabbers = GrabberWrapper::getInstance()->getActive(_hyperion->getInstanceIndex());
QStringList activeGrabbers = GrabberWrapper::getInstance()->getActive(_hyperion->getInstanceIndex(), GrabberTypeFilter::SCREEN);
QJsonArray activeGrabberNames;
for (auto grabberName : activeGrabbers)
{
activeGrabberNames.append(grabberName);
}
grabbers["active"] = activeGrabberNames;
screenGrabbers["active"] = activeGrabberNames;
}
// get available grabbers
for (auto grabber : GrabberWrapper::availableGrabbers())
QJsonArray availableScreenGrabbers;
for (auto grabber : GrabberWrapper::availableGrabbers(GrabberTypeFilter::SCREEN))
{
availableGrabbers.append(grabber);
availableScreenGrabbers.append(grabber);
}
screenGrabbers["available"] = availableScreenGrabbers;
#endif
QJsonObject videoGrabbers;
if (GrabberWrapper::getInstance() != nullptr)
{
QStringList activeGrabbers = GrabberWrapper::getInstance()->getActive(_hyperion->getInstanceIndex(), GrabberTypeFilter::VIDEO);
QJsonArray activeGrabberNames;
for (auto grabberName : activeGrabbers)
{
activeGrabberNames.append(grabberName);
}
grabbers["available"] = availableGrabbers;
info["videomode"] = QString(videoMode2String(_hyperion->getCurrentVideoMode()));
videoGrabbers["active"] = activeGrabberNames;
}
QJsonArray availableVideoGrabbers;
for (auto grabber : GrabberWrapper::availableGrabbers(GrabberTypeFilter::VIDEO))
{
availableVideoGrabbers.append(grabber);
}
videoGrabbers["available"] = availableVideoGrabbers;
grabbers.insert("screen", screenGrabbers);
grabbers.insert("video", videoGrabbers);
info["grabbers"] = grabbers;
info["videomode"] = QString(videoMode2String(_hyperion->getCurrentVideoMode()));
QJsonObject cecInfo;
#if defined(ENABLE_CEC)
cecInfo["enabled"] = true;
@@ -548,6 +585,36 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
#endif
info["cec"] = cecInfo;
// get available services
QJsonArray services;
#if defined(ENABLE_BOBLIGHT_SERVER)
services.append("boblight");
#endif
#if defined(ENABLE_CEC)
services.append("cec");
#endif
#if defined(ENABLE_FORWARDER)
services.append("forwarder");
#endif
#if defined(ENABLE_FLATBUF_SERVER)
services.append("flatbuffer");
#endif
#if defined(ENABLE_PROTOBUF_SERVER)
services.append("protobuffer");
#endif
if (!availableScreenGrabbers.isEmpty() || !availableVideoGrabbers.isEmpty() || services.contains("flatbuffer") || services.contains("protobuffer"))
{
services.append("borderdetection");
}
info["services"] = services;
// get available components
QJsonArray component;
std::map<hyperion::Components, bool> components = _hyperion->getComponentRegister().getRegister();

View File

@@ -44,27 +44,36 @@ void BlackBorderProcessor::handleSettingsUpdate(settings::type type, const QJson
{
if(type == settings::BLACKBORDER)
{
const QJsonObject& obj = config.object();
_unknownSwitchCnt = obj["unknownFrameCnt"].toInt(600);
_borderSwitchCnt = obj["borderFrameCnt"].toInt(50);
_maxInconsistentCnt = obj["maxInconsistentCnt"].toInt(10);
_blurRemoveCnt = obj["blurRemoveCnt"].toInt(1);
_detectionMode = obj["mode"].toString("default");
const double newThreshold = obj["threshold"].toDouble(5.0)/100.0;
if(_oldThreshold != newThreshold)
if (_hyperion->isComponentEnabled(COMP_BLACKBORDER) == -1)
{
_oldThreshold = newThreshold;
delete _detector;
_detector = new BlackBorderDetector(newThreshold);
//Disable, if service is not available
_enabled = false;
_userEnabled = false;
}
else
{
const QJsonObject& obj = config.object();
_unknownSwitchCnt = obj["unknownFrameCnt"].toInt(600);
_borderSwitchCnt = obj["borderFrameCnt"].toInt(50);
_maxInconsistentCnt = obj["maxInconsistentCnt"].toInt(10);
_blurRemoveCnt = obj["blurRemoveCnt"].toInt(1);
_detectionMode = obj["mode"].toString("default");
const double newThreshold = obj["threshold"].toDouble(5.0) / 100.0;
Debug(Logger::getInstance("BLACKBORDER"), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
if (_oldThreshold != newThreshold)
{
_oldThreshold = newThreshold;
// eval the comp state
handleCompStateChangeRequest(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
delete _detector;
_detector = new BlackBorderDetector(newThreshold);
}
Debug(Logger::getInstance("BLACKBORDER"), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
// eval the comp state
handleCompStateChangeRequest(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
}
}
}

View File

@@ -118,6 +118,8 @@ void BonjourServiceRegister::registerService(const BonjourRecord &record, quint1
connect(bonjourSocket, &QSocketNotifier::activated, this, &BonjourServiceRegister::bonjourSocketReadyRead);
}
}
TXTRecordDeallocate(&txtRec);
}

View File

@@ -8,8 +8,6 @@ include_directories(
${FLATBUFFERS_INCLUDE_DIRS}
)
FILE ( GLOB FLATBUFSERVER_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
set(Flatbuffer_GENERATED_FBS
hyperion_reply_generated.h
hyperion_request_generated.h
@@ -28,14 +26,39 @@ set_source_files_properties(
${Flatbuffer_GENERATED_FBS} PROPERTIES GENERATED TRUE
)
add_library(flatbufserver
### Split flatbufconnect from flatbufserver as flatbufserver relates to HyperionDaemon
if(ENABLE_FLATBUF_CONNECT)
add_library(flatbufconnect
${CURRENT_HEADER_DIR}/FlatBufferConnection.h
${CURRENT_SOURCE_DIR}/FlatBufferConnection.cpp
${FLATBUFSERVER_SOURCES}
${Flatbuffer_GENERATED_FBS}
)
target_link_libraries(flatbufserver
)
target_link_libraries(flatbufconnect
hyperion-utils
flatbuffers
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Core
)
endif()
if(ENABLE_FLATBUF_SERVER)
add_library(flatbufserver
${CURRENT_HEADER_DIR}/FlatBufferServer.h
${CURRENT_SOURCE_DIR}/FlatBufferServer.cpp
${CURRENT_SOURCE_DIR}/FlatBufferClient.h
${CURRENT_SOURCE_DIR}/FlatBufferClient.cpp
${FLATBUFSERVER_SOURCES}
${Flatbuffer_GENERATED_FBS}
)
target_link_libraries(flatbufserver
hyperion-utils
flatbuffers
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Core
)
endif()

View File

@@ -0,0 +1,24 @@
# Define the current source locations
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/forwarder)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/forwarder)
if(ENABLE_FLATBUF_CONNECT)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/flatbufserver
)
endif()
FILE ( GLOB Forwarder_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
add_library(forwarder ${Forwarder_SOURCES} )
target_link_libraries(forwarder
hyperion
hyperion-utils
${QT_LIBRARIES}
)
if(ENABLE_FLATBUF_CONNECT)
target_link_libraries(forwarder flatbufconnect)
endif()

View File

@@ -2,7 +2,7 @@
#include <stdexcept>
// project includes
#include <hyperion/MessageForwarder.h>
#include <forwarder/MessageForwarder.h>
// hyperion includes
#include <hyperion/Hyperion.h>

View File

@@ -3,9 +3,11 @@
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/hyperion)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/hyperion)
if(ENABLE_FLATBUF_SERVER)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/flatbufserver
)
endif()
FILE ( GLOB Hyperion_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
@@ -19,18 +21,24 @@ add_library(hyperion
target_link_libraries(hyperion
blackborder
hyperion-utils
flatbufserver
flatbuffers
leddevice
effectengine
database
${QT_LIBRARIES}
)
if(ENABLE_BOBLIGHT)
if(ENABLE_BOBLIGHT_SERVER)
target_link_libraries(hyperion boblightserver)
endif()
if(ENABLE_FLATBUF_SERVER)
target_link_libraries(hyperion flatbufserver)
endif()
if(ENABLE_FORWARDER)
target_link_libraries(hyperion forwarder)
endif()
if (ENABLE_AVAHI)
target_link_libraries(hyperion bonjour)
endif ()

View File

@@ -3,6 +3,8 @@
#include <hyperion/Hyperion.h>
#include <hyperion/GrabberWrapper.h>
using namespace hyperion;
ComponentRegister::ComponentRegister(Hyperion* hyperion)
@@ -11,12 +13,45 @@ ComponentRegister::ComponentRegister(Hyperion* hyperion)
{
// init all comps to false
QVector<hyperion::Components> vect;
vect << COMP_ALL << COMP_SMOOTHING << COMP_BLACKBORDER << COMP_FORWARDER << COMP_GRABBER << COMP_V4L << COMP_LEDDEVICE;
vect << COMP_ALL << COMP_SMOOTHING << COMP_LEDDEVICE;
#if defined(ENABLE_BOBLIGHT)
bool areScreenGrabberAvailable = !GrabberWrapper::availableGrabbers(GrabberTypeFilter::VIDEO).isEmpty();
bool areVideoGrabberAvailable = !GrabberWrapper::availableGrabbers(GrabberTypeFilter::VIDEO).isEmpty();
bool flatBufServerAvailable { false };
bool protoBufServerAvailable{ false };
#if defined(ENABLE_FLATBUF_SERVER)
flatBufServerAvailable = true;
#endif
#if defined(ENABLE_PROTOBUF_SERVER)
protoBufServerAvailable = true;
#endif
if (areScreenGrabberAvailable)
{
vect << COMP_GRABBER;
}
if (areVideoGrabberAvailable)
{
vect << COMP_V4L;
}
if (areScreenGrabberAvailable || areVideoGrabberAvailable || flatBufServerAvailable || protoBufServerAvailable)
{
vect << COMP_BLACKBORDER;
}
#if defined(ENABLE_BOBLIGHT_SERVER)
vect << COMP_BOBLIGHTSERVER;
#endif
#if defined(ENABLE_FORWARDER)
vect << COMP_FORWARDER;
#endif
for(auto e : vect)
{
_componentStates.emplace(e, (e == COMP_ALL));
@@ -36,12 +71,16 @@ int ComponentRegister::isComponentEnabled(hyperion::Components comp) const
void ComponentRegister::setNewComponentState(hyperion::Components comp, bool activated)
{
if(_componentStates[comp] != activated)
if (_componentStates.count(comp) > 0)
{
Debug( _log, "%s: %s", componentToString(comp), (activated? "enabled" : "disabled"));
_componentStates[comp] = activated;
// emit component has changed state
emit updatedComponentState(comp, activated);
if (_componentStates[comp] != activated)
{
Debug(_log, "%s: %s", componentToString(comp), (activated ? "enabled" : "disabled"));
_componentStates[comp] = activated;
// emit component has changed state
emit updatedComponentState(comp, activated);
}
}
}

View File

@@ -83,58 +83,70 @@ bool GrabberWrapper::isActive() const
return _timer->isActive();
}
QStringList GrabberWrapper::getActive(int inst) const
QStringList GrabberWrapper::getActive(int inst, GrabberTypeFilter type) const
{
QStringList result = QStringList();
if(GRABBER_V4L_CLIENTS.contains(inst))
result << GRABBER_V4L_CLIENTS.value(inst);
if (type == GrabberTypeFilter::SCREEN || type == GrabberTypeFilter::ALL)
{
if (GRABBER_SYS_CLIENTS.contains(inst))
result << GRABBER_SYS_CLIENTS.value(inst);
}
if(GRABBER_SYS_CLIENTS.contains(inst))
result << GRABBER_SYS_CLIENTS.value(inst);
if (type == GrabberTypeFilter::VIDEO || type == GrabberTypeFilter::ALL)
{
if (GRABBER_V4L_CLIENTS.contains(inst))
result << GRABBER_V4L_CLIENTS.value(inst);
}
return result;
}
QStringList GrabberWrapper::availableGrabbers()
QStringList GrabberWrapper::availableGrabbers(GrabberTypeFilter type)
{
QStringList grabbers;
#ifdef ENABLE_DISPMANX
grabbers << "dispmanx";
#endif
if (type == GrabberTypeFilter::SCREEN || type == GrabberTypeFilter::ALL)
{
#ifdef ENABLE_DISPMANX
grabbers << "dispmanx";
#endif
#if defined(ENABLE_V4L2) || defined(ENABLE_MF)
grabbers << "v4l2";
#endif
#ifdef ENABLE_FB
grabbers << "framebuffer";
#endif
#ifdef ENABLE_FB
grabbers << "framebuffer";
#endif
#ifdef ENABLE_AMLOGIC
grabbers << "amlogic";
#endif
#ifdef ENABLE_AMLOGIC
grabbers << "amlogic";
#endif
#ifdef ENABLE_OSX
grabbers << "osx";
#endif
#ifdef ENABLE_OSX
grabbers << "osx";
#endif
#ifdef ENABLE_X11
grabbers << "x11";
#endif
#ifdef ENABLE_X11
grabbers << "x11";
#endif
#ifdef ENABLE_XCB
grabbers << "xcb";
#endif
#ifdef ENABLE_XCB
grabbers << "xcb";
#endif
#ifdef ENABLE_QT
grabbers << "qt";
#endif
#ifdef ENABLE_QT
grabbers << "qt";
#endif
#ifdef ENABLE_DX
grabbers << "dx";
#endif
}
#ifdef ENABLE_DX
grabbers << "dx";
#endif
if (type == GrabberTypeFilter::VIDEO || type == GrabberTypeFilter::ALL)
{
#if defined(ENABLE_V4L2) || defined(ENABLE_MF)
grabbers << "v4l2";
#endif
}
return grabbers;
}

View File

@@ -9,7 +9,11 @@
// hyperion include
#include <hyperion/Hyperion.h>
#include <hyperion/MessageForwarder.h>
#if defined(ENABLE_FORWARDER)
#include <forwarder/MessageForwarder.h>
#endif
#include <hyperion/ImageProcessor.h>
#include <hyperion/ColorAdjustment.h>
@@ -37,7 +41,7 @@
#include <hyperion/CaptureCont.h>
// Boblight
#if defined(ENABLE_BOBLIGHT)
#if defined(ENABLE_BOBLIGHT_SERVER)
#include <boblightserver/BoblightServer.h>
#endif
@@ -53,14 +57,16 @@ Hyperion::Hyperion(quint8 instance, bool readonlyMode)
, _ledDeviceWrapper(nullptr)
, _deviceSmooth(nullptr)
, _effectEngine(nullptr)
#if defined(ENABLE_FORWARDER)
, _messageForwarder(nullptr)
#endif
, _log(Logger::getInstance("HYPERION"))
, _hwLedCount()
, _ledGridSize(hyperion::getLedLayoutGridSize(getSetting(settings::LEDS).array()))
, _BGEffectHandler(nullptr)
, _captureCont(nullptr)
, _ledBuffer(_ledString.leds().size(), ColorRgb::BLACK)
#if defined(ENABLE_BOBLIGHT)
#if defined(ENABLE_BOBLIGHT_SERVER)
, _boblightServer(nullptr)
#endif
, _readOnlyMode(readonlyMode)
@@ -127,11 +133,13 @@ void Hyperion::start()
//Start in pause mode, a new priority will activate smoothing (either start-effect or grabber)
_deviceSmooth->setPause(true);
#if defined(ENABLE_FORWARDER)
// create the message forwarder only on main instance
if (_instIndex == 0)
{
_messageForwarder = new MessageForwarder(this);
}
#endif
// create the effect engine; needs to be initialized after smoothing!
_effectEngine = new EffectEngine(this);
@@ -155,7 +163,7 @@ void Hyperion::start()
// if there is no startup / background effect and no sending capture interface we probably want to push once BLACK (as PrioMuxer won't emit a priority change)
update();
#if defined(ENABLE_BOBLIGHT)
#if defined(ENABLE_BOBLIGHT_SERVER)
// boblight, can't live in global scope as it depends on layout
_boblightServer = new BoblightServer(this, getSetting(settings::BOBLSERVER));
connect(this, &Hyperion::settingsChanged, _boblightServer, &BoblightServer::handleSettingsUpdate);
@@ -177,13 +185,18 @@ void Hyperion::freeObjects()
clear(-1,true);
// delete components on exit of hyperion core
#if defined(ENABLE_BOBLIGHT)
#if defined(ENABLE_BOBLIGHT_SERVER)
delete _boblightServer;
#endif
delete _captureCont;
delete _effectEngine;
delete _raw2ledAdjustment;
#if defined(ENABLE_FORWARDER)
delete _messageForwarder;
#endif
delete _settingsManager;
delete _ledDeviceWrapper;
}

View File

@@ -17,7 +17,7 @@
LedDeviceRegistry LedDeviceWrapper::_ledDeviceMap {};
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QRecursiveMutex LedDeviceWrapper::_ledDeviceMapLock;
#else
QMutex LedDeviceWrapper::_ledDeviceMapLock{ QMutex::Recursive };

View File

@@ -11,7 +11,6 @@ include_directories(
set(ProtoServer_PROTOS ${CURRENT_SOURCE_DIR}/message.proto )
protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS ${ProtoServer_PROTOS} )
### Split protoclient from protoserver as protoserver relates to HyperionDaemon and standalone capture binarys can't link to it
add_library(protoclient
@@ -27,12 +26,16 @@ add_library(protoserver
)
# disable warnings for auto generated proto files, we can't change the files ....
SET_SOURCE_FILES_PROPERTIES ( ${ProtoServer_PROTO_SRCS} ${ProtoServer_PROTO_HDRS} ${ProtoServer_PROTOS} PROPERTIES COMPILE_FLAGS -w )
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
set_source_files_properties(${ProtoServer_PROTO_SRCS} ${ProtoServer_PROTO_HDRS} ${ProtoServer_PROTOS} PROPERTIES COMPILE_FLAGS "-w -Wno-return-local-addr")
elseif(MSVC)
set_source_files_properties(${ProtoServer_PROTO_SRCS} ${ProtoServer_PROTO_HDRS} ${ProtoServer_PROTOS} PROPERTIES COMPILE_FLAGS "/W0")
endif()
target_link_libraries(protoclient
hyperion
hyperion-utils
protobuf
libprotobuf
Qt${QT_VERSION_MAJOR}::Gui
)

View File

@@ -1,3 +1,4 @@
syntax = "proto2";
package proto;
message HyperionRequest {

View File

@@ -31,7 +31,8 @@ PythonInit::PythonInit()
#if defined(ENABLE_DEPLOY_DEPENDENCIES)
// Set Program name
Py_SetProgramName(L"Hyperion");
wchar_t programName[] = L"Hyperion";
Py_SetProgramName(programName);
// set Python module path when exists
QString py_path = QDir::cleanPath(qApp->applicationDirPath() + "/../lib/python" + STRINGIFY(PYTHON_VERSION_MAJOR) + "." + STRINGIFY(PYTHON_VERSION_MINOR));

View File

@@ -17,7 +17,7 @@
static const QString SSDP_IDENTIFIER("urn:hyperion-project.org:device:basic:1");
SSDPHandler::SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 protoBufPort, quint16 jsonServerPort, quint16 sslPort, const QString& name, QObject * parent)
SSDPHandler::SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 protoBufPort, quint16 jsonServerPort, quint16 sslPort, const QString& name, QObject* parent)
: SSDPServer(parent)
, _webserver(webserver)
, _localAddress()
@@ -44,22 +44,31 @@ void SSDPHandler::initServer()
// announce targets
_deviceList.push_back("upnp:rootdevice");
_deviceList.push_back("uuid:"+_uuid);
_deviceList.push_back("uuid:" + _uuid);
_deviceList.push_back(SSDP_IDENTIFIER);
// prep server
SSDPServer::initServer();
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
#endif
_NCA = new QNetworkConfigurationManager(this);
connect(_NCA, &QNetworkConfigurationManager::configurationChanged, this, &SSDPHandler::handleNetworkConfigurationChanged);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QT_WARNING_POP
#endif
#endif
// listen for mSearchRequestes
connect(this, &SSDPServer::msearchRequestReceived, this, &SSDPHandler::handleMSearchRequest);
// get localAddress from interface
if(!getLocalAddress().isEmpty())
if (!getLocalAddress().isEmpty())
{
_localAddress = getLocalAddress();
}
@@ -68,7 +77,7 @@ void SSDPHandler::initServer()
bool isInited = false;
QMetaObject::invokeMethod(_webserver, "isInited", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, isInited));
if(!_localAddress.isEmpty() && isInited)
if (!_localAddress.isEmpty() && isInited)
{
handleWebServerStateChange(true);
}
@@ -84,33 +93,33 @@ void SSDPHandler::handleSettingsUpdate(settings::type type, const QJsonDocument&
{
const QJsonObject& obj = config.object();
if(type == settings::FLATBUFSERVER)
if (type == settings::FLATBUFSERVER)
{
if(obj["port"].toInt() != SSDPServer::getFlatBufPort())
if (obj["port"].toInt() != SSDPServer::getFlatBufPort())
{
SSDPServer::setFlatBufPort(obj["port"].toInt());
}
}
if(type == settings::PROTOSERVER)
if (type == settings::PROTOSERVER)
{
if(obj["port"].toInt() != SSDPServer::getProtoBufPort())
if (obj["port"].toInt() != SSDPServer::getProtoBufPort())
{
SSDPServer::setProtoBufPort(obj["port"].toInt());
}
}
if(type == settings::JSONSERVER)
if (type == settings::JSONSERVER)
{
if(obj["port"].toInt() != SSDPServer::getJsonServerPort())
if (obj["port"].toInt() != SSDPServer::getJsonServerPort())
{
SSDPServer::setJsonServerPort(obj["port"].toInt());
}
}
if(type == settings::WEBSERVER)
if (type == settings::WEBSERVER)
{
if(obj["sslPort"].toInt() != SSDPServer::getSSLServerPort())
if (obj["sslPort"].toInt() != SSDPServer::getSSLServerPort())
{
SSDPServer::setSSLServerPort(obj["sslPort"].toInt());
}
@@ -127,12 +136,12 @@ void SSDPHandler::handleSettingsUpdate(settings::type type, const QJsonDocument&
void SSDPHandler::handleWebServerStateChange(bool newState)
{
if(newState)
if (newState)
{
// refresh info
QMetaObject::invokeMethod(_webserver, "setSSDPDescription", Qt::BlockingQueuedConnection, Q_ARG(QString, buildDesc()));
setDescriptionAddress(getDescAddress());
if(start())
if (start())
sendAnnounceList(true);
}
else
@@ -144,11 +153,15 @@ void SSDPHandler::handleWebServerStateChange(bool newState)
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void SSDPHandler::handleNetworkConfigurationChanged(const QNetworkConfiguration &config)
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
#endif
void SSDPHandler::handleNetworkConfigurationChanged(const QNetworkConfiguration& config)
{
// get localAddress from interface
QString localAddress = getLocalAddress();
if(!localAddress.isEmpty() && _localAddress != localAddress)
if (!localAddress.isEmpty() && _localAddress != localAddress)
{
// revoke old ip
sendAnnounceList(false);
@@ -160,12 +173,15 @@ void SSDPHandler::handleNetworkConfigurationChanged(const QNetworkConfiguration
sendAnnounceList(true);
}
}
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
QT_WARNING_POP
#endif
#endif
QString SSDPHandler::getLocalAddress() const
{
// get the first valid IPv4 address. This is probably not that one we actually want to announce
for(const auto & address : QNetworkInterface::allAddresses())
for (const auto& address : QNetworkInterface::allAddresses())
{
// is valid when, no loopback, IPv4
if (!address.isLoopback() && address.protocol() == QAbstractSocket::IPv4Protocol)
@@ -178,11 +194,11 @@ QString SSDPHandler::getLocalAddress() const
void SSDPHandler::handleMSearchRequest(const QString& target, const QString& mx, const QString address, quint16 port)
{
const auto respond = [=] () {
const auto respond = [=]() {
// when searched for all devices / root devices / basic device
if(target == "ssdp:all")
if (target == "ssdp:all")
sendMSearchResponse(SSDP_IDENTIFIER, address, port);
else if(target == "upnp:rootdevice" || target == "urn:schemas-upnp-org:device:basic:1" || target == SSDP_IDENTIFIER)
else if (target == "upnp:rootdevice" || target == "urn:schemas-upnp-org:device:basic:1" || target == SSDP_IDENTIFIER)
sendMSearchResponse(target, address, port);
};
@@ -208,7 +224,7 @@ void SSDPHandler::handleMSearchRequest(const QString& target, const QString& mx,
QString SSDPHandler::getDescAddress() const
{
return getBaseAddress()+"description.xml";
return getBaseAddress() + "description.xml";
}
QString SSDPHandler::getBaseAddress() const
@@ -230,20 +246,20 @@ QString SSDPHandler::buildDesc() const
/// %8 flatbuf port 19400
return SSDP_DESCRIPTION.arg(
getBaseAddress(),
QString("Hyperion (%1)").arg(_localAddress),
QString(HYPERION_VERSION),
_uuid,
QString::number(SSDPServer::getJsonServerPort()),
QString::number(SSDPServer::getSSLServerPort()),
QString::number(SSDPServer::getProtoBufPort()),
QString::number(SSDPServer::getFlatBufPort())
getBaseAddress(),
QString("Hyperion (%1)").arg(_localAddress),
QString(HYPERION_VERSION),
_uuid,
QString::number(SSDPServer::getJsonServerPort()),
QString::number(SSDPServer::getSSLServerPort()),
QString::number(SSDPServer::getProtoBufPort()),
QString::number(SSDPServer::getFlatBufPort())
);
}
void SSDPHandler::sendAnnounceList(bool alive)
{
for(const auto & entry : _deviceList){
for (const auto& entry : _deviceList) {
alive ? SSDPServer::sendAlive(entry) : SSDPServer::sendByeBye(entry);
}
}

View File

@@ -27,7 +27,9 @@ static const QString UPNP_ALIVE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
"NTS: ssdp:alive\r\n"
"SERVER: %4\r\n"
"USN: uuid:%5\r\n"
#if defined(ENABLE_FLATBUF_SERVER)
"HYPERION-FBS-PORT: %6\r\n"
#endif
"HYPERION-JSS-PORT: %7\r\n"
"HYPERION-NAME: %8\r\n"
"\r\n";
@@ -72,7 +74,9 @@ static const QString UPNP_MSEARCH_RESPONSE = "HTTP/1.1 200 OK\r\n"
"SERVER: %4\r\n"
"ST: %5\r\n"
"USN: uuid:%6\r\n"
#if defined(ENABLE_FLATBUF_SERVER)
"HYPERION-FBS-PORT: %7\r\n"
#endif
"HYPERION-JSS-PORT: %8\r\n"
"HYPERION-NAME: %9\r\n"
"\r\n";
@@ -175,7 +179,9 @@ void SSDPServer::sendMSearchResponse(const QString& st, const QString& senderIp,
, _serverHeader
, st
, _uuid
#if defined(ENABLE_FLATBUF_SERVER)
, _fbsPort
#endif
, _jssPort
, _name );
@@ -202,7 +208,9 @@ void SSDPServer::sendAlive(const QString& st)
, st
, _serverHeader
, tempUSN
#if defined(ENABLE_FLATBUF_SERVER)
, _fbsPort
#endif
, _jssPort
, _name );

View File

@@ -17,7 +17,7 @@
#include <QThreadStorage>
#include <time.h>
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
QRecursiveMutex Logger::MapLock;
#else
QMutex Logger::MapLock{ QMutex::Recursive };

View File

@@ -1,10 +1,25 @@
#ifdef _WIN32
#include <QCoreApplication>
#include <QProcess>
#include <utils/Logger.h>
#include <QString>
#include <QByteArray>
namespace Process {
void restartHyperion(bool asNewProcess) {}
void restartHyperion(bool asNewProcess)
{
Logger* log = Logger::getInstance("Process");
Info(log, "Restarting hyperion ...");
auto arguments = QCoreApplication::arguments();
if (!arguments.contains("--wait-hyperion"))
arguments << "--wait-hyperion";
QProcess::startDetached(QCoreApplication::applicationFilePath(), arguments);
QCoreApplication::quit();
}
QByteArray command_exec(const QString& /*cmd*/, const QByteArray& /*data*/)
{

View File

@@ -15,7 +15,7 @@
#include <shlobj_core.h>
#endif
SysInfo* SysInfo::_instance = nullptr;
std::unique_ptr<SysInfo> SysInfo::_instance = nullptr;
SysInfo::SysInfo()
: QObject()
@@ -38,7 +38,7 @@ SysInfo::SysInfo()
SysInfo::HyperionSysInfo SysInfo::get()
{
if (SysInfo::_instance == nullptr)
SysInfo::_instance = new SysInfo();
SysInfo::_instance = std::unique_ptr<SysInfo>(new SysInfo());
return SysInfo::_instance->_sysinfo;
}