Windows: Add a DDA grabber for much better performance (#1745)

* Add a DXDI DDA grabber

* Change all names to camel case

* Handle cropping and pixel decimation

* Try more persistently to restart capture after an error occurred.

These can happen when changing resolution, or resuming from sleep.
This commit is contained in:
David Sansome
2024-05-30 21:39:46 +10:00
committed by GitHub
parent c0ddca3c5b
commit 8c303c8b9c
16 changed files with 535 additions and 9 deletions

View File

@@ -0,0 +1,75 @@
#pragma once
#include <QObject>
#include <QJsonObject>
#include <hyperion/Grabber.h>
#include <utils/ColorRgb.h>
class DDAGrabberImpl;
class DDAGrabber : public Grabber
{
public:
DDAGrabber(int display = 0, int cropLeft = 0, int cropRight = 0, int cropTop = 0, int cropBottom = 0);
virtual ~DDAGrabber();
///
/// Captures a single snapshot of the display and writes the data to the given image. The
/// provided image should have the same dimensions as the configured values (_width and _height)
///
/// @param[out] image The snapped screenshot
///
int grabFrame(Image<ColorRgb> &image);
///
/// @brief Set a new video mode
///
void setVideoMode(VideoMode mode) override;
///
/// @brief Apply new width/height values, overwrite Grabber.h implementation
///
bool setWidthHeight(int /* width */, int /*height*/) override
{
return true;
}
///
/// @brief Apply new pixelDecimation
///
bool setPixelDecimation(int pixelDecimation) override;
///
/// Set the crop values
/// @param cropLeft Left pixel crop
/// @param cropRight Right pixel crop
/// @param cropTop Top pixel crop
/// @param cropBottom Bottom pixel crop
///
void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
///
/// @brief Apply display index
///
bool setDisplayIndex(int index) override;
/// @brief Discover QT screens available (for configuration).
///
/// @param[in] params Parameters used to overwrite discovery default behaviour
///
/// @return A JSON structure holding a list of devices found
///
QJsonObject discover(const QJsonObject &params);
private:
///
/// @brief Setup a new capture display, will free the previous one
/// @return True on success, false if no display is found
///
bool restartCapture();
private:
std::unique_ptr<DDAGrabberImpl> d;
};

View File

@@ -0,0 +1,24 @@
#pragma once
#include <grabber/dda/DDAGrabber.h>
#include <hyperion/GrabberWrapper.h>
class DDAWrapper : public GrabberWrapper
{
public:
static constexpr const char *GRABBERTYPE = "DDA";
DDAWrapper(int updateRate_Hz = GrabberWrapper::DEFAULT_RATE_HZ, int display = 0,
int pixelDecimation = GrabberWrapper::DEFAULT_PIXELDECIMATION, int cropLeft = 0, int cropRight = 0,
int cropTop = 0, int cropBottom = 0);
DDAWrapper(const QJsonDocument &grabberConfig = QJsonDocument());
virtual ~DDAWrapper(){};
public slots:
virtual void action();
private:
DDAGrabber _grabber;
};