diff --git a/VideoReceiverApp/main.cpp b/VideoReceiverApp/main.cpp index 81711133f3300ab13a5253c684e2d5fc85afa51d..121d7ffe76b3bac91393e795e1e22b9fdffd815c 100644 --- a/VideoReceiverApp/main.cpp +++ b/VideoReceiverApp/main.cpp @@ -302,25 +302,8 @@ VideoReceiverApp::exec() startStreaming(); - QObject::connect(_receiver, &VideoReceiver::timeout, [this](){ + QObject::connect(_receiver, &VideoReceiver::timeout, [](){ qCDebug(AppLog) << "Streaming timeout"; - - _dispatch([this](){ - if (_streaming) { - _receiver->stop(); - } else { - if (--_connect > 0) { - qCDebug(AppLog) << "Restarting streaming"; - _dispatch([this](){ - startStreaming(); - }); - } else { - qCDebug(AppLog) << "Closing..."; - delete _receiver; - _app.exit(); - } - } - }); }); QObject::connect(_receiver, &VideoReceiver::streamingChanged, [this](bool active){ @@ -329,16 +312,6 @@ VideoReceiverApp::exec() qCDebug(AppLog) << "Streaming started"; } else { qCDebug(AppLog) << "Streaming stopped"; - _dispatch([this](){ - if (--_connect > 0) { - qCDebug(AppLog) << "Restarting streaming"; - startStreaming(); - } else { - qCDebug(AppLog) << "Closing..."; - delete _receiver; - _app.exit(); - } - }); } }); @@ -374,6 +347,44 @@ VideoReceiverApp::exec() } }); + QObject::connect(_receiver, &VideoReceiver::onStartComplete, [this](VideoReceiver::STATUS status){ + if (status != VideoReceiver::STATUS_OK) { + qCDebug(AppLog) << "Video receiver start failed"; + _dispatch([this](){ + if (--_connect > 0) { + qCDebug(AppLog) << "Restarting ..."; + _dispatch([this](){ + startStreaming(); + }); + } else { + qCDebug(AppLog) << "Closing..."; + delete _receiver; + _app.exit(); + } + }); + } else { + qCDebug(AppLog) << "Video receiver started"; + } + }); + + QObject::connect(_receiver, &VideoReceiver::onStopComplete, [this](VideoReceiver::STATUS ){ + qCDebug(AppLog) << "Video receiver stopped"; + + _dispatch([this](){ + if (--_connect > 0) { + qCDebug(AppLog) << "Restarting ..."; + _dispatch([this](){ + startStreaming(); + }); + } else { + qCDebug(AppLog) << "Closing..."; + delete _receiver; + _app.exit(); + } + }); + }); + + return _app.exec(); } diff --git a/src/VideoManager/VideoManager.cc b/src/VideoManager/VideoManager.cc index fc176a8c7117b321aa5a23e85b797768d29c8791..ebefed5e7f83d6a31abcbbb4bec449b5aa3fe6c2 100644 --- a/src/VideoManager/VideoManager.cc +++ b/src/VideoManager/VideoManager.cc @@ -115,14 +115,9 @@ VideoManager::setToolbox(QGCToolbox *toolbox) _videoReceiver[0] = toolbox->corePlugin()->createVideoReceiver(this); _videoReceiver[1] = toolbox->corePlugin()->createVideoReceiver(this); - connect(_videoReceiver[0], &VideoReceiver::timeout, this, [this](){ - _stopReceiver(0); - }); - connect(_videoReceiver[0], &VideoReceiver::streamingChanged, this, [this](bool active){ _streaming = active; emit streamingChanged(); - _restartVideo(0); }); connect(_videoReceiver[0], &VideoReceiver::onStartComplete, this, [this](VideoReceiver::STATUS status) { @@ -178,14 +173,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 (_videoReceiver[1] != nullptr) { - connect(_videoReceiver[1], &VideoReceiver::timeout, this, [this](){ - _stopReceiver(1); - }); - - connect(_videoReceiver[1], &VideoReceiver::streamingChanged, this, [this](bool active){ - _restartVideo(1); - }); - connect(_videoReceiver[1], &VideoReceiver::onStartComplete, this, [this](VideoReceiver::STATUS status) { if (status == VideoReceiver::STATUS_OK) { _videoStarted[1] = true; diff --git a/src/VideoReceiver/GstVideoReceiver.cc b/src/VideoReceiver/GstVideoReceiver.cc index 5f4fed69a094f30837c0d7483115d2a73b670caf..8e35089ceb41a2e228c0ab99d447bb11000364d9 100644 --- a/src/VideoReceiver/GstVideoReceiver.cc +++ b/src/VideoReceiver/GstVideoReceiver.cc @@ -644,6 +644,7 @@ GstVideoReceiver::_watchdog(void) _dispatchSignal([this](){ emit timeout(); }); + stop(); } if (_decoding && !_removingDecoder) { @@ -656,6 +657,7 @@ GstVideoReceiver::_watchdog(void) _dispatchSignal([this](){ emit timeout(); }); + stop(); } } });