From e7381f6c310ba21645e53295211a7bdf15d4366c Mon Sep 17 00:00:00 2001 From: "Patrick J.P" Date: Wed, 18 Apr 2018 19:07:59 -0300 Subject: [PATCH] VideoReceiver: Correct start and stop video functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/FlightDisplay/VideoManager.h | 2 +- src/VideoStreaming/VideoReceiver.cc | 6 +++++- src/VideoStreaming/VideoReceiver.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/FlightDisplay/VideoManager.h b/src/FlightDisplay/VideoManager.h index f419af90a..a63d6837a 100644 --- a/src/FlightDisplay/VideoManager.h +++ b/src/FlightDisplay/VideoManager.h @@ -56,7 +56,7 @@ public: // Override from QGCTool void setToolbox (QGCToolbox *toolbox); - Q_INVOKABLE void startVideo() {_videoReceiver->stop();}; + Q_INVOKABLE void startVideo() {_videoReceiver->start();}; Q_INVOKABLE void stopVideo() {_videoReceiver->stop();}; signals: diff --git a/src/VideoStreaming/VideoReceiver.cc b/src/VideoStreaming/VideoReceiver.cc index 633688e8e..a51638df6 100644 --- a/src/VideoStreaming/VideoReceiver.cc +++ b/src/VideoStreaming/VideoReceiver.cc @@ -218,6 +218,7 @@ VideoReceiver::start() return; } #if defined(QGC_GST_STREAMING) + _stop = false; qCDebug(VideoReceiverLog) << "start()"; if (_uri.isEmpty()) { @@ -433,6 +434,7 @@ void VideoReceiver::stop() { #if defined(QGC_GST_STREAMING) + _stop = true; qCDebug(VideoReceiverLog) << "stop()"; if(!_streaming) { _shutdownPipeline(); @@ -870,9 +872,11 @@ VideoReceiver::_updateTimer() } if(elapsed > (time_t)timeout && _videoSurface) { stop(); + // We want to start it back again with _updateTimer + _stop = false; } } else { - if(!running() && !_uri.isEmpty() && _videoSettings->streamEnabled()->rawValue().toBool()) { + if(!_stop && !running() && !_uri.isEmpty() && _videoSettings->streamEnabled()->rawValue().toBool()) { start(); } } diff --git a/src/VideoStreaming/VideoReceiver.h b/src/VideoStreaming/VideoReceiver.h index 76aa3044c..7739b2350 100644 --- a/src/VideoStreaming/VideoReceiver.h +++ b/src/VideoStreaming/VideoReceiver.h @@ -114,6 +114,7 @@ private: bool _streaming; bool _starting; bool _stopping; + bool _stop; Sink* _sink; GstElement* _tee; -- 2.22.0