hyperion.ng/libsrc/grabber/x11/X11Wrapper.cpp
2024-03-15 20:23:53 +01:00

52 lines
907 B
C++

#include <grabber/x11/X11Wrapper.h>
X11Wrapper::X11Wrapper( int updateRate_Hz,
int pixelDecimation,
int cropLeft, int cropRight, int cropTop, int cropBottom)
: GrabberWrapper(GRABBERTYPE, &_grabber, updateRate_Hz)
, _grabber(cropLeft, cropRight, cropTop, cropBottom)
, _init(false)
{
_grabber.setPixelDecimation(pixelDecimation);
}
X11Wrapper::X11Wrapper(const QJsonDocument& grabberConfig)
: X11Wrapper(GrabberWrapper::DEFAULT_RATE_HZ,
GrabberWrapper::DEFAULT_PIXELDECIMATION,
0,0,0,0)
{
this->handleSettingsUpdate(settings::SYSTEMCAPTURE, grabberConfig);
}
X11Wrapper::~X11Wrapper()
{
if ( _init )
{
stop();
}
}
void X11Wrapper::action()
{
if (! _init )
{
_init = true;
if ( ! _grabber.setupDisplay() )
{
stop();
}
else
{
if (_grabber.updateScreenDimensions() < 0 )
{
stop();
}
}
}
if (isActive())
{
transferFrame(_grabber);
}
}