mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Media Foundation/V4L2 grabber ... (#1119)
* - New Media Foundation grabber
- JsonAPI available grabber fix
- commented json config removed
* Added libjpeg-turbo to dependencies
* Fix OSX build
Removed Azure Pipelines from build scripts
* Remove Platform from Dashboard
* Correct Grabber Namings
* Grabber UI improvements, generic JSONEditor Selection Update
* Active grabber fix
* Stop Framebuffer grabber on failure
* - Image format NV12 and I420 added
- Flip mode
- Scaling factor for MJPEG
- VSCode (compile before run)
- CI (push) dependency libjpeg-turbo added
* Refactor MediaFoundation (Part 1)
* Remove QDebug output
* Added image flipping ability to MF Grabber
* fix issue 1160
* -Reload MF Grabber only once per WebUI update
- Cleanup
* Improvements
* - Set 'Software Frame Decimation' begin to 0
- Removed grabber specific device name from Log
- Keep pixel format when switching resolution
- Display 'Flip mode' correct in Log
- BGR24 images always flipped
* Refactor MediaFoundation (Part 2)
* Refactor V4L2 grabber (part 1) (#62)
* Media Foundation grabber adapted to V4L2 change
* Enable Media Foundation grabber on windows
* Have fps as int, fix height typo
* Added video standards to JsonAPI output
* Error handling in source reader improved
* Fix "Frame to small" error
* Discovery VideoSources and Dynamically Update Editor
* Hide all element when no video grabber discovered, upate naming
* Do not show unsupported grabbers
* Copy Log to Clipboard
* Update Grabber schema and Defaults
* Update access levels and validate crop ranges
* Height and width in Qt grabber corrected
* Correct formatting
* Untabify
* Global component states across instances
* Components divided on the dashboard
* refactor
* Fix Merge-issues
* Database migration aligning with updated grabber model
* Align Grabber.js with new utility functions
* Allow editor-validation for enum-lists
* Handle "Show Explainations scenario" correctly
* Grabber - Ensure save is only possible on valid content
* Dashboard update + fix GlobalSignal connection
* Ensure default database is populated with current release
* Correct grabber4L2 access level
* Display Signal detection area in preview
* Write Hyperion version into default config on compiling.
* Create defaultconfig.json dynamically
* WebUI changes
* Correct grabber config look-ups
* Refactor i18n language loading
* Fix en.json
* Split global capture from instance capture config
* Update grabber default values
* Standalone grabber: Add --debug switch
* Enhance showInputOptionsForKey for multiple keys
* Add grabber instance link to system grabber config
* Only show signal detection area, if grabber is enabled
* Always show Active element on grabber page
* Remote control - Only display gabber status, if global grabber is enabled
* WebUI optimization (thx to @mkcologne)
Start Grabber only when global settings are enabled
Fixed an issue in the WebUI preview
* V4L2/MF changes
* Jsoneditor, Correct translation for default values
* Refactor LED-Device handling in UI and make element naming consistent
* MF Discovery extended
* Fix LGTM finding
* Support Grabber Bri, Hue, Sat and Con in UI, plus their defaults
* Concider Access level for item filtering
* Concider Access level for item filtering
* Revert "Concider Access level for item filtering"
This reverts commit 5b0ce3c0f2
.
* Disable fpsSoftwareDecimation for framegrabber, as not supported yet
* JSON-Editor- Add updated schema for validation on dynamic elements
* added V4L2 color IDs
* LGTM findings fix
* destroy SR callback only on exit
* Grabber.js - Hide elements not supported by platform
* Fixed freezing start effect
* Grabber UI - Hardware controls - Show current values and allow to reset to defaults
* Grabber - Discovery - Add current values to properties
* Small things
* Clean-up Effects and have ENDLESS consistently defined
* Fix on/off/on priority during startup, by initializing _prevVisComp in line with background priority
* Add missing translation mappings
* DirectX Grabber reactivated/ QT Grabber size decimation fixed
* typo in push-master workflow
* Use PreciseTimer for Grabber to ensure stable FPS timing
* Set default Screencapture rate consistently
* Fix libjpeg-turbo download
* Remove Zero character from file
* docker-compile Add PLATFORM parameter, only copy output file after successful compile
* Framebuffer, Dispmanx, OSX, AML Grabber discovery, various clean-up and consistencies across grabbers
* Fix merge problem - on docker-compile Add PLATFORM parameter, only copy output file after successful compile
* Fix definition
* OSXFRameGrabber - Revert cast
* Clean-ups nach Feedback
* Disable certain libraries when building armlogic via standard stretch image as developer
* Add CEC availability to ServerInfo to have it platform independent
* Grabber UI - Fix problem that crop values are not populated when refining editor rage
* Preserve value when updating json-editor range
* LEDVisualisation - Clear image when source changes
* Fix - Preserve value when updating json-editor range
* LEDVisualisation - Clear image when no component is active
* Allow to have password handled by Password-Manager (#1263)
* Update default signal detection area to green assuming rainbow grabber
* LED Visualisation - Handle empty priority update
* Fix yuv420 in v4l2 grabber
* V4L2-Grabber discovery - Only report grabbers with valid video input information
* Grabber - Update static variables to have them working in release build
* LED Visualisation - ClearImage when no priorities
* LED Visualisation - Fix Logo resizing issue
* LED Visualisation - Have nearly black background and negative logo
Co-authored-by: LordGrey <lordgrey.emmel@gmail.com>
Co-authored-by: LordGrey <48840279+Lord-Grey@users.noreply.github.com>
This commit is contained in:
@@ -4,21 +4,33 @@
|
||||
#include <xcb/randr.h>
|
||||
#include <xcb/xcb_event.h>
|
||||
|
||||
X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation)
|
||||
: Grabber("X11GRABBER", 0, 0, cropLeft, cropRight, cropTop, cropBottom)
|
||||
// Constants
|
||||
namespace {
|
||||
const bool verbose = false;
|
||||
} //End of constants
|
||||
|
||||
X11Grabber::X11Grabber(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: Grabber("X11GRABBER", cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _x11Display(nullptr)
|
||||
, _xImage(nullptr)
|
||||
, _pixmap(None)
|
||||
, _srcFormat(nullptr)
|
||||
, _dstFormat(nullptr)
|
||||
, _srcPicture(None)
|
||||
, _dstPicture(None)
|
||||
, _pixelDecimation(pixelDecimation)
|
||||
, _screenWidth(0)
|
||||
, _screenHeight(0)
|
||||
, _calculatedWidth(0)
|
||||
, _calculatedHeight(0)
|
||||
, _src_x(cropLeft)
|
||||
, _src_y(cropTop)
|
||||
, _XShmAvailable(false)
|
||||
, _XRenderAvailable(false)
|
||||
, _XRandRAvailable(false)
|
||||
, _isWayland (false)
|
||||
, _logger{}
|
||||
, _image(0,0)
|
||||
{
|
||||
_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));
|
||||
@@ -37,7 +49,10 @@ X11Grabber::~X11Grabber()
|
||||
void X11Grabber::freeResources()
|
||||
{
|
||||
// Cleanup allocated resources of the X11 grab
|
||||
XDestroyImage(_xImage);
|
||||
if (_xImage != nullptr)
|
||||
{
|
||||
XDestroyImage(_xImage);
|
||||
}
|
||||
if (_XRandRAvailable)
|
||||
{
|
||||
qApp->removeNativeEventFilter(this);
|
||||
@@ -65,7 +80,7 @@ void X11Grabber::setupResources()
|
||||
|
||||
if(_XShmAvailable)
|
||||
{
|
||||
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _windowAttr.depth, ZPixmap, NULL, &_shminfo, _width, _height);
|
||||
_xImage = XShmCreateImage(_x11Display, _windowAttr.visual, _windowAttr.depth, ZPixmap, NULL, &_shminfo, _calculatedWidth, _calculatedHeight);
|
||||
_shminfo.shmid = shmget(IPC_PRIVATE, (size_t) _xImage->bytes_per_line * _xImage->height, IPC_CREAT|0777);
|
||||
_xImage->data = (char*)shmat(_shminfo.shmid,0,0);
|
||||
_shminfo.shmaddr = _xImage->data;
|
||||
@@ -75,17 +90,17 @@ void X11Grabber::setupResources()
|
||||
|
||||
if (_XRenderAvailable)
|
||||
{
|
||||
_useImageResampler = false;
|
||||
_useImageResampler = false;
|
||||
_imageResampler.setHorizontalPixelDecimation(1);
|
||||
_imageResampler.setVerticalPixelDecimation(1);
|
||||
|
||||
if(_XShmPixmapAvailable)
|
||||
{
|
||||
_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _width, _height, _windowAttr.depth);
|
||||
_pixmap = XShmCreatePixmap(_x11Display, _window, _xImage->data, &_shminfo, _calculatedWidth, _calculatedHeight, _windowAttr.depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
_pixmap = XCreatePixmap(_x11Display, _window, _width, _height, _windowAttr.depth);
|
||||
_pixmap = XCreatePixmap(_x11Display, _window, _calculatedWidth, _calculatedHeight, _windowAttr.depth);
|
||||
}
|
||||
_srcFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
|
||||
_dstFormat = XRenderFindVisualFormat(_x11Display, _windowAttr.visual);
|
||||
@@ -96,49 +111,82 @@ void X11Grabber::setupResources()
|
||||
}
|
||||
else
|
||||
{
|
||||
_useImageResampler = true;
|
||||
_useImageResampler = true;
|
||||
_imageResampler.setHorizontalPixelDecimation(_pixelDecimation);
|
||||
_imageResampler.setVerticalPixelDecimation(_pixelDecimation);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool X11Grabber::Setup()
|
||||
bool X11Grabber::open()
|
||||
{
|
||||
_x11Display = XOpenDisplay(NULL);
|
||||
if (_x11Display == nullptr)
|
||||
bool rc = false;
|
||||
|
||||
if (getenv("WAYLAND_DISPLAY") != nullptr)
|
||||
{
|
||||
Error(_log, "Unable to open display");
|
||||
if (getenv("DISPLAY"))
|
||||
_isWayland = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
_x11Display = XOpenDisplay(nullptr);
|
||||
if (_x11Display != nullptr)
|
||||
{
|
||||
Error(_log, "%s",getenv("DISPLAY"));
|
||||
rc = true;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
bool X11Grabber::setupDisplay()
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
if ( ! open() )
|
||||
{
|
||||
if ( _isWayland )
|
||||
{
|
||||
Error(_log, "Grabber does not work under Wayland!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log, "DISPLAY environment variable not set");
|
||||
if (getenv("DISPLAY") != nullptr)
|
||||
{
|
||||
Error(_log, "Unable to open display [%s]",getenv("DISPLAY"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Error(_log, "DISPLAY environment variable not set");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_window = DefaultRootWindow(_x11Display);
|
||||
|
||||
_window = DefaultRootWindow(_x11Display);
|
||||
int dummy, pixmaps_supported;
|
||||
|
||||
int dummy, pixmaps_supported;
|
||||
_XRandRAvailable = XRRQueryExtension(_x11Display, &_XRandREventBase, &dummy);
|
||||
_XRenderAvailable = XRenderQueryExtension(_x11Display, &dummy, &dummy);
|
||||
_XShmAvailable = XShmQueryExtension(_x11Display);
|
||||
XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported);
|
||||
_XShmPixmapAvailable = pixmaps_supported && XShmPixmapFormat(_x11Display) == ZPixmap;
|
||||
|
||||
_XRandRAvailable = XRRQueryExtension(_x11Display, &_XRandREventBase, &dummy);
|
||||
_XRenderAvailable = XRenderQueryExtension(_x11Display, &dummy, &dummy);
|
||||
_XShmAvailable = XShmQueryExtension(_x11Display);
|
||||
XShmQueryVersion(_x11Display, &dummy, &dummy, &pixmaps_supported);
|
||||
_XShmPixmapAvailable = pixmaps_supported && XShmPixmapFormat(_x11Display) == ZPixmap;
|
||||
Info(_log, QString("XRandR=[%1] XRender=[%2] XShm=[%3] XPixmap=[%4]")
|
||||
.arg(_XRandRAvailable ? "available" : "unavailable")
|
||||
.arg(_XRenderAvailable ? "available" : "unavailable")
|
||||
.arg(_XShmAvailable ? "available" : "unavailable")
|
||||
.arg(_XShmPixmapAvailable ? "available" : "unavailable")
|
||||
.toStdString().c_str());
|
||||
|
||||
bool result = (updateScreenDimensions(true) >=0);
|
||||
ErrorIf(!result, _log, "X11 Grabber start failed");
|
||||
setEnabled(result);
|
||||
result = (updateScreenDimensions(true) >=0);
|
||||
ErrorIf(!result, _log, "X11 Grabber start failed");
|
||||
setEnabled(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int X11Grabber::grabFrame(Image<ColorRgb> & image, bool forceUpdate)
|
||||
{
|
||||
if (!_enabled) return 0;
|
||||
if (!_isEnabled) return 0;
|
||||
|
||||
if (forceUpdate)
|
||||
updateScreenDimensions(forceUpdate);
|
||||
@@ -176,7 +224,7 @@ int X11Grabber::grabFrame(Image<ColorRgb> & image, bool forceUpdate)
|
||||
// src_y = cropTop, mask_x, mask_y, dest_x, dest_y, width, height
|
||||
XRenderComposite(
|
||||
_x11Display, PictOpSrc, _srcPicture, None, _dstPicture, ( _src_x/_pixelDecimation),
|
||||
(_src_y/_pixelDecimation), 0, 0, 0, 0, _width, _height);
|
||||
(_src_y/_pixelDecimation), 0, 0, 0, 0, _calculatedWidth, _calculatedHeight);
|
||||
|
||||
XSync(_x11Display, False);
|
||||
|
||||
@@ -186,7 +234,7 @@ int X11Grabber::grabFrame(Image<ColorRgb> & image, bool forceUpdate)
|
||||
}
|
||||
else
|
||||
{
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _width, _height, AllPlanes, ZPixmap);
|
||||
_xImage = XGetImage(_x11Display, _pixmap, 0, 0, _calculatedWidth, _calculatedHeight, AllPlanes, ZPixmap);
|
||||
}
|
||||
}
|
||||
else if (_XShmAvailable)
|
||||
@@ -197,7 +245,7 @@ int X11Grabber::grabFrame(Image<ColorRgb> & image, bool forceUpdate)
|
||||
else
|
||||
{
|
||||
// all things done by xgetimage
|
||||
_xImage = XGetImage(_x11Display, _window, _src_x, _src_y, _width, _height, AllPlanes, ZPixmap);
|
||||
_xImage = XGetImage(_x11Display, _window, _src_x, _src_y, _calculatedWidth, _calculatedHeight, AllPlanes, ZPixmap);
|
||||
}
|
||||
|
||||
if (_xImage == nullptr)
|
||||
@@ -220,45 +268,46 @@ int X11Grabber::updateScreenDimensions(bool force)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!force && _screenWidth == unsigned(_windowAttr.width) && _screenHeight == unsigned(_windowAttr.height))
|
||||
if (!force && _width == _windowAttr.width && _height == _windowAttr.height)
|
||||
{
|
||||
// No update required
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_screenWidth || _screenHeight)
|
||||
if (_width || _height)
|
||||
{
|
||||
freeResources();
|
||||
}
|
||||
|
||||
Info(_log, "Update of screen resolution: [%dx%d] to [%dx%d]", _screenWidth, _screenHeight, _windowAttr.width, _windowAttr.height);
|
||||
_screenWidth = _windowAttr.width;
|
||||
_screenHeight = _windowAttr.height;
|
||||
Info(_log, "Update of screen resolution: [%dx%d] to [%dx%d]", _width, _height, _windowAttr.width, _windowAttr.height);
|
||||
_width = _windowAttr.width;
|
||||
_height = _windowAttr.height;
|
||||
|
||||
int width=0, height=0;
|
||||
int width=0;
|
||||
int height=0;
|
||||
|
||||
// Image scaling is performed by XRender when available, otherwise by ImageResampler
|
||||
if (_XRenderAvailable)
|
||||
{
|
||||
width = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? ((_screenWidth - _cropLeft - _cropRight) / _pixelDecimation)
|
||||
: _screenWidth / _pixelDecimation;
|
||||
width = (_width > (_cropLeft + _cropRight))
|
||||
? ((_width - _cropLeft - _cropRight) / _pixelDecimation)
|
||||
: _width / _pixelDecimation;
|
||||
|
||||
height = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? ((_screenHeight - _cropTop - _cropBottom) / _pixelDecimation)
|
||||
: _screenHeight / _pixelDecimation;
|
||||
height = (_height > (_cropTop + _cropBottom))
|
||||
? ((_height - _cropTop - _cropBottom) / _pixelDecimation)
|
||||
: _height / _pixelDecimation;
|
||||
|
||||
Info(_log, "Using XRender for grabbing");
|
||||
}
|
||||
else
|
||||
{
|
||||
width = (_screenWidth > unsigned(_cropLeft + _cropRight))
|
||||
? (_screenWidth - _cropLeft - _cropRight)
|
||||
: _screenWidth;
|
||||
width = (_width > (_cropLeft + _cropRight))
|
||||
? (_width - _cropLeft - _cropRight)
|
||||
: _width;
|
||||
|
||||
height = (_screenHeight > unsigned(_cropTop + _cropBottom))
|
||||
? (_screenHeight - _cropTop - _cropBottom)
|
||||
: _screenHeight;
|
||||
height = (_height > (_cropTop + _cropBottom))
|
||||
? (_height - _cropTop - _cropBottom)
|
||||
: _height;
|
||||
|
||||
Info(_log, "Using XGetImage for grabbing");
|
||||
}
|
||||
@@ -267,29 +316,29 @@ int X11Grabber::updateScreenDimensions(bool force)
|
||||
switch (_videoMode)
|
||||
{
|
||||
case VideoMode::VIDEO_3DSBS:
|
||||
_width = width /2;
|
||||
_height = height;
|
||||
_calculatedWidth = width /2;
|
||||
_calculatedHeight = height;
|
||||
_src_x = _cropLeft / 2;
|
||||
_src_y = _cropTop;
|
||||
break;
|
||||
case VideoMode::VIDEO_3DTAB:
|
||||
_width = width;
|
||||
_height = height / 2;
|
||||
_calculatedWidth = width;
|
||||
_calculatedHeight = height / 2;
|
||||
_src_x = _cropLeft;
|
||||
_src_y = _cropTop / 2;
|
||||
break;
|
||||
case VideoMode::VIDEO_2D:
|
||||
default:
|
||||
_width = width;
|
||||
_height = height;
|
||||
_calculatedWidth = width;
|
||||
_calculatedHeight = height;
|
||||
_src_x = _cropLeft;
|
||||
_src_y = _cropTop;
|
||||
break;
|
||||
}
|
||||
|
||||
Info(_log, "Update output image resolution: [%dx%d] to [%dx%d]", _image.width(), _image.height(), _width, _height);
|
||||
Info(_log, "Update output image resolution: [%dx%d] to [%dx%d]", _image.width(), _image.height(), _calculatedWidth, _calculatedHeight);
|
||||
|
||||
_image.resize(_width, _height);
|
||||
_image.resize(_calculatedWidth, _calculatedHeight);
|
||||
setupResources();
|
||||
|
||||
return 1;
|
||||
@@ -298,22 +347,35 @@ int X11Grabber::updateScreenDimensions(bool force)
|
||||
void X11Grabber::setVideoMode(VideoMode mode)
|
||||
{
|
||||
Grabber::setVideoMode(mode);
|
||||
updateScreenDimensions(true);
|
||||
}
|
||||
|
||||
void X11Grabber::setPixelDecimation(int pixelDecimation)
|
||||
{
|
||||
if(_pixelDecimation != pixelDecimation)
|
||||
if(_x11Display != nullptr)
|
||||
{
|
||||
_pixelDecimation = pixelDecimation;
|
||||
updateScreenDimensions(true);
|
||||
}
|
||||
}
|
||||
|
||||
void X11Grabber::setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom)
|
||||
bool X11Grabber::setPixelDecimation(int pixelDecimation)
|
||||
{
|
||||
bool rc (true);
|
||||
if (Grabber::setPixelDecimation(pixelDecimation))
|
||||
{
|
||||
if(_x11Display != nullptr)
|
||||
{
|
||||
if ( updateScreenDimensions(true) < 0 )
|
||||
{
|
||||
rc = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
void X11Grabber::setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
{
|
||||
Grabber::setCropping(cropLeft, cropRight, cropTop, cropBottom);
|
||||
if(_x11Display != nullptr) updateScreenDimensions(true); // segfault on init
|
||||
if(_x11Display != nullptr)
|
||||
{
|
||||
updateScreenDimensions(true); // segfault on init
|
||||
}
|
||||
}
|
||||
|
||||
bool X11Grabber::nativeEventFilter(const QByteArray & eventType, void * message, long int * /*result*/)
|
||||
@@ -332,3 +394,78 @@ bool X11Grabber::nativeEventFilter(const QByteArray & eventType, void * message,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QJsonObject X11Grabber::discover(const QJsonObject& params)
|
||||
{
|
||||
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());
|
||||
|
||||
QJsonObject inputsDiscovered;
|
||||
if ( open() )
|
||||
{
|
||||
inputsDiscovered["device"] = "x11";
|
||||
inputsDiscovered["device_name"] = "X11";
|
||||
inputsDiscovered["type"] = "screen";
|
||||
|
||||
QJsonArray video_inputs;
|
||||
|
||||
if (_x11Display != nullptr)
|
||||
{
|
||||
QJsonArray fps = { 1, 5, 10, 15, 20, 25, 30, 40, 50, 60 };
|
||||
|
||||
// Iterate through all X screens
|
||||
for (int i = 0; i < XScreenCount(_x11Display); ++i)
|
||||
{
|
||||
_window = DefaultRootWindow(_x11Display);
|
||||
|
||||
const Status status = XGetWindowAttributes(_x11Display, _window, &_windowAttr);
|
||||
if (status == 0)
|
||||
{
|
||||
Debug(_log, "Failed to obtain window attributes");
|
||||
}
|
||||
else
|
||||
{
|
||||
QJsonObject in;
|
||||
|
||||
QString displayName;
|
||||
char* name;
|
||||
if ( XFetchName(_x11Display, _window, &name) > 0 )
|
||||
{
|
||||
displayName = name;
|
||||
}
|
||||
else {
|
||||
displayName = QString("Display:%1").arg(i);
|
||||
}
|
||||
|
||||
in["name"] = displayName;
|
||||
in["inputIdx"] = i;
|
||||
|
||||
QJsonArray formats;
|
||||
QJsonArray resolutionArray;
|
||||
QJsonObject format;
|
||||
QJsonObject resolution;
|
||||
|
||||
resolution["width"] = _windowAttr.width;
|
||||
resolution["height"] = _windowAttr.height;
|
||||
resolution["fps"] = fps;
|
||||
|
||||
resolutionArray.append(resolution);
|
||||
|
||||
format["resolutions"] = resolutionArray;
|
||||
formats.append(format);
|
||||
|
||||
in["formats"] = formats;
|
||||
video_inputs.append(in);
|
||||
}
|
||||
}
|
||||
|
||||
if ( !video_inputs.isEmpty() )
|
||||
{
|
||||
inputsDiscovered["video_inputs"] = video_inputs;
|
||||
}
|
||||
}
|
||||
}
|
||||
DebugIf(verbose, _log, "device: [%s]", QString(QJsonDocument(inputsDiscovered).toJson(QJsonDocument::Compact)).toUtf8().constData());
|
||||
|
||||
return inputsDiscovered;
|
||||
}
|
||||
|
||||
|
@@ -1,10 +1,14 @@
|
||||
#include <grabber/X11Wrapper.h>
|
||||
|
||||
X11Wrapper::X11Wrapper(int cropLeft, int cropRight, int cropTop, int cropBottom, int pixelDecimation, unsigned updateRate_Hz)
|
||||
: GrabberWrapper("X11", &_grabber, 0, 0, updateRate_Hz)
|
||||
, _grabber(cropLeft, cropRight, cropTop, cropBottom, pixelDecimation)
|
||||
, _init(false)
|
||||
{}
|
||||
X11Wrapper::X11Wrapper( int updateRate_Hz,
|
||||
int pixelDecimation,
|
||||
int cropLeft, int cropRight, int cropTop, int cropBottom)
|
||||
: GrabberWrapper("X11", &_grabber, updateRate_Hz)
|
||||
, _grabber(cropLeft, cropRight, cropTop, cropBottom)
|
||||
, _init(false)
|
||||
{
|
||||
_grabber.setPixelDecimation(pixelDecimation);
|
||||
}
|
||||
|
||||
X11Wrapper::~X11Wrapper()
|
||||
{
|
||||
@@ -19,7 +23,7 @@ void X11Wrapper::action()
|
||||
if (! _init )
|
||||
{
|
||||
_init = true;
|
||||
if ( ! _grabber.Setup() )
|
||||
if ( ! _grabber.setupDisplay() )
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
Reference in New Issue
Block a user