Added video standards to JsonAPI output

This commit is contained in:
Paulchen-Panther 2021-02-07 14:30:36 +01:00
parent 2ff3c1155b
commit 4f81fbd2ab
8 changed files with 95 additions and 8 deletions

View File

@ -61,7 +61,7 @@ public:
bool getCecDetectionEnabled() const { return _cecDetectionEnabled; } bool getCecDetectionEnabled() const { return _cecDetectionEnabled; }
QStringList getDevices() const override; QStringList getDevices() const override;
QString getDeviceName(const QString& devicePath) const override { return devicePath; } QString getDeviceName(const QString& devicePath) const override { return devicePath; }
QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const override { return {{ devicePath, 0}}; } QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const override { return { {devicePath, 0} }; }
QStringList getAvailableEncodingFormats(const QString& devicePath, const int& /*deviceInput*/) const override; QStringList getAvailableEncodingFormats(const QString& devicePath, const int& /*deviceInput*/) const override;
QMultiMap<int, int> getAvailableDeviceResolutions(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat) const override; QMultiMap<int, int> getAvailableDeviceResolutions(const QString& devicePath, const int& /*deviceInput*/, const PixelFormat& encFormat) const override;
QIntList 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;

View File

@ -14,7 +14,7 @@
// util includes // util includes
#include <utils/PixelFormat.h> #include <utils/PixelFormat.h>
#include <hyperion/Grabber.h> #include <hyperion/Grabber.h>
#include <grabber/VideoStandard.h> #include <utils/VideoStandard.h>
#include <utils/Components.h> #include <utils/Components.h>
#include <cec/CECEvent.h> #include <cec/CECEvent.h>
@ -50,6 +50,7 @@ public:
struct InputProperties struct InputProperties
{ {
QString inputName = QString(); QString inputName = QString();
QList<VideoStandard> standards = QList<VideoStandard>();
struct EncodingProperties struct EncodingProperties
{ {
unsigned int width = 0; unsigned int width = 0;
@ -142,6 +143,11 @@ public:
/// ///
QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const override; QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const override;
///
/// @brief overwrite Grabber.h implementation
///
QList<VideoStandard> getAvailableDeviceStandards(const QString& devicePath, const int& deviceInput) const override;
/// ///
/// @brief overwrite Grabber.h implementation /// @brief overwrite Grabber.h implementation
/// ///

View File

@ -6,7 +6,7 @@
#include <utils/ColorRgb.h> #include <utils/ColorRgb.h>
#include <utils/Image.h> #include <utils/Image.h>
#include <utils/VideoMode.h> #include <utils/VideoMode.h>
#include <grabber/VideoStandard.h> #include <utils/VideoStandard.h>
#include <utils/ImageResampler.h> #include <utils/ImageResampler.h>
#include <utils/Logger.h> #include <utils/Logger.h>
#include <utils/Components.h> #include <utils/Components.h>
@ -145,6 +145,14 @@ public:
/// ///
virtual QMultiMap<QString, int> getDeviceInputs(const QString& /*devicePath*/) const { return QMultiMap<QString, int>(); } virtual QMultiMap<QString, int> getDeviceInputs(const QString& /*devicePath*/) const { return QMultiMap<QString, int>(); }
///
/// @brief Get a list of available device video standards depends on device input
/// @param devicePath The device path
/// @param inputIndex The device input index
/// @return List of video standards on success else empty List
///
virtual QList<VideoStandard> getAvailableDeviceStandards(const QString& /*devicePath*/, const int& /*deviceInput*/) const { return QList<VideoStandard>(); }
/// ///
/// @brief Get a list of all available device encoding formats depends on device input /// @brief Get a list of all available device encoding formats depends on device input
/// @param devicePath The device path /// @param devicePath The device path

View File

@ -14,6 +14,7 @@
#include <utils/VideoMode.h> #include <utils/VideoMode.h>
#include <utils/PixelFormat.h> #include <utils/PixelFormat.h>
#include <utils/settings.h> #include <utils/settings.h>
#include <utils/VideoStandard.h>
class Grabber; class Grabber;
class GlobalSignals; class GlobalSignals;
@ -77,6 +78,14 @@ public:
/// ///
virtual QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const; virtual QMultiMap<QString, int> getDeviceInputs(const QString& devicePath) const;
///
/// @brief Get a list of available device video standards depends on device input
/// @param devicePath The device path
/// @param inputIndex The device input index
/// @return List of video standards on success else empty List
///
virtual QList<VideoStandard> getAvailableDeviceStandards(const QString& devicePath, const int& deviceInput) const;
/// ///
/// @brief Get a list of all available device encoding formats depends on device input /// @brief Get a list of all available device encoding formats depends on device input
/// @param devicePath The device path /// @param devicePath The device path
@ -95,7 +104,7 @@ public:
virtual QMultiMap<int, int> getAvailableDeviceResolutions(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat) const; virtual QMultiMap<int, int> getAvailableDeviceResolutions(const QString& devicePath, const int& deviceInput, const PixelFormat& encFormat) const;
/// ///
/// @brief Get a list of available device framerates depends on encoding format and resolution /// @brief Get a list of available device framerates depends on device input, encoding format and resolution
/// @param devicePath The device path /// @param devicePath The device path
/// @param inputIndex The device input index /// @param inputIndex The device input index
/// @param encFormat The device encoding format /// @param encFormat The device encoding format

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <QString>
/** /**
* Enumeration of the possible video standards the grabber can be set to * Enumeration of the possible video standards the grabber can be set to
*/ */
@ -13,17 +15,17 @@ enum class VideoStandard {
inline VideoStandard parseVideoStandard(const QString& videoStandard) inline VideoStandard parseVideoStandard(const QString& videoStandard)
{ {
// convert to lower case // convert to lower case
QString standard = videoStandard.toLower(); QString standard = videoStandard.toUpper();
if (standard == "pal") if (standard == "PAL")
{ {
return VideoStandard::PAL; return VideoStandard::PAL;
} }
else if (standard == "ntsc") else if (standard == "NTSC")
{ {
return VideoStandard::NTSC; return VideoStandard::NTSC;
} }
else if (standard == "secam") else if (standard == "SECAM")
{ {
return VideoStandard::SECAM; return VideoStandard::SECAM;
} }
@ -31,3 +33,14 @@ inline VideoStandard parseVideoStandard(const QString& videoStandard)
// return the default NO_CHANGE // return the default NO_CHANGE
return VideoStandard::NO_CHANGE; return VideoStandard::NO_CHANGE;
} }
inline QString VideoStandard2String(VideoStandard videoStandard)
{
switch (videoStandard)
{
case VideoStandard::PAL: return "PAL";
case VideoStandard::NTSC: return "NTSC";
case VideoStandard::SECAM: return "SECAM";
default: return "NO_CHANGE";
}
}

View File

@ -508,6 +508,13 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
in["name"] = input.key(); in["name"] = input.key();
in["inputIdx"] = input.value(); in["inputIdx"] = input.value();
QJsonArray standards;
QList<VideoStandard> videoStandards = GrabberWrapper::getInstance()->getAvailableDeviceStandards(devicePath, input.value());
for (auto standard : videoStandards)
{
standards.append(VideoStandard2String(standard));
}
QJsonArray formats; QJsonArray formats;
QStringList encodingFormats = GrabberWrapper::getInstance()->getAvailableEncodingFormats(devicePath, input.value()); QStringList encodingFormats = GrabberWrapper::getInstance()->getAvailableEncodingFormats(devicePath, input.value());
for (auto encodingFormat : encodingFormats) for (auto encodingFormat : encodingFormats)
@ -538,6 +545,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject &message, const QString
formats.append(format); formats.append(format);
} }
in["standards"] = standards;
in["formats"] = formats; in["formats"] = formats;
video_inputs.append(in); video_inputs.append(in);
} }

View File

@ -232,6 +232,26 @@ void V4L2Grabber::getV4Ldevices()
V4L2Grabber::DeviceProperties::InputProperties inputProperties; V4L2Grabber::DeviceProperties::InputProperties inputProperties;
inputProperties.inputName = QString((char*)input.name); inputProperties.inputName = QString((char*)input.name);
// Enumerate video standards
struct v4l2_standard standard;
CLEAR(standard);
standard.index = 0;
while (xioctl(fd, VIDIOC_ENUMSTD, &standard) >= 0)
{
if (standard.id & input.std)
{
if (standard.id == V4L2_STD_PAL)
inputProperties.standards.append(VideoStandard::PAL);
else if (standard.id == V4L2_STD_NTSC)
inputProperties.standards.append(VideoStandard::NTSC);
else if (standard.id == V4L2_STD_SECAM)
inputProperties.standards.append(VideoStandard::SECAM);
}
standard.index++;
}
// Enumerate pixel formats // Enumerate pixel formats
struct v4l2_fmtdesc desc; struct v4l2_fmtdesc desc;
CLEAR(desc); CLEAR(desc);
@ -1437,6 +1457,21 @@ QMultiMap<QString, int> V4L2Grabber::getDeviceInputs(const QString& devicePath)
return result; return result;
} }
QList<VideoStandard> V4L2Grabber::getAvailableDeviceStandards(const QString& devicePath, const int& deviceInput) const
{
QList<VideoStandard> result =QList<VideoStandard>();
for(auto it = _deviceProperties.begin(); it != _deviceProperties.end(); ++it)
if (it.key() == devicePath)
for (auto input = it.value().inputs.begin(); input != it.value().inputs.end(); input++)
if (input.key() == deviceInput)
for (auto standard = input.value().standards.begin(); standard != input.value().standards.end(); standard++)
if(!result.contains(*standard))
result << *standard;
return result;
}
QStringList V4L2Grabber::getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const QStringList V4L2Grabber::getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const
{ {
QStringList result = QStringList(); QStringList result = QStringList();

View File

@ -246,6 +246,14 @@ QMultiMap<QString, int> GrabberWrapper::getDeviceInputs(const QString& devicePat
return QMultiMap<QString, int>(); return QMultiMap<QString, int>();
} }
QList<VideoStandard> GrabberWrapper::getAvailableDeviceStandards(const QString& devicePath, const int& deviceInput) const
{
if(_grabberName.startsWith("V4L"))
return _ggrabber->getAvailableDeviceStandards(devicePath, deviceInput);
return QList<VideoStandard>();
}
QStringList GrabberWrapper::getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const QStringList GrabberWrapper::getAvailableEncodingFormats(const QString& devicePath, const int& deviceInput) const
{ {
if(_grabberName.startsWith("V4L")) if(_grabberName.startsWith("V4L"))