6#include <QtCore/QSettings>
7#include <QtCore/QVariantList>
11#ifdef QGC_GST_STREAMING
22 QVariantList videoSourceList;
23 videoSourceList.append(videoSourceRTSP);
24 videoSourceList.append(videoSourceUDPH264);
25 videoSourceList.append(videoSourceUDPH265);
26 videoSourceList.append(videoSourceTCP);
27 videoSourceList.append(videoSourceMPEGTS);
28 videoSourceList.append(videoSource3DRSolo);
29 videoSourceList.append(videoSourceParrotDiscovery);
30 videoSourceList.append(videoSourceYuneecMantisG);
32#ifdef QGC_HERELINK_AIRUNIT_VIDEO
33 videoSourceList.append(videoSourceHerelinkAirUnit);
35 videoSourceList.append(videoSourceHerelinkHotspot);
38 for (
const QString& device : uvcDevices) {
39 videoSourceList.append(device);
41 if (videoSourceList.count() == 0) {
43 videoSourceList.append(videoSourceNoVideo);
44 setUserVisible(
false);
46 videoSourceList.insert(0, videoDisabled);
50 QStringList videoSourceCookedList;
51 for (
const QVariant& videoSource: videoSourceList) {
52 videoSourceCookedList.append( VideoSettings::tr(videoSource.toString().toStdString().c_str()) );
55 _nameToMetaDataMap[videoSourceName]->setEnumInfo(videoSourceCookedList, videoSourceList);
57 _setForceVideoDecodeList();
62 settings.beginGroup(settingsGroup);
63 const bool hasLegacy = settings.contains(QStringLiteral(
"gpuZeroCopyEnabled"));
64 const bool hasNew = settings.contains(forceCpuVideoPathName);
67 const bool gpuZeroCopy = settings.value(QStringLiteral(
"gpuZeroCopyEnabled")).toBool();
68 forceCpuVideoPath()->setRawValue(!gpuZeroCopy);
70 settings.remove(QStringLiteral(
"gpuZeroCopyEnabled"));
79void VideoSettings::_setDefaults()
100 if (!_videoSourceFact) {
101 _videoSourceFact = _createSettingsFact(videoSourceName);
103 if(!_videoSourceFact->enumValues().contains(_videoSourceFact->rawValue().toString())) {
105 _videoSourceFact->setRawValue(videoSourceNoVideo);
107 _videoSourceFact->setRawValue(videoDisabled);
112 return _videoSourceFact;
117 if (!_forceVideoDecoderFact) {
118 _forceVideoDecoderFact = _createSettingsFact(forceVideoDecoderName);
120 _forceVideoDecoderFact->setUserVisible(
kGstEnabled);
122 connect(_forceVideoDecoderFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
124 return _forceVideoDecoderFact;
129 if (!_lowLatencyModeFact) {
130 _lowLatencyModeFact = _createSettingsFact(lowLatencyModeName);
134 connect(_lowLatencyModeFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
136 return _lowLatencyModeFact;
141 if (!_rtpJitterLatencyMsFact) {
142 _rtpJitterLatencyMsFact = _createSettingsFact(rtpJitterLatencyMsName);
143 _rtpJitterLatencyMsFact->setUserVisible(
kGstEnabled);
144 connect(_rtpJitterLatencyMsFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
146 return _rtpJitterLatencyMsFact;
151 if (!_rtspAutoReconnectFact) {
152 _rtspAutoReconnectFact = _createSettingsFact(rtspAutoReconnectName);
153 _rtspAutoReconnectFact->setUserVisible(
kGstEnabled);
154 connect(_rtspAutoReconnectFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
156 return _rtspAutoReconnectFact;
161 if (!_forceCpuVideoPathFact) {
162 _forceCpuVideoPathFact = _createSettingsFact(forceCpuVideoPathName);
164#if defined(QGC_HAS_ANY_GPU_PATH)
165 _forceCpuVideoPathFact->setUserVisible(
kGstEnabled);
167 _forceCpuVideoPathFact->setUserVisible(
false);
170 return _forceCpuVideoPathFact;
177 if (!_videoConversionElementFact) {
178 _videoConversionElementFact = _createSettingsFact(videoConversionElementName);
179 _videoConversionElementFact->setUserVisible(
kGstEnabled);
181 return _videoConversionElementFact;
186 if (!_disablePixelAspectRatioFact) {
187 _disablePixelAspectRatioFact = _createSettingsFact(disablePixelAspectRatioName);
188 _disablePixelAspectRatioFact->setUserVisible(
kGstEnabled);
190 return _disablePixelAspectRatioFact;
196 if (!_rtspTimeoutFact) {
197 _rtspTimeoutFact = _createSettingsFact(rtspTimeoutName);
203 return _rtspTimeoutFact;
209 _udpUrlFact = _createSettingsFact(udpUrlName);
218 _rtspUrlFact = _createSettingsFact(rtspUrlName);
227 _tcpUrlFact = _createSettingsFact(tcpUrlName);
237 qCDebug(VideoSettingsLog) <<
"Stream auto configured";
241 QString vSource = videoSource()->rawValue().toString();
247 const QString url = udpUrl()->rawValue().toString();
248 qCDebug(VideoSettingsLog) <<
"Testing configuration for UDP Stream:"
250 return !url.isEmpty();
254 const QString url = rtspUrl()->rawValue().toString();
255 qCDebug(VideoSettingsLog) <<
"Testing configuration for RTSP Stream:"
257 return !url.isEmpty();
261 const QString url = tcpUrl()->rawValue().toString();
262 qCDebug(VideoSettingsLog) <<
"Testing configuration for TCP Stream:"
264 return !url.isEmpty();
268 const QString url = udpUrl()->rawValue().toString();
269 qCDebug(VideoSettingsLog) <<
"Testing configuration for MPEG-TS Stream:"
271 return !url.isEmpty();
275 qCDebug(VideoSettingsLog) <<
"Stream configured for Herelink Air Unit";
280 qCDebug(VideoSettingsLog) <<
"Stream configured for Herelink Hotspot";
284 qCDebug(VideoSettingsLog) <<
"Stream configured for UVC";
290void VideoSettings::_configChanged(QVariant)
295void VideoSettings::_setForceVideoDecodeList()
297#ifdef QGC_GST_STREAMING
298 static const QList<GStreamer::VideoDecoderOptions> removeForceVideoDecodeList{
299#if defined(Q_OS_ANDROID)
305#elif defined(Q_OS_LINUX)
308#elif defined(Q_OS_WIN)
311#elif defined(Q_OS_MACOS)
314#elif defined(Q_OS_IOS)
322 for (
const auto &value : removeForceVideoDecodeList) {
330#ifdef QGC_GST_STREAMING
331 static const QList<GStreamer::VideoDecoderOptions> hardwareFamilies{
347 for (
const auto family : hardwareFamilies) {
350 const QVariant familyValue =
static_cast<int>(family);
351 if (!available.contains(family) && metaData->
enumValues().contains(familyValue)) {
357 Fact*
const fact = forceVideoDecoder();
#define QGC_LOGGING_CATEGORY(name, categoryStr)
#define DECLARE_SETTINGSFACT_NO_FUNC(CLASS, NAME)
#define DECLARE_SETTINGSFACT(CLASS, NAME)
#define DECLARE_SETTINGGROUP(NAME, GROUP)
static constexpr bool kGstEnabled
A Fact is used to hold a single value within the system.
void setRawValue(const QVariant &value)
QVariant rawValue() const
void valueChanged(const QVariant &value)
This signal is only meant for use by the QT property system. It should not be connected to by client ...
QMap< QString, FactMetaData * > _nameToMetaDataMap
static bool deviceExists(const QString &device)
static QStringList getDeviceNameList()
static VideoManager * instance()
static constexpr const char * videoSourceTCP
static constexpr const char * videoSourceUDPH264
static constexpr const char * videoSourceHerelinkHotspot
static constexpr const char * videoSourceRTSP
static constexpr const char * videoDisabled
void pruneUnavailableDecoders()
static constexpr const char * videoSourceUDPH265
void streamConfiguredChanged(bool configured)
static constexpr const char * videoSourceNoVideo
static constexpr const char * videoSourceMPEGTS
static constexpr const char * videoSourceHerelinkAirUnit
QList< VideoDecoderOptions > availableDecoderFamilies()
@ ForceVideoDecoderDefault
@ ForceVideoDecoderVulkan
@ ForceVideoDecoderNVIDIA
@ ForceVideoDecoderVideoToolbox
@ ForceVideoDecoderDirectX3D
QString redactedUrlForLogging(const QUrl &url)