diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc
index c9620f62cd94bed04edab4d3914fd0710cad5d94..870f12057139f0ea6c25b4fe15adec3a4511581f 100644
--- a/qgroundcontrol.qrc
+++ b/qgroundcontrol.qrc
@@ -179,10 +179,10 @@
src/Vehicle/GPSFact.json
src/Vehicle/WindFact.json
src/Vehicle/VibrationFact.json
- src/Settings/SettingsGroup.app.json
- src/Settings/SettingsGroup.autoConnect.json
- src/Settings/SettingsGroup.units.json
- src/Settings/SettingsGroup.video.json
+ src/Settings/App.SettingsGroup.json
+ src/Settings/AutoConnect.SettingsGroup.json
+ src/Settings/Units.SettingsGroup.json
+ src/Settings/Video.SettingsGroup.json
src/MissionManager/RallyPoint.FactMetaData.json
src/MissionManager/FWLandingPattern.FactMetaData.json
src/MissionManager/Survey.FactMetaData.json
diff --git a/src/FlightDisplay/VideoManager.cc b/src/FlightDisplay/VideoManager.cc
index 09a7c3216f7f9c67282fb9f1f8789e6159317484..e2cf39875c77b7f110c09279be3a07d3c5f223ba 100644
--- a/src/FlightDisplay/VideoManager.cc
+++ b/src/FlightDisplay/VideoManager.cc
@@ -25,19 +25,7 @@
#include "QGCToolbox.h"
#include "QGCCorePlugin.h"
#include "QGCOptions.h"
-
-static const char* kVideoSourceKey = "VideoSource";
-static const char* kVideoUDPPortKey = "VideoUDPPort";
-static const char* kVideoRTSPUrlKey = "VideoRTSPUrl";
-static const char* kNoVideo = "No Video Available";
-
-#if defined(QGC_GST_STREAMING)
-#if defined(QGC_ENABLE_VIDEORECORDING)
-static const char* kVideoSavePathKey= "VideoSavePath";
-#endif
-static const char* kUDPStream = "UDP Video Stream";
-static const char* kRTSPStream = "RTSP Video Stream";
-#endif
+#include "Settings/SettingsManager.h"
QGC_LOGGING_CATEGORY(VideoManagerLog, "VideoManagerLog")
@@ -47,8 +35,8 @@ VideoManager::VideoManager(QGCApplication* app)
, _videoSurface(NULL)
, _videoReceiver(NULL)
, _videoRunning(false)
- , _udpPort(5600) //-- Defalut Port 5600 == Solo UDP Port
, _init(false)
+ , _videoSettings(NULL)
{
}
@@ -65,31 +53,36 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
QGCTool::setToolbox(toolbox);
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType("QGroundControl.VideoManager", 1, 0, "VideoManager", "Reference only");
- //-- Get saved settings
+
+ _videoSettings = toolbox->settingsManager()->videoSettings();
+ QString videoSource = _videoSettings->videoSource()->rawValue().toString();
+
#if defined(QGC_GST_STREAMING)
- QSettings settings;
-#if defined(NO_UDP_VIDEO)
- setVideoSource(settings.value(kVideoSourceKey, kRTSPStream).toString());
-#else
- setVideoSource(settings.value(kVideoSourceKey, kUDPStream).toString());
-#endif
- //-- Check if core plugin defines its own video requirements
- if(qgcApp()->toolbox()->corePlugin()->options()->definesVideo()) {
- if(qgcApp()->toolbox()->corePlugin()->options()->videoUDPPort()) {
- setUdpPort(qgcApp()->toolbox()->corePlugin()->options()->videoUDPPort());
- setVideoSource(kUDPStream);
- } else {
- setVideoSource(kRTSPStream);
- setRtspURL(qgcApp()->toolbox()->corePlugin()->options()->videoRSTPUrl());
- }
- } else {
- setUdpPort(settings.value(kVideoUDPPortKey, 5600).toUInt());
- setRtspURL(settings.value(kVideoRTSPUrlKey, "rtsp://192.168.42.1:554/live").toString()); //-- Example RTSP URL
- }
-#if defined(QGC_ENABLE_VIDEORECORDING)
- setVideoSavePath(settings.value(kVideoSavePathKey, QDir::homePath()).toString());
+#ifndef QGC_DISABLE_UVC
+ // If we are using a UVC camera setup the device name
+ QList cameras = QCameraInfo::availableCameras();
+ foreach (const QCameraInfo &cameraInfo, cameras) {
+ if(cameraInfo.description() == videoSource) {
+ _videoSourceID = cameraInfo.deviceName();
+ emit videoSourceIDChanged();
+ qCDebug(VideoManagerLog) << "Found USB source:" << _videoSourceID << " Name:" << videoSource;
+ break;
+ }
+ }
#endif
+
+ emit isGStreamerChanged();
+ qCDebug(VideoManagerLog) << "New Video Source:" << videoSource;
+
+ if(_videoReceiver) {
+ if(isGStreamer()) {
+ _videoReceiver->start();
+ } else {
+ _videoReceiver->stop();
+ }
+ }
#endif
+
_init = true;
#if defined(QGC_GST_STREAMING)
_updateVideo();
@@ -105,7 +98,8 @@ VideoManager::hasVideo()
#if defined(QGC_GST_STREAMING)
return true;
#endif
- return !_videoSource.isEmpty();
+ QString videoSource = _videoSettings->videoSource()->rawValue().toString();
+ return !videoSource.isEmpty() && videoSource != VideoSettings::videoSourceNoVideo;
}
//-----------------------------------------------------------------------------
@@ -113,7 +107,8 @@ bool
VideoManager::isGStreamer()
{
#if defined(QGC_GST_STREAMING)
- return _videoSource == kUDPStream || _videoSource == kRTSPStream;
+ QString videoSource = _videoSettings->videoSource()->rawValue().toString();
+ return videoSource == VideoSettings::videoSourceUDP || videoSource == VideoSettings::videoSourceRTSP;
#else
return false;
#endif
@@ -128,118 +123,6 @@ VideoManager::uvcEnabled()
}
#endif
-//-----------------------------------------------------------------------------
-void
-VideoManager::setVideoSource(QString vSource)
-{
- if(vSource == kNoVideo)
- return;
- _videoSource = vSource;
- QSettings settings;
- settings.setValue(kVideoSourceKey, vSource);
- emit videoSourceChanged();
-#ifndef QGC_DISABLE_UVC
- QList cameras = QCameraInfo::availableCameras();
- foreach (const QCameraInfo &cameraInfo, cameras) {
- if(cameraInfo.description() == vSource) {
- _videoSourceID = cameraInfo.deviceName();
- emit videoSourceIDChanged();
- qCDebug(VideoManagerLog) << "Found USB source:" << _videoSourceID << " Name:" << _videoSource;
- break;
- }
- }
-#endif
- emit isGStreamerChanged();
- qCDebug(VideoManagerLog) << "New Video Source:" << vSource;
- /*
- * Not working. Requires restart for now. (Undef KRTSP/kUDP above when enabling this)
- if(isGStreamer())
- _updateVideo();
- */
- if(_videoReceiver) {
- if(isGStreamer()) {
- _videoReceiver->start();
- } else {
- _videoReceiver->stop();
- }
- }
-}
-
-//-----------------------------------------------------------------------------
-void
-VideoManager::setUdpPort(quint16 port)
-{
- _udpPort = port;
- QSettings settings;
- settings.setValue(kVideoUDPPortKey, port);
- emit udpPortChanged();
- /*
- * Not working. Requires restart for now. (Undef KRTSP/kUDP above when enabling this)
- if(_videoSource == kUDPStream)
- _updateVideo();
- */
-}
-
-//-----------------------------------------------------------------------------
-void
-VideoManager::setRtspURL(QString url)
-{
- _rtspURL = url;
- QSettings settings;
- settings.setValue(kVideoRTSPUrlKey, url);
- emit rtspURLChanged();
- /*
- * Not working. Requires restart for now. (Undef KRTSP/kUDP above when enabling this)
- if(_videoSource == kRTSPStream)
- _updateVideo();
- */
-}
-
-void
-VideoManager::setVideoSavePathByUrl(QUrl url) {
-#if defined(QGC_ENABLE_VIDEORECORDING)
- setVideoSavePath(url.toLocalFile());
-#else
- Q_UNUSED(url);
-#endif
-}
-
-void
-VideoManager::setVideoSavePath(QString path)
-{
-#if defined(QGC_ENABLE_VIDEORECORDING)
- _videoSavePath = path;
- QSettings settings;
- settings.setValue(kVideoSavePathKey, path);
- if(_videoReceiver)
- _videoReceiver->setVideoSavePath(_videoSavePath);
- emit videoSavePathChanged();
-#else
- Q_UNUSED(path);
-#endif
-}
-
-//-----------------------------------------------------------------------------
-QStringList
-VideoManager::videoSourceList()
-{
- _videoSourceList.clear();
-#if defined(QGC_GST_STREAMING)
- _videoSourceList.append(kUDPStream);
- _videoSourceList.append(kRTSPStream);
-#endif
-#ifndef QGC_DISABLE_UVC
- QList cameras = QCameraInfo::availableCameras();
- foreach (const QCameraInfo &cameraInfo, cameras) {
- qCDebug(VideoManagerLog) << "UVC Video source ID:" << cameraInfo.deviceName() << " Name:" << cameraInfo.description();
- _videoSourceList.append(cameraInfo.description());
- }
-#endif
- if(_videoSourceList.count() == 0)
- _videoSourceList.append(kNoVideo);
- return _videoSourceList;
-}
-
//-----------------------------------------------------------------------------
void VideoManager::_updateTimer()
{
@@ -292,13 +175,11 @@ void VideoManager::_updateVideo()
_videoReceiver = new VideoReceiver(this);
#if defined(QGC_GST_STREAMING)
_videoReceiver->setVideoSink(_videoSurface->videoSink());
- if(_videoSource == kUDPStream)
- _videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_udpPort));
+ QString videoSource = _videoSettings->videoSource()->rawValue().toString();
+ if (_videoSettings->videoSource()->rawValue().toString() == VideoSettings::videoSourceUDP)
+ _videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_videoSettings->udpPort()->rawValue().toInt()));
else
- _videoReceiver->setUri(_rtspURL);
-#if defined(QGC_ENABLE_VIDEORECORDING)
- _videoReceiver->setVideoSavePath(_videoSavePath);
-#endif
+ _videoReceiver->setUri(_videoSettings->rtspUrl()->rawValue().toString());
#endif
_videoReceiver->start();
}
diff --git a/src/FlightDisplay/VideoManager.h b/src/FlightDisplay/VideoManager.h
index 912e577157b910c4a46d45b0b5fbf562bfb72fe5..f96f1acb09731a2bfe92525d0764cb77d8a0ebc4 100644
--- a/src/FlightDisplay/VideoManager.h
+++ b/src/FlightDisplay/VideoManager.h
@@ -22,6 +22,8 @@
Q_DECLARE_LOGGING_CATEGORY(VideoManagerLog)
+class VideoSettings;
+
class VideoManager : public QGCTool
{
Q_OBJECT
@@ -33,28 +35,16 @@ public:
Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
Q_PROPERTY(bool isGStreamer READ isGStreamer NOTIFY isGStreamerChanged)
Q_PROPERTY(QString videoSourceID READ videoSourceID NOTIFY videoSourceIDChanged)
- Q_PROPERTY(QString videoSource READ videoSource WRITE setVideoSource NOTIFY videoSourceChanged)
- Q_PROPERTY(QStringList videoSourceList READ videoSourceList NOTIFY videoSourceListChanged)
Q_PROPERTY(bool videoRunning READ videoRunning NOTIFY videoRunningChanged)
- Q_PROPERTY(quint16 udpPort READ udpPort WRITE setUdpPort NOTIFY udpPortChanged)
- Q_PROPERTY(QString rtspURL READ rtspURL WRITE setRtspURL NOTIFY rtspURLChanged)
- Q_PROPERTY(QString videoSavePath READ videoSavePath NOTIFY videoSavePathChanged)
Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT)
Q_PROPERTY(VideoSurface* videoSurface MEMBER _videoSurface CONSTANT)
Q_PROPERTY(VideoReceiver* videoReceiver MEMBER _videoReceiver CONSTANT)
Q_PROPERTY(bool recordingEnabled READ recordingEnabled CONSTANT)
- Q_INVOKABLE void setVideoSavePathByUrl (QUrl url);
-
bool hasVideo ();
bool isGStreamer ();
bool videoRunning () { return _videoRunning; }
QString videoSourceID () { return _videoSourceID; }
- QString videoSource () { return _videoSource; }
- QStringList videoSourceList ();
- quint16 udpPort () { return _udpPort; }
- QString rtspURL () { return _rtspURL; }
- QString videoSavePath () { return _videoSavePath; }
#if defined(QGC_DISABLE_UVC)
bool uvcEnabled () { return false; }
@@ -68,43 +58,29 @@ public:
bool recordingEnabled () { return false; }
#endif
- void setVideoSource (QString vSource);
- void setUdpPort (quint16 port);
- void setRtspURL (QString url);
- void setVideoSavePath (QString path);
-
// Override from QGCTool
void setToolbox (QGCToolbox *toolbox);
signals:
void hasVideoChanged ();
void videoRunningChanged ();
- void videoSourceChanged ();
- void videoSourceListChanged ();
void isGStreamerChanged ();
void videoSourceIDChanged ();
- void udpPortChanged ();
- void rtspURLChanged ();
- void videoSavePathChanged ();
private:
void _updateTimer ();
void _updateVideo ();
private:
- VideoSurface* _videoSurface;
- VideoReceiver* _videoReceiver;
- bool _videoRunning;
+ VideoSurface* _videoSurface;
+ VideoReceiver* _videoReceiver;
+ bool _videoRunning;
#if defined(QGC_GST_STREAMING)
- QTimer _frameTimer;
+ QTimer _frameTimer;
#endif
- QString _videoSource;
- QString _videoSourceID;
- QStringList _videoSourceList;
- quint16 _udpPort;
- QString _rtspURL;
- QString _videoSavePath;
- bool _init;
+ QString _videoSourceID;
+ bool _init;
+ VideoSettings* _videoSettings;
};
#endif
diff --git a/src/Settings/SettingsGroup.app.json b/src/Settings/App.SettingsGroup.json
similarity index 100%
rename from src/Settings/SettingsGroup.app.json
rename to src/Settings/App.SettingsGroup.json
diff --git a/src/Settings/AppSettings.cc b/src/Settings/AppSettings.cc
index c0fb64fe8f3cf366dd18db0386b32a40159ed0f8..d2284a7b3e29f86c94cce6a9ae2c9c05dcc7546f 100644
--- a/src/Settings/AppSettings.cc
+++ b/src/Settings/AppSettings.cc
@@ -12,7 +12,7 @@
#include
#include
-const char* AppSettings::appSettingsGroupName = "app";
+const char* AppSettings::appSettingsGroupName = "App";
const char* AppSettings::offlineEditingFirmwareTypeSettingsName = "OfflineEditingFirmwareType";
const char* AppSettings::offlineEditingVehicleTypeSettingsName = "OfflineEditingVehicleType";
const char* AppSettings::offlineEditingCruiseSpeedSettingsName = "OfflineEditingCruiseSpeed";
diff --git a/src/Settings/SettingsGroup.autoConnect.json b/src/Settings/AutoConnect.SettingsGroup.json
similarity index 100%
rename from src/Settings/SettingsGroup.autoConnect.json
rename to src/Settings/AutoConnect.SettingsGroup.json
diff --git a/src/Settings/AutoConnectSettings.cc b/src/Settings/AutoConnectSettings.cc
index 008c08e046b9945dedc2de18309f97e68766fe69..fc1247f84c289394c062b872b0d92ec4882a86fe 100644
--- a/src/Settings/AutoConnectSettings.cc
+++ b/src/Settings/AutoConnectSettings.cc
@@ -22,7 +22,7 @@ const char* AutoConnectSettings:: autoConnectPX4FlowSettingsName = "Autocon
const char* AutoConnectSettings:: autoConnectRTKGPSSettingsName = "AutoconnectRTKGPS";
const char* AutoConnectSettings:: autoConnectLibrePilotSettingsName = "AutoconnectLibrePilot";
-const char* AutoConnectSettings::autoConnectSettingsGroupName = "autoConnect";
+const char* AutoConnectSettings::autoConnectSettingsGroupName = "AutoConnect";
AutoConnectSettings::AutoConnectSettings(QObject* parent)
: SettingsGroup(autoConnectSettingsGroupName, _settingsGroup, parent)
diff --git a/src/Settings/SettingsGroup.cc b/src/Settings/SettingsGroup.cc
index c29c42509378a547727c554054eea2a5f0c16299..e0f1ac231397146c46dbd31c3be6b44158b2d272 100644
--- a/src/Settings/SettingsGroup.cc
+++ b/src/Settings/SettingsGroup.cc
@@ -17,7 +17,7 @@ SettingsGroup::SettingsGroup(const QString& name, const QString& settingsGroup,
, _settingsGroup(settingsGroup)
, _visible(qgcApp()->toolbox()->corePlugin()->overrideSettingsGroupVisibility(name))
{
- QString jsonNameFormat(":/json/SettingsGroup.%1.json");
+ QString jsonNameFormat(":/json/%1.SettingsGroup.json");
_nameToMetaDataMap = FactMetaData::createMapFromJsonFile(jsonNameFormat.arg(name), this);
}
diff --git a/src/Settings/SettingsGroup.video.json b/src/Settings/SettingsGroup.video.json
deleted file mode 100644
index 0d4f101c7a37a4c875e6999bee1a287fdb733380..0000000000000000000000000000000000000000
--- a/src/Settings/SettingsGroup.video.json
+++ /dev/null
@@ -1,2 +0,0 @@
-[
-]
diff --git a/src/Settings/SettingsGroup.units.json b/src/Settings/Units.SettingsGroup.json
similarity index 100%
rename from src/Settings/SettingsGroup.units.json
rename to src/Settings/Units.SettingsGroup.json
diff --git a/src/Settings/UnitsSettings.cc b/src/Settings/UnitsSettings.cc
index 608e45cfd4650111aa8615d612117d3b4c759842..0d5c6e0d6df29fd8ecaf43ea5839bb286874866b 100644
--- a/src/Settings/UnitsSettings.cc
+++ b/src/Settings/UnitsSettings.cc
@@ -12,7 +12,7 @@
#include
#include
-const char* UnitsSettings::unitsSettingsGroupName = "units";
+const char* UnitsSettings::unitsSettingsGroupName = "Units";
const char* UnitsSettings::distanceUnitsSettingsName = "DistanceUnits";
const char* UnitsSettings::areaUnitsSettingsName = "AreaUnits";
const char* UnitsSettings::speedUnitsSettingsName = "SpeedUnits";
diff --git a/src/Settings/Video.SettingsGroup.json b/src/Settings/Video.SettingsGroup.json
new file mode 100644
index 0000000000000000000000000000000000000000..c9835ee0567129b141d8c071267a2420b93944e7
--- /dev/null
+++ b/src/Settings/Video.SettingsGroup.json
@@ -0,0 +1,31 @@
+[
+{
+ "name": "VideoSource",
+ "shortDescription": "Video source",
+ "longDescription": "Source for video. UDP, RTSP and UVC Cameras may be supported supported depending on Vehicle and QGroundControl version.",
+ "type": "string",
+ "defaultValue": ""
+},
+{
+ "name": "VideoUDPPort",
+ "shortDescription": "Video UDP Port",
+ "longDescription": "UDP port to bind to for video stream.",
+ "type": "uint16",
+ "min": 1025,
+ "defaultValue": 5600
+},
+{
+ "name": "VideoRTSPUrl",
+ "shortDescription": "Video RTSP Url",
+ "longDescription": "RTSP url address and port to bind to for video stream. Example: rtsp://192.168.42.1:554/live",
+ "type": "string",
+ "defaultValue": ""
+},
+{
+ "name": "VideoSavePath",
+ "shortDescription": "Video save directory",
+ "longDescription": "Directory to save videos to.",
+ "type": "string",
+ "defaultValue": ""
+}
+]
diff --git a/src/Settings/VideoSettings.cc b/src/Settings/VideoSettings.cc
index cd0228e57ce2f9688092af713226e74b8d203786..190c87fff1b2ea324b4f66cf53c0109a9792d690 100644
--- a/src/Settings/VideoSettings.cc
+++ b/src/Settings/VideoSettings.cc
@@ -11,12 +11,96 @@
#include
#include
+#include
-const char* VideoSettings::videoSettingsGroupName = "video";
+#ifndef QGC_DISABLE_UVC
+#include
+#endif
+
+const char* VideoSettings::videoSettingsGroupName = "Video";
+
+const char* VideoSettings::videoSourceName = "VideoSource";
+const char* VideoSettings::udpPortName = "VideoUDPPort";
+const char* VideoSettings::rtspUrlName = "VideoRTSPUrl";
+const char* VideoSettings::videoSavePathName = "VideoSavePath";
+
+const char* VideoSettings::videoSourceNoVideo = "No Video Available";
+const char* VideoSettings::videoSourceUDP = "UDP Video Stream";
+const char* VideoSettings::videoSourceRTSP = "RTSP Video Stream";
VideoSettings::VideoSettings(QObject* parent)
: SettingsGroup(videoSettingsGroupName, QString() /* root settings group */, parent)
+ , _videoSourceFact(NULL)
+ , _udpPortFact(NULL)
+ , _rtspUrlFact(NULL)
+ , _videoSavePathFact(NULL)
{
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only");
+
+ // Setup enum values for videoSource settings into meta data
+ QStringList videoSourceList;
+#ifdef QGC_GST_STREAMING
+#ifndef NO_UDP_VIDEO
+ videoSourceList.append(videoSourceUDP);
+#endif
+ videoSourceList.append(videoSourceRTSP);
+#endif
+#ifndef QGC_DISABLE_UVC
+ QList cameras = QCameraInfo::availableCameras();
+ foreach (const QCameraInfo &cameraInfo, cameras) {
+ videoSourceList.append(cameraInfo.description());
+ }
+#endif
+ if (videoSourceList.count() == 0) {
+ videoSourceList.append(videoSourceNoVideo);
+ }
+ QVariantList videoSourceVarList;
+ foreach (const QString& videoSource, videoSourceList) {
+ videoSourceVarList.append(QVariant::fromValue(videoSource));
+ }
+ _nameToMetaDataMap[videoSourceName]->setEnumInfo(videoSourceList, videoSourceVarList);
+
+ // Set default value for videoSource
+#if defined(NO_UDP_VIDEO)
+ _nameToMetaDataMap[videoSourceName]->setRawDefaultValue(videoSourceRTSP);
+#else
+ _nameToMetaDataMap[videoSourceName]->setRawDefaultValue(videoSourceUDP);
+#endif
+}
+
+Fact* VideoSettings::videoSource(void)
+{
+ if (!_videoSourceFact) {
+ _videoSourceFact = _createSettingsFact(videoSourceName);
+ }
+
+ return _videoSourceFact;
+}
+
+Fact* VideoSettings::udpPort(void)
+{
+ if (!_udpPortFact) {
+ _udpPortFact = _createSettingsFact(udpPortName);
+ }
+
+ return _udpPortFact;
+}
+
+Fact* VideoSettings::rtspUrl(void)
+{
+ if (!_rtspUrlFact) {
+ _rtspUrlFact = _createSettingsFact(rtspUrlName);
+ }
+
+ return _rtspUrlFact;
+}
+
+Fact* VideoSettings::videoSavePath(void)
+{
+ if (!_videoSavePathFact) {
+ _videoSavePathFact = _createSettingsFact(videoSavePathName);
+ }
+
+ return _videoSavePathFact;
}
diff --git a/src/Settings/VideoSettings.h b/src/Settings/VideoSettings.h
index 04bfc6bf82f310b3cc9dcf74e40b5949a1e0d3f8..df3821720d0916bf0d3270d338e0b069f91a9e65 100644
--- a/src/Settings/VideoSettings.h
+++ b/src/Settings/VideoSettings.h
@@ -19,9 +19,32 @@ class VideoSettings : public SettingsGroup
public:
VideoSettings(QObject* parent = NULL);
+ Q_PROPERTY(Fact* videoSource READ videoSource CONSTANT)
+ Q_PROPERTY(Fact* udpPort READ udpPort CONSTANT)
+ Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT)
+ Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT)
+
+ Fact* videoSource (void);
+ Fact* udpPort (void);
+ Fact* rtspUrl (void);
+ Fact* videoSavePath (void);
+
static const char* videoSettingsGroupName;
+ static const char* videoSourceName;
+ static const char* udpPortName;
+ static const char* rtspUrlName;
+ static const char* videoSavePathName;
+
+ static const char* videoSourceNoVideo;
+ static const char* videoSourceUDP;
+ static const char* videoSourceRTSP;
+
private:
+ SettingsFact* _videoSourceFact;
+ SettingsFact* _udpPortFact;
+ SettingsFact* _rtspUrlFact;
+ SettingsFact* _videoSavePathFact;
};
#endif
diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc
index 0a58ff8d02a2743562332c3230dd69a92405f9d3..383f92b6664f39e68010a4baa8c04229629bdfff 100644
--- a/src/VideoStreaming/VideoReceiver.cc
+++ b/src/VideoStreaming/VideoReceiver.cc
@@ -15,6 +15,9 @@
*/
#include "VideoReceiver.h"
+#include "SettingsManager.h"
+#include "QGCApplication.h"
+
#include
#include
#include
@@ -348,16 +351,6 @@ void VideoReceiver::setUri(const QString & uri)
_uri = uri;
}
-void VideoReceiver::setVideoSavePath(const QString& path)
-{
-#if defined(QGC_ENABLE_VIDEORECORDING)
- _path = path;
- qCDebug(VideoReceiverLog) << "New Path:" << _path;
-#else
- Q_UNUSED(path);
-#endif
-}
-
#if defined(QGC_GST_STREAMING)
void VideoReceiver::_shutdownPipeline() {
if(!_pipeline) {
@@ -467,8 +460,9 @@ void VideoReceiver::startRecording(void)
return;
}
- if(_path.isEmpty()) {
- qWarning() << "VideoReceiver::startRecording Empty Path!";
+ QString savePath = qgcApp()->toolbox()->settingsManager()->videoSettings()->videoSavePath()->rawValue().toString();
+ if(savePath.isEmpty()) {
+ qgcApp()->showMessage("Unabled to record video. Video save path must be specified in Settings.");
return;
}
@@ -485,7 +479,7 @@ void VideoReceiver::startRecording(void)
}
QString videoFile;
- videoFile = _path + "/QGC-" + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss") + ".mkv";
+ videoFile = savePath + "/QGC-" + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss") + ".mkv";
g_object_set(G_OBJECT(_sink->filesink), "location", qPrintable(videoFile), NULL);
qCDebug(VideoReceiverLog) << "New video file:" << videoFile;
diff --git a/src/VideoStreaming/VideoReceiver.h b/src/VideoStreaming/VideoReceiver.h
index 9ec600fedb3296ad41da2eecc47c097c42f28753..2c294cf2444cb10b348d885a9ad11ed9af2cf6c4 100644
--- a/src/VideoStreaming/VideoReceiver.h
+++ b/src/VideoStreaming/VideoReceiver.h
@@ -62,7 +62,6 @@ public slots:
void start ();
void stop ();
void setUri (const QString& uri);
- void setVideoSavePath (const QString& path);
void stopRecording ();
void startRecording ();
@@ -105,7 +104,6 @@ private:
#endif
QString _uri;
- QString _path;
#if defined(QGC_GST_STREAMING)
GstElement* _pipeline;
diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml
index 94f1968214c991c25263628ed31e02794e821f3b..a83ceb588b5c6c1b54113e88fd8d026e0aaf82b3 100644
--- a/src/ui/preferences/GeneralSettings.qml
+++ b/src/ui/preferences/GeneralSettings.qml
@@ -453,84 +453,68 @@ QGCView {
anchors.margins: ScreenTools.defaultFontPixelWidth
anchors.horizontalCenter: parent.horizontalCenter
visible: QGroundControl.settingsManager.videoSettings.visible
+
Column {
id: videoCol
spacing: ScreenTools.defaultFontPixelWidth
anchors.centerIn: parent
+
+
Row {
spacing: ScreenTools.defaultFontPixelWidth
+ visible: QGroundControl.settingsManager.videoSettings.videoSource.visible
QGCLabel {
anchors.baseline: videoSource.baseline
text: qsTr("Video Source:")
width: _labelWidth
}
- QGCComboBox {
- id: videoSource
- width: _editFieldWidth
- model: QGroundControl.videoManager.videoSourceList
- Component.onCompleted: {
- var index = videoSource.find(QGroundControl.videoManager.videoSource)
- if (index >= 0) {
- videoSource.currentIndex = index
- }
- }
- onActivated: {
- if (index != -1) {
- currentIndex = index
- QGroundControl.videoManager.videoSource = model[index]
- }
- }
+ FactComboBox {
+ id: videoSource
+ width: _editFieldWidth
+ indexModel: false
+ fact: QGroundControl.settingsManager.videoSettings.videoSource
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
- visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 0
+ visible: QGroundControl.settingsManager.videoSettings.udpPort.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 0
QGCLabel {
anchors.baseline: udpField.baseline
text: qsTr("UDP Port:")
width: _labelWidth
}
- QGCTextField {
+ FactTextField {
id: udpField
width: _editFieldWidth
- text: QGroundControl.videoManager.udpPort
- validator: IntValidator {bottom: 1024; top: 65535;}
- inputMethodHints: Qt.ImhDigitsOnly
- onEditingFinished: {
- QGroundControl.videoManager.udpPort = parseInt(text)
- }
+ fact: QGroundControl.settingsManager.videoSettings.udpPort
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
- visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 1
+ visible: QGroundControl.settingsManager.videoSettings.rtspUrl.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 1
QGCLabel {
anchors.baseline: rtspField.baseline
text: qsTr("RTSP URL:")
width: _labelWidth
}
- QGCTextField {
+ FactTextField {
id: rtspField
width: _editFieldWidth
- text: QGroundControl.videoManager.rtspURL
- onEditingFinished: {
- QGroundControl.videoManager.rtspURL = text
- }
+ fact: QGroundControl.settingsManager.videoSettings.rtspUrl
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
- visible: QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled
+ visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled
QGCLabel {
anchors.baseline: pathField.baseline
text: qsTr("Save Path:")
width: _labelWidth
}
- QGCTextField {
+ FactTextField {
id: pathField
width: _editFieldWidth
- readOnly: true
- text: QGroundControl.videoManager.videoSavePath
+ fact: QGroundControl.settingsManager.videoSettings.videoSavePath
}
QGCButton {
text: "Browse"
@@ -541,13 +525,12 @@ QGCView {
title: "Choose a location to save video files."
folder: shortcuts.home
selectFolder: true
- onAccepted: QGroundControl.videoManager.setVideoSavePathByUrl(fileDialog.fileUrl)
+ onAccepted: QGroundControl.settingsManager.videoSettings.videoSavePath.value = QGroundControl.urlToLocalFile(videoLocationFileDialog.fileUrl)
}
-
}
}
}
- }
+ } // Video Source - Rectangle
QGCLabel {
anchors.horizontalCenter: parent.horizontalCenter