mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Start SmartPointers (#1679)
* Refactor to fix #1671 * Add GUI/NonGUI mode to info page * Do not show lock config, if in non-UI mode * Updae Changelog * Correct includes * Ensure key member initialization - RGB Channels * Ensure key member initialization - WebServer * Update RGBChannels * Fix initialization order * Fix key when inserting new logger in LoggerMap, Prepare logBuffer-JSON snapshot view in LoggerManager, Increase buffered loglines to 500 * Fix Memory leak in GrabberWrapper * Fix Memory leak in BlackBorderProcessor * Fix Memory leak in BlackBorderProcessor * use ninja generator under macos * Fix BGEffectHandler destruction * Fix Mdns code * Clear list after applying qDeleteAll * Fix deletion of CecHandler * Fix memory leak caused by wrong buffer allocation * Remove extra pixel consistently * Change mDNS to Qt SmartPointers * Correct removal * Fix usage of _width/_height (they are the output resolution, not the screen resolution) That avoids unnecessary resizing of the output image with every transferFrame call * Move main non Thread Objects to Smart Pointers * Refactor Hyperion Daemon unsing smartpointers * Correction * Correct typos/ align text * Fix startGrabberDispmanx * Fix startGrabberDispmanx * Address CodeQL finding * Create Screen grabbers via Template * Fix typo * Change way of logging * Revert change * Address deprecation warning * Correct auto screen grabber evaluation --------- Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -27,7 +27,7 @@
|
||||
namespace {
|
||||
const bool verbose = false;
|
||||
|
||||
const char DEFAULT_FB_DEVICE[] = "/dev/fb0";
|
||||
const int DEFAULT_FB_DEVICE_IDX = 0;
|
||||
const char DEFAULT_VIDEO_DEVICE[] = "/dev/amvideo";
|
||||
const char DEFAULT_CAPTURE_DEVICE[] = "/dev/amvideocap0";
|
||||
const int AMVIDEOCAP_WAIT_MAX_MS = 40;
|
||||
@@ -36,11 +36,11 @@ const int AMVIDEOCAP_DEFAULT_RATE_HZ = 25;
|
||||
} //End of constants
|
||||
|
||||
AmlogicGrabber::AmlogicGrabber()
|
||||
: Grabber("AMLOGICGRABBER") // Minimum required width or height is 160
|
||||
: Grabber("GRABBER-AMLOGIC") // Minimum required width or height is 160
|
||||
, _captureDev(-1)
|
||||
, _videoDev(-1)
|
||||
, _lastError(0)
|
||||
, _fbGrabber(DEFAULT_FB_DEVICE)
|
||||
, _fbGrabber(DEFAULT_FB_DEVICE_IDX)
|
||||
, _grabbingModeNotification(0)
|
||||
{
|
||||
_image_ptr = _image_bgr.memptr();
|
||||
@@ -57,7 +57,7 @@ bool AmlogicGrabber::setupScreen()
|
||||
{
|
||||
bool rc (false);
|
||||
|
||||
QSize screenSize = _fbGrabber.getScreenSize(DEFAULT_FB_DEVICE);
|
||||
QSize screenSize = _fbGrabber.getScreenSize();
|
||||
if ( !screenSize.isEmpty() )
|
||||
{
|
||||
if (setWidthHeight(screenSize.width(), screenSize.height()))
|
||||
|
@@ -1,12 +1,18 @@
|
||||
#include <grabber/amlogic/AmlogicWrapper.h>
|
||||
|
||||
AmlogicWrapper::AmlogicWrapper(int pixelDecimation, int updateRate_Hz)
|
||||
: GrabberWrapper("Amlogic", &_grabber, updateRate_Hz)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber()
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
AmlogicWrapper::AmlogicWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
void AmlogicWrapper::action()
|
||||
{
|
||||
transferFrame(_grabber);
|
||||
|
@@ -10,7 +10,7 @@ namespace {
|
||||
} //End of constants
|
||||
|
||||
DirectXGrabber::DirectXGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: Grabber("DXGRABBER", cropLeft, cropRight, cropTop, cropBottom)
|
||||
: Grabber("GRABBER-DIRECTX", cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _display(unsigned(display))
|
||||
, _displayWidth(0)
|
||||
, _displayHeight(0)
|
||||
|
@@ -5,13 +5,19 @@ DirectXWrapper::DirectXWrapper( int updateRate_Hz,
|
||||
int pixelDecimation,
|
||||
int cropLeft, int cropRight, int cropTop, int cropBottom
|
||||
)
|
||||
: GrabberWrapper("DirectX", &_grabber, updateRate_Hz)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber(display, cropLeft, cropRight, cropTop, cropBottom)
|
||||
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
DirectXWrapper::DirectXWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
void DirectXWrapper::action()
|
||||
{
|
||||
transferFrame(_grabber);
|
||||
|
@@ -19,7 +19,7 @@ namespace {
|
||||
#include "grabber/dispmanx/DispmanxFrameGrabber.h"
|
||||
|
||||
DispmanxFrameGrabber::DispmanxFrameGrabber()
|
||||
: Grabber("DISPMANXGRABBER")
|
||||
: Grabber("GRABBER-DISPMANX")
|
||||
, _lib(nullptr)
|
||||
, _vc_display(0)
|
||||
, _vc_resource(0)
|
||||
|
@@ -3,15 +3,20 @@
|
||||
DispmanxWrapper::DispmanxWrapper( int updateRate_Hz,
|
||||
int pixelDecimation
|
||||
)
|
||||
: GrabberWrapper("Dispmanx", &_grabber, updateRate_Hz)
|
||||
, _grabber()
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
{
|
||||
if (available = _grabber.isAvailable())
|
||||
if (_isAvailable)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
}
|
||||
|
||||
DispmanxWrapper::DispmanxWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
bool DispmanxWrapper::open()
|
||||
{
|
||||
return _grabber.open();
|
||||
|
@@ -30,11 +30,11 @@ const char DISCOVERY_FILEPATTERN[] = "fb?";
|
||||
// Local includes
|
||||
#include <grabber/framebuffer/FramebufferFrameGrabber.h>
|
||||
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device)
|
||||
: Grabber("FRAMEBUFFERGRABBER")
|
||||
, _fbDevice(device)
|
||||
, _fbfd (-1)
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(int deviceIdx)
|
||||
: Grabber("GRABBER-FB")
|
||||
, _fbfd (-1)
|
||||
{
|
||||
_input = deviceIdx;
|
||||
_useImageResampler = true;
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@ bool FramebufferFrameGrabber::openDevice()
|
||||
{
|
||||
bool rc = true;
|
||||
|
||||
_fbDevice = getPath();
|
||||
/* Open the framebuffer device */
|
||||
_fbfd = ::open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
if (_fbfd < 0)
|
||||
@@ -136,8 +137,7 @@ QSize FramebufferFrameGrabber::getScreenSize() const
|
||||
|
||||
QSize FramebufferFrameGrabber::getScreenSize(const QString& device) const
|
||||
{
|
||||
int width (0);
|
||||
int height(0);
|
||||
QSize size;
|
||||
|
||||
int fbfd = ::open(QSTRING_CSTR(device), O_RDONLY);
|
||||
if (fbfd != -1)
|
||||
@@ -146,13 +146,13 @@ QSize FramebufferFrameGrabber::getScreenSize(const QString& device) const
|
||||
int result = ioctl (fbfd, FBIOGET_VSCREENINFO, &vinfo);
|
||||
if (result == 0)
|
||||
{
|
||||
width = static_cast<int>(vinfo.xres);
|
||||
height = static_cast<int>(vinfo.yres);
|
||||
DebugIf(verbose, _log, "FB device [%s] found with resolution: %dx%d", QSTRING_CSTR(device), width, height);
|
||||
size.setWidth(static_cast<int>(vinfo.xres));
|
||||
size.setHeight(static_cast<int>(vinfo.yres));
|
||||
DebugIf(verbose, _log, "FB device [%s] found with resolution: %dx%d", QSTRING_CSTR(device), size.width(), size.height());
|
||||
}
|
||||
::close(fbfd);
|
||||
}
|
||||
return QSize(width, height);
|
||||
return size;
|
||||
}
|
||||
|
||||
bool FramebufferFrameGrabber::getScreenInfo()
|
||||
|
@@ -1,14 +1,20 @@
|
||||
#include <grabber/framebuffer/FramebufferWrapper.h>
|
||||
|
||||
FramebufferWrapper::FramebufferWrapper( int updateRate_Hz,
|
||||
const QString & device,
|
||||
int deviceIdx,
|
||||
int pixelDecimation)
|
||||
: GrabberWrapper("FrameBuffer", &_grabber, updateRate_Hz)
|
||||
, _grabber(device)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber(deviceIdx)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
FramebufferWrapper::FramebufferWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
void FramebufferWrapper::action()
|
||||
{
|
||||
transferFrame(_grabber);
|
||||
|
@@ -16,7 +16,7 @@ const bool verbose = false;
|
||||
} //End of constants
|
||||
|
||||
OsxFrameGrabber::OsxFrameGrabber(int display)
|
||||
: Grabber("OSXGRABBER")
|
||||
: Grabber("GRABBER-OSX")
|
||||
, _screenIndex(display)
|
||||
{
|
||||
_isEnabled = false;
|
||||
|
@@ -4,12 +4,18 @@ OsxWrapper::OsxWrapper( int updateRate_Hz,
|
||||
int display,
|
||||
int pixelDecimation
|
||||
)
|
||||
: GrabberWrapper("OSX", &_grabber, updateRate_Hz)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber(display)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
OsxWrapper::OsxWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
void OsxWrapper::action()
|
||||
{
|
||||
transferFrame(_grabber);
|
||||
|
@@ -20,8 +20,9 @@ const bool verbose = false;
|
||||
} //End of constants
|
||||
|
||||
QtGrabber::QtGrabber(int display, int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: Grabber("QTGRABBER", cropLeft, cropRight, cropTop, cropBottom)
|
||||
: Grabber("GRABBER-QT", cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _display(display)
|
||||
, _numberOfSDisplays(0)
|
||||
, _screenWidth(0)
|
||||
, _screenHeight(0)
|
||||
, _src_x(0)
|
||||
@@ -32,7 +33,6 @@ QtGrabber::QtGrabber(int display, int cropLeft, int cropRight, int cropTop, int
|
||||
, _screen(nullptr)
|
||||
, _isVirtual(false)
|
||||
{
|
||||
_logger = Logger::getInstance("Qt");
|
||||
_useImageResampler = false;
|
||||
}
|
||||
|
||||
|
@@ -5,12 +5,18 @@ QtWrapper::QtWrapper( int updateRate_Hz,
|
||||
int pixelDecimation,
|
||||
int cropLeft, int cropRight, int cropTop, int cropBottom
|
||||
)
|
||||
: GrabberWrapper("Qt", &_grabber, updateRate_Hz)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber(display, cropLeft, cropRight, cropTop, cropBottom)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
QtWrapper::QtWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
bool QtWrapper::open()
|
||||
{
|
||||
return _grabber.open();
|
||||
|
@@ -10,7 +10,7 @@ namespace {
|
||||
} //End of constants
|
||||
|
||||
X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: Grabber("X11GRABBER", cropLeft, cropRight, cropTop, cropBottom)
|
||||
: Grabber("GRABBER-X11", cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _x11Display(nullptr)
|
||||
, _xImage(nullptr)
|
||||
, _pixmap(None)
|
||||
@@ -28,8 +28,6 @@ X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
, _isWayland (false)
|
||||
, _logger{}
|
||||
{
|
||||
_logger = Logger::getInstance("X11");
|
||||
|
||||
_useImageResampler = false;
|
||||
_imageResampler.setCropping(0, 0, 0, 0); // cropping is performed by XRender, XShmGetImage or XGetImage
|
||||
memset(&_pictAttr, 0, sizeof(_pictAttr));
|
||||
|
@@ -3,13 +3,19 @@
|
||||
X11Wrapper::X11Wrapper( int updateRate_Hz,
|
||||
int pixelDecimation,
|
||||
int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: GrabberWrapper("X11", &_grabber, updateRate_Hz)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber(cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _init(false)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
X11Wrapper::X11Wrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
X11Wrapper::~X11Wrapper()
|
||||
{
|
||||
if ( _init )
|
||||
|
@@ -18,7 +18,7 @@ namespace {
|
||||
#define DOUBLE_TO_FIXED(d) ((xcb_render_fixed_t) ((d) * 65536))
|
||||
|
||||
XcbGrabber::XcbGrabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: Grabber("XCBGRABBER", cropLeft, cropRight, cropTop, cropBottom)
|
||||
: Grabber("GRABBER-XCB", cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _connection{}
|
||||
, _screen{}
|
||||
, _pixmap{}
|
||||
@@ -41,8 +41,6 @@ XcbGrabber::XcbGrabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
, _shmData{}
|
||||
, _XcbRandREventBase{-1}
|
||||
{
|
||||
_logger = Logger::getInstance("XCB");
|
||||
|
||||
// cropping is performed by XcbRender, XcbShmGetImage or XcbGetImage
|
||||
_useImageResampler = false;
|
||||
_imageResampler.setCropping(0, 0, 0, 0);
|
||||
|
@@ -3,13 +3,19 @@
|
||||
XcbWrapper::XcbWrapper( int updateRate_Hz,
|
||||
int pixelDecimation,
|
||||
int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: GrabberWrapper("Xcb", &_grabber, updateRate_Hz)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
|
||||
, _grabber(cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _init(false)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
XcbWrapper::XcbWrapper(const QJsonDocument& grabberConfig)
|
||||
: GrabberWrapper(GRABBERTYPE, &_grabber)
|
||||
{
|
||||
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
|
||||
}
|
||||
|
||||
XcbWrapper::~XcbWrapper()
|
||||
{
|
||||
if ( _init )
|
||||
|
Reference in New Issue
Block a user