Commit 083af0b3 authored by Gus Grubba's avatar Gus Grubba

Allow setting the video streaming aspect ratio.

parent 8d5151b8
...@@ -23,35 +23,31 @@ import QGroundControl.Controllers 1.0 ...@@ -23,35 +23,31 @@ import QGroundControl.Controllers 1.0
Item { Item {
id: root id: root
property double _ar: QGroundControl.settingsManager.videoSettings.aspectRatio.rawValue
Rectangle { Rectangle {
id: noVideo id: noVideo
anchors.fill: parent anchors.fill: parent
color: Qt.rgba(0,0,0,0.75) color: Qt.rgba(0,0,0,0.75)
visible: !QGroundControl.videoManager.videoRunning visible: !QGroundControl.videoManager.videoRunning
QGCLabel { QGCLabel {
text: qsTr("NO VIDEO") text: qsTr("WAITING FOR VIDEO")
font.family: ScreenTools.demiboldFontFamily font.family: ScreenTools.demiboldFontFamily
color: "white" color: "white"
font.pointSize: _mainIsMap ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize font.pointSize: _mainIsMap ? ScreenTools.smallFontPointSize : ScreenTools.largeFontPointSize
anchors.centerIn: parent anchors.centerIn: parent
} }
} }
QGCVideoBackground { Rectangle {
anchors.fill: parent anchors.fill: parent
color: "black"
visible: QGroundControl.videoManager.videoRunning
QGCVideoBackground {
height: parent.height
width: _ar != 0.0 ? height * _ar : parent.width
anchors.centerIn: parent
display: QGroundControl.videoManager.videoSurface display: QGroundControl.videoManager.videoSurface
receiver: QGroundControl.videoManager.videoReceiver receiver: QGroundControl.videoManager.videoReceiver
visible: QGroundControl.videoManager.videoRunning 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
} }
*/
} }
} }
...@@ -27,5 +27,13 @@ ...@@ -27,5 +27,13 @@
"longDescription": "Directory to save videos to.", "longDescription": "Directory to save videos to.",
"type": "string", "type": "string",
"defaultValue": "" "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
} }
] ]
...@@ -23,6 +23,7 @@ const char* VideoSettings::videoSourceName = "VideoSource"; ...@@ -23,6 +23,7 @@ const char* VideoSettings::videoSourceName = "VideoSource";
const char* VideoSettings::udpPortName = "VideoUDPPort"; const char* VideoSettings::udpPortName = "VideoUDPPort";
const char* VideoSettings::rtspUrlName = "VideoRTSPUrl"; const char* VideoSettings::rtspUrlName = "VideoRTSPUrl";
const char* VideoSettings::videoSavePathName = "VideoSavePath"; const char* VideoSettings::videoSavePathName = "VideoSavePath";
const char* VideoSettings::videoAspectRatioName = "VideoAspectRatio";
const char* VideoSettings::videoSourceNoVideo = "No Video Available"; const char* VideoSettings::videoSourceNoVideo = "No Video Available";
const char* VideoSettings::videoSourceUDP = "UDP Video Stream"; const char* VideoSettings::videoSourceUDP = "UDP Video Stream";
...@@ -34,6 +35,7 @@ VideoSettings::VideoSettings(QObject* parent) ...@@ -34,6 +35,7 @@ VideoSettings::VideoSettings(QObject* parent)
, _udpPortFact(NULL) , _udpPortFact(NULL)
, _rtspUrlFact(NULL) , _rtspUrlFact(NULL)
, _videoSavePathFact(NULL) , _videoSavePathFact(NULL)
, _videoAspectRatioFact(NULL)
{ {
QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership);
qmlRegisterUncreatableType<VideoSettings>("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only"); qmlRegisterUncreatableType<VideoSettings>("QGroundControl.SettingsManager", 1, 0, "VideoSettings", "Reference only");
...@@ -104,3 +106,12 @@ Fact* VideoSettings::videoSavePath(void) ...@@ -104,3 +106,12 @@ Fact* VideoSettings::videoSavePath(void)
return _videoSavePathFact; return _videoSavePathFact;
} }
Fact* VideoSettings::aspectRatio(void)
{
if (!_videoAspectRatioFact) {
_videoAspectRatioFact = _createSettingsFact(videoAspectRatioName);
}
return _videoAspectRatioFact;
}
...@@ -23,11 +23,13 @@ public: ...@@ -23,11 +23,13 @@ public:
Q_PROPERTY(Fact* udpPort READ udpPort CONSTANT) Q_PROPERTY(Fact* udpPort READ udpPort CONSTANT)
Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT) Q_PROPERTY(Fact* rtspUrl READ rtspUrl CONSTANT)
Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT) Q_PROPERTY(Fact* videoSavePath READ videoSavePath CONSTANT)
Q_PROPERTY(Fact* aspectRatio READ aspectRatio CONSTANT)
Fact* videoSource (void); Fact* videoSource (void);
Fact* udpPort (void); Fact* udpPort (void);
Fact* rtspUrl (void); Fact* rtspUrl (void);
Fact* videoSavePath (void); Fact* videoSavePath (void);
Fact* aspectRatio (void);
static const char* videoSettingsGroupName; static const char* videoSettingsGroupName;
...@@ -35,6 +37,7 @@ public: ...@@ -35,6 +37,7 @@ public:
static const char* udpPortName; static const char* udpPortName;
static const char* rtspUrlName; static const char* rtspUrlName;
static const char* videoSavePathName; static const char* videoSavePathName;
static const char* videoAspectRatioName;
static const char* videoSourceNoVideo; static const char* videoSourceNoVideo;
static const char* videoSourceUDP; static const char* videoSourceUDP;
...@@ -45,6 +48,7 @@ private: ...@@ -45,6 +48,7 @@ private:
SettingsFact* _udpPortFact; SettingsFact* _udpPortFact;
SettingsFact* _rtspUrlFact; SettingsFact* _rtspUrlFact;
SettingsFact* _videoSavePathFact; SettingsFact* _videoSavePathFact;
SettingsFact* _videoAspectRatioFact;
}; };
#endif #endif
...@@ -503,6 +503,20 @@ QGCView { ...@@ -503,6 +503,20 @@ QGCView {
fact: QGroundControl.settingsManager.videoSettings.rtspUrl fact: QGroundControl.settingsManager.videoSettings.rtspUrl
} }
} }
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 { Row {
spacing: ScreenTools.defaultFontPixelWidth spacing: ScreenTools.defaultFontPixelWidth
visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled visible: QGroundControl.settingsManager.videoSettings.videoSavePath.visible && QGroundControl.videoManager.isGStreamer && QGroundControl.videoManager.recordingEnabled
......
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