Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3b025c14
Commit
3b025c14
authored
Nov 29, 2017
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make video enable persistent.
parent
ee922ff7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
87 additions
and
35 deletions
+87
-35
FlightDisplayViewVideo.qml
src/FlightDisplay/FlightDisplayViewVideo.qml
+1
-1
VideoPageWidget.qml
src/FlightMap/Widgets/VideoPageWidget.qml
+14
-8
Video.SettingsGroup.json
src/Settings/Video.SettingsGroup.json
+7
-0
VideoSettings.cc
src/Settings/VideoSettings.cc
+43
-11
VideoSettings.h
src/Settings/VideoSettings.h
+13
-1
VideoReceiver.cc
src/VideoStreaming/VideoReceiver.cc
+9
-9
VideoReceiver.h
src/VideoStreaming/VideoReceiver.h
+0
-5
No files found.
src/FlightDisplay/FlightDisplayViewVideo.qml
View file @
3b025c14
...
...
@@ -34,7 +34,7 @@ Item {
color
:
Qt
.
rgba
(
0
,
0
,
0
,
0.75
)
visible
:
!
(
_videoReceiver
&&
_videoReceiver
.
videoRunning
)
QGCLabel
{
text
:
_videoReceiver
&&
_videoReceiver
.
enabled
?
qsTr
(
"
WAITING FOR VIDEO
"
)
:
qsTr
(
"
VIDEO DISABLED
"
)
text
:
QGroundControl
.
settingsManager
.
videoSettings
.
streamEnabled
.
rawValue
?
qsTr
(
"
WAITING FOR VIDEO
"
)
:
qsTr
(
"
VIDEO DISABLED
"
)
font.family
:
ScreenTools
.
demiboldFontFamily
color
:
"
white
"
font.pointSize
:
_mainIsMap
?
ScreenTools
.
smallFontPointSize
:
ScreenTools
.
largeFontPointSize
...
...
src/FlightMap/Widgets/VideoPageWidget.qml
View file @
3b025c14
...
...
@@ -36,8 +36,9 @@ Item {
property
var
_videoReceiver
:
QGroundControl
.
videoManager
.
videoReceiver
property
bool
_recordingVideo
:
_videoReceiver
&&
_videoReceiver
.
recording
property
bool
_videoRunning
:
_videoReceiver
&&
_videoReceiver
.
videoRunning
property
bool
_streamingEnabled
:
QGroundControl
.
settingsManager
.
videoSettings
.
streamConfigured
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
parent
.
enabled
}
QGCPalette
{
id
:
qgcPal
;
colorGroupEnabled
:
true
}
GridLayout
{
id
:
videoGrid
...
...
@@ -50,12 +51,14 @@ Item {
font.pointSize
:
ScreenTools
.
smallFontPointSize
}
Switch
{
checked
:
_videoRunning
enabled
:
_activeVehicl
e
enabled
:
_streamingEnabled
&&
_activeVehicle
checked
:
QGroundControl
.
settingsManager
.
videoSettings
.
streamEnabled
.
rawValu
e
onClicked
:
{
if
(
checked
)
{
QGroundControl
.
settingsManager
.
videoSettings
.
streamEnabled
.
rawValue
=
1
_videoReceiver
.
start
()
}
else
{
QGroundControl
.
settingsManager
.
videoSettings
.
streamEnabled
.
rawValue
=
0
_videoReceiver
.
stop
()
}
}
...
...
@@ -82,14 +85,13 @@ Item {
width
:
height
Layout.alignment
:
Qt
.
AlignHCenter
visible
:
QGroundControl
.
settingsManager
.
videoSettings
.
showRecControl
.
rawValue
Rectangle
{
id
:
recordBtnBackground
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
width
:
height
radius
:
_recordingVideo
?
0
:
height
color
:
_videoRunning
?
"
red
"
:
"
gray
"
color
:
(
_videoRunning
&&
_streamingEnabled
)
?
"
red
"
:
"
gray
"
SequentialAnimation
on
opacity
{
running
:
_recordingVideo
loops
:
Animation
.
Infinite
...
...
@@ -97,7 +99,6 @@ Item {
PropertyAnimation
{
to
:
1.0
;
duration
:
500
}
}
}
QGCColoredImage
{
anchors.top
:
parent
.
top
anchors.bottom
:
parent
.
bottom
...
...
@@ -109,10 +110,9 @@ Item {
fillMode
:
Image
.
PreserveAspectFit
color
:
"
white
"
}
MouseArea
{
anchors.fill
:
parent
enabled
:
_videoRunning
enabled
:
_videoRunning
&&
_streamingEnabled
onClicked
:
{
if
(
_recordingVideo
)
{
_videoReceiver
.
stopRecording
()
...
...
@@ -124,5 +124,11 @@ Item {
}
}
}
QGCLabel
{
text
:
qsTr
(
"
Video Streaming Not Configured
"
)
font.pointSize
:
ScreenTools
.
smallFontPointSize
visible
:
!
_streamingEnabled
Layout.columnSpan
:
2
}
}
}
src/Settings/Video.SettingsGroup.json
View file @
3b025c14
...
...
@@ -94,5 +94,12 @@
"min"
:
1
,
"units"
:
"s"
,
"defaultValue"
:
2
},
{
"name"
:
"StreamEnabled"
,
"shortDescription"
:
"Video Stream Enabled"
,
"longDescription"
:
"Start/Stop Video Stream."
,
"type"
:
"bool"
,
"defaultValue"
:
true
}
]
src/Settings/VideoSettings.cc
View file @
3b025c14
...
...
@@ -30,6 +30,7 @@ const char* VideoSettings::recordingFormatName = "RecordingFormat";
const
char
*
VideoSettings
::
maxVideoSizeName
=
"MaxVideoSize"
;
const
char
*
VideoSettings
::
enableStorageLimitName
=
"EnableStorageLimit"
;
const
char
*
VideoSettings
::
rtspTimeoutName
=
"RtspTimeout"
;
const
char
*
VideoSettings
::
streamEnabledName
=
"StreamEnabled"
;
const
char
*
VideoSettings
::
videoSourceNoVideo
=
"No Video Available"
;
const
char
*
VideoSettings
::
videoDisabled
=
"Video Stream Disabled"
;
...
...
@@ -50,6 +51,7 @@ VideoSettings::VideoSettings(QObject* parent)
,
_maxVideoSizeFact
(
NULL
)
,
_enableStorageLimitFact
(
NULL
)
,
_rtspTimeoutFact
(
NULL
)
,
_streamEnabledFact
(
NULL
)
{
QQmlEngine
::
setObjectOwnership
(
this
,
QQmlEngine
::
CppOwnership
);
qmlRegisterUncreatableType
<
VideoSettings
>
(
"QGroundControl.SettingsManager"
,
1
,
0
,
"VideoSettings"
,
"Reference only"
);
...
...
@@ -94,8 +96,8 @@ Fact* VideoSettings::videoSource(void)
{
if
(
!
_videoSourceFact
)
{
_videoSourceFact
=
_createSettingsFact
(
videoSourceName
);
connect
(
_videoSourceFact
,
&
Fact
::
valueChanged
,
this
,
&
VideoSettings
::
_configChanged
);
}
return
_videoSourceFact
;
}
...
...
@@ -103,8 +105,8 @@ Fact* VideoSettings::udpPort(void)
{
if
(
!
_udpPortFact
)
{
_udpPortFact
=
_createSettingsFact
(
udpPortName
);
connect
(
_udpPortFact
,
&
Fact
::
valueChanged
,
this
,
&
VideoSettings
::
_configChanged
);
}
return
_udpPortFact
;
}
...
...
@@ -112,8 +114,8 @@ Fact* VideoSettings::rtspUrl(void)
{
if
(
!
_rtspUrlFact
)
{
_rtspUrlFact
=
_createSettingsFact
(
rtspUrlName
);
connect
(
_rtspUrlFact
,
&
Fact
::
valueChanged
,
this
,
&
VideoSettings
::
_configChanged
);
}
return
_rtspUrlFact
;
}
...
...
@@ -121,8 +123,8 @@ Fact* VideoSettings::tcpUrl(void)
{
if
(
!
_tcpUrlFact
)
{
_tcpUrlFact
=
_createSettingsFact
(
tcpUrlName
);
connect
(
_tcpUrlFact
,
&
Fact
::
valueChanged
,
this
,
&
VideoSettings
::
_configChanged
);
}
return
_tcpUrlFact
;
}
...
...
@@ -131,7 +133,6 @@ Fact* VideoSettings::aspectRatio(void)
if
(
!
_videoAspectRatioFact
)
{
_videoAspectRatioFact
=
_createSettingsFact
(
videoAspectRatioName
);
}
return
_videoAspectRatioFact
;
}
...
...
@@ -140,7 +141,6 @@ Fact* VideoSettings::gridLines(void)
if
(
!
_gridLinesFact
)
{
_gridLinesFact
=
_createSettingsFact
(
videoGridLinesName
);
}
return
_gridLinesFact
;
}
...
...
@@ -149,7 +149,6 @@ Fact* VideoSettings::showRecControl(void)
if
(
!
_showRecControlFact
)
{
_showRecControlFact
=
_createSettingsFact
(
showRecControlName
);
}
return
_showRecControlFact
;
}
...
...
@@ -158,7 +157,6 @@ Fact* VideoSettings::recordingFormat(void)
if
(
!
_recordingFormatFact
)
{
_recordingFormatFact
=
_createSettingsFact
(
recordingFormatName
);
}
return
_recordingFormatFact
;
}
...
...
@@ -167,7 +165,6 @@ Fact* VideoSettings::maxVideoSize(void)
if
(
!
_maxVideoSizeFact
)
{
_maxVideoSizeFact
=
_createSettingsFact
(
maxVideoSizeName
);
}
return
_maxVideoSizeFact
;
}
...
...
@@ -176,7 +173,6 @@ Fact* VideoSettings::enableStorageLimit(void)
if
(
!
_enableStorageLimitFact
)
{
_enableStorageLimitFact
=
_createSettingsFact
(
enableStorageLimitName
);
}
return
_enableStorageLimitFact
;
}
...
...
@@ -185,6 +181,42 @@ Fact* VideoSettings::rtspTimeout(void)
if
(
!
_rtspTimeoutFact
)
{
_rtspTimeoutFact
=
_createSettingsFact
(
rtspTimeoutName
);
}
return
_rtspTimeoutFact
;
}
Fact
*
VideoSettings
::
streamEnabled
(
void
)
{
if
(
!
_streamEnabledFact
)
{
_streamEnabledFact
=
_createSettingsFact
(
streamEnabledName
);
}
return
_streamEnabledFact
;
}
bool
VideoSettings
::
streamConfigured
(
void
)
{
#if !defined(QGC_GST_STREAMING)
return
false
;
#endif
QString
vSource
=
videoSource
()
->
rawValue
().
toString
();
if
(
vSource
==
videoSourceNoVideo
||
vSource
==
videoDisabled
)
{
return
false
;
}
//-- If UDP, check if port is set
if
(
vSource
==
videoSourceUDP
)
{
return
udpPort
()
->
rawValue
().
toInt
()
!=
0
;
}
//-- If RTSP, check for URL
if
(
vSource
==
videoSourceRTSP
)
{
return
!
rtspUrl
()
->
rawValue
().
toString
().
isEmpty
();
}
//-- If TCP, check for URL
if
(
vSource
==
videoSourceTCP
)
{
return
!
tcpUrl
()
->
rawValue
().
toString
().
isEmpty
();
}
return
false
;
}
void
VideoSettings
::
_configChanged
(
QVariant
)
{
emit
streamConfiguredChanged
();
}
src/Settings/VideoSettings.h
View file @
3b025c14
...
...
@@ -30,6 +30,8 @@ public:
Q_PROPERTY
(
Fact
*
maxVideoSize
READ
maxVideoSize
CONSTANT
)
Q_PROPERTY
(
Fact
*
enableStorageLimit
READ
enableStorageLimit
CONSTANT
)
Q_PROPERTY
(
Fact
*
rtspTimeout
READ
rtspTimeout
CONSTANT
)
Q_PROPERTY
(
Fact
*
streamEnabled
READ
streamEnabled
CONSTANT
)
Q_PROPERTY
(
bool
streamConfigured
READ
streamConfigured
NOTIFY
streamConfiguredChanged
)
Fact
*
videoSource
(
void
);
Fact
*
udpPort
(
void
);
...
...
@@ -41,7 +43,9 @@ public:
Fact
*
recordingFormat
(
void
);
Fact
*
maxVideoSize
(
void
);
Fact
*
enableStorageLimit
(
void
);
Fact
*
rtspTimeout
(
void
);
Fact
*
rtspTimeout
(
void
);
Fact
*
streamEnabled
(
void
);
bool
streamConfigured
(
void
);
static
const
char
*
videoSettingsGroupName
;
...
...
@@ -56,6 +60,7 @@ public:
static
const
char
*
maxVideoSizeName
;
static
const
char
*
enableStorageLimitName
;
static
const
char
*
rtspTimeoutName
;
static
const
char
*
streamEnabledName
;
static
const
char
*
videoSourceNoVideo
;
static
const
char
*
videoDisabled
;
...
...
@@ -63,6 +68,12 @@ public:
static
const
char
*
videoSourceRTSP
;
static
const
char
*
videoSourceTCP
;
signals:
void
streamConfiguredChanged
();
private
slots
:
void
_configChanged
(
QVariant
value
);
private:
SettingsFact
*
_videoSourceFact
;
SettingsFact
*
_udpPortFact
;
...
...
@@ -75,6 +86,7 @@ private:
SettingsFact
*
_maxVideoSizeFact
;
SettingsFact
*
_enableStorageLimitFact
;
SettingsFact
*
_rtspTimeoutFact
;
SettingsFact
*
_streamEnabledFact
;
};
#endif
src/VideoStreaming/VideoReceiver.cc
View file @
3b025c14
...
...
@@ -67,7 +67,6 @@ VideoReceiver::VideoReceiver(QObject* parent)
,
_videoSurface
(
NULL
)
,
_videoRunning
(
false
)
,
_showFullScreen
(
false
)
,
_enabled
(
true
)
{
_videoSurface
=
new
VideoSurface
;
#if defined(QGC_GST_STREAMING)
...
...
@@ -148,7 +147,7 @@ VideoReceiver::_connected()
_timer
.
stop
();
_socket
->
deleteLater
();
_socket
=
NULL
;
if
(
_enabled
)
{
if
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
streamEnabled
()
->
rawValue
().
toBool
()
)
{
_serverPresent
=
true
;
start
();
}
...
...
@@ -164,7 +163,7 @@ VideoReceiver::_socketError(QAbstractSocket::SocketError socketError)
_socket
->
deleteLater
();
_socket
=
NULL
;
//-- Try again in 5 seconds
if
(
_enabled
)
{
if
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
streamEnabled
()
->
rawValue
().
toBool
()
)
{
_timer
.
start
(
5000
);
}
}
...
...
@@ -180,7 +179,7 @@ VideoReceiver::_timeout()
delete
_socket
;
_socket
=
NULL
;
}
if
(
_enabled
)
{
if
(
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
streamEnabled
()
->
rawValue
().
toBool
()
)
{
//-- RTSP will try to connect to the server. If it cannot connect,
// it will simply give up and never try again. Instead, we keep
// attempting a connection on this timer. Once a connection is
...
...
@@ -209,8 +208,11 @@ VideoReceiver::_timeout()
void
VideoReceiver
::
start
()
{
_enabled
=
true
;
emit
enabledChanged
();
if
(
!
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
streamEnabled
()
->
rawValue
().
toBool
()
||
!
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
streamConfigured
())
{
qCDebug
(
VideoReceiverLog
)
<<
"start() but not enabled/configured"
;
return
;
}
#if defined(QGC_GST_STREAMING)
qCDebug
(
VideoReceiverLog
)
<<
"start()"
;
...
...
@@ -424,8 +426,6 @@ VideoReceiver::start()
void
VideoReceiver
::
stop
()
{
_enabled
=
false
;
emit
enabledChanged
();
#if defined(QGC_GST_STREAMING)
qCDebug
(
VideoReceiverLog
)
<<
"stop()"
;
if
(
!
_streaming
)
{
...
...
@@ -824,7 +824,7 @@ VideoReceiver::_updateTimer()
stop
();
}
}
else
{
if
(
!
running
()
&&
!
_uri
.
isEmpty
()
&&
_enabled
)
{
if
(
!
running
()
&&
!
_uri
.
isEmpty
()
&&
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
videoSettings
()
->
streamEnabled
()
->
rawValue
().
toBool
()
)
{
start
();
}
}
...
...
src/VideoStreaming/VideoReceiver.h
View file @
3b025c14
...
...
@@ -41,7 +41,6 @@ public:
Q_PROPERTY
(
bool
videoRunning
READ
videoRunning
NOTIFY
videoRunningChanged
)
Q_PROPERTY
(
QString
imageFile
READ
imageFile
NOTIFY
imageFileChanged
)
Q_PROPERTY
(
bool
showFullScreen
READ
showFullScreen
WRITE
setShowFullScreen
NOTIFY
showFullScreenChanged
)
Q_PROPERTY
(
bool
enabled
READ
enabled
NOTIFY
enabledChanged
)
explicit
VideoReceiver
(
QObject
*
parent
=
0
);
~
VideoReceiver
();
...
...
@@ -58,7 +57,6 @@ public:
bool
videoRunning
()
{
return
_videoRunning
;
}
QString
imageFile
()
{
return
_imageFile
;
}
bool
showFullScreen
()
{
return
_showFullScreen
;
}
bool
enabled
()
{
return
_enabled
;
}
void
grabImage
(
QString
imageFile
);
...
...
@@ -68,7 +66,6 @@ signals:
void
videoRunningChanged
();
void
imageFileChanged
();
void
showFullScreenChanged
();
void
enabledChanged
();
#if defined(QGC_GST_STREAMING)
void
recordingChanged
();
void
msgErrorReceived
();
...
...
@@ -140,8 +137,6 @@ private:
VideoSurface
*
_videoSurface
;
bool
_videoRunning
;
bool
_showFullScreen
;
bool
_enabled
;
};
#endif // VIDEORECEIVER_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment