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
fb03713f
Commit
fb03713f
authored
Feb 25, 2020
by
Andrew Voznytsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch VideoReceiver to new API (big refactoring)
parent
862508fc
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
1542 additions
and
1150 deletions
+1542
-1150
QGCCameraControl.cc
src/Camera/QGCCameraControl.cc
+4
-4
FlightDisplayViewVideo.qml
src/FlightDisplay/FlightDisplayViewVideo.qml
+4
-4
VideoPageWidget.qml
src/FlightMap/Widgets/VideoPageWidget.qml
+5
-5
SubtitleWriter.cc
src/VideoStreaming/SubtitleWriter.cc
+13
-50
SubtitleWriter.h
src/VideoStreaming/SubtitleWriter.h
+3
-10
VideoManager.cc
src/VideoStreaming/VideoManager.cc
+239
-92
VideoManager.h
src/VideoStreaming/VideoManager.h
+24
-5
VideoReceiver.cc
src/VideoStreaming/VideoReceiver.cc
+1122
-831
VideoReceiver.h
src/VideoStreaming/VideoReceiver.h
+125
-149
gstqgcvideosinkbin.c
src/VideoStreaming/gstqgcvideosinkbin.c
+3
-0
No files found.
src/Camera/QGCCameraControl.cc
View file @
fb03713f
...
...
@@ -388,11 +388,11 @@ QGCCameraControl::takePhoto()
_setPhotoStatus
(
PHOTO_CAPTURE_IN_PROGRESS
);
_captureInfoRetries
=
0
;
//-- Capture local image as well
if
(
qgcApp
()
->
toolbox
()
->
videoManager
()
->
videoReceiver
()
)
{
if
(
qgcApp
()
->
toolbox
()
->
videoManager
())
{
QString
photoPath
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
savePath
()
->
rawValue
().
toString
()
+
QStringLiteral
(
"/Photo"
);
QDir
().
mkpath
(
photoPath
);
photoPath
+=
+
"/"
+
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh.mm.ss.zzz"
)
+
".jpg"
;
qgcApp
()
->
toolbox
()
->
videoManager
()
->
videoReceiver
()
->
grabImage
(
photoPath
);
qgcApp
()
->
toolbox
()
->
videoManager
()
->
grabImage
(
photoPath
);
}
return
true
;
}
...
...
@@ -1542,11 +1542,11 @@ QGCCameraControl::handleCaptureStatus(const mavlink_camera_capture_status_t& cap
//-- Time Lapse
if
(
photoStatus
()
==
PHOTO_CAPTURE_INTERVAL_IDLE
||
photoStatus
()
==
PHOTO_CAPTURE_INTERVAL_IN_PROGRESS
)
{
//-- Capture local image as well
if
(
qgcApp
()
->
toolbox
()
->
videoManager
()
->
videoReceiver
()
)
{
if
(
qgcApp
()
->
toolbox
()
->
videoManager
())
{
QString
photoPath
=
qgcApp
()
->
toolbox
()
->
settingsManager
()
->
appSettings
()
->
savePath
()
->
rawValue
().
toString
()
+
QStringLiteral
(
"/Photo"
);
QDir
().
mkpath
(
photoPath
);
photoPath
+=
+
"/"
+
QDateTime
::
currentDateTime
().
toString
(
"yyyy-MM-dd_hh.mm.ss.zzz"
)
+
".jpg"
;
qgcApp
()
->
toolbox
()
->
videoManager
()
->
videoReceiver
()
->
grabImage
(
photoPath
);
qgcApp
()
->
toolbox
()
->
videoManager
()
->
grabImage
(
photoPath
);
}
}
}
...
...
src/FlightDisplay/FlightDisplayViewVideo.qml
View file @
fb03713f
...
...
@@ -40,7 +40,7 @@ Item {
id
:
noVideo
anchors.fill
:
parent
color
:
Qt
.
rgba
(
0
,
0
,
0
,
0.75
)
visible
:
!
(
_videoReceiver
&&
_videoReceiver
.
videoRunn
ing
)
visible
:
!
(
_videoReceiver
&&
_videoReceiver
.
decod
ing
)
QGCLabel
{
text
:
QGroundControl
.
settingsManager
.
videoSettings
.
streamEnabled
.
rawValue
?
qsTr
(
"
WAITING FOR VIDEO
"
)
:
qsTr
(
"
VIDEO DISABLED
"
)
font.family
:
ScreenTools
.
demiboldFontFamily
...
...
@@ -58,7 +58,7 @@ Item {
Rectangle
{
anchors.fill
:
parent
color
:
"
black
"
visible
:
_videoReceiver
&&
_videoReceiver
.
videoRunn
ing
visible
:
_videoReceiver
&&
_videoReceiver
.
decod
ing
function
getWidth
()
{
//-- Fit Width or Stretch
if
(
_fitMode
===
0
||
_fitMode
===
2
)
{
...
...
@@ -86,7 +86,7 @@ Item {
target
:
_videoReceiver
onImageFileChanged
:
{
videoContent
.
grabToImage
(
function
(
result
)
{
if
(
!
result
.
saveToFile
(
_videoReceiv
er
.
imageFile
))
{
if
(
!
result
.
saveToFile
(
QGroundControl
.
videoManag
er
.
imageFile
))
{
console
.
error
(
'
Error capturing video frame
'
);
}
});
...
...
@@ -130,7 +130,7 @@ Item {
height
:
parent
.
getHeight
()
width
:
parent
.
getWidth
()
anchors.centerIn
:
parent
visible
:
_videoReceiver
&&
_videoReceiver
.
videoRunn
ing
visible
:
_videoReceiver
&&
_videoReceiver
.
decod
ing
sourceComponent
:
videoBackgroundComponent
property
bool
videoDisabled
:
QGroundControl
.
settingsManager
.
videoSettings
.
videoSource
.
rawValue
===
QGroundControl
.
settingsManager
.
videoSettings
.
disabledVideoSource
...
...
src/FlightMap/Widgets/VideoPageWidget.qml
View file @
fb03713f
...
...
@@ -33,7 +33,7 @@ Item {
property
bool
_communicationLost
:
activeVehicle
?
activeVehicle
.
connectionLost
:
false
property
var
_videoReceiver
:
QGroundControl
.
videoManager
.
videoReceiver
property
bool
_recordingVideo
:
_videoReceiver
&&
_videoReceiver
.
recording
property
bool
_
videoRunning
:
_videoReceiver
&&
_videoReceiver
.
videoRunn
ing
property
bool
_
decodingVideo
:
_videoReceiver
&&
_videoReceiver
.
decod
ing
property
bool
_streamingEnabled
:
QGroundControl
.
settingsManager
.
videoSettings
.
streamConfigured
property
var
_dynamicCameras
:
activeVehicle
?
activeVehicle
.
dynamicCameras
:
null
property
int
_curCameraIndex
:
_dynamicCameras
?
_dynamicCameras
.
currentCamera
:
0
...
...
@@ -136,7 +136,7 @@ Item {
anchors.bottom
:
parent
.
bottom
width
:
height
radius
:
_recordingVideo
?
0
:
height
color
:
(
_
videoRunning
&&
_streamingEnabled
)
?
"
red
"
:
"
gray
"
color
:
(
_
decodingVideo
&&
_streamingEnabled
)
?
"
red
"
:
"
gray
"
SequentialAnimation
on
opacity
{
running
:
_recordingVideo
loops
:
Animation
.
Infinite
...
...
@@ -157,14 +157,14 @@ Item {
}
MouseArea
{
anchors.fill
:
parent
enabled
:
_
videoRunning
&&
_streamingEnabled
enabled
:
_
decodingVideo
&&
_streamingEnabled
onClicked
:
{
if
(
_recordingVideo
)
{
_videoReceiv
er
.
stopRecording
()
QGroundControl
.
videoManag
er
.
stopRecording
()
// reset blinking animation
recordBtnBackground
.
opacity
=
1
}
else
{
_videoReceiv
er
.
startRecording
(
videoFileName
.
text
)
QGroundControl
.
videoManag
er
.
startRecording
(
videoFileName
.
text
)
}
}
}
...
...
src/VideoStreaming/SubtitleWriter.cc
View file @
fb03713f
...
...
@@ -15,9 +15,6 @@
*/
#include "SubtitleWriter.h"
#include "SettingsManager.h"
#include "VideoReceiver.h"
#include "VideoManager.h"
#include "QGCApplication.h"
#include "QGCCorePlugin.h"
#include <QDateTime>
...
...
@@ -31,48 +28,11 @@ const int SubtitleWriter::_sampleRate = 1; // Sample rate in Hz for getting tele
SubtitleWriter
::
SubtitleWriter
(
QObject
*
parent
)
:
QObject
(
parent
)
{
connect
(
&
_timer
,
&
QTimer
::
timeout
,
this
,
&
SubtitleWriter
::
_captureTelemetry
);
}
void
SubtitleWriter
::
s
etVideoReceiver
(
VideoReceiver
*
videoReceiver
)
void
SubtitleWriter
::
s
tartCapturingTelemetry
(
const
QString
&
videoFile
)
{
if
(
!
videoReceiver
)
{
qCWarning
(
SubtitleWriterLog
)
<<
"Invalid VideoReceiver pointer! Aborting subtitle capture!"
;
return
;
}
_videoReceiver
=
videoReceiver
;
#if defined(QGC_GST_STREAMING)
// Only start writing subtitles once the recording pipeline actually starts
connect
(
_videoReceiver
,
&
VideoReceiver
::
gotFirstRecordingKeyFrame
,
this
,
&
SubtitleWriter
::
_startCapturingTelemetry
);
// Captures recordingChanged() signals to stop writing subtitles
connect
(
_videoReceiver
,
&
VideoReceiver
::
recordingChanged
,
this
,
&
SubtitleWriter
::
_onVideoRecordingChanged
);
#endif
// Timer for telemetry capture and writing to file
connect
(
&
_timer
,
&
QTimer
::
timeout
,
this
,
&
SubtitleWriter
::
_captureTelemetry
);
}
void
SubtitleWriter
::
_onVideoRecordingChanged
()
{
#if defined(QGC_GST_STREAMING)
// Stop capturing data if recording stopped
if
(
!
_videoReceiver
->
recording
())
{
qCDebug
(
SubtitleWriterLog
)
<<
"Stopping writing"
;
_timer
.
stop
();
_file
.
close
();
}
#endif
}
void
SubtitleWriter
::
_startCapturingTelemetry
()
{
if
(
!
_videoReceiver
)
{
qCWarning
(
SubtitleWriterLog
)
<<
"Invalid VideoReceiver pointer! Aborting subtitle capture!"
;
_timer
.
stop
();
return
;
}
// Get the facts displayed in the values widget and capture them, removing the "Vehicle." prefix.
QSettings
settings
;
settings
.
beginGroup
(
"ValuesWidget"
);
...
...
@@ -81,8 +41,8 @@ void SubtitleWriter::_startCapturingTelemetry()
_startTime
=
QDateTime
::
currentDateTime
();
QFileInfo
videoFile
(
_videoReceiver
->
videoFile
()
);
QString
subtitleFilePath
=
QStringLiteral
(
"%1/%2.ass"
).
arg
(
videoFile
.
path
(),
videoFile
.
completeBaseName
());
QFileInfo
videoFile
Info
(
videoFile
);
QString
subtitleFilePath
=
QStringLiteral
(
"%1/%2.ass"
).
arg
(
videoFile
Info
.
path
(),
videoFileInfo
.
completeBaseName
());
qCDebug
(
SubtitleWriterLog
)
<<
"Writing overlay to file:"
<<
subtitleFilePath
;
_file
.
setFileName
(
subtitleFilePath
);
...
...
@@ -118,14 +78,17 @@ void SubtitleWriter::_startCapturingTelemetry()
_timer
.
start
(
1000
/
_sampleRate
);
}
void
SubtitleWriter
::
_capture
Telemetry
()
void
SubtitleWriter
::
stopCapturing
Telemetry
()
{
if
(
!
_videoReceiver
)
{
qCWarning
(
SubtitleWriterLog
)
<<
"Invalid VideoReceiver pointer! Aborting subtitle capture!"
;
_timer
.
stop
();
return
;
}
#if defined(QGC_GST_STREAMING)
qCDebug
(
SubtitleWriterLog
)
<<
"Stopping writing"
;
_timer
.
stop
();
_file
.
close
();
#endif
}
void
SubtitleWriter
::
_captureTelemetry
()
{
static
const
float
nRows
=
3
;
// number of rows used for displaying data
static
const
int
offsetFactor
=
700
;
// Used to simulate a larger resolution and reduce the borders in the layout
...
...
src/VideoStreaming/SubtitleWriter.h
View file @
fb03713f
...
...
@@ -17,7 +17,6 @@
#pragma once
#include "QGCLoggingCategory.h"
#include "VideoReceiver.h"
#include <QObject>
#include <QTimer>
#include <QDateTime>
...
...
@@ -33,25 +32,19 @@ public:
explicit
SubtitleWriter
(
QObject
*
parent
=
nullptr
);
~
SubtitleWriter
()
=
default
;
void
setVideoReceiver
(
VideoReceiver
*
videoReceiver
);
// starts capturing vehicle telemetry.
void
startCapturingTelemetry
(
const
QString
&
videoFile
);
void
stopCapturingTelemetry
();
private
slots
:
// Fires with every "videoRecordingChanged() signal, stops capturing telemetry if video stopped."
void
_onVideoRecordingChanged
();
// Captures a snapshot of telemetry data from vehicle into the subtitles file.
void
_captureTelemetry
();
// starts capturing vehicle telemetry.
void
_startCapturingTelemetry
();
private:
QTimer
_timer
;
QStringList
_values
;
QDateTime
_startTime
;
QFile
_file
;
VideoReceiver
*
_videoReceiver
;
static
const
int
_sampleRate
;
};
src/VideoStreaming/VideoManager.cc
View file @
fb03713f
This diff is collapsed.
Click to expand it.
src/VideoStreaming/VideoManager.h
View file @
fb03713f
...
...
@@ -50,6 +50,7 @@ public:
Q_PROPERTY
(
double
thermalHfov
READ
thermalHfov
NOTIFY
aspectRatioChanged
)
Q_PROPERTY
(
bool
autoStreamConfigured
READ
autoStreamConfigured
NOTIFY
autoStreamConfiguredChanged
)
Q_PROPERTY
(
bool
hasThermal
READ
hasThermal
NOTIFY
aspectRatioChanged
)
Q_PROPERTY
(
QString
imageFile
READ
imageFile
NOTIFY
imageFileChanged
)
virtual
bool
hasVideo
();
virtual
bool
isGStreamer
();
...
...
@@ -62,14 +63,12 @@ public:
virtual
double
thermalHfov
();
virtual
bool
autoStreamConfigured
();
virtual
bool
hasThermal
();
virtual
void
restartVideo
();
virtual
QString
imageFile
();
virtual
VideoReceiver
*
videoReceiver
()
{
return
_videoReceiver
;
}
virtual
VideoReceiver
*
thermalVideoReceiver
()
{
return
_thermalVideoReceiver
;
}
QStringList
videoExtensions
();
QStringList
videoMuxes
();
#if defined(QGC_DISABLE_UVC)
virtual
bool
uvcEnabled
()
{
return
false
;
}
#else
...
...
@@ -85,7 +84,10 @@ public:
Q_INVOKABLE
void
startVideo
();
Q_INVOKABLE
void
stopVideo
();
void
cleanupOldVideos
();
Q_INVOKABLE
void
startRecording
(
const
QString
&
videoFile
=
QString
());
Q_INVOKABLE
void
stopRecording
();
Q_INVOKABLE
void
grabImage
(
const
QString
&
imageFile
);
signals:
void
hasVideoChanged
();
...
...
@@ -96,6 +98,7 @@ signals:
void
isTaisyncChanged
();
void
aspectRatioChanged
();
void
autoStreamConfiguredChanged
();
void
imageFileChanged
();
protected
slots
:
void
_videoSourceChanged
();
...
...
@@ -115,13 +118,29 @@ protected:
#endif
void
_initVideo
();
void
_updateSettings
();
void
_setVideoUri
(
const
QString
&
uri
);
void
_setThermalVideoUri
(
const
QString
&
uri
);
void
_cleanupOldVideos
();
void
_restartVideo
();
void
_streamingChanged
();
void
_recordingStarted
();
void
_recordingChanged
();
void
_screenshotComplete
();
protected:
QString
_videoFile
;
QString
_imageFile
;
SubtitleWriter
_subtitleWriter
;
bool
_isTaisync
=
false
;
VideoReceiver
*
_videoReceiver
=
nullptr
;
VideoReceiver
*
_thermalVideoReceiver
=
nullptr
;
#if defined(QGC_GST_STREAMING)
GstElement
*
_videoSink
=
nullptr
;
GstElement
*
_thermalVideoSink
=
nullptr
;
#endif
VideoSettings
*
_videoSettings
=
nullptr
;
QString
_videoUri
;
QString
_thermalVideoUri
;
QString
_videoSourceID
;
bool
_fullScreen
=
false
;
Vehicle
*
_activeVehicle
=
nullptr
;
...
...
src/VideoStreaming/VideoReceiver.cc
View file @
fb03713f
This diff is collapsed.
Click to expand it.
src/VideoStreaming/VideoReceiver.h
View file @
fb03713f
This diff is collapsed.
Click to expand it.
src/VideoStreaming/gstqgcvideosinkbin.c
View file @
fb03713f
...
...
@@ -125,6 +125,9 @@ _vsb_init(GstQgcVideoSinkBin *vsb)
break
;
}
// FIXME: AV: temporally disable sync due to MPEG2-TS sync issues
g_object_set
(
vsb
->
qmlglsink
,
"sync"
,
FALSE
,
NULL
);
if
((
glcolorconvert
=
gst_element_factory_make
(
"glcolorconvert"
,
NULL
))
==
NULL
)
{
GST_ERROR_OBJECT
(
vsb
,
"gst_element_factory_make('glcolorconvert' failed)"
);
break
;
...
...
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