fix: Resolve enable state for v4l and screen capture (#728)

* fix: Resolve the enable state for v4l and screen capture

* Use instance index instead of pointer

* Second try

* fix(QtGrabber): QScreen ownership

* Remove v4l2 compState listener
This commit is contained in:
brindosch
2020-03-26 17:49:36 +01:00
committed by GitHub
parent 49b30c47f7
commit cb98d51a9c
12 changed files with 109 additions and 52 deletions

View File

@@ -28,6 +28,9 @@ GrabberWrapper::GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned
(_grabberName.startsWith("V4L"))
? connect(this, &GrabberWrapper::systemImage, GlobalSignals::getInstance(), &GlobalSignals::setV4lImage)
: connect(this, &GrabberWrapper::systemImage, GlobalSignals::getInstance(), &GlobalSignals::setSystemImage);
// listen for source requests
connect(GlobalSignals::getInstance(), &GlobalSignals::requestSource, this, &GrabberWrapper::handleSourceRequest);
}
GrabberWrapper::~GrabberWrapper()
@@ -39,6 +42,7 @@ GrabberWrapper::~GrabberWrapper()
bool GrabberWrapper::start()
{
// Start the timer with the pre configured interval
Debug(_log,"Grabber start()");
_timer->start();
return _timer->isActive();
}
@@ -46,6 +50,7 @@ bool GrabberWrapper::start()
void GrabberWrapper::stop()
{
// Stop the timer, effectivly stopping the process
Debug(_log,"Grabber stop()");
_timer->stop();
}
@@ -169,3 +174,40 @@ void GrabberWrapper::handleSettingsUpdate(const settings::type& type, const QJso
}
}
}
void GrabberWrapper::handleSourceRequest(const hyperion::Components& component, const int hyperionInd, const bool listen)
{
if(component == hyperion::Components::COMP_GRABBER && !_grabberName.startsWith("V4L"))
{
if(listen && !GRABBER_SYS_CLIENTS.contains(hyperionInd))
GRABBER_SYS_CLIENTS.append(hyperionInd);
else if (!listen)
GRABBER_SYS_CLIENTS.removeOne(hyperionInd);
if(GRABBER_SYS_CLIENTS.empty())
stop();
else
start();
}
else if(component == hyperion::Components::COMP_V4L && _grabberName.startsWith("V4L"))
{
if(listen && !GRABBER_V4L_CLIENTS.contains(hyperionInd))
GRABBER_V4L_CLIENTS.append(hyperionInd);
else if (!listen)
GRABBER_V4L_CLIENTS.removeOne(hyperionInd);
if(GRABBER_V4L_CLIENTS.empty())
stop();
else
start();
}
}
void GrabberWrapper::tryStart()
{
// verify start condition
if((_grabberName.startsWith("V4L") && !GRABBER_V4L_CLIENTS.empty()) || (!_grabberName.startsWith("V4L") && !GRABBER_SYS_CLIENTS.empty()))
{
start();
}
}