refactoring and cleanup (#2)

* make hyperion to singelton.
remove arguments for config and hyperion - both are gettable via Hyperion::getInstance

* refactor hyperiond

* remove qt4 comapt
make zeroconf mandatory
refactor hyperiond

* xbmcchecker is now a singleton

* cleanup in hyperiond
zeroconf switchable between static and shared linking

* fix xbmcchecker
This commit is contained in:
redPanther 2016-06-17 01:25:40 +02:00 committed by brindosch
parent 5206202568
commit 88fbc4dfde
51 changed files with 507 additions and 723 deletions

View File

@ -17,7 +17,7 @@ SET ( DEFAULT_X11 OFF )
SET ( DEFAULT_SPIDEV OFF )
SET ( DEFAULT_WS2812BPWM OFF )
SET ( DEFAULT_WS281XPWM OFF )
SET ( DEFAULT_ZEROCONF OFF )
SET ( DEFAULT_ZEROCONF ON )
if (APPLE)
SET ( DEFAULT_OSX ON )
@ -42,8 +42,7 @@ else ()
endif ()
# set the build options
option(ENABLE_ZEROCONF "Enable the avahi/zeroconf announce" ${DEFAULT_ZEROCONF} )
message(STATUS "ENABLE_ZEROCONF = " ${ENABLE_ZEROCONF})
SET(ENABLE_ZEROCONF ON )
option(ENABLE_AMLOGIC "Enable the AMLOGIC video grabber" ${DEFAULT_AMLOGIC} )
message(STATUS "ENABLE_AMLOGIC = " ${ENABLE_AMLOGIC})
@ -75,8 +74,7 @@ message(STATUS "ENABLE_WS281XPWM = " ${ENABLE_WS281XPWM})
option(ENABLE_X11 "Enable the X11 grabber" ${DEFAULT_X11})
message(STATUS "ENABLE_X11 = " ${ENABLE_X11})
option(ENABLE_QT5 "Enable QT5" OFF)
message(STATUS "ENABLE_QT5 = " ${ENABLE_QT5})
SET(ENABLE_QT5 ON)
option(ENABLE_TESTS "Compile additional test applications" OFF)
message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS})
@ -116,13 +114,6 @@ find_package(GitVersion)
configure_file("${PROJECT_SOURCE_DIR}/HyperionConfig.h.in" "${PROJECT_BINARY_DIR}/HyperionConfig.h")
include_directories("${PROJECT_BINARY_DIR}")
if( NOT ENABLE_QT5)
#ADD_DEFINITIONS ( -DENABLE_QT5 )
#find_package(Qt5Widgets)
#else()
# Add specific cmake modules to find qt4 (default version finds first available QT which might not be qt4)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/qt4)
endif()
# Define the global output path of binaries
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
@ -142,26 +133,13 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Wall")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -std=c++11 -Wall")
if(ENABLE_QT5)
#find_package(Qt5Core REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
# set(CMAKE_CXX_FLAGS "-fPIC")
else()
# Configure the use of QT4
find_package(Qt4 COMPONENTS QtCore QtNetwork QtGui REQUIRED QUIET)
endif()
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
#add libusb and pthreads
find_package(libusb-1.0 REQUIRED)
find_package(Threads REQUIRED)
if(ENABLE_QT5)
#include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
else()
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
endif()
add_definitions(${QT_DEFINITIONS})
# TODO[TvdZ]: This linking directory should only be added if we are cross compiling
if(NOT APPLE)
@ -185,8 +163,9 @@ add_subdirectory(doc)
# uninstall target
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
# enable make package - no code after this line !
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/packages.cmake)

View File

@ -32,7 +32,6 @@
// Define to enable profiler for development purpose
#cmakedefine ENABLE_PROFILER
#cmakedefine ENABLE_QT5
// the hyperion build id string
#define HYPERION_VERSION_ID "${HYPERION_VERSION_ID}"

View File

@ -33,7 +33,7 @@ public:
/// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] hyperion The instance of Hyperion used to write the led values
///
AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion);
AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
///
/// Destructor of this dispmanx frame grabber. Releases any claimed resources.

View File

@ -33,7 +33,7 @@ public:
/// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] hyperion The instance of Hyperion used to write the led values
///
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion);
DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
///
/// Destructor of this dispmanx frame grabber. Releases any claimed resources.

View File

@ -31,9 +31,8 @@ public:
/// @param[in] grabWidth The width of the grabbed image [pixels]
/// @param[in] grabHeight The height of the grabbed images [pixels]
/// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] hyperion The instance of Hyperion used to write the led values
///
FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion);
FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
///
/// Destructor of this framebuffer frame grabber. Releases any claimed resources.

View File

@ -34,7 +34,7 @@ public:
/// @param[in] updateRate_Hz The image grab rate [Hz]
/// @param[in] hyperion The instance of Hyperion used to write the led values
///
OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion);
OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority);
///
/// Destructor of this osx frame grabber. Releases any claimed resources.

View File

@ -26,7 +26,6 @@ public:
double redSignalThreshold,
double greenSignalThreshold,
double blueSignalThreshold,
Hyperion * hyperion,
int hyperionPriority);
virtual ~V4L2Wrapper();

View File

@ -62,18 +62,15 @@ public:
SATURATION_GAIN, VALUE_GAIN, THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
};
///
/// Constructs the Hyperion instance based on the given Json configuration
///
/// @param[in] jsonConfig The Json configuration
///
Hyperion(const Json::Value& jsonConfig, const std::string configFile);
///
/// Destructor; cleans up resourcess
///
~Hyperion();
static Hyperion* initInstance(const Json::Value& jsonConfig, const std::string configFile);
static Hyperion* getInstance();
///
/// Returns the number of attached leds
///
@ -228,6 +225,8 @@ public slots:
int setEffect(const std::string & effectName, const Json::Value & args, int priority, int timeout = -1);
public:
static Hyperion *_hyperion;
static ColorOrder createColorOrder(const Json::Value & deviceConfig);
/**
* Construct the 'led-string' with the integration area definition per led and the color
@ -271,6 +270,14 @@ private slots:
void update();
private:
///
/// Constructs the Hyperion instance based on the given Json configuration
///
/// @param[in] jsonConfig The Json configuration
///
Hyperion(const Json::Value& jsonConfig, const std::string configFile);
/// The specifiation of the led frame construction and picture integration
LedString _ledString;

View File

@ -13,7 +13,7 @@ class WebConfig : public QObject {
Q_OBJECT
public:
WebConfig (Hyperion *hyperion, QObject * parent = NULL);
WebConfig (QObject * parent = NULL);
virtual ~WebConfig (void);

View File

@ -29,19 +29,8 @@ class XBMCVideoChecker : public QObject
Q_OBJECT
public:
///
/// Constructor
///
/// @param address Network address of the XBMC instance
/// @param port Port number to use (XBMC default = 9090)
/// @param grabVideo Whether or not to grab when the XBMC video player is playing
/// @param grabPhoto Whether or not to grab when the XBMC photo player is playing
/// @param grabAudio Whether or not to grab when the XBMC audio player is playing
/// @param grabMenu Whether or not to grab when nothing is playing (in XBMC menu)
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
/// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
///
XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection);
static XBMCVideoChecker* initInstance(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection);
static XBMCVideoChecker* getInstance();
///
/// Start polling XBMC
@ -72,6 +61,20 @@ private slots:
void connectionError(QAbstractSocket::SocketError error);
private:
///
/// Constructor
///
/// @param address Network address of the XBMC instance
/// @param port Port number to use (XBMC default = 9090)
/// @param grabVideo Whether or not to grab when the XBMC video player is playing
/// @param grabPhoto Whether or not to grab when the XBMC photo player is playing
/// @param grabAudio Whether or not to grab when the XBMC audio player is playing
/// @param grabMenu Whether or not to grab when nothing is playing (in XBMC menu)
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
/// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
///
XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection);
/// Set the grabbing mode
void setGrabbingMode(GrabbingMode grabbingMode);
@ -137,4 +140,6 @@ private:
/// XBMC version number
int _xbmcVersion;
static XBMCVideoChecker* _kodichecker;
};

View File

@ -6,20 +6,12 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc)
add_subdirectory(hyperion)
add_subdirectory(blackborder)
add_subdirectory(jsonserver)
add_subdirectory(protoserver)
if (ENABLE_ZEROCONF)
add_subdirectory(bonjour)
endif (ENABLE_ZEROCONF)
add_subdirectory(bonjour)
add_subdirectory(boblightserver)
add_subdirectory(leddevice)
add_subdirectory(utils)
add_subdirectory(xbmcvideochecker)
add_subdirectory(effectengine)
add_subdirectory(grabber)
if(ENABLE_QT5)
add_subdirectory(webconfig)
endif()
add_subdirectory(webconfig)

View File

@ -60,11 +60,7 @@ void BoblightClientConnection::readData()
while(bytes > 0)
{
// create message string (strip the newline)
#ifdef ENABLE_QT5
QString message = QString::fromLatin1(_receiveBuffer.data(), bytes-1);
#else
QString message = QString::fromAscii(_receiveBuffer.data(), bytes-1);
#endif
// remove message data from buffer
_receiveBuffer = _receiveBuffer.mid(bytes);

View File

@ -17,11 +17,7 @@ set(BoblightServer_SOURCES
${CURRENT_SOURCE_DIR}/BoblightClientConnection.cpp
)
if(ENABLE_QT5)
qt5_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS})
else()
qt4_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS})
endif()
qt5_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS})
add_library(boblightserver
${BoblightServer_HEADERS}
@ -30,9 +26,7 @@ add_library(boblightserver
${BoblightServer_HEADERS_MOC}
)
if(ENABLE_QT5)
qt5_use_modules(boblightserver Widgets)
endif()
qt5_use_modules(boblightserver Widgets)
target_link_libraries(boblightserver
hyperion

View File

@ -19,13 +19,8 @@ set(Bonjour_SOURCES
set(Bonjour_RESOURCES
)
if(ENABLE_QT5)
qt5_wrap_cpp(Bonjour_HEADERS_MOC ${Bonjour_QT_HEADERS})
qt5_add_resources(Bonjour_RESOURCES_RCC ${Bonjour_RESOURCES} OPTIONS "-no-compress")
else(ENABLE_QT5)
qt4_wrap_cpp(Bonjour_HEADERS_MOC ${Bonjour_QT_HEADERS})
qt4_add_resources(Bonjour_RESOURCES_RCC ${Bonjour_RESOURCES} OPTIONS "-no-compress")
endif(ENABLE_QT5)
add_library(bonjour
${Bonjour_HEADERS}
@ -36,17 +31,29 @@ add_library(bonjour
${Bonjour_RESOURCES_RCC}
)
if(ENABLE_QT5)
qt5_use_modules(bonjour Widgets Network)
endif(ENABLE_QT5)
target_link_libraries(bonjour
hyperion
hyperion-utils
${QT_LIBRARIES})
set(USE_SHARED_AVAHI_LIBS OFF CACHE BOOL "use avahi libraries from system")
if (USE_SHARED_AVAHI_LIBS)
target_link_libraries(bonjour
dns_sd
avahi-client
avahi-common
avahi-core
# avahi-qt4
dbus-1)
else()
target_link_libraries(bonjour
libdns_sd.a
libavahi-client.a
libavahi-common.a
libavahi-core.a
libavahi-qt4.a
libdbus-1.a
hyperion
hyperion-utils
${QT_LIBRARIES})
# libavahi-qt4.a
libdbus-1.a)
endif()

View File

@ -1,15 +0,0 @@
HEADERS = server.h \
bonjourserviceregister.h
SOURCES = server.cpp \
main.cpp \
bonjourserviceregister.cpp
QT += network
!mac:x11:LIBS+=-ldns_sd
win32 {
LIBS+=-ldnssd
# Add your path to bonjour here.
LIBPATH=C:/Temp/mDNSResponder-107.6/mDNSWindows/DLL/Debug
INCLUDEPATH += c:/Temp/mDNSResponder-107.6/mDNSShared
}

View File

@ -28,13 +28,8 @@ SET(EffectEngineSOURCES
set(EffectEngine_RESOURCES ${CURRENT_SOURCE_DIR}/EffectEngine.qrc)
if(ENABLE_QT5)
QT5_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS})
qt5_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress")
else()
QT4_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS})
qt4_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress")
endif()
QT5_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS})
qt5_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress")
add_library(effectengine
${EffectEngineHEADERS}
@ -44,9 +39,7 @@ add_library(effectengine
${EffectEngineSOURCES}
)
if(ENABLE_QT5)
qt5_use_modules(effectengine Widgets)
endif()
qt5_use_modules(effectengine Widgets)
target_link_libraries(effectengine
hyperion

View File

@ -98,11 +98,7 @@ const std::list<ActiveEffectDefinition> &EffectEngine::getActiveEffects()
bool EffectEngine::loadEffectDefinition(const std::string &path, const std::string &effectConfigFile, EffectDefinition & effectDefinition)
{
#ifdef ENABLE_QT5
std::string fileName = path + QDir::separator().toLatin1() + effectConfigFile;
#else
std::string fileName = path + QDir::separator().toAscii() + effectConfigFile;
#endif
std::ifstream file(fileName.c_str());
if (!file.is_open())
@ -137,11 +133,7 @@ bool EffectEngine::loadEffectDefinition(const std::string &path, const std::stri
// setup the definition
effectDefinition.name = config["name"].asString();
#ifdef ENABLE_QT5
effectDefinition.script = path + QDir::separator().toLatin1() + config["script"].asString();
#else
effectDefinition.script = path + QDir::separator().toAscii() + config["script"].asString();
#endif
effectDefinition.args = config["args"];
// return succes //BLACKLIST OUTPUT TO LOG (Spam). This is more a effect development thing and the list gets longer and longer

View File

@ -12,7 +12,7 @@
#include <grabber/AmlogicGrabber.h>
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion) :
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority) :
_updateInterval_ms(1000/updateRate_Hz),
_timeout_ms(2 * _updateInterval_ms),
_priority(priority),
@ -20,8 +20,8 @@ AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeig
_image(grabWidth, grabHeight),
_frameGrabber(new AmlogicGrabber(grabWidth, grabHeight)),
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
_hyperion(hyperion)
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0}),
_hyperion(Hyperion::getInstance())
{
// Configure the timer to generate events every n milliseconds
_timer.setInterval(_updateInterval_ms);

View File

@ -15,11 +15,7 @@ SET(AmlogicSOURCES
${CURRENT_SOURCE_DIR}/AmlogicGrabber.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(AmlogicHEADERS_MOC ${AmlogicQT_HEADERS})
else(ENABLE_QT5)
QT4_WRAP_CPP(AmlogicHEADERS_MOC ${AmlogicQT_HEADERS})
endif(ENABLE_QT5)
add_library(amlogic-grabber
${AmlogicHEADERS}

View File

@ -21,11 +21,7 @@ SET(DispmanxGrabberSOURCES
${CURRENT_SOURCE_DIR}/DispmanxFrameGrabber.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS})
else()
QT4_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS})
endif()
QT5_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS})
add_library(dispmanx-grabber
${DispmanxGrabberHEADERS}

View File

@ -12,7 +12,7 @@
#include <grabber/DispmanxFrameGrabber.h>
DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion) :
DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority) :
_updateInterval_ms(1000/updateRate_Hz),
_timeout_ms(2 * _updateInterval_ms),
_priority(priority),
@ -20,8 +20,8 @@ DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHe
_image(grabWidth, grabHeight),
_frameGrabber(new DispmanxFrameGrabber(grabWidth, grabHeight)),
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
_hyperion(hyperion)
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0}),
_hyperion(Hyperion::getInstance())
{
// Configure the timer to generate events every n milliseconds
_timer.setInterval(_updateInterval_ms);

View File

@ -21,11 +21,7 @@ SET(FramebufferGrabberSOURCES
${CURRENT_SOURCE_DIR}/FramebufferFrameGrabber.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS})
else()
QT4_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS})
endif()
QT5_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS})
add_library(framebuffer-grabber
${FramebufferGrabberHEADERS}

View File

@ -7,7 +7,7 @@
#include <grabber/FramebufferWrapper.h>
#include <grabber/FramebufferFrameGrabber.h>
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion) :
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority) :
_updateInterval_ms(1000/updateRate_Hz),
_timeout_ms(2 * _updateInterval_ms),
_priority(priority),
@ -15,8 +15,8 @@ FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigne
_image(grabWidth, grabHeight),
_frameGrabber(new FramebufferFrameGrabber(device, grabWidth, grabHeight)),
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
_hyperion(hyperion)
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0}),
_hyperion(Hyperion::getInstance())
{
// Configure the timer to generate events every n milliseconds
_timer.setInterval(_updateInterval_ms);

View File

@ -16,11 +16,7 @@ SET(OsxGrabberSOURCES
${CURRENT_SOURCE_DIR}/OsxFrameGrabber.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS})
else()
QT4_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS})
endif()
QT5_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS})
add_library(osx-grabber
${OsxGrabberHEADERS}

View File

@ -7,7 +7,7 @@
#include <grabber/OsxWrapper.h>
#include <grabber/OsxFrameGrabber.h>
OsxWrapper::OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority, Hyperion * hyperion) :
OsxWrapper::OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority) :
_updateInterval_ms(1000/updateRate_Hz),
_timeout_ms(2 * _updateInterval_ms),
_priority(priority),
@ -15,8 +15,8 @@ OsxWrapper::OsxWrapper(const unsigned display, const unsigned grabWidth, const u
_image(grabWidth, grabHeight),
_frameGrabber(new OsxFrameGrabber(display, grabWidth, grabHeight)),
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
_hyperion(hyperion)
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0}),
_hyperion(Hyperion::getInstance())
{
// Configure the timer to generate events every n milliseconds
_timer.setInterval(_updateInterval_ms);

View File

@ -16,11 +16,7 @@ SET(V4L2_SOURCES
${CURRENT_SOURCE_DIR}/V4L2Wrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS})
else()
QT4_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS})
endif()
QT5_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS})
add_library(v4l2-grabber
${V4L2_HEADERS}
@ -29,9 +25,7 @@ add_library(v4l2-grabber
${V4L2_HEADERS_MOC}
)
if(ENABLE_QT5)
qt5_use_modules(v4l2-grabber Widgets)
endif(ENABLE_QT5)
target_link_libraries(v4l2-grabber
hyperion

View File

@ -15,7 +15,6 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
double redSignalThreshold,
double greenSignalThreshold,
double blueSignalThreshold,
Hyperion *hyperion,
int hyperionPriority) :
_timeout_ms(1000),
_priority(hyperionPriority),
@ -29,8 +28,8 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
pixelDecimation,
pixelDecimation),
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
_hyperion(hyperion),
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
_hyperion(Hyperion::getInstance()),
_ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0}),
_timer()
{
// set the signal detection threshold of the grabber

View File

@ -22,11 +22,7 @@ SET(X11_SOURCES
${CURRENT_SOURCE_DIR}/X11Grabber.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(X11_HEADERS_MOC ${X11_QT_HEADERS})
else()
QT4_WRAP_CPP(X11_HEADERS_MOC ${X11_QT_HEADERS})
endif()
QT5_WRAP_CPP(X11_HEADERS_MOC ${X11_QT_HEADERS})
add_library(x11-grabber
${X11_HEADERS}

View File

@ -42,13 +42,8 @@ SET(Hyperion_RESOURCES
${CURRENT_SOURCE_DIR}/resource.qrc
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS})
QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress")
else()
QT4_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS})
QT4_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress")
endif()
QT5_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS})
QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress")
add_library(hyperion
${Hyperion_HEADERS}
@ -58,9 +53,7 @@ add_library(hyperion
${Hyperion_RESOURCES_RCC}
)
if(ENABLE_QT5)
qt5_use_modules(hyperion Widgets)
endif()
qt5_use_modules(hyperion Widgets)
target_link_libraries(hyperion
blackborder

View File

@ -1,6 +1,7 @@
// STL includes
#include <cassert>
#include <exception>
// QT includes
#include <QDateTime>
@ -31,6 +32,24 @@
// effect engine includes
#include <effectengine/EffectEngine.h>
Hyperion* Hyperion::_hyperion = nullptr;
Hyperion* Hyperion::initInstance(const Json::Value& jsonConfig, const std::string configFile)
{
if ( Hyperion::_hyperion != nullptr )
throw std::runtime_error("Hyperion::initInstance can be called only one time");
Hyperion::_hyperion = new Hyperion(jsonConfig,configFile);
return Hyperion::_hyperion;
}
Hyperion* Hyperion::getInstance()
{
if ( Hyperion::_hyperion == nullptr )
throw std::runtime_error("Hyperion::getInstance used without call of Hyperion::initInstance before");
return Hyperion::_hyperion;
}
ColorOrder Hyperion::createColorOrder(const Json::Value &deviceConfig)
{

View File

@ -20,13 +20,9 @@ set(JsonServer_SOURCES
set(JsonServer_RESOURCES
${CURRENT_SOURCE_DIR}/JsonSchemas.qrc
)
if(ENABLE_QT5)
qt5_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS})
qt5_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress")
else()
qt4_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS})
qt4_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress")
endif()
qt5_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS})
qt5_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress")
add_library(jsonserver
${JsonServer_HEADERS}
@ -37,9 +33,7 @@ add_library(jsonserver
${JsonServer_RESOURCES_RCC}
)
if(ENABLE_QT5)
qt5_use_modules(jsonserver Widgets Network)
endif()
qt5_use_modules(jsonserver Widgets Network)
target_link_libraries(jsonserver
hyperion

View File

@ -129,11 +129,7 @@ if(ENABLE_TINKERFORGE)
)
endif()
if(ENABLE_QT5)
QT5_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS})
else()
QT4_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS})
endif()
QT5_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS})
add_library(leddevice
@ -143,9 +139,7 @@ add_library(leddevice
${Leddevice_SOURCES}
)
if(ENABLE_QT5)
qt5_use_modules(leddevice Widgets Network)
endif()
qt5_use_modules(leddevice Widgets Network)
target_link_libraries(leddevice
hyperion-utils

View File

@ -34,11 +34,7 @@ protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS
${ProtoServer_PROTOS}
)
if(ENABLE_QT5)
qt5_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
else()
qt4_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
endif()
qt5_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
add_library(protoserver
${ProtoServer_HEADERS}
@ -49,9 +45,8 @@ add_library(protoserver
${ProtoServer_PROTO_SRCS}
${ProtoServer_PROTO_HDRS}
)
if(ENABLE_QT5)
qt5_use_modules(protoserver Widgets)
endif()
qt5_use_modules(protoserver Widgets)
target_link_libraries(protoserver
hyperion

View File

@ -49,9 +49,7 @@ add_library(hyperion-utils
${CURRENT_SOURCE_DIR}/jsonschema/JsonSchemaChecker.cpp
)
if(ENABLE_QT5)
qt5_use_modules(hyperion-utils Widgets)
endif()
qt5_use_modules(hyperion-utils Widgets)
target_link_libraries(hyperion-utils
jsoncpp

View File

@ -29,11 +29,7 @@ set(WebConfig_SOURCES
${CURRENT_SOURCE_DIR}/WebConfig.cpp
)
if(ENABLE_QT5)
qt5_wrap_cpp(WebConfig_HEADERS_MOC ${WebConfig_QT_HEADERS})
else()
qt4_wrap_cpp(WebConfigr_HEADERS_MOC ${WebConfig_QT_HEADERS})
endif()
qt5_wrap_cpp(WebConfig_HEADERS_MOC ${WebConfig_QT_HEADERS})
add_library(webconfig
${WebConfig_HEADERS}
@ -42,9 +38,7 @@ add_library(webconfig
${WebConfig_HEADERS_MOC}
)
if(ENABLE_QT5)
qt5_use_modules(webconfig Widgets Network)
endif()
qt5_use_modules(webconfig Widgets Network)
target_link_libraries(webconfig
hyperion

View File

@ -2,13 +2,13 @@
#include "StaticFileServing.h"
WebConfig::WebConfig(Hyperion *hyperion, QObject * parent)
WebConfig::WebConfig(QObject * parent)
: QObject(parent)
, _hyperion(hyperion)
, _port(WEBCONFIG_DEFAULT_PORT)
, _server(nullptr)
{
const Json::Value &config = hyperion->getJsonConfig();
_hyperion = Hyperion::getInstance();
const Json::Value &config = _hyperion->getJsonConfig();
_baseUrl = QString::fromStdString(WEBCONFIG_DEFAULT_PATH);
bool webconfigEnable = true;

View File

@ -15,11 +15,7 @@ SET(XBMCVideoChecker_SOURCES
${CURRENT_SOURCE_DIR}/XBMCVideoChecker.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS})
else()
QT4_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS})
endif()
QT5_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS})
add_library(xbmcvideochecker
${XBMCVideoChecker_HEADERS}
@ -28,9 +24,7 @@ add_library(xbmcvideochecker
${XBMCVideoChecker_SOURCES}
)
if(ENABLE_QT5)
qt5_use_modules(xbmcvideochecker Widgets)
endif()
qt5_use_modules(xbmcvideochecker Widgets)
target_link_libraries(xbmcvideochecker
hyperion

View File

@ -5,6 +5,24 @@
#include <xbmcvideochecker/XBMCVideoChecker.h>
XBMCVideoChecker* XBMCVideoChecker::_kodichecker = nullptr;
XBMCVideoChecker* XBMCVideoChecker::initInstance(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection)
{
if ( XBMCVideoChecker::_kodichecker != nullptr )
throw std::runtime_error("XBMCVideoChecker::initInstance can be called only one time");
XBMCVideoChecker::_kodichecker = new XBMCVideoChecker(address, port, grabVideo, grabPhoto, grabAudio, grabMenu, grabPause, grabScreensaver, enable3DDetection);
return XBMCVideoChecker::_kodichecker;
}
XBMCVideoChecker* XBMCVideoChecker::getInstance()
{
return XBMCVideoChecker::_kodichecker;
}
// Request player example:
// {"jsonrpc":"2.0","method":"Player.GetActivePlayers", "id":666}
// {"id":666,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}

View File

@ -1,15 +1,7 @@
# Configure minimum CMAKE version
cmake_minimum_required(VERSION 2.8)
# Set the project name
project(hyperion-aml)
# find QT
if(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
else(ENABLE_QT5)
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork)
endif(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver
@ -29,11 +21,7 @@ set(Hyperion_AML_SOURCES
AmlogicWrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
else()
QT4_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
endif()
QT5_WRAP_CPP(Hyperion_AML_HEADERS_MOC ${Hyperion_AML_QT_HEADERS})
add_executable(${PROJECT_NAME}
${Hyperion_AML_HEADERS}
@ -50,15 +38,6 @@ target_link_libraries(${PROJECT_NAME}
pthread
)
qt4_use_modules(${PROJECT_NAME}
Core
Gui
Network)
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -1,17 +1,7 @@
# Configure minimum CMAKE version
cmake_minimum_required(VERSION 2.8)
# Set the project name
project(hyperion-dispmanx)
# find QT
if(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
else()
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork )
endif()
# Find the BCM-package (VC control)
find_package(Qt5Widgets REQUIRED)
find_package(BCM REQUIRED)
include_directories(
@ -32,11 +22,7 @@ set(Hyperion_Dispmanx_SOURCES
DispmanxWrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_Dispmanx_HEADERS_MOC ${Hyperion_Dispmanx_QT_HEADERS})
else()
QT4_WRAP_CPP(Hyperion_Dispmanx_HEADERS_MOC ${Hyperion_Dispmanx_QT_HEADERS})
endif()
QT5_WRAP_CPP(Hyperion_Dispmanx_HEADERS_MOC ${Hyperion_Dispmanx_QT_HEADERS})
add_executable( ${PROJECT_NAME}
${Hyperion_Dispmanx_HEADERS}
@ -54,10 +40,6 @@ target_link_libraries( ${PROJECT_NAME}
pthread
)
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -1,15 +1,7 @@
# Configure minimum CMAKE version
cmake_minimum_required(VERSION 2.8)
# Set the project name
project(hyperion-framebuffer)
# find QT
if(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
else()
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork )
endif()
find_package(Qt5Widgets REQUIRED)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver
@ -29,11 +21,7 @@ set(Hyperion_FB_SOURCES
FramebufferWrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_FB_HEADERS_MOC ${Hyperion_FB_QT_HEADERS})
else()
QT4_WRAP_CPP(Hyperion_FB_HEADERS_MOC ${Hyperion_FB_QT_HEADERS})
endif()
QT5_WRAP_CPP(Hyperion_FB_HEADERS_MOC ${Hyperion_FB_QT_HEADERS})
add_executable( ${PROJECT_NAME}
${Hyperion_FB_HEADERS}
@ -50,10 +38,6 @@ target_link_libraries( ${PROJECT_NAME}
pthread
)
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -1,15 +1,7 @@
# Configure minimum CMAKE version
cmake_minimum_required(VERSION 2.8)
# Set the project name
project(hyperion-osx)
# find QT
if(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
else()
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork )
endif()
find_package(Qt5Widgets REQUIRED)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver
@ -29,11 +21,7 @@ set(Hyperion_OSX_SOURCES
OsxWrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_OSX_HEADERS_MOC ${Hyperion_OSX_QT_HEADERS})
else()
QT4_WRAP_CPP(Hyperion_OSX_HEADERS_MOC ${Hyperion_OSX_QT_HEADERS})
endif()
QT5_WRAP_CPP(Hyperion_OSX_HEADERS_MOC ${Hyperion_OSX_QT_HEADERS})
add_executable( ${PROJECT_NAME}
${Hyperion_OSX_HEADERS}
@ -50,11 +38,6 @@ target_link_libraries( ${PROJECT_NAME}
pthread
)
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -1,15 +1,9 @@
cmake_minimum_required(VERSION 2.8)
project(hyperion-remote)
# find Qt
if(ENABLE_QT5)
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Widgets Network REQUIRED)
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
# set(CMAKE_CXX_FLAGS "-fPIC")
else()
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork)
endif()
# The following I do not undrstand completely...
# libQtCore.so uses some hardcoded library path inside which are incorrect after copying the file RPi file system
@ -36,11 +30,7 @@ target_link_libraries(${PROJECT_NAME}
getoptPlusPlus
${QT_LIBRARIES})
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -51,13 +51,8 @@ int main(int argc, char * argv[])
// create the option parser and initialize all parameters
OptionsParser optionParser("Simple application to send a command to hyperion using the Json interface");
ParameterSet & parameters = optionParser.getParameters();
#ifdef ENABLE_QT5
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address" , QString("Set the address of the hyperion server [default: %1]").arg(defaultServerAddress).toLatin1().constData());
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority" , QString("Use to the provided priority channel (the lower the number, the higher the priority) [default: %1]").arg(defaultPriority).toLatin1().constData());
#else
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address" , QString("Set the address of the hyperion server [default: %1]").arg(defaultServerAddress).toAscii().constData());
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority" , QString("Use to the provided priority channel (the lower the number, the higher the priority) [default: %1]").arg(defaultPriority).toAscii().constData());
#endif
IntParameter & argDuration = parameters.add<IntParameter> ('d', "duration" , "Specify how long the leds should be switched on in millseconds [default: infinity]");
ColorParameter & argColor = parameters.add<ColorParameter> ('c', "color" , "Set all leds to a constant color (either RRGGBB hex value or a color name. The color may be repeated multiple time like: RRGGBBRRGGBB)");
ImageParameter & argImage = parameters.add<ImageParameter> ('i', "image" , "Set the leds to the colors according to the given image file");

View File

@ -1,16 +1,8 @@
cmake_minimum_required(VERSION 2.8)
project(hyperion-v4l2)
# find Qt
if(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
# set(CMAKE_CXX_FLAGS "-fPIC")
else()
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork)
endif()
find_package(Qt5Widgets REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/protoserver
@ -31,11 +23,8 @@ set(Hyperion_V4L2_SOURCES
hyperion-v4l2.cpp
ScreenshotHandler.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_V4L2_MOC_SOURCES ${Hyperion_V4L2_QT_HEADERS})
else()
QT4_WRAP_CPP(Hyperion_V4L2_MOC_SOURCES ${Hyperion_V4L2_QT_HEADERS})
endif()
QT5_WRAP_CPP(Hyperion_V4L2_MOC_SOURCES ${Hyperion_V4L2_QT_HEADERS})
add_executable(${PROJECT_NAME}
${Hyperion_V4L2_HEADERS}
@ -54,10 +43,6 @@ target_link_libraries(${PROJECT_NAME}
${QT_LIBRARIES}
)
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -1,17 +1,7 @@
# Configure minimum CMAKE version
cmake_minimum_required(VERSION 2.8)
# Set the project name
project(hyperion-x11)
# find QT
if(ENABLE_QT5)
find_package(Qt5Widgets REQUIRED)
else()
find_package(Qt4 REQUIRED QtCore QtGui QtNetwork)
endif()
# Find X11
find_package(Qt5Widgets REQUIRED)
find_package(X11 REQUIRED)
include_directories(
@ -32,12 +22,7 @@ set(Hyperion_X11_SOURCES
X11Wrapper.cpp
)
if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_X11_HEADERS_MOC ${Hyperion_X11_QT_HEADERS})
else()
QT4_WRAP_CPP(Hyperion_X11_HEADERS_MOC ${Hyperion_X11_QT_HEADERS})
endif()
QT5_WRAP_CPP(Hyperion_X11_HEADERS_MOC ${Hyperion_X11_QT_HEADERS})
add_executable(${PROJECT_NAME}
${Hyperion_X11_HEADERS}
@ -56,10 +41,6 @@ target_link_libraries(${PROJECT_NAME}
pthread
)
if(ENABLE_QT5)
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
else()
qt4_use_modules(${PROJECT_NAME} Core Gui Network )
endif()
qt5_use_modules(${PROJECT_NAME} Widgets Core Gui Network)
install ( TARGETS ${PROJECT_NAME} DESTINATION "bin" COMPONENT ambilight )

View File

@ -1,6 +1,6 @@
add_executable(hyperiond
hyperiond.cpp)
hyperiond.cpp hyperiond.h main.cpp)
target_link_libraries(hyperiond
getoptPlusPlus
@ -10,10 +10,9 @@ target_link_libraries(hyperiond
jsonserver
boblightserver
protoserver
webconfig
bonjour
)
if (ENABLE_QT5)
target_link_libraries(hyperiond webconfig)
endif ()
if (ENABLE_DISPMANX)
target_link_libraries(hyperiond dispmanx-grabber)
@ -35,10 +34,6 @@ if (ENABLE_AMLOGIC)
target_link_libraries(hyperiond amlogic-grabber)
endif ()
if (ENABLE_ZEROCONF)
target_link_libraries(hyperiond bonjour)
endif()
install ( TARGETS hyperiond DESTINATION "bin" COMPONENT ambilight )
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/effects DESTINATION "share/hyperion/" COMPONENT ambilight )
install ( DIRECTORY ${CMAKE_SOURCE_DIR}/bin/service DESTINATION "share/hyperion/" COMPONENT ambilight )

View File

@ -1,130 +1,32 @@
// C++ includes
#include <cassert>
#include <csignal>
#include <vector>
#include <unistd.h>
// QT includes
#include <QCoreApplication>
#include <QResource>
#include <QLocale>
#include <QFile>
#include <QHostInfo>
// getoptPlusPLus includes
#include <getoptPlusPlus/getoptpp.h>
// config includes
#include "HyperionConfig.h"
// Json-Schema includes
#include <utils/jsonschema/JsonFactory.h>
#include <utils/Logger.h>
// Hyperion includes
#include <hyperion/Hyperion.h>
#ifdef ENABLE_DISPMANX
// Dispmanx grabber includes
#include <grabber/DispmanxWrapper.h>
#endif
#ifdef ENABLE_V4L2
// v4l2 grabber
#include <grabber/V4L2Wrapper.h>
#endif
#ifdef ENABLE_FB
// Framebuffer grabber includes
#include <grabber/FramebufferWrapper.h>
#endif
#ifdef ENABLE_AMLOGIC
#include <grabber/AmlogicWrapper.h>
#endif
#ifdef ENABLE_OSX
// OSX grabber includes
#include <grabber/OsxWrapper.h>
#endif
// XBMC Video checker includes
#include <xbmcvideochecker/XBMCVideoChecker.h>
// Effect engine includes
#include <effectengine/EffectEngine.h>
#ifdef ENABLE_ZEROCONF
#include <bonjour/bonjourserviceregister.h>
#include <bonjour/bonjourrecord.h>
#include <QHostInfo>
#endif
// network servers
#include <jsonserver/JsonServer.h>
#include <protoserver/ProtoServer.h>
#include <boblightserver/BoblightServer.h>
#include <webconfig/WebConfig.h>
#include <sys/prctl.h>
#include <utils/Logger.h>
#include "hyperiond.h"
using namespace vlofgren;
// ProtoServer includes
#include <protoserver/ProtoServer.h>
// BoblightServer includes
#include <boblightserver/BoblightServer.h>
#include <sys/prctl.h>
using namespace vlofgren;
void signal_handler(const int signum)
void startBootsequence()
{
QCoreApplication::quit();
Hyperion *hyperion = Hyperion::getInstance();
const Json::Value &config = hyperion->getJsonConfig();
// reset signal handler to default (in case this handler is not capable of stopping)
signal(signum, SIG_DFL);
}
Json::Value loadConfig(const std::string & configFile)
{
// make sure the resources are loaded (they may be left out after static linking)
Q_INIT_RESOURCE(resource);
// read the json schema from the resource
QResource schemaData(":/hyperion-schema");
assert(schemaData.isValid());
Json::Reader jsonReader;
Json::Value schemaJson;
if (!jsonReader.parse(reinterpret_cast<const char *>(schemaData.data()), reinterpret_cast<const char *>(schemaData.data()) + schemaData.size(), schemaJson, false))
{
throw std::runtime_error("ERROR: Json schema wrong: " + jsonReader.getFormattedErrorMessages()) ;
}
JsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
schemaChecker.validate(jsonConfig);
return jsonConfig;
}
void startNewHyperion(int parentPid, std::string hyperionFile, std::string configFile)
{
if ( fork() == 0 )
{
sleep(3);
execl(hyperionFile.c_str(), hyperionFile.c_str(), "--parent", QString::number(parentPid).toStdString().c_str(), configFile.c_str(), NULL);
exit(0);
}
}
void startBootsequence(const Json::Value &config, Hyperion &hyperion)
{
// create boot sequence if the configuration is present
if (config.isMember("bootsequence"))
{
@ -138,7 +40,7 @@ void startBootsequence(const Json::Value &config, Hyperion &hyperion)
// clear the leds
ColorRgb boot_color = ColorRgb::BLACK;
hyperion.setColor(bootcolor_priority, boot_color, 0, false);
hyperion->setColor(bootcolor_priority, boot_color, 0, false);
// start boot effect
if ( ! effectName.empty() )
@ -149,11 +51,11 @@ void startBootsequence(const Json::Value &config, Hyperion &hyperion)
{
std::cout << " (with user defined arguments) ";
const Json::Value effectConfigArgs = effectConfig["args"];
result = hyperion.setEffect(effectName, effectConfigArgs, priority, duration_ms);
result = hyperion->setEffect(effectName, effectConfigArgs, priority, duration_ms);
}
else
{
result = hyperion.setEffect(effectName, priority, duration_ms);
result = hyperion->setEffect(effectName, priority, duration_ms);
}
std::cout << ((result == 0) ? "started" : "failed") << std::endl;
}
@ -168,18 +70,20 @@ void startBootsequence(const Json::Value &config, Hyperion &hyperion)
};
}
hyperion.setColor(bootcolor_priority, boot_color, 0, false);
hyperion->setColor(bootcolor_priority, boot_color, 0, false);
}
}
// create XBMC video checker if the configuration is present
void startXBMCVideoChecker(const Json::Value &config, XBMCVideoChecker* &xbmcVideoChecker)
XBMCVideoChecker* createXBMCVideoChecker()
{
XBMCVideoChecker* xbmcVideoChecker = nullptr;
const Json::Value &config = Hyperion::getInstance()->getJsonConfig();
if (config.isMember("xbmcVideoChecker"))
{
const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"];
xbmcVideoChecker = new XBMCVideoChecker(
xbmcVideoChecker = XBMCVideoChecker::initInstance(
videoCheckerConfig["xbmcAddress"].asString(),
videoCheckerConfig["xbmcTcpPort"].asUInt(),
videoCheckerConfig["grabVideo"].asBool(),
@ -191,12 +95,17 @@ void startXBMCVideoChecker(const Json::Value &config, XBMCVideoChecker* &xbmcVid
videoCheckerConfig.get("enable3DDetection", true).asBool());
xbmcVideoChecker->start();
std::cout << "INFO: Kodi checker created and started" << std::endl;
Info(Logger::getInstance("MAIN"), "Kodi checker created and started");
}
return xbmcVideoChecker;
}
void startNetworkServices(const Json::Value &config, Hyperion &hyperion, JsonServer* &jsonServer, ProtoServer* &protoServer, BoblightServer* &boblightServer, XBMCVideoChecker* &xbmcVideoChecker)
void startNetworkServices(JsonServer* &jsonServer, ProtoServer* &protoServer, BoblightServer* &boblightServer)
{
Hyperion *hyperion = Hyperion::getInstance();
XBMCVideoChecker* xbmcVideoChecker = XBMCVideoChecker::getInstance();
const Json::Value &config = hyperion->getJsonConfig();
// Create Json server if configuration is present
unsigned int jsonPort = 19444;
if (config.isMember("jsonServer"))
@ -206,8 +115,8 @@ void startNetworkServices(const Json::Value &config, Hyperion &hyperion, JsonSer
jsonPort = jsonServerConfig.get("port", jsonPort).asUInt();
}
jsonServer = new JsonServer(&hyperion, jsonPort );
std::cout << "INFO: Json server created and started on port " << jsonServer->getPort() << std::endl;
jsonServer = new JsonServer(hyperion, jsonPort );
Info(Logger::getInstance("MAIN"), "Json server created and started on port %d", jsonServer->getPort());
// Create Proto server if configuration is present
unsigned int protoPort = 19445;
@ -218,15 +127,14 @@ void startNetworkServices(const Json::Value &config, Hyperion &hyperion, JsonSer
protoPort = protoServerConfig.get("port", protoPort).asUInt();
}
protoServer = new ProtoServer(&hyperion, protoPort );
protoServer = new ProtoServer(hyperion, protoPort );
if (xbmcVideoChecker != nullptr)
{
QObject::connect(xbmcVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), protoServer, SIGNAL(grabbingMode(GrabbingMode)));
QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), protoServer, SIGNAL(videoMode(VideoMode)));
}
std::cout << "INFO: Proto server created and started on port " << protoServer->getPort() << std::endl;
Info(Logger::getInstance("MAIN"), "Proto server created and started on port %d", protoServer->getPort());
#ifdef ENABLE_ZEROCONF
const Json::Value & deviceConfig = config["device"];
const std::string deviceName = deviceConfig.get("name", "").asString();
@ -244,7 +152,7 @@ void startNetworkServices(const Json::Value &config, Hyperion &hyperion, JsonSer
BonjourServiceRegister *bonjourRegister_json = new BonjourServiceRegister();
bonjourRegister_json->registerService(BonjourRecord((deviceName + " @ " + mDNSDescr_json).c_str(), mDNSService_json.c_str(),
QString()), jsonServer->getPort() );
std::cout << "INFO: Json mDNS responder started" << std::endl;
Info(Logger::getInstance("MAIN"), "Json mDNS responder started");
std::string mDNSDescr_proto = hostname;
std::string mDNSService_proto = "_hyperiond_proto._tcp";
@ -258,21 +166,24 @@ void startNetworkServices(const Json::Value &config, Hyperion &hyperion, JsonSer
BonjourServiceRegister *bonjourRegister_proto = new BonjourServiceRegister();
bonjourRegister_proto->registerService(BonjourRecord((deviceName + " @ " + mDNSDescr_proto).c_str(), mDNSService_proto.c_str(),
QString()), protoServer->getPort() );
std::cout << "INFO: Proto mDNS responder started" << std::endl;
#endif
Info(Logger::getInstance("MAIN"), "Proto mDNS responder started");
// Create Boblight server if configuration is present
if (config.isMember("boblightServer"))
{
const Json::Value & boblightServerConfig = config["boblightServer"];
boblightServer = new BoblightServer(&hyperion, boblightServerConfig.get("priority",900).asInt(), boblightServerConfig["port"].asUInt());
std::cout << "INFO: Boblight server created and started on port " << boblightServer->getPort() << std::endl;
boblightServer = new BoblightServer(hyperion, boblightServerConfig.get("priority",900).asInt(), boblightServerConfig["port"].asUInt());
Info(Logger::getInstance("MAIN"), "Boblight server created and started on port %d", boblightServer->getPort());
}
}
#ifdef ENABLE_DISPMANX
void startGrabberDispmanx(const Json::Value &config, Hyperion &hyperion, ProtoServer* &protoServer, XBMCVideoChecker* &xbmcVideoChecker, DispmanxWrapper* &dispmanx)
DispmanxWrapper* createGrabberDispmanx(ProtoServer* &protoServer)
{
DispmanxWrapper* dispmanx = nullptr;
#ifdef ENABLE_DISPMANX
XBMCVideoChecker* xbmcVideoChecker = XBMCVideoChecker::getInstance();
const Json::Value &config = Hyperion::getInstance()->getJsonConfig();
// Construct and start the frame-grabber if the configuration is present
if (config.isMember("framegrabber"))
{
@ -281,8 +192,7 @@ void startGrabberDispmanx(const Json::Value &config, Hyperion &hyperion, ProtoSe
frameGrabberConfig["width"].asUInt(),
frameGrabberConfig["height"].asUInt(),
frameGrabberConfig["frequency_Hz"].asUInt(),
frameGrabberConfig.get("priority",900).asInt(),
&hyperion);
frameGrabberConfig.get("priority",900).asInt());
dispmanx->setCropping(
frameGrabberConfig.get("cropLeft", 0).asInt(),
frameGrabberConfig.get("cropRight", 0).asInt(),
@ -298,15 +208,19 @@ void startGrabberDispmanx(const Json::Value &config, Hyperion &hyperion, ProtoSe
QObject::connect(dispmanx, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
dispmanx->start();
std::cout << "INFO: Frame grabber created and started" << std::endl;
Info(Logger::getInstance("MAIN"), "Frame grabber created and started");
}
}
#endif
return dispmanx;
}
#ifdef ENABLE_V4L2
void startGrabberV4L2(const Json::Value &config, Hyperion &hyperion, ProtoServer* &protoServer, V4L2Wrapper* &v4l2Grabber )
V4L2Wrapper* createGrabberV4L2(ProtoServer* &protoServer )
{
// construct and start the v4l2 grabber if the configuration is present
V4L2Wrapper* v4l2Grabber = nullptr;
#ifdef ENABLE_V4L2
const Json::Value &config = Hyperion::getInstance()->getJsonConfig();
if (config.isMember("grabber-v4l2"))
{
const Json::Value & grabberConfig = config["grabber-v4l2"];
@ -322,7 +236,6 @@ void startGrabberV4L2(const Json::Value &config, Hyperion &hyperion, ProtoServer
grabberConfig.get("redSignalThreshold", 0.0).asDouble(),
grabberConfig.get("greenSignalThreshold", 0.0).asDouble(),
grabberConfig.get("blueSignalThreshold", 0.0).asDouble(),
&hyperion,
grabberConfig.get("priority", 900).asInt());
v4l2Grabber->set3D(parse3DMode(grabberConfig.get("mode", "2D").asString()));
v4l2Grabber->setCropping(
@ -334,15 +247,19 @@ void startGrabberV4L2(const Json::Value &config, Hyperion &hyperion, ProtoServer
QObject::connect(v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
v4l2Grabber->start();
std::cout << "INFO: V4L2 grabber created and started" << std::endl;
Info(Logger::getInstance("MAIN"), "V4L2 grabber created and started");
}
}
#endif
return v4l2Grabber;
}
#ifdef ENABLE_AMLOGIC
void startGrabberAmlogic(const Json::Value &config, Hyperion &hyperion, ProtoServer* &protoServer, XBMCVideoChecker* &xbmcVideoChecker, AmlogicWrapper* &amlGrabber)
AmlogicWrapper* createGrabberAmlogic(ProtoServer* &protoServer)
{
AmlogicWrapper* amlGrabber = nullptr;
#ifdef ENABLE_AMLOGIC
XBMCVideoChecker* xbmcVideoChecker = XBMCVideoChecker::getInstance();
const Json::Value &config = Hyperion::getInstance()->getJsonConfig();
// Construct and start the framebuffer grabber if the configuration is present
if (config.isMember("amlgrabber"))
{
@ -351,8 +268,7 @@ void startGrabberAmlogic(const Json::Value &config, Hyperion &hyperion, ProtoSer
grabberConfig["width"].asUInt(),
grabberConfig["height"].asUInt(),
grabberConfig["frequency_Hz"].asUInt(),
grabberConfig.get("priority",900).asInt(),
&hyperion);
grabberConfig.get("priority",900).asInt());
if (xbmcVideoChecker != nullptr)
{
@ -363,15 +279,20 @@ void startGrabberAmlogic(const Json::Value &config, Hyperion &hyperion, ProtoSer
QObject::connect(amlGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
amlGrabber->start();
std::cout << "INFO: AMLOGIC grabber created and started" << std::endl;
Info(Logger::getInstance("MAIN"), "AMLOGIC grabber created and started");
}
}
#endif
return amlGrabber;
}
#ifdef ENABLE_FB
void startGrabberFramebuffer(const Json::Value &config, Hyperion &hyperion, ProtoServer* &protoServer, XBMCVideoChecker* &xbmcVideoChecker, FramebufferWrapper* &fbGrabber)
FramebufferWrapper* createGrabberFramebuffer(ProtoServer* &protoServer)
{
FramebufferWrapper* fbGrabber = nullptr;
#ifdef ENABLE_FB
XBMCVideoChecker* xbmcVideoChecker = XBMCVideoChecker::getInstance();
const Json::Value &config = Hyperion::getInstance()->getJsonConfig();
// Construct and start the framebuffer grabber if the configuration is present
if (config.isMember("framebuffergrabber") || config.isMember("framegrabber"))
{
@ -381,8 +302,7 @@ void startGrabberFramebuffer(const Json::Value &config, Hyperion &hyperion, Prot
grabberConfig["width"].asUInt(),
grabberConfig["height"].asUInt(),
grabberConfig["frequency_Hz"].asUInt(),
grabberConfig.get("priority",900).asInt(),
&hyperion);
grabberConfig.get("priority",900).asInt());
if (xbmcVideoChecker != nullptr)
{
@ -393,15 +313,20 @@ void startGrabberFramebuffer(const Json::Value &config, Hyperion &hyperion, Prot
QObject::connect(fbGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
fbGrabber->start();
std::cout << "INFO: Framebuffer grabber created and started" << std::endl;
Info(Logger::getInstance("MAIN"), "Framebuffer grabber created and started");
}
}
#endif
return fbGrabber;
}
#ifdef ENABLE_OSX
void startGrabberOsx(const Json::Value &config, Hyperion &hyperion, ProtoServer* &protoServer, XBMCVideoChecker* &xbmcVideoChecker, OsxWrapper* &osxGrabber)
OsxWrapper* createGrabberOsx(ProtoServer* &protoServer)
{
OsxWrapper* osxGrabber = nullptr;
#ifdef ENABLE_OSX
XBMCVideoChecker* xbmcVideoChecker = XBMCVideoChecker::getInstance();
const Json::Value &config = Hyperion::getInstance()->getJsonConfig();
// Construct and start the osx grabber if the configuration is present
if (config.isMember("osxgrabber") || config.isMember("framegrabber"))
{
@ -411,8 +336,7 @@ void startGrabberOsx(const Json::Value &config, Hyperion &hyperion, ProtoServer*
grabberConfig["width"].asUInt(),
grabberConfig["height"].asUInt(),
grabberConfig["frequency_Hz"].asUInt(),
grabberConfig.get("priority",900).asInt(),
&hyperion );
grabberConfig.get("priority",900).asInt());
if (xbmcVideoChecker != nullptr)
{
@ -423,190 +347,8 @@ void startGrabberOsx(const Json::Value &config, Hyperion &hyperion, ProtoServer*
QObject::connect(osxGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
osxGrabber->start();
std::cout << "INFO: OSX grabber created and started" << std::endl;
Info(Logger::getInstance("MAIN"), "OSX grabber created and started");
}
}
#endif
int main(int argc, char** argv)
{
std::cout
<< "Hyperion Ambilight Deamon (" << getpid() << ")" << std::endl
<< "\tVersion : " << HYPERION_VERSION_ID << std::endl
<< "\tBuild Time: " << __DATE__ << " " << __TIME__ << std::endl;
// Initialising QCoreApplication
QCoreApplication app(argc, argv);
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGCHLD, signal_handler);
// force the locale
setlocale(LC_ALL, "C");
QLocale::setDefault(QLocale::c());
OptionsParser optionParser("Hyperion Daemon");
ParameterSet & parameters = optionParser.getParameters();
IntParameter & argParentPid = parameters.add<IntParameter> (0x0, "parent", "pid of parent hyperiond");
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
argParentPid.setDefault(0);
optionParser.parse(argc, const_cast<const char **>(argv));
const std::vector<std::string> configFiles = optionParser.getFiles();
// check if we need to display the usage. exit if we do.
if (argHelp.isSet())
{
optionParser.usage();
return 0;
}
if (configFiles.size() == 0)
{
std::cout << "ERROR: Missing required configuration file. Usage:" << std::endl;
std::cout << "hyperiond <options ...> [config.file ...]" << std::endl;
return 1;
}
if (argParentPid.getValue() > 0 )
{
std::cout << "hyperiond client, parent is pid " << argParentPid.getValue() << std::endl;
prctl(PR_SET_PDEATHSIG, SIGHUP);
}
int argvId = -1;
for(size_t idx=0; idx < configFiles.size(); idx++) {
if ( QFile::exists(configFiles[idx].c_str()))
{
if (argvId < 0) argvId=idx;
else startNewHyperion(getpid(), argv[0], configFiles[idx].c_str());
}
}
if ( argvId < 0)
{
std::cout << "ERROR: No valid config found " << std::endl;
return 1;
}
const std::string configFile = configFiles[argvId];
std::cout << "INFO: Selected configuration file: " << configFile.c_str() << std::endl;
const Json::Value config = loadConfig(configFile);
Hyperion hyperion(config, configFile);
std::cout << "INFO: Hyperion started and initialised" << std::endl;
startBootsequence(config, hyperion);
XBMCVideoChecker * xbmcVideoChecker = nullptr;
startXBMCVideoChecker(config, xbmcVideoChecker);
// ---- network services -----
JsonServer * jsonServer = nullptr;
ProtoServer * protoServer = nullptr;
BoblightServer * boblightServer = nullptr;
startNetworkServices(config, hyperion, jsonServer, protoServer, boblightServer, xbmcVideoChecker);
#ifdef ENABLE_QT5
WebConfig webConfig(&hyperion, &app);
#endif
// ---- grabber -----
#ifdef ENABLE_DISPMANX
DispmanxWrapper * dispmanx = nullptr;
startGrabberDispmanx(config, hyperion, protoServer, xbmcVideoChecker, dispmanx);
#else
#if !defined(ENABLE_OSX) && !defined(ENABLE_FB)
if (config.isMember("framegrabber"))
{
std::cerr << "ERRROR: The dispmanx framegrabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#endif
#ifdef ENABLE_V4L2
V4L2Wrapper * v4l2Grabber = nullptr;
startGrabberV4L2(config, hyperion, protoServer, v4l2Grabber);
#else
if (config.isMember("grabber-v4l2"))
{
std::cerr << "ERROR: The v4l2 grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#ifdef ENABLE_AMLOGIC
// Construct and start the framebuffer grabber if the configuration is present
AmlogicWrapper * amlGrabber = nullptr;
startGrabberAmlogic(config, hyperion, protoServer, xbmcVideoChecker, amlGrabber);
#else
if (config.isMember("amlgrabber"))
{
std::cerr << "ERROR: The AMLOGIC grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#ifdef ENABLE_FB
// Construct and start the framebuffer grabber if the configuration is present
FramebufferWrapper * fbGrabber = nullptr;
startGrabberFramebuffer(config, hyperion, protoServer, xbmcVideoChecker, fbGrabber);
#else
if (config.isMember("framebuffergrabber"))
{
std::cerr << "ERROR: The framebuffer grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX)
else if (config.isMember("framegrabber"))
{
std::cerr << "ERROR: The framebuffer grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#endif
#ifdef ENABLE_OSX
// Construct and start the osx grabber if the configuration is present
OsxWrapper * osxGrabber = nullptr;
startGrabberDispmanx(config, hyperion, protoServer, xbmcVideoChecker, osxGrabber);
#else
if (config.isMember("osxgrabber"))
{
std::cerr << "ERROR: The osx grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_FB)
else if (config.isMember("framegrabber"))
{
std::cerr << "ERROR: The osx grabber can not be instantiated, because it has been left out from the build" << std::endl;
}
#endif
#endif
// run the application
int rc = app.exec();
std::cout << "INFO: Application closed with code " << rc << std::endl;
// Delete all component
#ifdef ENABLE_DISPMANX
delete dispmanx;
#endif
#ifdef ENABLE_FB
delete fbGrabber;
#endif
#ifdef ENABLE_OSX
delete osxGrabber;
#endif
#ifdef ENABLE_V4L2
delete v4l2Grabber;
#endif
delete xbmcVideoChecker;
delete jsonServer;
delete protoServer;
delete boblightServer;
// leave application
return rc;
#endif
return osxGrabber;
}

49
src/hyperiond/hyperiond.h Normal file
View File

@ -0,0 +1,49 @@
#pragma once
#include <QObject>
#ifdef ENABLE_DISPMANX
#include <grabber/DispmanxWrapper.h>
#else
typedef QObject DispmanxWrapper;
#endif
#ifdef ENABLE_V4L2
#include <grabber/V4L2Wrapper.h>
#else
typedef QObject V4L2Wrapper;
#endif
#ifdef ENABLE_FB
#include <grabber/FramebufferWrapper.h>
#else
typedef QObject FramebufferWrapper;
#endif
#ifdef ENABLE_AMLOGIC
#include <grabber/AmlogicWrapper.h>
#else
typedef QObject AmlogicWrapper;
#endif
#ifdef ENABLE_OSX
#include <grabber/OsxWrapper.h>
#else
typedef QObject OsxWrapper;
#endif
#include <xbmcvideochecker/XBMCVideoChecker.h>
#include <jsonserver/JsonServer.h>
#include <protoserver/ProtoServer.h>
#include <boblightserver/BoblightServer.h>
void startBootsequence();
XBMCVideoChecker* createXBMCVideoChecker();
void startNetworkServices(JsonServer* &jsonServer, ProtoServer* &protoServer, BoblightServer* &boblightServer);
// grabber creators
DispmanxWrapper* createGrabberDispmanx(ProtoServer* &protoServer);
V4L2Wrapper* createGrabberV4L2(ProtoServer* &protoServer );
AmlogicWrapper* createGrabberAmlogic(ProtoServer* &protoServer);
FramebufferWrapper* createGrabberFramebuffer(ProtoServer* &protoServer);
OsxWrapper* createGrabberOsx(ProtoServer* &protoServer);

205
src/hyperiond/main.cpp Normal file
View File

@ -0,0 +1,205 @@
#include <cassert>
#include <csignal>
#include <unistd.h>
#include <sys/prctl.h>
#include <QCoreApplication>
#include <QResource>
#include <QLocale>
#include <QFile>
#include "HyperionConfig.h"
#include <getoptPlusPlus/getoptpp.h>
#include <utils/jsonschema/JsonFactory.h>
#include <utils/Logger.h>
#include <hyperion/Hyperion.h>
#include <webconfig/WebConfig.h>
#include "hyperiond.h"
using namespace vlofgren;
void signal_handler(const int signum)
{
QCoreApplication::quit();
// reset signal handler to default (in case this handler is not capable of stopping)
signal(signum, SIG_DFL);
}
Json::Value loadConfig(const std::string & configFile)
{
// make sure the resources are loaded (they may be left out after static linking)
Q_INIT_RESOURCE(resource);
// read the json schema from the resource
QResource schemaData(":/hyperion-schema");
assert(schemaData.isValid());
Json::Reader jsonReader;
Json::Value schemaJson;
if (!jsonReader.parse(reinterpret_cast<const char *>(schemaData.data()), reinterpret_cast<const char *>(schemaData.data()) + schemaData.size(), schemaJson, false))
{
throw std::runtime_error("ERROR: Json schema wrong: " + jsonReader.getFormattedErrorMessages()) ;
}
JsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
schemaChecker.validate(jsonConfig);
return jsonConfig;
}
void startNewHyperion(int parentPid, std::string hyperionFile, std::string configFile)
{
if ( fork() == 0 )
{
sleep(3);
execl(hyperionFile.c_str(), hyperionFile.c_str(), "--parent", QString::number(parentPid).toStdString().c_str(), configFile.c_str(), NULL);
exit(0);
}
}
int main(int argc, char** argv)
{
Logger* log = Logger::getInstance("MAIN", Logger::INFO);
// Initialising QCoreApplication
QCoreApplication app(argc, argv);
signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler);
signal(SIGCHLD, signal_handler);
// force the locale
setlocale(LC_ALL, "C");
QLocale::setDefault(QLocale::c());
OptionsParser optionParser("Hyperion Daemon");
ParameterSet & parameters = optionParser.getParameters();
SwitchParameter<> & argVersion = parameters.add<SwitchParameter<>> (0x0, "version", "Show version information");
IntParameter & argParentPid = parameters.add<IntParameter> (0x0, "parent", "pid of parent hyperiond");
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
argParentPid.setDefault(0);
optionParser.parse(argc, const_cast<const char **>(argv));
const std::vector<std::string> configFiles = optionParser.getFiles();
// check if we need to display the usage. exit if we do.
if (argHelp.isSet())
{
optionParser.usage();
return 0;
}
if (argVersion.isSet())
{
std::cout
<< "Hyperion Ambilight Deamon (" << getpid() << ")" << std::endl
<< "\tVersion : " << HYPERION_VERSION_ID << std::endl
<< "\tBuild Time: " << __DATE__ << " " << __TIME__ << std::endl;
return 0;
}
if (configFiles.size() == 0)
{
Error(log, "Missing required configuration file. Usage: hyperiond <options ...> [config.file ...]");
return 1;
}
if (argParentPid.getValue() > 0 )
{
Info(log, "hyperiond client, parent is pid %d",argParentPid.getValue());
prctl(PR_SET_PDEATHSIG, SIGHUP);
}
int argvId = -1;
for(size_t idx=0; idx < configFiles.size(); idx++) {
if ( QFile::exists(configFiles[idx].c_str()))
{
if (argvId < 0) argvId=idx;
else startNewHyperion(getpid(), argv[0], configFiles[idx].c_str());
}
}
if ( argvId < 0)
{
Error(log, "No valid config found");
return 1;
}
const std::string configFile = configFiles[argvId];
Info(log, "Selected configuration file: %s", configFile.c_str() );
const Json::Value config = loadConfig(configFile);
Hyperion::initInstance(config, configFile);
Info(log, "Hyperion started and initialised");
startBootsequence();
XBMCVideoChecker * xbmcVideoChecker = createXBMCVideoChecker();
// ---- network services -----
JsonServer * jsonServer = nullptr;
ProtoServer * protoServer = nullptr;
BoblightServer * boblightServer = nullptr;
startNetworkServices(jsonServer, protoServer, boblightServer);
WebConfig webConfig(&app);
// ---- grabber -----
// if a grabber is left out of build, then <grabber>Wrapper is set to QObject as dummy and has value nullptr
V4L2Wrapper * v4l2Grabber = createGrabberV4L2(protoServer);
#ifndef ENABLE_V4L2
ErrorIf(config.isMember("grabber-v4l2"), log, "The v4l2 grabber can not be instantiated, because it has been left out from the build");
#endif
DispmanxWrapper * dispmanx = createGrabberDispmanx(protoServer);
#ifndef ENABLE_DISPMANX
ErrorIf(config.isMember("framegrabber"), log, "The dispmanx framegrabber can not be instantiated, because it has been left out from the build");
#endif
AmlogicWrapper * amlGrabber = createGrabberAmlogic(protoServer);
#ifndef ENABLE_AMLOGIC
ErrorIf(config.isMember("amlgrabber"), log, "The AMLOGIC grabber can not be instantiated, because it has been left out from the build");
#endif
FramebufferWrapper * fbGrabber = createGrabberFramebuffer(protoServer);
#ifndef ENABLE_FB
ErrorIf(config.isMember("framebuffergrabber"), log, "The framebuffer grabber can not be instantiated, because it has been left out from the build");
#endif
OsxWrapper * osxGrabber = createGrabberDispmanx(protoServer);
#ifndef ENABLE_OSX
ErrorIf(config.isMember("osxgrabber"), log, "The osx grabber can not be instantiated, because it has been left out from the build");
#endif
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX) && !defined(ENABLE_FB)
ErrorIf(config.isMember("framegrabber"), log, "No grabber can be instantiated, because all grabbers have been left out from the build" << std::endl;
#endif
// run the application
int rc = app.exec();
Info(log, "INFO: Application closed with code %d", rc);
// Delete all components
delete amlGrabber;
delete dispmanx;
delete fbGrabber;
delete osxGrabber;
delete v4l2Grabber;
delete xbmcVideoChecker;
delete jsonServer;
delete protoServer;
delete boblightServer;
return rc;
}

View File

@ -35,10 +35,8 @@ if (ENABLE_DISPMANX)
add_subdirectory(dispmanx2png)
endif (ENABLE_DISPMANX)
add_executable(test_blackborderdetector
TestBlackBorderDetector.cpp)
target_link_libraries(test_blackborderdetector
hyperion)
add_executable(test_blackborderdetector TestBlackBorderDetector.cpp)
target_link_libraries(test_blackborderdetector hyperion)
add_executable(test_blackborderprocessor
TestBlackBorderProcessor.cpp)
@ -53,10 +51,8 @@ add_executable(test_qtscreenshot TestQtScreenshot.cpp)
target_link_libraries(test_qtscreenshot
${QT_LIBRARIES})
if(ENABLE_QT5)
qt5_use_modules(test_qregexp Widgets)
qt5_use_modules(test_qtscreenshot Widgets)
endif(ENABLE_QT5)
if(ENABLE_X11)
# Find X11
@ -64,8 +60,7 @@ if(ENABLE_X11)
add_executable(test_x11performance TestX11Performance.cpp)
target_link_libraries(test_x11performance ${X11_LIBRARIES} ${QT_LIBRARIES})
if(ENABLE_QT5)
qt5_use_modules(test_x11performance Widgets)
endif(ENABLE_QT5)
qt5_use_modules(test_x11performance Widgets)
endif(ENABLE_X11)