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
f52bc85d
Commit
f52bc85d
authored
Mar 31, 2020
by
Andrew Voznytsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix VideoManager state handling
parent
fcf9d0dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
85 additions
and
78 deletions
+85
-78
VideoManager.cc
src/VideoManager/VideoManager.cc
+81
-74
VideoManager.h
src/VideoManager/VideoManager.h
+4
-4
No files found.
src/VideoManager/VideoManager.cc
View file @
f52bc85d
...
...
@@ -109,8 +109,16 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
_videoReceiver
=
toolbox
->
corePlugin
()
->
createVideoReceiver
(
this
);
_thermalVideoReceiver
=
toolbox
->
corePlugin
()
->
createVideoReceiver
(
this
);
connect
(
_videoReceiver
,
&
VideoReceiver
::
timeout
,
this
,
&
VideoManager
::
_restartVideo
);
connect
(
_videoReceiver
,
&
VideoReceiver
::
streamingChanged
,
this
,
&
VideoManager
::
_streamingChanged
);
connect
(
_videoReceiver
,
&
VideoReceiver
::
timeout
,
this
,
[
this
](){
if
(
!
_enableVideoRestart
)
return
;
_startReceiver
(
0
);
});
connect
(
_videoReceiver
,
&
VideoReceiver
::
streamingChanged
,
this
,
[
this
](){
if
(
!
_enableVideoRestart
||
_videoReceiver
->
streaming
())
return
;
_startReceiver
(
0
);
});
connect
(
_videoReceiver
,
&
VideoReceiver
::
recordingStarted
,
this
,
&
VideoManager
::
_recordingStarted
);
connect
(
_videoReceiver
,
&
VideoReceiver
::
recordingChanged
,
this
,
&
VideoManager
::
_recordingChanged
);
connect
(
_videoReceiver
,
&
VideoReceiver
::
onTakeScreenshotComplete
,
this
,
&
VideoManager
::
_onTakeScreenshotComplete
);
...
...
@@ -118,8 +126,15 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
// FIXME: AV: I believe _thermalVideoReceiver should be handled just like _videoReceiver in terms of event
// and I expect that it will be changed during multiple video stream activity
if
(
_thermalVideoReceiver
!=
nullptr
)
{
connect
(
_thermalVideoReceiver
,
&
VideoReceiver
::
timeout
,
this
,
&
VideoManager
::
_restartVideo
);
connect
(
_thermalVideoReceiver
,
&
VideoReceiver
::
streamingChanged
,
this
,
&
VideoManager
::
_streamingChanged
);
connect
(
_thermalVideoReceiver
,
&
VideoReceiver
::
timeout
,
this
,
[
this
](){
if
(
!
_enableVideoRestart
)
return
;
_startReceiver
(
1
);
});
connect
(
_thermalVideoReceiver
,
&
VideoReceiver
::
streamingChanged
,
this
,
[
this
](){
if
(
!
_enableVideoRestart
)
return
;
_startReceiver
(
1
);
});
}
#endif
_updateSettings
();
...
...
@@ -186,24 +201,10 @@ VideoManager::startVideo()
return
;
}
#if defined(QGC_GST_STREAMING)
const
unsigned
timeout
=
_videoSettings
->
rtspTimeout
()
->
rawValue
().
toUInt
();
if
(
_videoReceiver
!=
nullptr
)
{
connect
(
_videoReceiver
,
&
VideoReceiver
::
onStartComplete
,
this
,
&
VideoManager
::
_onStartComplete
);
_videoReceiver
->
start
(
_videoUri
,
timeout
);
if
(
_videoSink
!=
nullptr
)
{
_videoReceiver
->
startDecoding
(
_videoSink
);
}
}
_enableVideoRestart
=
true
;
if
(
_thermalVideoReceiver
!=
nullptr
)
{
_thermalVideoReceiver
->
start
(
_thermalVideoUri
,
timeout
);
if
(
_thermalVideoSink
!=
nullptr
)
{
_thermalVideoReceiver
->
startDecoding
(
_thermalVideoSink
);
}
}
#endif
_startReceiver
(
0
);
_startReceiver
(
1
);
}
//-----------------------------------------------------------------------------
...
...
@@ -214,13 +215,10 @@ VideoManager::stopVideo()
return
;
}
disconnect
(
_videoReceiver
,
&
VideoReceiver
::
timeout
,
this
,
&
VideoManager
::
_restartVideo
);
disconnect
(
_videoReceiver
,
&
VideoReceiver
::
streamingChanged
,
this
,
&
VideoManager
::
_streamingChanged
);
_enableVideoRestart
=
false
;
#if defined(QGC_GST_STREAMING)
if
(
_videoReceiver
)
_videoReceiver
->
stop
();
if
(
_thermalVideoReceiver
)
_thermalVideoReceiver
->
stop
();
#endif
_stopReceiver
(
1
);
_stopReceiver
(
0
);
}
void
...
...
@@ -574,16 +572,16 @@ VideoManager::_updateSettings()
switch
(
pTinfo
->
type
())
{
case
VIDEO_STREAM_TYPE_RTSP
:
case
VIDEO_STREAM_TYPE_TCP_MPEG
:
_updateThermalVideoUri
(
pTinfo
->
uri
());
status
|=
_updateThermalVideoUri
(
pTinfo
->
uri
());
break
;
case
VIDEO_STREAM_TYPE_RTPUDP
:
_updateThermalVideoUri
(
QStringLiteral
(
"udp://0.0.0.0:%1"
).
arg
(
pTinfo
->
uri
()));
status
|=
_updateThermalVideoUri
(
QStringLiteral
(
"udp://0.0.0.0:%1"
).
arg
(
pTinfo
->
uri
()));
break
;
case
VIDEO_STREAM_TYPE_MPEG_TS_H264
:
_updateThermalVideoUri
(
QStringLiteral
(
"mpegts://0.0.0.0:%1"
).
arg
(
pTinfo
->
uri
()));
status
|=
_updateThermalVideoUri
(
QStringLiteral
(
"mpegts://0.0.0.0:%1"
).
arg
(
pTinfo
->
uri
()));
break
;
default:
_updateThermalVideoUri
(
pTinfo
->
uri
());
status
|=
_updateThermalVideoUri
(
pTinfo
->
uri
());
break
;
}
}
...
...
@@ -621,7 +619,7 @@ VideoManager::_updateVideoUri(const QString& uri)
return
true
;
}
void
bool
VideoManager
::
_updateThermalVideoUri
(
const
QString
&
uri
)
{
#if defined(QGC_GST_TAISYNC_ENABLED) && (defined(__android__) || defined(__ios__))
...
...
@@ -632,47 +630,13 @@ VideoManager::_updateThermalVideoUri(const QString& uri)
return
;
}
#endif
_thermalVideoUri
=
uri
;
}
//-----------------------------------------------------------------------------
void
VideoManager
::
_streamingChanged
()
{
#if defined(QGC_GST_STREAMING)
// FIXME: AV: we need VideoReceiver::running() to avoid restarting if one of streams is not active
// but since VideoManager is going to be relpaced by Video Model during multiple video streaming development activity
// I'll leave it as is for week or two
if
((
_videoReceiver
&&
!
_videoReceiver
->
streaming
())
/*|| (_thermalVideoReceiver && !_thermalVideoReceiver->streaming())*/
)
{
_restartVideo
();
}
#endif
}
//-----------------------------------------------------------------------------
void
VideoManager
::
_streamChanged
()
{
if
(
_updateSettings
())
{
_restartVideo
();
if
(
uri
==
_thermalVideoUri
)
{
return
false
;
}
}
//-----------------------------------------------------------------------------
void
VideoManager
::
_onStartComplete
(
VideoReceiver
::
STATUS
status
)
{
disconnect
(
_videoReceiver
,
&
VideoReceiver
::
onStartComplete
,
this
,
&
VideoManager
::
_onStartComplete
);
_thermalVideoUri
=
uri
;
if
(
status
==
VideoReceiver
::
STATUS_OK
)
{
connect
(
_videoReceiver
,
&
VideoReceiver
::
timeout
,
this
,
&
VideoManager
::
_restartVideo
);
connect
(
_videoReceiver
,
&
VideoReceiver
::
streamingChanged
,
this
,
&
VideoManager
::
_streamingChanged
);
}
else
{
QTimer
::
singleShot
(
1000
,
[
this
](){
_restartVideo
();
});
}
return
true
;
}
//-----------------------------------------------------------------------------
...
...
@@ -680,10 +644,15 @@ void
VideoManager
::
_restartVideo
()
{
#if defined(QGC_GST_STREAMING)
if
(
!
_updateSettings
())
{
qCDebug
(
VideoManagerLog
)
<<
"No sense to restart video streaming, skipped"
;
return
;
}
qCDebug
(
VideoManagerLog
)
<<
"Restart video streaming"
;
stopVideo
();
_
updateSettings
(
);
startVideo
(
);
_
stopReceiver
(
1
);
_stopReceiver
(
0
);
// emit aspectRatioChanged();
#endif
}
...
...
@@ -712,6 +681,44 @@ VideoManager::_onTakeScreenshotComplete(VideoReceiver::STATUS status)
{
}
//----------------------------------------------------------------------------------------
void
VideoManager
::
_startReceiver
(
unsigned
id
)
{
#if defined(QGC_GST_STREAMING)
const
unsigned
timeout
=
_videoSettings
->
rtspTimeout
()
->
rawValue
().
toUInt
();
if
(
id
==
0
&&
_videoReceiver
!=
nullptr
)
{
_videoReceiver
->
start
(
_videoUri
,
timeout
);
if
(
_videoSink
!=
nullptr
)
{
_videoReceiver
->
startDecoding
(
_videoSink
);
}
}
else
if
(
id
==
1
&&
_thermalVideoReceiver
!=
nullptr
)
{
_thermalVideoReceiver
->
start
(
_thermalVideoUri
,
timeout
);
if
(
_thermalVideoSink
!=
nullptr
)
{
_thermalVideoReceiver
->
startDecoding
(
_thermalVideoSink
);
}
}
else
if
(
id
>
1
)
{
qCDebug
(
VideoManagerLog
)
<<
"Unsupported receiver id"
<<
id
;
}
#endif
}
//----------------------------------------------------------------------------------------
void
VideoManager
::
_stopReceiver
(
unsigned
id
)
{
#if defined(QGC_GST_STREAMING)
if
(
id
==
0
&&
_videoReceiver
!=
nullptr
)
{
_videoReceiver
->
stop
();
}
else
if
(
id
==
1
&&
_thermalVideoReceiver
!=
nullptr
){
_thermalVideoReceiver
->
stop
();
}
else
if
(
id
>
1
)
{
qCDebug
(
VideoManagerLog
)
<<
"Unsupported receiver id"
<<
id
;
}
#endif
}
//----------------------------------------------------------------------------------------
void
VideoManager
::
_setActiveVehicle
(
Vehicle
*
vehicle
)
...
...
@@ -730,7 +737,7 @@ VideoManager::_setActiveVehicle(Vehicle* vehicle)
if
(
_activeVehicle
)
{
connect
(
_activeVehicle
,
&
Vehicle
::
connectionLostChanged
,
this
,
&
VideoManager
::
_connectionLostChanged
);
if
(
_activeVehicle
->
dynamicCameras
())
{
connect
(
_activeVehicle
->
dynamicCameras
(),
&
QGCCameraManager
::
streamChanged
,
this
,
&
VideoManager
::
_
streamChanged
);
connect
(
_activeVehicle
->
dynamicCameras
(),
&
QGCCameraManager
::
streamChanged
,
this
,
&
VideoManager
::
_
restartVideo
);
QGCCameraControl
*
pCamera
=
_activeVehicle
->
dynamicCameras
()
->
currentCameraInstance
();
if
(
pCamera
)
{
pCamera
->
resumeStream
();
...
...
src/VideoManager/VideoManager.h
View file @
f52bc85d
...
...
@@ -117,15 +117,14 @@ protected:
void
_initVideo
();
bool
_updateSettings
();
bool
_updateVideoUri
(
const
QString
&
uri
);
void
_updateThermalVideoUri
(
const
QString
&
uri
);
bool
_updateThermalVideoUri
(
const
QString
&
uri
);
void
_cleanupOldVideos
();
void
_streamChanged
();
void
_onStartComplete
(
VideoReceiver
::
STATUS
status
);
void
_restartVideo
();
void
_streamingChanged
();
void
_recordingStarted
();
void
_recordingChanged
();
void
_onTakeScreenshotComplete
(
VideoReceiver
::
STATUS
status
);
void
_startReceiver
(
unsigned
id
);
void
_stopReceiver
(
unsigned
id
);
protected:
QString
_videoFile
;
...
...
@@ -134,6 +133,7 @@ protected:
bool
_isTaisync
=
false
;
VideoReceiver
*
_videoReceiver
=
nullptr
;
VideoReceiver
*
_thermalVideoReceiver
=
nullptr
;
bool
_enableVideoRestart
=
false
;
void
*
_videoSink
=
nullptr
;
void
*
_thermalVideoSink
=
nullptr
;
VideoSettings
*
_videoSettings
=
nullptr
;
...
...
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