mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
migrate std::string to qstring + add sysinfo via json (#412)
* std::string -> qstring part 1 * more string migration * more string migration ... * ... * more qstring mogrations add sysinfo via json * remove unneccessary includes * integrate sysinfo into webui
This commit is contained in:
@@ -69,13 +69,13 @@ void AmlogicGrabber::setVideoMode(const VideoMode videoMode)
|
||||
|
||||
bool AmlogicGrabber::isVideoPlaying()
|
||||
{
|
||||
const std::string videoDevice = "/dev/amvideo";
|
||||
const QString videoDevice = "/dev/amvideo";
|
||||
|
||||
// Open the video device
|
||||
int video_fd = open(videoDevice.c_str(), O_RDONLY);
|
||||
int video_fd = open(QSTRING_CSTR(videoDevice), O_RDONLY);
|
||||
if (video_fd < 0)
|
||||
{
|
||||
Error(_log, "Failed to open video device(%s): %d - %s", videoDevice.c_str(), errno, strerror(errno));
|
||||
Error(_log, "Failed to open video device(%s): %d - %s", QSTRING_CSTR(videoDevice), errno, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,7 @@
|
||||
// Local includes
|
||||
#include <grabber/FramebufferFrameGrabber.h>
|
||||
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const std::string & device, const unsigned width, const unsigned height) :
|
||||
FramebufferFrameGrabber::FramebufferFrameGrabber(const QString & device, const unsigned width, const unsigned height) :
|
||||
_fbfd(0),
|
||||
_fbp(0),
|
||||
_fbDevice(device),
|
||||
@@ -25,10 +25,10 @@ FramebufferFrameGrabber::FramebufferFrameGrabber(const std::string & device, con
|
||||
struct fb_var_screeninfo vinfo;
|
||||
|
||||
// Check if the framebuffer device can be opened and display the current resolution
|
||||
_fbfd = open(_fbDevice.c_str(), O_RDONLY);
|
||||
_fbfd = open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
if (_fbfd == 0)
|
||||
{
|
||||
Error(_log, "Error openning %s", _fbDevice.c_str());
|
||||
Error(_log, "Error openning %s", QSTRING_CSTR(_fbDevice));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -63,7 +63,7 @@ void FramebufferFrameGrabber::grabFrame(Image<ColorRgb> & image)
|
||||
PixelFormat pixelFormat;
|
||||
|
||||
/* Open the framebuffer device */
|
||||
_fbfd = open(_fbDevice.c_str(), O_RDONLY);
|
||||
_fbfd = open(QSTRING_CSTR(_fbDevice), O_RDONLY);
|
||||
|
||||
/* get variable screen information */
|
||||
ioctl (_fbfd, FBIOGET_VSCREENINFO, &vinfo);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
#include <grabber/FramebufferWrapper.h>
|
||||
#include <grabber/FramebufferFrameGrabber.h>
|
||||
|
||||
FramebufferWrapper::FramebufferWrapper(const std::string & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
|
||||
FramebufferWrapper::FramebufferWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
|
||||
: GrabberWrapper("FrameBuffer", priority)
|
||||
, _updateInterval_ms(1000/updateRate_Hz)
|
||||
, _timeout_ms(2 * _updateInterval_ms)
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#define CLEAR(x) memset(&(x), 0, sizeof(x))
|
||||
|
||||
V4L2Grabber::V4L2Grabber(const std::string & device
|
||||
V4L2Grabber::V4L2Grabber(const QString & device
|
||||
, int input
|
||||
, VideoStandard videoStandard
|
||||
, PixelFormat pixelFormat
|
||||
@@ -51,7 +51,7 @@ V4L2Grabber::V4L2Grabber(const std::string & device
|
||||
, _noSignalCounter(0)
|
||||
, _streamNotifier(nullptr)
|
||||
, _imageResampler()
|
||||
, _log(Logger::getInstance("V4L2:"+QString::fromStdString(device)))
|
||||
, _log(Logger::getInstance("V4L2:"+device))
|
||||
, _initialized(false)
|
||||
, _deviceAutoDiscoverEnabled(false)
|
||||
, _noSignalDetected(false)
|
||||
@@ -74,7 +74,7 @@ V4L2Grabber::~V4L2Grabber()
|
||||
|
||||
void V4L2Grabber::uninit()
|
||||
{
|
||||
Debug(_log,"uninit grabber: %s", _deviceName.c_str());
|
||||
Debug(_log,"uninit grabber: %s", QSTRING_CSTR(_deviceName));
|
||||
// stop if the grabber was not stopped
|
||||
if (_initialized)
|
||||
{
|
||||
@@ -91,16 +91,16 @@ bool V4L2Grabber::init()
|
||||
if (! _initialized)
|
||||
{
|
||||
getV4Ldevices();
|
||||
std::string v4lDevices_str;
|
||||
QString v4lDevices_str;
|
||||
|
||||
// show list only once
|
||||
if ( ! QString(_deviceName.c_str()).startsWith("/dev/") )
|
||||
if ( ! QString(QSTRING_CSTR(_deviceName)).startsWith("/dev/") )
|
||||
{
|
||||
for (auto& dev: _v4lDevices)
|
||||
{
|
||||
v4lDevices_str += "\t"+ dev.first + "\t" + dev.second + "\n";
|
||||
}
|
||||
Info(_log, "available V4L2 devices:\n%s", v4lDevices_str.c_str());
|
||||
Info(_log, "available V4L2 devices:\n%s", QSTRING_CSTR(v4lDevices_str));
|
||||
}
|
||||
|
||||
if ( _deviceName == "auto" )
|
||||
@@ -113,28 +113,28 @@ bool V4L2Grabber::init()
|
||||
_deviceName = dev.first;
|
||||
if ( init() )
|
||||
{
|
||||
Info(_log, "found usable v4l2 device: %s (%s)",dev.first.c_str(), dev.second.c_str());
|
||||
Info(_log, "found usable v4l2 device: %s (%s)",QSTRING_CSTR(dev.first), QSTRING_CSTR(dev.second));
|
||||
_deviceAutoDiscoverEnabled = false;
|
||||
return _initialized;
|
||||
}
|
||||
}
|
||||
Info( _log, "no usable device found" );
|
||||
}
|
||||
else if ( ! QString(_deviceName.c_str()).startsWith("/dev/") )
|
||||
else if ( ! _deviceName.startsWith("/dev/") )
|
||||
{
|
||||
for (auto& dev: _v4lDevices)
|
||||
{
|
||||
if ( QString(_deviceName.c_str()).toLower() == QString(dev.second.c_str()).toLower() )
|
||||
if ( _deviceName.toLower() == dev.second.toLower() )
|
||||
{
|
||||
_deviceName = dev.first;
|
||||
Info(_log, "found v4l2 device with configured name: %s (%s)", dev.second.c_str(), dev.first.c_str() );
|
||||
Info(_log, "found v4l2 device with configured name: %s (%s)", QSTRING_CSTR(dev.second), QSTRING_CSTR(dev.first) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info(_log, "%s v4l device: %s", (_deviceAutoDiscoverEnabled? "test" : "configured"),_deviceName.c_str());
|
||||
Info(_log, "%s v4l device: %s", (_deviceAutoDiscoverEnabled? "test" : "configured"), QSTRING_CSTR(_deviceName));
|
||||
}
|
||||
|
||||
bool opened = false;
|
||||
@@ -177,7 +177,7 @@ void V4L2Grabber::getV4Ldevices()
|
||||
devName = devName.trimmed();
|
||||
devNameFile.close();
|
||||
}
|
||||
_v4lDevices.emplace("/dev/"+it.fileName().toStdString(), devName.toStdString());
|
||||
_v4lDevices.emplace("/dev/"+it.fileName(), devName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,14 +194,12 @@ void V4L2Grabber::set3D(VideoMode mode)
|
||||
|
||||
void V4L2Grabber::setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold)
|
||||
{
|
||||
_noSignalThresholdColor.red = uint8_t(255*redSignalThreshold);
|
||||
_noSignalThresholdColor.red = uint8_t(255*redSignalThreshold);
|
||||
_noSignalThresholdColor.green = uint8_t(255*greenSignalThreshold);
|
||||
_noSignalThresholdColor.blue = uint8_t(255*blueSignalThreshold);
|
||||
_noSignalCounterThreshold = std::max(1, noSignalCounterThreshold);
|
||||
_noSignalThresholdColor.blue = uint8_t(255*blueSignalThreshold);
|
||||
_noSignalCounterThreshold = std::max(1, noSignalCounterThreshold);
|
||||
|
||||
std::stringstream ss;
|
||||
ss << _noSignalThresholdColor;
|
||||
Info(_log, "Signal threshold set to: %s", ss.str().c_str() );
|
||||
Info(_log, "Signal threshold set to: {%d, %d, %d}", _noSignalThresholdColor.red, _noSignalThresholdColor.green, _noSignalThresholdColor.blue );
|
||||
}
|
||||
|
||||
void V4L2Grabber::setSignalDetectionOffset(double horizontalMin, double verticalMin, double horizontalMax, double verticalMax)
|
||||
@@ -256,7 +254,7 @@ void V4L2Grabber::open_device()
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (-1 == stat(_deviceName.c_str(), &st))
|
||||
if (-1 == stat(QSTRING_CSTR(_deviceName), &st))
|
||||
{
|
||||
throw_errno_exception("Cannot identify '" + _deviceName + "'");
|
||||
}
|
||||
@@ -266,7 +264,7 @@ void V4L2Grabber::open_device()
|
||||
throw_exception("'" + _deviceName + "' is no device");
|
||||
}
|
||||
|
||||
_fileDescriptor = open(_deviceName.c_str(), O_RDWR /* required */ | O_NONBLOCK, 0);
|
||||
_fileDescriptor = open(QSTRING_CSTR(_deviceName), O_RDWR | O_NONBLOCK, 0);
|
||||
|
||||
if (-1 == _fileDescriptor)
|
||||
{
|
||||
@@ -870,14 +868,12 @@ int V4L2Grabber::xioctl(int request, void *arg)
|
||||
return r;
|
||||
}
|
||||
|
||||
void V4L2Grabber::throw_exception(const std::string & error)
|
||||
void V4L2Grabber::throw_exception(const QString & error)
|
||||
{
|
||||
throw std::runtime_error(error);
|
||||
throw std::runtime_error(error.toStdString());
|
||||
}
|
||||
|
||||
void V4L2Grabber::throw_errno_exception(const std::string & error)
|
||||
void V4L2Grabber::throw_errno_exception(const QString & error)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss << error << " error code " << errno << ", " << strerror(errno);
|
||||
throw std::runtime_error(oss.str());
|
||||
throw std::runtime_error(QString(error + " error code " + QString::number(errno) + ", " + strerror(errno)).toStdString());
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <hyperion/ImageProcessorFactory.h>
|
||||
|
||||
V4L2Wrapper::V4L2Wrapper(const std::string &device,
|
||||
V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
int input,
|
||||
VideoStandard videoStandard,
|
||||
PixelFormat pixelFormat,
|
||||
@@ -16,7 +16,7 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
|
||||
double greenSignalThreshold,
|
||||
double blueSignalThreshold,
|
||||
const int priority)
|
||||
: GrabberWrapper("V4L2:"+QString::fromStdString(device), priority, hyperion::COMP_V4L)
|
||||
: GrabberWrapper("V4L2:"+device, priority, hyperion::COMP_V4L)
|
||||
, _timeout_ms(1000)
|
||||
, _grabber(device,
|
||||
input,
|
||||
|
Reference in New Issue
Block a user