QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
VideoSettings.cc
Go to the documentation of this file.
1#include "VideoSettings.h"
2#include "VideoManager.h"
3
4#include <QtCore/QVariantList>
5
6#ifdef QGC_GST_STREAMING
7#include "GStreamer.h"
8#endif
9#ifndef QGC_DISABLE_UVC
10#include "UVCReceiver.h"
11#endif
12
13DECLARE_SETTINGGROUP(Video, "Video")
14{
15 // Setup enum values for videoSource settings into meta data
16 QVariantList videoSourceList;
17#if defined(QGC_GST_STREAMING) || defined(QGC_QT_STREAMING)
18 videoSourceList.append(videoSourceRTSP);
19 videoSourceList.append(videoSourceUDPH264);
20 videoSourceList.append(videoSourceUDPH265);
21 videoSourceList.append(videoSourceTCP);
22 videoSourceList.append(videoSourceMPEGTS);
23 videoSourceList.append(videoSource3DRSolo);
24 videoSourceList.append(videoSourceParrotDiscovery);
25 videoSourceList.append(videoSourceYuneecMantisG);
26
27 #ifdef QGC_HERELINK_AIRUNIT_VIDEO
28 videoSourceList.append(videoSourceHerelinkAirUnit);
29 #else
30 videoSourceList.append(videoSourceHerelinkHotspot);
31 #endif
32#endif
33#ifndef QGC_DISABLE_UVC
34 QStringList uvcDevices = UVCReceiver::getDeviceNameList();
35 for (const QString& device : uvcDevices) {
36 videoSourceList.append(device);
37 }
38#endif
39 if (videoSourceList.count() == 0) {
40 _noVideo = true;
41 videoSourceList.append(videoSourceNoVideo);
42 setVisible(false);
43 } else {
44 videoSourceList.insert(0, videoDisabled);
45 }
46
47 // make translated strings
48 QStringList videoSourceCookedList;
49 for (const QVariant& videoSource: videoSourceList) {
50 videoSourceCookedList.append( VideoSettings::tr(videoSource.toString().toStdString().c_str()) );
51 }
52
53 _nameToMetaDataMap[videoSourceName]->setEnumInfo(videoSourceCookedList, videoSourceList);
54
55 _setForceVideoDecodeList();
56
57 // Set default value for videoSource
58 _setDefaults();
59}
60
61void VideoSettings::_setDefaults()
62{
63 if (_noVideo) {
65 } else {
67 }
68}
69
79
81{
82 if (!_videoSourceFact) {
83 _videoSourceFact = _createSettingsFact(videoSourceName);
84 //-- Check for sources no longer available
85 if(!_videoSourceFact->enumValues().contains(_videoSourceFact->rawValue().toString())) {
86 if (_noVideo) {
87 _videoSourceFact->setRawValue(videoSourceNoVideo);
88 } else {
89 _videoSourceFact->setRawValue(videoDisabled);
90 }
91 }
92 connect(_videoSourceFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
93 }
94 return _videoSourceFact;
95}
96
98{
99 if (!_forceVideoDecoderFact) {
100 _forceVideoDecoderFact = _createSettingsFact(forceVideoDecoderName);
101
102 _forceVideoDecoderFact->setVisible(
103#ifdef QGC_GST_STREAMING
104 true
105#else
106 false
107#endif
108 );
109
110 connect(_forceVideoDecoderFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
111 }
112 return _forceVideoDecoderFact;
113}
114
116{
117 if (!_lowLatencyModeFact) {
118 _lowLatencyModeFact = _createSettingsFact(lowLatencyModeName);
119
120 _lowLatencyModeFact->setVisible(
121#ifdef QGC_GST_STREAMING
122 true
123#else
124 false
125#endif
126 );
127
128 connect(_lowLatencyModeFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
129 }
130 return _lowLatencyModeFact;
131}
132
134{
135 if (!_rtspTimeoutFact) {
136 _rtspTimeoutFact = _createSettingsFact(rtspTimeoutName);
137
138 _rtspTimeoutFact->setVisible(
139#ifdef QGC_GST_STREAMING
140 true
141#else
142 false
143#endif
144 );
145
146 connect(_rtspTimeoutFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
147 }
148 return _rtspTimeoutFact;
149}
150
152{
153 if (!_udpUrlFact) {
154 _udpUrlFact = _createSettingsFact(udpUrlName);
155 connect(_udpUrlFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
156 }
157 return _udpUrlFact;
158}
159
161{
162 if (!_rtspUrlFact) {
163 _rtspUrlFact = _createSettingsFact(rtspUrlName);
164 connect(_rtspUrlFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
165 }
166 return _rtspUrlFact;
167}
168
170{
171 if (!_tcpUrlFact) {
172 _tcpUrlFact = _createSettingsFact(tcpUrlName);
173 connect(_tcpUrlFact, &Fact::valueChanged, this, &VideoSettings::_configChanged);
174 }
175 return _tcpUrlFact;
176}
177
178bool VideoSettings::streamConfigured(void)
179{
180 //-- First, check if it's autoconfigured
181 if(VideoManager::instance()->autoStreamConfigured()) {
182 qCDebug(VideoManagerLog) << "Stream auto configured";
183 return true;
184 }
185 //-- Check if it's disabled
186 QString vSource = videoSource()->rawValue().toString();
187 if(vSource == videoSourceNoVideo || vSource == videoDisabled) {
188 return false;
189 }
190 //-- If UDP, check for URL
191 if(vSource == videoSourceUDPH264 || vSource == videoSourceUDPH265) {
192 qCDebug(VideoManagerLog) << "Testing configuration for UDP Stream:" << udpUrl()->rawValue().toString();
193 return !udpUrl()->rawValue().toString().isEmpty();
194 }
195 //-- If RTSP, check for URL
196 if(vSource == videoSourceRTSP) {
197 qCDebug(VideoManagerLog) << "Testing configuration for RTSP Stream:" << rtspUrl()->rawValue().toString();
198 return !rtspUrl()->rawValue().toString().isEmpty();
199 }
200 //-- If TCP, check for URL
201 if(vSource == videoSourceTCP) {
202 qCDebug(VideoManagerLog) << "Testing configuration for TCP Stream:" << tcpUrl()->rawValue().toString();
203 return !tcpUrl()->rawValue().toString().isEmpty();
204 }
205 //-- If MPEG-TS, check for URL
206 if(vSource == videoSourceMPEGTS) {
207 qCDebug(VideoManagerLog) << "Testing configuration for MPEG-TS Stream:" << udpUrl()->rawValue().toString();
208 return !udpUrl()->rawValue().toString().isEmpty();
209 }
210 //-- If Herelink Air unit, good to go
211 if(vSource == videoSourceHerelinkAirUnit) {
212 qCDebug(VideoManagerLog) << "Stream configured for Herelink Air Unit";
213 return true;
214 }
215 //-- If Herelink Hotspot, good to go
216 if(vSource == videoSourceHerelinkHotspot) {
217 qCDebug(VideoManagerLog) << "Stream configured for Herelink Hotspot";
218 return true;
219 }
220#ifndef QGC_DISABLE_UVC
222 qCDebug(VideoManagerLog) << "Stream configured for UVC";
223 return true;
224 }
225#endif
226 return false;
227}
228
229void VideoSettings::_configChanged(QVariant)
230{
231 emit streamConfiguredChanged(streamConfigured());
232}
233
234void VideoSettings::_setForceVideoDecodeList()
235{
236#ifdef QGC_GST_STREAMING
237 static const QList<GStreamer::VideoDecoderOptions> removeForceVideoDecodeList{
238#if defined(Q_OS_ANDROID)
244#elif defined(Q_OS_LINUX)
247#elif defined(Q_OS_WIN)
250#elif defined(Q_OS_MACOS)
253#elif defined(Q_OS_IOS)
258#endif
259 };
260
261 for (const auto &value : removeForceVideoDecodeList) {
262 _nameToMetaDataMap[forceVideoDecoderName]->removeEnumInfo(value);
263 }
264#endif
265}
#define DECLARE_SETTINGSFACT_NO_FUNC(CLASS, NAME)
#define DECLARE_SETTINGSFACT(CLASS, NAME)
#define DECLARE_SETTINGGROUP(NAME, GROUP)
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 enabled()
static bool deviceExists(const QString &device)
static QStringList getDeviceNameList()
Fact *rtspUrl READ rtspUrl CONSTANT Fact * rtspUrl()
static constexpr const char * videoSourceTCP
static const char * videoSourceName
static constexpr const char * videoSourceUDPH264
static constexpr const char * videoSourceHerelinkHotspot
bool streamConfigured READ streamConfigured NOTIFY streamConfiguredChanged(QString rtspVideoSource READ rtspVideoSource CONSTANT) 1(QString udp264VideoSource READ udp264VideoSource CONSTANT) 1(QString udp265VideoSource READ udp265VideoSource CONSTANT) 1(QString tcpVideoSource READ tcpVideoSource CONSTANT) 1(QString mpegtsVideoSource READ mpegtsVideoSource CONSTANT) 1(QString disabledVideoSource READ disabledVideoSource CONSTANT) bool streamConfigured()
static constexpr const char * videoSourceRTSP
static const char * forceVideoDecoderName
static constexpr const char * videoDisabled
Fact *udpUrl READ udpUrl CONSTANT Fact * udpUrl()
Fact *tcpUrl READ tcpUrl CONSTANT Fact * tcpUrl()
Fact *videoSource READ videoSource CONSTANT Fact * videoSource()
static constexpr const char * videoSourceUDPH265
static constexpr const char * videoSourceNoVideo
static constexpr const char * videoSourceMPEGTS
static constexpr const char * videoSourceHerelinkAirUnit
@ ForceVideoDecoderIntel
Definition GStreamer.h:21
@ ForceVideoDecoderVulkan
Definition GStreamer.h:22
@ ForceVideoDecoderNVIDIA
Definition GStreamer.h:17
@ ForceVideoDecoderVAAPI
Definition GStreamer.h:18
@ ForceVideoDecoderVideoToolbox
Definition GStreamer.h:20
@ ForceVideoDecoderDirectX3D
Definition GStreamer.h:19