LordGrey 31df065c0f
Start SmartPointers (#1679)
* Refactor to fix #1671

* Add GUI/NonGUI mode to info page

* Do not show lock config, if in non-UI mode

* Updae Changelog

* Correct includes

* Ensure key member initialization - RGB Channels

* Ensure key member initialization - WebServer

* Update RGBChannels

* Fix initialization order

* Fix key when inserting new logger in LoggerMap,
Prepare logBuffer-JSON snapshot view in LoggerManager,
Increase buffered loglines to 500

* Fix Memory leak in GrabberWrapper

* Fix Memory leak in BlackBorderProcessor

* Fix Memory leak in BlackBorderProcessor

* use ninja generator under macos

* Fix BGEffectHandler destruction

* Fix Mdns code

* Clear list after applying qDeleteAll

* Fix deletion of CecHandler

* Fix memory leak caused by wrong buffer allocation

* Remove extra pixel consistently

* Change mDNS to Qt SmartPointers

* Correct removal

* Fix usage of _width/_height (they are the output resolution, not the screen resolution)
That avoids unnecessary resizing of the output image with every transferFrame call

* Move main non Thread Objects to Smart Pointers

* Refactor Hyperion Daemon unsing smartpointers

* Correction

* Correct typos/ align text

* Fix startGrabberDispmanx

* Fix startGrabberDispmanx

* Address CodeQL finding

* Create Screen grabbers via Template

* Fix typo

* Change way of logging

* Revert change

* Address deprecation warning

* Correct auto screen grabber evaluation

---------

Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2024-02-25 17:35:39 +01:00

190 lines
4.0 KiB
C++

#pragma once
#include <QObject>
#include <cstdint>
#include <utils/ColorRgb.h>
#include <utils/Image.h>
#include <utils/VideoMode.h>
#include <utils/VideoStandard.h>
#include <utils/ImageResampler.h>
#include <utils/Logger.h>
#include <utils/Components.h>
#include <events/EventEnum.h>
///
/// @brief The Grabber class is responsible to apply image resizes (with or without ImageResampler)
class Grabber : public QObject
{
Q_OBJECT
public:
Grabber(const QString& grabberName = "", int cropLeft=0, int cropRight=0, int cropTop=0, int cropBottom=0);
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
virtual void setVideoMode(VideoMode mode);
///
/// Apply new flip mode (vertical/horizontal/both)
/// @param[in] mode The new flip mode
///
virtual void setFlipMode(FlipMode mode);
///
/// @brief Apply new crop values, on errors reject the values
///
virtual void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
///
/// @brief Apply new video input (used from v4l2/MediaFoundation)
/// @param input device input
///
virtual bool setInput(int input);
///
/// @brief Apply new width/height values, on errors (collide with cropping) reject the values
/// @return True on success else false
///
virtual bool setWidthHeight(int width, int height);
///
/// @brief Apply new capture framerate in Hz
/// @param fps framesPerSecond
///
virtual bool setFramerate(int fps);
///
/// @brief Apply new framerate software decimation (used from v4l2/MediaFoundation)
/// @param decimation how many frames per second to omit
///
virtual void setFpsSoftwareDecimation(int decimation);
///
/// @brief Apply videoStandard (used from v4l2)
///
virtual void setVideoStandard(VideoStandard videoStandard);
///
/// @brief Apply new pixelDecimation
///
virtual bool setPixelDecimation(int pixelDecimation);
///
/// @brief Apply display index (used from qt)
///
virtual bool setDisplayIndex(int /*index*/) { return true; }
///
/// @brief Prevent the real capture implementation from capturing if disabled
///
virtual void setEnabled(bool enable);
///
/// @brief get current resulting height of image (after crop)
///
int getImageWidth() const { return _width; }
///
/// @brief get current resulting width of image (after crop)
///
int getImageHeight() const { return _height; }
///
/// @brief Get current capture framerate in Hz
/// @param fps framesPerSecond
///
int getFramerate() const { return _fps; }
///
/// @brief Get capture interval in ms
///
int getUpdateInterval() const { return 1000/_fps; }
///
/// @brief Get pixelDecimation
///
int getPixelDecimation() const { return _pixelDecimation; }
QString getGrabberName() const { return _grabberName; }
///
/// @brief Determine if the grabber is available.
///
/// @return true, on success (i.e. library is present), else false
///
virtual bool isAvailable() { return _isAvailable; }
public slots:
virtual void handleEvent(Event event) {}
protected slots:
///
/// @brief Set device in error state
///
/// @param[in] errorMsg The error message to be logged
///
virtual void setInError( const QString& errorMsg);
protected:
QString _grabberName;
/// logger instance
Logger * _log;
ImageResampler _imageResampler;
bool _useImageResampler;
/// the selected VideoMode
VideoMode _videoMode;
/// the used video standard
VideoStandard _videoStandard;
/// Image size decimation
int _pixelDecimation;
/// the used Flip Mode
FlipMode _flipMode;
/// With of the captured snapshot [pixels]
int _width;
/// Height of the captured snapshot [pixels]
int _height;
/// frame per second
int _fps;
/// fps software decimation
int _fpsSoftwareDecimation;
/// device input
int _input;
/// number of pixels to crop after capturing
int _cropLeft, _cropRight, _cropTop, _cropBottom;
// Device states
/// Is the device available?
bool _isAvailable;
/// Is the device enabled?
bool _isEnabled;
/// Is the device in error state and stopped?
bool _isDeviceInError;
};