Commit 05c8fde3 authored by Jacob Walser's avatar Jacob Walser

Add button in general settings to select location to save video files

parent ac4080a1
......@@ -27,6 +27,7 @@
static const char* kVideoSourceKey = "VideoSource";
static const char* kVideoUDPPortKey = "VideoUDPPort";
static const char* kVideoRTSPUrlKey = "VideoRTSPUrl";
static const char* kVideoSavePathKey = "VideoSaveDir";
#if defined(QGC_GST_STREAMING)
static const char* kUDPStream = "UDP Video Stream";
static const char* kRTSPStream = "RTSP Video Stream";
......@@ -80,6 +81,7 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
setUdpPort(settings.value(kVideoUDPPortKey, 5600).toUInt());
setRtspURL(settings.value(kVideoRTSPUrlKey, "rtsp://192.168.42.1:554/live").toString()); //-- Example RTSP URL
}
setVideoSavePath(settings.value(kVideoSavePathKey, QDir::homePath()).toString());
#endif
_init = true;
#if defined(QGC_GST_STREAMING)
......@@ -186,6 +188,17 @@ VideoManager::setRtspURL(QString url)
*/
}
void
VideoManager::setVideoSavePath(QString path)
{
_videoSavePath = path;
QSettings settings;
settings.setValue(kVideoSavePathKey, path);
if(_videoReceiver)
_videoReceiver->setVideoSavePath(_videoSavePath);
emit videoSavePathChanged();
}
//-----------------------------------------------------------------------------
QStringList
VideoManager::videoSourceList()
......@@ -265,6 +278,7 @@ void VideoManager::_updateVideo()
_videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_udpPort));
else
_videoReceiver->setUri(_rtspURL);
_videoReceiver->setVideoSavePath(_videoSavePath);
#endif
_videoReceiver->start();
}
......
......@@ -37,6 +37,7 @@ public:
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 WRITE setVideoSavePath NOTIFY videoSavePathChanged)
Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT)
Q_PROPERTY(VideoSurface* videoSurface MEMBER _videoSurface CONSTANT)
Q_PROPERTY(VideoReceiver* videoReceiver MEMBER _videoReceiver CONSTANT)
......@@ -49,6 +50,7 @@ public:
QStringList videoSourceList ();
quint16 udpPort () { return _udpPort; }
QString rtspURL () { return _rtspURL; }
QString videoSavePath () { return _videoSavePath; }
#if defined(QGC_DISABLE_UVC)
bool uvcEnabled () { return false; }
......@@ -59,6 +61,7 @@ public:
void setVideoSource (QString vSource);
void setUdpPort (quint16 port);
void setRtspURL (QString url);
void setVideoSavePath (QString path);
// Override from QGCTool
void setToolbox (QGCToolbox *toolbox);
......@@ -72,6 +75,7 @@ signals:
void videoSourceIDChanged ();
void udpPortChanged ();
void rtspURLChanged ();
void videoSavePathChanged ();
private:
void _updateTimer ();
......@@ -89,6 +93,7 @@ private:
QStringList _videoSourceList;
quint16 _udpPort;
QString _rtspURL;
QString _videoSavePath;
bool _init;
};
......
......@@ -19,6 +19,7 @@
#include <QUrl>
#include <QDir>
#include <QDateTime>
#include <QSysInfo>
VideoReceiver::Sink* VideoReceiver::_sink = NULL;
GstElement* VideoReceiver::_pipeline = NULL;
......@@ -127,8 +128,14 @@ void VideoReceiver::startRecording(void)
_sink->filesink = gst_element_factory_make("filesink", NULL);
_sink->removing = false;
QString filename = QDir::homePath() + "/" + QDateTime::currentDateTime().toString() + ".mkv";
g_object_set(G_OBJECT(_sink->filesink), "location", qPrintable(filename), NULL);
QString fileName;
if(QSysInfo::WindowsVersion != QSysInfo::WV_None) {
fileName = _path + "\\QGC-" + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss") + ".mkv";
} else {
fileName = _path + "/QGC-" + QDateTime::currentDateTime().toString("yyyy-MM-dd-hh:mm:ss") + ".mkv";
}
g_object_set(G_OBJECT(_sink->filesink), "location", qPrintable(fileName), NULL);
qDebug() << "New video file:" << fileName;
gst_object_ref(_sink->queue);
gst_object_ref(_sink->mux);
......@@ -482,6 +489,12 @@ void VideoReceiver::setUri(const QString & uri)
_uri = uri;
}
void VideoReceiver::setVideoSavePath(const QString & path)
{
_path = path;
qDebug() << "New Path:" << _path;
}
#if defined(QGC_GST_STREAMING)
void VideoReceiver::_onBusMessage(GstMessage* msg)
{
......
......@@ -47,11 +47,12 @@ signals:
void streamingChanged();
public slots:
void start ();
void stop ();
void setUri (const QString& uri);
void stopRecording ();
void startRecording ();
void start ();
void stop ();
void setUri (const QString& uri);
void setVideoSavePath (const QString& path);
void stopRecording ();
void startRecording ();
private slots:
#if defined(QGC_GST_STREAMING)
......@@ -85,6 +86,7 @@ private:
#endif
QString _uri;
QString _path;
#if defined(QGC_GST_STREAMING)
static GstElement* _pipeline;
......
......@@ -41,6 +41,18 @@ QGCView {
QGCPalette { id: qgcPal }
FileDialog {
id: fileDialog
title: "Choose a location to save video files."
folder: shortcuts.home
selectFolder: true
onAccepted: {
var path = fileDialog.fileUrl.toString();
path = path.replace(/^(file:\/{2})/,"");
QGroundControl.videoManager.videoSavePath = path
}
}
QGCViewPanel {
id: panel
anchors.fill: parent
......@@ -499,6 +511,25 @@ QGCView {
}
}
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.videoManager.isGStreamer
QGCLabel {
anchors.baseline: pathField.baseline
text: qsTr("Save Path:")
width: _labelWidth
}
QGCTextField {
id: pathField
width: _editFieldWidth
readOnly: true
text: QGroundControl.videoManager.videoSavePath
}
Button {
text: "Browse"
onClicked: fileDialog.visible = true
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment