enable components at runtime + grabber refactoring (#160)

* implement enable/disable on runtime for:
- smoothing
- kodi
- udplistener
- boblight

* implement enable/disable for forwarder
refactor component

* - implement grabber enable/disable at runtime
- big grabber refactoring. now with common base class for all grabbers

* implement enable/disable at runtime for bb detector

* osx fix

* try to fix cutted travis output for osx build
This commit is contained in:
redPanther
2016-08-11 07:13:55 +02:00
committed by GitHub
parent 0d3f6c7ba1
commit f1cc82b8c7
36 changed files with 471 additions and 495 deletions

View File

@@ -15,9 +15,9 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
double redSignalThreshold,
double greenSignalThreshold,
double blueSignalThreshold,
int hyperionPriority)
: _timeout_ms(1000)
, _priority(hyperionPriority)
const int priority)
: GrabberWrapper("V4L2", priority)
, _timeout_ms(1000)
, _grabber(device,
input,
videoStandard,
@@ -27,10 +27,7 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
frameDecimation,
pixelDecimation,
pixelDecimation)
, _processor(ImageProcessorFactory::getInstance().newImageProcessor())
, _hyperion(Hyperion::getInstance())
, _ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0})
, _timer()
{
// set the signal detection threshold of the grabber
_grabber.setSignalThreshold( redSignalThreshold, greenSignalThreshold, blueSignalThreshold, 50);
@@ -46,44 +43,30 @@ V4L2Wrapper::V4L2Wrapper(const std::string &device,
Qt::DirectConnection);
// send color data to Hyperion using a queued connection to handle the data over to the main event loop
QObject::connect(
this, SIGNAL(emitColors(int,std::vector<ColorRgb>,int)),
_hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int)),
Qt::QueuedConnection);
// QObject::connect(
// this, SIGNAL(emitColors(int,std::vector<ColorRgb>,int)),
// _hyperion, SLOT(setColors(int,std::vector<ColorRgb>,int)),
// Qt::QueuedConnection);
// setup the higher prio source checker
// this will disable the v4l2 grabber when a source with hisher priority is active
// this will disable the v4l2 grabber when a source with higher priority is active
_timer.setInterval(500);
_timer.setSingleShot(false);
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(checkSources()));
}
V4L2Wrapper::~V4L2Wrapper()
{
delete _processor;
}
bool V4L2Wrapper::start()
{
_timer.start();
bool grabber_started = _grabber.start();
if ( ! grabber_started )
{
_timer.stop();
}
else
{
_hyperion->registerPriority("V4L2", _priority);
}
return grabber_started;
return ( _grabber.start() && GrabberWrapper::start());
}
void V4L2Wrapper::stop()
{
_grabber.stop();
_hyperion->unRegisterPriority("V4L2");
GrabberWrapper::stop();
}
void V4L2Wrapper::setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom)
@@ -98,14 +81,15 @@ void V4L2Wrapper::set3D(VideoMode mode)
void V4L2Wrapper::newFrame(const Image<ColorRgb> &image)
{
// forward to other hyperions
if ( _forward )
{
emit emitImage(_priority, image, _timeout_ms);
}
// process the new image
_processor->process(image, _ledColors);
// forward to other hyperions
emit emitImage(_priority, image, _timeout_ms);
// send colors to Hyperion
emit emitColors(_priority, _ledColors, _timeout_ms);
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
}
void V4L2Wrapper::checkSources()
@@ -125,3 +109,8 @@ void V4L2Wrapper::checkSources()
// no higher priority source was found: grabber should be enabled
_grabber.start();
}
void V4L2Wrapper::action()
{
checkSources();
}