WebUI optimization (thx to @mkcologne)

Start Grabber only when global settings are enabled
Fixed an issue in the WebUI preview
This commit is contained in:
Paulchen Panther 2021-05-14 21:20:14 +02:00
parent 96de6012e8
commit bf32557a8a
12 changed files with 131 additions and 94 deletions

View File

@ -24,14 +24,35 @@ body{
*/ */
/* fixed brand icon */ /* fixed brand icon */
@media (min-width: 768px){ @media (min-width: 768px){
.navbar-brand{position:fixed} #wrapper{
#main-nav{position:absolute !important;} padding-left: 10px;
padding-bottom: 10px;
padding-right: 10px;
}
.navbar-brand{
position:fixed;
padding: 0px;
height: 80px;
}
#main-nav{
position:absolute !important;
}
.navbar-top-links li a {
font-size: 22px;
}
} }
/*mobile nav*/ /*mobile nav*/
@media (max-width: 768px){ @media (max-width: 768px){
.navbar-toggle{position:fixed;right:0px;} #wrapper{
#main-nav{position:fixed;right:-200px;} padding: 0px;
}
.navbar-toggle{
position:fixed;right:0px;
}
#main-nav{
position:fixed;right:-200px;
}
} }
.navbar-toggle .icon-bar { .navbar-toggle .icon-bar {
background-color:#4c4c4c !important; background-color:#4c4c4c !important;
@ -83,14 +104,14 @@ table.first_cell_borderless td:first-child,table.first_cell_borderless th:first-
table.first_cell_borderless td:first-child{width: 25px !important;} table.first_cell_borderless td:first-child{width: 25px !important;}
/*Header*/ /*Header*/
.navbar-brand{padding-top:4px;padding-bottom:0px;padding-left:2;} .navbar-brand{padding-top:0px;padding-left:2;}
.sidebar{margin-top:65px;} .sidebar{margin-top:85px;}
.dropdown{font-size:18px;} .dropdown{font-size:18px;}
@media (max-width: 767px) {.sidebar{margin-top:0px;padding-top:0px !important;}} @media (max-width: 767px) {.sidebar{margin-top:0px;padding-top:0px !important;}}
.page-header{margin-top:0px;} .page-header{margin-top:0px;}
.navbar-top-links li a { .navbar-top-links li a {
min-height: 64px; min-height: 84px;
display: flex; display: flex;
align-items: center; align-items: center;
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -101,7 +101,7 @@
<div id="wrapper"> <div id="wrapper">
<!-- Navigation --> <!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0; min-height: 65px"> <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0; min-height: 85px">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle closed" aria-controls="navbar"> <button type="button" class="navbar-toggle closed" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
@ -109,7 +109,7 @@
<span class="icon-bar middle-bar"></span> <span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span> <span class="icon-bar bottom-bar"></span>
</button> </button>
<a class="navbar-brand" href="https://www.hyperion-project.org" target="_blank"><img id="navbar_brand_logo" src="img/hyperion/logo_positiv.png" alt="Redefine ambient light!" height="60"></a> <a class="navbar-brand" href="https://www.hyperion-project.org" target="_blank"><img id="navbar_brand_logo" src="img/hyperion/logo_positiv.png" alt="Redefine ambient light!" height="80"></a>
</div> </div>
<!-- /.navbar-header --> <!-- /.navbar-header -->

View File

@ -112,6 +112,7 @@ $(document).ready(function () {
}, },
closed: function (e) { closed: function (e) {
modalOpened = false; modalOpened = false;
lC = false;
}, },
resizeStop: function (e) { resizeStop: function (e) {
setStorage("ledsim_width", $("#ledsim_dialog").outerWidth()); setStorage("ledsim_width", $("#ledsim_dialog").outerWidth());

View File

@ -16,7 +16,7 @@ install_file()
} }
echo "---Hyperion ambient light postinstall ---" echo "--- Hyperion ambient light postinstall ---"
#check system #check system
CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710\|BCM2835\|BCM2836\|BCM2837\|BCM2711' /proc/cpuinfo` CPU_RPI=`grep -m1 -c 'BCM2708\|BCM2709\|BCM2710\|BCM2835\|BCM2836\|BCM2837\|BCM2711' /proc/cpuinfo`

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -23,6 +23,8 @@ class QTimer;
/// Map of Hyperion instances with grabber name that requested screen capture /// Map of Hyperion instances with grabber name that requested screen capture
static QMap<int, QString> GRABBER_SYS_CLIENTS; static QMap<int, QString> GRABBER_SYS_CLIENTS;
static QMap<int, QString> GRABBER_V4L_CLIENTS; static QMap<int, QString> GRABBER_V4L_CLIENTS;
static bool GLOBAL_GRABBER_SYS_ENABLE;
static bool GLOBAL_GRABBER_V4L_ENABLE;
/// ///
/// This class will be inherted by FramebufferWrapper and others which contains the real capture interface /// This class will be inherted by FramebufferWrapper and others which contains the real capture interface

View File

@ -53,67 +53,73 @@ void VideoWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument
// extract settings // extract settings
const QJsonObject& obj = config.object(); const QJsonObject& obj = config.object();
// Device // global grabber state
_grabber.setDevice(obj["device"].toString("auto")); GLOBAL_GRABBER_V4L_ENABLE = obj["enable"].toBool(false);
// Device input if (GLOBAL_GRABBER_V4L_ENABLE)
_grabber.setInput(obj["input"].toInt(0)); {
// Device
_grabber.setDevice(obj["device"].toString("auto"));
// Device resolution // Device input
_grabber.setWidthHeight(obj["width"].toInt(0), obj["height"].toInt(0)); _grabber.setInput(obj["input"].toInt(0));
// Device framerate // Device resolution
_grabber.setFramerate(obj["fps"].toInt(15)); _grabber.setWidthHeight(obj["width"].toInt(0), obj["height"].toInt(0));
// Device encoding format // Device framerate
_grabber.setEncoding(obj["encoding"].toString("NO_CHANGE")); _grabber.setFramerate(obj["fps"].toInt(15));
// Video standard // Device encoding format
_grabber.setVideoStandard(parseVideoStandard(obj["standard"].toString("NO_CHANGE"))); _grabber.setEncoding(obj["encoding"].toString("NO_CHANGE"));
// Image size decimation // Video standard
_grabber.setPixelDecimation(obj["sizeDecimation"].toInt(8)); _grabber.setVideoStandard(parseVideoStandard(obj["standard"].toString("NO_CHANGE")));
// Flip mode // Image size decimation
_grabber.setFlipMode(parseFlipMode(obj["flip"].toString("NO_CHANGE"))); _grabber.setPixelDecimation(obj["sizeDecimation"].toInt(8));
// Image cropping // Flip mode
_grabber.setCropping( _grabber.setFlipMode(parseFlipMode(obj["flip"].toString("NO_CHANGE")));
obj["cropLeft"].toInt(0),
obj["cropRight"].toInt(0),
obj["cropTop"].toInt(0),
obj["cropBottom"].toInt(0));
// Brightness, Contrast, Saturation, Hue // Image cropping
_grabber.setBrightnessContrastSaturationHue( _grabber.setCropping(
obj["hardware_brightness"].toInt(0), obj["cropLeft"].toInt(0),
obj["hardware_contrast"].toInt(0), obj["cropRight"].toInt(0),
obj["hardware_saturation"].toInt(0), obj["cropTop"].toInt(0),
obj["hardware_hue"].toInt(0)); obj["cropBottom"].toInt(0));
// Brightness, Contrast, Saturation, Hue
_grabber.setBrightnessContrastSaturationHue(
obj["hardware_brightness"].toInt(0),
obj["hardware_contrast"].toInt(0),
obj["hardware_saturation"].toInt(0),
obj["hardware_hue"].toInt(0));
#if defined(ENABLE_CEC) && defined(ENABLE_V4L2) #if defined(ENABLE_CEC) && defined(ENABLE_V4L2)
// CEC Standby // CEC Standby
_grabber.setCecDetectionEnable(obj["cecDetection"].toBool(true)); _grabber.setCecDetectionEnable(obj["cecDetection"].toBool(true));
#endif #endif
// Software frame skipping // Software frame skipping
_grabber.setFpsSoftwareDecimation(obj["fpsSoftwareDecimation"].toInt(1)); _grabber.setFpsSoftwareDecimation(obj["fpsSoftwareDecimation"].toInt(1));
// Signal detection // Signal detection
_grabber.setSignalDetectionEnable(obj["signalDetection"].toBool(true)); _grabber.setSignalDetectionEnable(obj["signalDetection"].toBool(true));
_grabber.setSignalDetectionOffset( _grabber.setSignalDetectionOffset(
obj["sDHOffsetMin"].toDouble(0.25), obj["sDHOffsetMin"].toDouble(0.25),
obj["sDVOffsetMin"].toDouble(0.25), obj["sDVOffsetMin"].toDouble(0.25),
obj["sDHOffsetMax"].toDouble(0.75), obj["sDHOffsetMax"].toDouble(0.75),
obj["sDVOffsetMax"].toDouble(0.75)); obj["sDVOffsetMax"].toDouble(0.75));
_grabber.setSignalThreshold( _grabber.setSignalThreshold(
obj["redSignalThreshold"].toDouble(0.0)/100.0, obj["redSignalThreshold"].toDouble(0.0)/100.0,
obj["greenSignalThreshold"].toDouble(0.0)/100.0, obj["greenSignalThreshold"].toDouble(0.0)/100.0,
obj["blueSignalThreshold"].toDouble(0.0)/100.0, obj["blueSignalThreshold"].toDouble(0.0)/100.0,
obj["noSignalCounterThreshold"].toInt(50)); obj["noSignalCounterThreshold"].toInt(50));
// Reload the Grabber if any settings have been changed that require it // Reload the Grabber if any settings have been changed that require it
_grabber.reload(); _grabber.reload();
}
} }
} }

View File

@ -127,8 +127,8 @@ void CaptureCont::handleSettingsUpdate(settings::type type, const QJsonDocument&
_systemCaptPrio = obj["systemPriority"].toInt(250); _systemCaptPrio = obj["systemPriority"].toInt(250);
} }
setV4LCaptureEnable(obj["v4lEnable"].toBool(true)); setV4LCaptureEnable(obj["v4lEnable"].toBool(false));
setSystemCaptureEnable(obj["systemEnable"].toBool(true)); setSystemCaptureEnable(obj["systemEnable"].toBool(false));
} }
} }

View File

@ -165,33 +165,38 @@ void GrabberWrapper::updateTimer(int interval)
} }
void GrabberWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& config) void GrabberWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
{ { if(type == settings::SYSTEMCAPTURE && !_grabberName.startsWith("V4L"))
if(type == settings::SYSTEMCAPTURE && !_grabberName.startsWith("V4L"))
{ {
// extract settings // extract settings
const QJsonObject& obj = config.object(); const QJsonObject& obj = config.object();
// width/height // global grabber state
_ggrabber->setWidthHeight(obj["width"].toInt(96), obj["height"].toInt(96)); GLOBAL_GRABBER_SYS_ENABLE = obj["enable"].toBool(false);
// display index for MAC if (GLOBAL_GRABBER_SYS_ENABLE)
_ggrabber->setDisplayIndex(obj["input"].toInt(0)); {
// width/height
_ggrabber->setWidthHeight(obj["width"].toInt(96), obj["height"].toInt(96));
// device path for Framebuffer // display index for MAC
_ggrabber->setDevicePath(obj["device"].toString("/dev/fb0")); _ggrabber->setDisplayIndex(obj["input"].toInt(0));
// pixel decimation for x11 // device path for Framebuffer
_ggrabber->setPixelDecimation(obj["pixelDecimation"].toInt(8)); _ggrabber->setDevicePath(obj["device"].toString("/dev/fb0"));
// crop for system capture // pixel decimation for x11
_ggrabber->setCropping( _ggrabber->setPixelDecimation(obj["pixelDecimation"].toInt(8));
obj["cropLeft"].toInt(0),
obj["cropRight"].toInt(0),
obj["cropTop"].toInt(0),
obj["cropBottom"].toInt(0));
// eval new update time // crop for system capture
updateTimer(1000/obj["fps"].toInt(10)); _ggrabber->setCropping(
obj["cropLeft"].toInt(0),
obj["cropRight"].toInt(0),
obj["cropTop"].toInt(0),
obj["cropBottom"].toInt(0));
// eval new update time
updateTimer(1000/obj["fps"].toInt(10));
}
} }
} }
@ -204,7 +209,7 @@ void GrabberWrapper::handleSourceRequest(hyperion::Components component, int hyp
else else
GRABBER_SYS_CLIENTS.remove(hyperionInd); GRABBER_SYS_CLIENTS.remove(hyperionInd);
if(GRABBER_SYS_CLIENTS.empty()) if(GRABBER_SYS_CLIENTS.empty() || !GLOBAL_GRABBER_SYS_ENABLE)
stop(); stop();
else else
start(); start();
@ -216,7 +221,7 @@ void GrabberWrapper::handleSourceRequest(hyperion::Components component, int hyp
else else
GRABBER_V4L_CLIENTS.remove(hyperionInd); GRABBER_V4L_CLIENTS.remove(hyperionInd);
if(GRABBER_V4L_CLIENTS.empty()) if(GRABBER_V4L_CLIENTS.empty() || !GLOBAL_GRABBER_V4L_ENABLE)
stop(); stop();
else else
start(); start();
@ -226,8 +231,6 @@ void GrabberWrapper::handleSourceRequest(hyperion::Components component, int hyp
void GrabberWrapper::tryStart() void GrabberWrapper::tryStart()
{ {
// verify start condition // verify start condition
if((_grabberName.startsWith("V4L") && !GRABBER_V4L_CLIENTS.empty()) || (!_grabberName.startsWith("V4L") && !GRABBER_SYS_CLIENTS.empty())) if(!_grabberName.startsWith("V4L") && !GRABBER_SYS_CLIENTS.empty() && GLOBAL_GRABBER_SYS_ENABLE)
{
start(); start();
}
} }

View File

@ -493,7 +493,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberFramebuffer(grabberConfig); createGrabberFramebuffer(grabberConfig);
} }
#ifdef ENABLE_FB #ifdef ENABLE_FB
_fbGrabber->tryStart(); _dispmanx->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_dispmanx->tryStart();
#endif #endif
} }
else if (type == "dispmanx") else if (type == "dispmanx")
@ -503,7 +504,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberDispmanx(); createGrabberDispmanx();
} }
#ifdef ENABLE_DISPMANX #ifdef ENABLE_DISPMANX
_dispmanx->tryStart(); _dispmanx->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_dispmanx->tryStart();
#endif #endif
} }
else if (type == "amlogic") else if (type == "amlogic")
@ -513,7 +515,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberAmlogic(); createGrabberAmlogic();
} }
#ifdef ENABLE_AMLOGIC #ifdef ENABLE_AMLOGIC
_amlGrabber->tryStart(); _amlGrabber->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_amlGrabber->tryStart();
#endif #endif
} }
else if (type == "osx") else if (type == "osx")
@ -523,7 +526,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberOsx(grabberConfig); createGrabberOsx(grabberConfig);
} }
#ifdef ENABLE_OSX #ifdef ENABLE_OSX
_osxGrabber->tryStart(); _osxGrabber->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_osxGrabber->tryStart();
#endif #endif
} }
else if (type == "x11") else if (type == "x11")
@ -533,7 +537,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberX11(grabberConfig); createGrabberX11(grabberConfig);
} }
#ifdef ENABLE_X11 #ifdef ENABLE_X11
_x11Grabber->tryStart(); _x11Grabber->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_x11Grabber->tryStart();
#endif #endif
} }
else if (type == "xcb") else if (type == "xcb")
@ -543,7 +548,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberXcb(grabberConfig); createGrabberXcb(grabberConfig);
} }
#ifdef ENABLE_XCB #ifdef ENABLE_XCB
_xcbGrabber->tryStart(); _xcbGrabber->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_xcbGrabber->tryStart();
#endif #endif
} }
else if (type == "qt") else if (type == "qt")
@ -553,7 +559,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberQt(grabberConfig); createGrabberQt(grabberConfig);
} }
#ifdef ENABLE_QT #ifdef ENABLE_QT
_qtGrabber->tryStart(); _qtGrabber->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_qtGrabber->tryStart();
#endif #endif
} }
else if (type == "dx") else if (type == "dx")
@ -563,7 +570,7 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
createGrabberDx(grabberConfig); createGrabberDx(grabberConfig);
} }
#ifdef ENABLE_DX #ifdef ENABLE_DX
_dxGrabber->tryStart(); // _dxGrabber->tryStart();
#endif #endif
} }
else else
@ -577,11 +584,8 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
else if (settingsType == settings::V4L2) else if (settingsType == settings::V4L2)
{ {
#if defined(ENABLE_CEC) || defined(ENABLE_V4L2) || defined(ENABLE_MF)
const QJsonObject& grabberConfig = config.object();
#endif
#ifdef ENABLE_CEC #ifdef ENABLE_CEC
const QJsonObject& grabberConfig = config.object();
if (_cecHandler != nullptr && grabberConfig["cecDetection"].toBool(false)) if (_cecHandler != nullptr && grabberConfig["cecDetection"].toBool(false))
{ {
QMetaObject::invokeMethod(_cecHandler, "start", Qt::QueuedConnection); QMetaObject::invokeMethod(_cecHandler, "start", Qt::QueuedConnection);
@ -596,7 +600,7 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
if (_videoGrabber == nullptr) if (_videoGrabber == nullptr)
{ {
_videoGrabber = new VideoWrapper(); _videoGrabber = new VideoWrapper();
_videoGrabber->handleSettingsUpdate(settings::V4L2, QJsonDocument(grabberConfig)); _videoGrabber->handleSettingsUpdate(settings::V4L2, getSetting(settings::V4L2));
#if defined(ENABLE_MF) #if defined(ENABLE_MF)
Debug(_log, "Media Foundation grabber created"); Debug(_log, "Media Foundation grabber created");