2015-08-07 14:37:41 +02:00
|
|
|
// QT includes
|
|
|
|
#include <QDateTime>
|
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
#include <hyperion/ImageProcessorFactory.h>
|
|
|
|
#include <hyperion/ImageProcessor.h>
|
|
|
|
|
|
|
|
// Amlogic grabber includes
|
|
|
|
#include <grabber/AmlogicWrapper.h>
|
2016-02-24 14:42:25 +01:00
|
|
|
#include <grabber/AmlogicGrabber.h>
|
2015-08-07 14:37:41 +02:00
|
|
|
|
|
|
|
|
2016-07-27 22:52:59 +02:00
|
|
|
AmlogicWrapper::AmlogicWrapper(const unsigned grabWidth, const unsigned grabHeight, const unsigned updateRate_Hz, const int priority)
|
2016-08-11 07:13:55 +02:00
|
|
|
: GrabberWrapper("AmLogic", priority)
|
|
|
|
, _updateInterval_ms(1000/updateRate_Hz)
|
2016-07-27 22:52:59 +02:00
|
|
|
, _timeout_ms(2 * _updateInterval_ms)
|
|
|
|
, _image(grabWidth, grabHeight)
|
2016-08-11 07:13:55 +02:00
|
|
|
, _grabber(new AmlogicGrabber(grabWidth, grabHeight))
|
2016-07-27 22:52:59 +02:00
|
|
|
, _ledColors(Hyperion::getInstance()->getLedCount(), ColorRgb{0,0,0})
|
2015-08-07 14:37:41 +02:00
|
|
|
{
|
|
|
|
// Configure the timer to generate events every n milliseconds
|
|
|
|
_timer.setInterval(_updateInterval_ms);
|
|
|
|
|
|
|
|
_processor->setSize(grabWidth, grabHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
AmlogicWrapper::~AmlogicWrapper()
|
|
|
|
{
|
2016-08-11 07:13:55 +02:00
|
|
|
delete _grabber;
|
2015-08-07 14:37:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void AmlogicWrapper::action()
|
|
|
|
{
|
|
|
|
// Grab frame into the allocated image
|
2016-08-11 07:13:55 +02:00
|
|
|
if (_grabber->grabFrame(_image) < 0)
|
2015-08-20 09:51:44 +02:00
|
|
|
{
|
|
|
|
// Frame grab failed, maybe nothing playing or ....
|
|
|
|
return;
|
|
|
|
}
|
2015-08-07 14:37:41 +02:00
|
|
|
|
2016-02-24 14:34:19 +01:00
|
|
|
if ( _forward )
|
|
|
|
{
|
|
|
|
Image<ColorRgb> image_rgb;
|
|
|
|
_image.toRgb(image_rgb);
|
|
|
|
emit emitImage(_priority, image_rgb, _timeout_ms);
|
|
|
|
}
|
2015-08-07 14:37:41 +02:00
|
|
|
|
2016-02-24 14:34:19 +01:00
|
|
|
_processor->process(_image, _ledColors);
|
2015-08-07 14:37:41 +02:00
|
|
|
_hyperion->setColors(_priority, _ledColors, _timeout_ms);
|
|
|
|
}
|
2015-08-20 09:51:44 +02:00
|
|
|
|
2015-08-07 14:37:41 +02:00
|
|
|
void AmlogicWrapper::setVideoMode(const VideoMode mode)
|
|
|
|
{
|
2016-08-11 07:13:55 +02:00
|
|
|
_grabber->setVideoMode(mode);
|
2015-08-07 14:37:41 +02:00
|
|
|
}
|