Skip to content

Commit

Permalink
VideoManager: Fix crash on exit
Browse files Browse the repository at this point in the history
  • Loading branch information
HTRamsey committed Sep 6, 2024
1 parent b3c4fa5 commit 990189b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 34 deletions.
2 changes: 1 addition & 1 deletion src/FlightDisplay/FlyViewVideo.qml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Item {
Loader {
id: cameraLoader
anchors.fill: parent
visible: !QGroundControl.videoManager.isStreamSource
visible: QGroundControl.videoManager.isUvc
source: QGroundControl.videoManager.uvcEnabled ? "qrc:/qml/FlightDisplayViewUVC.qml" : "qrc:/qml/FlightDisplayViewDummy.qml"
}

Expand Down
40 changes: 10 additions & 30 deletions src/VideoManager/VideoManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ VideoManager::~VideoManager()
// calling _toolbox->corePlugin()->releaseVideoSink(_videoSink[i]);
// As for now let's call GStreamer::releaseVideoSink() directly
GStreamer::releaseVideoSink(videoReceiver.sink);
#endif
#ifdef QGC_QT_STREAMING
#elif defined(QGC_QT_STREAMING)
QtMultimediaReceiver::releaseVideoSink(videoReceiver.sink);
#endif
}
Expand All @@ -110,9 +109,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
const QString videoSource = _videoSettings->videoSource()->rawValue().toString();
qCDebug(VideoManagerLog) << "New Video Source:" << videoSource;
connect(_videoSettings->videoSource(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged);
connect(_videoSettings->udpPort(), &Fact::rawValueChanged, this, &VideoManager::_udpPortChanged);
connect(_videoSettings->rtspUrl(), &Fact::rawValueChanged, this, &VideoManager::_rtspUrlChanged);
connect(_videoSettings->tcpUrl(), &Fact::rawValueChanged, this, &VideoManager::_tcpUrlChanged);
connect(_videoSettings->udpPort(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged);
connect(_videoSettings->rtspUrl(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged);
connect(_videoSettings->tcpUrl(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged);
connect(_videoSettings->aspectRatio(), &Fact::rawValueChanged, this, &VideoManager::aspectRatioChanged);
connect(_videoSettings->lowLatencyMode(),&Fact::rawValueChanged, this, &VideoManager::_lowLatencyModeChanged);
MultiVehicleManager *pVehicleMgr = _toolbox->multiVehicleManager();
Expand Down Expand Up @@ -200,8 +199,6 @@ 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 (_videoReceiverData[1].receiver != nullptr) {
(void) connect(_videoReceiverData[1].receiver, &VideoReceiver::onStartComplete, this, [this](VideoReceiver::STATUS status) {
if (status == VideoReceiver::STATUS_OK) {
Expand Down Expand Up @@ -279,7 +276,7 @@ VideoManager::startVideo()
return;
}

if(!_videoSettings->streamEnabled()->rawValue().toBool() || !_videoSettings->streamConfigured() || !hasVideo()) {
if(!_videoSettings->streamEnabled()->rawValue().toBool() || !hasVideo()) {
qCDebug(VideoManagerLog) << "Stream not enabled/configured";
return;
}
Expand Down Expand Up @@ -515,27 +512,6 @@ VideoManager::_videoSourceChanged()
}
}

//-----------------------------------------------------------------------------
void
VideoManager::_udpPortChanged()
{
_restartVideo(0);
}

//-----------------------------------------------------------------------------
void
VideoManager::_rtspUrlChanged()
{
_restartVideo(0);
}

//-----------------------------------------------------------------------------
void
VideoManager::_tcpUrlChanged()
{
_restartVideo(0);
}

//-----------------------------------------------------------------------------
void
VideoManager::_lowLatencyModeChanged()
Expand Down Expand Up @@ -674,6 +650,8 @@ VideoManager::_updateSettings(unsigned id)
settingsChanged = true;
}

settingsChanged |= _updateUVC();

//-- Auto discovery

if(_activeVehicle && _activeVehicle->cameraManager()) {
Expand Down Expand Up @@ -731,10 +709,13 @@ VideoManager::_updateSettings(unsigned id)
}
}
}
settingsChanged |= _updateUVC();
return settingsChanged;
}
}

settingsChanged |= _updateUVC();

const QString source = _videoSettings->videoSource()->rawValue().toString();
if (source == VideoSettings::videoSourceUDPH264)
settingsChanged |= _updateVideoUri(0, QStringLiteral("udp://0.0.0.0:%1").arg(_videoSettings->udpPort()->rawValue().toInt()));
Expand All @@ -760,7 +741,6 @@ VideoManager::_updateSettings(unsigned id)
settingsChanged |= _updateVideoUri(0, "");
else {
settingsChanged |= _updateVideoUri(0, "");
settingsChanged |= _updateUVC();
if (!isUvc()) {
qCCritical(VideoManagerLog)
<< "Video source URI \"" << source << "\" is not supported. Please add support!";
Expand Down
3 changes: 0 additions & 3 deletions src/VideoManager/VideoManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ class VideoManager : public QGCTool

protected slots:
void _videoSourceChanged ();
void _udpPortChanged ();
void _rtspUrlChanged ();
void _tcpUrlChanged ();
void _lowLatencyModeChanged ();
bool _updateUVC ();
void _setActiveVehicle (Vehicle* vehicle);
Expand Down

0 comments on commit 990189b

Please sign in to comment.