mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Feature/xcb grabber (#912)
* Add Xcb grabber * update compile instruction Signed-off-by: Paulchen Panther <Paulchen-Panter@protonmail.com> * Fix problem on resolution change + Make XCB default if X11 is not avaialable * Fix decimation problem Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com> Co-authored-by: Paulchen Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -95,6 +95,10 @@ if (ENABLE_X11)
|
||||
target_link_libraries(hyperiond x11-grabber)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_XCB)
|
||||
target_link_libraries(hyperiond xcb-grabber)
|
||||
endif ()
|
||||
|
||||
if (ENABLE_QT)
|
||||
target_link_libraries(hyperiond qt-grabber)
|
||||
endif ()
|
||||
|
@@ -75,6 +75,7 @@ HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bo
|
||||
, _v4l2Grabber(nullptr)
|
||||
, _dispmanx(nullptr)
|
||||
, _x11Grabber(nullptr)
|
||||
, _xcbGrabber(nullptr)
|
||||
, _amlGrabber(nullptr)
|
||||
, _fbGrabber(nullptr)
|
||||
, _osxGrabber(nullptr)
|
||||
@@ -133,7 +134,7 @@ HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bo
|
||||
connect(this, &HyperionDaemon::videoMode, _instanceManager, &HyperionIManager::newVideoMode);
|
||||
|
||||
// ---- grabber -----
|
||||
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX) && !defined(ENABLE_FB) && !defined(ENABLE_X11) && !defined(ENABLE_AMLOGIC) && !defined(ENABLE_QT)
|
||||
#if !defined(ENABLE_DISPMANX) && !defined(ENABLE_OSX) && !defined(ENABLE_FB) && !defined(ENABLE_X11) && !defined(ENABLE_XCB) && !defined(ENABLE_AMLOGIC) && !defined(ENABLE_QT)
|
||||
Warning(_log, "No platform capture can be instantiated, because all grabbers have been left out from the build");
|
||||
#endif
|
||||
|
||||
@@ -374,7 +375,13 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type &settingsType, co
|
||||
QByteArray envDisplay = qgetenv("DISPLAY");
|
||||
if ( !envDisplay.isEmpty() )
|
||||
{
|
||||
#if defined(ENABLE_X11)
|
||||
type = "x11";
|
||||
#elif defined(ENABLE_XCB)
|
||||
type = "xcb";
|
||||
#else
|
||||
type = "qt";
|
||||
#endif
|
||||
}
|
||||
// qt -> if nothing other applies
|
||||
else
|
||||
@@ -429,6 +436,14 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type &settingsType, co
|
||||
_x11Grabber = nullptr;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_XCB
|
||||
if(_xcbGrabber != nullptr)
|
||||
{
|
||||
_xcbGrabber->stop();
|
||||
delete _xcbGrabber;
|
||||
_xcbGrabber = nullptr;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_QT
|
||||
if(_qtGrabber != nullptr)
|
||||
{
|
||||
@@ -479,6 +494,14 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type &settingsType, co
|
||||
_x11Grabber->tryStart();
|
||||
#endif
|
||||
}
|
||||
else if (type == "xcb")
|
||||
{
|
||||
if (_xcbGrabber == nullptr)
|
||||
createGrabberXcb(grabberConfig);
|
||||
#ifdef ENABLE_XCB
|
||||
_xcbGrabber->tryStart();
|
||||
#endif
|
||||
}
|
||||
else if (type == "qt")
|
||||
{
|
||||
if (_qtGrabber == nullptr)
|
||||
@@ -603,6 +626,25 @@ void HyperionDaemon::createGrabberX11(const QJsonObject &grabberConfig)
|
||||
#endif
|
||||
}
|
||||
|
||||
void HyperionDaemon::createGrabberXcb(const QJsonObject &grabberConfig)
|
||||
{
|
||||
#ifdef ENABLE_XCB
|
||||
_xcbGrabber = new XcbWrapper(
|
||||
_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom,
|
||||
grabberConfig["pixelDecimation"].toInt(8),
|
||||
_grabber_frequency);
|
||||
_xcbGrabber->setCropping(_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom);
|
||||
|
||||
// connect to HyperionDaemon signal
|
||||
connect(this, &HyperionDaemon::videoMode, _xcbGrabber, &XcbWrapper::setVideoMode);
|
||||
connect(this, &HyperionDaemon::settingsChanged, _xcbGrabber, &XcbWrapper::handleSettingsUpdate);
|
||||
|
||||
Info(_log, "XCB grabber created");
|
||||
#else
|
||||
Error(_log, "The XCB grabber can not be instantiated, because it has been left out from the build");
|
||||
#endif
|
||||
}
|
||||
|
||||
void HyperionDaemon::createGrabberQt(const QJsonObject &grabberConfig)
|
||||
{
|
||||
#ifdef ENABLE_QT
|
||||
|
@@ -40,6 +40,12 @@
|
||||
typedef QObject X11Wrapper;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_XCB
|
||||
#include <grabber/XcbWrapper.h>
|
||||
#else
|
||||
typedef QObject XcbWrapper;
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_QT
|
||||
#include <grabber/QtWrapper.h>
|
||||
#else
|
||||
@@ -144,6 +150,7 @@ private:
|
||||
void createGrabberFramebuffer(const QJsonObject & grabberConfig);
|
||||
void createGrabberOsx(const QJsonObject & grabberConfig);
|
||||
void createGrabberX11(const QJsonObject & grabberConfig);
|
||||
void createGrabberXcb(const QJsonObject & grabberConfig);
|
||||
void createGrabberQt(const QJsonObject & grabberConfig);
|
||||
void createCecHandler();
|
||||
|
||||
@@ -159,6 +166,7 @@ private:
|
||||
V4L2Wrapper* _v4l2Grabber;
|
||||
DispmanxWrapper* _dispmanx;
|
||||
X11Wrapper* _x11Grabber;
|
||||
XcbWrapper* _xcbGrabber;
|
||||
AmlogicWrapper* _amlGrabber;
|
||||
FramebufferWrapper* _fbGrabber;
|
||||
OsxWrapper* _osxGrabber;
|
||||
|
@@ -105,13 +105,21 @@ QCoreApplication* createApplication(int &argc, char *argv[])
|
||||
if (!forceNoGui)
|
||||
{
|
||||
// if x11, then test if xserver is available
|
||||
#ifdef ENABLE_X11
|
||||
#if defined(ENABLE_X11)
|
||||
Display* dpy = XOpenDisplay(NULL);
|
||||
if (dpy != NULL)
|
||||
{
|
||||
XCloseDisplay(dpy);
|
||||
isGuiApp = true;
|
||||
}
|
||||
#elif defined(ENABLE_XCB)
|
||||
int screen_num;
|
||||
xcb_connection_t * connection = xcb_connect(nullptr, &screen_num);
|
||||
if (!xcb_connection_has_error(connection))
|
||||
{
|
||||
isGuiApp = true;
|
||||
}
|
||||
xcb_disconnect(connection);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user