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

Allow disabling video recording

parent 78711fb9
...@@ -268,7 +268,7 @@ QGCView { ...@@ -268,7 +268,7 @@ QGCView {
anchors.right: _flightVideo.right anchors.right: _flightVideo.right
height: ScreenTools.defaultFontPixelHeight * 2 height: ScreenTools.defaultFontPixelHeight * 2
width: height width: height
visible: QGroundControl.videoManager.videoRunning visible: QGroundControl.videoManager.videoRunning && QGroundControl.videoManager.recordingEnabled
opacity: 0.75 opacity: 0.75
Rectangle { Rectangle {
......
...@@ -29,12 +29,15 @@ ...@@ -29,12 +29,15 @@
static const char* kVideoSourceKey = "VideoSource"; static const char* kVideoSourceKey = "VideoSource";
static const char* kVideoUDPPortKey = "VideoUDPPort"; static const char* kVideoUDPPortKey = "VideoUDPPort";
static const char* kVideoRTSPUrlKey = "VideoRTSPUrl"; 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_GST_STREAMING)
#if defined(QGC_ENABLE_VIDEORECORDING)
static const char* kVideoSavePathKey= "VideoSavePath";
#endif
static const char* kUDPStream = "UDP Video Stream"; static const char* kUDPStream = "UDP Video Stream";
static const char* kRTSPStream = "RTSP Video Stream"; static const char* kRTSPStream = "RTSP Video Stream";
#endif #endif
static const char* kNoVideo = "No Video Available";
QGC_LOGGING_CATEGORY(VideoManagerLog, "VideoManagerLog") QGC_LOGGING_CATEGORY(VideoManagerLog, "VideoManagerLog")
...@@ -83,7 +86,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox) ...@@ -83,7 +86,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
setUdpPort(settings.value(kVideoUDPPortKey, 5600).toUInt()); setUdpPort(settings.value(kVideoUDPPortKey, 5600).toUInt());
setRtspURL(settings.value(kVideoRTSPUrlKey, "rtsp://192.168.42.1:554/live").toString()); //-- Example RTSP URL 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()); setVideoSavePath(settings.value(kVideoSavePathKey, QDir::homePath()).toString());
#endif
#endif #endif
_init = true; _init = true;
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
...@@ -192,18 +197,26 @@ VideoManager::setRtspURL(QString url) ...@@ -192,18 +197,26 @@ VideoManager::setRtspURL(QString url)
void void
VideoManager::setVideoSavePathByUrl(QUrl url) { VideoManager::setVideoSavePathByUrl(QUrl url) {
#if defined(QGC_ENABLE_VIDEORECORDING)
setVideoSavePath(url.toLocalFile()); setVideoSavePath(url.toLocalFile());
#else
Q_UNUSED(url);
#endif
} }
void void
VideoManager::setVideoSavePath(QString path) VideoManager::setVideoSavePath(QString path)
{ {
#if defined(QGC_ENABLE_VIDEORECORDING)
_videoSavePath = path; _videoSavePath = path;
QSettings settings; QSettings settings;
settings.setValue(kVideoSavePathKey, path); settings.setValue(kVideoSavePathKey, path);
if(_videoReceiver) if(_videoReceiver)
_videoReceiver->setVideoSavePath(_videoSavePath); _videoReceiver->setVideoSavePath(_videoSavePath);
emit videoSavePathChanged(); emit videoSavePathChanged();
#else
Q_UNUSED(path);
#endif
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -277,14 +290,16 @@ void VideoManager::_updateVideo() ...@@ -277,14 +290,16 @@ void VideoManager::_updateVideo()
delete _videoSurface; delete _videoSurface;
_videoSurface = new VideoSurface; _videoSurface = new VideoSurface;
_videoReceiver = new VideoReceiver(this); _videoReceiver = new VideoReceiver(this);
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
_videoReceiver->setVideoSink(_videoSurface->videoSink()); _videoReceiver->setVideoSink(_videoSurface->videoSink());
if(_videoSource == kUDPStream) if(_videoSource == kUDPStream)
_videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_udpPort)); _videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_udpPort));
else else
_videoReceiver->setUri(_rtspURL); _videoReceiver->setUri(_rtspURL);
#if defined(QGC_ENABLE_VIDEORECORDING)
_videoReceiver->setVideoSavePath(_videoSavePath); _videoReceiver->setVideoSavePath(_videoSavePath);
#endif #endif
#endif
_videoReceiver->start(); _videoReceiver->start();
} }
} }
...@@ -30,18 +30,19 @@ public: ...@@ -30,18 +30,19 @@ public:
VideoManager (QGCApplication* app); VideoManager (QGCApplication* app);
~VideoManager (); ~VideoManager ();
Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged) Q_PROPERTY(bool hasVideo READ hasVideo NOTIFY hasVideoChanged)
Q_PROPERTY(bool isGStreamer READ isGStreamer NOTIFY isGStreamerChanged) Q_PROPERTY(bool isGStreamer READ isGStreamer NOTIFY isGStreamerChanged)
Q_PROPERTY(QString videoSourceID READ videoSourceID NOTIFY videoSourceIDChanged) Q_PROPERTY(QString videoSourceID READ videoSourceID NOTIFY videoSourceIDChanged)
Q_PROPERTY(QString videoSource READ videoSource WRITE setVideoSource NOTIFY videoSourceChanged) Q_PROPERTY(QString videoSource READ videoSource WRITE setVideoSource NOTIFY videoSourceChanged)
Q_PROPERTY(QStringList videoSourceList READ videoSourceList NOTIFY videoSourceListChanged) Q_PROPERTY(QStringList videoSourceList READ videoSourceList NOTIFY videoSourceListChanged)
Q_PROPERTY(bool videoRunning READ videoRunning NOTIFY videoRunningChanged) Q_PROPERTY(bool videoRunning READ videoRunning NOTIFY videoRunningChanged)
Q_PROPERTY(quint16 udpPort READ udpPort WRITE setUdpPort NOTIFY udpPortChanged) Q_PROPERTY(quint16 udpPort READ udpPort WRITE setUdpPort NOTIFY udpPortChanged)
Q_PROPERTY(QString rtspURL READ rtspURL WRITE setRtspURL NOTIFY rtspURLChanged) Q_PROPERTY(QString rtspURL READ rtspURL WRITE setRtspURL NOTIFY rtspURLChanged)
Q_PROPERTY(QString videoSavePath READ videoSavePath NOTIFY videoSavePathChanged) Q_PROPERTY(QString videoSavePath READ videoSavePath NOTIFY videoSavePathChanged)
Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT) Q_PROPERTY(bool uvcEnabled READ uvcEnabled CONSTANT)
Q_PROPERTY(VideoSurface* videoSurface MEMBER _videoSurface CONSTANT) Q_PROPERTY(VideoSurface* videoSurface MEMBER _videoSurface CONSTANT)
Q_PROPERTY(VideoReceiver* videoReceiver MEMBER _videoReceiver CONSTANT) Q_PROPERTY(VideoReceiver* videoReceiver MEMBER _videoReceiver CONSTANT)
Q_PROPERTY(bool recordingEnabled READ recordingEnabled CONSTANT)
Q_INVOKABLE void setVideoSavePathByUrl (QUrl url); Q_INVOKABLE void setVideoSavePathByUrl (QUrl url);
...@@ -61,6 +62,12 @@ public: ...@@ -61,6 +62,12 @@ public:
bool uvcEnabled (); bool uvcEnabled ();
#endif #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 setVideoSource (QString vSource);
void setUdpPort (quint16 port); void setUdpPort (quint16 port);
void setRtspURL (QString url); void setRtspURL (QString url);
......
...@@ -346,10 +346,14 @@ void VideoReceiver::setUri(const QString & uri) ...@@ -346,10 +346,14 @@ void VideoReceiver::setUri(const QString & uri)
_uri = uri; _uri = uri;
} }
void VideoReceiver::setVideoSavePath(const QString & path) void VideoReceiver::setVideoSavePath(const QString& path)
{ {
#if defined(QGC_ENABLE_VIDEORECORDING)
_path = path; _path = path;
qCDebug(VideoReceiverLog) << "New Path:" << _path; qCDebug(VideoReceiverLog) << "New Path:" << _path;
#else
Q_UNUSED(path);
#endif
} }
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
...@@ -452,7 +456,8 @@ gboolean VideoReceiver::_onBusMessage(GstBus* bus, GstMessage* msg, gpointer dat ...@@ -452,7 +456,8 @@ gboolean VideoReceiver::_onBusMessage(GstBus* bus, GstMessage* msg, gpointer dat
// +--------------------------------------+ // +--------------------------------------+
void VideoReceiver::startRecording(void) void VideoReceiver::startRecording(void)
{ {
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
qCDebug(VideoReceiverLog) << "startRecording()"; qCDebug(VideoReceiverLog) << "startRecording()";
// exit immediately if we are already recording // exit immediately if we are already recording
if(_pipeline == NULL || _recording) { if(_pipeline == NULL || _recording) {
...@@ -506,7 +511,7 @@ void VideoReceiver::startRecording(void) ...@@ -506,7 +511,7 @@ void VideoReceiver::startRecording(void)
void VideoReceiver::stopRecording(void) void VideoReceiver::stopRecording(void)
{ {
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING) && defined(QGC_ENABLE_VIDEORECORDING)
qCDebug(VideoReceiverLog) << "stopRecording()"; qCDebug(VideoReceiverLog) << "stopRecording()";
// exit immediately if we are not recording // exit immediately if we are not recording
if(_pipeline == NULL || !_recording) { if(_pipeline == NULL || !_recording) {
......
...@@ -120,6 +120,15 @@ VideoEnabled { ...@@ -120,6 +120,15 @@ VideoEnabled {
message("Including support for video streaming") 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 += \ DEFINES += \
QGC_GST_STREAMING \ QGC_GST_STREAMING \
GST_PLUGIN_BUILD_STATIC \ GST_PLUGIN_BUILD_STATIC \
......
...@@ -535,7 +535,7 @@ QGCView { ...@@ -535,7 +535,7 @@ QGCView {
} }
Row { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.videoManager.isGStreamer visible: QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled
QGCLabel { QGCLabel {
anchors.baseline: pathField.baseline anchors.baseline: pathField.baseline
text: qsTr("Save Path:") 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