From 083af0b305d3604d606bd5c307c80a25e2cf9219 Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sat, 25 Feb 2017 16:39:50 -0500 Subject: [PATCH 1/2] Allow setting the video streaming aspect ratio. --- src/FlightDisplay/FlightDisplayViewVideo.qml | 26 +++++++++++--------------- src/Settings/Video.SettingsGroup.json | 8 ++++++++ src/Settings/VideoSettings.cc | 19 +++++++++++++++---- src/Settings/VideoSettings.h | 6 +++++- src/ui/preferences/GeneralSettings.qml | 14 ++++++++++++++ 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/FlightDisplay/FlightDisplayViewVideo.qml b/src/FlightDisplay/FlightDisplayViewVideo.qml index 86d08af..65d9af2 100644 --- a/src/FlightDisplay/FlightDisplayViewVideo.qml +++ b/src/FlightDisplay/FlightDisplayViewVideo.qml @@ -23,35 +23,31 @@ import QGroundControl.Controllers 1.0 Item { id: root + property double _ar: QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue Rectangle { id: noVideo anchors.fill: parent color: Qt.rgba(0,0,0,0.75) visible: !QGroundControl.videoManager.videoRunning QGCLabel { - text: qsTr("NO VIDEO") + text: qsTr("WAITING FOR VIDEO") font.family: ScreenTools.demiboldFontFamily color: "white" font.pointSize: _mainIsMap ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize anchors.centerIn: parent } } - QGCVideoBackground { + Rectangle { anchors.fill: parent - display: QGroundControl.videoManager.videoSurface - receiver: QGroundControl.videoManager.videoReceiver + color: "black" visible: QGroundControl.videoManager.videoRunning - /* TODO: Come up with a way to make this an option - QGCAttitudeHUD { - id: attitudeHUD - visible: !_mainIsMap - rollAngle: _activeVehicle ? _activeVehicle.roll.value : 0 - pitchAngle: _activeVehicle ? _activeVehicle.pitch.value : 0 - width: ScreenTools.defaultFontPixelHeight * (30) - height: ScreenTools.defaultFontPixelHeight * (30) - active: QGroundControl.multiVehicleManager.activeVehicleAvailable - z: QGroundControl.zOrderWidgets + QGCVideoBackground { + height: parent.height + width: _ar != 0.0 ? height * _ar : parent.width + anchors.centerIn: parent + display: QGroundControl.videoManager.videoSurface + receiver: QGroundControl.videoManager.videoReceiver + visible: QGroundControl.videoManager.videoRunning } - */ } } diff --git a/src/Settings/Video.SettingsGroup.json b/src/Settings/Video.SettingsGroup.json index c9835ee..17e8254 100644 --- a/src/Settings/Video.SettingsGroup.json +++ b/src/Settings/Video.SettingsGroup.json @@ -27,5 +27,13 @@ "longDescription": "Directory to save videos to.", "type": "string", "defaultValue": "" +}, +{ + "name": "VideoAspectRatio", + "shortDescription": "Video Aspect Ratio", + "longDescription": "Video Aspect Ratio (width / height). Use 0.0 to ignore it.", + "type": "float", + "decimalPlaces": 6, + "defaultValue": 1.777777 } ] diff --git a/src/Settings/VideoSettings.cc b/src/Settings/VideoSettings.cc index 190c87f..f36751d 100644 --- a/src/Settings/VideoSettings.cc +++ b/src/Settings/VideoSettings.cc @@ -19,10 +19,11 @@ const char* VideoSettings::videoSettingsGroupName = "Video"; -const char* VideoSettings::videoSourceName = "VideoSource"; -const char* VideoSettings::udpPortName = "VideoUDPPort"; -const char* VideoSettings::rtspUrlName = "VideoRTSPUrl"; -const char* VideoSettings::videoSavePathName = "VideoSavePath"; +const char* VideoSettings::videoSourceName = "VideoSource"; +const char* VideoSettings::udpPortName = "VideoUDPPort"; +const char* VideoSettings::rtspUrlName = "VideoRTSPUrl"; +const char* VideoSettings::videoSavePathName = "VideoSavePath"; +const char* VideoSettings::videoAspectRatioName = "VideoAspectRatio"; const char* VideoSettings::videoSourceNoVideo = "No Video Available"; const char* VideoSettings::videoSourceUDP = "UDP Video Stream"; @@ -34,6 +35,7 @@ VideoSettings::VideoSettings(QObject* parent) , _udpPortFact(NULL) , _rtspUrlFact(NULL) , _videoSavePathFact(NULL) + , _videoAspectRatioFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only"); @@ -104,3 +106,12 @@ Fact* VideoSettings::videoSavePath(void) return _videoSavePathFact; } + +Fact* VideoSettings::aspectRatio(void) +{ + if (!_videoAspectRatioFact) { + _videoAspectRatioFact = _createSettingsFact(videoAspectRatioName); + } + + return _videoAspectRatioFact; +} diff --git a/src/Settings/VideoSettings.h b/src/Settings/VideoSettings.h index df38217..d914fc7 100644 --- a/src/Settings/VideoSettings.h +++ b/src/Settings/VideoSettings.h @@ -15,7 +15,7 @@ class VideoSettings : public SettingsGroup { Q_OBJECT - + public: VideoSettings(QObject* parent = NULL); @@ -23,11 +23,13 @@ public: Q_PROPERTY(Fact* udpPort READ udpPort CONSTANT) Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT) Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT) + Q_PROPERTY(Fact* aspectRatio READ aspectRatio CONSTANT) Fact* videoSource (void); Fact* udpPort (void); Fact* rtspUrl (void); Fact* videoSavePath (void); + Fact* aspectRatio (void); static const char* videoSettingsGroupName; @@ -35,6 +37,7 @@ public: static const char* udpPortName; static const char* rtspUrlName; static const char* videoSavePathName; + static const char* videoAspectRatioName; static const char* videoSourceNoVideo; static const char* videoSourceUDP; @@ -45,6 +48,7 @@ private: SettingsFact* _udpPortFact; SettingsFact* _rtspUrlFact; SettingsFact* _videoSavePathFact; + SettingsFact* _videoAspectRatioFact; }; #endif diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index a83ceb5..3190493 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -505,6 +505,20 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth + visible: QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 + QGCLabel { + anchors.baseline: aspectField.baseline + text: qsTr("Aspect Ratio:") + width: _labelWidth + } + FactTextField { + id: aspectField + width: _editFieldWidth + fact: QGroundControl.settingsManager.videoSettings.aspectRatio + } + } + Row { + spacing: ScreenTools.defaultFontPixelWidth visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled QGCLabel { anchors.baseline: pathField.baseline From 9935949a6f704445a5b0d9d69c69c6a2c41791cc Mon Sep 17 00:00:00 2001 From: Gus Grubba Date: Sun, 26 Feb 2017 15:54:52 -0500 Subject: [PATCH 2/2] Check for visibility and remove duplicated test. --- src/ui/preferences/GeneralSettings.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ui/preferences/GeneralSettings.qml b/src/ui/preferences/GeneralSettings.qml index 3190493..85186ba 100644 --- a/src/ui/preferences/GeneralSettings.qml +++ b/src/ui/preferences/GeneralSettings.qml @@ -505,7 +505,7 @@ QGCView { } Row { spacing: ScreenTools.defaultFontPixelWidth - visible: QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 + visible: QGroundControl.videoManager.isGStreamer && videoSource.currentIndex < 2 && QGroundControl.settingsManager.videoSettings.aspectRatio.visible QGCLabel { anchors.baseline: aspectField.baseline text: qsTr("Aspect Ratio:")