From 5766d7df47ba0d3a985162ccd882d29ecc8322fb Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Thu, 2 Feb 2017 20:05:15 -0500 Subject: [PATCH] Allow disabling video recording --- src/FlightDisplay/FlightDisplayView.qml | 2 +- src/FlightDisplay/VideoManager.cc | 23 ++++++++++++++---- src/FlightDisplay/VideoManager.h | 31 +++++++++++++++---------- src/VideoStreaming/VideoReceiver.cc | 11 ++++++--- src/VideoStreaming/VideoStreaming.pri | 9 +++++++ src/ui/preferences/GeneralSettings.qml | 2 +- 6 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayView.qml b/src/FlightDisplay/FlightDisplayView.qml index e46cd5da1..ec47cffb2 100644 --- a/src/FlightDisplay/FlightDisplayView.qml +++ b/src/FlightDisplay/FlightDisplayView.qml @@ -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 { diff --git a/src/FlightDisplay/VideoManager.cc b/src/FlightDisplay/VideoManager.cc index 3eab2d874..09a7c3216 100644 --- a/src/FlightDisplay/VideoManager.cc +++ b/src/FlightDisplay/VideoManager.cc @@ -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(); } } diff --git a/src/FlightDisplay/VideoManager.h b/src/FlightDisplay/VideoManager.h index c9a5e6291..912e57715 100644 --- a/src/FlightDisplay/VideoManager.h +++ b/src/FlightDisplay/VideoManager.h @@ -30,18 +30,19 @@ public: VideoManager (QGCApplication* app); ~VideoManager (); - 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 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); @@ -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); diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc index 65dc1a16c..5d6e27f31 100644 --- a/src/VideoStreaming/VideoReceiver.cc +++ b/src/VideoStreaming/VideoReceiver.cc @@ -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) { diff --git a/src/VideoStreaming/VideoStreaming.pri b/src/VideoStreaming/VideoStreaming.pri index 762a608f5..fb1e58206 100644 --- a/src/VideoStreaming/VideoStreaming.pri +++ b/src/VideoStreaming/VideoStreaming.pri @@ -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 \ diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index be64cafd5..ed39910a2 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -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:") -- 2.22.0