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
7d3cb138
Commit
7d3cb138
authored
Oct 28, 2015
by
Gus Grubba
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2133 from dogmaphobic/videoWork
Detect video stream.
parents
2583e66a
3a37fd25
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
24 deletions
+90
-24
FlightDisplayView.qml
src/FlightDisplay/FlightDisplayView.qml
+0
-4
FlightDisplayViewController.cc
src/FlightDisplay/FlightDisplayViewController.cc
+33
-0
FlightDisplayViewController.h
src/FlightDisplay/FlightDisplayViewController.h
+15
-0
FlightDisplayViewVideo.qml
src/FlightDisplay/FlightDisplayViewVideo.qml
+33
-17
QGCVideoBackground.qml
src/FlightMap/QGCVideoBackground.qml
+4
-3
VideoSurface.cc
src/VideoStreaming/VideoSurface.cc
+2
-0
VideoSurface.h
src/VideoStreaming/VideoSurface.h
+3
-0
No files found.
src/FlightDisplay/FlightDisplayView.qml
View file @
7d3cb138
...
@@ -116,7 +116,6 @@ Item {
...
@@ -116,7 +116,6 @@ Item {
_flightMap
.
updateMapPosition
(
true
/* force */
)
_flightMap
.
updateMapPosition
(
true
/* force */
)
}
else
{
}
else
{
_flightVideo
=
item
_flightVideo
=
item
_flightVideo
.
visible
=
true
}
}
}
}
}
}
...
@@ -146,20 +145,17 @@ Item {
...
@@ -146,20 +145,17 @@ Item {
onLoaded
:
{
onLoaded
:
{
if
(
_mainIsMap
)
{
if
(
_mainIsMap
)
{
_flightVideo
=
item
_flightVideo
=
item
_flightVideo
.
visible
=
true
}
else
{
}
else
{
_flightMap
=
item
_flightMap
=
item
_savedZoomLevel
=
_flightMap
.
zoomLevel
_savedZoomLevel
=
_flightMap
.
zoomLevel
_flightMap
.
zoomLevel
=
_savedZoomLevel
-
3
_flightMap
.
zoomLevel
=
_savedZoomLevel
-
3
}
}
pip
.
visible
=
_controller
.
hasVideo
}
}
}
}
MouseArea
{
MouseArea
{
anchors.fill
:
parent
anchors.fill
:
parent
onClicked
:
{
onClicked
:
{
_mainIsMap
=
!
_mainIsMap
_mainIsMap
=
!
_mainIsMap
pip
.
visible
=
false
reloadContents
();
reloadContents
();
QGroundControl
.
saveBoolGlobalSetting
(
_mainIsMapKey
,
_mainIsMap
)
QGroundControl
.
saveBoolGlobalSetting
(
_mainIsMapKey
,
_mainIsMap
)
}
}
...
...
src/FlightDisplay/FlightDisplayViewController.cc
View file @
7d3cb138
...
@@ -34,6 +34,7 @@ const char* kMainFlightDisplayViewControllerGroup = "FlightDisplayViewController
...
@@ -34,6 +34,7 @@ const char* kMainFlightDisplayViewControllerGroup = "FlightDisplayViewController
FlightDisplayViewController
::
FlightDisplayViewController
(
QObject
*
parent
)
FlightDisplayViewController
::
FlightDisplayViewController
(
QObject
*
parent
)
:
QObject
(
parent
)
:
QObject
(
parent
)
,
_videoRunning
(
false
)
{
{
/*
/*
* This is the receiving end of an UDP RTP stream. The sender can be setup with this command:
* This is the receiving end of an UDP RTP stream. The sender can be setup with this command:
...
@@ -65,6 +66,8 @@ FlightDisplayViewController::FlightDisplayViewController(QObject *parent)
...
@@ -65,6 +66,8 @@ FlightDisplayViewController::FlightDisplayViewController(QObject *parent)
_videoReceiver
->
setUri
(
QLatin1Literal
(
"udp://0.0.0.0:5000"
));
_videoReceiver
->
setUri
(
QLatin1Literal
(
"udp://0.0.0.0:5000"
));
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
_videoReceiver
->
setVideoSink
(
_videoSurface
->
videoSink
());
_videoReceiver
->
setVideoSink
(
_videoSurface
->
videoSink
());
connect
(
&
_frameTimer
,
&
QTimer
::
timeout
,
this
,
&
FlightDisplayViewController
::
_updateTimer
);
_frameTimer
.
start
(
1000
);
#endif
#endif
}
}
...
@@ -72,3 +75,33 @@ FlightDisplayViewController::~FlightDisplayViewController()
...
@@ -72,3 +75,33 @@ FlightDisplayViewController::~FlightDisplayViewController()
{
{
}
}
#if defined(QGC_GST_STREAMING)
void
FlightDisplayViewController
::
_updateTimer
(
void
)
{
if
(
_videoRunning
)
{
time_t
elapsed
=
0
;
if
(
_videoSurface
)
{
elapsed
=
time
(
0
)
-
_videoSurface
->
lastFrame
();
}
if
(
elapsed
>
2
)
{
_videoRunning
=
false
;
_videoSurface
->
setLastFrame
(
0
);
emit
videoRunningChanged
();
}
}
else
{
if
(
_videoSurface
&&
_videoSurface
->
lastFrame
())
{
if
(
!
_videoRunning
)
{
_videoRunning
=
true
;
emit
videoRunningChanged
();
}
}
}
}
#endif
src/FlightDisplay/FlightDisplayViewController.h
View file @
7d3cb138
...
@@ -25,6 +25,7 @@ This file is part of the QGROUNDCONTROL project
...
@@ -25,6 +25,7 @@ This file is part of the QGROUNDCONTROL project
#define FlightDisplayViewController_H
#define FlightDisplayViewController_H
#include <QObject>
#include <QObject>
#include <QTimer>
#include "VideoSurface.h"
#include "VideoSurface.h"
#include "VideoReceiver.h"
#include "VideoReceiver.h"
...
@@ -42,15 +43,29 @@ public:
...
@@ -42,15 +43,29 @@ public:
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
videoRunning
READ
videoRunning
NOTIFY
videoRunningChanged
)
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
bool
hasVideo
()
{
return
true
;
}
bool
hasVideo
()
{
return
true
;
}
#else
#else
bool
hasVideo
()
{
return
false
;
}
bool
hasVideo
()
{
return
false
;
}
#endif
#endif
bool
videoRunning
()
{
return
_videoRunning
;
}
signals:
void
videoRunningChanged
();
private:
void
_updateTimer
(
void
);
private:
private:
VideoSurface
*
_videoSurface
;
VideoSurface
*
_videoSurface
;
VideoReceiver
*
_videoReceiver
;
VideoReceiver
*
_videoReceiver
;
bool
_videoRunning
;
#if defined(QGC_GST_STREAMING)
QTimer
_frameTimer
;
#endif
};
};
#endif
#endif
src/FlightDisplay/FlightDisplayViewVideo.qml
View file @
7d3cb138
...
@@ -34,22 +34,38 @@ import QGroundControl.Vehicle 1.0
...
@@ -34,22 +34,38 @@ import QGroundControl.Vehicle 1.0
import
QGroundControl
.
Controllers
1.0
import
QGroundControl
.
Controllers
1.0
QGCVideoBackground
{
Item
{
anchors.fill
:
parent
id
:
root
display
:
_controller
.
videoSurface
Rectangle
{
receiver
:
_controller
.
videoReceiver
id
:
noVideo
anchors.fill
:
parent
/* TODO: Come up with a way to make this an option
color
:
"
black
"
QGCAttitudeHUD {
visible
:
!
_controller
.
videoRunning
id: attitudeHUD
QGCLabel
{
visible: !_mainIsMap
text
:
"
NO VIDEO
"
rollAngle: _roll
font.weight
:
Font
.
DemiBold
pitchAngle: _pitch
color
:
"
white
"
width: ScreenTools.defaultFontPixelSize * (30)
font.pixelSize
:
ScreenTools
.
defaultFontPixelSize
*
1.5
height: ScreenTools.defaultFontPixelSize * (30)
anchors.centerIn
:
parent
active: multiVehicleManager.activeVehicleAvailable
}
z: QGroundControl.zOrderWidgets
}
QGCVideoBackground
{
anchors.fill
:
parent
display
:
_controller
.
videoSurface
receiver
:
_controller
.
videoReceiver
visible
:
_controller
.
videoRunning
runVideo
:
true
/* TODO: Come up with a way to make this an option
QGCAttitudeHUD {
id: attitudeHUD
visible: !_mainIsMap
rollAngle: _roll
pitchAngle: _pitch
width: ScreenTools.defaultFontPixelSize * (30)
height: ScreenTools.defaultFontPixelSize * (30)
active: multiVehicleManager.activeVehicleAvailable
z: QGroundControl.zOrderWidgets
}
*/
}
}
*/
}
}
src/FlightMap/QGCVideoBackground.qml
View file @
7d3cb138
...
@@ -35,10 +35,11 @@ VideoItem {
...
@@ -35,10 +35,11 @@ VideoItem {
id
:
videoBackground
id
:
videoBackground
property
var
display
property
var
display
property
var
receiver
property
var
receiver
property
var
runVideo
:
false
surface
:
display
surface
:
display
on
Visible
Changed
:
{
on
RunVideo
Changed
:
{
if
(
videoBackground
.
receiver
&&
videoBackground
.
display
)
{
if
(
videoBackground
.
receiver
&&
videoBackground
.
display
)
{
if
(
videoBackground
.
visible
)
{
if
(
videoBackground
.
runVideo
)
{
videoBackground
.
receiver
.
start
();
videoBackground
.
receiver
.
start
();
}
else
{
}
else
{
videoBackground
.
receiver
.
stop
();
videoBackground
.
receiver
.
stop
();
...
@@ -46,7 +47,7 @@ VideoItem {
...
@@ -46,7 +47,7 @@ VideoItem {
}
}
}
}
Component.onCompleted
:
{
Component.onCompleted
:
{
if
(
videoBackground
.
visible
&&
videoBackground
.
receiver
)
{
if
(
videoBackground
.
runVideo
&&
videoBackground
.
receiver
)
{
videoBackground
.
receiver
.
start
();
videoBackground
.
receiver
.
start
();
}
}
}
}
...
...
src/VideoStreaming/VideoSurface.cc
View file @
7d3cb138
...
@@ -39,6 +39,7 @@ VideoSurface::VideoSurface(QObject *parent)
...
@@ -39,6 +39,7 @@ VideoSurface::VideoSurface(QObject *parent)
:
QObject
(
parent
)
:
QObject
(
parent
)
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
,
_data
(
new
VideoSurfacePrivate
)
,
_data
(
new
VideoSurfacePrivate
)
,
_lastFrame
(
0
)
#endif
#endif
{
{
}
}
...
@@ -68,6 +69,7 @@ GstElement* VideoSurface::videoSink() const
...
@@ -68,6 +69,7 @@ GstElement* VideoSurface::videoSink() const
void
VideoSurface
::
onUpdate
()
void
VideoSurface
::
onUpdate
()
{
{
_lastFrame
=
time
(
0
);
Q_FOREACH
(
QQuickItem
*
item
,
_data
->
items
)
{
Q_FOREACH
(
QQuickItem
*
item
,
_data
->
items
)
{
item
->
update
();
item
->
update
();
}
}
...
...
src/VideoStreaming/VideoSurface.h
View file @
7d3cb138
...
@@ -54,6 +54,8 @@ public:
...
@@ -54,6 +54,8 @@ public:
*/
*/
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
GstElement
*
videoSink
()
const
;
GstElement
*
videoSink
()
const
;
time_t
lastFrame
()
{
return
_lastFrame
;
}
void
setLastFrame
(
time_t
t
)
{
_lastFrame
=
t
;
}
#endif
#endif
protected:
protected:
...
@@ -66,6 +68,7 @@ private:
...
@@ -66,6 +68,7 @@ private:
friend
class
VideoItem
;
friend
class
VideoItem
;
#if defined(QGC_GST_STREAMING)
#if defined(QGC_GST_STREAMING)
VideoSurfacePrivate
*
const
_data
;
VideoSurfacePrivate
*
const
_data
;
time_t
_lastFrame
;
#endif
#endif
};
};
...
...
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