hyperion.ng/include/utils/GlobalSignals.h

121 lines
4.3 KiB
C
Raw Normal View History

#pragma once
// util
#include <utils/Image.h>
#include <utils/ColorRgb.h>
#include <utils/Components.h>
// qt
#include <QObject>
///
/// Singleton instance for simple signal sharing across threads, should be never used with Qt:DirectConnection!
///
class GlobalSignals : public QObject
{
Q_OBJECT
public:
static GlobalSignals* getInstance()
{
static GlobalSignals instance;
return & instance;
}
private:
GlobalSignals() = default;
public:
GlobalSignals(GlobalSignals const&) = delete;
void operator=(GlobalSignals const&) = delete;
signals:
///////////////////////////////////////
///////////// TO HYPERION /////////////
///////////////////////////////////////
///
/// @brief PIPE SystemCapture images from GrabberWrapper to Hyperion class
/// @param name The name of the platform capture that is currently active
/// @param image The prepared image
///
void setSystemImage(const QString& name, const Image<ColorRgb>& image);
///
/// @brief PIPE v4lCapture images from v4lCapture over HyperionDaemon to Hyperion class
/// @param name The name of the v4l capture (path) that is currently active
/// @param image The prepared image
///
void setV4lImage(const QString& name, const Image<ColorRgb>& image);
#if defined(ENABLE_FLATBUF_SERVER) || defined(ENABLE_PROTOBUF_SERVER)
///
/// @brief PIPE Flat-/Proto- buffer images to Hyperion class
/// @param name The name of the buffer capture that is currently active
/// @param image The prepared image
///
void setBufferImage(const QString& name, const Image<ColorRgb>& image);
#endif
Audio Grabber Feature (#1570) * Creating Audio Grabber Creating Audio Grabber Creating Audio Grabber. Successfully began capturing audio in windows. Starting to implement a hard-coded UV Visualizer. Got Windows DirectSound Implementation working. Hardcoded basic VU Meter. Begin working on linux audio grabber implementation. Finished Linux Draft Implementation. Minor Mods to windows implementation. Windows: - Free memory used by device id. - Prevent starting audio if the grabber is disabled - More debug logging Linux: - Prevent starting audio if the grabber is disabled Added strings to english Removed "custom" from device selection Made hard-coded visualizer values configurable. wrote values to imageData with BGR priority to enable configurable values to be set in RGB format. created logic to support "Automatic" to enable the API to select the default device. Add language key for audio in "Remote Control" section. Removed audio configuration for number of channels. This was causing an error with some devices. Fixed logic to update capture while its active. Optimizing code . UI Tweaks Destructuring. Fixed build error on linux. Custom Effects - Clean-ups and Enhancements (#1163) * Cleanup EffectFileHandler * Support Custom Effect Schemas and align EffectFileHandler * Change back to colon prefix for system effects * WebSockets - Fix error in handling fragmented frames * Correct missing colon updates * Update json with image file location for custom gif effects * Image effect deletion - considere full filename is stored in JSON * Correct selection lists indentions Creating Audio Grabber Creating Audio Grabber Creating Audio Grabber. Successfully began capturing audio in windows. Starting to implement a hard-coded UV Visualizer. Got Windows DirectSound Implementation working. Hardcoded basic VU Meter. Begin working on linux audio grabber implementation. Finished Linux Draft Implementation. Minor Mods to windows implementation. Windows: - Free memory used by device id. - Prevent starting audio if the grabber is disabled - More debug logging Linux: - Prevent starting audio if the grabber is disabled Added strings to english Removed "custom" from device selection Made hard-coded visualizer values configurable. wrote values to imageData with BGR priority to enable configurable values to be set in RGB format. created logic to support "Automatic" to enable the API to select the default device. Add language key for audio in "Remote Control" section. Removed audio configuration for number of channels. This was causing an error with some devices. Fixed logic to update capture while its active. Optimizing code . UI Tweaks Destructuring. Fixed build error on linux. Commented setVideoMode from AudioGrabber. Linux Threading changes. Implementing new API Continuing to implement audio into new APIs Fixed Audio Grabber for DirectSound on Windows Fixed UI for Audio Grabber Configuration Default AUDIO to off unless specified. fixed missing #ifdef for audio grabber. Added logic to calculate a dynamic multiplier from the signal input. Updating linux api for discovering devices. Fixed HTML/JS issues with view. Fixed NPE in Windows. Disabled setting thread priority in linux. updated the schema options check to pass through hidden states and commented the change. Updated grabber start conditions Updated Audio grabber to instantiate similar to video grabber Updated windows grabber to set "started" flag to false when shutting down. Removed "tryStart" to prevent enabling audio capture unnecessarily. Fixing instance audio grabber device configuration Added configurable resolution Reduced tolerance to 5% Fixed issue where grabber failed for additional instances when "start" was called multiple times. Fixed resolution calculation Change averaging algorithm to prevent overflowing the sum. Updated logic to stop audio grabber when disabled. Fix integer casting and rounding. Restart grabber on configuration change. Fix missing include/grabber/AudioGrabber. Disable tolerance. Added configurable tolerance. Fixed tolerance algorithm. reset multiplier on configuration change. Line Endings Proposed change and questions/request to fix implementing more of LordGrey's suggestions. Fix mode for snd_pcm_open. Latest ALSA uses SND_PCM_NONBLOCK instead of SND_PCM_OPEN_NONBLOCK defaulted multiplier to 0 "auto" defaulted tolerance to 20% changed 100 to 100.0 for pixel value percentage calculation to fix value from being 0. missed a 100 as a double so precision isn't lost during math operation. Fix Windows grabber and further cleanups Enable Audio grabbing in standard build Remove empty methods Fix audio capture priority setting Remove unused code Clean-up default config Allow additional json-editor attributes Allow multiple effects and resetting to defaults Correct default values Allow to build for Qt < 5.14 Update CodeQL build dependency Update build dependencies Remove effect1 placeholder * Renamed uvMeter to VU Meter (Volume Unit) - Fixed issues flagged by code scanning bot. * Moved stop call into destructor of implementing class. * Removed commented linux audio channel configuration logic. --------- Co-authored-by: Michael Rochelle <michael@j2inn.com>
2023-02-19 09:36:39 +01:00
///
/// @brief PIPE audioCapture images from audioCapture over HyperionDaemon to Hyperion class
/// @param name The name of the audio capture (path) that is currently active
/// @param image The prepared image
///
void setAudioImage(const QString& name, const Image<ColorRgb>& image);
///
/// @brief PIPE the register command for a new global input over HyperionDaemon to Hyperion class
/// @param[in] priority The priority of the channel
/// @param[in] component The component of the channel
/// @param[in] origin Who set the channel (CustomString@IP)
/// @param[in] owner Specific owner string, might be empty
/// @param[in] smooth_cfg The smooth id to use
///
2020-08-08 13:09:15 +02:00
void registerGlobalInput(int priority, hyperion::Components component, const QString& origin = "External", const QString& owner = "", unsigned smooth_cfg = 0);
///
/// @brief PIPE the clear command for the global priority channel over HyperionDaemon to Hyperion class
/// @param[in] priority The priority channel (-1 to clear all possible priorities)
/// @param[in] forceclearAll Force the clear
///
void clearGlobalInput(int priority, bool forceClearAll=false);
///
/// @brief PIPE external images over HyperionDaemon to Hyperion class
/// @param[in] priority The priority of the channel
/// @param image The prepared image
/// @param[in] timeout_ms The timeout in milliseconds
/// @param clearEffect Should be true when NOT called from an effect
///
2020-08-08 13:09:15 +02:00
void setGlobalImage(int priority, const Image<ColorRgb>& image, int timeout_ms, bool clearEffect = true);
///
/// @brief PIPE external color message over HyperionDaemon to Hyperion class
/// @param[in] priority The priority of the channel
/// @param image The prepared color
/// @param[in] timeout_ms The timeout in milliseconds
/// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect
///
2020-08-08 13:09:15 +02:00
void setGlobalColor(int priority, const std::vector<ColorRgb> &ledColor, int timeout_ms, const QString& origin = "External" ,bool clearEffects = true);
///////////////////////////////////////
//////////// FROM HYPERION ////////////
///////////////////////////////////////
///
/// @brief PIPE a registration request from the Hyperion class to the priority channel
/// @param[in] priority The priority channel
///
void globalRegRequired(int priority);
///
/// @brief Tell v4l2/screen capture the listener state
/// @param component The component to handle
/// @param hyperionInd The Hyperion instance index as identifier
/// @param listen True when listening, else false
///
2020-08-08 13:09:15 +02:00
void requestSource(hyperion::Components component, int hyperionInd, bool listen);
};