Merge remote-tracking branch 'origin/master' into temperture

This commit is contained in:
LordGrey 2024-03-03 11:58:50 +01:00
commit 168caa255e
67 changed files with 820 additions and 933 deletions

View File

@ -226,7 +226,7 @@ jobs:
echo '::endgroup::' echo '::endgroup::'
- name: 💾 Artifact download - name: 💾 Artifact download
uses: actions/download-artifact@v4.1.1 uses: actions/download-artifact@v4.1.4
with: with:
pattern: artifact-* pattern: artifact-*
path: all-artifacts path: all-artifacts

View File

@ -88,6 +88,7 @@ Note: The wizard will configure an APIv2 capable bridge always with Entertainmen
- Changed default build from Stretch to Buster - Changed default build from Stretch to Buster
- Support Qt 6.7, Update to Protobuf 25.1, Update mbedTLS to v3.4.0, Update flatbuffers to v23.5.26 - Support Qt 6.7, Update to Protobuf 25.1, Update mbedTLS to v3.4.0, Update flatbuffers to v23.5.26
- Use C++17 standard as default - Use C++17 standard as default
- Started using SmartPointers (#981)
- Added Pull Request (PR) installation script, allowing users to test development builds savely on Linux - Added Pull Request (PR) installation script, allowing users to test development builds savely on Linux
- Fixed missing include limits in QJsonSchemaChecker - Thanks @Portisch - Fixed missing include limits in QJsonSchemaChecker - Thanks @Portisch
- Fixed dependencies for deb packages in Debian Bookworm (#1579) - Thanks @hg42, @Psirus - Fixed dependencies for deb packages in Debian Bookworm (#1579) - Thanks @hg42, @Psirus

View File

@ -70,7 +70,7 @@ if [[ ! -z ${CURRENT_SERVICE} ]]; then
exit 0; exit 0;
fi fi
echo "Disable current service: ${CURRENT_SERVICE}" echo "Disable current service: ${CURRENT_SERVICE}"
systemctl is-active --quiet ${CURRENT_SERVICE} && systemctl disable --quiet ${CURRENT_SERVICE} --now >/dev/null 2>&1 systemctl disable --quiet ${CURRENT_SERVICE} --now >/dev/null 2>&1
fi fi
HYPERION="hyperion" HYPERION="hyperion"
@ -84,9 +84,5 @@ NEW_SERVICE="${HYPERION}@${USERNAME}.service"
echo "Restarting Hyperion Service: ${NEW_SERVICE}" echo "Restarting Hyperion Service: ${NEW_SERVICE}"
systemctl enable --quiet ${NEW_SERVICE} --now >/dev/null 2>&1 systemctl enable --quiet ${NEW_SERVICE} --now >/dev/null 2>&1
# Update HyperBian splash screen
sed -i "s/${CURRENT_SERVICE}/${NEW_SERVICE}/" /etc/update-motd.d/10-hyperbian >/dev/null 2>&1
echo "Done." echo "Done."
exit 0 exit 0

View File

@ -13,10 +13,9 @@ class EventHandler : public QObject
Q_OBJECT Q_OBJECT
public: public:
EventHandler();
~EventHandler() override; ~EventHandler() override;
static EventHandler* getInstance(); static QScopedPointer<EventHandler>& getInstance();
public slots: public slots:
@ -40,6 +39,12 @@ protected:
Logger * _log {}; Logger * _log {};
private: private:
EventHandler();
EventHandler(const EventHandler&) = delete;
EventHandler& operator=(const EventHandler&) = delete;
static QScopedPointer<EventHandler> instance;
bool _isSuspended; bool _isSuspended;
bool _isIdle; bool _isIdle;
}; };

View File

@ -12,6 +12,9 @@ class AmlogicWrapper : public GrabberWrapper
{ {
Q_OBJECT Q_OBJECT
public: public:
static constexpr const char* GRABBERTYPE = "Amlogic";
/// ///
/// Constructs the Amlogic frame grabber /// Constructs the Amlogic frame grabber
/// ///
@ -22,6 +25,12 @@ public:
AmlogicWrapper(int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION, AmlogicWrapper(int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION,
int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ); int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ);
///
/// Constructs the Amlogic frame grabber from configuration settings
///
AmlogicWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
public slots: public slots:
/// ///
/// Performs a single frame grab and computes the led-colors /// Performs a single frame grab and computes the led-colors

View File

@ -6,6 +6,8 @@
class DirectXWrapper: public GrabberWrapper class DirectXWrapper: public GrabberWrapper
{ {
public: public:
static constexpr const char* GRABBERTYPE = "DirectX";
/// ///
/// Constructs the DirectX grabber with a specified grab size and update rate. /// Constructs the DirectX grabber with a specified grab size and update rate.
/// ///
@ -25,6 +27,11 @@ public:
int cropTop=0, int cropBottom=0 int cropTop=0, int cropBottom=0
); );
///
/// Constructs the QT frame grabber from configuration settings
///
DirectXWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
/// ///
/// Destructor of this DirectX grabber. Releases any claimed resources. /// Destructor of this DirectX grabber. Releases any claimed resources.
/// ///

View File

@ -36,9 +36,9 @@ public:
/// ///
/// @brief Determine if the bcm library is available. /// @brief Determine if the bcm library is available.
/// ///
/// @return Zero, on success (i.e. library is present), else negative /// @return true, on success (i.e. library is present), else false
/// ///
bool isAvailable(); bool isAvailable() override;
/// ///
/// @brief Opens the input device. /// @brief Opens the input device.

View File

@ -13,6 +13,9 @@ class DispmanxWrapper: public GrabberWrapper
{ {
Q_OBJECT Q_OBJECT
public: public:
static constexpr const char* GRABBERTYPE = "DispmanX";
/// ///
/// Constructs the dispmanx frame grabber with a specified grab size and update rate. /// Constructs the dispmanx frame grabber with a specified grab size and update rate.
/// ///
@ -23,9 +26,12 @@ public:
int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION
); );
bool screenInit(); ///
/// Constructs the QT frame grabber from configuration settings
///
DispmanxWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
bool available = false; bool screenInit();
/// ///
/// Starts the grabber which produces led values with the specified update rate /// Starts the grabber which produces led values with the specified update rate

View File

@ -17,7 +17,7 @@ public:
/// ///
/// @param[in] device The framebuffer device name/path /// @param[in] device The framebuffer device name/path
/// ///
FramebufferFrameGrabber(const QString & device="/dev/fb0"); FramebufferFrameGrabber(int deviceIdx = 0);
~FramebufferFrameGrabber() override; ~FramebufferFrameGrabber() override;
@ -45,7 +45,7 @@ public:
///@brief Set new width and height for framegrabber, overwrite Grabber.h implementation ///@brief Set new width and height for framegrabber, overwrite Grabber.h implementation
bool setWidthHeight(int width, int height) override; bool setWidthHeight(int width, int height) override;
QString getPath() const {return _fbDevice;} QString getPath() const {return QString("/dev/fb%1").arg(_input);}
/// ///
/// @brief Discover Framebuffer screens available (for configuration). /// @brief Discover Framebuffer screens available (for configuration).
@ -62,7 +62,7 @@ private:
bool closeDevice(); bool closeDevice();
bool getScreenInfo(); bool getScreenInfo();
/// Framebuffer device e.g. /dev/fb0 // /// Framebuffer device e.g. /dev/fb0
QString _fbDevice; QString _fbDevice;
int _fbfd; int _fbfd;

View File

@ -12,18 +12,26 @@ class FramebufferWrapper: public GrabberWrapper
{ {
Q_OBJECT Q_OBJECT
public: public:
static constexpr const char* GRABBERTYPE = "FB";
/// ///
/// Constructs the framebuffer frame grabber with a specified grab size and update rate. /// Constructs the framebuffer frame grabber with a specified grab size and update rate.
/// ///
/// @param[in] updateRate_Hz The image grab rate [Hz] /// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] device Framebuffer device name/path /// @param[in] deviceIdx Framebuffer device index
/// @param[in] pixelDecimation Decimation factor for image [pixels] /// @param[in] pixelDecimation Decimation factor for image [pixels]
/// ///
FramebufferWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ, FramebufferWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ,
const QString & device = "/dev/fb0", int deviceIdx = 0,
int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION
); );
///
/// Constructs the QT frame grabber from configuration settings
///
FramebufferWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
public slots: public slots:
/// ///
/// Performs a single frame grab and computes the led-colors /// Performs a single frame grab and computes the led-colors

View File

@ -11,6 +11,8 @@ class OsxWrapper: public GrabberWrapper
{ {
Q_OBJECT Q_OBJECT
public: public:
static constexpr const char* GRABBERTYPE = "OSX";
/// ///
/// Constructs the osx frame grabber with a specified grab size and update rate. /// Constructs the osx frame grabber with a specified grab size and update rate.
/// ///
@ -23,6 +25,12 @@ public:
int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION
); );
///
/// Constructs the QT frame grabber from configuration settings
///
OsxWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
public slots: public slots:
/// ///
/// Performs a single frame grab and computes the led-colors /// Performs a single frame grab and computes the led-colors

View File

@ -1,5 +1,8 @@
#pragma once #pragma once
#include <QJsonObject>
#include <QStringLiteral>
#include <hyperion/GrabberWrapper.h> #include <hyperion/GrabberWrapper.h>
#include <grabber/qt/QtGrabber.h> #include <grabber/qt/QtGrabber.h>
@ -8,7 +11,10 @@
/// ///
class QtWrapper: public GrabberWrapper class QtWrapper: public GrabberWrapper
{ {
public: public:
static constexpr const char* GRABBERTYPE = "Qt";
/// ///
/// Constructs the QT frame grabber with a specified grab size and update rate. /// Constructs the QT frame grabber with a specified grab size and update rate.
/// ///
@ -19,7 +25,6 @@ public:
/// @param[in] cropRight Remove from right [pixels] /// @param[in] cropRight Remove from right [pixels]
/// @param[in] cropTop Remove from top [pixels] /// @param[in] cropTop Remove from top [pixels]
/// @param[in] cropBottom Remove from bottom [pixels] /// @param[in] cropBottom Remove from bottom [pixels]
/// ///
QtWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ, QtWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ,
int display=0, int display=0,
@ -28,6 +33,11 @@ public:
int cropTop=0, int cropBottom=0 int cropTop=0, int cropBottom=0
); );
///
/// Constructs the QT frame grabber from configuration settings
///
QtWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
/// ///
/// Starts the grabber which produces led values with the specified update rate /// Starts the grabber which produces led values with the specified update rate
/// ///

View File

@ -7,7 +7,6 @@
#undef None #undef None
#endif #endif
/// ///
/// The X11Wrapper uses an instance of the X11Grabber to obtain ImageRgb's from the displayed content. /// The X11Wrapper uses an instance of the X11Grabber to obtain ImageRgb's from the displayed content.
/// This ImageRgb is processed to a ColorRgb for each led and committed to the attached Hyperion. /// This ImageRgb is processed to a ColorRgb for each led and committed to the attached Hyperion.
@ -15,6 +14,8 @@
class X11Wrapper: public GrabberWrapper class X11Wrapper: public GrabberWrapper
{ {
public: public:
static constexpr const char* GRABBERTYPE = "X11";
/// ///
/// Constructs the X11 frame grabber with a specified grab size and update rate. /// Constructs the X11 frame grabber with a specified grab size and update rate.
/// ///
@ -27,6 +28,11 @@ public:
int cropTop=0, int cropBottom=0 int cropTop=0, int cropBottom=0
); );
///
/// Constructs the X11 frame grabber from configuration settings
///
X11Wrapper(const QJsonDocument& grabberConfig = QJsonDocument());
/// ///
/// Destructor of this frame grabber. Releases any claimed resources. /// Destructor of this frame grabber. Releases any claimed resources.
/// ///

View File

@ -11,12 +11,30 @@
class XcbWrapper: public GrabberWrapper class XcbWrapper: public GrabberWrapper
{ {
public: public:
static constexpr const char* GRABBERTYPE = "XCB";
///
/// Constructs the XCB frame grabber with a specified grab size and update rate.
///
/// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] pixelDecimation Decimation factor for image [pixels]
/// @param[in] cropLeft Remove from left [pixels]
/// @param[in] cropRight Remove from right [pixels]
/// @param[in] cropTop Remove from top [pixels]
/// @param[in] cropBottom Remove from bottom [pixels]
///
XcbWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ, XcbWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ,
int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION, int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION,
int cropLeft=0, int cropRight=0, int cropLeft=0, int cropRight=0,
int cropTop=0, int cropBottom=0 int cropTop=0, int cropBottom=0
); );
///
/// Constructs the XCB frame grabber from configuration settings
///
XcbWrapper(const QJsonDocument& grabberConfig = QJsonDocument());
~XcbWrapper() override; ~XcbWrapper() override;
public slots: public slots:

View File

@ -113,6 +113,13 @@ public:
QString getGrabberName() const { return _grabberName; } QString getGrabberName() const { return _grabberName; }
///
/// @brief Determine if the grabber is available.
///
/// @return true, on success (i.e. library is present), else false
///
virtual bool isAvailable() { return _isAvailable; }
public slots: public slots:
virtual void handleEvent(Event event) {} virtual void handleEvent(Event event) {}
@ -168,10 +175,15 @@ protected:
// Device states // Device states
/// Is the device available?
bool _isAvailable;
/// Is the device enabled? /// Is the device enabled?
bool _isEnabled; bool _isEnabled;
/// Is the device in error state and stopped? /// Is the device in error state and stopped?
bool _isDeviceInError; bool _isDeviceInError;
}; };

View File

@ -32,6 +32,14 @@ class GrabberWrapper : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static constexpr const char* GRABBERTYPE = "Base";
template<typename GrabberType>
static QSharedPointer<GrabberType> create(const QJsonDocument& config) {
return QSharedPointer<GrabberType>::create(config);
}
GrabberWrapper(const QString& grabberName, Grabber * ggrabber,int updateRate_Hz = DEFAULT_RATE_HZ); GrabberWrapper(const QString& grabberName, Grabber * ggrabber,int updateRate_Hz = DEFAULT_RATE_HZ);
~GrabberWrapper() override; ~GrabberWrapper() override;
@ -71,6 +79,11 @@ public:
/// ///
virtual bool isActive() const; virtual bool isActive() const;
virtual bool isAvailable() { return _isAvailable; }
QString getName() { return _grabberName; }
/// ///
/// @brief Get active grabber name /// @brief Get active grabber name
/// @param hyperionInd The instance index /// @param hyperionInd The instance index
@ -195,4 +208,6 @@ protected:
/// The image used for grabbing frames /// The image used for grabbing frames
Image<ColorRgb> _image; Image<ColorRgb> _image;
bool _isAvailable;
}; };

View File

@ -17,6 +17,7 @@
#include <QByteArray> #include <QByteArray>
#include <QMap> #include <QMap>
#include <QJsonArray> #include <QJsonArray>
#include <QScopedPointer>
#include <QSharedPointer> #include <QSharedPointer>
// Utility includes // Utility includes
@ -39,21 +40,17 @@ private:
/// ///
// Run MdnsBrowser as singleton // Run MdnsBrowser as singleton
MdnsBrowser(QObject* parent = nullptr); MdnsBrowser(QObject* parent = nullptr);
~MdnsBrowser() override;
public:
static MdnsBrowser& getInstance()
{
static MdnsBrowser* instance = new MdnsBrowser();
return *instance;
}
MdnsBrowser(const MdnsBrowser&) = delete; MdnsBrowser(const MdnsBrowser&) = delete;
MdnsBrowser(MdnsBrowser&&) = delete; MdnsBrowser(MdnsBrowser&&) = delete;
MdnsBrowser& operator=(const MdnsBrowser&) = delete; MdnsBrowser& operator=(const MdnsBrowser&) = delete;
MdnsBrowser& operator=(MdnsBrowser&&) = delete; MdnsBrowser& operator=(MdnsBrowser&&) = delete;
static QScopedPointer<MdnsBrowser> instance;
public:
~MdnsBrowser() override;
static QScopedPointer<MdnsBrowser>& getInstance();
QMdnsEngine::Service getFirstService(const QByteArray& serviceType, const QString& filter = ".*", const std::chrono::milliseconds waitTime = DEFAULT_DISCOVER_TIMEOUT) const; QMdnsEngine::Service getFirstService(const QByteArray& serviceType, const QString& filter = ".*", const std::chrono::milliseconds waitTime = DEFAULT_DISCOVER_TIMEOUT) const;
QJsonArray getServicesDiscoveredJson(const QByteArray& serviceType, const QString& filter = ".*", const std::chrono::milliseconds waitTime = std::chrono::milliseconds{ 0 }) const; QJsonArray getServicesDiscoveredJson(const QByteArray& serviceType, const QString& filter = ".*", const std::chrono::milliseconds waitTime = std::chrono::milliseconds{ 0 }) const;

View File

@ -7,6 +7,7 @@
#include <QAtomicInteger> #include <QAtomicInteger>
#include <QList> #include <QList>
#include <QJsonArray> #include <QJsonArray>
#include <QScopedPointer>
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
#include <QRecursiveMutex> #include <QRecursiveMutex>
@ -106,8 +107,19 @@ class LoggerManager : public QObject
{ {
Q_OBJECT Q_OBJECT
private:
// Run LoggerManager as singleton
LoggerManager();
LoggerManager(const LoggerManager&) = delete;
LoggerManager(LoggerManager&&) = delete;
LoggerManager& operator=(const LoggerManager&) = delete;
LoggerManager& operator=(LoggerManager&&) = delete;
static QScopedPointer<LoggerManager> instance;
public: public:
static LoggerManager* getInstance(); ~LoggerManager() override;
static QScopedPointer<LoggerManager>& getInstance();
public slots: public slots:
void handleNewLogMessage(const Logger::T_LOG_MESSAGE&); void handleNewLogMessage(const Logger::T_LOG_MESSAGE&);
@ -117,7 +129,6 @@ signals:
void newLogMessage(const Logger::T_LOG_MESSAGE&); void newLogMessage(const Logger::T_LOG_MESSAGE&);
private: private:
LoggerManager();
QList<Logger::T_LOG_MESSAGE> _logMessageBuffer; QList<Logger::T_LOG_MESSAGE> _logMessageBuffer;
const int _loggerMaxMsgBufferSize; const int _loggerMaxMsgBufferSize;

View File

@ -111,7 +111,7 @@ namespace NetUtils {
if (hostname.endsWith(".local") || hostname.endsWith(".local.")) if (hostname.endsWith(".local") || hostname.endsWith(".local."))
{ {
QHostAddress resolvedAddress; QHostAddress resolvedAddress;
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "resolveAddress", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "resolveAddress",
Qt::BlockingQueuedConnection, Qt::BlockingQueuedConnection,
Q_RETURN_ARG(bool, isHostAddressOK), Q_RETURN_ARG(bool, isHostAddressOK),
Q_ARG(Logger*, log), Q_ARG(QString, hostname), Q_ARG(QHostAddress&, resolvedAddress)); Q_ARG(Logger*, log), Q_ARG(QString, hostname), Q_ARG(QHostAddress&, resolvedAddress));
@ -163,7 +163,7 @@ namespace NetUtils {
if (hostname.endsWith("._tcp.local")) if (hostname.endsWith("._tcp.local"))
{ {
//Treat hostname as service instance name that requires to be resolved into an mDNS-Hostname first //Treat hostname as service instance name that requires to be resolved into an mDNS-Hostname first
QMdnsEngine::Record service = MdnsBrowser::getInstance().getServiceInstanceRecord(hostname.toUtf8()); QMdnsEngine::Record service = MdnsBrowser::getInstance().data()->getServiceInstanceRecord(hostname.toUtf8());
if (!service.target().isEmpty()) if (!service.target().isEmpty())
{ {
Info(log, "Resolved service [%s] to mDNS hostname [%s], service port [%d]", QSTRING_CSTR(hostname), service.target().constData(), service.port()); Info(log, "Resolved service [%s] to mDNS hostname [%s], service port [%d]", QSTRING_CSTR(hostname), service.target().constData(), service.port());

View File

@ -4,6 +4,7 @@
#include <QObject> #include <QObject>
#include <QString> #include <QString>
#include <QJsonDocument> #include <QJsonDocument>
#include <QScopedPointer>
// hyperion / utils // hyperion / utils
#include <utils/Logger.h> #include <utils/Logger.h>
@ -64,7 +65,7 @@ public slots:
void onServerStopped (); void onServerStopped ();
void onServerStarted (quint16 port); void onServerStarted (quint16 port);
void onServerError (QString msg); void onServerError (const QString& msg);
/// ///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor /// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
@ -90,7 +91,7 @@ private:
QString _baseUrl; QString _baseUrl;
quint16 _port; quint16 _port;
StaticFileServing* _staticFileServing; StaticFileServing* _staticFileServing;
QtHttpServer* _server; QScopedPointer<QtHttpServer> _server;
bool _inited = false; bool _inited = false;
}; };

View File

@ -143,7 +143,7 @@ void JsonAPI::initialize()
} }
//notify eventhadler on suspend/resume/idle requests //notify eventhadler on suspend/resume/idle requests
connect(this, &JsonAPI::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); connect(this, &JsonAPI::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
connect(_ledStreamTimer, &QTimer::timeout, this, &JsonAPI::streamLedColorsUpdate, Qt::UniqueConnection); connect(_ledStreamTimer, &QTimer::timeout, this, &JsonAPI::streamLedColorsUpdate, Qt::UniqueConnection);
} }
@ -1091,7 +1091,7 @@ void JsonAPI::handleConfigRestoreCommand(const QJsonObject &message, const QStri
} }
} }
void JsonAPI::handleSchemaGetCommand(const QJsonObject &message, const QString &command, int tan) void JsonAPI::handleSchemaGetCommand(const QJsonObject& /*message*/, const QString &command, int tan)
{ {
// create result // create result
QJsonObject schemaJson, alldevices, properties; QJsonObject schemaJson, alldevices, properties;
@ -1240,7 +1240,7 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
if (!_streaming_logging_activated) if (!_streaming_logging_activated)
{ {
_streaming_logging_reply["command"] = command + "-update"; _streaming_logging_reply["command"] = command + "-update";
connect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage); connect(LoggerManager::getInstance().data(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
emit incommingLogMessage (Logger::T_LOG_MESSAGE{}); // needed to trigger log sending emit incommingLogMessage (Logger::T_LOG_MESSAGE{}); // needed to trigger log sending
Debug(_log, "log streaming activated for client %s", _peerAddress.toStdString().c_str()); Debug(_log, "log streaming activated for client %s", _peerAddress.toStdString().c_str());
@ -1250,7 +1250,7 @@ void JsonAPI::handleLoggingCommand(const QJsonObject &message, const QString &co
{ {
if (_streaming_logging_activated) if (_streaming_logging_activated)
{ {
disconnect(LoggerManager::getInstance(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage); disconnect(LoggerManager::getInstance().data(), &LoggerManager::newLogMessage, this, &JsonAPI::incommingLogMessage);
_streaming_logging_activated = false; _streaming_logging_activated = false;
Debug(_log, "log streaming deactivated for client %s", _peerAddress.toStdString().c_str()); Debug(_log, "log streaming deactivated for client %s", _peerAddress.toStdString().c_str());
} }
@ -1714,59 +1714,54 @@ void JsonAPI::handleInputSourceCommand(const QJsonObject& message, const QString
QJsonObject device; QJsonObject device;
#ifdef ENABLE_QT #ifdef ENABLE_QT
QtGrabber* qtgrabber = new QtGrabber(); QScopedPointer<QtGrabber> qtgrabber(new QtGrabber());
device = qtgrabber->discover(params); device = qtgrabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete qtgrabber;
#endif #endif
#ifdef ENABLE_DX #ifdef ENABLE_DX
DirectXGrabber* dxgrabber = new DirectXGrabber(); QScopedPointer<DirectXGrabber> dxgrabber (new DirectXGrabber());
device = dxgrabber->discover(params); device = dxgrabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete dxgrabber;
#endif #endif
#ifdef ENABLE_X11 #ifdef ENABLE_X11
X11Grabber* x11Grabber = new X11Grabber(); QScopedPointer<X11Grabber> x11Grabber(new X11Grabber());
device = x11Grabber->discover(params); device = x11Grabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete x11Grabber;
#endif #endif
#ifdef ENABLE_XCB #ifdef ENABLE_XCB
XcbGrabber* xcbGrabber = new XcbGrabber(); QScopedPointer<XcbGrabber> xcbGrabber (new XcbGrabber());
device = xcbGrabber->discover(params); device = xcbGrabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete xcbGrabber;
#endif #endif
//Ignore FB for Amlogic, as it is embedded in the Amlogic grabber itself //Ignore FB for Amlogic, as it is embedded in the Amlogic grabber itself
#if defined(ENABLE_FB) && !defined(ENABLE_AMLOGIC) #if defined(ENABLE_FB) && !defined(ENABLE_AMLOGIC)
FramebufferFrameGrabber* fbGrabber = new FramebufferFrameGrabber(); QScopedPointer<FramebufferFrameGrabber> fbGrabber(new FramebufferFrameGrabber());
device = fbGrabber->discover(params); device = fbGrabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete fbGrabber;
#endif #endif
#if defined(ENABLE_DISPMANX) #if defined(ENABLE_DISPMANX)
DispmanxFrameGrabber* dispmanx = new DispmanxFrameGrabber(); QScopedPointer<DispmanxFrameGrabber> dispmanx(new DispmanxFrameGrabber());
if (dispmanx->isAvailable()) if (dispmanx->isAvailable())
{ {
device = dispmanx->discover(params); device = dispmanx->discover(params);
@ -1775,27 +1770,24 @@ void JsonAPI::handleInputSourceCommand(const QJsonObject& message, const QString
videoInputs.append(device); videoInputs.append(device);
} }
} }
delete dispmanx;
#endif #endif
#if defined(ENABLE_AMLOGIC) #if defined(ENABLE_AMLOGIC)
AmlogicGrabber* amlGrabber = new AmlogicGrabber(); QScopedPointer<AmlogicGrabber> amlGrabber(new AmlogicGrabber());
device = amlGrabber->discover(params); device = amlGrabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete amlGrabber;
#endif #endif
#if defined(ENABLE_OSX) #if defined(ENABLE_OSX)
OsxFrameGrabber* osxGrabber = new OsxFrameGrabber(); QScopedPointer<OsxFrameGrabber> osxGrabber(new OsxFrameGrabber());
device = osxGrabber->discover(params); device = osxGrabber->discover(params);
if (!device.isEmpty() ) if (!device.isEmpty() )
{ {
videoInputs.append(device); videoInputs.append(device);
} }
delete osxGrabber;
#endif #endif
} }
@ -1840,10 +1832,10 @@ void JsonAPI::handleServiceCommand(const QJsonObject &message, const QString &co
if (!serviceType.isEmpty()) if (!serviceType.isEmpty())
{ {
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, serviceType)); Qt::QueuedConnection, Q_ARG(QByteArray, serviceType));
serviceList = MdnsBrowser::getInstance().getServicesDiscoveredJson(serviceType, MdnsServiceRegister::getServiceNameFilter(type), DEFAULT_DISCOVER_TIMEOUT); serviceList = MdnsBrowser::getInstance().data()->getServicesDiscoveredJson(serviceType, MdnsServiceRegister::getServiceNameFilter(type), DEFAULT_DISCOVER_TIMEOUT);
#endif #endif
servicesOfType.insert(type, serviceList); servicesOfType.insert(type, serviceList);
@ -1997,7 +1989,7 @@ void JsonAPI::incommingLogMessage(const Logger::T_LOG_MESSAGE &msg)
if (!_streaming_logging_activated) if (!_streaming_logging_activated)
{ {
_streaming_logging_activated = true; _streaming_logging_activated = true;
QMetaObject::invokeMethod(LoggerManager::getInstance(), "getLogMessageBuffer", QMetaObject::invokeMethod(LoggerManager::getInstance().data(), "getLogMessageBuffer",
Qt::DirectConnection, Qt::DirectConnection,
Q_RETURN_ARG(QJsonArray, messageArray), Q_RETURN_ARG(QJsonArray, messageArray),
Q_ARG(Logger::LogLevel, _log->getLogLevel())); Q_ARG(Logger::LogLevel, _log->getLogLevel()));
@ -2047,7 +2039,7 @@ void JsonAPI::handleTokenResponse(bool success, const QString &token, const QStr
sendErrorReply("Token request timeout or denied", cmd, tan); sendErrorReply("Token request timeout or denied", cmd, tan);
} }
void JsonAPI::handleInstanceStateChange(InstanceState state, quint8 instance, const QString &name) void JsonAPI::handleInstanceStateChange(InstanceState state, quint8 instance, const QString& /*name */)
{ {
switch (state) switch (state)
{ {

View File

@ -38,6 +38,7 @@ CECHandler::CECHandler(const QJsonDocument& config, QObject * parent)
CECHandler::~CECHandler() CECHandler::~CECHandler()
{ {
Info(_logger, "CEC handler stopped");
} }
void CECHandler::handleSettingsUpdate(settings::type type, const QJsonDocument& config) void CECHandler::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
@ -165,7 +166,7 @@ bool CECHandler::enable()
else else
{ {
_isOpen=true; _isOpen=true;
QObject::connect(this, &CECHandler::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); QObject::connect(this, &CECHandler::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
#ifdef VERBOSE_CEC #ifdef VERBOSE_CEC
std::cout << "Found Devices: " << scan().toStdString() << std::endl; std::cout << "Found Devices: " << scan().toStdString() << std::endl;
#endif #endif
@ -188,7 +189,7 @@ void CECHandler::disable()
{ {
if (_isInitialised) if (_isInitialised)
{ {
QObject::disconnect(this, &CECHandler::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); QObject::disconnect(this, &CECHandler::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
_cecAdapter->Close(); _cecAdapter->Close();
_isOpen=false; _isOpen=false;
Info(_logger, "CEC handler disabled"); Info(_logger, "CEC handler disabled");

View File

@ -7,6 +7,8 @@
#include <utils/Process.h> #include <utils/Process.h>
#include <hyperion/HyperionIManager.h> #include <hyperion/HyperionIManager.h>
QScopedPointer<EventHandler> EventHandler::instance;
EventHandler::EventHandler() EventHandler::EventHandler()
: _isSuspended(false) : _isSuspended(false)
, _isIdle(false) , _isIdle(false)
@ -15,6 +17,7 @@ EventHandler::EventHandler()
_log = Logger::getInstance("EVENTS"); _log = Logger::getInstance("EVENTS");
QObject::connect(this, &EventHandler::signalEvent, HyperionIManager::getInstance(), &HyperionIManager::handleEvent); QObject::connect(this, &EventHandler::signalEvent, HyperionIManager::getInstance(), &HyperionIManager::handleEvent);
Debug(_log, "Hyperion event handler created");
} }
EventHandler::~EventHandler() EventHandler::~EventHandler()
@ -22,10 +25,14 @@ EventHandler::~EventHandler()
QObject::disconnect(this, &EventHandler::signalEvent, HyperionIManager::getInstance(), &HyperionIManager::handleEvent); QObject::disconnect(this, &EventHandler::signalEvent, HyperionIManager::getInstance(), &HyperionIManager::handleEvent);
} }
EventHandler* EventHandler::getInstance() QScopedPointer<EventHandler>& EventHandler::getInstance()
{ {
static EventHandler instance; if (!instance)
return &instance; {
instance.reset(new EventHandler());
}
return instance;
} }
void EventHandler::suspend() void EventHandler::suspend()

View File

@ -15,14 +15,16 @@ EventScheduler::EventScheduler()
qRegisterMetaType<Event>("Event"); qRegisterMetaType<Event>("Event");
_log = Logger::getInstance("EVENTS-SCHED"); _log = Logger::getInstance("EVENTS-SCHED");
QObject::connect(this, &EventScheduler::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); QObject::connect(this, &EventScheduler::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
Debug(_log, "Hyperion event scheduler created");
} }
EventScheduler::~EventScheduler() EventScheduler::~EventScheduler()
{ {
QObject::disconnect(this, &EventScheduler::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); QObject::disconnect(this, &EventScheduler::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
clearTimers(); clearTimers();
Info(_log, "Event scheduler stopped"); Info(_log, "Hyperion event scheduler stopped");
} }
void EventScheduler::handleSettingsUpdate(settings::type type, const QJsonDocument& config) void EventScheduler::handleSettingsUpdate(settings::type type, const QJsonDocument& config)

View File

@ -39,12 +39,14 @@ OsEventHandlerBase::OsEventHandlerBase()
{ {
_isService = true; _isService = true;
} }
QObject::connect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); QObject::connect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
Debug(_log, "Operating System event handler created");
} }
OsEventHandlerBase::~OsEventHandlerBase() OsEventHandlerBase::~OsEventHandlerBase()
{ {
QObject::disconnect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); QObject::disconnect(this, &OsEventHandlerBase::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
OsEventHandlerBase::unregisterLockHandler(); OsEventHandlerBase::unregisterLockHandler();
OsEventHandlerBase::unregisterOsEventHandler(); OsEventHandlerBase::unregisterOsEventHandler();

View File

@ -125,6 +125,6 @@ void FlatBufferServer::stopServer()
client->forceClose(); client->forceClose();
} }
_server->close(); _server->close();
Info(_log, "Stopped"); Info(_log, "FlatBuffer-Server stopped");
} }
} }

View File

@ -48,7 +48,7 @@ MessageForwarder::MessageForwarder(Hyperion* hyperion)
qRegisterMetaType<TargetHost>("TargetHost"); qRegisterMetaType<TargetHost>("TargetHost");
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType("jsonapi"))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType("jsonapi")));
#endif #endif
@ -257,7 +257,7 @@ int MessageForwarder::startJsonTargets(const QJsonObject& config)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
if (!addr.isEmpty()) if (!addr.isEmpty())
{ {
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType("jsonapi"))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType("jsonapi")));
} }
#endif #endif
@ -362,7 +362,7 @@ int MessageForwarder::startFlatbufferTargets(const QJsonObject& config)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
if (!addr.isEmpty()) if (!addr.isEmpty())
{ {
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType("flatbuffer"))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType("flatbuffer")));
} }
#endif #endif

View File

@ -27,7 +27,7 @@
namespace { namespace {
const bool verbose = false; const bool verbose = false;
const char DEFAULT_FB_DEVICE[] = "/dev/fb0"; const int DEFAULT_FB_DEVICE_IDX = 0;
const char DEFAULT_VIDEO_DEVICE[] = "/dev/amvideo"; const char DEFAULT_VIDEO_DEVICE[] = "/dev/amvideo";
const char DEFAULT_CAPTURE_DEVICE[] = "/dev/amvideocap0"; const char DEFAULT_CAPTURE_DEVICE[] = "/dev/amvideocap0";
const int AMVIDEOCAP_WAIT_MAX_MS = 40; const int AMVIDEOCAP_WAIT_MAX_MS = 40;
@ -36,11 +36,11 @@ const int AMVIDEOCAP_DEFAULT_RATE_HZ = 25;
} //End of constants } //End of constants
AmlogicGrabber::AmlogicGrabber() AmlogicGrabber::AmlogicGrabber()
: Grabber("AMLOGICGRABBER") // Minimum required width or height is 160 : Grabber("GRABBER-AMLOGIC") // Minimum required width or height is 160
, _captureDev(-1) , _captureDev(-1)
, _videoDev(-1) , _videoDev(-1)
, _lastError(0) , _lastError(0)
, _fbGrabber(DEFAULT_FB_DEVICE) , _fbGrabber(DEFAULT_FB_DEVICE_IDX)
, _grabbingModeNotification(0) , _grabbingModeNotification(0)
{ {
_image_ptr = _image_bgr.memptr(); _image_ptr = _image_bgr.memptr();
@ -57,7 +57,7 @@ bool AmlogicGrabber::setupScreen()
{ {
bool rc (false); bool rc (false);
QSize screenSize = _fbGrabber.getScreenSize(DEFAULT_FB_DEVICE); QSize screenSize = _fbGrabber.getScreenSize();
if ( !screenSize.isEmpty() ) if ( !screenSize.isEmpty() )
{ {
if (setWidthHeight(screenSize.width(), screenSize.height())) if (setWidthHeight(screenSize.width(), screenSize.height()))

View File

@ -1,12 +1,18 @@
#include <grabber/amlogic/AmlogicWrapper.h> #include <grabber/amlogic/AmlogicWrapper.h>
AmlogicWrapper::AmlogicWrapper(int pixelDecimation, int updateRate_Hz) AmlogicWrapper::AmlogicWrapper(int pixelDecimation, int updateRate_Hz)
: GrabberWrapper("Amlogic", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber() , _grabber()
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
AmlogicWrapper::AmlogicWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
void AmlogicWrapper::action() void AmlogicWrapper::action()
{ {
transferFrame(_grabber); transferFrame(_grabber);

View File

@ -10,7 +10,7 @@ namespace {
} //End of constants } //End of constants
DirectXGrabber::DirectXGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom) DirectXGrabber::DirectXGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom)
: Grabber("DXGRABBER", cropLeft, cropRight, cropTop, cropBottom) : Grabber("GRABBER-DIRECTX", cropLeft, cropRight, cropTop, cropBottom)
, _display(unsigned(display)) , _display(unsigned(display))
, _displayWidth(0) , _displayWidth(0)
, _displayHeight(0) , _displayHeight(0)

View File

@ -5,13 +5,19 @@ DirectXWrapper::DirectXWrapper( int updateRate_Hz,
int pixelDecimation, int pixelDecimation,
int cropLeft, int cropRight, int cropTop, int cropBottom int cropLeft, int cropRight, int cropTop, int cropBottom
) )
: GrabberWrapper("DirectX", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(display, cropLeft, cropRight, cropTop, cropBottom) , _grabber(display, cropLeft, cropRight, cropTop, cropBottom)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
DirectXWrapper::DirectXWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
void DirectXWrapper::action() void DirectXWrapper::action()
{ {
transferFrame(_grabber); transferFrame(_grabber);

View File

@ -19,7 +19,7 @@ namespace {
#include "grabber/dispmanx/DispmanxFrameGrabber.h" #include "grabber/dispmanx/DispmanxFrameGrabber.h"
DispmanxFrameGrabber::DispmanxFrameGrabber() DispmanxFrameGrabber::DispmanxFrameGrabber()
: Grabber("DISPMANXGRABBER") : Grabber("GRABBER-DISPMANX")
, _lib(nullptr) , _lib(nullptr)
, _vc_display(0) , _vc_display(0)
, _vc_resource(0) , _vc_resource(0)

View File

@ -3,15 +3,20 @@
DispmanxWrapper::DispmanxWrapper( int updateRate_Hz, DispmanxWrapper::DispmanxWrapper( int updateRate_Hz,
int pixelDecimation int pixelDecimation
) )
: GrabberWrapper("Dispmanx", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber()
{ {
if (available = _grabber.isAvailable()) if (_isAvailable)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
} }
DispmanxWrapper::DispmanxWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
bool DispmanxWrapper::open() bool DispmanxWrapper::open()
{ {
return _grabber.open(); return _grabber.open();

View File

@ -30,11 +30,11 @@ const char DISCOVERY_FILEPATTERN[] = "fb?";
// Local includes // Local includes
#include <grabber/framebuffer/FramebufferFrameGrabber.h> #include <grabber/framebuffer/FramebufferFrameGrabber.h>
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device) FramebufferFrameGrabber::FramebufferFrameGrabber(int deviceIdx)
: Grabber("FRAMEBUFFERGRABBER") : Grabber("GRABBER-FB")
, _fbDevice(device) , _fbfd (-1)
, _fbfd (-1)
{ {
_input = deviceIdx;
_useImageResampler = true; _useImageResampler = true;
} }
@ -105,6 +105,7 @@ bool FramebufferFrameGrabber::openDevice()
{ {
bool rc = true; bool rc = true;
_fbDevice = getPath();
/* Open the framebuffer device */ /* Open the framebuffer device */
_fbfd = ::open(QSTRING_CSTR(_fbDevice), O_RDONLY); _fbfd = ::open(QSTRING_CSTR(_fbDevice), O_RDONLY);
if (_fbfd < 0) if (_fbfd < 0)
@ -136,8 +137,7 @@ QSize FramebufferFrameGrabber::getScreenSize() const
QSize FramebufferFrameGrabber::getScreenSize(const QString& device) const QSize FramebufferFrameGrabber::getScreenSize(const QString& device) const
{ {
int width (0); QSize size;
int height(0);
int fbfd = ::open(QSTRING_CSTR(device), O_RDONLY); int fbfd = ::open(QSTRING_CSTR(device), O_RDONLY);
if (fbfd != -1) if (fbfd != -1)
@ -146,13 +146,13 @@ QSize FramebufferFrameGrabber::getScreenSize(const QString& device) const
int result = ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo); int result = ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo);
if (result == 0) if (result == 0)
{ {
width = static_cast<int>(vinfo.xres); size.setWidth(static_cast<int>(vinfo.xres));
height = static_cast<int>(vinfo.yres); size.setHeight(static_cast<int>(vinfo.yres));
DebugIf(verbose, _log, "FB device [%s] found with resolution: %dx%d", QSTRING_CSTR(device), width, height); DebugIf(verbose, _log, "FB device [%s] found with resolution: %dx%d", QSTRING_CSTR(device), size.width(), size.height());
} }
::close(fbfd); ::close(fbfd);
} }
return QSize(width, height); return size;
} }
bool FramebufferFrameGrabber::getScreenInfo() bool FramebufferFrameGrabber::getScreenInfo()

View File

@ -1,14 +1,20 @@
#include <grabber/framebuffer/FramebufferWrapper.h> #include <grabber/framebuffer/FramebufferWrapper.h>
FramebufferWrapper::FramebufferWrapper( int updateRate_Hz, FramebufferWrapper::FramebufferWrapper( int updateRate_Hz,
const QString & device, int deviceIdx,
int pixelDecimation) int pixelDecimation)
: GrabberWrapper("FrameBuffer", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(device) , _grabber(deviceIdx)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
FramebufferWrapper::FramebufferWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
void FramebufferWrapper::action() void FramebufferWrapper::action()
{ {
transferFrame(_grabber); transferFrame(_grabber);

View File

@ -16,7 +16,7 @@ const bool verbose = false;
} //End of constants } //End of constants
OsxFrameGrabber::OsxFrameGrabber(int display) OsxFrameGrabber::OsxFrameGrabber(int display)
: Grabber("OSXGRABBER") : Grabber("GRABBER-OSX")
, _screenIndex(display) , _screenIndex(display)
{ {
_isEnabled = false; _isEnabled = false;

View File

@ -4,12 +4,18 @@ OsxWrapper::OsxWrapper( int updateRate_Hz,
int display, int display,
int pixelDecimation int pixelDecimation
) )
: GrabberWrapper("OSX", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(display) , _grabber(display)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
OsxWrapper::OsxWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
void OsxWrapper::action() void OsxWrapper::action()
{ {
transferFrame(_grabber); transferFrame(_grabber);

View File

@ -20,8 +20,9 @@ const bool verbose = false;
} //End of constants } //End of constants
QtGrabber::QtGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom) QtGrabber::QtGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom)
: Grabber("QTGRABBER", cropLeft, cropRight, cropTop, cropBottom) : Grabber("GRABBER-QT", cropLeft, cropRight, cropTop, cropBottom)
, _display(display) , _display(display)
, _numberOfSDisplays(0)
, _screenWidth(0) , _screenWidth(0)
, _screenHeight(0) , _screenHeight(0)
, _src_x(0) , _src_x(0)
@ -32,7 +33,6 @@ QtGrabber::QtGrabber(int display, int cropLeft, int cropRight, int cropTop, int
, _screen(nullptr) , _screen(nullptr)
, _isVirtual(false) , _isVirtual(false)
{ {
_logger = Logger::getInstance("Qt");
_useImageResampler = false; _useImageResampler = false;
} }

View File

@ -5,12 +5,18 @@ QtWrapper::QtWrapper( int updateRate_Hz,
int pixelDecimation, int pixelDecimation,
int cropLeft, int cropRight, int cropTop, int cropBottom int cropLeft, int cropRight, int cropTop, int cropBottom
) )
: GrabberWrapper("Qt", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(display, cropLeft, cropRight, cropTop, cropBottom) , _grabber(display, cropLeft, cropRight, cropTop, cropBottom)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
QtWrapper::QtWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
bool QtWrapper::open() bool QtWrapper::open()
{ {
return _grabber.open(); return _grabber.open();

View File

@ -10,7 +10,7 @@ namespace {
} //End of constants } //End of constants
X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom) X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
: Grabber("X11GRABBER", cropLeft, cropRight, cropTop, cropBottom) : Grabber("GRABBER-X11", cropLeft, cropRight, cropTop, cropBottom)
, _x11Display(nullptr) , _x11Display(nullptr)
, _xImage(nullptr) , _xImage(nullptr)
, _pixmap(None) , _pixmap(None)
@ -28,8 +28,6 @@ X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
, _isWayland (false) , _isWayland (false)
, _logger{} , _logger{}
{ {
_logger = Logger::getInstance("X11");
_useImageResampler = false; _useImageResampler = false;
_imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage _imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage
memset(&_pictAttr, 0, sizeof(_pictAttr)); memset(&_pictAttr, 0, sizeof(_pictAttr));

View File

@ -3,13 +3,19 @@
X11Wrapper::X11Wrapper( int updateRate_Hz, X11Wrapper::X11Wrapper( int updateRate_Hz,
int pixelDecimation, int pixelDecimation,
int cropLeft, int cropRight, int cropTop, int cropBottom) int cropLeft, int cropRight, int cropTop, int cropBottom)
: GrabberWrapper("X11", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(cropLeft, cropRight, cropTop, cropBottom) , _grabber(cropLeft, cropRight, cropTop, cropBottom)
, _init(false) , _init(false)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
X11Wrapper::X11Wrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
X11Wrapper::~X11Wrapper() X11Wrapper::~X11Wrapper()
{ {
if ( _init ) if ( _init )

View File

@ -18,7 +18,7 @@ namespace {
#define DOUBLE_TO_FIXED(d) ((xcb_render_fixed_t) ((d) * 65536)) #define DOUBLE_TO_FIXED(d) ((xcb_render_fixed_t) ((d) * 65536))
XcbGrabber::XcbGrabber(int cropLeft, int cropRight, int cropTop, int cropBottom) XcbGrabber::XcbGrabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
: Grabber("XCBGRABBER", cropLeft, cropRight, cropTop, cropBottom) : Grabber("GRABBER-XCB", cropLeft, cropRight, cropTop, cropBottom)
, _connection{} , _connection{}
, _screen{} , _screen{}
, _pixmap{} , _pixmap{}
@ -41,8 +41,6 @@ XcbGrabber::XcbGrabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
, _shmData{} , _shmData{}
, _XcbRandREventBase{-1} , _XcbRandREventBase{-1}
{ {
_logger = Logger::getInstance("XCB");
// cropping is performed by XcbRender, XcbShmGetImage or XcbGetImage // cropping is performed by XcbRender, XcbShmGetImage or XcbGetImage
_useImageResampler = false; _useImageResampler = false;
_imageResampler.setCropping(0, 0, 0, 0); _imageResampler.setCropping(0, 0, 0, 0);

View File

@ -3,13 +3,19 @@
XcbWrapper::XcbWrapper( int updateRate_Hz, XcbWrapper::XcbWrapper( int updateRate_Hz,
int pixelDecimation, int pixelDecimation,
int cropLeft, int cropRight, int cropTop, int cropBottom) int cropLeft, int cropRight, int cropTop, int cropBottom)
: GrabberWrapper("Xcb", &_grabber, updateRate_Hz) : GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(cropLeft, cropRight, cropTop, cropBottom) , _grabber(cropLeft, cropRight, cropTop, cropBottom)
, _init(false) , _init(false)
{ {
_grabber.setPixelDecimation(pixelDecimation); _grabber.setPixelDecimation(pixelDecimation);
} }
XcbWrapper::XcbWrapper(const QJsonDocument& grabberConfig)
: GrabberWrapper(GRABBERTYPE, &_grabber)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
XcbWrapper::~XcbWrapper() XcbWrapper::~XcbWrapper()
{ {
if ( _init ) if ( _init )

View File

@ -18,6 +18,7 @@ Grabber::Grabber(const QString& grabberName, int cropLeft, int cropRight, int cr
, _cropRight(0) , _cropRight(0)
, _cropTop(0) , _cropTop(0)
, _cropBottom(0) , _cropBottom(0)
, _isAvailable(true)
, _isEnabled(true) , _isEnabled(true)
, _isDeviceInError(false) , _isDeviceInError(false)
{ {

View File

@ -26,10 +26,11 @@ bool GrabberWrapper::GLOBAL_GRABBER_AUDIO_ENABLE = false;
GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, int updateRate_Hz) GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, int updateRate_Hz)
: _grabberName(grabberName) : _grabberName(grabberName)
, _log(Logger::getInstance(grabberName.toUpper())) , _log(Logger::getInstance(("Grabber-" + grabberName).toUpper()))
, _timer(nullptr) , _timer(nullptr)
, _updateInterval_ms(1000/updateRate_Hz) , _updateInterval_ms(1000/updateRate_Hz)
, _ggrabber(ggrabber) , _ggrabber(ggrabber)
, _isAvailable(true)
{ {
GrabberWrapper::instance = this; GrabberWrapper::instance = this;
@ -58,7 +59,7 @@ GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, i
// listen for source requests // listen for source requests
connect(GlobalSignals::getInstance(), &GlobalSignals::requestSource, this, &GrabberWrapper::handleSourceRequest); connect(GlobalSignals::getInstance(), &GlobalSignals::requestSource, this, &GrabberWrapper::handleSourceRequest);
QObject::connect(EventHandler::getInstance(), &EventHandler::signalEvent, this, &GrabberWrapper::handleEvent); QObject::connect(EventHandler::getInstance().data(), &EventHandler::signalEvent, this, &GrabberWrapper::handleEvent);
} }
GrabberWrapper::~GrabberWrapper() GrabberWrapper::~GrabberWrapper()
@ -75,7 +76,7 @@ bool GrabberWrapper::start()
if (!_timer->isActive()) if (!_timer->isActive())
{ {
// Start the timer with the pre configured interval // Start the timer with the pre configured interval
Debug(_log,"Grabber start()"); Info(_log,"%s grabber started", QSTRING_CSTR(getName()));
_timer->start(); _timer->start();
} }
@ -89,7 +90,7 @@ void GrabberWrapper::stop()
if (_timer->isActive()) if (_timer->isActive())
{ {
// Stop the timer, effectively stopping the process // Stop the timer, effectively stopping the process
Debug(_log,"Grabber stop()"); Info(_log,"%s grabber stopped", QSTRING_CSTR(getName()));
_timer->stop(); _timer->stop();
} }
} }

View File

@ -247,7 +247,7 @@ void HyperionIManager::handleFinished()
Hyperion* hyperion = qobject_cast<Hyperion*>(sender()); Hyperion* hyperion = qobject_cast<Hyperion*>(sender());
quint8 instance = hyperion->getInstanceIndex(); quint8 instance = hyperion->getInstanceIndex();
Info(_log,"Hyperion instance '%s' has been stopped", QSTRING_CSTR(_instanceTable->getNamebyIndex(instance))); Info(_log,"Hyperion instance '%s' stopped", QSTRING_CSTR(_instanceTable->getNamebyIndex(instance)));
_runningInstances.remove(instance); _runningInstances.remove(instance);
hyperion->thread()->deleteLater(); hyperion->thread()->deleteLater();

View File

@ -29,11 +29,12 @@ JsonServer::JsonServer(const QJsonDocument& config)
, _netOrigin(NetOrigin::getInstance()) , _netOrigin(NetOrigin::getInstance())
, _config(config) , _config(config)
{ {
Debug(_log, "Created instance"); Debug(_log, "JSON API server created");
} }
JsonServer::~JsonServer() JsonServer::~JsonServer()
{ {
stop();
qDeleteAll(_openConnections); qDeleteAll(_openConnections);
_openConnections.clear(); _openConnections.clear();
} }
@ -66,10 +67,12 @@ void JsonServer::start()
void JsonServer::stop() void JsonServer::stop()
{ {
if(!_server->isListening()) if(!_server->isListening())
{
return; return;
}
_server->close(); _server->close();
Info(_log, "Stopped"); Info(_log, "JSON-Server stopped");
} }
void JsonServer::handleSettingsUpdate(settings::type type, const QJsonDocument& config) void JsonServer::handleSettingsUpdate(settings::type type, const QJsonDocument& config)

View File

@ -100,7 +100,7 @@ void LedDevice::stop()
this->stopEnableAttemptsTimer(); this->stopEnableAttemptsTimer();
this->disable(); this->disable();
this->stopRefreshTimer(); this->stopRefreshTimer();
Info(_log, " Stopped LedDevice '%s'", QSTRING_CSTR(_activeDeviceType)); Info(_log, "Stopped LedDevice '%s'", QSTRING_CSTR(_activeDeviceType));
} }
int LedDevice::open() int LedDevice::open()

View File

@ -53,7 +53,7 @@ LedDeviceCololight::LedDeviceCololight(const QJsonObject& deviceConfig)
, _sequenceNumber(1) , _sequenceNumber(1)
{ {
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType)));
#endif #endif
@ -679,7 +679,7 @@ QJsonObject LedDeviceCololight::discover(const QJsonObject& /*params*/)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QString discoveryMethod("mDNS"); QString discoveryMethod("mDNS");
deviceList = MdnsBrowser::getInstance().getServicesDiscoveredJson( deviceList = MdnsBrowser::getInstance().data()->getServicesDiscoveredJson(
MdnsServiceRegister::getServiceType(_activeDeviceType), MdnsServiceRegister::getServiceType(_activeDeviceType),
MdnsServiceRegister::getServiceNameFilter(_activeDeviceType), MdnsServiceRegister::getServiceNameFilter(_activeDeviceType),
DEFAULT_DISCOVER_TIMEOUT DEFAULT_DISCOVER_TIMEOUT

View File

@ -111,7 +111,7 @@ LedDeviceNanoleaf::LedDeviceNanoleaf(const QJsonObject& deviceConfig)
, _panelLedCount(0) , _panelLedCount(0)
{ {
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType)));
#endif #endif
} }
@ -461,7 +461,7 @@ QJsonObject LedDeviceNanoleaf::discover(const QJsonObject& /*params*/)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QString discoveryMethod("mDNS"); QString discoveryMethod("mDNS");
deviceList = MdnsBrowser::getInstance().getServicesDiscoveredJson( deviceList = MdnsBrowser::getInstance().data()->getServicesDiscoveredJson(
MdnsServiceRegister::getServiceType(_activeDeviceType), MdnsServiceRegister::getServiceType(_activeDeviceType),
MdnsServiceRegister::getServiceNameFilter(_activeDeviceType), MdnsServiceRegister::getServiceNameFilter(_activeDeviceType),
DEFAULT_DISCOVER_TIMEOUT DEFAULT_DISCOVER_TIMEOUT

View File

@ -349,7 +349,7 @@ LedDevicePhilipsHueBridge::LedDevicePhilipsHueBridge(const QJsonObject &deviceCo
, _isHueEntertainmentReady(false) , _isHueEntertainmentReady(false)
{ {
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType)));
#endif #endif
} }
@ -1294,7 +1294,7 @@ QJsonObject LedDevicePhilipsHueBridge::discover(const QJsonObject& /*params*/)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QString discoveryMethod("mDNS"); QString discoveryMethod("mDNS");
deviceList = MdnsBrowser::getInstance().getServicesDiscoveredJson( deviceList = MdnsBrowser::getInstance().data()->getServicesDiscoveredJson(
MdnsServiceRegister::getServiceType(_activeDeviceType), MdnsServiceRegister::getServiceType(_activeDeviceType),
MdnsServiceRegister::getServiceNameFilter(_activeDeviceType), MdnsServiceRegister::getServiceNameFilter(_activeDeviceType),
DEFAULT_DISCOVER_TIMEOUT DEFAULT_DISCOVER_TIMEOUT

View File

@ -99,7 +99,7 @@ LedDeviceWled::LedDeviceWled(const QJsonObject &deviceConfig)
,_isStreamToSegment(false) ,_isStreamToSegment(false)
{ {
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType)));
#endif #endif
} }
@ -547,7 +547,7 @@ QJsonObject LedDeviceWled::discover(const QJsonObject& /*params*/)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QString discoveryMethod("mDNS"); QString discoveryMethod("mDNS");
deviceList = MdnsBrowser::getInstance().getServicesDiscoveredJson( deviceList = MdnsBrowser::getInstance().data()->getServicesDiscoveredJson(
MdnsServiceRegister::getServiceType(_activeDeviceType), MdnsServiceRegister::getServiceType(_activeDeviceType),
MdnsServiceRegister::getServiceNameFilter(_activeDeviceType), MdnsServiceRegister::getServiceNameFilter(_activeDeviceType),
DEFAULT_DISCOVER_TIMEOUT DEFAULT_DISCOVER_TIMEOUT

View File

@ -1006,7 +1006,7 @@ LedDeviceYeelight::LedDeviceYeelight(const QJsonObject &deviceConfig)
,_musicModeServerPort(-1) ,_musicModeServerPort(-1)
{ {
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QMetaObject::invokeMethod(&MdnsBrowser::getInstance(), "browseForServiceType", QMetaObject::invokeMethod(MdnsBrowser::getInstance().data(), "browseForServiceType",
Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType))); Qt::QueuedConnection, Q_ARG(QByteArray, MdnsServiceRegister::getServiceType(_activeDeviceType)));
#endif #endif
} }
@ -1391,7 +1391,7 @@ QJsonObject LedDeviceYeelight::discover(const QJsonObject& /*params*/)
#ifdef ENABLE_MDNS #ifdef ENABLE_MDNS
QString discoveryMethod("mDNS"); QString discoveryMethod("mDNS");
deviceList = MdnsBrowser::getInstance().getServicesDiscoveredJson( deviceList = MdnsBrowser::getInstance().data()->getServicesDiscoveredJson(
MdnsServiceRegister::getServiceType(_activeDeviceType), MdnsServiceRegister::getServiceType(_activeDeviceType),
MdnsServiceRegister::getServiceNameFilter(_activeDeviceType), MdnsServiceRegister::getServiceNameFilter(_activeDeviceType),
DEFAULT_DISCOVER_TIMEOUT DEFAULT_DISCOVER_TIMEOUT

View File

@ -21,6 +21,8 @@ namespace {
const int SERVICE_LOOKUP_RETRIES = 5; const int SERVICE_LOOKUP_RETRIES = 5;
} // End of constants } // End of constants
QScopedPointer<MdnsBrowser> MdnsBrowser::instance;
MdnsBrowser::MdnsBrowser(QObject* parent) MdnsBrowser::MdnsBrowser(QObject* parent)
: QObject(parent) : QObject(parent)
, _log(Logger::getInstance("MDNS")) , _log(Logger::getInstance("MDNS"))
@ -33,6 +35,16 @@ MdnsBrowser::~MdnsBrowser()
_browsedServiceTypes.clear(); _browsedServiceTypes.clear();
} }
QScopedPointer<MdnsBrowser>& MdnsBrowser::getInstance()
{
if (!instance)
{
instance.reset(new MdnsBrowser());
}
return instance;
}
void MdnsBrowser::browseForServiceType(const QByteArray& serviceType) void MdnsBrowser::browseForServiceType(const QByteArray& serviceType)
{ {
if (!_browsedServiceTypes.contains(serviceType)) if (!_browsedServiceTypes.contains(serviceType))
@ -163,8 +175,8 @@ bool MdnsBrowser::resolveAddress(Logger* log, const QString& hostname, QHostAddr
QEventLoop loop; QEventLoop loop;
QTimer timer; QTimer timer;
QObject::connect(&MdnsBrowser::getInstance(), &MdnsBrowser::addressResolved, &loop, &QEventLoop::quit); QObject::connect(MdnsBrowser::getInstance().data(), &MdnsBrowser::addressResolved, &loop, &QEventLoop::quit);
weakConnect(&MdnsBrowser::getInstance(), &MdnsBrowser::addressResolved, weakConnect(MdnsBrowser::getInstance().data(), &MdnsBrowser::addressResolved,
[&hostAddress, hostname, log](const QHostAddress& resolvedAddress) { [&hostAddress, hostname, log](const QHostAddress& resolvedAddress) {
DebugIf(verboseBrowser, log, "Resolver resolved hostname [%s] to address [%s], Thread: %s", QSTRING_CSTR(hostname), QSTRING_CSTR(resolvedAddress.toString()), QSTRING_CSTR(QThread::currentThread()->objectName())); DebugIf(verboseBrowser, log, "Resolver resolved hostname [%s] to address [%s], Thread: %s", QSTRING_CSTR(hostname), QSTRING_CSTR(resolvedAddress.toString()), QSTRING_CSTR(QThread::currentThread()->objectName()));
hostAddress = resolvedAddress; hostAddress = resolvedAddress;
@ -182,7 +194,7 @@ bool MdnsBrowser::resolveAddress(Logger* log, const QString& hostname, QHostAddr
} }
else else
{ {
QObject::disconnect(&MdnsBrowser::getInstance(), &MdnsBrowser::addressResolved, nullptr, nullptr); QObject::disconnect(MdnsBrowser::getInstance().data(), &MdnsBrowser::addressResolved, nullptr, nullptr);
Error(log, "Resolved mDNS hostname [%s] timed out", QSTRING_CSTR(hostname)); Error(log, "Resolved mDNS hostname [%s] timed out", QSTRING_CSTR(hostname));
} }
} }

View File

@ -34,6 +34,7 @@ void MdnsProvider::init()
MdnsProvider::~MdnsProvider() MdnsProvider::~MdnsProvider()
{ {
_providedServiceTypes.clear(); _providedServiceTypes.clear();
Info(_log, "mDNS info service stopped");
} }
void MdnsProvider::publishService(const QString& serviceType, quint16 servicePort, const QByteArray& serviceName) void MdnsProvider::publishService(const QString& serviceType, quint16 servicePort, const QByteArray& serviceName)

View File

@ -20,7 +20,6 @@ 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) : SSDPServer(parent)
, _webserver(webserver) , _webserver(webserver)
, _localAddress()
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
, _NCA(nullptr) , _NCA(nullptr)
#endif #endif
@ -30,6 +29,8 @@ SSDPHandler::SSDPHandler(WebServer* webserver, quint16 flatBufPort, quint16 prot
setJsonServerPort(jsonServerPort); setJsonServerPort(jsonServerPort);
setSSLServerPort(sslPort); setSSLServerPort(sslPort);
setHyperionName(name); setHyperionName(name);
Debug(_log, "SSDP info service created");
} }
SSDPHandler::~SSDPHandler() SSDPHandler::~SSDPHandler()
@ -87,6 +88,7 @@ void SSDPHandler::stopServer()
{ {
sendAnnounceList(false); sendAnnounceList(false);
SSDPServer::stop(); SSDPServer::stop();
Info(_log, "SSDP info service stopped");
} }
void SSDPHandler::handleSettingsUpdate(settings::type type, const QJsonDocument& config) void SSDPHandler::handleSettingsUpdate(settings::type type, const QJsonDocument& config)

View File

@ -53,7 +53,7 @@ Logger* Logger::getInstance(const QString & name, const QString & subName, Logge
{ {
log = new Logger(name, subName, minLevel); log = new Logger(name, subName, minLevel);
LoggerMap.insert(name + subName, log); LoggerMap.insert(name + subName, log);
connect(log, &Logger::newLogMessage, LoggerManager::getInstance(), &LoggerManager::handleNewLogMessage); connect(log, &Logger::newLogMessage, LoggerManager::getInstance().data(), &LoggerManager::handleNewLogMessage);
} }
return log; return log;
@ -151,9 +151,8 @@ void Logger::write(const Logger::T_LOG_MESSAGE & message)
name.resize(MAX_IDENTIFICATION_LENGTH, ' '); name.resize(MAX_IDENTIFICATION_LENGTH, ' ');
const QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(message.utime); const QDateTime timestamp = QDateTime::fromMSecsSinceEpoch(message.utime);
std::cout << QString("%1 %2 : <%3> %4%5") std::cout << QString("%1 %2 : <%3> %4%5")
.arg(timestamp.toString("yyyy-MM-ddThh:mm:ss.zzz")) .arg(timestamp.toString(Qt::ISODateWithMs))
.arg(name) .arg(name)
.arg(LogLevelStrings[message.level]) .arg(LogLevelStrings[message.level])
.arg(location) .arg(location)
@ -169,8 +168,10 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
Logger::LogLevel globalLevel = static_cast<Logger::LogLevel>(int(GLOBAL_MIN_LOG_LEVEL)); Logger::LogLevel globalLevel = static_cast<Logger::LogLevel>(int(GLOBAL_MIN_LOG_LEVEL));
if ( (globalLevel == Logger::UNSET && level < _minLevel) // no global level, use level from logger if ( (globalLevel == Logger::UNSET && level < _minLevel) // no global level, use level from logger
|| (globalLevel > Logger::UNSET && level < globalLevel) ) // global level set, use global level || (globalLevel > Logger::UNSET && level < globalLevel) ) // global level set, use global level
{
return; return;
}
const size_t max_msg_length = 1024; const size_t max_msg_length = 1024;
char msg[max_msg_length]; char msg[max_msg_length];
@ -188,7 +189,9 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
write(repMsg); write(repMsg);
#ifndef _WIN32 #ifndef _WIN32
if ( _syslogEnabled && repMsg.level >= Logger::WARNING ) if ( _syslogEnabled && repMsg.level >= Logger::WARNING )
{
syslog (LogLevelSysLog[repMsg.level], "Previous line repeats %d times", RepeatCount.localData()); syslog (LogLevelSysLog[repMsg.level], "Previous line repeats %d times", RepeatCount.localData());
}
#endif #endif
RepeatCount.setLocalData(0); RepeatCount.setLocalData(0);
@ -201,14 +204,20 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
RepeatMessage.localData().line == line) RepeatMessage.localData().line == line)
{ {
if (RepeatCount.localData() >= MaxRepeatCountSize) if (RepeatCount.localData() >= MaxRepeatCountSize)
{
repeatedSummary(); repeatedSummary();
}
else else
{
RepeatCount.setLocalData(RepeatCount.localData() + 1); RepeatCount.setLocalData(RepeatCount.localData() + 1);
}
} }
else else
{ {
if (RepeatCount.localData()) if (RepeatCount.localData())
{
repeatedSummary(); repeatedSummary();
}
Logger::T_LOG_MESSAGE logMsg; Logger::T_LOG_MESSAGE logMsg;
@ -225,12 +234,16 @@ void Logger::Message(LogLevel level, const char* sourceFile, const char* func, u
write(logMsg); write(logMsg);
#ifndef _WIN32 #ifndef _WIN32
if ( _syslogEnabled && level >= Logger::WARNING ) if ( _syslogEnabled && level >= Logger::WARNING )
{
syslog (LogLevelSysLog[level], "%s", msg); syslog (LogLevelSysLog[level], "%s", msg);
}
#endif #endif
RepeatMessage.setLocalData(logMsg); RepeatMessage.setLocalData(logMsg);
} }
} }
QScopedPointer<LoggerManager> LoggerManager::instance;
LoggerManager::LoggerManager() LoggerManager::LoggerManager()
: QObject() : QObject()
, _loggerMaxMsgBufferSize(MAX_LOG_MSG_BUFFERED) , _loggerMaxMsgBufferSize(MAX_LOG_MSG_BUFFERED)
@ -238,6 +251,14 @@ LoggerManager::LoggerManager()
_logMessageBuffer.reserve(_loggerMaxMsgBufferSize); _logMessageBuffer.reserve(_loggerMaxMsgBufferSize);
} }
LoggerManager::~LoggerManager()
{
// delete components
Logger::deleteInstance();
_logMessageBuffer.clear();
}
QJsonArray LoggerManager::getLogMessageBuffer(Logger::LogLevel filter) const QJsonArray LoggerManager::getLogMessageBuffer(Logger::LogLevel filter) const
{ {
QJsonArray messageArray; QJsonArray messageArray;
@ -274,8 +295,12 @@ void LoggerManager::handleNewLogMessage(const Logger::T_LOG_MESSAGE & msg)
emit newLogMessage(msg); emit newLogMessage(msg);
} }
LoggerManager* LoggerManager::getInstance() QScopedPointer<LoggerManager>& LoggerManager::getInstance()
{ {
static LoggerManager instance; if (!instance)
return &instance; {
instance.reset(new LoggerManager());
}
return instance;
} }

View File

@ -31,7 +31,6 @@ WebServer::WebServer(const QJsonDocument& config, bool useSsl, QObject* parent)
, _useSsl(useSsl) , _useSsl(useSsl)
, _log(Logger::getInstance("WEBSERVER")) , _log(Logger::getInstance("WEBSERVER"))
, _port(WEBSERVER_DEFAULT_PORT) , _port(WEBSERVER_DEFAULT_PORT)
, _server()
{ {
} }
@ -43,7 +42,7 @@ WebServer::~WebServer()
void WebServer::initServer() void WebServer::initServer()
{ {
Debug(_log, "Initialize %s-Webserver", _useSsl ? "https" : "http"); Debug(_log, "Initialize %s-Webserver", _useSsl ? "https" : "http");
_server = new QtHttpServer(this); _server.reset(new QtHttpServer(this));
_server->setServerName(QStringLiteral("Hyperion %1-Webserver").arg(_useSsl ? "https" : "http")); _server->setServerName(QStringLiteral("Hyperion %1-Webserver").arg(_useSsl ? "https" : "http"));
if (_useSsl) if (_useSsl)
@ -51,13 +50,13 @@ void WebServer::initServer()
_server->setUseSecure(); _server->setUseSecure();
} }
connect(_server, &QtHttpServer::started, this, &WebServer::onServerStarted); connect(_server.get(), &QtHttpServer::started, this, &WebServer::onServerStarted);
connect(_server, &QtHttpServer::stopped, this, &WebServer::onServerStopped); connect(_server.get(), &QtHttpServer::stopped, this, &WebServer::onServerStopped);
connect(_server, &QtHttpServer::error, this, &WebServer::onServerError); connect(_server.get(), &QtHttpServer::error, this, &WebServer::onServerError);
// create StaticFileServing // create StaticFileServing
_staticFileServing = new StaticFileServing(this); _staticFileServing = new StaticFileServing(this);
connect(_server, &QtHttpServer::requestNeedsReply, _staticFileServing, &StaticFileServing::onRequestNeedsReply); connect(_server.get(), &QtHttpServer::requestNeedsReply, _staticFileServing, &StaticFileServing::onRequestNeedsReply);
// init // init
handleSettingsUpdate(settings::WEBSERVER, _config); handleSettingsUpdate(settings::WEBSERVER, _config);
@ -83,11 +82,11 @@ void WebServer::onServerStarted(quint16 port)
void WebServer::onServerStopped() void WebServer::onServerStopped()
{ {
Info(_log, "Stopped %s", _server->getServerName().toStdString().c_str()); Info(_log, "%s stopped", _server->getServerName().toStdString().c_str());
emit stateChange(false); emit stateChange(false);
} }
void WebServer::onServerError(QString msg) void WebServer::onServerError(const QString& msg)
{ {
Error(_log, "%s", msg.toStdString().c_str()); Error(_log, "%s", msg.toStdString().c_str());
} }
@ -112,7 +111,9 @@ void WebServer::handleSettingsUpdate(settings::type type, const QJsonDocument& c
} }
} }
else else
{
_baseUrl = WEBSERVER_DEFAULT_PATH; _baseUrl = WEBSERVER_DEFAULT_PATH;
}
Debug(_log, "Set document root to: %s", _baseUrl.toUtf8().constData()); Debug(_log, "Set document root to: %s", _baseUrl.toUtf8().constData());
_staticFileServing->setBaseUrl(_baseUrl); _staticFileServing->setBaseUrl(_baseUrl);
@ -127,7 +128,9 @@ void WebServer::handleSettingsUpdate(settings::type type, const QJsonDocument& c
// eval if the port is available, will be incremented if not // eval if the port is available, will be incremented if not
if (!_server->isListening()) if (!_server->isListening())
{
NetUtils::portAvailable(_port, _log); NetUtils::portAvailable(_port, _log);
}
// on ssl we want .key .cert and probably key password // on ssl we want .key .cert and probably key password
if (_useSsl) if (_useSsl)
@ -149,7 +152,9 @@ void WebServer::handleSettingsUpdate(settings::type type, const QJsonDocument& c
} }
} }
else else
{
keyPath = WEBSERVER_DEFAULT_KEY_PATH; keyPath = WEBSERVER_DEFAULT_KEY_PATH;
}
// check crtPath // check crtPath
if ((crtPath != WEBSERVER_DEFAULT_CRT_PATH) && !crtPath.trimmed().isEmpty()) if ((crtPath != WEBSERVER_DEFAULT_CRT_PATH) && !crtPath.trimmed().isEmpty())
@ -162,7 +167,9 @@ void WebServer::handleSettingsUpdate(settings::type type, const QJsonDocument& c
} }
} }
else else
{
crtPath = WEBSERVER_DEFAULT_CRT_PATH; crtPath = WEBSERVER_DEFAULT_CRT_PATH;
}
// load and verify crt // load and verify crt
QFile cfile(crtPath); QFile cfile(crtPath);
@ -174,9 +181,13 @@ void WebServer::handleSettingsUpdate(settings::type type, const QJsonDocument& c
// Filter for valid certs // Filter for valid certs
for (const auto& entry : cList) { for (const auto& entry : cList) {
if (!entry.isNull() && QDateTime::currentDateTime().daysTo(entry.expiryDate()) > 0) if (!entry.isNull() && QDateTime::currentDateTime().daysTo(entry.expiryDate()) > 0)
{
validList.append(entry); validList.append(entry);
}
else else
{
Error(_log, "The provided SSL certificate is invalid/not supported/reached expiry date ('%s')", crtPath.toUtf8().constData()); Error(_log, "The provided SSL certificate is invalid/not supported/reached expiry date ('%s')", crtPath.toUtf8().constData());
}
} }
if (!validList.isEmpty()) { if (!validList.isEmpty()) {

View File

@ -23,9 +23,11 @@ WebSocketClient::WebSocketClient(QtHttpRequest* request, QTcpSocket* sock, bool
const QString client = request->getClientInfo().clientAddress.toString(); const QString client = request->getClientInfo().clientAddress.toString();
// Json processor // Json processor
_jsonAPI = new JsonAPI(client, _log, localConnection, this); _jsonAPI.reset(new JsonAPI(client, _log, localConnection, this));
connect(_jsonAPI, &JsonAPI::callbackMessage, this, &WebSocketClient::sendMessage); connect(_jsonAPI.get(), &JsonAPI::callbackMessage, this, &WebSocketClient::sendMessage);
connect(_jsonAPI, &JsonAPI::forceClose, this,[this]() { this->sendClose(CLOSECODE::NORMAL); }); connect(_jsonAPI.get(), &JsonAPI::forceClose, this,[this]() { this->sendClose(CLOSECODE::NORMAL); });
connect(this, &WebSocketClient::handleMessage, _jsonAPI.get(), &JsonAPI::handleMessage);
Debug(_log, "New connection from %s", QSTRING_CSTR(client)); Debug(_log, "New connection from %s", QSTRING_CSTR(client));
@ -129,7 +131,7 @@ void WebSocketClient::handleWebSocketFrame()
if (_frameOpCode == OPCODE::TEXT) if (_frameOpCode == OPCODE::TEXT)
{ {
_jsonAPI->handleMessage(QString(_wsReceiveBuffer)); emit handleMessage(QString(_wsReceiveBuffer),"");
} }
else else
{ {

View File

@ -2,6 +2,9 @@
#include <utils/Logger.h> #include <utils/Logger.h>
#include "WebSocketUtils.h" #include "WebSocketUtils.h"
#include <api/JsonAPI.h>
#include <QScopedPointer>
class QTcpSocket; class QTcpSocket;
@ -28,7 +31,7 @@ private:
QTcpSocket* _socket; QTcpSocket* _socket;
Logger* _log; Logger* _log;
Hyperion* _hyperion; Hyperion* _hyperion;
JsonAPI* _jsonAPI; QScopedPointer<JsonAPI> _jsonAPI;
void getWsFrameHeader(WebSocketHeader* header); void getWsFrameHeader(WebSocketHeader* header);
void sendClose(int status, const QString& reason = ""); void sendClose(int status, const QString& reason = "");
@ -73,4 +76,7 @@ private:
private slots: private slots:
void handleWebSocketFrame(); void handleWebSocketFrame();
qint64 sendMessage(QJsonObject obj); qint64 sendMessage(QJsonObject obj);
signals:
void handleMessage(const QString &message, const QString &httpAuthHeader);
}; };

View File

@ -2,13 +2,13 @@
#include "FramebufferWrapper.h" #include "FramebufferWrapper.h"
FramebufferWrapper::FramebufferWrapper( int updateRate_Hz, FramebufferWrapper::FramebufferWrapper( int updateRate_Hz,
const QString & device, int deviceIdx,
int pixelDecimation, int pixelDecimation,
int cropLeft, int cropRight, int cropLeft, int cropRight,
int cropTop, int cropBottom int cropTop, int cropBottom
) : ) :
_timer(this), _timer(this),
_grabber(device) _grabber(deviceIdx)
{ {
_grabber.setFramerate(updateRate_Hz); _grabber.setFramerate(updateRate_Hz);
_grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom); _grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom);

View File

@ -12,7 +12,7 @@ class FramebufferWrapper : public QObject
public: public:
FramebufferWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ, FramebufferWrapper( int updateRate_Hz=GrabberWrapper::DEFAULT_RATE_HZ,
const QString & device = "/dev/fb0", int deviceIdx = 0,
int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION, int pixelDecimation=GrabberWrapper::DEFAULT_PIXELDECIMATION,
int cropLeft=0, int cropRight=0, int cropLeft=0, int cropRight=0,
int cropTop=0, int cropBottom=0 int cropTop=0, int cropBottom=0

View File

@ -50,7 +50,7 @@ int main(int argc, char ** argv)
// create the option parser and initialize all parameters // create the option parser and initialize all parameters
Parser parser("FrameBuffer capture application for Hyperion. Will automatically search a Hyperion server if -a option isn't used. Please note that if you have more than one server running it's more or less random which one will be used."); Parser parser("FrameBuffer capture application for Hyperion. Will automatically search a Hyperion server if -a option isn't used. Please note that if you have more than one server running it's more or less random which one will be used.");
Option & argDevice = parser.add<Option> ('d', "device", "Set the framebuffer device [default: %1]", "/dev/fb0"); IntOption & argDeviceIdx = parser.add<IntOption> ('d', "deviceIdx", "Set the framebuffer device index [default: %1]", 0);
IntOption & argFps = parser.add<IntOption> ('f', "framerate", QString("Capture frame rate. Range %1-%2fps").arg(GrabberWrapper::DEFAULT_MIN_GRAB_RATE_HZ).arg(GrabberWrapper::DEFAULT_MAX_GRAB_RATE_HZ), QString::number(GrabberWrapper::DEFAULT_RATE_HZ), GrabberWrapper::DEFAULT_MIN_GRAB_RATE_HZ, GrabberWrapper::DEFAULT_MAX_GRAB_RATE_HZ); IntOption & argFps = parser.add<IntOption> ('f', "framerate", QString("Capture frame rate. Range %1-%2fps").arg(GrabberWrapper::DEFAULT_MIN_GRAB_RATE_HZ).arg(GrabberWrapper::DEFAULT_MAX_GRAB_RATE_HZ), QString::number(GrabberWrapper::DEFAULT_RATE_HZ), GrabberWrapper::DEFAULT_MIN_GRAB_RATE_HZ, GrabberWrapper::DEFAULT_MAX_GRAB_RATE_HZ);
IntOption & argSizeDecimation = parser.add<IntOption> ('s', "size-decimator", "Decimation factor for the output image size [default=%1]", QString::number(GrabberWrapper::DEFAULT_PIXELDECIMATION), 1); IntOption & argSizeDecimation = parser.add<IntOption> ('s', "size-decimator", "Decimation factor for the output image size [default=%1]", QString::number(GrabberWrapper::DEFAULT_PIXELDECIMATION), 1);
@ -88,7 +88,7 @@ int main(int argc, char ** argv)
FramebufferWrapper fbWrapper( FramebufferWrapper fbWrapper(
argFps.getInt(parser), argFps.getInt(parser),
argDevice.value(parser), argDeviceIdx.getInt(parser),
argSizeDecimation.getInt(parser), argSizeDecimation.getInt(parser),
argCropLeft.getInt(parser), argCropLeft.getInt(parser),
argCropRight.getInt(parser), argCropRight.getInt(parser),

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,12 @@
#pragma once #ifndef HYPERIOND_H
#define HYPERIOND_H
#include <memory>
#include <QApplication> #include <QApplication>
#include <QObject> #include <QObject>
#include <QJsonObject> #include <QJsonObject>
#include <QScopedPointer>
#include <hyperion/HyperionIManager.h> #include <hyperion/HyperionIManager.h>
@ -110,7 +114,7 @@ public:
/// ///
/// @brief Get webserver pointer (systray) /// @brief Get webserver pointer (systray)
/// ///
WebServer *getWebServerInstance() { return _webserver; } WebServer *getWebServerInstance() { return _webserver.data(); }
/// ///
/// @brief Get the current videoMode /// @brief Get the current videoMode
@ -122,14 +126,11 @@ public:
/// ///
QJsonDocument getSetting(settings::type type) const; QJsonDocument getSetting(settings::type type) const;
void startNetworkServices();
void startEventServices();
static HyperionDaemon* getInstance() { return daemon; } static HyperionDaemon* getInstance() { return daemon; }
static HyperionDaemon* daemon; static HyperionDaemon* daemon;
public slots: public slots:
void freeObjects(); void stoppServices();
signals: signals:
/////////////////////////////////////// ///////////////////////////////////////
@ -176,67 +177,100 @@ private slots:
void handleInstanceStateChange(InstanceState state, quint8 instance); void handleInstanceStateChange(InstanceState state, quint8 instance);
private: private:
void createGrabberDispmanx(const QJsonObject & grabberConfig);
void createGrabberAmlogic(const QJsonObject & grabberConfig);
void createGrabberFramebuffer(const QJsonObject & grabberConfig);
void createGrabberOsx(const QJsonObject & grabberConfig);
void createGrabberX11(const QJsonObject & grabberConfig);
void createGrabberXcb(const QJsonObject & grabberConfig);
void createGrabberQt(const QJsonObject & grabberConfig);
void createGrabberDx(const QJsonObject & grabberConfig);
void createGrabberAudio(const QJsonObject & grabberConfig);
void startCecHandler(); void createNetworkServices();
void stopCecHandler(); void startNetworkServices();
void stopNetworkServices();
void startEventServices();
void stopEventServices();
void startGrabberServices();
void stopGrabberServices();
void updateScreenGrabbers(const QJsonDocument& grabberConfig);
void updateVideoGrabbers(const QJsonObject& grabberConfig);
void updateAudioGrabbers(const QJsonObject& grabberConfig);
QString evalScreenGrabberType();
template<typename GrabberType>
void startGrabber(QScopedPointer<GrabberWrapper>& sharedGrabber, const QJsonDocument& grabberConfig, bool enableGrabber = true) {
QString typeName = GrabberType::GRABBERTYPE;
if (!enableGrabber)
{
Debug(_log, "The %s grabber is not enabled on this platform", QSTRING_CSTR(typeName));
sharedGrabber.reset();
return;
}
std::unique_ptr<GrabberType> grabber = std::make_unique<GrabberType>(grabberConfig);
if (!grabber)
{
Error(_log, "Failed to cast grabber type %s to GrabberWrapper", QSTRING_CSTR(typeName));
}
else
{
if (!grabber->isAvailable())
{
Debug(_log, "The %s grabber is not available on this platform", QSTRING_CSTR(typeName));
return;
}
connect(this, &HyperionDaemon::videoMode, grabber.get(), &GrabberType::setVideoMode);
connect(this, &HyperionDaemon::settingsChanged, grabber.get(), &GrabberType::handleSettingsUpdate);
Info(_log, "%s grabber created", QSTRING_CSTR(typeName));
grabber->tryStart();
// Transfer ownership to sharedGrabber
sharedGrabber.reset(grabber.release());
}
}
Logger* _log;
/// Core services
QScopedPointer<HyperionIManager> _instanceManager;
QScopedPointer<SettingsManager> _settingsManager;
Logger* _log;
HyperionIManager* _instanceManager;
AuthManager* _authManager;
#ifdef ENABLE_MDNS
MdnsProvider* _mDNSProvider;
#endif
NetOrigin* _netOrigin;
#if defined(ENABLE_EFFECTENGINE) #if defined(ENABLE_EFFECTENGINE)
PythonInit* _pyInit; PythonInit* _pyInit;
#endif #endif
WebServer* _webserver;
WebServer* _sslWebserver; /// Network services
JsonServer* _jsonServer; QScopedPointer<AuthManager> _authManager;
VideoWrapper* _videoGrabber; QScopedPointer<NetOrigin> _netOrigin;
DispmanxWrapper* _dispmanx; QScopedPointer<JsonServer, QScopedPointerDeleteLater> _jsonServer;
X11Wrapper* _x11Grabber; QScopedPointer<WebServer, QScopedPointerDeleteLater> _webserver;
XcbWrapper* _xcbGrabber; QScopedPointer<WebServer, QScopedPointerDeleteLater> _sslWebserver;
AmlogicWrapper* _amlGrabber; QScopedPointer<SSDPHandler, QScopedPointerDeleteLater> _ssdp;
FramebufferWrapper* _fbGrabber; #ifdef ENABLE_MDNS
OsxWrapper* _osxGrabber; QScopedPointer<MdnsProvider, QScopedPointerDeleteLater> _mDNSProvider;
QtWrapper* _qtGrabber; #endif
DirectXWrapper* _dxGrabber; #if defined(ENABLE_FLATBUF_SERVER)
AudioWrapper* _audioGrabber; QScopedPointer<FlatBufferServer, QScopedPointerDeleteLater> _flatBufferServer;
SSDPHandler* _ssdp; #endif
EventHandler* _eventHandler; #if defined(ENABLE_PROTOBUF_SERVER)
OsEventHandler* _osEventHandler; QScopedPointer<ProtoServer, QScopedPointerDeleteLater> _protoServer;
EventScheduler* _eventScheduler;
#ifdef ENABLE_CEC
CECHandler* _cecHandler;
#endif #endif
#if defined(ENABLE_FLATBUF_SERVER) /// Event services
FlatBufferServer* _flatBufferServer; QScopedPointer<EventHandler> _eventHandler;
#endif QScopedPointer<OsEventHandler> _osEventHandler;
#if defined(ENABLE_PROTOBUF_SERVER) QScopedPointer<EventScheduler> _eventScheduler;
ProtoServer* _protoServer; #ifdef ENABLE_CEC
#endif QScopedPointer<CECHandler> _cecHandler;
int _grabber_width; #endif
int _grabber_height;
int _grabber_pixelDecimation; /// Grabber services
int _grabber_frequency; QScopedPointer<GrabberWrapper> _screenGrabber;
int _grabber_cropLeft; QScopedPointer<VideoWrapper> _videoGrabber;
int _grabber_cropRight; QScopedPointer<AudioWrapper> _audioGrabber;
int _grabber_cropTop;
int _grabber_cropBottom;
QString _prevType; QString _prevType;
VideoMode _currVideoMode; VideoMode _currVideoMode;
SettingsManager* _settingsManager;
}; };
#endif // HYPERIOND_H

View File

@ -389,9 +389,6 @@ int main(int argc, char** argv)
Error(log, "Hyperion aborted: %s", e.what()); Error(log, "Hyperion aborted: %s", e.what());
} }
// delete components
Logger::deleteInstance();
#ifdef _WIN32 #ifdef _WIN32
if (parser.isSet(consoleOption)) if (parser.isSet(consoleOption))
{ {

View File

@ -45,7 +45,7 @@ SysTray::SysTray(HyperionDaemon *hyperiond)
// instance changes // instance changes
connect(_instanceManager, &HyperionIManager::instanceStateChanged, this, &SysTray::handleInstanceStateChange); connect(_instanceManager, &HyperionIManager::instanceStateChanged, this, &SysTray::handleInstanceStateChange);
connect(this, &SysTray::signalEvent, EventHandler::getInstance(), &EventHandler::handleEvent); connect(this, &SysTray::signalEvent, EventHandler::getInstance().data(), &EventHandler::handleEvent);
} }
SysTray::~SysTray() SysTray::~SysTray()