Skip to content

Commit dda5e54

Browse files
committed
Pipewire DMA & EGL hardware support
1 parent 3353015 commit dda5e54

17 files changed

+968
-208
lines changed

Diff for: CMakeLists.txt

+16-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ SET ( DEFAULT_MAC_SYSTEM OFF )
3030
SET ( DEFAULT_V4L2 OFF )
3131
SET ( DEFAULT_X11 OFF )
3232
SET ( DEFAULT_PIPEWIRE OFF )
33+
SET ( DEFAULT_PIPEWIRE_EGL OFF )
3334
SET ( DEFAULT_FRAMEBUFFER OFF )
3435
SET ( DEFAULT_SOUNDCAPWINDOWS OFF )
3536
SET ( DEFAULT_SOUNDCAPMACOS OFF )
@@ -252,13 +253,21 @@ if (DEFAULT_PIPEWIRE)
252253
message( WARNING "QT dbus library is required for PipeWire/Portal support" )
253254
SET ( DEFAULT_PIPEWIRE OFF )
254255
else()
255-
256256
pkg_check_modules(PIPEWIRE libpipewire-0.3)
257257
if(NOT PIPEWIRE_FOUND OR NOT PIPEWIRE_INCLUDE_DIRS OR NOT PIPEWIRE_LIBRARIES)
258258
message( WARNING "Pipewire >= 3.0 not found (did you install libpipewire-0.3-dev?). Disabling support for PipeWire software grabber.")
259259
SET ( DEFAULT_PIPEWIRE OFF )
260+
else()
261+
if(POLICY CMP0072)
262+
cmake_policy(SET CMP0072 NEW)
263+
endif()
264+
find_package(OpenGL)
265+
if (NOT OpenGL_OpenGL_FOUND OR NOT OpenGL_EGL_FOUND)
266+
message( WARNING "OpenGL/EGL not found. Disabling DMA buffers for Pipewire.")
267+
else()
268+
SET ( DEFAULT_PIPEWIRE_EGL ON )
269+
endif()
260270
endif()
261-
262271
endif()
263272
endif()
264273

@@ -340,6 +349,11 @@ colorMe("ENABLE_MAC_SYSTEM = " ${ENABLE_MAC_SYSTEM})
340349
option(ENABLE_PIPEWIRE "Enable the pipewire/portal Linux system grabber" ${DEFAULT_PIPEWIRE})
341350
colorMe("ENABLE_PIPEWIRE = " ${ENABLE_PIPEWIRE})
342351

352+
option(ENABLE_PIPEWIRE_EGL "Enable the pipewire EGL extension" ${DEFAULT_PIPEWIRE_EGL})
353+
if (DEFAULT_PIPEWIRE)
354+
colorMe("ENABLE_PIPEWIRE_EGL = " ${ENABLE_PIPEWIRE_EGL})
355+
endif()
356+
343357
option(ENABLE_X11 "Enable the X11 Linux system grabber" ${DEFAULT_X11})
344358
colorMe("ENABLE_X11 = " ${ENABLE_X11})
345359

Diff for: HyperhdrConfig.h.in

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
// PipeWire system grabber
2222
#cmakedefine ENABLE_PIPEWIRE
2323

24+
// PipeWire EGL extension
25+
#cmakedefine ENABLE_PIPEWIRE_EGL
26+
2427
// Define to enable boblight server
2528
#cmakedefine ENABLE_BOBLIGHT
2629

Diff for: include/base/Grabber.h

+2
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ class Grabber : public DetectionAutomatic, public DetectionManual
139139
};
140140

141141
public slots:
142+
virtual bool isRunning();
143+
142144
virtual bool start() = 0;
143145

144146
virtual void stop() = 0;

Diff for: include/base/SystemWrapper.h

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public slots:
5858
void setHdrToneMappingEnabled(int mode);
5959
void handleSettingsUpdate(settings::type type, const QJsonDocument& config);
6060
virtual void stateChanged(bool state);
61+
bool isRunning();
6162

6263
protected:
6364
virtual QString getGrabberInfo();

Diff for: include/grabber/PipewireGrabber.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <utils/PixelFormat.h>
1919
#include <base/Grabber.h>
2020
#include <utils/Components.h>
21+
#include <grabber/smartPipewire.h>
2122

2223
// general JPEG decoder includes
2324
#include <QImage>
@@ -42,12 +43,12 @@ class PipewireGrabber : public Grabber
4243

4344
void stateChanged(bool state);
4445

45-
private slots:
46-
47-
void grabFrame();
46+
static void callbackFunction(const PipewireImage& frame);
4847

4948
public slots:
5049

50+
void grabFrame(const PipewireImage& data);
51+
5152
bool start() override;
5253

5354
void stop() override;
@@ -56,6 +57,8 @@ public slots:
5657

5758
void newWorkerFrameError(unsigned int workerIndex, QString error, quint64 sourceCount) override {};
5859

60+
bool isRunning() override;
61+
5962
private:
6063
QString GetSharedLut();
6164

@@ -75,12 +78,11 @@ public slots:
7578

7679
private:
7780
QString _configurationPath;
78-
QTimer _timer;
79-
QSemaphore _semaphore;
8081

8182
void* _library;
8283
int _actualDisplay;
8384
bool _isActive;
8485
bool _storedToken;
8586
bool _versionCheck;
87+
bool _hasFrame;
8688
};

Diff for: include/grabber/PipewireWrapper.h

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class PipewireWrapper : public SystemWrapper
1313

1414
public slots:
1515
void stateChanged(bool state) override;
16+
void processFrame(const PipewireImage& frame);
1617

1718
protected:
1819
QString getGrabberInfo() override;

Diff for: include/grabber/smartPipewire.h

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
15
struct PipewireImage
26
{
37
int version;
48
bool isError;
5-
int width, height;
9+
int width, height, stride;
610
bool isOrderRgb;
7-
unsigned char* data;
11+
uint8_t* data;
812
};
13+
14+
typedef int (*pipewire_callback_func)(const PipewireImage& frame);
15+
916
extern "C" const char* getPipewireToken();
1017
extern "C" const char* getPipewireError();
1118
extern "C" bool hasPipewire();
12-
extern "C" void initPipewireDisplay(const char* restorationToken);
19+
extern "C" void initPipewireDisplay(const char* restorationToken, uint32_t requestedFPS, pipewire_callback_func callback);
1320
extern "C" void uniniPipewireDisplay();
14-
extern "C" PipewireImage getFramePipewire();
15-
extern "C" void releaseFramePipewire();
1621

Diff for: sources/base/Grabber.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -910,3 +910,8 @@ QJsonObject Grabber::getJsonInfo()
910910
void Grabber::alternativeCaching(bool alternative)
911911
{
912912
}
913+
914+
bool Grabber::isRunning()
915+
{
916+
return false;
917+
}

Diff for: sources/base/HyperHdrInstance.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ void HyperHdrInstance::updateResult(std::vector<ColorRgb> _ledBuffer)
665665
else if (prevToken != (_computeStats.token = PerformanceCounters::currentToken()))
666666
{
667667

668-
if (diff >= 59000 && diff <= 65000)
668+
if (diff >= 59000)
669669
emit PerformanceCounters::getInstance()->newCounter(
670670
PerformanceReport(static_cast<int>(PerformanceReportType::INSTANCE), _computeStats.token, _name, _computeStats.total / qMax(diff/1000.0, 1.0), _computeStats.total, 0, 0, getInstanceIndex()));
671671

Diff for: sources/base/SystemControl.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ void SystemControl::handleCompStateChangeRequest(hyperhdr::Components component,
137137

138138
void SystemControl::setSysInactive()
139139
{
140+
if (SystemWrapper::getInstance() != nullptr && SystemWrapper::getInstance()->isRunning())
141+
return;
142+
140143
if (!_alive)
141144
_hyperhdr->setInputInactive(_sysCaptPrio);
142145

Diff for: sources/base/SystemWrapper.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -237,3 +237,13 @@ QJsonObject SystemWrapper::getJsonInfo()
237237

238238
return systemDevice;
239239
}
240+
241+
bool SystemWrapper::isRunning()
242+
{
243+
if (_grabber != NULL)
244+
{
245+
return _grabber->isRunning();
246+
}
247+
248+
return false;
249+
}

Diff for: sources/grabber/pipewire/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ add_library(smartPipewire SHARED ${SMARTPIPEWIRE_SOURCES} )
88
set_target_properties(smartPipewire PROPERTIES VERSION 1)
99

1010
# Pipewire
11-
target_include_directories(smartPipewire PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${PIPEWIRE_INCLUDE_DIRS} )
11+
target_include_directories(smartPipewire PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${PIPEWIRE_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} ${OPENGL_EGL_INCLUDE_DIRS} )
1212
target_link_libraries(smartPipewire PUBLIC ${PIPEWIRE_LIBRARIES} Qt${Qt_VERSION}::Core Qt${Qt_VERSION}::DBus )
1313

1414
# Grabber

0 commit comments

Comments
 (0)