Commit 5766d7df authored by Gus Grubba's avatar Gus Grubba

Allow disabling video recording

parent 78711fb9
......@@ -268,7 +268,7 @@ QGCView {
anchors.right: _flightVideo.right
height: ScreenTools.defaultFontPixelHeight * 2
width: height
visible: QGroundControl.videoManager.videoRunning
visible: QGroundControl.videoManager.videoRunning && QGroundControl.videoManager.recordingEnabled
opacity: 0.75
Rectangle {
......
......@@ -29,12 +29,15 @@
static const char* kVideoSourceKey = "VideoSource";
static const char* kVideoUDPPortKey = "VideoUDPPort";
static const char* kVideoRTSPUrlKey = "VideoRTSPUrl";
static const char* kVideoSavePathKey = "VideoSavePath";
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
static const char* kNoVideo = "No Video Available";
QGC_LOGGING_CATEGORY(VideoManagerLog, "VideoManagerLog")
......@@ -83,7 +86,9 @@ 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
}
#if defined(QGC_ENABLE_VIDEORECORDING)
setVideoSavePath(settings.value(kVideoSavePathKey, QDir::homePath()).toString());
#endif
#endif
_init = true;
#if defined(QGC_GST_STREAMING)
......@@ -192,18 +197,26 @@ VideoManager::setRtspURL(QString url)
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
}
//-----------------------------------------------------------------------------
......@@ -277,14 +290,16 @@ void VideoManager::_updateVideo()
delete _videoSurface;
_videoSurface = new VideoSurface;
_videoReceiver = new VideoReceiver(this);
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
_videoReceiver->setVideoSink(_videoSurface->videoSink());
if(_videoSource == kUDPStream)
_videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_udpPort));
else
_videoReceiver->setUri(_rtspURL);
#if defined(QGC_ENABLE_VIDEORECORDING)
_videoReceiver->setVideoSavePath(_videoSavePath);
#endif
#endif
#endif
_videoReceiver->start();
}
}
......@@ -42,6 +42,7 @@ public:
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);
......@@ -61,6 +62,12 @@ public:
bool uvcEnabled ();
#endif
#if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
bool recordingEnabled () { return true; }
#else
bool recordingEnabled () { return false; }
#endif
void setVideoSource (QString vSource);
void setUdpPort (quint16 port);
void setRtspURL (QString url);
......
......@@ -346,10 +346,14 @@ void VideoReceiver::setUri(const QString & uri)
_uri = uri;
}
void VideoReceiver::setVideoSavePath(const QString & path)
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)
......@@ -452,7 +456,8 @@ gboolean VideoReceiver::_onBusMessage(GstBus* bus, GstMessage* msg, gpointer dat
// +--------------------------------------+
void VideoReceiver::startRecording(void)
{
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
qCDebug(VideoReceiverLog) << "startRecording()";
// exit immediately if we are already recording
if(_pipeline == NULL || _recording) {
......@@ -506,7 +511,7 @@ void VideoReceiver::startRecording(void)
void VideoReceiver::stopRecording(void)
{
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
qCDebug(VideoReceiverLog) << "stopRecording()";
// exit immediately if we are not recording
if(_pipeline == NULL || !_recording) {
......
......@@ -120,6 +120,15 @@ VideoEnabled {
message("Including support for video streaming")
contains (CONFIG, DISABLE_VIDEORECORDING) {
message("Skipping support for video recording (manual override from command line)")
# Otherwise the user can still disable this feature in the user_config.pri file.
} else:exists($$BASEDIR/user_config.pri):infile($$BASEDIR/user_config.pri, DEFINES, DISABLE_VIDEORECORDING) {
message("Skipping support for video recording (manual override from user_config.pri)")
} else {
DEFINES += QGC_ENABLE_VIDEORECORDING
}
DEFINES += \
QGC_GST_STREAMING \
GST_PLUGIN_BUILD_STATIC \
......
......@@ -535,7 +535,7 @@ QGCView {
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.videoManager.isGStreamer
visible: QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled
QGCLabel {
anchors.baseline: pathField.baseline
text: qsTr("Save Path:")
......
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