big code cleanup. mostly line endings and indentions (#659)

No functional changes - except protobuffer is mandatory and not optional now.

Former-commit-id: 1e6347e708707cc388cdedb8d0352a9f017030b8
This commit is contained in:
redPanther 2016-05-26 23:44:27 +02:00 committed by brindosch
parent 667ee80ef6
commit 945f3d1c5b
73 changed files with 4941 additions and 4966 deletions

View File

@ -51,8 +51,7 @@ message(STATUS "ENABLE_FB = " ${ENABLE_FB})
option(ENABLE_OSX "Enable the osx grabber" ${DEFAULT_OSX} ) option(ENABLE_OSX "Enable the osx grabber" ${DEFAULT_OSX} )
message(STATUS "ENABLE_OSX = " ${ENABLE_OSX}) message(STATUS "ENABLE_OSX = " ${ENABLE_OSX})
option(ENABLE_PROTOBUF "Enable PROTOBUF server" ON) set(ENABLE_PROTOBUF ON)
message(STATUS "ENABLE_PROTOBUF = " ${ENABLE_PROTOBUF})
option(ENABLE_SPIDEV "Enable the SPIDEV device" ${DEFAULT_SPIDEV} ) option(ENABLE_SPIDEV "Enable the SPIDEV device" ${DEFAULT_SPIDEV} )
message(STATUS "ENABLE_SPIDEV = " ${ENABLE_SPIDEV}) message(STATUS "ENABLE_SPIDEV = " ${ENABLE_SPIDEV})
@ -78,9 +77,6 @@ message(STATUS "ENABLE_QT5 = " ${ENABLE_QT5})
option(ENABLE_TESTS "Compile additional test applications" OFF) option(ENABLE_TESTS "Compile additional test applications" OFF)
message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS}) message(STATUS "ENABLE_TESTS = " ${ENABLE_TESTS})
if(ENABLE_V4L2 AND NOT ENABLE_PROTOBUF)
message(FATAL_ERROR "V4L2 grabber requires PROTOBUF. Disable V4L2 or enable PROTOBUF")
endif()
if(ENABLE_FB AND ENABLE_DISPMANX) if(ENABLE_FB AND ENABLE_DISPMANX)
message(FATAL_ERROR "dispmanx grabber and framebuffer grabber cannot be used at the same time") message(FATAL_ERROR "dispmanx grabber and framebuffer grabber cannot be used at the same time")

View File

@ -1,8 +1,8 @@
#!/bin/sh #!/bin/sh
if [ "$#" -ne 2 ] || ! [ -d "$1" ] || ! [ -d "$2" ]; then if [ "$#" -ne 2 ] || ! [ -d "$1" ] || ! [ -d "$2" ]; then
echo "Usage: $0 <BUILD-DIR> <REPO-DIR>" >&2 echo "Usage: $0 <BUILD-DIR> <REPO-DIR>" >&2
exit 1 exit 1
fi fi
builddir="$1" builddir="$1"

View File

@ -6,15 +6,15 @@ PATH="/sbin:$PATH"
#Check if HyperCon is logged in as root #Check if HyperCon is logged in as root
if [ $(id -u) != 0 ] && [ "$1" = "HyperConRemove" ]; then if [ $(id -u) != 0 ] && [ "$1" = "HyperConRemove" ]; then
echo '---> Critical Error: Please connect as user "root" through HyperCon' echo '---> Critical Error: Please connect as user "root" through HyperCon'
echo '---> We need admin privileges to remove your Hyperion! -> abort' echo '---> We need admin privileges to remove your Hyperion! -> abort'
exit 1 exit 1
fi fi
#Check, if script is running as root #Check, if script is running as root
if [ $(id -u) != 0 ]; then if [ $(id -u) != 0 ]; then
echo '---> Critical Error: Please run the script as root (sudo sh ./remove_hyperion.sh)' echo '---> Critical Error: Please run the script as root (sudo sh ./remove_hyperion.sh)'
exit 1 exit 1
fi fi
#Welcome message #Welcome message
@ -26,21 +26,22 @@ echo '**************************************************************************
#Skip the prompt if HyperCon Remove #Skip the prompt if HyperCon Remove
if [ "$1" = "" ]; then if [ "$1" = "" ]; then
#Prompt for confirmation to proceed #Prompt for confirmation to proceed
while true while true
do do
echo -n "---> Do you really want to remove Hyperion and it´s services? (y or n) :" echo -n "---> Do you really want to remove Hyperion and it´s services? (y or n) :"
read CONFIRM read CONFIRM
case $CONFIRM in case $CONFIRM in
y|Y|YES|yes|Yes) break ;; y|Y|YES|yes|Yes) break ;;
n|N|no|NO|No) n|N|no|NO|No)
echo "---> Aborting - you entered \"$CONFIRM\"" echo "---> Aborting - you entered \"$CONFIRM\""
exit exit
;; ;;
*) echo "-> Please enter only y or n" *) echo "-> Please enter only y or n"
esac esac
done done
echo "---> You entered \"$CONFIRM\". Remove Hyperion!"
echo "---> You entered \"$CONFIRM\". Remove Hyperion!"
fi fi
# Find out if we are on OpenElec or RasPlex # Find out if we are on OpenElec or RasPlex
OS_OPENELEC=`grep -m1 -c 'OpenELEC\|RasPlex\|LibreELEC' /etc/issue` OS_OPENELEC=`grep -m1 -c 'OpenELEC\|RasPlex\|LibreELEC' /etc/issue`
@ -124,4 +125,3 @@ echo '**************************************************************************
echo 'Hyperion successful removed!' echo 'Hyperion successful removed!'
echo '*******************************************************************************' echo '*******************************************************************************'
exit 0 exit 0

View File

@ -8,16 +8,16 @@
# #
FIND_PATH(BCM_INCLUDE_DIR FIND_PATH(BCM_INCLUDE_DIR
bcm_host.h bcm_host.h
/usr/include /usr/include
/usr/local/include /usr/local/include
/opt/vc/include) /opt/vc/include)
SET(BCM_INCLUDE_DIRS SET(BCM_INCLUDE_DIRS
${BCM_INCLUDE_DIR} ${BCM_INCLUDE_DIR}
${BCM_INCLUDE_DIR}/interface/vcos/pthreads ${BCM_INCLUDE_DIR}/interface/vcos/pthreads
${BCM_INCLUDE_DIR}/interface/vmcs_host/linux) ${BCM_INCLUDE_DIR}/interface/vmcs_host/linux)
FIND_LIBRARY(BCM_LIBRARIES FIND_LIBRARY(BCM_LIBRARIES
NAMES bcm_host NAMES bcm_host
PATHS /usr/lib /usr/local/lib /opt/vc/lib) PATHS /usr/lib /usr/local/lib /opt/vc/lib)

View File

@ -17,5 +17,5 @@ if(APPLE)
set(CoreFoundation_FOUND true) set(CoreFoundation_FOUND true)
set(CoreFoundation_INCLUDE_DIR ${CoreFoundation}) set(CoreFoundation_INCLUDE_DIR ${CoreFoundation})
set(CoreFoundation_LIBRARY ${CoreFoundation}) set(CoreFoundation_LIBRARY ${CoreFoundation})
endif(CoreFoundation) endif()
endif(APPLE) endif()

View File

@ -13,9 +13,9 @@ set(IOKit_LIBRARY)
if(APPLE) if(APPLE)
# The only platform it makes sense to check for IOKit # The only platform it makes sense to check for IOKit
find_library(IOKit IOKit) find_library(IOKit IOKit)
if(IOKit) if(IOKit)
set(IOKit_FOUND true) set(IOKit_FOUND true)
set(IOKit_INCLUDE_DIR ${IOKit}) set(IOKit_INCLUDE_DIR ${IOKit})
set(IOKit_LIBRARY ${IOKit}) set(IOKit_LIBRARY ${IOKit})
endif(IOKit) endif(IOKit)
endif(APPLE) endif(APPLE)

View File

@ -10,44 +10,44 @@
# #
FIND_PATH( FIND_PATH(
UDEV_INCLUDE_DIR UDEV_INCLUDE_DIR
libudev.h libudev.h
/usr/include /usr/include
/usr/local/include /usr/local/include
${UDEV_PATH_INCLUDES} ${UDEV_PATH_INCLUDES}
) )
FIND_LIBRARY( FIND_LIBRARY(
UDEV_LIBRARIES UDEV_LIBRARIES
NAMES udev libudev NAMES udev libudev
PATHS PATHS
/usr/lib${LIB_SUFFIX} /usr/lib${LIB_SUFFIX}
/usr/local/lib${LIB_SUFFIX} /usr/local/lib${LIB_SUFFIX}
${UDEV_PATH_LIB} ${UDEV_PATH_LIB}
) )
IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR) IF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR)
SET(UDEV_FOUND "YES") SET(UDEV_FOUND "YES")
execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE) execute_process(COMMAND pkg-config --atleast-version=143 libudev RESULT_VARIABLE UDEV_STABLE)
# retvale is 0 of the condition is "true" so we need to negate the value... # retvale is 0 of the condition is "true" so we need to negate the value...
if (UDEV_STABLE) if (UDEV_STABLE)
set(UDEV_STABLE 0) set(UDEV_STABLE 0)
else (UDEV_STABLE) else ()
set(UDEV_STABLE 1) set(UDEV_STABLE 1)
endif (UDEV_STABLE) endif ()
message(STATUS "libudev stable: ${UDEV_STABLE}") message(STATUS "libudev stable: ${UDEV_STABLE}")
ENDIF (UDEV_LIBRARIES AND UDEV_INCLUDE_DIR) ENDIF ()
IF (UDEV_FOUND) IF (UDEV_FOUND)
MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}") MESSAGE(STATUS "Found UDev: ${UDEV_LIBRARIES}")
MESSAGE(STATUS " include: ${UDEV_INCLUDE_DIR}") MESSAGE(STATUS " include: ${UDEV_INCLUDE_DIR}")
ELSE (UDEV_FOUND) ELSE ()
MESSAGE(STATUS "UDev not found.") MESSAGE(STATUS "UDev not found.")
MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include") MESSAGE(STATUS "UDev: You can specify includes: -DUDEV_PATH_INCLUDES=/opt/udev/include")
MESSAGE(STATUS " currently found includes: ${UDEV_INCLUDE_DIR}") MESSAGE(STATUS " currently found includes: ${UDEV_INCLUDE_DIR}")
MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib") MESSAGE(STATUS "UDev: You can specify libs: -DUDEV_PATH_LIB=/opt/udev/lib")
MESSAGE(STATUS " currently found libs: ${UDEV_LIBRARIES}") MESSAGE(STATUS " currently found libs: ${UDEV_LIBRARIES}")
IF (UDev_FIND_REQUIRED) IF (UDev_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find UDev library") MESSAGE(FATAL_ERROR "Could not find UDev library")
ENDIF (UDev_FIND_REQUIRED) ENDIF ()
ENDIF (UDEV_FOUND) ENDIF ()

View File

@ -44,56 +44,52 @@
if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) if (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
# in cache already # in cache already
set(LIBUSB_FOUND TRUE) set(LIBUSB_FOUND TRUE)
else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) else (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)
find_path(LIBUSB_1_INCLUDE_DIR find_path(LIBUSB_1_INCLUDE_DIR
NAMES
libusb.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
PATH_SUFFIXES
libusb-1.0
)
find_library(LIBUSB_1_LIBRARY
NAMES NAMES
libusb.h usb-1.0 usb
PATHS PATHS
/usr/include /usr/lib
/usr/local/include /usr/local/lib
/opt/local/include /opt/local/lib
/sw/include /sw/lib
PATH_SUFFIXES )
libusb-1.0
)
find_library(LIBUSB_1_LIBRARY set(LIBUSB_1_INCLUDE_DIRS ${LIBUSB_1_INCLUDE_DIR} )
NAMES set(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY} )
usb-1.0 usb
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(LIBUSB_1_INCLUDE_DIRS if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
${LIBUSB_1_INCLUDE_DIR} set(LIBUSB_1_FOUND TRUE)
) endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES)
set(LIBUSB_1_LIBRARIES
${LIBUSB_1_LIBRARY}
)
if (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES) if (LIBUSB_1_FOUND)
set(LIBUSB_1_FOUND TRUE) if (NOT libusb_1_FIND_QUIETLY)
endif (LIBUSB_1_INCLUDE_DIRS AND LIBUSB_1_LIBRARIES) message(STATUS "Found libusb-1.0:")
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
endif (NOT libusb_1_FIND_QUIETLY)
else (LIBUSB_1_FOUND)
unset(LIBUSB_1_LIBRARY CACHE)
if (libusb_1_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libusb")
endif (libusb_1_FIND_REQUIRED)
endif (LIBUSB_1_FOUND)
if (LIBUSB_1_FOUND) # show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
if (NOT libusb_1_FIND_QUIETLY) mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
message(STATUS "Found libusb-1.0:")
message(STATUS " - Includes: ${LIBUSB_1_INCLUDE_DIRS}")
message(STATUS " - Libraries: ${LIBUSB_1_LIBRARIES}")
endif (NOT libusb_1_FIND_QUIETLY)
else (LIBUSB_1_FOUND)
unset(LIBUSB_1_LIBRARY CACHE)
if (libusb_1_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libusb")
endif (libusb_1_FIND_REQUIRED)
endif (LIBUSB_1_FOUND)
# show the LIBUSB_1_INCLUDE_DIRS and LIBUSB_1_LIBRARIES variables only in the advanced view
mark_as_advanced(LIBUSB_1_INCLUDE_DIRS LIBUSB_1_LIBRARIES)
endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS) endif (LIBUSB_1_LIBRARIES AND LIBUSB_1_INCLUDE_DIRS)

View File

@ -1,22 +1,22 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}") string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files}) foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}") message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program( exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval RETURN_VALUE rm_retval
) )
if(NOT "${rm_retval}" STREQUAL 0) if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0) endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.") message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file) endforeach(file)

View File

@ -23,103 +23,103 @@
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html /// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
class V4L2Grabber : public QObject class V4L2Grabber : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
V4L2Grabber(const std::string & device, V4L2Grabber(const std::string & device,
int input, int input,
VideoStandard videoStandard, PixelFormat pixelFormat, VideoStandard videoStandard, PixelFormat pixelFormat,
int width, int width,
int height, int height,
int frameDecimation, int frameDecimation,
int horizontalPixelDecimation, int horizontalPixelDecimation,
int verticalPixelDecimation); int verticalPixelDecimation);
virtual ~V4L2Grabber(); virtual ~V4L2Grabber();
public slots: public slots:
void setCropping(int cropLeft, void setCropping(int cropLeft,
int cropRight, int cropRight,
int cropTop, int cropTop,
int cropBottom); int cropBottom);
void set3D(VideoMode mode); void set3D(VideoMode mode);
void setSignalThreshold(double redSignalThreshold, void setSignalThreshold(double redSignalThreshold,
double greenSignalThreshold, double greenSignalThreshold,
double blueSignalThreshold, double blueSignalThreshold,
int noSignalCounterThreshold); int noSignalCounterThreshold);
void start(); void start();
void stop(); void stop();
signals: signals:
void newFrame(const Image<ColorRgb> & image); void newFrame(const Image<ColorRgb> & image);
private slots: private slots:
int read_frame(); int read_frame();
private: private:
void open_device(); void open_device();
void close_device(); void close_device();
void init_read(unsigned int buffer_size); void init_read(unsigned int buffer_size);
void init_mmap(); void init_mmap();
void init_userp(unsigned int buffer_size); void init_userp(unsigned int buffer_size);
void init_device(VideoStandard videoStandard, int input); void init_device(VideoStandard videoStandard, int input);
void uninit_device(); void uninit_device();
void start_capturing(); void start_capturing();
void stop_capturing(); void stop_capturing();
bool process_image(const void *p, int size); bool process_image(const void *p, int size);
void process_image(const uint8_t *p); void process_image(const uint8_t *p);
int xioctl(int request, void *arg); int xioctl(int request, void *arg);
void throw_exception(const std::string &error); void throw_exception(const std::string &error);
void throw_errno_exception(const std::string &error); void throw_errno_exception(const std::string &error);
private: private:
enum io_method { enum io_method {
IO_METHOD_READ, IO_METHOD_READ,
IO_METHOD_MMAP, IO_METHOD_MMAP,
IO_METHOD_USERPTR IO_METHOD_USERPTR
}; };
struct buffer { struct buffer {
void *start; void *start;
size_t length; size_t length;
}; };
private: private:
const std::string _deviceName; const std::string _deviceName;
const io_method _ioMethod; const io_method _ioMethod;
int _fileDescriptor; int _fileDescriptor;
std::vector<buffer> _buffers; std::vector<buffer> _buffers;
PixelFormat _pixelFormat; PixelFormat _pixelFormat;
int _width; int _width;
int _height; int _height;
int _lineLength; int _lineLength;
int _frameByteSize; int _frameByteSize;
int _frameDecimation; int _frameDecimation;
int _noSignalCounterThreshold; int _noSignalCounterThreshold;
ColorRgb _noSignalThresholdColor; ColorRgb _noSignalThresholdColor;
int _currentFrame; int _currentFrame;
int _noSignalCounter; int _noSignalCounter;
QSocketNotifier * _streamNotifier; QSocketNotifier * _streamNotifier;
ImageResampler _imageResampler; ImageResampler _imageResampler;
}; };

View File

@ -15,7 +15,7 @@ class X11Grabber
{ {
public: public:
X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation); X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation);
virtual ~X11Grabber(); virtual ~X11Grabber();
@ -26,16 +26,16 @@ public:
Image<ColorRgb> & grab(); Image<ColorRgb> & grab();
private: private:
ImageResampler _imageResampler; ImageResampler _imageResampler;
bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable; bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable;
int _cropLeft; int _cropLeft;
int _cropRight; int _cropRight;
int _cropTop; int _cropTop;
int _cropBottom; int _cropBottom;
XImage* _xImage; XImage* _xImage;
XShmSegmentInfo _shminfo; XShmSegmentInfo _shminfo;
/// Reference to the X11 display (nullptr if not opened) /// Reference to the X11 display (nullptr if not opened)
Display* _x11Display; Display* _x11Display;

View File

@ -23,90 +23,90 @@
class ProtoConnection : public QObject class ProtoConnection : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
/// ///
/// Constructor /// Constructor
/// ///
/// @param address The address of the Hyperion server (for example "192.168.0.32:19444) /// @param address The address of the Hyperion server (for example "192.168.0.32:19444)
/// ///
ProtoConnection(const std::string & address); ProtoConnection(const std::string & address);
/// ///
/// Destructor /// Destructor
/// ///
~ProtoConnection(); ~ProtoConnection();
/// Do not read reply messages from Hyperion if set to true /// Do not read reply messages from Hyperion if set to true
void setSkipReply(bool skip); void setSkipReply(bool skip);
/// ///
/// Set all leds to the specified color /// Set all leds to the specified color
/// ///
/// @param color The color /// @param color The color
/// @param priority The priority /// @param priority The priority
/// @param duration The duration in milliseconds /// @param duration The duration in milliseconds
/// ///
void setColor(const ColorRgb & color, int priority, int duration = 1); void setColor(const ColorRgb & color, int priority, int duration = 1);
/// ///
/// Set the leds according to the given image (assume the image is stretched to the display size) /// Set the leds according to the given image (assume the image is stretched to the display size)
/// ///
/// @param image The image /// @param image The image
/// @param priority The priority /// @param priority The priority
/// @param duration The duration in milliseconds /// @param duration The duration in milliseconds
/// ///
void setImage(const Image<ColorRgb> & image, int priority, int duration = -1); void setImage(const Image<ColorRgb> & image, int priority, int duration = -1);
/// ///
/// Clear the given priority channel /// Clear the given priority channel
/// ///
/// @param priority The priority /// @param priority The priority
/// ///
void clear(int priority); void clear(int priority);
/// ///
/// Clear all priority channels /// Clear all priority channels
/// ///
void clearAll(); void clearAll();
/// ///
/// Send a command message and receive its reply /// Send a command message and receive its reply
/// ///
/// @param message The message to send /// @param message The message to send
/// ///
void sendMessage(const proto::HyperionRequest & message); void sendMessage(const proto::HyperionRequest & message);
private slots: private slots:
/// Try to connect to the Hyperion host /// Try to connect to the Hyperion host
void connectToHost(); void connectToHost();
private: private:
/// ///
/// Parse a reply message /// Parse a reply message
/// ///
/// @param reply The received reply /// @param reply The received reply
/// ///
/// @return true if the reply indicates success /// @return true if the reply indicates success
/// ///
bool parseReply(const proto::HyperionReply & reply); bool parseReply(const proto::HyperionReply & reply);
private: private:
/// The TCP-Socket with the connection to the server /// The TCP-Socket with the connection to the server
QTcpSocket _socket; QTcpSocket _socket;
/// Host address /// Host address
QString _host; QString _host;
/// Host port /// Host port
uint16_t _port; uint16_t _port;
/// Skip receiving reply messages from Hyperion if set /// Skip receiving reply messages from Hyperion if set
bool _skipReply; bool _skipReply;
QTimer _timer; QTimer _timer;
QAbstractSocket::SocketState _prevSocketState; QAbstractSocket::SocketState _prevSocketState;
}; };

View File

@ -11,24 +11,24 @@
/// This class handles callbacks from the V4L2 grabber /// This class handles callbacks from the V4L2 grabber
class ProtoConnectionWrapper : public QObject class ProtoConnectionWrapper : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply); ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply);
virtual ~ProtoConnectionWrapper(); virtual ~ProtoConnectionWrapper();
public slots: public slots:
/// Handle a single image /// Handle a single image
/// @param image The image to process /// @param image The image to process
void receiveImage(const Image<ColorRgb> & image); void receiveImage(const Image<ColorRgb> & image);
private: private:
/// Priority for calls to Hyperion /// Priority for calls to Hyperion
const int _priority; const int _priority;
/// Duration for color calls to Hyperion /// Duration for color calls to Hyperion
const int _duration_ms; const int _duration_ms;
/// Hyperion proto connection object /// Hyperion proto connection object
ProtoConnection _connection; ProtoConnection _connection;
}; };

View File

@ -13,221 +13,221 @@ class Image
{ {
public: public:
typedef Pixel_T pixel_type; typedef Pixel_T pixel_type;
/// ///
/// Default constructor for an image /// Default constructor for an image
/// ///
Image() : Image() :
_width(1), _width(1),
_height(1), _height(1),
_pixels(new Pixel_T[2]), _pixels(new Pixel_T[2]),
_endOfPixels(_pixels + 1) _endOfPixels(_pixels + 1)
{ {
memset(_pixels, 0, 2*sizeof(Pixel_T)); memset(_pixels, 0, 2*sizeof(Pixel_T));
} }
/// ///
/// Constructor for an image with specified width and height /// Constructor for an image with specified width and height
/// ///
/// @param width The width of the image /// @param width The width of the image
/// @param height The height of the image /// @param height The height of the image
/// ///
Image(const unsigned width, const unsigned height) : Image(const unsigned width, const unsigned height) :
_width(width), _width(width),
_height(height), _height(height),
_pixels(new Pixel_T[width * height + 1]), _pixels(new Pixel_T[width * height + 1]),
_endOfPixels(_pixels + width * height) _endOfPixels(_pixels + width * height)
{ {
memset(_pixels, 0, (_width*_height+1)*sizeof(Pixel_T)); memset(_pixels, 0, (_width*_height+1)*sizeof(Pixel_T));
} }
/// ///
/// Constructor for an image with specified width and height /// Constructor for an image with specified width and height
/// ///
/// @param width The width of the image /// @param width The width of the image
/// @param height The height of the image /// @param height The height of the image
/// @param background The color of the image /// @param background The color of the image
/// ///
Image(const unsigned width, const unsigned height, const Pixel_T background) : Image(const unsigned width, const unsigned height, const Pixel_T background) :
_width(width), _width(width),
_height(height), _height(height),
_pixels(new Pixel_T[width * height + 1]), _pixels(new Pixel_T[width * height + 1]),
_endOfPixels(_pixels + width * height) _endOfPixels(_pixels + width * height)
{ {
std::fill(_pixels, _endOfPixels, background); std::fill(_pixels, _endOfPixels, background);
} }
/// ///
/// Copy constructor for an image /// Copy constructor for an image
/// ///
Image(const Image & other) : Image(const Image & other) :
_width(other._width), _width(other._width),
_height(other._height), _height(other._height),
_pixels(new Pixel_T[other._width * other._height + 1]), _pixels(new Pixel_T[other._width * other._height + 1]),
_endOfPixels(_pixels + other._width * other._height) _endOfPixels(_pixels + other._width * other._height)
{ {
memcpy(_pixels, other._pixels, other._width * other._height * sizeof(Pixel_T)); memcpy(_pixels, other._pixels, other._width * other._height * sizeof(Pixel_T));
} }
/// ///
/// Destructor /// Destructor
/// ///
~Image() ~Image()
{ {
delete[] _pixels; delete[] _pixels;
} }
/// ///
/// Returns the width of the image /// Returns the width of the image
/// ///
/// @return The width of the image /// @return The width of the image
/// ///
inline unsigned width() const inline unsigned width() const
{ {
return _width; return _width;
} }
/// ///
/// Returns the height of the image /// Returns the height of the image
/// ///
/// @return The height of the image /// @return The height of the image
/// ///
inline unsigned height() const inline unsigned height() const
{ {
return _height; return _height;
} }
uint8_t red(const unsigned pixel) const uint8_t red(const unsigned pixel) const
{ {
return (_pixels + pixel)->red; return (_pixels + pixel)->red;
} }
uint8_t green(const unsigned pixel) const uint8_t green(const unsigned pixel) const
{ {
return (_pixels + pixel)->green; return (_pixels + pixel)->green;
} }
uint8_t blue(const unsigned pixel) const uint8_t blue(const unsigned pixel) const
{ {
return (_pixels + pixel)->blue; return (_pixels + pixel)->blue;
} }
/// ///
/// Returns a const reference to a specified pixel in the image /// Returns a const reference to a specified pixel in the image
/// ///
/// @param x The x index /// @param x The x index
/// @param y The y index /// @param y The y index
/// ///
/// @return const reference to specified pixel /// @return const reference to specified pixel
/// ///
const Pixel_T& operator()(const unsigned x, const unsigned y) const const Pixel_T& operator()(const unsigned x, const unsigned y) const
{ {
return _pixels[toIndex(x,y)]; return _pixels[toIndex(x,y)];
} }
/// ///
/// Returns a reference to a specified pixel in the image /// Returns a reference to a specified pixel in the image
/// ///
/// @param x The x index /// @param x The x index
/// @param y The y index /// @param y The y index
/// ///
/// @return reference to specified pixel /// @return reference to specified pixel
/// ///
Pixel_T& operator()(const unsigned x, const unsigned y) Pixel_T& operator()(const unsigned x, const unsigned y)
{ {
return _pixels[toIndex(x,y)]; return _pixels[toIndex(x,y)];
} }
/// Resize the image /// Resize the image
/// @param width The width of the image /// @param width The width of the image
/// @param height The height of the image /// @param height The height of the image
void resize(const unsigned width, const unsigned height) void resize(const unsigned width, const unsigned height)
{ {
if ((width*height) > unsigned((_endOfPixels-_pixels))) if ((width*height) > unsigned((_endOfPixels-_pixels)))
{ {
delete[] _pixels; delete[] _pixels;
_pixels = new Pixel_T[width*height + 1]; _pixels = new Pixel_T[width*height + 1];
_endOfPixels = _pixels + width*height; _endOfPixels = _pixels + width*height;
} }
_width = width; _width = width;
_height = height; _height = height;
} }
/// ///
/// Copies another image into this image. The images should have exactly the same size. /// Copies another image into this image. The images should have exactly the same size.
/// ///
/// @param other The image to copy into this /// @param other The image to copy into this
/// ///
void copy(const Image<Pixel_T>& other) void copy(const Image<Pixel_T>& other)
{ {
assert(other._width == _width); assert(other._width == _width);
assert(other._height == _height); assert(other._height == _height);
memcpy(_pixels, other._pixels, _width*_height*sizeof(Pixel_T)); memcpy(_pixels, other._pixels, _width*_height*sizeof(Pixel_T));
} }
/// ///
/// Returns a memory pointer to the first pixel in the image /// Returns a memory pointer to the first pixel in the image
/// @return The memory pointer to the first pixel /// @return The memory pointer to the first pixel
/// ///
Pixel_T* memptr() Pixel_T* memptr()
{ {
return _pixels; return _pixels;
} }
/// ///
/// Returns a const memory pointer to the first pixel in the image /// Returns a const memory pointer to the first pixel in the image
/// @return The const memory pointer to the first pixel /// @return The const memory pointer to the first pixel
/// ///
const Pixel_T* memptr() const const Pixel_T* memptr() const
{ {
return _pixels; return _pixels;
} }
/// ///
/// Convert image of any color order to a RGB image. /// Convert image of any color order to a RGB image.
/// ///
/// @param[out] image The image that buffers the output /// @param[out] image The image that buffers the output
/// ///
void toRgb(Image<ColorRgb>& image) void toRgb(Image<ColorRgb>& image)
{ {
image.resize(_width, _height); image.resize(_width, _height);
const unsigned imageSize = _width * _height; const unsigned imageSize = _width * _height;
for (unsigned idx=0; idx<imageSize; idx++) for (unsigned idx=0; idx<imageSize; idx++)
{ {
const Pixel_T color = memptr()[idx]; const Pixel_T color = memptr()[idx];
image.memptr()[idx] = ColorRgb{color.red, color.green, color.blue}; image.memptr()[idx] = ColorRgb{color.red, color.green, color.blue};
} }
} }
private: private:
/// ///
/// Translate x and y coordinate to index of the underlying vector /// Translate x and y coordinate to index of the underlying vector
/// ///
/// @param x The x index /// @param x The x index
/// @param y The y index /// @param y The y index
/// ///
/// @return The index into the underlying data-vector /// @return The index into the underlying data-vector
/// ///
inline unsigned toIndex(const unsigned x, const unsigned y) const inline unsigned toIndex(const unsigned x, const unsigned y) const
{ {
return y*_width + x; return y*_width + x;
} }
private: private:
/// The width of the image /// The width of the image
unsigned _width; unsigned _width;
/// The height of the image /// The height of the image
unsigned _height; unsigned _height;
/// The pixels of the image /// The pixels of the image
Pixel_T* _pixels; Pixel_T* _pixels;
/// Pointer to the last(extra) pixel /// Pointer to the last(extra) pixel
Pixel_T* _endOfPixels; Pixel_T* _endOfPixels;
}; };

View File

@ -8,22 +8,21 @@
class ImageResampler class ImageResampler
{ {
public: public:
ImageResampler(); ImageResampler();
~ImageResampler(); ~ImageResampler();
void setHorizontalPixelDecimation(int decimator); void setHorizontalPixelDecimation(int decimator);
void setVerticalPixelDecimation(int decimator); void setVerticalPixelDecimation(int decimator);
void setCropping(int cropLeft, void setCropping(int cropLeft,
int cropRight, int cropRight,
int cropTop, int cropTop,
int cropBottom); int cropBottom);
void set3D(VideoMode mode); void set3D(VideoMode mode);
void processImage(const uint8_t * data, int width, int height, int lineLength, PixelFormat pixelFormat, void processImage(const uint8_t * data, int width, int height, int lineLength, PixelFormat pixelFormat, Image<ColorRgb> & outputImage) const;
Image<ColorRgb> & outputImage) const;
private: private:
static inline uint8_t clamp(int x); static inline uint8_t clamp(int x);

View File

@ -11,9 +11,9 @@ enum PixelFormat {
PIXELFORMAT_UYVY, PIXELFORMAT_UYVY,
PIXELFORMAT_BGR16, PIXELFORMAT_BGR16,
PIXELFORMAT_BGR24, PIXELFORMAT_BGR24,
PIXELFORMAT_RGB32, PIXELFORMAT_RGB32,
PIXELFORMAT_BGR32, PIXELFORMAT_BGR32,
PIXELFORMAT_NO_CHANGE PIXELFORMAT_NO_CHANGE
}; };
inline PixelFormat parsePixelFormat(std::string pixelFormat) inline PixelFormat parsePixelFormat(std::string pixelFormat)
@ -29,22 +29,22 @@ inline PixelFormat parsePixelFormat(std::string pixelFormat)
{ {
return PIXELFORMAT_UYVY; return PIXELFORMAT_UYVY;
} }
else if (pixelFormat == "bgr16") else if (pixelFormat == "bgr16")
{ {
return PIXELFORMAT_BGR16; return PIXELFORMAT_BGR16;
} }
else if (pixelFormat == "bgr24") else if (pixelFormat == "bgr24")
{ {
return PIXELFORMAT_BGR24; return PIXELFORMAT_BGR24;
} }
else if (pixelFormat == "rgb32") else if (pixelFormat == "rgb32")
{ {
return PIXELFORMAT_RGB32; return PIXELFORMAT_RGB32;
} }
else if (pixelFormat == "bgr32") else if (pixelFormat == "bgr32")
{ {
return PIXELFORMAT_BGR32; return PIXELFORMAT_BGR32;
} }
// return the default NO_CHANGE // return the default NO_CHANGE
return PIXELFORMAT_NO_CHANGE; return PIXELFORMAT_NO_CHANGE;

View File

@ -4,7 +4,7 @@
class Sleep : protected QThread { class Sleep : protected QThread {
public: public:
static inline void msleep(unsigned long msecs) { static inline void msleep(unsigned long msecs) {
QThread::msleep(msecs); QThread::msleep(msecs);
} }
}; };

View File

@ -9,7 +9,7 @@ add_subdirectory(jsonserver)
if (ENABLE_PROTOBUF) if (ENABLE_PROTOBUF)
add_subdirectory(protoserver) add_subdirectory(protoserver)
endif (ENABLE_PROTOBUF) endif ()
add_subdirectory(boblightserver) add_subdirectory(boblightserver)
add_subdirectory(leddevice) add_subdirectory(leddevice)

View File

@ -5,36 +5,36 @@ set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/boblightserver)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
set(BoblightServer_QT_HEADERS set(BoblightServer_QT_HEADERS
${CURRENT_HEADER_DIR}/BoblightServer.h ${CURRENT_HEADER_DIR}/BoblightServer.h
${CURRENT_SOURCE_DIR}/BoblightClientConnection.h ${CURRENT_SOURCE_DIR}/BoblightClientConnection.h
) )
set(BoblightServer_HEADERS set(BoblightServer_HEADERS
) )
set(BoblightServer_SOURCES set(BoblightServer_SOURCES
${CURRENT_SOURCE_DIR}/BoblightServer.cpp ${CURRENT_SOURCE_DIR}/BoblightServer.cpp
${CURRENT_SOURCE_DIR}/BoblightClientConnection.cpp ${CURRENT_SOURCE_DIR}/BoblightClientConnection.cpp
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS}) qt5_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS})
else(ENABLE_QT5) else()
qt4_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS}) qt4_wrap_cpp(BoblightServer_HEADERS_MOC ${BoblightServer_QT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(boblightserver add_library(boblightserver
${BoblightServer_HEADERS} ${BoblightServer_HEADERS}
${BoblightServer_QT_HEADERS} ${BoblightServer_QT_HEADERS}
${BoblightServer_SOURCES} ${BoblightServer_SOURCES}
${BoblightServer_HEADERS_MOC} ${BoblightServer_HEADERS_MOC}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(boblightserver Widgets) qt5_use_modules(boblightserver Widgets)
endif(ENABLE_QT5) endif()
target_link_libraries(boblightserver target_link_libraries(boblightserver
hyperion hyperion
hyperion-utils hyperion-utils
${QT_LIBRARIES}) ${QT_LIBRARIES})

View File

@ -13,8 +13,8 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/effectengine)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(EffectEngineQT_HEADERS SET(EffectEngineQT_HEADERS
${CURRENT_HEADER_DIR}/EffectEngine.h ${CURRENT_HEADER_DIR}/EffectEngine.h
${CURRENT_SOURCE_DIR}/Effect.h ${CURRENT_SOURCE_DIR}/Effect.h
) )
SET(EffectEngineHEADERS SET(EffectEngineHEADERS
@ -22,35 +22,34 @@ SET(EffectEngineHEADERS
) )
SET(EffectEngineSOURCES SET(EffectEngineSOURCES
${CURRENT_SOURCE_DIR}/EffectEngine.cpp ${CURRENT_SOURCE_DIR}/EffectEngine.cpp
${CURRENT_SOURCE_DIR}/Effect.cpp ${CURRENT_SOURCE_DIR}/Effect.cpp
) )
set(EffectEngine_RESOURCES ${CURRENT_SOURCE_DIR}/EffectEngine.qrc) set(EffectEngine_RESOURCES ${CURRENT_SOURCE_DIR}/EffectEngine.qrc)
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS}) QT5_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS})
qt5_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress") qt5_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress")
else(ENABLE_QT5) else()
QT4_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS}) QT4_WRAP_CPP(EffectEngineHEADERS_MOC ${EffectEngineQT_HEADERS})
qt4_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress") qt4_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} OPTIONS "-no-compress")
endif(ENABLE_QT5) endif()
add_library(effectengine add_library(effectengine
${EffectEngineHEADERS} ${EffectEngineHEADERS}
${EffectEngineQT_HEADERS} ${EffectEngineQT_HEADERS}
${EffectEngineHEADERS_MOC} ${EffectEngineHEADERS_MOC}
${EffectEngine_RESOURCES_RCC} ${EffectEngine_RESOURCES_RCC}
${EffectEngineSOURCES} ${EffectEngineSOURCES}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(effectengine Widgets) qt5_use_modules(effectengine Widgets)
endif(ENABLE_QT5) endif()
target_link_libraries(effectengine target_link_libraries(effectengine
hyperion hyperion
jsoncpp jsoncpp
${QT_LIBRARIES} ${QT_LIBRARIES}
${PYTHON_LIBRARIES}) ${PYTHON_LIBRARIES})

View File

@ -7,12 +7,12 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic)
SET(AmlogicQT_HEADERS ${CURRENT_HEADER_DIR}/AmlogicWrapper.h) SET(AmlogicQT_HEADERS ${CURRENT_HEADER_DIR}/AmlogicWrapper.h)
SET(AmlogicHEADERS SET(AmlogicHEADERS
${CURRENT_HEADER_DIR}/AmlogicGrabber.h ${CURRENT_HEADER_DIR}/AmlogicGrabber.h
) )
SET(AmlogicSOURCES SET(AmlogicSOURCES
${CURRENT_SOURCE_DIR}/AmlogicWrapper.cpp ${CURRENT_SOURCE_DIR}/AmlogicWrapper.cpp
${CURRENT_SOURCE_DIR}/AmlogicGrabber.cpp ${CURRENT_SOURCE_DIR}/AmlogicGrabber.cpp
) )
if(ENABLE_QT5) if(ENABLE_QT5)
@ -22,12 +22,12 @@ QT4_WRAP_CPP(AmlogicHEADERS_MOC ${AmlogicQT_HEADERS})
endif(ENABLE_QT5) endif(ENABLE_QT5)
add_library(amlogic-grabber add_library(amlogic-grabber
${AmlogicHEADERS} ${AmlogicHEADERS}
${AmlogicQT_HEADERS} ${AmlogicQT_HEADERS}
${AmlogicHEADERS_MOC} ${AmlogicHEADERS_MOC}
${AmlogicSOURCES} ${AmlogicSOURCES}
) )
target_link_libraries(amlogic-grabber target_link_libraries(amlogic-grabber
hyperion hyperion
${QT_LIBRARIES}) ${QT_LIBRARIES})

View File

@ -23,9 +23,9 @@ SET(DispmanxGrabberSOURCES
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS}) QT5_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS})
else(ENABLE_QT5) else()
QT4_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS}) QT4_WRAP_CPP(DispmanxGrabberHEADERS_MOC ${DispmanxGrabberQT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(dispmanx-grabber add_library(dispmanx-grabber
${DispmanxGrabberHEADERS} ${DispmanxGrabberHEADERS}

View File

@ -9,31 +9,31 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/framebuffer)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(FramebufferGrabberQT_HEADERS SET(FramebufferGrabberQT_HEADERS
${CURRENT_HEADER_DIR}/FramebufferWrapper.h ${CURRENT_HEADER_DIR}/FramebufferWrapper.h
) )
SET(FramebufferGrabberHEADERS SET(FramebufferGrabberHEADERS
${CURRENT_HEADER_DIR}/FramebufferFrameGrabber.h ${CURRENT_HEADER_DIR}/FramebufferFrameGrabber.h
) )
SET(FramebufferGrabberSOURCES SET(FramebufferGrabberSOURCES
${CURRENT_SOURCE_DIR}/FramebufferWrapper.cpp ${CURRENT_SOURCE_DIR}/FramebufferWrapper.cpp
${CURRENT_SOURCE_DIR}/FramebufferFrameGrabber.cpp ${CURRENT_SOURCE_DIR}/FramebufferFrameGrabber.cpp
) )
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS}) QT5_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS})
else(ENABLE_QT5) else()
QT4_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS}) QT4_WRAP_CPP(FramebufferGrabberHEADERS_MOC ${FramebufferGrabberQT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(framebuffer-grabber add_library(framebuffer-grabber
${FramebufferGrabberHEADERS} ${FramebufferGrabberHEADERS}
${FramebufferGrabberQT_HEADERS} ${FramebufferGrabberQT_HEADERS}
${FramebufferGrabberHEADERS_MOC} ${FramebufferGrabberHEADERS_MOC}
${FramebufferGrabberSOURCES} ${FramebufferGrabberSOURCES}
) )
target_link_libraries(framebuffer-grabber target_link_libraries(framebuffer-grabber
hyperion hyperion
${QT_LIBRARIES}) ${QT_LIBRARIES})

View File

@ -4,31 +4,31 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/osx)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(OsxGrabberQT_HEADERS SET(OsxGrabberQT_HEADERS
${CURRENT_HEADER_DIR}/OsxWrapper.h ${CURRENT_HEADER_DIR}/OsxWrapper.h
) )
SET(OsxGrabberHEADERS SET(OsxGrabberHEADERS
${CURRENT_HEADER_DIR}/OsxFrameGrabber.h ${CURRENT_HEADER_DIR}/OsxFrameGrabber.h
) )
SET(OsxGrabberSOURCES SET(OsxGrabberSOURCES
${CURRENT_SOURCE_DIR}/OsxWrapper.cpp ${CURRENT_SOURCE_DIR}/OsxWrapper.cpp
${CURRENT_SOURCE_DIR}/OsxFrameGrabber.cpp ${CURRENT_SOURCE_DIR}/OsxFrameGrabber.cpp
) )
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS}) QT5_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS})
else(ENABLE_QT5) else()
QT4_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS}) QT4_WRAP_CPP(OsxGrabberHEADERS_MOC ${OsxGrabberQT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(osx-grabber add_library(osx-grabber
${OsxGrabberHEADERS} ${OsxGrabberHEADERS}
${OsxGrabberQT_HEADERS} ${OsxGrabberQT_HEADERS}
${OsxGrabberHEADERS_MOC} ${OsxGrabberHEADERS_MOC}
${OsxGrabberSOURCES} ${OsxGrabberSOURCES}
) )
target_link_libraries(osx-grabber target_link_libraries(osx-grabber
hyperion hyperion
${QT_LIBRARIES}) ${QT_LIBRARIES})

View File

@ -3,30 +3,30 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/v4l2) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/v4l2)
SET(V4L2_QT_HEADERS SET(V4L2_QT_HEADERS
${CURRENT_HEADER_DIR}/V4L2Grabber.h ${CURRENT_HEADER_DIR}/V4L2Grabber.h
${CURRENT_HEADER_DIR}/V4L2Wrapper.h ${CURRENT_HEADER_DIR}/V4L2Wrapper.h
) )
SET(V4L2_HEADERS SET(V4L2_HEADERS
${CURRENT_HEADER_DIR}/VideoStandard.h ${CURRENT_HEADER_DIR}/VideoStandard.h
) )
SET(V4L2_SOURCES SET(V4L2_SOURCES
${CURRENT_SOURCE_DIR}/V4L2Grabber.cpp ${CURRENT_SOURCE_DIR}/V4L2Grabber.cpp
${CURRENT_SOURCE_DIR}/V4L2Wrapper.cpp ${CURRENT_SOURCE_DIR}/V4L2Wrapper.cpp
) )
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS}) QT5_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS})
else(ENABLE_QT5) else()
QT4_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS}) QT4_WRAP_CPP(V4L2_HEADERS_MOC ${V4L2_QT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(v4l2-grabber add_library(v4l2-grabber
${V4L2_HEADERS} ${V4L2_HEADERS}
${V4L2_SOURCES} ${V4L2_SOURCES}
${V4L2_QT_HEADERS} ${V4L2_QT_HEADERS}
${V4L2_HEADERS_MOC} ${V4L2_HEADERS_MOC}
) )
if(ENABLE_QT5) if(ENABLE_QT5)

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -6,107 +6,108 @@
#include <grabber/X11Grabber.h> #include <grabber/X11Grabber.h>
X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) : X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) :
_imageResampler(), _imageResampler(),
_useXGetImage(useXGetImage), _useXGetImage(useXGetImage),
_cropLeft(cropLeft), _cropLeft(cropLeft),
_cropRight(cropRight), _cropRight(cropRight),
_cropTop(cropTop), _cropTop(cropTop),
_cropBottom(cropBottom), _cropBottom(cropBottom),
_x11Display(nullptr), _x11Display(nullptr),
_pixmap(None), _pixmap(None),
_srcFormat(nullptr), _srcFormat(nullptr),
_dstFormat(nullptr), _dstFormat(nullptr),
_srcPicture(None), _srcPicture(None),
_dstPicture(None), _dstPicture(None),
_screenWidth(0), _screenWidth(0),
_screenHeight(0), _screenHeight(0),
_croppedWidth(0), _croppedWidth(0),
_croppedHeight(0), _croppedHeight(0),
_image(0,0) _image(0,0)
{ {
_imageResampler.setHorizontalPixelDecimation(horizontalPixelDecimation); _imageResampler.setHorizontalPixelDecimation(horizontalPixelDecimation);
_imageResampler.setVerticalPixelDecimation(verticalPixelDecimation); _imageResampler.setVerticalPixelDecimation(verticalPixelDecimation);
_imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XShmGetImage or XGetImage _imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XShmGetImage or XGetImage
memset(&_pictAttr, 0, sizeof(_pictAttr)); memset(&_pictAttr, 0, sizeof(_pictAttr));
_pictAttr.repeat = RepeatNone; _pictAttr.repeat = RepeatNone;
} }
X11Grabber::~X11Grabber() X11Grabber::~X11Grabber()
{ {
if (_x11Display != nullptr) if (_x11Display != nullptr)
{ {
freeResources(); freeResources();
XCloseDisplay(_x11Display); XCloseDisplay(_x11Display);
} }
} }
void X11Grabber::freeResources() void X11Grabber::freeResources()
{ {
// Cleanup allocated resources of the X11 grab // Cleanup allocated resources of the X11 grab
XDestroyImage(_xImage); XDestroyImage(_xImage);
if(_XShmAvailable && !_useXGetImage) { if(_XShmAvailable && !_useXGetImage) {
XShmDetach(_x11Display, &_shminfo); XShmDetach(_x11Display, &_shminfo);
shmdt(_shminfo.shmaddr); shmdt(_shminfo.shmaddr);
shmctl(_shminfo.shmid, IPC_RMID, 0); shmctl(_shminfo.shmid, IPC_RMID, 0);
} }
if (_XRenderAvailable && !_useXGetImage) { if (_XRenderAvailable && !_useXGetImage) {
XRenderFreePicture(_x11Display, _srcPicture); XRenderFreePicture(_x11Display, _srcPicture);
XRenderFreePicture(_x11Display, _dstPicture); XRenderFreePicture(_x11Display, _dstPicture);
XFreePixmap(_x11Display, _pixmap); XFreePixmap(_x11Display, _pixmap);
} }
} }
void X11Grabber::setupResources() void X11Grabber::setupResources()
{ {
if(_XShmAvailable && !_useXGetImage) { if(_XShmAvailable && !_useXGetImage) {
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _xImage = XShmCreateImage(_x11Display, _windowAttr.visual,
_windowAttr.depth, ZPixmap, NULL, &_shminfo, _windowAttr.depth, ZPixmap, NULL, &_shminfo,
_croppedWidth, _croppedHeight); _croppedWidth, _croppedHeight);
_shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777); _shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
_xImage->data = (char*)shmat(_shminfo.shmid,0,0); _xImage->data = (char*)shmat(_shminfo.shmid,0,0);
_shminfo.shmaddr = _xImage->data; _shminfo.shmaddr = _xImage->data;
_shminfo.readOnly = False; _shminfo.readOnly = False;
XShmAttach(_x11Display, &_shminfo); XShmAttach(_x11Display, &_shminfo);
}
if (_XRenderAvailable && !_useXGetImage) {
if(_XShmPixmapAvailable) {
_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth);
} else {
_pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth);
} }
_srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual); if (_XRenderAvailable && !_useXGetImage) {
_dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual); if(_XShmPixmapAvailable) {
_srcPicture = XRenderCreatePicture(_x11Display, _window, _srcFormat, CPRepeat, &_pictAttr); _pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth);
_dstPicture = XRenderCreatePicture(_x11Display, _pixmap, _dstFormat, CPRepeat, &_pictAttr); } else {
XRenderSetPictureFilter(_x11Display, _srcPicture, "bilinear", NULL, 0); _pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth);
} }
_srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
_dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
_srcPicture = XRenderCreatePicture(_x11Display, _window, _srcFormat, CPRepeat, &_pictAttr);
_dstPicture = XRenderCreatePicture(_x11Display, _pixmap, _dstFormat, CPRepeat, &_pictAttr);
XRenderSetPictureFilter(_x11Display, _srcPicture, "bilinear", NULL, 0);
}
} }
bool X11Grabber::Setup() bool X11Grabber::Setup()
{ {
_x11Display = XOpenDisplay(NULL); _x11Display = XOpenDisplay(NULL);
if (_x11Display == nullptr) if (_x11Display == nullptr)
{ {
std::cerr << "X11GRABBER ERROR: Unable to open display"; std::cerr << "X11GRABBER ERROR: Unable to open display";
if (getenv("DISPLAY")) if (getenv("DISPLAY")) {
std::cerr << " " << std::string(getenv("DISPLAY")) << std::endl; std::cerr << " " << std::string(getenv("DISPLAY")) << std::endl;
else } else {
std::cerr << ". DISPLAY environment variable not set" << std::endl; std::cerr << ". DISPLAY environment variable not set" << std::endl;
return false; }
} return false;
}
_window = DefaultRootWindow(_x11Display); _window = DefaultRootWindow(_x11Display);
int dummy, pixmaps_supported; int dummy, pixmaps_supported;
_XRenderAvailable = XRenderQueryExtension(_x11Display, &dummy, &dummy); _XRenderAvailable = XRenderQueryExtension(_x11Display, &dummy, &dummy);
_XShmAvailable = XShmQueryExtension(_x11Display); _XShmAvailable = XShmQueryExtension(_x11Display);
XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported); XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported);
_XShmPixmapAvailable = pixmaps_supported && XShmPixmapFormat(_x11Display) == ZPixmap; _XShmPixmapAvailable = pixmaps_supported && XShmPixmapFormat(_x11Display) == ZPixmap;
return true; return true;
} }
Image<ColorRgb> & X11Grabber::grab() Image<ColorRgb> & X11Grabber::grab()
@ -130,74 +131,73 @@ Image<ColorRgb> & X11Grabber::grab()
XSync(_x11Display, False); XSync(_x11Display, False);
if (_XShmAvailable) { if (_XShmAvailable) {
XShmGetImage(_x11Display, _pixmap, _xImage, 0, 0, AllPlanes); XShmGetImage(_x11Display, _pixmap, _xImage, 0, 0, AllPlanes);
} else {
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
}
} else { } else {
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); if (_XShmAvailable && !_useXGetImage) {
XShmGetImage(_x11Display, _window, _xImage, _cropLeft, _cropTop, AllPlanes);
} else {
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap);
}
} }
} else {
if (_XShmAvailable && !_useXGetImage) { if (_xImage == nullptr)
XShmGetImage(_x11Display, _window, _xImage, _cropLeft, _cropTop, AllPlanes); {
} else { std::cerr << "X11GRABBER ERROR: Grab failed" << std::endl;
_xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); return _image;
} }
}
if (_xImage == nullptr) _imageResampler.processImage(reinterpret_cast<const uint8_t *>(_xImage->data), _xImage->width, _xImage->height, _xImage->bytes_per_line, PIXELFORMAT_BGR32, _image);
{
std::cerr << "X11GRABBER ERROR: Grab failed" << std::endl;
return _image;
}
_imageResampler.processImage(reinterpret_cast<const uint8_t *>(_xImage->data), _xImage->width, _xImage->height, _xImage->bytes_per_line, PIXELFORMAT_BGR32, _image); return _image;
return _image;
} }
int X11Grabber::updateScreenDimensions() int X11Grabber::updateScreenDimensions()
{ {
const Status status = XGetWindowAttributes(_x11Display, _window, &_windowAttr); const Status status = XGetWindowAttributes(_x11Display, _window, &_windowAttr);
if (status == 0) if (status == 0)
{ {
std::cerr << "X11GRABBER ERROR: Failed to obtain window attributes" << std::endl; std::cerr << "X11GRABBER ERROR: Failed to obtain window attributes" << std::endl;
return -1; return -1;
} }
if (_screenWidth == unsigned(_windowAttr.width) && _screenHeight == unsigned(_windowAttr.height)) if (_screenWidth == unsigned(_windowAttr.width) && _screenHeight == unsigned(_windowAttr.height))
{ {
// No update required // No update required
return 0; return 0;
} }
std::cout << "X11GRABBER INFO: Update of screen resolution: [" << _screenWidth << "x" << _screenHeight <<"] => "; std::cout << "X11GRABBER INFO: Update of screen resolution: [" << _screenWidth << "x" << _screenHeight <<"] => ";
if (_screenWidth || _screenHeight) if (_screenWidth || _screenHeight) {
freeResources(); freeResources();
}
_screenWidth = _windowAttr.width; _screenWidth = _windowAttr.width;
_screenHeight = _windowAttr.height; _screenHeight = _windowAttr.height;
std::cout << "[" << _screenWidth << "x" << _screenHeight <<"]" << std::endl; std::cout << "[" << _screenWidth << "x" << _screenHeight <<"]" << std::endl;
if (_screenWidth > unsigned(_cropLeft + _cropRight)) _croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight))
_croppedWidth = _screenWidth - _cropLeft - _cropRight; ? (_screenWidth - _cropLeft - _cropRight)
else : _screenWidth;
_croppedWidth = _screenWidth;
if (_screenHeight > unsigned(_cropTop + _cropBottom)) _croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom))
_croppedHeight = _screenHeight - _cropTop - _cropBottom; ? (_screenHeight - _cropTop - _cropBottom)
else : (_croppedHeight = _screenHeight);
_croppedHeight = _screenHeight;
std::cout << "X11GRABBER INFO: Using "; std::cout << "X11GRABBER INFO: Using ";
if (_XRenderAvailable && !_useXGetImage) { if (_XRenderAvailable && !_useXGetImage) {
std::cout << "XRender for grabbing" << std::endl; std::cout << "XRender for grabbing" << std::endl;
} else { } else {
std::cout << "XGetImage for grabbing" << std::endl; std::cout << "XGetImage for grabbing" << std::endl;
} }
setupResources(); setupResources();
return 0; return 0;
} }

View File

@ -5,68 +5,68 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/hyperion)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(Hyperion_QT_HEADERS SET(Hyperion_QT_HEADERS
${CURRENT_HEADER_DIR}/Hyperion.h ${CURRENT_HEADER_DIR}/Hyperion.h
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h
) )
SET(Hyperion_HEADERS SET(Hyperion_HEADERS
${CURRENT_HEADER_DIR}/ImageProcessor.h ${CURRENT_HEADER_DIR}/ImageProcessor.h
${CURRENT_HEADER_DIR}/ImageProcessorFactory.h ${CURRENT_HEADER_DIR}/ImageProcessorFactory.h
${CURRENT_HEADER_DIR}/ImageToLedsMap.h ${CURRENT_HEADER_DIR}/ImageToLedsMap.h
${CURRENT_HEADER_DIR}/LedString.h ${CURRENT_HEADER_DIR}/LedString.h
${CURRENT_HEADER_DIR}/PriorityMuxer.h ${CURRENT_HEADER_DIR}/PriorityMuxer.h
${CURRENT_SOURCE_DIR}/MultiColorTransform.h ${CURRENT_SOURCE_DIR}/MultiColorTransform.h
${CURRENT_SOURCE_DIR}/MultiColorCorrection.h ${CURRENT_SOURCE_DIR}/MultiColorCorrection.h
${CURRENT_SOURCE_DIR}/MultiColorAdjustment.h ${CURRENT_SOURCE_DIR}/MultiColorAdjustment.h
${CURRENT_HEADER_DIR}/MessageForwarder.h ${CURRENT_HEADER_DIR}/MessageForwarder.h
) )
SET(Hyperion_SOURCES SET(Hyperion_SOURCES
${CURRENT_SOURCE_DIR}/Hyperion.cpp ${CURRENT_SOURCE_DIR}/Hyperion.cpp
${CURRENT_SOURCE_DIR}/ImageProcessor.cpp ${CURRENT_SOURCE_DIR}/ImageProcessor.cpp
${CURRENT_SOURCE_DIR}/ImageProcessorFactory.cpp ${CURRENT_SOURCE_DIR}/ImageProcessorFactory.cpp
${CURRENT_SOURCE_DIR}/LedString.cpp ${CURRENT_SOURCE_DIR}/LedString.cpp
${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp ${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp
${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp ${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp
${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp ${CURRENT_SOURCE_DIR}/MultiColorTransform.cpp
${CURRENT_SOURCE_DIR}/MultiColorCorrection.cpp ${CURRENT_SOURCE_DIR}/MultiColorCorrection.cpp
${CURRENT_SOURCE_DIR}/MultiColorAdjustment.cpp ${CURRENT_SOURCE_DIR}/MultiColorAdjustment.cpp
${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp
${CURRENT_SOURCE_DIR}/MessageForwarder.cpp ${CURRENT_SOURCE_DIR}/MessageForwarder.cpp
) )
set(Hyperion_RESOURCES SET(Hyperion_RESOURCES
${CURRENT_SOURCE_DIR}/resource.qrc ${CURRENT_SOURCE_DIR}/resource.qrc
) )
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS}) QT5_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS})
QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress")
else(ENABLE_QT5) else()
QT4_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS}) QT4_WRAP_CPP(Hyperion_HEADERS_MOC ${Hyperion_QT_HEADERS})
QT4_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") QT4_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress")
endif(ENABLE_QT5) endif()
add_library(hyperion add_library(hyperion
${Hyperion_HEADERS} ${Hyperion_HEADERS}
${Hyperion_QT_HEADERS} ${Hyperion_QT_HEADERS}
${Hyperion_HEADERS_MOC} ${Hyperion_HEADERS_MOC}
${Hyperion_SOURCES} ${Hyperion_SOURCES}
${Hyperion_RESOURCES_RCC} ${Hyperion_RESOURCES_RCC}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(hyperion Widgets) qt5_use_modules(hyperion Widgets)
endif(ENABLE_QT5) endif()
target_link_libraries(hyperion target_link_libraries(hyperion
blackborder blackborder
hyperion-utils hyperion-utils
leddevice leddevice
effectengine effectengine
serialport serialport
${QT_LIBRARIES} ${QT_LIBRARIES}
) )

View File

@ -5,44 +5,44 @@ set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/jsonserver)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
set(JsonServer_QT_HEADERS set(JsonServer_QT_HEADERS
${CURRENT_HEADER_DIR}/JsonServer.h ${CURRENT_HEADER_DIR}/JsonServer.h
${CURRENT_SOURCE_DIR}/JsonClientConnection.h ${CURRENT_SOURCE_DIR}/JsonClientConnection.h
) )
set(JsonServer_HEADERS set(JsonServer_HEADERS
) )
set(JsonServer_SOURCES set(JsonServer_SOURCES
${CURRENT_SOURCE_DIR}/JsonServer.cpp ${CURRENT_SOURCE_DIR}/JsonServer.cpp
${CURRENT_SOURCE_DIR}/JsonClientConnection.cpp ${CURRENT_SOURCE_DIR}/JsonClientConnection.cpp
) )
set(JsonServer_RESOURCES set(JsonServer_RESOURCES
${CURRENT_SOURCE_DIR}/JsonSchemas.qrc ${CURRENT_SOURCE_DIR}/JsonSchemas.qrc
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS}) qt5_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS})
qt5_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress") qt5_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress")
else(ENABLE_QT5) else()
qt4_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS}) qt4_wrap_cpp(JsonServer_HEADERS_MOC ${JsonServer_QT_HEADERS})
qt4_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress") qt4_add_resources(JsonServer_RESOURCES_RCC ${JsonServer_RESOURCES} OPTIONS "-no-compress")
endif(ENABLE_QT5) endif()
add_library(jsonserver add_library(jsonserver
${JsonServer_HEADERS} ${JsonServer_HEADERS}
${JsonServer_QT_HEADERS} ${JsonServer_QT_HEADERS}
${JsonServer_SOURCES} ${JsonServer_SOURCES}
${JsonServer_RESOURCES} ${JsonServer_RESOURCES}
${JsonServer_HEADERS_MOC} ${JsonServer_HEADERS_MOC}
${JsonServer_RESOURCES_RCC} ${JsonServer_RESOURCES_RCC}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(jsonserver Widgets Network) qt5_use_modules(jsonserver Widgets Network)
endif(ENABLE_QT5) endif()
target_link_libraries(jsonserver target_link_libraries(jsonserver
hyperion hyperion
hyperion-utils hyperion-utils
jsoncpp jsoncpp
${QT_LIBRARIES}) ${QT_LIBRARIES})

View File

@ -8,143 +8,144 @@ find_package(libusb-1.0 REQUIRED)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
include_directories( include_directories(
../../include/hidapi ../../include/hidapi
${LIBUSB_1_INCLUDE_DIRS}) # for Lightpack device ${LIBUSB_1_INCLUDE_DIRS}
) # for Lightpack device
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(Leddevice_QT_HEADERS SET(Leddevice_QT_HEADERS
${CURRENT_SOURCE_DIR}/LedRs232Device.h ${CURRENT_SOURCE_DIR}/LedRs232Device.h
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.h
${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.h
${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h
${CURRENT_SOURCE_DIR}/LedHIDDevice.h ${CURRENT_SOURCE_DIR}/LedHIDDevice.h
${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h
${CURRENT_SOURCE_DIR}/LedDeviceFile.h ${CURRENT_SOURCE_DIR}/LedDeviceFile.h
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
) )
SET(Leddevice_HEADERS SET(Leddevice_HEADERS
${CURRENT_HEADER_DIR}/LedDevice.h ${CURRENT_HEADER_DIR}/LedDevice.h
${CURRENT_HEADER_DIR}/LedDeviceFactory.h ${CURRENT_HEADER_DIR}/LedDeviceFactory.h
${CURRENT_SOURCE_DIR}/LedDeviceLightpack.h ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.h
${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.h ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.h
${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h ${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.h
${CURRENT_SOURCE_DIR}/LedDeviceSedu.h ${CURRENT_SOURCE_DIR}/LedDeviceSedu.h
${CURRENT_SOURCE_DIR}/LedDeviceFile.h ${CURRENT_SOURCE_DIR}/LedDeviceFile.h
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h
${CURRENT_SOURCE_DIR}/LedDeviceUdp.h ${CURRENT_SOURCE_DIR}/LedDeviceUdp.h
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h
${CURRENT_SOURCE_DIR}/LedDeviceTpm2.h ${CURRENT_SOURCE_DIR}/LedDeviceTpm2.h
${CURRENT_SOURCE_DIR}/LedDeviceAtmo.h ${CURRENT_SOURCE_DIR}/LedDeviceAtmo.h
) )
SET(Leddevice_SOURCES SET(Leddevice_SOURCES
${CURRENT_SOURCE_DIR}/LedDeviceFactory.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFactory.cpp
${CURRENT_SOURCE_DIR}/LedRs232Device.cpp ${CURRENT_SOURCE_DIR}/LedRs232Device.cpp
${CURRENT_SOURCE_DIR}/LedHIDDevice.cpp ${CURRENT_SOURCE_DIR}/LedHIDDevice.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalightApa102.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAmbiLed.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.cpp
${CURRENT_SOURCE_DIR}/LedDeviceRawHID.cpp ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.cpp
${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.cpp
${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.cpp
${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.cpp
${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.cpp ${CURRENT_SOURCE_DIR}/LedDevicePiBlaster.cpp
${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp ${CURRENT_SOURCE_DIR}/LedDeviceSedu.cpp
${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFile.cpp
${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.cpp
${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceUdp.cpp
${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp
${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.cpp ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.cpp
${CURRENT_SOURCE_DIR}/LedDeviceTpm2.cpp ${CURRENT_SOURCE_DIR}/LedDeviceTpm2.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAtmo.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAtmo.cpp
) )
if(ENABLE_SPIDEV) if(ENABLE_SPIDEV)
SET(Leddevice_HEADERS SET(Leddevice_HEADERS
${Leddevice_HEADERS} ${Leddevice_HEADERS}
${CURRENT_SOURCE_DIR}/LedSpiDevice.h ${CURRENT_SOURCE_DIR}/LedSpiDevice.h
${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.h ${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.h
${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.h ${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.h
${CURRENT_SOURCE_DIR}/LedDeviceP9813.h ${CURRENT_SOURCE_DIR}/LedDeviceP9813.h
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h ${CURRENT_SOURCE_DIR}/LedDeviceWs2801.h
${CURRENT_SOURCE_DIR}/LedDeviceWs2812SPI.h ${CURRENT_SOURCE_DIR}/LedDeviceWs2812SPI.h
${CURRENT_SOURCE_DIR}/LedDeviceAPA102.h ${CURRENT_SOURCE_DIR}/LedDeviceAPA102.h
) )
SET(Leddevice_SOURCES SET(Leddevice_SOURCES
${Leddevice_SOURCES} ${Leddevice_SOURCES}
${CURRENT_SOURCE_DIR}/LedSpiDevice.cpp ${CURRENT_SOURCE_DIR}/LedSpiDevice.cpp
${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLpd6803.cpp
${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.cpp ${CURRENT_SOURCE_DIR}/LedDeviceLpd8806.cpp
${CURRENT_SOURCE_DIR}/LedDeviceP9813.cpp ${CURRENT_SOURCE_DIR}/LedDeviceP9813.cpp
${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp ${CURRENT_SOURCE_DIR}/LedDeviceWs2801.cpp
${CURRENT_SOURCE_DIR}/LedDeviceWs2812SPI.cpp ${CURRENT_SOURCE_DIR}/LedDeviceWs2812SPI.cpp
${CURRENT_SOURCE_DIR}/LedDeviceAPA102.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAPA102.cpp
) )
endif(ENABLE_SPIDEV) endif()
if(ENABLE_WS2812BPWM) if(ENABLE_WS2812BPWM)
SET(Leddevice_HEADERS SET(Leddevice_HEADERS
${Leddevice_HEADERS} ${Leddevice_HEADERS}
${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.h ${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.h
) )
SET(Leddevice_SOURCES SET(Leddevice_SOURCES
${Leddevice_SOURCES} ${Leddevice_SOURCES}
${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.cpp ${CURRENT_SOURCE_DIR}/LedDeviceWS2812b.cpp
) )
endif(ENABLE_WS2812BPWM) endif()
if(ENABLE_WS281XPWM) if(ENABLE_WS281XPWM)
include_directories(../../dependencies/external/rpi_ws281x) include_directories(../../dependencies/external/rpi_ws281x)
SET(Leddevice_HEADERS SET(Leddevice_HEADERS
${Leddevice_HEADERS} ${Leddevice_HEADERS}
${CURRENT_SOURCE_DIR}/LedDeviceWS281x.h ${CURRENT_SOURCE_DIR}/LedDeviceWS281x.h
) )
SET(Leddevice_SOURCES SET(Leddevice_SOURCES
${Leddevice_SOURCES} ${Leddevice_SOURCES}
${CURRENT_SOURCE_DIR}/LedDeviceWS281x.cpp ${CURRENT_SOURCE_DIR}/LedDeviceWS281x.cpp
) )
endif(ENABLE_WS281XPWM) endif()
if(ENABLE_TINKERFORGE) if(ENABLE_TINKERFORGE)
SET(Leddevice_HEADERS SET(Leddevice_HEADERS
${Leddevice_HEADERS} ${Leddevice_HEADERS}
${CURRENT_SOURCE_DIR}/LedDeviceTinkerforge.h ${CURRENT_SOURCE_DIR}/LedDeviceTinkerforge.h
) )
SET(Leddevice_SOURCES SET(Leddevice_SOURCES
${Leddevice_SOURCES} ${Leddevice_SOURCES}
${CURRENT_SOURCE_DIR}/LedDeviceTinkerforge.cpp ${CURRENT_SOURCE_DIR}/LedDeviceTinkerforge.cpp
) )
endif(ENABLE_TINKERFORGE) endif()
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS}) QT5_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS})
else(ENABLE_QT5) else()
QT4_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS}) QT4_WRAP_CPP(Leddevice_HEADERS_MOC ${Leddevice_QT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(leddevice add_library(leddevice
${Leddevice_HEADERS} ${Leddevice_HEADERS}
${Leddevice_QT_HEADERS} ${Leddevice_QT_HEADERS}
${Leddevice_HEADERS_MOC} ${Leddevice_HEADERS_MOC}
${Leddevice_SOURCES} ${Leddevice_SOURCES}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(leddevice Widgets Network) qt5_use_modules(leddevice Widgets Network)
endif(ENABLE_QT5) endif()
target_link_libraries(leddevice target_link_libraries(leddevice
hyperion-utils hyperion-utils
serialport serialport
${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev ${LIBUSB_1_LIBRARIES} #apt-get install libusb-1.0-0-dev
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_THREAD_LIBS_INIT}
${QT_LIBRARIES} ${QT_LIBRARIES}

View File

@ -12,141 +12,147 @@
#include <set> #include <set>
AtmoOrbLight::AtmoOrbLight(unsigned int id) { AtmoOrbLight::AtmoOrbLight(unsigned int id) {
// Not implemented // Not implemented
} }
LedDeviceAtmoOrb::LedDeviceAtmoOrb(const std::string &output, bool useOrbSmoothing, LedDeviceAtmoOrb::LedDeviceAtmoOrb(
int transitiontime, int skipSmoothingDiff, int port, int numLeds, std::vector<unsigned int> orbIds) : const std::string &output,
multicastGroup(output.c_str()), useOrbSmoothing(useOrbSmoothing), transitiontime(transitiontime), skipSmoothingDiff(skipSmoothingDiff), bool useOrbSmoothing,
multiCastGroupPort(port), numLeds(numLeds), orbIds(orbIds) { int transitiontime,
manager = new QNetworkAccessManager(); int skipSmoothingDiff,
groupAddress = QHostAddress(multicastGroup); int port,
int numLeds,
std::vector<unsigned int> orbIds) :
multicastGroup(output.c_str()), useOrbSmoothing(useOrbSmoothing), transitiontime(transitiontime), skipSmoothingDiff(skipSmoothingDiff),
multiCastGroupPort(port), numLeds(numLeds), orbIds(orbIds)
{
manager = new QNetworkAccessManager();
groupAddress = QHostAddress(multicastGroup);
udpSocket = new QUdpSocket(this); udpSocket = new QUdpSocket(this);
udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); udpSocket->bind(multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress); joinedMulticastgroup = udpSocket->joinMulticastGroup(groupAddress);
} }
int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues) { int LedDeviceAtmoOrb::write(const std::vector <ColorRgb> &ledValues) {
// If not in multicast group return
if (!joinedMulticastgroup) {
return 0;
}
// If not in multicast group return // Command options:
if (!joinedMulticastgroup) { //
return 0; // 1 = force off
} // 2 = use lamp smoothing and validate by Orb ID
// 4 = validate by Orb ID
// Command options: // When setting useOrbSmoothing = true it's recommended to disable Hyperion's own smoothing as it will conflict (double smoothing)
// int commandType = 4;
// 1 = force off if(useOrbSmoothing)
// 2 = use lamp smoothing and validate by Orb ID {
// 4 = validate by Orb ID commandType = 2;
}
// When setting useOrbSmoothing = true it's recommended to disable Hyperion's own smoothing as it will conflict (double smoothing) // Iterate through colors and set Orb color
int commandType = 4; // Start off with idx 1 as 0 is reserved for controlling all orbs at once
if(useOrbSmoothing) unsigned int idx = 1;
{
commandType = 2;
}
// Iterate through colors and set Orb color for (const ColorRgb &color : ledValues) {
// Start off with idx 1 as 0 is reserved for controlling all orbs at once // Retrieve last send colors
unsigned int idx = 1; int lastRed = lastColorRedMap[idx];
int lastGreen = lastColorGreenMap[idx];
int lastBlue = lastColorBlueMap[idx];
for (const ColorRgb &color : ledValues) { // If color difference is higher than skipSmoothingDiff than we skip Orb smoothing (if enabled) and send it right away
// Retrieve last send colors if ((skipSmoothingDiff != 0 && useOrbSmoothing) && (abs(color.red - lastRed) >= skipSmoothingDiff || abs(color.blue - lastBlue) >= skipSmoothingDiff ||
int lastRed = lastColorRedMap[idx]; abs(color.green - lastGreen) >= skipSmoothingDiff))
int lastGreen = lastColorGreenMap[idx]; {
int lastBlue = lastColorBlueMap[idx]; // Skip Orb smoothing when using (command type 4)
for (unsigned int i = 0; i < orbIds.size(); i++) {
if (orbIds[i] == idx) {
setColor(idx, color, 4);
}
}
}
else {
// Send color
for (unsigned int i = 0; i < orbIds.size(); i++) {
if (orbIds[i] == idx) {
setColor(idx, color, commandType);
}
}
}
// If color difference is higher than skipSmoothingDiff than we skip Orb smoothing (if enabled) and send it right away // Store last colors send for light id
if ((skipSmoothingDiff != 0 && useOrbSmoothing) && (abs(color.red - lastRed) >= skipSmoothingDiff || abs(color.blue - lastBlue) >= skipSmoothingDiff || lastColorRedMap[idx] = color.red;
abs(color.green - lastGreen) >= skipSmoothingDiff)) lastColorGreenMap[idx] = color.green;
{ lastColorBlueMap[idx] = color.blue;
// Skip Orb smoothing when using (command type 4)
for (unsigned int i = 0; i < orbIds.size(); i++) {
if (orbIds[i] == idx) {
setColor(idx, color, 4);
}
}
}
else {
// Send color
for (unsigned int i = 0; i < orbIds.size(); i++) {
if (orbIds[i] == idx) {
setColor(idx, color, commandType);
}
}
}
// Store last colors send for light id // Next light id.
lastColorRedMap[idx] = color.red; idx++;
lastColorGreenMap[idx] = color.green; }
lastColorBlueMap[idx] = color.blue;
// Next light id. return 0;
idx++;
}
return 0;
} }
void LedDeviceAtmoOrb::setColor(unsigned int orbId, const ColorRgb &color, int commandType) { void LedDeviceAtmoOrb::setColor(unsigned int orbId, const ColorRgb &color, int commandType) {
QByteArray bytes; QByteArray bytes;
bytes.resize(5 + numLeds * 3); bytes.resize(5 + numLeds * 3);
bytes.fill('\0'); bytes.fill('\0');
// Command identifier: C0FFEE // Command identifier: C0FFEE
bytes[0] = 0xC0; bytes[0] = 0xC0;
bytes[1] = 0xFF; bytes[1] = 0xFF;
bytes[2] = 0xEE; bytes[2] = 0xEE;
// Command type // Command type
bytes[3] = commandType; bytes[3] = commandType;
// Orb ID // Orb ID
bytes[4] = orbId; bytes[4] = orbId;
// RED / GREEN / BLUE // RED / GREEN / BLUE
bytes[5] = color.red; bytes[5] = color.red;
bytes[6] = color.green; bytes[6] = color.green;
bytes[7] = color.blue; bytes[7] = color.blue;
sendCommand(bytes); sendCommand(bytes);
} }
void LedDeviceAtmoOrb::sendCommand(const QByteArray &bytes) { void LedDeviceAtmoOrb::sendCommand(const QByteArray &bytes) {
QByteArray datagram = bytes; QByteArray datagram = bytes;
udpSocket->writeDatagram(datagram.data(), datagram.size(), udpSocket->writeDatagram(datagram.data(), datagram.size(),
groupAddress, multiCastGroupPort); groupAddress, multiCastGroupPort);
} }
int LedDeviceAtmoOrb::switchOff() { int LedDeviceAtmoOrb::switchOff() {
for (unsigned int i = 0; i < orbIds.size(); i++) { for (unsigned int i = 0; i < orbIds.size(); i++) {
QByteArray bytes; QByteArray bytes;
bytes.resize(5 + numLeds * 3); bytes.resize(5 + numLeds * 3);
bytes.fill('\0'); bytes.fill('\0');
// Command identifier: C0FFEE // Command identifier: C0FFEE
bytes[0] = 0xC0; bytes[0] = 0xC0;
bytes[1] = 0xFF; bytes[1] = 0xFF;
bytes[2] = 0xEE; bytes[2] = 0xEE;
// Command type // Command type
bytes[3] = 1; bytes[3] = 1;
// Orb ID // Orb ID
bytes[4] = orbIds[i]; bytes[4] = orbIds[i];
// RED / GREEN / BLUE // RED / GREEN / BLUE
bytes[5] = 0; bytes[5] = 0;
bytes[6] = 0; bytes[6] = 0;
bytes[7] = 0; bytes[7] = 0;
sendCommand(bytes); sendCommand(bytes);
} }
return 0; return 0;
} }
LedDeviceAtmoOrb::~LedDeviceAtmoOrb() { LedDeviceAtmoOrb::~LedDeviceAtmoOrb() {
delete manager; delete manager;
} }

View File

@ -16,13 +16,13 @@ class QUdpSocket;
class AtmoOrbLight { class AtmoOrbLight {
public: public:
unsigned int id; unsigned int id;
/// ///
/// Constructs the light. /// Constructs the light.
/// ///
/// @param id the orb id /// @param id the orb id
AtmoOrbLight(unsigned int id); AtmoOrbLight(unsigned int id);
}; };
/** /**
@ -33,100 +33,100 @@ public:
* @author RickDB (github) * @author RickDB (github)
*/ */
class LedDeviceAtmoOrb : public QObject, public LedDevice { class LedDeviceAtmoOrb : public QObject, public LedDevice {
Q_OBJECT Q_OBJECT
public: public:
// Last send color map // Last send color map
QMap<int, int> lastColorRedMap; QMap<int, int> lastColorRedMap;
QMap<int, int> lastColorGreenMap; QMap<int, int> lastColorGreenMap;
QMap<int, int> lastColorBlueMap; QMap<int, int> lastColorBlueMap;
// Multicast status // Multicast status
bool joinedMulticastgroup; bool joinedMulticastgroup;
/// ///
/// Constructs the device. /// Constructs the device.
/// ///
/// @param output is the multicast address of Orbs /// @param output is the multicast address of Orbs
/// ///
/// @param transitiontime is optional and not used at the moment /// @param transitiontime is optional and not used at the moment
/// ///
/// @param useOrbSmoothing use Orbs own (external) smoothing algorithm (default: false) /// @param useOrbSmoothing use Orbs own (external) smoothing algorithm (default: false)
/// ///
/// @param skipSmoothingDiff minimal color (0-255) difference to override smoothing so that if current and previously received colors are higher than set dif we override smoothing /// @param skipSmoothingDiff minimal color (0-255) difference to override smoothing so that if current and previously received colors are higher than set dif we override smoothing
/// ///
/// @param port is the multicast port. /// @param port is the multicast port.
/// ///
/// @param numLeds is the total amount of leds per Orb /// @param numLeds is the total amount of leds per Orb
/// ///
/// @param array containing orb ids /// @param array containing orb ids
/// ///
LedDeviceAtmoOrb(const std::string &output, bool useOrbSmoothing = LedDeviceAtmoOrb(const std::string &output, bool useOrbSmoothing =
false, int transitiontime = 0, int skipSmoothingDiff = 0, int port = 49692, int numLeds = 24, false, int transitiontime = 0, int skipSmoothingDiff = 0, int port = 49692, int numLeds = 24,
std::vector<unsigned int> orbIds = std::vector < unsigned int>()); std::vector<unsigned int> orbIds = std::vector < unsigned int>());
/// ///
/// Destructor of this device /// Destructor of this device
/// ///
virtual ~LedDeviceAtmoOrb(); virtual ~LedDeviceAtmoOrb();
/// ///
/// Sends the given led-color values to the Orbs /// Sends the given led-color values to the Orbs
/// ///
/// @param ledValues The color-value per led /// @param ledValues The color-value per led
/// ///
/// @return Zero on success else negative /// @return Zero on success else negative
/// ///
virtual int write(const std::vector <ColorRgb> &ledValues); virtual int write(const std::vector <ColorRgb> &ledValues);
virtual int switchOff(); virtual int switchOff();
private: private:
/// QNetworkAccessManager object for sending requests. /// QNetworkAccessManager object for sending requests.
QNetworkAccessManager *manager; QNetworkAccessManager *manager;
/// String containing multicast group IP address /// String containing multicast group IP address
QString multicastGroup; QString multicastGroup;
/// use Orbs own (external) smoothing algorithm /// use Orbs own (external) smoothing algorithm
bool useOrbSmoothing; bool useOrbSmoothing;
/// Transition time between colors (not implemented) /// Transition time between colors (not implemented)
int transitiontime; int transitiontime;
// Maximum allowed color difference, will skip Orb (external) smoothing once reached // Maximum allowed color difference, will skip Orb (external) smoothing once reached
int skipSmoothingDiff; int skipSmoothingDiff;
/// Multicast port to send data to /// Multicast port to send data to
int multiCastGroupPort; int multiCastGroupPort;
/// Number of leds in Orb, used to determine buffer size /// Number of leds in Orb, used to determine buffer size
int numLeds; int numLeds;
/// QHostAddress object of multicast group IP address /// QHostAddress object of multicast group IP address
QHostAddress groupAddress; QHostAddress groupAddress;
/// QUdpSocket object used to send data over /// QUdpSocket object used to send data over
QUdpSocket *udpSocket; QUdpSocket *udpSocket;
/// Array of the orb ids. /// Array of the orb ids.
std::vector<unsigned int> orbIds; std::vector<unsigned int> orbIds;
/// ///
/// Set Orbcolor /// Set Orbcolor
/// ///
/// @param orbId the orb id /// @param orbId the orb id
/// ///
/// @param color which color to set /// @param color which color to set
/// ///
/// ///
/// @param commandType which type of command to send (off / smoothing / etc..) /// @param commandType which type of command to send (off / smoothing / etc..)
/// ///
void setColor(unsigned int orbId, const ColorRgb &color, int commandType); void setColor(unsigned int orbId, const ColorRgb &color, int commandType);
/// ///
/// Send Orb command /// Send Orb command
/// ///
/// @param bytes the byte array containing command to send over multicast /// @param bytes the byte array containing command to send over multicast
/// ///
void sendCommand(const QByteArray &bytes); void sendCommand(const QByteArray &bytes);
}; };

View File

@ -16,18 +16,18 @@ LedDeviceTpm2::LedDeviceTpm2(const std::string& outputDevice, const unsigned bau
int LedDeviceTpm2::write(const std::vector<ColorRgb> &ledValues) int LedDeviceTpm2::write(const std::vector<ColorRgb> &ledValues)
{ {
if (_ledBuffer.size() == 0) if (_ledBuffer.size() == 0)
{ {
_ledBuffer.resize(5 + 3*ledValues.size()); _ledBuffer.resize(5 + 3*ledValues.size());
_ledBuffer[0] = 0xC9; // block-start byte _ledBuffer[0] = 0xC9; // block-start byte
_ledBuffer[1] = 0xDA; // DATA frame _ledBuffer[1] = 0xDA; // DATA frame
_ledBuffer[2] = ((3 * ledValues.size()) >> 8) & 0xFF; // frame size high byte _ledBuffer[2] = ((3 * ledValues.size()) >> 8) & 0xFF; // frame size high byte
_ledBuffer[3] = (3 * ledValues.size()) & 0xFF; // frame size low byte _ledBuffer[3] = (3 * ledValues.size()) & 0xFF; // frame size low byte
_ledBuffer.back() = 0x36; // block-end byte _ledBuffer.back() = 0x36; // block-end byte
} }
// write data // write data
memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3); memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * 3);
return writeBytes(_ledBuffer.size(), _ledBuffer.data()); return writeBytes(_ledBuffer.size(), _ledBuffer.data());
} }

View File

@ -25,55 +25,54 @@ LedDeviceUdp::LedDeviceUdp(const std::string& output, const unsigned baudrate, c
//LedDeviceUdp::LedDeviceUdp(const std::string& output, const unsigned baudrate) : //LedDeviceUdp::LedDeviceUdp(const std::string& output, const unsigned baudrate) :
// _ofs(output.empty()?"/home/pi/LedDevice.out":output.c_str()) // _ofs(output.empty()?"/home/pi/LedDevice.out":output.c_str())
{ {
std::string hostname;
std::string hostname; std::string port;
std::string port; ledprotocol = protocol;
ledprotocol = protocol; leds_per_pkt = ((maxPacket-4)/3);
leds_per_pkt = ((maxPacket-4)/3); if (leds_per_pkt <= 0) {
if (leds_per_pkt <= 0) { leds_per_pkt = 200;
leds_per_pkt = 200; }
}
//printf ("leds_per_pkt is %d\n", leds_per_pkt); //printf ("leds_per_pkt is %d\n", leds_per_pkt);
int got_colon=0; int got_colon=0;
for (unsigned int i=0; i<output.length(); i++) { for (unsigned int i=0; i<output.length(); i++) {
if (output[i] == ':') { if (output[i] == ':') {
got_colon++; got_colon++;
} else if (got_colon == 0) { } else if (got_colon == 0) {
hostname+=output[i]; hostname+=output[i];
} else { } else {
port+=output[i]; port+=output[i];
}
} }
} //std::cout << "output " << output << " hostname " << hostname << " port " << port <<std::endl;
//std::cout << "output " << output << " hostname " << hostname << " port " << port <<std::endl; assert(got_colon==1);
assert(got_colon==1);
int rv; int rv;
memset(&hints, 0, sizeof hints); memset(&hints, 0, sizeof hints);
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_DGRAM; hints.ai_socktype = SOCK_DGRAM;
if ((rv = getaddrinfo(hostname.c_str() , port.c_str(), &hints, &servinfo)) != 0) { if ((rv = getaddrinfo(hostname.c_str() , port.c_str(), &hints, &servinfo)) != 0) {
fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv)); fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(rv));
assert(rv==0); assert(rv==0);
} }
// loop through all the results and make a socket // loop through all the results and make a socket
for(p = servinfo; p != NULL; p = p->ai_next) { for(p = servinfo; p != NULL; p = p->ai_next) {
if ((sockfd = socket(p->ai_family, p->ai_socktype, if ((sockfd = socket(p->ai_family, p->ai_socktype,
p->ai_protocol)) == -1) { p->ai_protocol)) == -1) {
perror("talker: socket"); perror("talker: socket");
continue; continue;
} }
break; break;
} }
if (p == NULL) { if (p == NULL) {
fprintf(stderr, "talker: failed to create socket\n"); fprintf(stderr, "talker: failed to create socket\n");
assert(p!=NULL); assert(p!=NULL);
} }
} }
LedDeviceUdp::~LedDeviceUdp() LedDeviceUdp::~LedDeviceUdp()
@ -99,7 +98,7 @@ int LedDeviceUdp::write(const std::vector<ColorRgb> & ledValues)
udpbuffer[i++] = color.green; udpbuffer[i++] = color.green;
udpbuffer[i++] = color.blue; udpbuffer[i++] = color.blue;
} }
//printf ("c.red %d sz c.red %d\n", color.red, sizeof(color.red)); //printf ("c.red %d sz c.red %d\n", color.red, sizeof(color.red));
} }
sendto(sockfd, udpbuffer, i, 0, p->ai_addr, p->ai_addrlen); sendto(sockfd, udpbuffer, i, 0, p->ai_addr, p->ai_addrlen);
} }
@ -153,7 +152,6 @@ int LedDeviceUdp::write(const std::vector<ColorRgb> & ledValues)
udpbuffer[udpPtr++] = ledCtr%256; // low byte udpbuffer[udpPtr++] = ledCtr%256; // low byte
} }
} }
} }
if (ledprotocol == 3) { if (ledprotocol == 3) {
@ -172,7 +170,6 @@ int LedDeviceUdp::write(const std::vector<ColorRgb> & ledValues)
udpbuffer[udpPtr++] = fragment_number++; udpbuffer[udpPtr++] = fragment_number++;
udpbuffer[udpPtr++] = fragments; udpbuffer[udpPtr++] = fragments;
for (const ColorRgb& color : ledValues) for (const ColorRgb& color : ledValues)
{ {
if (udpPtr<4090) { if (udpPtr<4090) {
@ -201,6 +198,6 @@ int LedDeviceUdp::write(const std::vector<ColorRgb> & ledValues)
int LedDeviceUdp::switchOff() int LedDeviceUdp::switchOff()
{ {
// return write(std::vector<ColorRgb>(mLedCount, ColorRgb{0,0,0})); // return write(std::vector<ColorRgb>(mLedCount, ColorRgb{0,0,0}));
return 0; return 0;
} }

View File

@ -86,17 +86,17 @@
// Raspberry Pi low-level peripherals: // Raspberry Pi low-level peripherals:
// http://elinux.org/RPi_Low-level_peripherals // http://elinux.org/RPi_Low-level_peripherals
// //
// Richard Hirst's nice, clean code: // Richard Hirst's nice, clean code:
// https://github.com/richardghirst/PiBits/blob/master/PiFmDma/PiFmDma.c // https://github.com/richardghirst/PiBits/blob/master/PiFmDma/PiFmDma.c
// //
// PWM clock register: // PWM clock register:
// http://www.raspberrypi.org/forums/viewtopic.php?t=8467&p=124620 // http://www.raspberrypi.org/forums/viewtopic.php?t=8467&p=124620
// //
// Simple (because it's in assembly) PWM+DMA setup: // Simple (because it's in assembly) PWM+DMA setup:
// https://github.com/mikedurso/rpi-projects/blob/master/asm-nyancat/rpi-nyancat.s // https://github.com/mikedurso/rpi-projects/blob/master/asm-nyancat/rpi-nyancat.s
// //
// Adafruit's NeoPixel driver: // Adafruit's NeoPixel driver:
// https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp // https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp
// Hyperion includes // Hyperion includes
#include <leddevice/LedDevice.h> #include <leddevice/LedDevice.h>

View File

@ -35,10 +35,10 @@ protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS}) qt5_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
else(ENABLE_QT5) else()
qt4_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS}) qt4_wrap_cpp(ProtoServer_HEADERS_MOC ${ProtoServer_QT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(protoserver add_library(protoserver
${ProtoServer_HEADERS} ${ProtoServer_HEADERS}
@ -50,8 +50,8 @@ add_library(protoserver
${ProtoServer_PROTO_HDRS} ${ProtoServer_PROTO_HDRS}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(protoserver Widgets) qt5_use_modules(protoserver Widgets)
endif(ENABLE_QT5) endif()
target_link_libraries(protoserver target_link_libraries(protoserver
hyperion hyperion

View File

@ -8,207 +8,207 @@
#include "protoserver/ProtoConnection.h" #include "protoserver/ProtoConnection.h"
ProtoConnection::ProtoConnection(const std::string & a) : ProtoConnection::ProtoConnection(const std::string & a) :
_socket(), _socket(),
_skipReply(false), _skipReply(false),
_prevSocketState(QAbstractSocket::UnconnectedState) _prevSocketState(QAbstractSocket::UnconnectedState)
{ {
QString address(a.c_str()); QString address(a.c_str());
QStringList parts = address.split(":"); QStringList parts = address.split(":");
if (parts.size() != 2) if (parts.size() != 2)
{ {
throw std::runtime_error(QString("PROTOCONNECTION ERROR: Wrong address: Unable to parse address (%1)").arg(address).toStdString()); throw std::runtime_error(QString("PROTOCONNECTION ERROR: Wrong address: Unable to parse address (%1)").arg(address).toStdString());
} }
_host = parts[0]; _host = parts[0];
bool ok; bool ok;
_port = parts[1].toUShort(&ok); _port = parts[1].toUShort(&ok);
if (!ok) if (!ok)
{ {
throw std::runtime_error(QString("PROTOCONNECTION ERROR: Wrong port: Unable to parse the port number (%1)").arg(parts[1]).toStdString()); throw std::runtime_error(QString("PROTOCONNECTION ERROR: Wrong port: Unable to parse the port number (%1)").arg(parts[1]).toStdString());
} }
// try to connect to host // try to connect to host
std::cout << "PROTOCONNECTION INFO: Connecting to Hyperion: " << _host.toStdString() << ":" << _port << std::endl; std::cout << "PROTOCONNECTION INFO: Connecting to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
connectToHost(); connectToHost();
// start the connection timer // start the connection timer
_timer.setInterval(5000); _timer.setInterval(5000);
_timer.setSingleShot(false); _timer.setSingleShot(false);
connect(&_timer,SIGNAL(timeout()), this, SLOT(connectToHost()) ); connect(&_timer,SIGNAL(timeout()), this, SLOT(connectToHost()) );
_timer.start(); _timer.start();
} }
ProtoConnection::~ProtoConnection() ProtoConnection::~ProtoConnection()
{ {
_timer.stop(); _timer.stop();
_socket.close(); _socket.close();
} }
void ProtoConnection::setSkipReply(bool skip) void ProtoConnection::setSkipReply(bool skip)
{ {
_skipReply = skip; _skipReply = skip;
} }
void ProtoConnection::setColor(const ColorRgb & color, int priority, int duration) void ProtoConnection::setColor(const ColorRgb & color, int priority, int duration)
{ {
proto::HyperionRequest request; proto::HyperionRequest request;
request.set_command(proto::HyperionRequest::COLOR); request.set_command(proto::HyperionRequest::COLOR);
proto::ColorRequest * colorRequest = request.MutableExtension(proto::ColorRequest::colorRequest); proto::ColorRequest * colorRequest = request.MutableExtension(proto::ColorRequest::colorRequest);
colorRequest->set_rgbcolor((color.red << 16) | (color.green << 8) | color.blue); colorRequest->set_rgbcolor((color.red << 16) | (color.green << 8) | color.blue);
colorRequest->set_priority(priority); colorRequest->set_priority(priority);
colorRequest->set_duration(duration); colorRequest->set_duration(duration);
// send command message // send command message
sendMessage(request); sendMessage(request);
} }
void ProtoConnection::setImage(const Image<ColorRgb> &image, int priority, int duration) void ProtoConnection::setImage(const Image<ColorRgb> &image, int priority, int duration)
{ {
proto::HyperionRequest request; proto::HyperionRequest request;
request.set_command(proto::HyperionRequest::IMAGE); request.set_command(proto::HyperionRequest::IMAGE);
proto::ImageRequest * imageRequest = request.MutableExtension(proto::ImageRequest::imageRequest); proto::ImageRequest * imageRequest = request.MutableExtension(proto::ImageRequest::imageRequest);
imageRequest->set_imagedata(image.memptr(), image.width() * image.height() * 3); imageRequest->set_imagedata(image.memptr(), image.width() * image.height() * 3);
imageRequest->set_imagewidth(image.width()); imageRequest->set_imagewidth(image.width());
imageRequest->set_imageheight(image.height()); imageRequest->set_imageheight(image.height());
imageRequest->set_priority(priority); imageRequest->set_priority(priority);
imageRequest->set_duration(duration); imageRequest->set_duration(duration);
// send command message // send command message
sendMessage(request); sendMessage(request);
} }
void ProtoConnection::clear(int priority) void ProtoConnection::clear(int priority)
{ {
proto::HyperionRequest request; proto::HyperionRequest request;
request.set_command(proto::HyperionRequest::CLEAR); request.set_command(proto::HyperionRequest::CLEAR);
proto::ClearRequest * clearRequest = request.MutableExtension(proto::ClearRequest::clearRequest); proto::ClearRequest * clearRequest = request.MutableExtension(proto::ClearRequest::clearRequest);
clearRequest->set_priority(priority); clearRequest->set_priority(priority);
// send command message // send command message
sendMessage(request); sendMessage(request);
} }
void ProtoConnection::clearAll() void ProtoConnection::clearAll()
{ {
proto::HyperionRequest request; proto::HyperionRequest request;
request.set_command(proto::HyperionRequest::CLEARALL); request.set_command(proto::HyperionRequest::CLEARALL);
// send command message // send command message
sendMessage(request); sendMessage(request);
} }
void ProtoConnection::connectToHost() void ProtoConnection::connectToHost()
{ {
// try connection only when // try connection only when
if (_socket.state() == QAbstractSocket::UnconnectedState) if (_socket.state() == QAbstractSocket::UnconnectedState)
{ {
_socket.connectToHost(_host, _port); _socket.connectToHost(_host, _port);
//_socket.waitForConnected(1000); //_socket.waitForConnected(1000);
} }
} }
void ProtoConnection::sendMessage(const proto::HyperionRequest &message) void ProtoConnection::sendMessage(const proto::HyperionRequest &message)
{ {
// print out connection message only when state is changed // print out connection message only when state is changed
if (_socket.state() != _prevSocketState ) if (_socket.state() != _prevSocketState )
{ {
switch (_socket.state() ) switch (_socket.state() )
{ {
case QAbstractSocket::UnconnectedState: case QAbstractSocket::UnconnectedState:
std::cout << "PROTOCONNECTION INFO: No connection to Hyperion: " << _host.toStdString() << ":" << _port << std::endl; std::cout << "PROTOCONNECTION INFO: No connection to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
break; break;
case QAbstractSocket::ConnectedState: case QAbstractSocket::ConnectedState:
std::cout << "PROTOCONNECTION INFO: Connected to Hyperion: " << _host.toStdString() << ":" << _port << std::endl; std::cout << "PROTOCONNECTION INFO: Connected to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
break; break;
default: default:
//std::cout << "Connecting to Hyperion: " << _host.toStdString() << ":" << _port << std::endl; //std::cout << "Connecting to Hyperion: " << _host.toStdString() << ":" << _port << std::endl;
break; break;
} }
_prevSocketState = _socket.state(); _prevSocketState = _socket.state();
} }
if (_socket.state() != QAbstractSocket::ConnectedState) if (_socket.state() != QAbstractSocket::ConnectedState)
{ {
return; return;
} }
// We only get here if we are connected // We only get here if we are connected
// serialize message (FastWriter already appends a newline) // serialize message (FastWriter already appends a newline)
std::string serializedMessage = message.SerializeAsString(); std::string serializedMessage = message.SerializeAsString();
int length = serializedMessage.size(); int length = serializedMessage.size();
const uint8_t header[] = { const uint8_t header[] = {
uint8_t((length >> 24) & 0xFF), uint8_t((length >> 24) & 0xFF),
uint8_t((length >> 16) & 0xFF), uint8_t((length >> 16) & 0xFF),
uint8_t((length >> 8) & 0xFF), uint8_t((length >> 8) & 0xFF),
uint8_t((length ) & 0xFF)}; uint8_t((length ) & 0xFF)};
// write message // write message
int count = 0; int count = 0;
count += _socket.write(reinterpret_cast<const char *>(header), 4); count += _socket.write(reinterpret_cast<const char *>(header), 4);
count += _socket.write(reinterpret_cast<const char *>(serializedMessage.data()), length); count += _socket.write(reinterpret_cast<const char *>(serializedMessage.data()), length);
if (!_socket.waitForBytesWritten()) if (!_socket.waitForBytesWritten())
{ {
std::cerr << "PROTOCONNECTION ERROR: Error while writing data to host" << std::endl; std::cerr << "PROTOCONNECTION ERROR: Error while writing data to host" << std::endl;
return; return;
} }
if (!_skipReply) if (!_skipReply)
{ {
// read reply data // read reply data
QByteArray serializedReply; QByteArray serializedReply;
length = -1; length = -1;
while (length < 0 && serializedReply.size() < length+4) while (length < 0 && serializedReply.size() < length+4)
{ {
// receive reply // receive reply
if (!_socket.waitForReadyRead()) if (!_socket.waitForReadyRead())
{ {
std::cerr << "PROTOCONNECTION ERROR: Error while reading data from host" << std::endl; std::cerr << "PROTOCONNECTION ERROR: Error while reading data from host" << std::endl;
return; return;
} }
serializedReply += _socket.readAll(); serializedReply += _socket.readAll();
if (length < 0 && serializedReply.size() >= 4) if (length < 0 && serializedReply.size() >= 4)
{ {
// read the message size // read the message size
length = length =
((serializedReply[0]<<24) & 0xFF000000) | ((serializedReply[0]<<24) & 0xFF000000) |
((serializedReply[1]<<16) & 0x00FF0000) | ((serializedReply[1]<<16) & 0x00FF0000) |
((serializedReply[2]<< 8) & 0x0000FF00) | ((serializedReply[2]<< 8) & 0x0000FF00) |
((serializedReply[3] ) & 0x000000FF); ((serializedReply[3] ) & 0x000000FF);
} }
} }
// parse reply data // parse reply data
proto::HyperionReply reply; proto::HyperionReply reply;
reply.ParseFromArray(serializedReply.constData()+4, length); reply.ParseFromArray(serializedReply.constData()+4, length);
// parse reply message // parse reply message
parseReply(reply); parseReply(reply);
} }
} }
bool ProtoConnection::parseReply(const proto::HyperionReply &reply) bool ProtoConnection::parseReply(const proto::HyperionReply &reply)
{ {
bool success = false; bool success = false;
if (!reply.success()) if (!reply.success())
{ {
if (reply.has_error()) if (reply.has_error())
{ {
throw std::runtime_error("PROTOCONNECTION ERROR: " + reply.error()); throw std::runtime_error("PROTOCONNECTION ERROR: " + reply.error());
} }
else else
{ {
throw std::runtime_error("PROTOCONNECTION ERROR: No error info"); throw std::runtime_error("PROTOCONNECTION ERROR: No error info");
} }
} }
return success; return success;
} }

View File

@ -2,11 +2,11 @@
#include "protoserver/ProtoConnectionWrapper.h" #include "protoserver/ProtoConnectionWrapper.h"
ProtoConnectionWrapper::ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply) : ProtoConnectionWrapper::ProtoConnectionWrapper(const std::string & address, int priority, int duration_ms, bool skipProtoReply) :
_priority(priority), _priority(priority),
_duration_ms(duration_ms), _duration_ms(duration_ms),
_connection(address) _connection(address)
{ {
_connection.setSkipReply(skipProtoReply); _connection.setSkipReply(skipProtoReply);
} }
ProtoConnectionWrapper::~ProtoConnectionWrapper() ProtoConnectionWrapper::~ProtoConnectionWrapper()
@ -15,5 +15,5 @@ ProtoConnectionWrapper::~ProtoConnectionWrapper()
void ProtoConnectionWrapper::receiveImage(const Image<ColorRgb> & image) void ProtoConnectionWrapper::receiveImage(const Image<ColorRgb> & image)
{ {
_connection.setImage(image, _priority, _duration_ms); _connection.setImage(image, _priority, _duration_ms);
} }

View File

@ -4,38 +4,38 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/utils)
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/utils) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/utils)
add_library(hyperion-utils add_library(hyperion-utils
${CURRENT_HEADER_DIR}/ColorArgb.h ${CURRENT_HEADER_DIR}/ColorArgb.h
${CURRENT_SOURCE_DIR}/ColorArgb.cpp ${CURRENT_SOURCE_DIR}/ColorArgb.cpp
${CURRENT_HEADER_DIR}/ColorBgr.h ${CURRENT_HEADER_DIR}/ColorBgr.h
${CURRENT_SOURCE_DIR}/ColorBgr.cpp ${CURRENT_SOURCE_DIR}/ColorBgr.cpp
${CURRENT_HEADER_DIR}/ColorRgb.h ${CURRENT_HEADER_DIR}/ColorRgb.h
${CURRENT_SOURCE_DIR}/ColorRgb.cpp ${CURRENT_SOURCE_DIR}/ColorRgb.cpp
${CURRENT_HEADER_DIR}/ColorRgba.h ${CURRENT_HEADER_DIR}/ColorRgba.h
${CURRENT_SOURCE_DIR}/ColorRgba.cpp ${CURRENT_SOURCE_DIR}/ColorRgba.cpp
${CURRENT_HEADER_DIR}/Image.h ${CURRENT_HEADER_DIR}/Image.h
${CURRENT_HEADER_DIR}/Sleep.h ${CURRENT_HEADER_DIR}/Sleep.h
${CURRENT_HEADER_DIR}/PixelFormat.h ${CURRENT_HEADER_DIR}/PixelFormat.h
${CURRENT_HEADER_DIR}/VideoMode.h ${CURRENT_HEADER_DIR}/VideoMode.h
${CURRENT_HEADER_DIR}/ImageResampler.h ${CURRENT_HEADER_DIR}/ImageResampler.h
${CURRENT_SOURCE_DIR}/ImageResampler.cpp ${CURRENT_SOURCE_DIR}/ImageResampler.cpp
${CURRENT_HEADER_DIR}/HsvTransform.h ${CURRENT_HEADER_DIR}/HsvTransform.h
${CURRENT_SOURCE_DIR}/HsvTransform.cpp ${CURRENT_SOURCE_DIR}/HsvTransform.cpp
${CURRENT_HEADER_DIR}/HslTransform.h ${CURRENT_HEADER_DIR}/HslTransform.h
${CURRENT_SOURCE_DIR}/HslTransform.cpp ${CURRENT_SOURCE_DIR}/HslTransform.cpp
${CURRENT_HEADER_DIR}/RgbChannelTransform.h ${CURRENT_HEADER_DIR}/RgbChannelTransform.h
${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp ${CURRENT_SOURCE_DIR}/RgbChannelTransform.cpp
${CURRENT_HEADER_DIR}/RgbChannelCorrection.h ${CURRENT_HEADER_DIR}/RgbChannelCorrection.h
${CURRENT_SOURCE_DIR}/RgbChannelCorrection.cpp ${CURRENT_SOURCE_DIR}/RgbChannelCorrection.cpp
${CURRENT_HEADER_DIR}/RgbChannelAdjustment.h ${CURRENT_HEADER_DIR}/RgbChannelAdjustment.h
${CURRENT_SOURCE_DIR}/RgbChannelAdjustment.cpp ${CURRENT_SOURCE_DIR}/RgbChannelAdjustment.cpp
${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h ${CURRENT_HEADER_DIR}/jsonschema/JsonFactory.h
${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h ${CURRENT_HEADER_DIR}/jsonschema/JsonSchemaChecker.h
${CURRENT_SOURCE_DIR}/jsonschema/JsonSchemaChecker.cpp ${CURRENT_SOURCE_DIR}/jsonschema/JsonSchemaChecker.cpp
) )
target_link_libraries(hyperion-utils target_link_libraries(hyperion-utils
jsoncpp) jsoncpp)

View File

@ -5,33 +5,33 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/xbmcvideochecker)
# Group the headers that go through the MOC compiler # Group the headers that go through the MOC compiler
SET(XBMCVideoChecker_QT_HEADERS SET(XBMCVideoChecker_QT_HEADERS
${CURRENT_HEADER_DIR}/XBMCVideoChecker.h ${CURRENT_HEADER_DIR}/XBMCVideoChecker.h
) )
SET(XBMCVideoChecker_HEADERS SET(XBMCVideoChecker_HEADERS
) )
SET(XBMCVideoChecker_SOURCES SET(XBMCVideoChecker_SOURCES
${CURRENT_SOURCE_DIR}/XBMCVideoChecker.cpp ${CURRENT_SOURCE_DIR}/XBMCVideoChecker.cpp
) )
if(ENABLE_QT5) if(ENABLE_QT5)
QT5_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS}) QT5_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS})
else(ENABLE_QT5) else()
QT4_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS}) QT4_WRAP_CPP(XBMCVideoChecker_HEADERS_MOC ${XBMCVideoChecker_QT_HEADERS})
endif(ENABLE_QT5) endif()
add_library(xbmcvideochecker add_library(xbmcvideochecker
${XBMCVideoChecker_HEADERS} ${XBMCVideoChecker_HEADERS}
${XBMCVideoChecker_QT_HEADERS} ${XBMCVideoChecker_QT_HEADERS}
${XBMCVideoChecker_HEADERS_MOC} ${XBMCVideoChecker_HEADERS_MOC}
${XBMCVideoChecker_SOURCES} ${XBMCVideoChecker_SOURCES}
) )
if(ENABLE_QT5) if(ENABLE_QT5)
qt5_use_modules(xbmcvideochecker Widgets) qt5_use_modules(xbmcvideochecker Widgets)
endif(ENABLE_QT5) endif()
target_link_libraries(xbmcvideochecker target_link_libraries(xbmcvideochecker
hyperion hyperion
${QT_LIBRARIES}) ${QT_LIBRARIES})

View File

@ -2,30 +2,27 @@ add_subdirectory(hyperiond)
add_subdirectory(hyperion-remote) add_subdirectory(hyperion-remote)
# The following clients depend on the protobuf library # The following clients depend on the protobuf library
if(ENABLE_PROTOBUF) if (ENABLE_AMLOGIC)
add_subdirectory(hyperion-aml)
if (ENABLE_AMLOGIC)
add_subdirectory(hyperion-aml)
endif()
if(ENABLE_V4L2)
add_subdirectory(hyperion-v4l2)
endif()
if(ENABLE_X11)
add_subdirectory(hyperion-x11)
endif()
if(ENABLE_DISPMANX)
add_subdirectory(hyperion-dispmanx)
endif()
if(ENABLE_FB)
add_subdirectory(hyperion-framebuffer)
endif()
if(ENABLE_OSX)
add_subdirectory(hyperion-osx)
endif()
endif() endif()
if(ENABLE_V4L2)
add_subdirectory(hyperion-v4l2)
endif()
if(ENABLE_X11)
add_subdirectory(hyperion-x11)
endif()
if(ENABLE_DISPMANX)
add_subdirectory(hyperion-dispmanx)
endif()
if(ENABLE_FB)
add_subdirectory(hyperion-framebuffer)
endif()
if(ENABLE_OSX)
add_subdirectory(hyperion-osx)
endif()

View File

@ -3,14 +3,14 @@
#include "AmlogicWrapper.h" #include "AmlogicWrapper.h"
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) : AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
_timer(this), _timer(this),
_grabber(grabWidth, grabHeight) _grabber(grabWidth, grabHeight)
{ {
_timer.setSingleShot(false); _timer.setSingleShot(false);
_timer.setInterval(updateRate_Hz); _timer.setInterval(updateRate_Hz);
// Connect capturing to the timeout signal of the timer // Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture())); connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
} }
const Image<ColorRgb> & AmlogicWrapper::getScreenshot() const Image<ColorRgb> & AmlogicWrapper::getScreenshot()
@ -21,12 +21,12 @@ const Image<ColorRgb> & AmlogicWrapper::getScreenshot()
void AmlogicWrapper::start() void AmlogicWrapper::start()
{ {
_timer.start(); _timer.start();
} }
void AmlogicWrapper::stop() void AmlogicWrapper::stop()
{ {
_timer.stop(); _timer.stop();
} }
void AmlogicWrapper::capture() void AmlogicWrapper::capture()

View File

@ -7,16 +7,16 @@ DispmanxWrapper::DispmanxWrapper(const unsigned grabWidth, const unsigned grabHe
const unsigned cropLeft, const unsigned cropRight, const unsigned cropLeft, const unsigned cropRight,
const unsigned cropTop, const unsigned cropBottom, const unsigned cropTop, const unsigned cropBottom,
const unsigned updateRate_Hz) : const unsigned updateRate_Hz) :
_timer(this), _timer(this),
_grabber(grabWidth, grabHeight) _grabber(grabWidth, grabHeight)
{ {
_grabber.setVideoMode(videoMode); _grabber.setVideoMode(videoMode);
_grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom); _grabber.setCropping(cropLeft, cropRight, cropTop, cropBottom);
_timer.setSingleShot(false); _timer.setSingleShot(false);
_timer.setInterval(updateRate_Hz); _timer.setInterval(updateRate_Hz);
// Connect capturing to the timeout signal of the timer // Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture())); connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
} }
const Image<ColorRgb> & DispmanxWrapper::getScreenshot() const Image<ColorRgb> & DispmanxWrapper::getScreenshot()
@ -27,12 +27,12 @@ const Image<ColorRgb> & DispmanxWrapper::getScreenshot()
void DispmanxWrapper::start() void DispmanxWrapper::start()
{ {
_timer.start(); _timer.start();
} }
void DispmanxWrapper::stop() void DispmanxWrapper::stop()
{ {
_timer.stop(); _timer.stop();
} }
void DispmanxWrapper::capture() void DispmanxWrapper::capture()

View File

@ -3,14 +3,14 @@
#include "FramebufferWrapper.h" #include "FramebufferWrapper.h"
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) : FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
_timer(this), _timer(this),
_grabber(device,grabWidth, grabHeight) _grabber(device,grabWidth, grabHeight)
{ {
_timer.setSingleShot(false); _timer.setSingleShot(false);
_timer.setInterval(updateRate_Hz); _timer.setInterval(updateRate_Hz);
// Connect capturing to the timeout signal of the timer // Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture())); connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
} }
const Image<ColorRgb> & FramebufferWrapper::getScreenshot() const Image<ColorRgb> & FramebufferWrapper::getScreenshot()
@ -21,12 +21,12 @@ const Image<ColorRgb> & FramebufferWrapper::getScreenshot()
void FramebufferWrapper::start() void FramebufferWrapper::start()
{ {
_timer.start(); _timer.start();
} }
void FramebufferWrapper::stop() void FramebufferWrapper::stop()
{ {
_timer.stop(); _timer.stop();
} }
void FramebufferWrapper::capture() void FramebufferWrapper::capture()

View File

@ -3,14 +3,14 @@
#include "OsxWrapper.h" #include "OsxWrapper.h"
OsxWrapper::OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) : OsxWrapper::OsxWrapper(const unsigned display, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz) :
_timer(this), _timer(this),
_grabber(display,grabWidth, grabHeight) _grabber(display,grabWidth, grabHeight)
{ {
_timer.setSingleShot(false); _timer.setSingleShot(false);
_timer.setInterval(updateRate_Hz); _timer.setInterval(updateRate_Hz);
// Connect capturing to the timeout signal of the timer // Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture())); connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
} }
const Image<ColorRgb> & OsxWrapper::getScreenshot() const Image<ColorRgb> & OsxWrapper::getScreenshot()

View File

@ -10,34 +10,34 @@ using namespace vlofgren;
typedef vlofgren::PODParameter<PixelFormat> PixelFormatParameter; typedef vlofgren::PODParameter<PixelFormat> PixelFormatParameter;
namespace vlofgren { namespace vlofgren {
/// Translates a string (as passed on the commandline) to a pixel format /// Translates a string (as passed on the commandline) to a pixel format
/// ///
/// @param[in] s The string (as passed on the commandline) /// @param[in] s The string (as passed on the commandline)
/// @return The pixel format /// @return The pixel format
/// @throws Parameter::ParameterRejected If the string did not result in a pixel format /// @throws Parameter::ParameterRejected If the string did not result in a pixel format
template<> template<>
PixelFormat PixelFormatParameter::validate(const std::string& s) throw (Parameter::ParameterRejected) PixelFormat PixelFormatParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
{ {
QString input = QString::fromStdString(s).toLower(); QString input = QString::fromStdString(s).toLower();
if (input == "yuyv") if (input == "yuyv")
{ {
return PIXELFORMAT_YUYV; return PIXELFORMAT_YUYV;
} }
else if (input == "uyvy") else if (input == "uyvy")
{ {
return PIXELFORMAT_UYVY; return PIXELFORMAT_UYVY;
} }
else if (input == "rgb32") else if (input == "rgb32")
{ {
return PIXELFORMAT_RGB32; return PIXELFORMAT_RGB32;
} }
else if (input == "no-change") else if (input == "no-change")
{ {
return PIXELFORMAT_NO_CHANGE; return PIXELFORMAT_NO_CHANGE;
} }
throw Parameter::ParameterRejected("Invalid value for pixel format. Valid values are: YUYV, UYVY, RGB32, and NO-CHANGE"); throw Parameter::ParameterRejected("Invalid value for pixel format. Valid values are: YUYV, UYVY, RGB32, and NO-CHANGE");
return PIXELFORMAT_NO_CHANGE; return PIXELFORMAT_NO_CHANGE;
} }
} }

View File

@ -6,7 +6,7 @@
#include "ScreenshotHandler.h" #include "ScreenshotHandler.h"
ScreenshotHandler::ScreenshotHandler(const std::string & filename) : ScreenshotHandler::ScreenshotHandler(const std::string & filename) :
_filename(filename) _filename(filename)
{ {
} }

View File

@ -31,150 +31,150 @@ using namespace vlofgren;
// save the image as screenshot // save the image as screenshot
void saveScreenshot(void *, const Image<ColorRgb> & image) void saveScreenshot(void *, const Image<ColorRgb> & image)
{ {
// store as PNG // store as PNG
QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888); QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888);
pngImage.save("screenshot.png"); pngImage.save("screenshot.png");
} }
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
std::cout std::cout
<< "hyperion-v4l2:" << std::endl << "hyperion-v4l2:" << std::endl
<< "\tversion : " << HYPERION_VERSION_ID << std::endl << "\tversion : " << HYPERION_VERSION_ID << std::endl
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
// force the locale // force the locale
setlocale(LC_ALL, "C"); setlocale(LC_ALL, "C");
QLocale::setDefault(QLocale::c()); QLocale::setDefault(QLocale::c());
// register the image type to use in signals // register the image type to use in signals
qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>"); qRegisterMetaType<Image<ColorRgb>>("Image<ColorRgb>");
try try
{ {
// create the option parser and initialize all parameters // create the option parser and initialize all parameters
OptionsParser optionParser("V4L capture application for Hyperion"); OptionsParser optionParser("V4L capture application for Hyperion");
ParameterSet & parameters = optionParser.getParameters(); ParameterSet & parameters = optionParser.getParameters();
StringParameter & argDevice = parameters.add<StringParameter> ('d', "device", "The device to use [default: /dev/video0]"); StringParameter & argDevice = parameters.add<StringParameter> ('d', "device", "The device to use [default: /dev/video0]");
VideoStandardParameter & argVideoStandard = parameters.add<VideoStandardParameter>('v', "video-standard", "The used video standard. Valid values are PAL or NTSC (optional)"); VideoStandardParameter & argVideoStandard = parameters.add<VideoStandardParameter>('v', "video-standard", "The used video standard. Valid values are PAL or NTSC (optional)");
PixelFormatParameter & argPixelFormat = parameters.add<PixelFormatParameter> (0x0, "pixel-format", "The use pixel format. Valid values are YUYV, UYVY, and RGB32 (optional)"); PixelFormatParameter & argPixelFormat = parameters.add<PixelFormatParameter> (0x0, "pixel-format", "The use pixel format. Valid values are YUYV, UYVY, and RGB32 (optional)");
IntParameter & argInput = parameters.add<IntParameter> (0x0, "input", "Input channel (optional)"); IntParameter & argInput = parameters.add<IntParameter> (0x0, "input", "Input channel (optional)");
IntParameter & argWidth = parameters.add<IntParameter> (0x0, "width", "Try to set the width of the video input (optional)"); IntParameter & argWidth = parameters.add<IntParameter> (0x0, "width", "Try to set the width of the video input (optional)");
IntParameter & argHeight = parameters.add<IntParameter> (0x0, "height", "Try to set the height of the video input (optional)"); IntParameter & argHeight = parameters.add<IntParameter> (0x0, "height", "Try to set the height of the video input (optional)");
IntParameter & argCropWidth = parameters.add<IntParameter> (0x0, "crop-width", "Number of pixels to crop from the left and right sides of the picture before decimation [default: 0]"); IntParameter & argCropWidth = parameters.add<IntParameter> (0x0, "crop-width", "Number of pixels to crop from the left and right sides of the picture before decimation [default: 0]");
IntParameter & argCropHeight = parameters.add<IntParameter> (0x0, "crop-height", "Number of pixels to crop from the top and the bottom of the picture before decimation [default: 0]"); IntParameter & argCropHeight = parameters.add<IntParameter> (0x0, "crop-height", "Number of pixels to crop from the top and the bottom of the picture before decimation [default: 0]");
IntParameter & argCropLeft = parameters.add<IntParameter> (0x0, "crop-left", "Number of pixels to crop from the left of the picture before decimation (overrides --crop-width)"); IntParameter & argCropLeft = parameters.add<IntParameter> (0x0, "crop-left", "Number of pixels to crop from the left of the picture before decimation (overrides --crop-width)");
IntParameter & argCropRight = parameters.add<IntParameter> (0x0, "crop-right", "Number of pixels to crop from the right of the picture before decimation (overrides --crop-width)"); IntParameter & argCropRight = parameters.add<IntParameter> (0x0, "crop-right", "Number of pixels to crop from the right of the picture before decimation (overrides --crop-width)");
IntParameter & argCropTop = parameters.add<IntParameter> (0x0, "crop-top", "Number of pixels to crop from the top of the picture before decimation (overrides --crop-height)"); IntParameter & argCropTop = parameters.add<IntParameter> (0x0, "crop-top", "Number of pixels to crop from the top of the picture before decimation (overrides --crop-height)");
IntParameter & argCropBottom = parameters.add<IntParameter> (0x0, "crop-bottom", "Number of pixels to crop from the bottom of the picture before decimation (overrides --crop-height)"); IntParameter & argCropBottom = parameters.add<IntParameter> (0x0, "crop-bottom", "Number of pixels to crop from the bottom of the picture before decimation (overrides --crop-height)");
IntParameter & argSizeDecimation = parameters.add<IntParameter> ('s', "size-decimator", "Decimation factor for the output size [default=1]"); IntParameter & argSizeDecimation = parameters.add<IntParameter> ('s', "size-decimator", "Decimation factor for the output size [default=1]");
IntParameter & argFrameDecimation = parameters.add<IntParameter> ('f', "frame-decimator", "Decimation factor for the video frames [default=1]"); IntParameter & argFrameDecimation = parameters.add<IntParameter> ('f', "frame-decimator", "Decimation factor for the video frames [default=1]");
SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit"); SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit");
DoubleParameter & argSignalThreshold = parameters.add<DoubleParameter> ('t', "signal-threshold", "The signal threshold for detecting the presence of a signal. Value should be between 0.0 and 1.0."); DoubleParameter & argSignalThreshold = parameters.add<DoubleParameter> ('t', "signal-threshold", "The signal threshold for detecting the presence of a signal. Value should be between 0.0 and 1.0.");
DoubleParameter & argRedSignalThreshold = parameters.add<DoubleParameter> (0x0, "red-threshold", "The red signal threshold. Value should be between 0.0 and 1.0. (overrides --signal-threshold)"); DoubleParameter & argRedSignalThreshold = parameters.add<DoubleParameter> (0x0, "red-threshold", "The red signal threshold. Value should be between 0.0 and 1.0. (overrides --signal-threshold)");
DoubleParameter & argGreenSignalThreshold = parameters.add<DoubleParameter> (0x0, "green-threshold", "The green signal threshold. Value should be between 0.0 and 1.0. (overrides --signal-threshold)"); DoubleParameter & argGreenSignalThreshold = parameters.add<DoubleParameter> (0x0, "green-threshold", "The green signal threshold. Value should be between 0.0 and 1.0. (overrides --signal-threshold)");
DoubleParameter & argBlueSignalThreshold = parameters.add<DoubleParameter> (0x0, "blue-threshold", "The blue signal threshold. Value should be between 0.0 and 1.0. (overrides --signal-threshold)"); DoubleParameter & argBlueSignalThreshold = parameters.add<DoubleParameter> (0x0, "blue-threshold", "The blue signal threshold. Value should be between 0.0 and 1.0. (overrides --signal-threshold)");
SwitchParameter<> & arg3DSBS = parameters.add<SwitchParameter<>> (0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side"); SwitchParameter<> & arg3DSBS = parameters.add<SwitchParameter<>> (0x0, "3DSBS", "Interpret the incoming video stream as 3D side-by-side");
SwitchParameter<> & arg3DTAB = parameters.add<SwitchParameter<>> (0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom"); SwitchParameter<> & arg3DTAB = parameters.add<SwitchParameter<>> (0x0, "3DTAB", "Interpret the incoming video stream as 3D top-and-bottom");
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]"); StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]");
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]"); IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]");
SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion"); SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit"); SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
// set defaults // set defaults
argDevice.setDefault("/dev/video0"); argDevice.setDefault("/dev/video0");
argVideoStandard.setDefault(VIDEOSTANDARD_NO_CHANGE); argVideoStandard.setDefault(VIDEOSTANDARD_NO_CHANGE);
argPixelFormat.setDefault(PIXELFORMAT_NO_CHANGE); argPixelFormat.setDefault(PIXELFORMAT_NO_CHANGE);
argInput.setDefault(-1); argInput.setDefault(-1);
argWidth.setDefault(-1); argWidth.setDefault(-1);
argHeight.setDefault(-1); argHeight.setDefault(-1);
argCropWidth.setDefault(0); argCropWidth.setDefault(0);
argCropHeight.setDefault(0); argCropHeight.setDefault(0);
argSizeDecimation.setDefault(1); argSizeDecimation.setDefault(1);
argFrameDecimation.setDefault(1); argFrameDecimation.setDefault(1);
argAddress.setDefault("127.0.0.1:19445"); argAddress.setDefault("127.0.0.1:19445");
argPriority.setDefault(800); argPriority.setDefault(800);
argSignalThreshold.setDefault(-1); argSignalThreshold.setDefault(-1);
// parse all options // parse all options
optionParser.parse(argc, const_cast<const char **>(argv)); optionParser.parse(argc, const_cast<const char **>(argv));
// check if we need to display the usage. exit if we do. // check if we need to display the usage. exit if we do.
if (argHelp.isSet()) if (argHelp.isSet())
{ {
optionParser.usage(); optionParser.usage();
return 0; return 0;
} }
// cropping values if not defined // cropping values if not defined
if (!argCropLeft.isSet()) argCropLeft.setDefault(argCropWidth.getValue()); if (!argCropLeft.isSet()) argCropLeft.setDefault(argCropWidth.getValue());
if (!argCropRight.isSet()) argCropRight.setDefault(argCropWidth.getValue()); if (!argCropRight.isSet()) argCropRight.setDefault(argCropWidth.getValue());
if (!argCropTop.isSet()) argCropTop.setDefault(argCropHeight.getValue()); if (!argCropTop.isSet()) argCropTop.setDefault(argCropHeight.getValue());
if (!argCropBottom.isSet()) argCropBottom.setDefault(argCropHeight.getValue()); if (!argCropBottom.isSet()) argCropBottom.setDefault(argCropHeight.getValue());
// initialize the grabber // initialize the grabber
V4L2Grabber grabber( V4L2Grabber grabber(
argDevice.getValue(), argDevice.getValue(),
argInput.getValue(), argInput.getValue(),
argVideoStandard.getValue(), argVideoStandard.getValue(),
argPixelFormat.getValue(), argPixelFormat.getValue(),
argWidth.getValue(), argWidth.getValue(),
argHeight.getValue(), argHeight.getValue(),
std::max(1, argFrameDecimation.getValue()), std::max(1, argFrameDecimation.getValue()),
std::max(1, argSizeDecimation.getValue()), std::max(1, argSizeDecimation.getValue()),
std::max(1, argSizeDecimation.getValue())); std::max(1, argSizeDecimation.getValue()));
// set signal detection // set signal detection
grabber.setSignalThreshold( grabber.setSignalThreshold(
std::min(1.0, std::max(0.0, argRedSignalThreshold.isSet() ? argRedSignalThreshold.getValue() : argSignalThreshold.getValue())), std::min(1.0, std::max(0.0, argRedSignalThreshold.isSet() ? argRedSignalThreshold.getValue() : argSignalThreshold.getValue())),
std::min(1.0, std::max(0.0, argGreenSignalThreshold.isSet() ? argGreenSignalThreshold.getValue() : argSignalThreshold.getValue())), std::min(1.0, std::max(0.0, argGreenSignalThreshold.isSet() ? argGreenSignalThreshold.getValue() : argSignalThreshold.getValue())),
std::min(1.0, std::max(0.0, argBlueSignalThreshold.isSet() ? argBlueSignalThreshold.getValue() : argSignalThreshold.getValue())), std::min(1.0, std::max(0.0, argBlueSignalThreshold.isSet() ? argBlueSignalThreshold.getValue() : argSignalThreshold.getValue())),
50); 50);
// set cropping values // set cropping values
grabber.setCropping( grabber.setCropping(
std::max(0, argCropLeft.getValue()), std::max(0, argCropLeft.getValue()),
std::max(0, argCropRight.getValue()), std::max(0, argCropRight.getValue()),
std::max(0, argCropTop.getValue()), std::max(0, argCropTop.getValue()),
std::max(0, argCropBottom.getValue())); std::max(0, argCropBottom.getValue()));
// set 3D mode if applicable // set 3D mode if applicable
if (arg3DSBS.isSet()) if (arg3DSBS.isSet())
{ {
grabber.set3D(VIDEO_3DSBS); grabber.set3D(VIDEO_3DSBS);
} }
else if (arg3DTAB.isSet()) else if (arg3DTAB.isSet())
{ {
grabber.set3D(VIDEO_3DTAB); grabber.set3D(VIDEO_3DTAB);
} }
// run the grabber // run the grabber
if (argScreenshot.isSet()) if (argScreenshot.isSet())
{ {
ScreenshotHandler handler("screenshot.png"); ScreenshotHandler handler("screenshot.png");
QObject::connect(&grabber, SIGNAL(newFrame(Image<ColorRgb>)), &handler, SLOT(receiveImage(Image<ColorRgb>))); QObject::connect(&grabber, SIGNAL(newFrame(Image<ColorRgb>)), &handler, SLOT(receiveImage(Image<ColorRgb>)));
grabber.start(); grabber.start();
QCoreApplication::exec(); QCoreApplication::exec();
grabber.stop(); grabber.stop();
} }
else else
{ {
ProtoConnectionWrapper handler(argAddress.getValue(), argPriority.getValue(), 1000, argSkipReply.isSet()); ProtoConnectionWrapper handler(argAddress.getValue(), argPriority.getValue(), 1000, argSkipReply.isSet());
QObject::connect(&grabber, SIGNAL(newFrame(Image<ColorRgb>)), &handler, SLOT(receiveImage(Image<ColorRgb>))); QObject::connect(&grabber, SIGNAL(newFrame(Image<ColorRgb>)), &handler, SLOT(receiveImage(Image<ColorRgb>)));
grabber.start(); grabber.start();
QCoreApplication::exec(); QCoreApplication::exec();
grabber.stop(); grabber.stop();
} }
} }
catch (const std::runtime_error & e) catch (const std::runtime_error & e)
{ {
// An error occured. Display error and quit // An error occured. Display error and quit
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return 1; return 1;
} }
return 0; return 0;
} }

View File

@ -3,39 +3,39 @@
#include "X11Wrapper.h" #include "X11Wrapper.h"
X11Wrapper::X11Wrapper(int grabInterval, bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) : X11Wrapper::X11Wrapper(int grabInterval, bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) :
_timer(this), _timer(this),
_grabber(useXGetImage, cropLeft, cropRight, cropTop, cropBottom, horizontalPixelDecimation, verticalPixelDecimation) _grabber(useXGetImage, cropLeft, cropRight, cropTop, cropBottom, horizontalPixelDecimation, verticalPixelDecimation)
{ {
_timer.setSingleShot(false); _timer.setSingleShot(false);
_timer.setInterval(grabInterval); _timer.setInterval(grabInterval);
// Connect capturing to the timeout signal of the timer // Connect capturing to the timeout signal of the timer
connect(&_timer, SIGNAL(timeout()), this, SLOT(capture())); connect(&_timer, SIGNAL(timeout()), this, SLOT(capture()));
} }
const Image<ColorRgb> & X11Wrapper::getScreenshot() const Image<ColorRgb> & X11Wrapper::getScreenshot()
{ {
const Image<ColorRgb> & screenshot = _grabber.grab(); const Image<ColorRgb> & screenshot = _grabber.grab();
return screenshot; return screenshot;
} }
void X11Wrapper::start() void X11Wrapper::start()
{ {
_timer.start(); _timer.start();
} }
void X11Wrapper::stop() void X11Wrapper::stop()
{ {
_timer.stop(); _timer.stop();
} }
bool X11Wrapper::displayInit() bool X11Wrapper::displayInit()
{ {
return _grabber.Setup(); return _grabber.Setup();
} }
void X11Wrapper::capture() void X11Wrapper::capture()
{ {
const Image<ColorRgb> & screenshot = _grabber.grab(); const Image<ColorRgb> & screenshot = _grabber.grab();
emit sig_screenshot(screenshot); emit sig_screenshot(screenshot);
} }

View File

@ -7,35 +7,35 @@
class X11Wrapper : public QObject class X11Wrapper : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
X11Wrapper(int grabInterval, bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation); X11Wrapper(int grabInterval, bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation);
const Image<ColorRgb> & getScreenshot(); const Image<ColorRgb> & getScreenshot();
/// ///
/// Starts the timed capturing of screenshots /// Starts the timed capturing of screenshots
/// ///
void start(); void start();
void stop(); void stop();
bool displayInit(); bool displayInit();
signals: signals:
void sig_screenshot(const Image<ColorRgb> & screenshot); void sig_screenshot(const Image<ColorRgb> & screenshot);
private slots: private slots:
/// ///
/// Performs a single screenshot capture and publishes the capture screenshot on the screenshot /// Performs a single screenshot capture and publishes the capture screenshot on the screenshot
/// signal. /// signal.
/// ///
void capture(); void capture();
private: private:
/// The QT timer to generate capture-publish events /// The QT timer to generate capture-publish events
QTimer _timer; QTimer _timer;
/// The grabber for creating screenshots /// The grabber for creating screenshots
X11Grabber _grabber; X11Grabber _grabber;
}; };

View File

@ -15,108 +15,108 @@ using namespace vlofgren;
// save the image as screenshot // save the image as screenshot
void saveScreenshot(const char * filename, const Image<ColorRgb> & image) void saveScreenshot(const char * filename, const Image<ColorRgb> & image)
{ {
// store as PNG // store as PNG
QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888); QImage pngImage((const uint8_t *) image.memptr(), image.width(), image.height(), 3*image.width(), QImage::Format_RGB888);
pngImage.save(filename); pngImage.save(filename);
} }
int main(int argc, char ** argv) int main(int argc, char ** argv)
{ {
std::cout std::cout
<< "hyperion-x11:" << std::endl << "hyperion-x11:" << std::endl
<< "\tversion : " << HYPERION_VERSION_ID << std::endl << "\tversion : " << HYPERION_VERSION_ID << std::endl
<< "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl; << "\tbuild time: " << __DATE__ << " " << __TIME__ << std::endl;
QCoreApplication app(argc, argv); QCoreApplication app(argc, argv);
try try
{ {
// create the option parser and initialize all parameters // create the option parser and initialize all parameters
OptionsParser optionParser("X11 capture application for Hyperion"); OptionsParser optionParser("X11 capture application for Hyperion");
ParameterSet & parameters = optionParser.getParameters(); ParameterSet & parameters = optionParser.getParameters();
IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Capture frame rate [default: 10]"); IntParameter & argFps = parameters.add<IntParameter> ('f', "framerate", "Capture frame rate [default: 10]");
SwitchParameter<> & argXGetImage = parameters.add<SwitchParameter<>> ('x', "xgetimage", "Use XGetImage instead of XRender"); SwitchParameter<> & argXGetImage = parameters.add<SwitchParameter<>> ('x', "xgetimage", "Use XGetImage instead of XRender");
IntParameter & argCropWidth = parameters.add<IntParameter> (0x0, "crop-width", "Number of pixels to crop from the left and right sides of the picture before decimation [default: 0]"); IntParameter & argCropWidth = parameters.add<IntParameter> (0x0, "crop-width", "Number of pixels to crop from the left and right sides of the picture before decimation [default: 0]");
IntParameter & argCropHeight = parameters.add<IntParameter> (0x0, "crop-height", "Number of pixels to crop from the top and the bottom of the picture before decimation [default: 0]"); IntParameter & argCropHeight = parameters.add<IntParameter> (0x0, "crop-height", "Number of pixels to crop from the top and the bottom of the picture before decimation [default: 0]");
IntParameter & argCropLeft = parameters.add<IntParameter> (0x0, "crop-left", "Number of pixels to crop from the left of the picture before decimation (overrides --crop-width)"); IntParameter & argCropLeft = parameters.add<IntParameter> (0x0, "crop-left", "Number of pixels to crop from the left of the picture before decimation (overrides --crop-width)");
IntParameter & argCropRight = parameters.add<IntParameter> (0x0, "crop-right", "Number of pixels to crop from the right of the picture before decimation (overrides --crop-width)"); IntParameter & argCropRight = parameters.add<IntParameter> (0x0, "crop-right", "Number of pixels to crop from the right of the picture before decimation (overrides --crop-width)");
IntParameter & argCropTop = parameters.add<IntParameter> (0x0, "crop-top", "Number of pixels to crop from the top of the picture before decimation (overrides --crop-height)"); IntParameter & argCropTop = parameters.add<IntParameter> (0x0, "crop-top", "Number of pixels to crop from the top of the picture before decimation (overrides --crop-height)");
IntParameter & argCropBottom = parameters.add<IntParameter> (0x0, "crop-bottom", "Number of pixels to crop from the bottom of the picture before decimation (overrides --crop-height)"); IntParameter & argCropBottom = parameters.add<IntParameter> (0x0, "crop-bottom", "Number of pixels to crop from the bottom of the picture before decimation (overrides --crop-height)");
IntParameter & argSizeDecimation = parameters.add<IntParameter> ('s', "size-decimator", "Decimation factor for the output size [default=8]"); IntParameter & argSizeDecimation = parameters.add<IntParameter> ('s', "size-decimator", "Decimation factor for the output size [default=8]");
SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit"); SwitchParameter<> & argScreenshot = parameters.add<SwitchParameter<>> (0x0, "screenshot", "Take a single screenshot, save it to file and quit");
StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]"); StringParameter & argAddress = parameters.add<StringParameter> ('a', "address", "Set the address of the hyperion server [default: 127.0.0.1:19445]");
IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]"); IntParameter & argPriority = parameters.add<IntParameter> ('p', "priority", "Use the provided priority channel (the lower the number, the higher the priority) [default: 800]");
SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion"); SwitchParameter<> & argSkipReply = parameters.add<SwitchParameter<>> (0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit"); SwitchParameter<> & argHelp = parameters.add<SwitchParameter<>> ('h', "help", "Show this help message and exit");
// set defaults // set defaults
argFps.setDefault(10); argFps.setDefault(10);
argCropWidth.setDefault(0); argCropWidth.setDefault(0);
argCropHeight.setDefault(0); argCropHeight.setDefault(0);
argSizeDecimation.setDefault(8); argSizeDecimation.setDefault(8);
argAddress.setDefault("127.0.0.1:19445"); argAddress.setDefault("127.0.0.1:19445");
argPriority.setDefault(800); argPriority.setDefault(800);
// parse all options // parse all options
optionParser.parse(argc, const_cast<const char **>(argv)); optionParser.parse(argc, const_cast<const char **>(argv));
// check if we need to display the usage. exit if we do. // check if we need to display the usage. exit if we do.
if (argHelp.isSet()) if (argHelp.isSet())
{ {
optionParser.usage(); optionParser.usage();
return 0; return 0;
} }
// cropping values if not defined // cropping values if not defined
if (!argCropLeft.isSet()) argCropLeft.setDefault(argCropWidth.getValue()); if (!argCropLeft.isSet()) argCropLeft.setDefault(argCropWidth.getValue());
if (!argCropRight.isSet()) argCropRight.setDefault(argCropWidth.getValue()); if (!argCropRight.isSet()) argCropRight.setDefault(argCropWidth.getValue());
if (!argCropTop.isSet()) argCropTop.setDefault(argCropHeight.getValue()); if (!argCropTop.isSet()) argCropTop.setDefault(argCropHeight.getValue());
if (!argCropBottom.isSet()) argCropBottom.setDefault(argCropHeight.getValue()); if (!argCropBottom.isSet()) argCropBottom.setDefault(argCropHeight.getValue());
// Create the X11 grabbing stuff // Create the X11 grabbing stuff
int grabInterval = 1000 / argFps.getValue(); int grabInterval = 1000 / argFps.getValue();
bool useXGetImage = argXGetImage.isSet(); bool useXGetImage = argXGetImage.isSet();
X11Wrapper x11Wrapper( X11Wrapper x11Wrapper(
grabInterval, grabInterval,
useXGetImage, useXGetImage,
argCropLeft.getValue(), argCropLeft.getValue(),
argCropRight.getValue(), argCropRight.getValue(),
argCropTop.getValue(), argCropTop.getValue(),
argCropBottom.getValue(), argCropBottom.getValue(),
argSizeDecimation.getValue(), // horizontal decimation argSizeDecimation.getValue(), // horizontal decimation
argSizeDecimation.getValue()); // vertical decimation argSizeDecimation.getValue()); // vertical decimation
if (!x11Wrapper.displayInit()) if (!x11Wrapper.displayInit())
return -1; return -1;
if (argScreenshot.isSet()) if (argScreenshot.isSet())
{ {
// Capture a single screenshot and finish // Capture a single screenshot and finish
const Image<ColorRgb> & screenshot = x11Wrapper.getScreenshot(); const Image<ColorRgb> & screenshot = x11Wrapper.getScreenshot();
saveScreenshot("screenshot.png", screenshot); saveScreenshot("screenshot.png", screenshot);
} }
else else
{ {
// Create the Proto-connection with hyperiond // Create the Proto-connection with hyperiond
ProtoConnectionWrapper protoWrapper(argAddress.getValue(), argPriority.getValue(), 1000, argSkipReply.isSet()); ProtoConnectionWrapper protoWrapper(argAddress.getValue(), argPriority.getValue(), 1000, argSkipReply.isSet());
// Connect the screen capturing to the proto processing // Connect the screen capturing to the proto processing
QObject::connect(&x11Wrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &protoWrapper, SLOT(receiveImage(Image<ColorRgb>))); QObject::connect(&x11Wrapper, SIGNAL(sig_screenshot(const Image<ColorRgb> &)), &protoWrapper, SLOT(receiveImage(Image<ColorRgb>)));
// Start the capturing // Start the capturing
x11Wrapper.start(); x11Wrapper.start();
// Start the application // Start the application
app.exec(); app.exec();
} }
} }
catch (const std::runtime_error & e) catch (const std::runtime_error & e)
{ {
// An error occured. Display error and quit // An error occured. Display error and quit
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return -1; return -1;
} }
return 0; return 0;
} }

View File

@ -51,10 +51,8 @@
// JsonServer includes // JsonServer includes
#include <jsonserver/JsonServer.h> #include <jsonserver/JsonServer.h>
#ifdef ENABLE_PROTOBUF
// ProtoServer includes // ProtoServer includes
#include <protoserver/ProtoServer.h> #include <protoserver/ProtoServer.h>
#endif
// BoblightServer includes // BoblightServer includes
#include <boblightserver/BoblightServer.h> #include <boblightserver/BoblightServer.h>
@ -208,7 +206,6 @@ int main(int argc, char** argv)
std::cout << "INFO: Json server created and started on port " << jsonServer->getPort() << std::endl; std::cout << "INFO: Json server created and started on port " << jsonServer->getPort() << std::endl;
} }
#ifdef ENABLE_PROTOBUF
// Create Proto server if configuration is present // Create Proto server if configuration is present
ProtoServer * protoServer = nullptr; ProtoServer * protoServer = nullptr;
if (config.isMember("protoServer")) if (config.isMember("protoServer"))
@ -217,7 +214,6 @@ int main(int argc, char** argv)
protoServer = new ProtoServer(&hyperion, protoServerConfig["port"].asUInt() ); protoServer = new ProtoServer(&hyperion, protoServerConfig["port"].asUInt() );
std::cout << "INFO: Proto server created and started on port " << protoServer->getPort() << std::endl; std::cout << "INFO: Proto server created and started on port " << protoServer->getPort() << std::endl;
} }
#endif
// Create Boblight server if configuration is present // Create Boblight server if configuration is present
BoblightServer * boblightServer = nullptr; BoblightServer * boblightServer = nullptr;
@ -254,9 +250,7 @@ int main(int argc, char** argv)
QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), dispmanx, SLOT(setVideoMode(VideoMode))); QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), dispmanx, SLOT(setVideoMode(VideoMode)));
} }
#ifdef ENABLE_PROTOBUF
QObject::connect(dispmanx, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) ); QObject::connect(dispmanx, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
#endif
dispmanx->start(); dispmanx->start();
std::cout << "INFO: Frame grabber created and started" << std::endl; std::cout << "INFO: Frame grabber created and started" << std::endl;
@ -297,9 +291,7 @@ int main(int argc, char** argv)
grabberConfig.get("cropTop", 0).asInt(), grabberConfig.get("cropTop", 0).asInt(),
grabberConfig.get("cropBottom", 0).asInt()); grabberConfig.get("cropBottom", 0).asInt());
#ifdef ENABLE_PROTOBUF
QObject::connect(v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) ); QObject::connect(v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
#endif
v4l2Grabber->start(); v4l2Grabber->start();
std::cout << "INFO: V4L2 grabber created and started" << std::endl; std::cout << "INFO: V4L2 grabber created and started" << std::endl;
@ -331,9 +323,7 @@ int main(int argc, char** argv)
QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), amlGrabber, SLOT(setVideoMode(VideoMode))); QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), amlGrabber, SLOT(setVideoMode(VideoMode)));
} }
#ifdef ENABLE_PROTOBUF
QObject::connect(amlGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) ); QObject::connect(amlGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
#endif
amlGrabber->start(); amlGrabber->start();
std::cout << "INFO: AMLOGIC grabber created and started" << std::endl; std::cout << "INFO: AMLOGIC grabber created and started" << std::endl;
@ -365,9 +355,7 @@ int main(int argc, char** argv)
QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), fbGrabber, SLOT(setVideoMode(VideoMode))); QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), fbGrabber, SLOT(setVideoMode(VideoMode)));
} }
#ifdef ENABLE_PROTOBUF
QObject::connect(fbGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) ); QObject::connect(fbGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
#endif
fbGrabber->start(); fbGrabber->start();
std::cout << "INFO: Framebuffer grabber created and started" << std::endl; std::cout << "INFO: Framebuffer grabber created and started" << std::endl;
@ -405,9 +393,7 @@ int main(int argc, char** argv)
QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), osxGrabber, SLOT(setVideoMode(VideoMode))); QObject::connect(xbmcVideoChecker, SIGNAL(videoMode(VideoMode)), osxGrabber, SLOT(setVideoMode(VideoMode)));
} }
#ifdef ENABLE_PROTOBUF
QObject::connect(osxGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) ); QObject::connect(osxGrabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)) );
#endif
osxGrabber->start(); osxGrabber->start();
std::cout << "INFO: OSX grabber created and started" << std::endl; std::cout << "INFO: OSX grabber created and started" << std::endl;
@ -445,9 +431,7 @@ int main(int argc, char** argv)
#endif #endif
delete xbmcVideoChecker; delete xbmcVideoChecker;
delete jsonServer; delete jsonServer;
#ifdef ENABLE_PROTOBUF
delete protoServer; delete protoServer;
#endif
delete boblightServer; delete boblightServer;
// leave application // leave application