Dynamic loading of the Dispmanx Grabber (#1440)

* BCM dynamic loading

* cleanup

* better handle start of dispmanx

* set GrabberWrapper pointer to null on exit

* Update DispmanxFrameGrabber.cpp
This commit is contained in:
Markus
2022-03-20 14:42:21 +01:00
committed by GitHub
parent f32db90c12
commit addff6f7ef
16 changed files with 278 additions and 287 deletions

View File

@@ -3,16 +3,8 @@ project(hyperion-dispmanx)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Widgets REQUIRED)
IF ( "${PLATFORM}" MATCHES rpi)
find_package(BCM REQUIRED)
ELSE()
SET(BCM_INCLUDE_DIRS "")
SET(BCM_LIBRARIES "")
ENDIF()
include_directories(
${CMAKE_CURRENT_BINARY_DIR}/../../libsrc/flatbufserver
${BCM_INCLUDE_DIRS}
${FLATBUFFERS_INCLUDE_DIRS}
)
@@ -30,13 +22,15 @@ add_executable( ${PROJECT_NAME}
${Hyperion_Dispmanx_SOURCES}
)
SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-rdynamic")
SET(CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS} "-rdynamic")
target_link_libraries( ${PROJECT_NAME}
commandline
hyperion-utils
flatbufconnect
flatbuffers
dispmanx-grabber
${Dispmanx_LIBRARIES}
ssdp
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Network

View File

@@ -27,6 +27,11 @@ const Image<ColorRgb> & DispmanxWrapper::getScreenshot()
return _screenshot;
}
bool DispmanxWrapper::open()
{
return _grabber.open();
}
void DispmanxWrapper::start()
{
_timer.start();
@@ -39,13 +44,16 @@ void DispmanxWrapper::stop()
bool DispmanxWrapper::screenInit()
{
return _grabber.setupScreen();
return (open() && _grabber.setupScreen());
}
void DispmanxWrapper::capture()
{
_grabber.grabFrame(_screenshot);
emit sig_screenshot(_screenshot);
if ( open() )
{
_grabber.grabFrame(_screenshot);
emit sig_screenshot(_screenshot);
}
}
void DispmanxWrapper::setVideoMode(VideoMode mode)

View File

@@ -16,6 +16,8 @@ public:
);
const Image<ColorRgb> & getScreenshot();
bool open();
///
/// Starts the timed capturing of screenshots

View File

@@ -90,13 +90,6 @@ if (ENABLE_AMLOGIC)
endif(ENABLE_AMLOGIC)
if (ENABLE_DISPMANX)
IF ( "${PLATFORM}" MATCHES rpi)
find_package(BCM REQUIRED)
include_directories(${BCM_INCLUDE_DIRS})
ELSE()
SET(BCM_INCLUDE_DIRS "")
SET(BCM_LIBRARIES "")
ENDIF()
target_link_libraries(${PROJECT_NAME} dispmanx-grabber)
endif (ENABLE_DISPMANX)

View File

@@ -264,7 +264,8 @@ void HyperionDaemon::freeObjects()
#endif
delete _amlGrabber;
delete _dispmanx;
if (_dispmanx != nullptr)
delete _dispmanx;
delete _fbGrabber;
delete _osxGrabber;
delete _qtGrabber;
@@ -522,9 +523,13 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
{
createGrabberDispmanx(grabberConfig);
}
#ifdef ENABLE_DISPMANX
if (_dispmanx != nullptr)
{
_dispmanx->handleSettingsUpdate(settings::SYSTEMCAPTURE, getSetting(settings::SYSTEMCAPTURE));
_dispmanx->tryStart();
}
#endif
}
else if (type == "amlogic")
@@ -644,7 +649,16 @@ void HyperionDaemon::createGrabberDispmanx(const QJsonObject& /*grabberConfig*/)
_dispmanx = new DispmanxWrapper(
_grabber_frequency,
_grabber_pixelDecimation
);
);
if (!_dispmanx->available)
{
delete _dispmanx;
_dispmanx = nullptr;
Debug(_log, "The dispmanx framegrabber is not supported on this platform");
return;
}
_dispmanx->setCropping(_grabber_cropLeft, _grabber_cropRight, _grabber_cropTop, _grabber_cropBottom);
// connect to HyperionDaemon signal