Commit 23f21402 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #5054 from lbegani/issue_videorestart

Support Video Source & Setting Changes Runtime
parents 08f54ff7 cb488272
...@@ -57,6 +57,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox) ...@@ -57,6 +57,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox)
_videoSettings = toolbox->settingsManager()->videoSettings(); _videoSettings = toolbox->settingsManager()->videoSettings();
QString videoSource = _videoSettings->videoSource()->rawValue().toString(); QString videoSource = _videoSettings->videoSource()->rawValue().toString();
connect(_videoSettings->videoSource(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged); connect(_videoSettings->videoSource(), &Fact::rawValueChanged, this, &VideoManager::_videoSourceChanged);
connect(_videoSettings->udpPort(), &Fact::rawValueChanged, this, &VideoManager::_udpPortChanged);
connect(_videoSettings->rtspUrl(), &Fact::rawValueChanged, this, &VideoManager::_rtspUrlChanged);
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
#ifndef QGC_DISABLE_UVC #ifndef QGC_DISABLE_UVC
...@@ -96,6 +99,17 @@ void VideoManager::_videoSourceChanged(void) ...@@ -96,6 +99,17 @@ void VideoManager::_videoSourceChanged(void)
{ {
emit hasVideoChanged(); emit hasVideoChanged();
emit isGStreamerChanged(); emit isGStreamerChanged();
_restartVideo();
}
void VideoManager::_udpPortChanged(void)
{
_restartVideo();
}
void VideoManager::_rtspUrlChanged(void)
{
_restartVideo();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -170,6 +184,18 @@ void VideoManager::_updateTimer() ...@@ -170,6 +184,18 @@ void VideoManager::_updateTimer()
#endif #endif
} }
//-----------------------------------------------------------------------------
void VideoManager::_updateSettings()
{
if(!_videoSettings || !_videoReceiver)
return;
if (_videoSettings->videoSource()->rawValue().toString() == VideoSettings::videoSourceUDP)
_videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_videoSettings->udpPort()->rawValue().toInt()));
else
_videoReceiver->setUri(_videoSettings->rtspUrl()->rawValue().toString());
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void VideoManager::_updateVideo() void VideoManager::_updateVideo()
{ {
...@@ -182,12 +208,20 @@ void VideoManager::_updateVideo() ...@@ -182,12 +208,20 @@ void VideoManager::_updateVideo()
_videoReceiver = new VideoReceiver(this); _videoReceiver = new VideoReceiver(this);
#if defined(QGC_GST_STREAMING) #if defined(QGC_GST_STREAMING)
_videoReceiver->setVideoSink(_videoSurface->videoSink()); _videoReceiver->setVideoSink(_videoSurface->videoSink());
QString videoSource = _videoSettings->videoSource()->rawValue().toString(); _updateSettings();
if (_videoSettings->videoSource()->rawValue().toString() == VideoSettings::videoSourceUDP)
_videoReceiver->setUri(QStringLiteral("udp://0.0.0.0:%1").arg(_videoSettings->udpPort()->rawValue().toInt()));
else
_videoReceiver->setUri(_videoSettings->rtspUrl()->rawValue().toString());
#endif #endif
_videoReceiver->start(); _videoReceiver->start();
} }
} }
//-----------------------------------------------------------------------------
void VideoManager::_restartVideo()
{
if(!_videoReceiver)
return;
#if defined(QGC_GST_STREAMING)
_videoReceiver->stop();
_updateSettings();
_videoReceiver->start();
#endif
}
...@@ -69,10 +69,16 @@ signals: ...@@ -69,10 +69,16 @@ signals:
private slots: private slots:
void _videoSourceChanged(void); void _videoSourceChanged(void);
void _udpPortChanged(void);
void _rtspUrlChanged(void);
private: private:
void _updateTimer (); void _updateTimer ();
void _updateSettings ();
void _updateVideo (); void _updateVideo ();
void _restartVideo ();
VideoSurface* _videoSurface; VideoSurface* _videoSurface;
VideoReceiver* _videoReceiver; VideoReceiver* _videoReceiver;
......
...@@ -495,7 +495,7 @@ QGCView { ...@@ -495,7 +495,7 @@ QGCView {
visible: QGroundControl.settingsManager.videoSettings.visible visible: QGroundControl.settingsManager.videoSettings.visible
QGCLabel { QGCLabel {
id: videoLabel id: videoLabel
text: qsTr("Video (Requires Restart)") text: qsTr("Video")
font.family: ScreenTools.demiboldFontFamily font.family: ScreenTools.demiboldFontFamily
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment