From 2ff3c1155b97e1d4079b69ab10ce97c139af3025 Mon Sep 17 00:00:00 2001 From: Lord-Grey Date: Sun, 7 Feb 2021 11:12:28 +0100 Subject: [PATCH] Have fps as int, fix height typo --- include/grabber/MFGrabber.h | 2 +- include/grabber/V4L2Grabber.h | 2 +- include/hyperion/Grabber.h | 2 +- include/hyperion/GrabberWrapper.h | 2 +- include/utils/global_defines.h | 2 ++ libsrc/api/JsonAPI.cpp | 4 ++-- libsrc/grabber/mediafoundation/MFGrabber.cpp | 8 ++++---- libsrc/grabber/v4l2/V4L2Grabber.cpp | 8 ++++---- libsrc/hyperion/GrabberWrapper.cpp | 4 ++-- 9 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/grabber/MFGrabber.h b/include/grabber/MFGrabber.h index 68cc7823..b39d3f82 100644 --- a/include/grabber/MFGrabber.h +++ b/include/grabber/MFGrabber.h @@ -64,7 +64,7 @@ public: QMultiMap getDeviceInputs(const QString& devicePath) const override { return {{ devicePath, 0}}; } QStringList getAvailableEncodingFormats(const QString& devicePath, const int& /*deviceInput*/) const override; QMultiMap getAvailableDeviceResolutions(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat) const override; - QStringList getAvailableDeviceFramerates(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat, const unsigned width, const unsigned height) const override; + QIntList getAvailableDeviceFramerates(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat, const unsigned width, const unsigned height) const override; void setSignalThreshold(double redSignalThreshold, double greenSignalThreshold, double blueSignalThreshold, int noSignalCounterThreshold) override; void setSignalDetectionOffset( double verticalMin, double horizontalMin, double verticalMax, double horizontalMax) override; void setSignalDetectionEnable(bool enable) override; diff --git a/include/grabber/V4L2Grabber.h b/include/grabber/V4L2Grabber.h index 7dc61b92..a726a1d3 100644 --- a/include/grabber/V4L2Grabber.h +++ b/include/grabber/V4L2Grabber.h @@ -155,7 +155,7 @@ public: /// /// @brief overwrite Grabber.h implementation /// - QStringList getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const override; + QIntList getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const override; public slots: diff --git a/include/hyperion/Grabber.h b/include/hyperion/Grabber.h index 90937297..d7e64a0b 100644 --- a/include/hyperion/Grabber.h +++ b/include/hyperion/Grabber.h @@ -171,7 +171,7 @@ public: /// @param heigth The device heigth /// @return List of framerates on success else empty List /// - virtual QStringList getAvailableDeviceFramerates(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/, const unsigned /*width*/, const unsigned /*height*/) const { return QStringList(); } + virtual QIntList getAvailableDeviceFramerates(const QString& /*devicePath*/, const int& /*deviceInput*/, const PixelFormat& /*encFormat*/, const unsigned /*width*/, const unsigned /*height*/) const { return QIntList(); } protected: ImageResampler _imageResampler; diff --git a/include/hyperion/GrabberWrapper.h b/include/hyperion/GrabberWrapper.h index 5120ce0a..25f64fcd 100644 --- a/include/hyperion/GrabberWrapper.h +++ b/include/hyperion/GrabberWrapper.h @@ -103,7 +103,7 @@ public: /// @param heigth The device heigth /// @return List of framerates on success else empty List /// - virtual QStringList getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const; + virtual QIntList getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const; /// /// @brief Get active grabber name diff --git a/include/utils/global_defines.h b/include/utils/global_defines.h index eb75d339..e5a6808e 100644 --- a/include/utils/global_defines.h +++ b/include/utils/global_defines.h @@ -1,4 +1,6 @@ #pragma once #define QSTRING_CSTR(str) str.toLocal8Bit().constData() +typedef QList< int > QIntList; + diff --git a/libsrc/api/JsonAPI.cpp b/libsrc/api/JsonAPI.cpp index 7e824650..2f864171 100644 --- a/libsrc/api/JsonAPI.cpp +++ b/libsrc/api/JsonAPI.cpp @@ -521,10 +521,10 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString { QJsonObject resolution; resolution["width"] = width_height.key(); - resolution["heigth"] = width_height.value(); + resolution["height"] = width_height.value(); QJsonArray fps; - QStringList framerates = GrabberWrapper::getInstance()->getAvailableDeviceFramerates(devicePath, input.value(), parsePixelFormat(encodingFormat), width_height.key(), width_height.value()); + QIntList framerates = GrabberWrapper::getInstance()->getAvailableDeviceFramerates(devicePath, input.value(), parsePixelFormat(encodingFormat), width_height.key(), width_height.value()); for (auto framerate : framerates) { fps.append(framerate); diff --git a/libsrc/grabber/mediafoundation/MFGrabber.cpp b/libsrc/grabber/mediafoundation/MFGrabber.cpp index 40ce2c2f..b49f8d75 100644 --- a/libsrc/grabber/mediafoundation/MFGrabber.cpp +++ b/libsrc/grabber/mediafoundation/MFGrabber.cpp @@ -718,14 +718,14 @@ QMultiMap MFGrabber::getAvailableDeviceResolutions(const QString& devi return result; } -QStringList MFGrabber::getAvailableDeviceFramerates(const QString& devicePath, const int& /*device input not used on windows*/, const PixelFormat& encFormat, const unsigned width, const unsigned height) const +QIntList MFGrabber::getAvailableDeviceFramerates(const QString& devicePath, const int& /*device input not used on windows*/, const PixelFormat& encFormat, const unsigned width, const unsigned height) const { - QStringList result = QStringList(); + QIntList result = QIntList(); for(int i = 0; i < _deviceProperties[devicePath].count(); ++i ) { - QString fps = QString::number(_deviceProperties[devicePath][i].numerator / _deviceProperties[devicePath][i].denominator); - if(!result.contains(fps, Qt::CaseInsensitive) && _deviceProperties[devicePath][i].pf == encFormat && _deviceProperties[devicePath][i].width == width && _deviceProperties[devicePath][i].height == height) + int fps = _deviceProperties[devicePath][i].numerator / _deviceProperties[devicePath][i].denominator; + if(!result.contains(fps) && _deviceProperties[devicePath][i].pf == encFormat && _deviceProperties[devicePath][i].width == width && _deviceProperties[devicePath][i].height == height) result << fps; } diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index 2b8009e1..d19e6fac 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -1467,9 +1467,9 @@ QMultiMap V4L2Grabber::getAvailableDeviceResolutions(const QString& de return result; } -QStringList V4L2Grabber::getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const +QIntList V4L2Grabber::getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const { - QStringList result = QStringList(); + QIntList result = QIntList(); for(auto it = _deviceProperties.begin(); it != _deviceProperties.end(); ++it) if (it.key() == devicePath) @@ -1478,8 +1478,8 @@ QStringList V4L2Grabber::getAvailableDeviceFramerates(const QString& devicePath, for (auto enc = input.value().encodingFormats.begin(); enc != input.value().encodingFormats.end(); enc++) if(enc.key() == encFormat && enc.value().width == width && enc.value().height == height) for (auto fps = enc.value().framerates.begin(); fps != enc.value().framerates.end(); fps++) - if(!result.contains(QString::number(*fps))) - result << QString::number(*fps); + if(!result.contains(*fps)) + result << *fps; return result; } diff --git a/libsrc/hyperion/GrabberWrapper.cpp b/libsrc/hyperion/GrabberWrapper.cpp index b95a891d..54cf1007 100644 --- a/libsrc/hyperion/GrabberWrapper.cpp +++ b/libsrc/hyperion/GrabberWrapper.cpp @@ -262,10 +262,10 @@ QMultiMap GrabberWrapper::getAvailableDeviceResolutions(const QString& return QMultiMap(); } -QStringList GrabberWrapper::getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const +QIntList GrabberWrapper::getAvailableDeviceFramerates(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat, const unsigned width, const unsigned height) const { if(_grabberName.startsWith("V4L")) return _ggrabber->getAvailableDeviceFramerates(devicePath, deviceInput, encFormat, width, height); - return QStringList(); + return QIntList(); }