From 569e59110e44235eab10ea1ac48e2495205b0d45 Mon Sep 17 00:00:00 2001 From: redPanther Date: Fri, 4 Aug 2017 23:08:15 +0200 Subject: [PATCH] implement set videomode via json api (#457) * implement set videomode via json api * refactor grabbers: - new base class - move shared code to base class * fix osx * rework all cmakelist files with auto file collection. except leddevices (need further restructuring) * store current video and grabbing mode * add json stuff * remove grabbingmode - we do not want to expose it --- include/grabber/AmlogicGrabber.h | 22 +------- include/grabber/AmlogicWrapper.h | 6 +- include/grabber/DispmanxFrameGrabber.h | 28 +--------- include/grabber/FramebufferFrameGrabber.h | 24 +------- include/grabber/OsxFrameGrabber.h | 24 +------- include/grabber/V4L2Grabber.h | 30 +++------- include/grabber/V4L2Wrapper.h | 5 +- include/grabber/X11Grabber.h | 35 +++--------- include/grabber/X11Wrapper.h | 1 - include/hyperion/Grabber.h | 53 ++++++++++++++++++ include/hyperion/GrabberWrapper.h | 7 +++ include/hyperion/Hyperion.h | 26 +++++++++ include/utils/GrabbingMode.h | 17 ++++++ include/utils/JsonProcessor.h | 6 ++ include/utils/VideoMode.h | 15 ++++- libsrc/blackborder/CMakeLists.txt | 19 +------ libsrc/boblightserver/CMakeLists.txt | 18 ++---- libsrc/bonjour/CMakeLists.txt | 24 +------- libsrc/commandline/CMakeLists.txt | 37 ++---------- libsrc/effectengine/CMakeLists.txt | 18 ++---- libsrc/grabber/amlogic/AmlogicGrabber.cpp | 25 ++------- libsrc/grabber/amlogic/CMakeLists.txt | 16 +----- libsrc/grabber/dispmanx/CMakeLists.txt | 16 +----- .../grabber/dispmanx/DispmanxFrameGrabber.cpp | 28 +++------- libsrc/grabber/framebuffer/CMakeLists.txt | 20 +------ .../framebuffer/FramebufferFrameGrabber.cpp | 25 +++------ libsrc/grabber/osx/CMakeLists.txt | 15 +---- libsrc/grabber/osx/OsxFrameGrabber.cpp | 23 +++----- libsrc/grabber/v4l2/CMakeLists.txt | 16 +----- libsrc/grabber/v4l2/V4L2Grabber.cpp | 12 +--- libsrc/grabber/v4l2/V4L2Wrapper.cpp | 11 +++- libsrc/grabber/x11/CMakeLists.txt | 23 ++------ libsrc/grabber/x11/X11Grabber.cpp | 46 ++++++--------- libsrc/grabber/x11/X11Wrapper.cpp | 1 + libsrc/hyperion/CMakeLists.txt | 39 +------------ libsrc/hyperion/Grabber.cpp | 27 +++++++++ libsrc/hyperion/GrabberWrapper.cpp | 3 + libsrc/hyperion/Hyperion.cpp | 15 +++++ libsrc/jsonserver/CMakeLists.txt | 18 ++---- libsrc/kodivideochecker/CMakeLists.txt | 14 +---- libsrc/leddevice/CMakeLists.txt | 9 +-- libsrc/protoserver/CMakeLists.txt | 24 +------- libsrc/udplistener/CMakeLists.txt | 16 ++---- libsrc/utils/CMakeLists.txt | 56 ++----------------- .../JSONRPC_schema/schema-videomode.json | 19 +++++++ libsrc/utils/JSONRPC_schema/schema.json | 2 +- libsrc/utils/JSONRPC_schemas.qrc | 1 + libsrc/utils/JsonProcessor.cpp | 22 +++++--- libsrc/webconfig/CMakeLists.txt | 23 +------- src/hyperion-remote/JsonConnection.cpp | 10 ++++ src/hyperion-remote/JsonConnection.h | 4 ++ src/hyperion-remote/hyperion-remote.cpp | 7 ++- src/hyperion-v4l2/hyperion-v4l2.cpp | 4 +- src/hyperiond/hyperiond.cpp | 29 +++------- 54 files changed, 375 insertions(+), 659 deletions(-) create mode 100644 include/hyperion/Grabber.h create mode 100644 libsrc/hyperion/Grabber.cpp create mode 100644 libsrc/utils/JSONRPC_schema/schema-videomode.json diff --git a/include/grabber/AmlogicGrabber.h b/include/grabber/AmlogicGrabber.h index 158f91f5..1b9dd8cc 100755 --- a/include/grabber/AmlogicGrabber.h +++ b/include/grabber/AmlogicGrabber.h @@ -1,18 +1,14 @@ #pragma once -// STL includes -#include -#include // Utils includes -#include #include -#include +#include /// /// The DispmanxFrameGrabber is used for creating snapshots of the display (screenshots) with a /// downsized and scaled resolution. /// -class AmlogicGrabber +class AmlogicGrabber : public Grabber { public: /// @@ -24,12 +20,6 @@ public: AmlogicGrabber(const unsigned width, const unsigned height); ~AmlogicGrabber(); - /// - /// Set the video mode (2D/3D) - /// @param[in] mode The new video mode - /// - void setVideoMode(const VideoMode videoMode); - /// /// Captures a single snapshot of the display and writes the data to the given image. The /// provided image should have the same dimensions as the configured values (_width and @@ -47,14 +37,6 @@ public: */ bool isVideoPlaying(); private: - - /// With of the captured snapshot [pixels] - const unsigned _width; - /// Height of the captured snapshot [pixels] - const unsigned _height; - /** The snapshot/capture device of the amlogic video chip */ int _amlogicCaptureDev; - - Logger * _log; }; diff --git a/include/grabber/AmlogicWrapper.h b/include/grabber/AmlogicWrapper.h index 0673933b..82b8243e 100644 --- a/include/grabber/AmlogicWrapper.h +++ b/include/grabber/AmlogicWrapper.h @@ -42,11 +42,7 @@ public slots: /// virtual void action(); - /// - /// Set the video mode (2D/3D) - /// @param[in] mode The new video mode - /// - void setVideoMode(const VideoMode videoMode); + virtual void setVideoMode(const VideoMode mode); private: /// The update rate [Hz] diff --git a/include/grabber/DispmanxFrameGrabber.h b/include/grabber/DispmanxFrameGrabber.h index 1372fa62..0f28e33e 100644 --- a/include/grabber/DispmanxFrameGrabber.h +++ b/include/grabber/DispmanxFrameGrabber.h @@ -4,20 +4,15 @@ #pragma GCC system_header #include -// STL includes -#include - // Utils includes -#include #include -#include -#include +#include /// /// The DispmanxFrameGrabber is used for creating snapshots of the display (screenshots) with a /// downsized and scaled resolution. /// -class DispmanxFrameGrabber +class DispmanxFrameGrabber : public Grabber { public: /// @@ -36,12 +31,6 @@ public: /// void setFlags(const int vc_flags); - /// - /// Set the video mode (2D/3D) - /// @param[in] mode The new video mode - /// - void setVideoMode(const VideoMode videoMode); - void setCropping(const unsigned cropLeft, const unsigned cropRight, const unsigned cropTop, const unsigned cropBottom); @@ -68,23 +57,10 @@ private: /// Flags (transforms) for creating snapshots int _vc_flags; - /// With of the captured snapshot [pixels] - const unsigned _width; - /// Height of the captured snapshot [pixels] - const unsigned _height; - - // the selected VideoMode - VideoMode _videoMode; - - // number of pixels to crop after capturing - unsigned _cropLeft, _cropRight, _cropTop, _cropBottom; - // temp buffer when capturing with unsupported pitch size or // when we need to crop the image ColorRgba* _captureBuffer; // size of the capture buffer in Pixels unsigned _captureBufferSize; - - Logger * _log; }; diff --git a/include/grabber/FramebufferFrameGrabber.h b/include/grabber/FramebufferFrameGrabber.h index fd5add9c..d478c074 100644 --- a/include/grabber/FramebufferFrameGrabber.h +++ b/include/grabber/FramebufferFrameGrabber.h @@ -1,16 +1,13 @@ #pragma once // Utils includes -#include #include -#include -#include -#include +#include /// /// The FramebufferFrameGrabber is used for creating snapshots of the display (screenshots) /// -class FramebufferFrameGrabber +class FramebufferFrameGrabber : public Grabber { public: /// @@ -23,12 +20,6 @@ public: FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height); ~FramebufferFrameGrabber(); - /// - /// Set the video mode (2D/3D) - /// @param[in] mode The new video mode - /// - void setVideoMode(const VideoMode videoMode); - /// /// Captures a single snapshot of the display and writes the data to the given image. The /// provided image should have the same dimensions as the configured values (_width and @@ -48,15 +39,4 @@ private: /// Framebuffer device e.g. /dev/fb0 const QString _fbDevice; - - /// With of the captured snapshot [pixels] - const unsigned _width; - - /// Height of the captured snapshot [pixels] - const unsigned _height; - - /// Image resampler for downscaling the image - ImageResampler * _imgResampler; - - Logger * _log; }; diff --git a/include/grabber/OsxFrameGrabber.h b/include/grabber/OsxFrameGrabber.h index 16872881..1126478f 100644 --- a/include/grabber/OsxFrameGrabber.h +++ b/include/grabber/OsxFrameGrabber.h @@ -4,16 +4,13 @@ #include // Utils includes -#include #include -#include -#include -#include +#include /// /// The OsxFrameGrabber is used for creating snapshots of the display (screenshots) /// -class OsxFrameGrabber +class OsxFrameGrabber : public Grabber { public: /// @@ -26,12 +23,6 @@ public: OsxFrameGrabber(const unsigned display, const unsigned width, const unsigned height); ~OsxFrameGrabber(); - /// - /// Set the video mode (2D/3D) - /// @param[in] mode The new video mode - /// - void setVideoMode(const VideoMode videoMode); - /// /// Captures a single snapshot of the display and writes the data to the given image. The /// provided image should have the same dimensions as the configured values (_width and @@ -46,17 +37,6 @@ private: /// display const unsigned _screenIndex; - /// With of the captured snapshot [pixels] - const unsigned _width; - - /// Height of the captured snapshot [pixels] - const unsigned _height; - /// Reference to the captured diaplay CGDirectDisplayID _display; - - /// Image resampler for downscaling the image - ImageResampler * _imgResampler; - - Logger * _log; }; diff --git a/include/grabber/V4L2Grabber.h b/include/grabber/V4L2Grabber.h index 3a877eed..8a631a5c 100644 --- a/include/grabber/V4L2Grabber.h +++ b/include/grabber/V4L2Grabber.h @@ -10,12 +10,9 @@ #include // util includes -#include #include #include -#include -#include -#include +#include // grabber includes #include @@ -23,7 +20,7 @@ /// Capture class for V4L2 devices /// /// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html -class V4L2Grabber : public QObject +class V4L2Grabber : public Grabber { Q_OBJECT @@ -48,8 +45,6 @@ public slots: int cropTop, int cropBottom); - void set3D(VideoMode mode); - void setSignalThreshold( double redSignalThreshold, double greenSignalThreshold, @@ -124,18 +119,16 @@ private: private: QString _deviceName; std::map _v4lDevices; - int _input; - VideoStandard _videoStandard; - io_method _ioMethod; - int _fileDescriptor; + int _input; + VideoStandard _videoStandard; + io_method _ioMethod; + int _fileDescriptor; std::vector _buffers; PixelFormat _pixelFormat; - int _width; - int _height; - int _lineLength; - int _frameByteSize; - int _frameDecimation; + int _lineLength; + int _frameByteSize; + int _frameDecimation; // signal detection int _noSignalCounterThreshold; @@ -151,11 +144,6 @@ private: QSocketNotifier * _streamNotifier; - ImageResampler _imageResampler; - - Logger * _log; bool _initialized; bool _deviceAutoDiscoverEnabled; - - }; diff --git a/include/grabber/V4L2Wrapper.h b/include/grabber/V4L2Wrapper.h index 39e52192..fbeb23f0 100644 --- a/include/grabber/V4L2Wrapper.h +++ b/include/grabber/V4L2Wrapper.h @@ -24,7 +24,8 @@ public: double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, - const int priority); + const int priority, + bool useGrabbingMode); virtual ~V4L2Wrapper(); bool getSignalDetectionEnable(); @@ -35,7 +36,7 @@ public slots: void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom); void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax); - void set3D(VideoMode mode); + void setVideoMode(VideoMode mode); void setSignalDetectionEnable(bool enable); // signals: diff --git a/include/grabber/X11Grabber.h b/include/grabber/X11Grabber.h index e026bab2..26c30991 100755 --- a/include/grabber/X11Grabber.h +++ b/include/grabber/X11Grabber.h @@ -1,9 +1,11 @@ +#pragma once + +#include // Hyperion-utils includes -#include #include -#include -#include +#include + // X11 includes #include #include @@ -11,7 +13,7 @@ #include #include -class X11Grabber +class X11Grabber : public Grabber { public: @@ -19,12 +21,6 @@ public: virtual ~X11Grabber(); - /// - /// Set the video mode (2D/3D) - /// @param[in] mode The new video mode - /// - void setVideoMode(const VideoMode videoMode); - bool Setup(); Image & grab(); @@ -43,21 +39,9 @@ public: /// update dimension according current screen int updateScreenDimensions(); - /// gets resulting height of image - const unsigned getImageWidth() { return _croppedWidth; }; - - /// gets resulting width of image - const unsigned getImageHeight() { return _croppedHeight; }; - private: - ImageResampler _imageResampler; - bool _useXGetImage, _XShmAvailable, _XShmPixmapAvailable, _XRenderAvailable; - int _cropLeft; - int _cropRight; - int _cropTop; - int _cropBottom; - + XImage* _xImage; XShmSegmentInfo _shminfo; @@ -79,14 +63,9 @@ private: unsigned _screenWidth; unsigned _screenHeight; - unsigned _croppedWidth; - unsigned _croppedHeight; Image _image; void freeResources(); void setupResources(); - - - Logger * _log; }; diff --git a/include/grabber/X11Wrapper.h b/include/grabber/X11Wrapper.h index 51adb34b..24ecdc62 100644 --- a/include/grabber/X11Wrapper.h +++ b/include/grabber/X11Wrapper.h @@ -17,7 +17,6 @@ class ImageProcessor; /// class X11Wrapper: public GrabberWrapper { - Q_OBJECT public: /// /// Constructs the framebuffer frame grabber with a specified grab size and update rate. diff --git a/include/hyperion/Grabber.h b/include/hyperion/Grabber.h new file mode 100644 index 00000000..83a9c783 --- /dev/null +++ b/include/hyperion/Grabber.h @@ -0,0 +1,53 @@ +#pragma once + +#include +#include + +#include +#include +#include +#include +#include + + +class Grabber : public QObject +{ + Q_OBJECT + +public: + Grabber(QString grabberName, int width=0, int height=0, int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0); + ~Grabber(); + + /// + /// Set the video mode (2D/3D) + /// @param[in] mode The new video mode + /// + void setVideoMode(VideoMode mode); + + /// gets resulting height of image + const int getImageWidth() { return _width; }; + + /// gets resulting width of image + const int getImageHeight() { return _height; }; + + +protected: + ImageResampler _imageResampler; + + /// the selected VideoMode + VideoMode _videoMode; + + /// With of the captured snapshot [pixels] + int _width; + + /// Height of the captured snapshot [pixels] + int _height; + + // number of pixels to crop after capturing + int _cropLeft, _cropRight, _cropTop, _cropBottom; + + + /// logger instance + Logger * _log; + +}; diff --git a/include/hyperion/GrabberWrapper.h b/include/hyperion/GrabberWrapper.h index d73d4587..43c52aa5 100644 --- a/include/hyperion/GrabberWrapper.h +++ b/include/hyperion/GrabberWrapper.h @@ -46,6 +46,13 @@ public slots: /// void setGrabbingMode(const GrabbingMode mode); + /// + /// Set the video mode (2D/3D) + /// @param[in] mode The new video mode + /// + virtual void setVideoMode(const VideoMode videoMode) = 0; + + signals: void emitImage(int priority, const Image & image, const int timeout_ms); diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h index 8de93dac..63ea3b32 100644 --- a/include/hyperion/Hyperion.h +++ b/include/hyperion/Hyperion.h @@ -21,6 +21,8 @@ #include #include #include +#include +#include // Hyperion includes #include @@ -192,6 +194,9 @@ public: /// forward smoothing config unsigned addSmoothingConfig(int settlingTime_ms, double ledUpdateFrequency_hz=25.0, unsigned updateDelay=0); + VideoMode getCurrentVideoMode() { return _videoMode; }; + GrabbingMode getCurrentGrabbingMode() { return _grabbingMode; }; + public slots: /// /// Writes a single color to all the leds for the given time and priority @@ -280,6 +285,19 @@ public slots: /// Slot which is called, when state of hyperion has been changed void hyperionStateChanged(); + /// + /// Set the video mode (2D/3D) + /// @param[in] mode The new video mode + /// + void setVideoMode(VideoMode mode); + + /// + /// Set the grabbing mode + /// @param[in] mode The new grabbing mode + /// + void setGrabbingMode(const GrabbingMode mode); + + public: static Hyperion *_hyperion; @@ -324,6 +342,11 @@ signals: /// Signal which is emitted, after the hyperionStateChanged has been processed with a emit count blocker (250ms interval) void sendServerInfo(); + /// Signal emitted when a 3D movie is detected + void videoMode(VideoMode mode); + + void grabbingMode(GrabbingMode mode); + private slots: /// /// Updates the priority muxer with the current time and (re)writes the led color with applied @@ -432,4 +455,7 @@ private: /// timers to handle severinfo blocking QTimer _fsi_timer; QTimer _fsi_blockTimer; + + VideoMode _videoMode; + GrabbingMode _grabbingMode; }; diff --git a/include/utils/GrabbingMode.h b/include/utils/GrabbingMode.h index 83f06beb..7a7bfe17 100644 --- a/include/utils/GrabbingMode.h +++ b/include/utils/GrabbingMode.h @@ -1,5 +1,7 @@ #pragma once +#include + /** * Enumeration of the possible modes in which frame-grabbing is performed. */ @@ -16,3 +18,18 @@ enum GrabbingMode GRABBINGMODE_SCREENSAVER, GRABBINGMODE_INVALID }; + +inline QString grabbingMode2String(GrabbingMode mode) +{ + switch(mode) + { + case GRABBINGMODE_OFF: return "OFF"; + case GRABBINGMODE_VIDEO: return "VIDEO"; + case GRABBINGMODE_PAUSE: return "PAUSE"; + case GRABBINGMODE_PHOTO: return "PHOTO"; + case GRABBINGMODE_AUDIO: return "AUDIO"; + case GRABBINGMODE_MENU: return "MENU"; + case GRABBINGMODE_SCREENSAVER: return "SCREENSAVER"; + default: return "INVALID"; + } +} diff --git a/include/utils/JsonProcessor.h b/include/utils/JsonProcessor.h index 3d1f031b..89d58d37 100644 --- a/include/utils/JsonProcessor.h +++ b/include/utils/JsonProcessor.h @@ -244,6 +244,12 @@ private: /// void handleProcessingCommand(const QJsonObject & message, const QString &command, const int tan); + /// Handle an incoming JSON VideoMode message + /// + /// @param message the incoming message + /// + void handleVideoModeCommand(const QJsonObject & message, const QString &command, const int tan); + /// /// Handle an incoming JSON message of unknown type /// diff --git a/include/utils/VideoMode.h b/include/utils/VideoMode.h index 226a0e1f..654a6431 100644 --- a/include/utils/VideoMode.h +++ b/include/utils/VideoMode.h @@ -14,8 +14,8 @@ enum VideoMode inline VideoMode parse3DMode(QString videoMode) { - // convert to lower case - videoMode = videoMode.toLower(); + // convert to upper case + videoMode = videoMode.toUpper(); if (videoMode == "3DTAB") { @@ -29,3 +29,14 @@ inline VideoMode parse3DMode(QString videoMode) // return the default 2D return VIDEO_2D; } + +inline QString videoMode2String(VideoMode mode) +{ + switch(mode) + { + case VIDEO_3DTAB: return "3DTAB"; + case VIDEO_3DSBS: return "3DSBS"; + case VIDEO_2D: return "2D"; + default: return "INVALID"; + } +} diff --git a/libsrc/blackborder/CMakeLists.txt b/libsrc/blackborder/CMakeLists.txt index 97d62739..023ebb60 100644 --- a/libsrc/blackborder/CMakeLists.txt +++ b/libsrc/blackborder/CMakeLists.txt @@ -3,21 +3,8 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/blackborder) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/blackborder) -SET(Blackborder_HEADERS - ${CURRENT_HEADER_DIR}/BlackBorderDetector.h - ${CURRENT_HEADER_DIR}/BlackBorderProcessor.h -) +FILE ( GLOB Blackborder_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(Blackborder_SOURCES - ${CURRENT_SOURCE_DIR}/BlackBorderDetector.cpp - ${CURRENT_SOURCE_DIR}/BlackBorderProcessor.cpp -) +add_library(blackborder ${Blackborder_SOURCES} ) -add_library(blackborder - ${Blackborder_HEADERS} - ${Blackborder_SOURCES} -) - -target_link_libraries(blackborder - hyperion-utils -) +target_link_libraries(blackborder hyperion-utils ) diff --git a/libsrc/boblightserver/CMakeLists.txt b/libsrc/boblightserver/CMakeLists.txt index 110953a3..1587d4df 100644 --- a/libsrc/boblightserver/CMakeLists.txt +++ b/libsrc/boblightserver/CMakeLists.txt @@ -3,22 +3,12 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/boblightserver) set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/boblightserver) -set(BoblightServer_HEADERS - ${CURRENT_HEADER_DIR}/BoblightServer.h - ${CURRENT_SOURCE_DIR}/BoblightClientConnection.h -) +FILE ( GLOB BoblightServer_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -set(BoblightServer_SOURCES - ${CURRENT_SOURCE_DIR}/BoblightServer.cpp - ${CURRENT_SOURCE_DIR}/BoblightClientConnection.cpp -) - -add_library(boblightserver - ${BoblightServer_HEADERS} - ${BoblightServer_SOURCES} -) +add_library(boblightserver ${BoblightServer_SOURCES} ) target_link_libraries(boblightserver hyperion hyperion-utils - ${QT_LIBRARIES}) + ${QT_LIBRARIES} +) diff --git a/libsrc/bonjour/CMakeLists.txt b/libsrc/bonjour/CMakeLists.txt index 0cd64c44..20b61823 100644 --- a/libsrc/bonjour/CMakeLists.txt +++ b/libsrc/bonjour/CMakeLists.txt @@ -3,29 +3,9 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/bonjour) set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/bonjour) -set(Bonjour_HEADERS - ${CURRENT_HEADER_DIR}/bonjourserviceregister.h - ${CURRENT_HEADER_DIR}/bonjourservicebrowser.h - ${CURRENT_HEADER_DIR}/bonjourserviceresolver.h -) +FILE ( GLOB Bonjour_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -set(Bonjour_SOURCES - ${CURRENT_SOURCE_DIR}/bonjourserviceregister.cpp - ${CURRENT_SOURCE_DIR}/bonjourservicebrowser.cpp - ${CURRENT_SOURCE_DIR}/bonjourserviceresolver.cpp -) - -#set(Bonjour_RESOURCES -#) - -#qt5_add_resources(Bonjour_RESOURCES_RCC ${Bonjour_RESOURCES} OPTIONS "-no-compress") - -add_library(bonjour - ${Bonjour_HEADERS} - ${Bonjour_SOURCES} - ${Bonjour_RESOURCES} - ${Bonjour_RESOURCES_RCC} -) +add_library(bonjour ${Bonjour_SOURCES} ) target_link_libraries(bonjour hyperion diff --git a/libsrc/commandline/CMakeLists.txt b/libsrc/commandline/CMakeLists.txt index 493d0f9a..d59b2360 100644 --- a/libsrc/commandline/CMakeLists.txt +++ b/libsrc/commandline/CMakeLists.txt @@ -2,40 +2,11 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/commandline) set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/commandline) -set(Parser_HEADERS - ${CURRENT_HEADER_DIR}/ColorOption.h - ${CURRENT_HEADER_DIR}/ColorsOption.h - ${CURRENT_HEADER_DIR}/DoubleOption.h - ${CURRENT_HEADER_DIR}/ImageOption.h - ${CURRENT_HEADER_DIR}/IntOption.h - ${CURRENT_HEADER_DIR}/Option.h - ${CURRENT_HEADER_DIR}/Parser.h - ${CURRENT_HEADER_DIR}/RegularExpressionOption.h - ${CURRENT_HEADER_DIR}/SwitchOption.h - ${CURRENT_HEADER_DIR}/ValidatorOption.h - ${CURRENT_HEADER_DIR}/BooleanOption.h -) +FILE ( GLOB Parser_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -set(Parser_SOURCES - ${CURRENT_SOURCE_DIR}/ColorOption.cpp - ${CURRENT_SOURCE_DIR}/ColorsOption.cpp - ${CURRENT_SOURCE_DIR}/DoubleOption.cpp - ${CURRENT_SOURCE_DIR}/ImageOption.cpp - ${CURRENT_SOURCE_DIR}/IntOption.cpp - ${CURRENT_SOURCE_DIR}/Option.cpp - ${CURRENT_SOURCE_DIR}/Parser.cpp - ${CURRENT_SOURCE_DIR}/RegularExpressionOption.cpp - ${CURRENT_SOURCE_DIR}/SwitchOption.cpp - ${CURRENT_SOURCE_DIR}/ValidatorOption.cpp - ${CURRENT_SOURCE_DIR}/BooleanOption.cpp -) - -add_library(commandline - ${Parser_HEADERS} - ${Parser_SOURCES} -) +add_library(commandline ${Parser_SOURCES} ) target_link_libraries(commandline - hyperion - Qt5::Gui + hyperion + Qt5::Gui ) diff --git a/libsrc/effectengine/CMakeLists.txt b/libsrc/effectengine/CMakeLists.txt index c67d79c6..f2a33c9d 100644 --- a/libsrc/effectengine/CMakeLists.txt +++ b/libsrc/effectengine/CMakeLists.txt @@ -9,19 +9,9 @@ include_directories(${PYTHON_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}/..) SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/effectengine) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/effectengine) -SET(EffectEngineHEADERS - ${CURRENT_HEADER_DIR}/EffectDefinition.h - ${CURRENT_HEADER_DIR}/EffectEngine.h - ${CURRENT_SOURCE_DIR}/Effect.h -) - -SET(EffectEngineSOURCES - ${CURRENT_SOURCE_DIR}/EffectEngine.cpp - ${CURRENT_SOURCE_DIR}/Effect.cpp -) - - +FILE ( GLOB EffectEngineSOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) FILE ( GLOB effectFiles RELATIVE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/effects/* ) + SET ( HYPERION_EFFECTS_RES "") FOREACH( f ${effectFiles} ) GET_FILENAME_COMPONENT(fname ${f} NAME) @@ -34,7 +24,6 @@ SET(EffectEngine_RESOURCES ${CMAKE_BINARY_DIR}/EffectEngine.qrc) qt5_add_resources(EffectEngine_RESOURCES_RCC ${EffectEngine_RESOURCES} ) # OPTIONS "-no-compress" add_library(effectengine - ${EffectEngineHEADERS} ${EffectEngine_RESOURCES_RCC} ${EffectEngineSOURCES} ) @@ -43,4 +32,5 @@ target_link_libraries(effectengine hyperion Qt5::Core Qt5::Gui - ${PYTHON_LIBRARIES}) + ${PYTHON_LIBRARIES} +) diff --git a/libsrc/grabber/amlogic/AmlogicGrabber.cpp b/libsrc/grabber/amlogic/AmlogicGrabber.cpp index 76db83a8..1422e59c 100755 --- a/libsrc/grabber/amlogic/AmlogicGrabber.cpp +++ b/libsrc/grabber/amlogic/AmlogicGrabber.cpp @@ -31,10 +31,8 @@ #endif AmlogicGrabber::AmlogicGrabber(const unsigned width, const unsigned height) - : _width(qMax(160u, width)) // Minimum required width or height is 160 - , _height(qMax(160u, height)) + : Grabber("AMLOGICGRABBER", qMax(160u, width), qMax(160u, height)) // Minimum required width or height is 160 , _amlogicCaptureDev(-1) - , _log(Logger::getInstance("AMLOGICGRABBER")) { Debug(_log, "constructed(%d x %d)",_width,_height); } @@ -51,24 +49,13 @@ AmlogicGrabber::~AmlogicGrabber() } } -void AmlogicGrabber::setVideoMode(const VideoMode videoMode) -{ - switch (videoMode) { - case VIDEO_3DSBS: - //vc_dispmanx_rect_set(&_rectangle, 0, 0, _width/2, _height); - break; - case VIDEO_3DTAB: - //vc_dispmanx_rect_set(&_rectangle, 0, 0, _width, _height/2); - break; - case VIDEO_2D: - default: - //vc_dispmanx_rect_set(&_rectangle, 0, 0, _width, _height); - break; - } -} bool AmlogicGrabber::isVideoPlaying() { + + // TODO crop resulting image accroding member _videoMode + // TODO add croping + const QString videoDevice = "/dev/amvideo"; // Open the video device @@ -97,7 +84,7 @@ bool AmlogicGrabber::isVideoPlaying() int AmlogicGrabber::grabFrame(Image & image) { // resize the given image if needed - if (image.width() != _width || image.height() != _height) + if (image.width() != (unsigned)_width || image.height() != (unsigned)_height) { image.resize(_width, _height); } diff --git a/libsrc/grabber/amlogic/CMakeLists.txt b/libsrc/grabber/amlogic/CMakeLists.txt index fef559b9..40ce2d59 100644 --- a/libsrc/grabber/amlogic/CMakeLists.txt +++ b/libsrc/grabber/amlogic/CMakeLists.txt @@ -4,26 +4,14 @@ INCLUDE (CheckIncludeFiles) SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/amlogic) -SET(AmlogicHEADERS - ${CURRENT_HEADER_DIR}/AmlogicGrabber.h - ${CURRENT_HEADER_DIR}/AmlogicWrapper.h -) - -SET(AmlogicSOURCES - ${CURRENT_SOURCE_DIR}/AmlogicWrapper.cpp - ${CURRENT_SOURCE_DIR}/AmlogicGrabber.cpp -) +FILE ( GLOB AmlogicSOURCES "${CURRENT_HEADER_DIR}/Amlogic*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) CHECK_INCLUDE_FILES ("amcodec/amports/amstream.h" HAVE_AML_HEADER) IF (${HAVE_AML_HEADER}) ADD_DEFINITIONS( -DHAVE_AML_HEADER ) ENDIF() - -add_library(amlogic-grabber - ${AmlogicHEADERS} - ${AmlogicSOURCES} -) +add_library(amlogic-grabber ${AmlogicSOURCES} ) target_link_libraries(amlogic-grabber hyperion diff --git a/libsrc/grabber/dispmanx/CMakeLists.txt b/libsrc/grabber/dispmanx/CMakeLists.txt index 59b0a66d..2da57aa5 100644 --- a/libsrc/grabber/dispmanx/CMakeLists.txt +++ b/libsrc/grabber/dispmanx/CMakeLists.txt @@ -1,4 +1,3 @@ - # Find the BCM-package (VC control) find_package(BCM REQUIRED) include_directories(${BCM_INCLUDE_DIRS}) @@ -7,20 +6,9 @@ include_directories(${BCM_INCLUDE_DIRS}) SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/dispmanx) -SET(DispmanxGrabberHEADERS - ${CURRENT_HEADER_DIR}/DispmanxWrapper.h - ${CURRENT_HEADER_DIR}/DispmanxFrameGrabber.h -) +FILE ( GLOB DispmanxGrabberSOURCES "${CURRENT_HEADER_DIR}/Dispmanx*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(DispmanxGrabberSOURCES - ${CURRENT_SOURCE_DIR}/DispmanxWrapper.cpp - ${CURRENT_SOURCE_DIR}/DispmanxFrameGrabber.cpp -) - -add_library(dispmanx-grabber - ${DispmanxGrabberHEADERS} - ${DispmanxGrabberSOURCES} -) +add_library(dispmanx-grabber ${DispmanxGrabberSOURCES} ) target_link_libraries(dispmanx-grabber hyperion diff --git a/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp b/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp index f8649d28..d5003a1b 100644 --- a/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp +++ b/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp @@ -6,20 +6,13 @@ // Local includes #include "grabber/DispmanxFrameGrabber.h" -DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned height) : - _vc_display(0), - _vc_resource(0), - _vc_flags(0), - _width(width), - _height(height), - _videoMode(VIDEO_2D), - _cropLeft(0), - _cropRight(0), - _cropTop(0), - _cropBottom(0), - _captureBuffer(new ColorRgba[0]), - _captureBufferSize(0), - _log(Logger::getInstance("DISPMANXGRABBER")) +DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned height) + : Grabber("DISPMANXGRABBER", width, height) + , _vc_display(0) + , _vc_resource(0) + , _vc_flags(0) + , _captureBuffer(new ColorRgba[0]) + , _captureBufferSize(0) { // Initiase BCM bcm_host_init(); @@ -71,14 +64,9 @@ void DispmanxFrameGrabber::setFlags(const int vc_flags) _vc_flags = vc_flags; } -void DispmanxFrameGrabber::setVideoMode(const VideoMode videoMode) -{ - _videoMode = videoMode; -} - void DispmanxFrameGrabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom) { - if (cropLeft + cropRight >= _width || cropTop + cropBottom >= _height) + if (cropLeft + cropRight >= (unsigned)_width || cropTop + cropBottom >= (unsigned)_height) { Error(_log, "Rejecting invalid crop values: left: %d, right: %d, top: %d, bottom: %d", cropLeft, cropRight, cropTop, cropBottom); return; diff --git a/libsrc/grabber/framebuffer/CMakeLists.txt b/libsrc/grabber/framebuffer/CMakeLists.txt index 3e9367f8..af1368ff 100644 --- a/libsrc/grabber/framebuffer/CMakeLists.txt +++ b/libsrc/grabber/framebuffer/CMakeLists.txt @@ -1,26 +1,10 @@ - -# Find the BCM-package (VC control) -# find_package(BCM REQUIRED) -# include_directories(${BCM_INCLUDE_DIRS}) - # Define the current source locations SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/framebuffer) -SET(FramebufferGrabberHEADERS - ${CURRENT_HEADER_DIR}/FramebufferFrameGrabber.h - ${CURRENT_HEADER_DIR}/FramebufferWrapper.h -) +FILE ( GLOB FramebufferGrabberSOURCES "${CURRENT_HEADER_DIR}/Framebuffer*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(FramebufferGrabberSOURCES - ${CURRENT_SOURCE_DIR}/FramebufferWrapper.cpp - ${CURRENT_SOURCE_DIR}/FramebufferFrameGrabber.cpp -) - -add_library(framebuffer-grabber - ${FramebufferGrabberHEADERS} - ${FramebufferGrabberSOURCES} -) +add_library(framebuffer-grabber ${FramebufferGrabberSOURCES} ) target_link_libraries(framebuffer-grabber hyperion diff --git a/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp b/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp index fa320f22..9e072830 100755 --- a/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp +++ b/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp @@ -12,14 +12,11 @@ // Local includes #include -FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height) : - _fbfd(0), - _fbp(0), - _fbDevice(device), - _width(width), - _height(height), - _imgResampler(new ImageResampler()), - _log(Logger::getInstance("FRAMEBUFFERGRABBER")) +FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height) + : Grabber("FRAMEBUFFERGRABBER", width, height) + , _fbfd(0) + , _fbp(0) + , _fbDevice(device) { int result; struct fb_var_screeninfo vinfo; @@ -48,12 +45,6 @@ FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const u FramebufferFrameGrabber::~FramebufferFrameGrabber() { - delete _imgResampler; -} - -void FramebufferFrameGrabber::setVideoMode(const VideoMode videoMode) -{ - _imgResampler->set3D(videoMode); } void FramebufferFrameGrabber::grabFrame(Image & image) @@ -93,9 +84,9 @@ void FramebufferFrameGrabber::grabFrame(Image & image) /* map the device to memory */ _fbp = (unsigned char*)mmap(0, capSize, PROT_READ, MAP_PRIVATE | MAP_NORESERVE, _fbfd, 0); - _imgResampler->setHorizontalPixelDecimation(vinfo.xres/_width); - _imgResampler->setVerticalPixelDecimation(vinfo.yres/_height); - _imgResampler->processImage(_fbp, + _imageResampler.setHorizontalPixelDecimation(vinfo.xres/_width); + _imageResampler.setVerticalPixelDecimation(vinfo.yres/_height); + _imageResampler.processImage(_fbp, vinfo.xres, vinfo.yres, vinfo.xres * bytesPerPixel, diff --git a/libsrc/grabber/osx/CMakeLists.txt b/libsrc/grabber/osx/CMakeLists.txt index 57e4ac81..3a5690c6 100644 --- a/libsrc/grabber/osx/CMakeLists.txt +++ b/libsrc/grabber/osx/CMakeLists.txt @@ -2,20 +2,9 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/osx) -SET(OsxGrabberHEADERS - ${CURRENT_HEADER_DIR}/OsxWrapper.h - ${CURRENT_HEADER_DIR}/OsxFrameGrabber.h -) +FILE ( GLOB OsxGrabberSOURCES "${CURRENT_HEADER_DIR}/Osx*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(OsxGrabberSOURCES - ${CURRENT_SOURCE_DIR}/OsxWrapper.cpp - ${CURRENT_SOURCE_DIR}/OsxFrameGrabber.cpp -) - -add_library(osx-grabber - ${OsxGrabberHEADERS} - ${OsxGrabberSOURCES} -) +add_library(osx-grabber ${OsxGrabberSOURCES} ) target_link_libraries(osx-grabber hyperion diff --git a/libsrc/grabber/osx/OsxFrameGrabber.cpp b/libsrc/grabber/osx/OsxFrameGrabber.cpp index 24e568ae..eb523836 100755 --- a/libsrc/grabber/osx/OsxFrameGrabber.cpp +++ b/libsrc/grabber/osx/OsxFrameGrabber.cpp @@ -5,12 +5,9 @@ // Local includes #include -OsxFrameGrabber::OsxFrameGrabber(const unsigned display, const unsigned width, const unsigned height) : - _screenIndex(display), - _width(width), - _height(height), - _imgResampler(new ImageResampler()), - _log(Logger::getInstance("OSXGRABBER")) +OsxFrameGrabber::OsxFrameGrabber(const unsigned display, const unsigned width, const unsigned height) + : Grabber("OSXGRABBER", width, height) + , _screenIndex(display) { CGImageRef image; CGDisplayCount displayCount; @@ -36,12 +33,6 @@ OsxFrameGrabber::OsxFrameGrabber(const unsigned display, const unsigned width, c OsxFrameGrabber::~OsxFrameGrabber() { - delete _imgResampler; -} - -void OsxFrameGrabber::setVideoMode(const VideoMode videoMode) -{ - _imgResampler->set3D(videoMode); } void OsxFrameGrabber::grabFrame(Image & image) @@ -53,7 +44,7 @@ void OsxFrameGrabber::grabFrame(Image & image) dispImage = CGDisplayCreateImage(_display); - // dsiplay lost, use main + // display lost, use main if (dispImage == NULL && _display) { dispImage = CGDisplayCreateImage(kCGDirectMainDisplay); @@ -69,9 +60,9 @@ void OsxFrameGrabber::grabFrame(Image & image) dspWidth = CGImageGetWidth(dispImage); dspHeight = CGImageGetHeight(dispImage); - _imgResampler->setHorizontalPixelDecimation(dspWidth/_width); - _imgResampler->setVerticalPixelDecimation(dspHeight/_height); - _imgResampler->processImage( pImgData, + _imageResampler.setHorizontalPixelDecimation(dspWidth/_width); + _imageResampler.setVerticalPixelDecimation(dspHeight/_height); + _imageResampler.processImage( pImgData, dspWidth, dspHeight, CGImageGetBytesPerRow(dispImage), diff --git a/libsrc/grabber/v4l2/CMakeLists.txt b/libsrc/grabber/v4l2/CMakeLists.txt index 109463d7..fd1fe93c 100644 --- a/libsrc/grabber/v4l2/CMakeLists.txt +++ b/libsrc/grabber/v4l2/CMakeLists.txt @@ -2,21 +2,9 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/grabber) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/v4l2) -SET(V4L2_HEADERS - ${CURRENT_HEADER_DIR}/V4L2Grabber.h - ${CURRENT_HEADER_DIR}/V4L2Wrapper.h - ${CURRENT_HEADER_DIR}/VideoStandard.h -) +FILE ( GLOB V4L2_SOURCES "${CURRENT_HEADER_DIR}/V4L2*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(V4L2_SOURCES - ${CURRENT_SOURCE_DIR}/V4L2Grabber.cpp - ${CURRENT_SOURCE_DIR}/V4L2Wrapper.cpp -) - -add_library(v4l2-grabber - ${V4L2_HEADERS} - ${V4L2_SOURCES} -) +add_library(v4l2-grabber ${V4L2_SOURCES} ) target_link_libraries(v4l2-grabber hyperion diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index 11739dd3..65714850 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -33,15 +33,14 @@ V4L2Grabber::V4L2Grabber(const QString & device , int horizontalPixelDecimation , int verticalPixelDecimation ) - : _deviceName(device) + : Grabber("V4L2:"+device, width, height) + , _deviceName(device) , _input(input) , _videoStandard(videoStandard) , _ioMethod(IO_METHOD_MMAP) , _fileDescriptor(-1) , _buffers() , _pixelFormat(pixelFormat) - , _width(width) - , _height(height) , _lineLength(-1) , _frameByteSize(-1) , _frameDecimation(qMax(1, frameDecimation)) @@ -56,8 +55,6 @@ V4L2Grabber::V4L2Grabber(const QString & device , _y_frac_max(0.75) , _currentFrame(0) , _streamNotifier(nullptr) - , _imageResampler() - , _log(Logger::getInstance("V4L2:"+device)) , _initialized(false) , _deviceAutoDiscoverEnabled(false) @@ -188,11 +185,6 @@ void V4L2Grabber::setCropping(int cropLeft, int cropRight, int cropTop, int crop _imageResampler.setCropping(cropLeft, cropRight, cropTop, cropBottom); } -void V4L2Grabber::set3D(VideoMode mode) -{ - _imageResampler.set3D(mode); -} - void V4L2Grabber::setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold) { _noSignalThresholdColor.red = uint8_t(255*redSignalThreshold); diff --git a/libsrc/grabber/v4l2/V4L2Wrapper.cpp b/libsrc/grabber/v4l2/V4L2Wrapper.cpp index b56e8243..eb0b48cd 100644 --- a/libsrc/grabber/v4l2/V4L2Wrapper.cpp +++ b/libsrc/grabber/v4l2/V4L2Wrapper.cpp @@ -15,7 +15,8 @@ V4L2Wrapper::V4L2Wrapper(const QString &device, double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, - const int priority) + const int priority, + bool useGrabbingMode) : GrabberWrapper("V4L2:"+device, priority, hyperion::COMP_V4L) , _timeout_ms(1000) , _grabber(device, @@ -42,6 +43,10 @@ V4L2Wrapper::V4L2Wrapper(const QString &device, QObject::connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection); + if (!useGrabbingMode) + { + disconnect(_hyperion, SIGNAL(grabbingMode(GrabbingMode)), this, 0); + } // send color data to Hyperion using a queued connection to handle the data over to the main event loop // QObject::connect( // this, SIGNAL(emitColors(int,std::vector,int)), @@ -80,9 +85,9 @@ void V4L2Wrapper::setSignalDetectionOffset(double verticalMin, double horizontal } -void V4L2Wrapper::set3D(VideoMode mode) +void V4L2Wrapper::setVideoMode(VideoMode mode) { - _grabber.set3D(mode); + _grabber.setVideoMode(mode); } void V4L2Wrapper::newFrame(const Image &image) diff --git a/libsrc/grabber/x11/CMakeLists.txt b/libsrc/grabber/x11/CMakeLists.txt index 566942cf..7228fdab 100644 --- a/libsrc/grabber/x11/CMakeLists.txt +++ b/libsrc/grabber/x11/CMakeLists.txt @@ -5,27 +5,14 @@ SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/grabber/x11) # Find X11 find_package(X11 REQUIRED) -include_directories( - ${X11_INCLUDES} -) +include_directories( ${X11_INCLUDES} ) -SET(X11_HEADERS - ${CURRENT_HEADER_DIR}/X11Wrapper.h - ${CURRENT_HEADER_DIR}/X11Grabber.h -) +FILE ( GLOB X11_SOURCES "${CURRENT_HEADER_DIR}/X11*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(X11_SOURCES - ${CURRENT_SOURCE_DIR}/X11Grabber.cpp - ${CURRENT_SOURCE_DIR}/X11Wrapper.cpp -) - -add_library(x11-grabber - ${X11_HEADERS} - ${X11_SOURCES} -) +add_library(x11-grabber ${X11_SOURCES} ) target_link_libraries(x11-grabber hyperion - ${X11_LIBRARIES} - ${X11_Xrender_LIB} + ${X11_LIBRARIES} + ${X11_Xrender_LIB} ) diff --git a/libsrc/grabber/x11/X11Grabber.cpp b/libsrc/grabber/x11/X11Grabber.cpp index 2b75abcf..7b19be73 100755 --- a/libsrc/grabber/x11/X11Grabber.cpp +++ b/libsrc/grabber/x11/X11Grabber.cpp @@ -2,12 +2,8 @@ #include X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropTop, int cropBottom, int horizontalPixelDecimation, int verticalPixelDecimation) - : _imageResampler() + : Grabber("X11GRABBER", 0, 0, cropLeft, cropRight, cropTop, cropBottom) , _useXGetImage(useXGetImage) - , _cropLeft(cropLeft) - , _cropRight(cropRight) - , _cropTop(cropTop) - , _cropBottom(cropBottom) , _x11Display(nullptr) , _pixmap(None) , _srcFormat(nullptr) @@ -18,10 +14,7 @@ X11Grabber::X11Grabber(bool useXGetImage, int cropLeft, int cropRight, int cropT , _verticalDecimation(verticalPixelDecimation) , _screenWidth(0) , _screenHeight(0) - , _croppedWidth(0) - , _croppedHeight(0) , _image(0,0) - , _log(Logger::getInstance("X11GRABBER")) { _imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage memset(&_pictAttr, 0, sizeof(_pictAttr)); @@ -37,11 +30,6 @@ X11Grabber::~X11Grabber() } } -void X11Grabber::setVideoMode(const VideoMode videoMode) -{ - _imageResampler.set3D(videoMode); -} - void X11Grabber::freeResources() { // Cleanup allocated resources of the X11 grab @@ -66,7 +54,7 @@ void X11Grabber::setupResources() { _xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _windowAttr.depth, ZPixmap, NULL, &_shminfo, - _croppedWidth, _croppedHeight); + _width, _height); _shminfo.shmid = shmget(IPC_PRIVATE, _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777); _xImage->data = (char*)shmat(_shminfo.shmid,0,0); _shminfo.shmaddr = _xImage->data; @@ -77,11 +65,11 @@ void X11Grabber::setupResources() { if(_XShmPixmapAvailable) { - _pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _croppedWidth, _croppedHeight, _windowAttr.depth); + _pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _width, _height, _windowAttr.depth); } else { - _pixmap = XCreatePixmap(_x11Display, _window, _croppedWidth, _croppedHeight, _windowAttr.depth); + _pixmap = XCreatePixmap(_x11Display, _window, _width, _height, _windowAttr.depth); } _srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual); _dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual); @@ -168,8 +156,8 @@ Image & X11Grabber::grab() 0, // mask_y 0, // dst_x 0, // dst_y - _croppedWidth, // width - _croppedHeight); // height + _width, // width + _height); // height XSync(_x11Display, False); @@ -179,7 +167,7 @@ Image & X11Grabber::grab() } else { - _xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); + _xImage = XGetImage(_x11Display, _pixmap, 0, 0, _width, _height, AllPlanes, ZPixmap); } } else @@ -189,7 +177,7 @@ Image & X11Grabber::grab() } else { - _xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); + _xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _width, _height, AllPlanes, ZPixmap); } } @@ -246,8 +234,8 @@ int X11Grabber::grabFrame(Image & image) 0, // mask_y 0, // dst_x 0, // dst_y - _croppedWidth, // width - _croppedHeight); // height + _width, // width + _height); // height XSync(_x11Display, False); @@ -257,7 +245,7 @@ int X11Grabber::grabFrame(Image & image) } else { - _xImage = XGetImage(_x11Display, _pixmap, 0, 0, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); + _xImage = XGetImage(_x11Display, _pixmap, 0, 0, _width, _height, AllPlanes, ZPixmap); } } else @@ -267,7 +255,7 @@ int X11Grabber::grabFrame(Image & image) } else { - _xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _croppedWidth, _croppedHeight, AllPlanes, ZPixmap); + _xImage = XGetImage(_x11Display, _window, _cropLeft, _cropTop, _width, _height, AllPlanes, ZPixmap); } } @@ -309,11 +297,11 @@ int X11Grabber::updateScreenDimensions() // Image scaling is performed by XRender when available, otherwise by ImageResampler if (_XRenderAvailable && !_useXGetImage) { - _croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight)) + _width = (_screenWidth > unsigned(_cropLeft + _cropRight)) ? ((_screenWidth - _cropLeft - _cropRight) / _horizontalDecimation) : _screenWidth / _horizontalDecimation; - _croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom)) + _height = (_screenHeight > unsigned(_cropTop + _cropBottom)) ? ((_screenHeight - _cropTop - _cropBottom) / _verticalDecimation) : _screenHeight / _verticalDecimation; @@ -321,18 +309,18 @@ int X11Grabber::updateScreenDimensions() } else { - _croppedWidth = (_screenWidth > unsigned(_cropLeft + _cropRight)) + _width = (_screenWidth > unsigned(_cropLeft + _cropRight)) ? (_screenWidth - _cropLeft - _cropRight) : _screenWidth; - _croppedHeight = (_screenHeight > unsigned(_cropTop + _cropBottom)) + _height = (_screenHeight > unsigned(_cropTop + _cropBottom)) ? (_screenHeight - _cropTop - _cropBottom) : _screenHeight; Info(_log, "Using XGetImage for grabbing"); } - _image.resize(_croppedWidth, _croppedHeight); + _image.resize(_width, _height); setupResources(); return 1; diff --git a/libsrc/grabber/x11/X11Wrapper.cpp b/libsrc/grabber/x11/X11Wrapper.cpp index 7fa2cf75..ff610910 100644 --- a/libsrc/grabber/x11/X11Wrapper.cpp +++ b/libsrc/grabber/x11/X11Wrapper.cpp @@ -1,3 +1,4 @@ + // Hyperion includes #include #include diff --git a/libsrc/hyperion/CMakeLists.txt b/libsrc/hyperion/CMakeLists.txt index 813a8424..a974d91f 100644 --- a/libsrc/hyperion/CMakeLists.txt +++ b/libsrc/hyperion/CMakeLists.txt @@ -3,46 +3,11 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/hyperion) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/hyperion) -SET(Hyperion_HEADERS - ${CURRENT_HEADER_DIR}/ImageProcessorFactory.h - ${CURRENT_HEADER_DIR}/ImageToLedsMap.h - ${CURRENT_HEADER_DIR}/LedString.h +FILE ( GLOB Hyperion_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) - ${CURRENT_SOURCE_DIR}/MultiColorAdjustment.h - ${CURRENT_HEADER_DIR}/MessageForwarder.h - - ${CURRENT_HEADER_DIR}/Hyperion.h - ${CURRENT_HEADER_DIR}/ImageProcessor.h - - ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.h - ${CURRENT_HEADER_DIR}/GrabberWrapper.h - ${CURRENT_HEADER_DIR}/ComponentRegister.h - ${CURRENT_HEADER_DIR}/PriorityMuxer.h -) - -SET(Hyperion_SOURCES - ${CURRENT_SOURCE_DIR}/Hyperion.cpp - ${CURRENT_SOURCE_DIR}/ImageProcessor.cpp - ${CURRENT_SOURCE_DIR}/ImageProcessorFactory.cpp - ${CURRENT_SOURCE_DIR}/LedString.cpp - ${CURRENT_SOURCE_DIR}/PriorityMuxer.cpp - - ${CURRENT_SOURCE_DIR}/ImageToLedsMap.cpp - ${CURRENT_SOURCE_DIR}/MultiColorAdjustment.cpp - ${CURRENT_SOURCE_DIR}/LinearColorSmoothing.cpp - ${CURRENT_SOURCE_DIR}/MessageForwarder.cpp - ${CURRENT_SOURCE_DIR}/GrabberWrapper.cpp - ${CURRENT_SOURCE_DIR}/ComponentRegister.cpp -) - -SET(Hyperion_RESOURCES - ${CURRENT_SOURCE_DIR}/resource.qrc -) - -QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${Hyperion_RESOURCES} OPTIONS "-no-compress") +QT5_ADD_RESOURCES(Hyperion_RESOURCES_RCC ${CURRENT_SOURCE_DIR}/resource.qrc OPTIONS "-no-compress") add_library(hyperion - ${Hyperion_HEADERS} ${Hyperion_SOURCES} ${Hyperion_RESOURCES_RCC} ) diff --git a/libsrc/hyperion/Grabber.cpp b/libsrc/hyperion/Grabber.cpp new file mode 100644 index 00000000..db0d9598 --- /dev/null +++ b/libsrc/hyperion/Grabber.cpp @@ -0,0 +1,27 @@ +#include + + +Grabber::Grabber(QString grabberName, int width, int height, int cropLeft, int cropRight, int cropTop, int cropBottom) + : _imageResampler() + , _videoMode(VIDEO_2D) + , _width(width) + , _height(height) + , _cropLeft(cropLeft) + , _cropRight(cropRight) + , _cropTop(cropTop) + , _cropBottom(cropBottom) + , _log(Logger::getInstance(grabberName)) + +{ +} + +Grabber::~Grabber() +{ +} + + +void Grabber::setVideoMode(VideoMode mode) +{ + _videoMode = mode; + _imageResampler.set3D(_videoMode); +} diff --git a/libsrc/hyperion/GrabberWrapper.cpp b/libsrc/hyperion/GrabberWrapper.cpp index 734fb539..cd743606 100644 --- a/libsrc/hyperion/GrabberWrapper.cpp +++ b/libsrc/hyperion/GrabberWrapper.cpp @@ -22,6 +22,9 @@ GrabberWrapper::GrabberWrapper(QString grabberName, const int priority, hyperion connect(_hyperion, SIGNAL(imageToLedsMappingChanged(int)), _processor, SLOT(setLedMappingType(int))); connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool))); + connect(_hyperion, SIGNAL(grabbingMode(GrabbingMode)), this, SLOT(setGrabbingMode(GrabbingMode))); + connect(_hyperion, SIGNAL(videoMode(VideoMode)), this, SLOT(setVideoMode(VideoMode))); + connect(this, SIGNAL(emitImage(int, const Image&, const int)), _hyperion, SLOT(setImage(int, const Image&, const int)) ); connect(&_timer, SIGNAL(timeout()), this, SLOT(action())); } diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp index d9517ec6..b9e5e2b7 100644 --- a/libsrc/hyperion/Hyperion.cpp +++ b/libsrc/hyperion/Hyperion.cpp @@ -400,6 +400,8 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile) , _prevCompId(hyperion::COMP_INVALID) , _bonjourBrowser(this) , _bonjourResolver(this) + , _videoMode(VIDEO_2D) + , _grabbingMode(GRABBINGMODE_INVALID) { if (!_raw2ledAdjustment->verifyAdjustments()) @@ -802,6 +804,19 @@ void Hyperion::setLedMappingType(int mappingType) emit imageToLedsMappingChanged(mappingType); } +void Hyperion::setVideoMode(VideoMode mode) +{ + _videoMode = mode; + emit videoMode(mode); +} + +void Hyperion::setGrabbingMode(GrabbingMode mode) +{ + _grabbingMode = mode; + emit grabbingMode(mode); +} + + void Hyperion::hyperionStateChanged() { if(_fsi_blockTimer.isActive()) diff --git a/libsrc/jsonserver/CMakeLists.txt b/libsrc/jsonserver/CMakeLists.txt index 3e41f7cb..dfddffa5 100644 --- a/libsrc/jsonserver/CMakeLists.txt +++ b/libsrc/jsonserver/CMakeLists.txt @@ -3,22 +3,12 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/jsonserver) set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/jsonserver) -set(JsonServer_HEADERS - ${CURRENT_HEADER_DIR}/JsonServer.h - ${CURRENT_SOURCE_DIR}/JsonClientConnection.h -) +FILE ( GLOB JsonServer_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -set(JsonServer_SOURCES - ${CURRENT_SOURCE_DIR}/JsonServer.cpp - ${CURRENT_SOURCE_DIR}/JsonClientConnection.cpp -) - -add_library(jsonserver - ${JsonServer_HEADERS} - ${JsonServer_SOURCES} -) +add_library(jsonserver ${JsonServer_SOURCES} ) target_link_libraries(jsonserver hyperion Qt5::Network - Qt5::Gui) + Qt5::Gui +) diff --git a/libsrc/kodivideochecker/CMakeLists.txt b/libsrc/kodivideochecker/CMakeLists.txt index dd7d9693..73806a52 100644 --- a/libsrc/kodivideochecker/CMakeLists.txt +++ b/libsrc/kodivideochecker/CMakeLists.txt @@ -3,19 +3,9 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/kodivideochecker) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/kodivideochecker) -SET(KODIVideoChecker_HEADERS - ${CURRENT_HEADER_DIR}/KODIVideoChecker.h -) +FILE ( GLOB KODIVideoChecker_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(KODIVideoChecker_SOURCES - ${CURRENT_SOURCE_DIR}/KODIVideoChecker.cpp -) - - -add_library(kodivideochecker - ${KODIVideoChecker_HEADERS} - ${KODIVideoChecker_SOURCES} -) +add_library(kodivideochecker ${KODIVideoChecker_SOURCES} ) target_link_libraries(kodivideochecker hyperion diff --git a/libsrc/leddevice/CMakeLists.txt b/libsrc/leddevice/CMakeLists.txt index cf297b57..88a88418 100755 --- a/libsrc/leddevice/CMakeLists.txt +++ b/libsrc/leddevice/CMakeLists.txt @@ -18,6 +18,10 @@ include_directories( SET(Leddevice_HEADERS ${CURRENT_HEADER_DIR}/LedDeviceFactory.h + ${CURRENT_SOURCE_DIR}/ProviderRs232.h + ${CURRENT_SOURCE_DIR}/ProviderHID.h + ${CURRENT_SOURCE_DIR}/ProviderUdp.h + ${CURRENT_SOURCE_DIR}/LedDeviceLightpack.h ${CURRENT_SOURCE_DIR}/LedDeviceMultiLightpack.h ${CURRENT_SOURCE_DIR}/LedDevicePaintpack.h @@ -29,17 +33,14 @@ SET(Leddevice_HEADERS ${CURRENT_SOURCE_DIR}/LedDeviceUdpH801.h ${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.h ${CURRENT_SOURCE_DIR}/LedDeviceUdpArtNet.h - ${CURRENT_SOURCE_DIR}/ProviderUdp.h ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.h ${CURRENT_SOURCE_DIR}/LedDeviceTpm2.h ${CURRENT_SOURCE_DIR}/LedDeviceTpm2net.h ${CURRENT_SOURCE_DIR}/LedDeviceAtmo.h ${CURRENT_HEADER_DIR}/LedDevice.h - ${CURRENT_SOURCE_DIR}/ProviderRs232.h ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.h ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.h ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.h - ${CURRENT_SOURCE_DIR}/ProviderHID.h ${CURRENT_SOURCE_DIR}/LedDeviceRawHID.h ${CURRENT_SOURCE_DIR}/LedDeviceFadeCandy.h ) @@ -50,6 +51,7 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/ProviderRs232.cpp ${CURRENT_SOURCE_DIR}/ProviderHID.cpp + ${CURRENT_SOURCE_DIR}/ProviderUdp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAdalight.cpp ${CURRENT_SOURCE_DIR}/LedDeviceAtmoOrb.cpp @@ -66,7 +68,6 @@ SET(Leddevice_SOURCES ${CURRENT_SOURCE_DIR}/LedDeviceUdpH801.cpp ${CURRENT_SOURCE_DIR}/LedDeviceUdpE131.cpp ${CURRENT_SOURCE_DIR}/LedDeviceUdpArtNet.cpp - ${CURRENT_SOURCE_DIR}/ProviderUdp.cpp ${CURRENT_SOURCE_DIR}/LedDeviceHyperionUsbasp.cpp ${CURRENT_SOURCE_DIR}/LedDevicePhilipsHue.cpp ${CURRENT_SOURCE_DIR}/LedDeviceTpm2.cpp diff --git a/libsrc/protoserver/CMakeLists.txt b/libsrc/protoserver/CMakeLists.txt index cc5384e5..5c5bd1e6 100644 --- a/libsrc/protoserver/CMakeLists.txt +++ b/libsrc/protoserver/CMakeLists.txt @@ -7,31 +7,13 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${PROTOBUF_INCLUDE_DIRS} ) +FILE ( GLOB ProtoServer_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -set(ProtoServer_HEADERS - ${CURRENT_HEADER_DIR}/ProtoServer.h - ${CURRENT_HEADER_DIR}/ProtoConnection.h - ${CURRENT_SOURCE_DIR}/ProtoClientConnection.h - ${CURRENT_HEADER_DIR}/ProtoConnectionWrapper.h -) +set(ProtoServer_PROTOS ${CURRENT_SOURCE_DIR}/message.proto ) -set(ProtoServer_SOURCES - ${CURRENT_SOURCE_DIR}/ProtoServer.cpp - ${CURRENT_SOURCE_DIR}/ProtoClientConnection.cpp - ${CURRENT_SOURCE_DIR}/ProtoConnection.cpp - ${CURRENT_SOURCE_DIR}/ProtoConnectionWrapper.cpp -) - -set(ProtoServer_PROTOS - ${CURRENT_SOURCE_DIR}/message.proto -) - -protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS - ${ProtoServer_PROTOS} -) +protobuf_generate_cpp(ProtoServer_PROTO_SRCS ProtoServer_PROTO_HDRS ${ProtoServer_PROTOS} ) add_library(protoserver - ${ProtoServer_HEADERS} ${ProtoServer_SOURCES} ${ProtoServer_PROTOS} ${ProtoServer_PROTO_SRCS} diff --git a/libsrc/udplistener/CMakeLists.txt b/libsrc/udplistener/CMakeLists.txt index 75bb74e6..ef222d7f 100644 --- a/libsrc/udplistener/CMakeLists.txt +++ b/libsrc/udplistener/CMakeLists.txt @@ -3,20 +3,12 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/udplistener) set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/udplistener) -set(UDPListener_HEADERS - ${CURRENT_HEADER_DIR}/UDPListener.h -) +FILE ( GLOB UDPListener_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -set(UDPListener_SOURCES - ${CURRENT_SOURCE_DIR}/UDPListener.cpp -) - -add_library(udplistener - ${UDPListener_HEADERS} - ${UDPListener_SOURCES} -) +add_library(udplistener ${UDPListener_SOURCES} ) target_link_libraries(udplistener hyperion hyperion-utils - ${QT_LIBRARIES}) + ${QT_LIBRARIES} +) diff --git a/libsrc/utils/CMakeLists.txt b/libsrc/utils/CMakeLists.txt index 7c73e2d0..00913cb4 100644 --- a/libsrc/utils/CMakeLists.txt +++ b/libsrc/utils/CMakeLists.txt @@ -3,67 +3,19 @@ SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/utils) SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/utils) -SET(Utils_HEADERS - ${CURRENT_HEADER_DIR}/ColorBgr.h - ${CURRENT_HEADER_DIR}/ColorRgb.h - ${CURRENT_HEADER_DIR}/ColorRgba.h - ${CURRENT_HEADER_DIR}/ColorRgbw.h - ${CURRENT_HEADER_DIR}/Image.h - ${CURRENT_HEADER_DIR}/Sleep.h - ${CURRENT_HEADER_DIR}/FileUtils.h - ${CURRENT_HEADER_DIR}/Process.h - ${CURRENT_HEADER_DIR}/PixelFormat.h - ${CURRENT_HEADER_DIR}/VideoMode.h - ${CURRENT_HEADER_DIR}/ImageResampler.h - ${CURRENT_HEADER_DIR}/RgbTransform.h - ${CURRENT_HEADER_DIR}/ColorSys.h - ${CURRENT_HEADER_DIR}/RgbChannelAdjustment.h - ${CURRENT_HEADER_DIR}/RgbToRgbw.h - ${CURRENT_HEADER_DIR}/jsonschema/QJsonFactory.h - ${CURRENT_HEADER_DIR}/jsonschema/QJsonSchemaChecker.h - ${CURRENT_HEADER_DIR}/jsonschema/QJsonUtils.h - ${CURRENT_HEADER_DIR}/global_defines.h - ${CURRENT_HEADER_DIR}/SysInfo.h - ${CURRENT_HEADER_DIR}/Logger.h - ${CURRENT_HEADER_DIR}/Stats.h - ${CURRENT_HEADER_DIR}/JsonProcessor.h -) +FILE ( GLOB_RECURSE Utils_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) -SET(Utils_SOURCES - ${CURRENT_SOURCE_DIR}/ColorArgb.cpp - ${CURRENT_SOURCE_DIR}/ColorBgr.cpp - ${CURRENT_SOURCE_DIR}/ColorRgb.cpp - ${CURRENT_SOURCE_DIR}/ColorRgba.cpp - ${CURRENT_SOURCE_DIR}/ColorRgbw.cpp - ${CURRENT_SOURCE_DIR}/FileUtils.cpp - ${CURRENT_SOURCE_DIR}/Process.cpp - ${CURRENT_SOURCE_DIR}/Logger.cpp - ${CURRENT_SOURCE_DIR}/ImageResampler.cpp - ${CURRENT_SOURCE_DIR}/ColorSys.cpp - ${CURRENT_SOURCE_DIR}/RgbChannelAdjustment.cpp - ${CURRENT_SOURCE_DIR}/RgbTransform.cpp - ${CURRENT_SOURCE_DIR}/RgbToRgbw.cpp - ${CURRENT_SOURCE_DIR}/SysInfo.cpp - ${CURRENT_SOURCE_DIR}/Stats.cpp - ${CURRENT_SOURCE_DIR}/JsonProcessor.cpp - ${CURRENT_SOURCE_DIR}/jsonschema/QJsonSchemaChecker.cpp -) - -if ( ENABLE_PROFILER ) - SET ( PROFILER_SOURCE ${CURRENT_HEADER_DIR}/Profiler.h ${CURRENT_SOURCE_DIR}/Profiler.cpp ) +if ( NOT ENABLE_PROFILER ) + LIST ( REMOVE_ITEM Utils_SOURCES ${CURRENT_HEADER_DIR}/Profiler.h ${CURRENT_SOURCE_DIR}/Profiler.cpp ) endif() -set(Utils_RESOURCES - ${CURRENT_SOURCE_DIR}/JSONRPC_schemas.qrc -) +set(Utils_RESOURCES ${CURRENT_SOURCE_DIR}/JSONRPC_schemas.qrc ) qt5_add_resources(Utils_RESOURCES_RCC ${Utils_RESOURCES} OPTIONS "-no-compress") add_library(hyperion-utils - ${Utils_HEADERS} ${Utils_SOURCES} - ${PROFILER_SOURCE} ${Utils_RESOURCES} ${Utils_RESOURCES_RCC} ) diff --git a/libsrc/utils/JSONRPC_schema/schema-videomode.json b/libsrc/utils/JSONRPC_schema/schema-videomode.json new file mode 100644 index 00000000..8ffc7c28 --- /dev/null +++ b/libsrc/utils/JSONRPC_schema/schema-videomode.json @@ -0,0 +1,19 @@ +{ + "type":"object", + "required":true, + "properties":{ + "command": { + "type" : "string", + "required" : true, + "enum" : ["videomode"] + }, + "tan" : { + "type" : "integer" + }, + "mappingType": { + "type" : "string", + "enum" : ["2D", "3DSBS", "3DTAB"] + } + }, + "additionalProperties": false +} diff --git a/libsrc/utils/JSONRPC_schema/schema.json b/libsrc/utils/JSONRPC_schema/schema.json index 20156ff7..9aca8d98 100644 --- a/libsrc/utils/JSONRPC_schema/schema.json +++ b/libsrc/utils/JSONRPC_schema/schema.json @@ -5,7 +5,7 @@ "command": { "type" : "string", "required" : true, - "enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo"] + "enum" : ["color", "image", "effect", "create-effect", "delete-effect", "serverinfo", "clear", "clearall", "adjustment", "sourceselect", "config", "componentstate", "ledcolors", "logging", "processing", "sysinfo", "videomode"] } } } diff --git a/libsrc/utils/JSONRPC_schemas.qrc b/libsrc/utils/JSONRPC_schemas.qrc index 47df3792..1c708443 100644 --- a/libsrc/utils/JSONRPC_schemas.qrc +++ b/libsrc/utils/JSONRPC_schemas.qrc @@ -17,5 +17,6 @@ JSONRPC_schema/schema-ledcolors.json JSONRPC_schema/schema-logging.json JSONRPC_schema/schema-processing.json + JSONRPC_schema/schema-videomode.json diff --git a/libsrc/utils/JsonProcessor.cpp b/libsrc/utils/JsonProcessor.cpp index 74e2e14d..4fff59ac 100644 --- a/libsrc/utils/JsonProcessor.cpp +++ b/libsrc/utils/JsonProcessor.cpp @@ -136,6 +136,7 @@ void JsonProcessor::handleMessage(const QString& messageString, const QString pe else if (command == "ledcolors") handleLedColorsCommand (message, command, tan); else if (command == "logging") handleLoggingCommand (message, command, tan); else if (command == "processing") handleProcessingCommand (message, command, tan); + else if (command == "videomode") handleVideoModeCommand (message, command, tan); else handleNotImplemented (); } catch (std::exception& e) @@ -583,7 +584,7 @@ void JsonProcessor::handleServerInfoCommand(const QJsonObject&, const QString& c // get available led devices QJsonObject ledDevices; - ledDevices["active"] =LedDevice::activeDevice(); + ledDevices["active"] = LedDevice::activeDevice(); QJsonArray availableLedDevices; for (auto dev: LedDevice::getDeviceMap()) { @@ -593,21 +594,19 @@ void JsonProcessor::handleServerInfoCommand(const QJsonObject&, const QString& c ledDevices["available"] = availableLedDevices; info["ledDevices"] = ledDevices; + QJsonObject grabbers; + QJsonArray availableGrabbers; #if defined(ENABLE_DISPMANX) || defined(ENABLE_V4L2) || defined(ENABLE_FB) || defined(ENABLE_AMLOGIC) || defined(ENABLE_OSX) || defined(ENABLE_X11) // get available grabbers - QJsonObject grabbers; //grabbers["active"] = ????; - QJsonArray availableGrabbers; for (auto grabber: GrabberWrapper::availableGrabbers()) { availableGrabbers.append(grabber); } - - grabbers["available"] = availableGrabbers; - info["grabbers"] = grabbers; -#else - info["grabbers"] = QString("none"); #endif + grabbers["available"] = availableGrabbers; + grabbers["videomode"] = QString(videoMode2String(_hyperion->getCurrentVideoMode())); + info["grabbers"] = grabbers; // get available components QJsonArray component; @@ -1036,6 +1035,13 @@ void JsonProcessor::handleProcessingCommand(const QJsonObject& message, const QS sendSuccessReply(command, tan); } +void JsonProcessor::handleVideoModeCommand(const QJsonObject& message, const QString &command, const int tan) +{ + _hyperion->setVideoMode(parse3DMode(message["videoMode"].toString("2D"))); + + sendSuccessReply(command, tan); +} + void JsonProcessor::handleNotImplemented() { sendErrorReply("Command not implemented"); diff --git a/libsrc/webconfig/CMakeLists.txt b/libsrc/webconfig/CMakeLists.txt index 5a13e62f..278e3d30 100644 --- a/libsrc/webconfig/CMakeLists.txt +++ b/libsrc/webconfig/CMakeLists.txt @@ -3,27 +3,9 @@ set(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/webconfig) set(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/webconfig) -set(WebConfig_HEADERS - ${CURRENT_SOURCE_DIR}/QtHttpClientWrapper.h - ${CURRENT_SOURCE_DIR}/QtHttpReply.h - ${CURRENT_SOURCE_DIR}/QtHttpRequest.h - ${CURRENT_SOURCE_DIR}/QtHttpServer.h - ${CURRENT_SOURCE_DIR}/CgiHandler.h - ${CURRENT_SOURCE_DIR}/StaticFileServing.h - ${CURRENT_HEADER_DIR}/WebConfig.h -) - -set(WebConfig_SOURCES - ${CURRENT_SOURCE_DIR}/QtHttpClientWrapper.cpp - ${CURRENT_SOURCE_DIR}/QtHttpHeader.cpp - ${CURRENT_SOURCE_DIR}/QtHttpReply.cpp - ${CURRENT_SOURCE_DIR}/QtHttpRequest.cpp - ${CURRENT_SOURCE_DIR}/QtHttpServer.cpp - ${CURRENT_SOURCE_DIR}/CgiHandler.cpp - ${CURRENT_SOURCE_DIR}/StaticFileServing.cpp - ${CURRENT_SOURCE_DIR}/WebConfig.cpp -) +FILE ( GLOB WebConfig_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" ) FILE ( GLOB_RECURSE webFiles RELATIVE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/assets/webconfig/* ) + FOREACH( f ${webFiles} ) STRING ( REPLACE "../assets/webconfig/" "" fname ${f}) SET(HYPERION_WEBCONFIG_RES "${HYPERION_WEBCONFIG_RES}\n\t\t${f}") @@ -34,7 +16,6 @@ SET(WebConfig_RESOURCES ${CMAKE_BINARY_DIR}/WebConfig.qrc) qt5_add_resources(WebConfig_RESOURCES_RCC ${WebConfig_RESOURCES} ) #OPTIONS "-no-compress" add_library(webconfig - ${WebConfig_HEADERS} ${WebConfig_SOURCES} ${WebConfig_RESOURCES_RCC} ) diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 25d7ffcf..7ec79336 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -576,6 +576,16 @@ void JsonConnection::setLedMapping(QString mappingType) parseReply(reply); } +void JsonConnection::setVideoMode(QString videoMode) +{ + QJsonObject command; + command["command"] = QString("videomode"); + command["videoMode"] = videoMode.toUpper(); + + QJsonObject reply = sendMessage(command); + parseReply(reply); +} + QJsonObject JsonConnection::sendMessage(const QJsonObject & message) { // serialize message diff --git a/src/hyperion-remote/JsonConnection.h b/src/hyperion-remote/JsonConnection.h index 4a3d9f6a..ab56d82e 100644 --- a/src/hyperion-remote/JsonConnection.h +++ b/src/hyperion-remote/JsonConnection.h @@ -165,6 +165,10 @@ public: /// @param mappingType led mapping type void setLedMapping(QString mappingType); + // sets video mode 3D/2D + void setVideoMode(QString videoMode); + + private: /// /// Send a json command message and receive its reply diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp index aa6e1f92..1b499012 100644 --- a/src/hyperion-remote/hyperion-remote.cpp +++ b/src/hyperion-remote/hyperion-remote.cpp @@ -92,6 +92,7 @@ int main(int argc, char * argv[]) ColorOption & argWAdjust = parser.add ('W', "whiteAdjustment", "Set the adjustment of the white color (requires colors in hex format as RRGGBB)"); ColorOption & argbAdjust = parser.add ('b', "blackAdjustment", "Set the adjustment of the black color (requires colors in hex format as RRGGBB)"); Option & argMapping = parser.add