5#include <QtCore/QSettings>
6#include <QtCore/QVariantList>
10#ifdef QGC_GST_STREAMING
21 QVariantList videoSourceList;
22 videoSourceList.append(videoSourceRTSP);
23 videoSourceList.append(videoSourceUDPH264);
24 videoSourceList.append(videoSourceUDPH265);
25 videoSourceList.append(videoSourceTCP);
26 videoSourceList.append(videoSourceMPEGTS);
27 videoSourceList.append(videoSource3DRSolo);
28 videoSourceList.append(videoSourceParrotDiscovery);
29 videoSourceList.append(videoSourceYuneecMantisG);
31#ifdef QGC_HERELINK_AIRUNIT_VIDEO
32 videoSourceList.append(videoSourceHerelinkAirUnit);
34 videoSourceList.append(videoSourceHerelinkHotspot);
37 for (
const QString& device : uvcDevices) {
38 videoSourceList.append(device);
40 if (videoSourceList.count() == 0) {
42 videoSourceList.append(videoSourceNoVideo);
43 setUserVisible(
false);
45 videoSourceList.insert(0, videoDisabled);
49 QStringList videoSourceCookedList;
50 for (
const QVariant& videoSource: videoSourceList) {
51 videoSourceCookedList.append( VideoSettings::tr(videoSource.toString().toStdString().c_str()) );
54 _nameToMetaDataMap[videoSourceName]->setEnumInfo(videoSourceCookedList, videoSourceList);
56 _setForceVideoDecodeList();
61 settings.beginGroup(settingsGroup);
62 const bool hasLegacy = settings.contains(QStringLiteral(
"gpuZeroCopyEnabled"));
63 const bool hasNew = settings.contains(forceCpuVideoPathName);
66 const bool gpuZeroCopy = settings.value(QStringLiteral(
"gpuZeroCopyEnabled")).toBool();
67 forceCpuVideoPath()->setRawValue(!gpuZeroCopy);
69 settings.remove(QStringLiteral(
"gpuZeroCopyEnabled"));
78void VideoSettings::_setDefaults()
99 if (!_videoSourceFact) {
100 _videoSourceFact = _createSettingsFact(videoSourceName);
102 if(!_videoSourceFact->enumValues().contains(_videoSourceFact->rawValue().toString())) {
104 _videoSourceFact->setRawValue(videoSourceNoVideo);
106 _videoSourceFact->setRawValue(videoDisabled);
111 return _videoSourceFact;
116 if (!_forceVideoDecoderFact) {
117 _forceVideoDecoderFact = _createSettingsFact(forceVideoDecoderName);
119 _forceVideoDecoderFact->setUserVisible(
kGstEnabled);
121 connect(_forceVideoDecoderFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
123 return _forceVideoDecoderFact;
128 if (!_lowLatencyModeFact) {
129 _lowLatencyModeFact = _createSettingsFact(lowLatencyModeName);
133 connect(_lowLatencyModeFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
135 return _lowLatencyModeFact;
140 if (!_rtpJitterLatencyMsFact) {
141 _rtpJitterLatencyMsFact = _createSettingsFact(rtpJitterLatencyMsName);
142 _rtpJitterLatencyMsFact->setUserVisible(
kGstEnabled);
143 connect(_rtpJitterLatencyMsFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
145 return _rtpJitterLatencyMsFact;
150 if (!_rtspAutoReconnectFact) {
151 _rtspAutoReconnectFact = _createSettingsFact(rtspAutoReconnectName);
152 _rtspAutoReconnectFact->setUserVisible(
kGstEnabled);
153 connect(_rtspAutoReconnectFact, &
Fact::valueChanged,
this, &VideoSettings::_configChanged);
155 return _rtspAutoReconnectFact;
160 if (!_forceCpuVideoPathFact) {
161 _forceCpuVideoPathFact = _createSettingsFact(forceCpuVideoPathName);
163#if defined(QGC_HAS_ANY_GPU_PATH)
164 _forceCpuVideoPathFact->setUserVisible(
kGstEnabled);
166 _forceCpuVideoPathFact->setUserVisible(
false);
169 return _forceCpuVideoPathFact;
176 if (!_videoConversionElementFact) {
177 _videoConversionElementFact = _createSettingsFact(videoConversionElementName);
178 _videoConversionElementFact->setUserVisible(
kGstEnabled);
180 return _videoConversionElementFact;
185 if (!_disablePixelAspectRatioFact) {
186 _disablePixelAspectRatioFact = _createSettingsFact(disablePixelAspectRatioName);
187 _disablePixelAspectRatioFact->setUserVisible(
kGstEnabled);
189 return _disablePixelAspectRatioFact;
195 if (!_rtspTimeoutFact) {
196 _rtspTimeoutFact = _createSettingsFact(rtspTimeoutName);
202 return _rtspTimeoutFact;
208 _udpUrlFact = _createSettingsFact(udpUrlName);
217 _rtspUrlFact = _createSettingsFact(rtspUrlName);
226 _tcpUrlFact = _createSettingsFact(tcpUrlName);
236 qCDebug(VideoSettingsLog) <<
"Stream auto configured";
240 QString vSource = videoSource()->rawValue().toString();
246 qCDebug(VideoSettingsLog) <<
"Testing configuration for UDP Stream:" << udpUrl()->rawValue().toString();
247 return !udpUrl()->rawValue().toString().isEmpty();
251 qCDebug(VideoSettingsLog) <<
"Testing configuration for RTSP Stream:" << rtspUrl()->rawValue().toString();
252 return !rtspUrl()->rawValue().toString().isEmpty();
256 qCDebug(VideoSettingsLog) <<
"Testing configuration for TCP Stream:" << tcpUrl()->rawValue().toString();
257 return !tcpUrl()->rawValue().toString().isEmpty();
261 qCDebug(VideoSettingsLog) <<
"Testing configuration for MPEG-TS Stream:" << udpUrl()->rawValue().toString();
262 return !udpUrl()->rawValue().toString().isEmpty();
266 qCDebug(VideoSettingsLog) <<
"Stream configured for Herelink Air Unit";
271 qCDebug(VideoSettingsLog) <<
"Stream configured for Herelink Hotspot";
275 qCDebug(VideoSettingsLog) <<
"Stream configured for UVC";
281void VideoSettings::_configChanged(QVariant)
286void VideoSettings::_setForceVideoDecodeList()
288#ifdef QGC_GST_STREAMING
289 static const QList<GStreamer::VideoDecoderOptions> removeForceVideoDecodeList{
290#if defined(Q_OS_ANDROID)
296#elif defined(Q_OS_LINUX)
299#elif defined(Q_OS_WIN)
302#elif defined(Q_OS_MACOS)
305#elif defined(Q_OS_IOS)
313 for (
const auto &value : removeForceVideoDecodeList) {
321#ifdef QGC_GST_STREAMING
322 static const QList<GStreamer::VideoDecoderOptions> hardwareFamilies{
338 for (
const auto family : hardwareFamilies) {
341 const QVariant familyValue =
static_cast<int>(family);
342 if (!available.contains(family) && metaData->
enumValues().contains(familyValue)) {
348 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
Value after translation.
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