diff --git a/src/FlightDisplay/VideoManager.cc b/src/FlightDisplay/VideoManager.cc index 76444f402dc376827326ef87b7908bf50c19e6fc..ed275e23dfbe9cbb29999ac5df97d30b69165d88 100644 --- a/src/FlightDisplay/VideoManager.cc +++ b/src/FlightDisplay/VideoManager.cc @@ -114,11 +114,8 @@ VideoManager::_rtspUrlChanged() bool VideoManager::hasVideo() { -#if defined(QGC_GST_STREAMING) - return true; -#endif QString videoSource = _videoSettings->videoSource()->rawValue().toString(); - return !videoSource.isEmpty() && videoSource != VideoSettings::videoSourceNoVideo; + return !videoSource.isEmpty() && videoSource != VideoSettings::videoSourceNoVideo && videoSource != VideoSettings::videoDisabled; } //----------------------------------------------------------------------------- @@ -150,7 +147,7 @@ VideoManager::_updateSettings() return; if (_videoSettings->videoSource()->rawValue().toString() == VideoSettings::videoSourceUDP) _videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_videoSettings->udpPort()->rawValue().toInt())); - else + else if (_videoSettings->videoSource()->rawValue().toString() == VideoSettings::videoSourceRTSP) _videoReceiver->setUri(_videoSettings->rtspUrl()->rawValue().toString()); } diff --git a/src/Settings/VideoSettings.cc b/src/Settings/VideoSettings.cc index 120b0ce80bd6e4d32c4ae904d6db3b6ce617fc8c..577e590524c3118fd969ae3b9c2d8ef83c3541dc 100644 --- a/src/Settings/VideoSettings.cc +++ b/src/Settings/VideoSettings.cc @@ -29,6 +29,7 @@ const char* VideoSettings::recordingFormatName = "RecordingFormat"; const char* VideoSettings::maxVideoSizeName = "MaxVideoSize"; const char* VideoSettings::videoSourceNoVideo = "No Video Available"; +const char* VideoSettings::videoDisabled = "Video Stream Disabled"; const char* VideoSettings::videoSourceUDP = "UDP Video Stream"; const char* VideoSettings::videoSourceRTSP = "RTSP Video Stream"; @@ -47,6 +48,7 @@ VideoSettings::VideoSettings(QObject* parent) qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only"); // Setup enum values for videoSource settings into meta data + bool noVideo = false; QStringList videoSourceList; #ifdef QGC_GST_STREAMING #ifndef NO_UDP_VIDEO @@ -61,7 +63,10 @@ VideoSettings::VideoSettings(QObject* parent) } #endif if (videoSourceList.count() == 0) { + noVideo = true; videoSourceList.append(videoSourceNoVideo); + } else { + videoSourceList.insert(0, videoDisabled); } QVariantList videoSourceVarList; foreach (const QString& videoSource, videoSourceList) { @@ -70,11 +75,11 @@ VideoSettings::VideoSettings(QObject* parent) _nameToMetaDataMap[videoSourceName]->setEnumInfo(videoSourceList, videoSourceVarList); // Set default value for videoSource -#if defined(NO_UDP_VIDEO) - _nameToMetaDataMap[videoSourceName]->setRawDefaultValue(videoSourceRTSP); -#else - _nameToMetaDataMap[videoSourceName]->setRawDefaultValue(videoSourceUDP); -#endif + if (noVideo) { + _nameToMetaDataMap[videoSourceName]->setRawDefaultValue(videoSourceNoVideo); + } else { + _nameToMetaDataMap[videoSourceName]->setRawDefaultValue(videoDisabled); + } } Fact* VideoSettings::videoSource(void) diff --git a/src/Settings/VideoSettings.h b/src/Settings/VideoSettings.h index 22fcbbb36c14a4d273d167c625cf03cdfdfef43f..71a6652c7d15a888d8ec61e3e2c5208b4b591998 100644 --- a/src/Settings/VideoSettings.h +++ b/src/Settings/VideoSettings.h @@ -49,6 +49,7 @@ public: static const char* maxVideoSizeName; static const char* videoSourceNoVideo; + static const char* videoDisabled; static const char* videoSourceUDP; static const char* videoSourceRTSP; diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc index 2feb997dc5d95598cdb6c2d75d5130922bd28edb..c0318b66d4879c022dbd65e68fc857716c42fa22 100644 --- a/src/VideoStreaming/VideoReceiver.cc +++ b/src/VideoStreaming/VideoReceiver.cc @@ -220,10 +220,11 @@ VideoReceiver::start() _starting = true; - bool isUdp = _uri.contains("udp://"); + bool isUdp = _uri.contains("udp://"); + bool isRtsp = _uri.contains("rtsp://"); //-- For RTSP, check to see if server is there first - if(!_serverPresent && !isUdp) { + if(!_serverPresent && isRtsp) { _timer.start(100); return; } @@ -776,7 +777,7 @@ VideoReceiver::_updateTimer() stop(); } } else { - if(!running()) { + if(!running() && !_uri.isEmpty()) { start(); } } diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 27dc2dd9ca5c444756b5fa43bc9a5784835b56d9..68abd607299c116116199c02ac1861dbff917e72 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -529,7 +529,7 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.settingsManager.videoSettings.udpPort.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 0 + visible: QGroundControl.settingsManager.videoSettings.udpPort.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 1 QGCLabel { text: qsTr("UDP Port:") width: _labelWidth @@ -543,7 +543,7 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.settingsManager.videoSettings.rtspUrl.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 1 + visible: QGroundControl.settingsManager.videoSettings.rtspUrl.visible && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex === 2 QGCLabel { anchors.verticalCenter: parent.verticalCenter text: qsTr("RTSP URL:") @@ -557,7 +557,7 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.aspectRatio.visible + visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex && videoSource.currentIndex < 3 && QGroundControl.settingsManager.videoSettings.aspectRatio.visible QGCLabel { text: qsTr("Aspect Ratio:") width: _labelWidth @@ -571,7 +571,7 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.gridLines.visible + visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex && videoSource.currentIndex < 3 && QGroundControl.settingsManager.videoSettings.gridLines.visible QGCLabel { text: qsTr("Grid Lines:") width: _labelWidth @@ -613,7 +613,7 @@ QGCView { anchors.centerIn: parent Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.maxVideoSize.visible + visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex && videoSource.currentIndex < 3 && QGroundControl.settingsManager.videoSettings.maxVideoSize.visible QGCLabel { text: qsTr("Max Storage Usage:") width: _labelWidth @@ -627,7 +627,7 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.recordingFormat.visible + visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex && videoSource.currentIndex < 3 && QGroundControl.settingsManager.videoSettings.recordingFormat.visible QGCLabel { text: qsTr("Video File Format:") width: _labelWidth