diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc index 341558bd1f57fb58ead5c6ff7de9e51ad2b88354..d41ce35243f3fd05050f91137d831f74cb2c9fab 100644 --- a/src/VideoStreaming/VideoReceiver.cc +++ b/src/VideoStreaming/VideoReceiver.cc @@ -609,7 +609,7 @@ VideoReceiver::_cleanupOldVideos() // | | // +--------------------------------------+ void -VideoReceiver::startRecording(void) +VideoReceiver::startRecording(const QString &videoFile) { #if defined(QGC_GST_STREAMING) @@ -620,12 +620,6 @@ VideoReceiver::startRecording(void) return; } - QString savePath = qgcApp()->toolbox()->settingsManager()->appSettings()->videoSavePath(); - if(savePath.isEmpty()) { - qgcApp()->showMessage(tr("Unabled to record video. Video save path must be specified in Settings.")); - return; - } - uint32_t muxIdx = _videoSettings->recordingFormat()->rawValue().toUInt(); if(muxIdx >= NUM_MUXES) { qgcApp()->showMessage(tr("Invalid video format defined.")); @@ -648,11 +642,20 @@ VideoReceiver::startRecording(void) return; } - QString videoFile; - videoFile = savePath + "/" + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss") + "." + kVideoExtensions[muxIdx]; + if(videoFile.isEmpty()) { + QString savePath = qgcApp()->toolbox()->settingsManager()->appSettings()->videoSavePath(); + if(savePath.isEmpty()) { + qgcApp()->showMessage(tr("Unabled to record video. Video save path must be specified in Settings.")); + return; + } + _videoFile = savePath + "/" + QDateTime::currentDateTime().toString("yyyy-MM-dd_hh.mm.ss") + "." + kVideoExtensions[muxIdx]; + } else { + _videoFile = videoFile; + } + emit videoFileChanged(); - g_object_set(G_OBJECT(_sink->filesink), "location", qPrintable(videoFile), NULL); - qCDebug(VideoReceiverLog) << "New video file:" << videoFile; + g_object_set(G_OBJECT(_sink->filesink), "location", qPrintable(_videoFile), NULL); + qCDebug(VideoReceiverLog) << "New video file:" << _videoFile; gst_object_ref(_sink->queue); gst_object_ref(_sink->parse); diff --git a/src/VideoStreaming/VideoReceiver.h b/src/VideoStreaming/VideoReceiver.h index f21380a78ec4925894f65d01f6b8b5ec7993858c..843abdf144ea6b0d3e18529ea9abfbd06df653cb 100644 --- a/src/VideoStreaming/VideoReceiver.h +++ b/src/VideoStreaming/VideoReceiver.h @@ -42,6 +42,7 @@ public: Q_PROPERTY(VideoSurface* videoSurface READ videoSurface CONSTANT) Q_PROPERTY(bool videoRunning READ videoRunning NOTIFY videoRunningChanged) Q_PROPERTY(QString imageFile READ imageFile NOTIFY imageFileChanged) + Q_PROPERTY(QString videoFile READ videoFile NOTIFY videoFileChanged) Q_PROPERTY(bool showFullScreen READ showFullScreen WRITE setShowFullScreen NOTIFY showFullScreenChanged) explicit VideoReceiver(QObject* parent = 0); @@ -58,6 +59,7 @@ public: VideoSurface* videoSurface () { return _videoSurface; } bool videoRunning () { return _videoRunning; } QString imageFile () { return _imageFile; } + QString videoFile () { return _videoFile; } bool showFullScreen () { return _showFullScreen; } void grabImage (QString imageFile); @@ -67,6 +69,7 @@ public: signals: void videoRunningChanged (); void imageFileChanged (); + void videoFileChanged (); void showFullScreenChanged (); #if defined(QGC_GST_STREAMING) void recordingChanged (); @@ -80,7 +83,7 @@ public slots: void stop (); void setUri (const QString& uri); void stopRecording (); - void startRecording (); + void startRecording (const QString& videoFile = QString()); private slots: void _updateTimer (); @@ -136,6 +139,7 @@ private: QString _uri; QString _imageFile; + QString _videoFile; VideoSurface* _videoSurface; bool _videoRunning; bool _showFullScreen;