rework kodi grabbing mode for all grabbers (#169)

* pull out setgrabbing mode from every grabber into parent class

* implement optional kodi check for v4l

* fix typo

* fix dispmanx build
This commit is contained in:
redPanther 2016-08-12 23:07:32 +02:00 committed by GitHub
parent 050ab11c8e
commit 7ee2e7cf8d
15 changed files with 99 additions and 168 deletions

View File

@ -4,7 +4,6 @@
#include <utils/Image.h> #include <utils/Image.h>
#include <utils/ColorBgr.h> #include <utils/ColorBgr.h>
#include <utils/ColorRgb.h> #include <utils/ColorRgb.h>
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h> #include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h> #include <hyperion/GrabberWrapper.h>
@ -43,12 +42,6 @@ public slots:
/// ///
virtual void action(); virtual void action();
///
/// Set the grabbing mode
/// @param[in] mode The new grabbing mode
///
void setGrabbingMode(const GrabbingMode mode);
/// ///
/// Set the video mode (2D/3D) /// Set the video mode (2D/3D)
/// @param[in] mode The new video mode /// @param[in] mode The new video mode

View File

@ -45,11 +45,8 @@ public slots:
void setCropping(const unsigned cropLeft, const unsigned cropRight, void setCropping(const unsigned cropLeft, const unsigned cropRight,
const unsigned cropTop, const unsigned cropBottom); const unsigned cropTop, const unsigned cropBottom);
/// virtual void kodiPlay();
/// Set the grabbing mode virtual void kodiPause();
/// @param[in] mode The new grabbing mode
///
void setGrabbingMode(const GrabbingMode mode);
/// ///
/// Set the video mode (2D/3D) /// Set the video mode (2D/3D)

View File

@ -41,12 +41,6 @@ public slots:
/// ///
virtual void action(); virtual void action();
///
/// Set the grabbing mode
/// @param[in] mode The new grabbing mode
///
void setGrabbingMode(const GrabbingMode mode);
/// ///
/// Set the video mode (2D/3D) /// Set the video mode (2D/3D)
/// @param[in] mode The new video mode /// @param[in] mode The new video mode

View File

@ -43,12 +43,6 @@ public slots:
/// ///
virtual void action(); virtual void action();
///
/// Set the grabbing mode
/// @param[in] mode The new grabbing mode
///
void setGrabbingMode(const GrabbingMode mode);
/// ///
/// Set the video mode (2D/3D) /// Set the video mode (2D/3D)
/// @param[in] mode The new video mode /// @param[in] mode The new video mode

View File

@ -32,10 +32,7 @@ public slots:
void stop(); void stop();
void setCropping(int cropLeft, void setCropping(int cropLeft, int cropRight, int cropTop, int cropBottom);
int cropRight,
int cropTop,
int cropBottom);
void set3D(VideoMode mode); void set3D(VideoMode mode);

View File

@ -3,7 +3,6 @@
// Utils includes // Utils includes
#include <utils/Image.h> #include <utils/Image.h>
#include <utils/ColorRgb.h> #include <utils/ColorRgb.h>
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h> #include <utils/VideoMode.h>
#include <hyperion/GrabberWrapper.h> #include <hyperion/GrabberWrapper.h>
@ -46,12 +45,6 @@ public slots:
/// ///
virtual void action(); virtual void action();
///
/// Set the grabbing mode
/// @param[in] mode The new grabbing mode
///
void setGrabbingMode(const GrabbingMode mode);
/// ///
/// Set the video mode (2D/3D) /// Set the video mode (2D/3D)
/// @param[in] mode The new video mode /// @param[in] mode The new video mode

View File

@ -6,6 +6,7 @@
#include <utils/Logger.h> #include <utils/Logger.h>
#include <utils/Components.h> #include <utils/Components.h>
#include <utils/GrabbingMode.h>
#include <hyperion/Hyperion.h> #include <hyperion/Hyperion.h>
class ImageProcessor; class ImageProcessor;
@ -18,17 +19,39 @@ public:
virtual ~GrabberWrapper(); virtual ~GrabberWrapper();
///
/// Starts the grabber wich produces led values with the specified update rate
///
virtual bool start(); virtual bool start();
///
/// Stop grabber
///
virtual void stop(); virtual void stop();
public slots: public slots:
void componentStateChanged(const hyperion::Components component, bool enable); void componentStateChanged(const hyperion::Components component, bool enable);
///
/// virtual method, should perform single frame grab and computes the led-colors
///
virtual void action() = 0; virtual void action() = 0;
///
/// Set the grabbing mode
/// @param[in] mode The new grabbing mode
///
void setGrabbingMode(const GrabbingMode mode);
signals: signals:
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms); void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
protected: protected:
virtual void kodiPlay();
virtual void kodiOff();
virtual void kodiPause();
std::string _grabberName; std::string _grabberName;
/// Pointer to Hyperion for writing led values /// Pointer to Hyperion for writing led values

View File

@ -50,29 +50,6 @@ void AmlogicWrapper::action()
_hyperion->setColors(_priority, _ledColors, _timeout_ms); _hyperion->setColors(_priority, _ledColors, _timeout_ms);
} }
void AmlogicWrapper::setGrabbingMode(const GrabbingMode mode)
{
switch (mode)
{
case GRABBINGMODE_VIDEO:
case GRABBINGMODE_PAUSE:
// _grabber->setFlags(DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL);
start();
break;
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
// _grabber->setFlags(0);
start();
break;
case GRABBINGMODE_OFF:
stop();
break;
}
}
void AmlogicWrapper::setVideoMode(const VideoMode mode) void AmlogicWrapper::setVideoMode(const VideoMode mode)
{ {
_grabber->setVideoMode(mode); _grabber->setVideoMode(mode);

View File

@ -46,27 +46,17 @@ void DispmanxWrapper::action()
_hyperion->setColors(_priority, _ledColors, _timeout_ms); _hyperion->setColors(_priority, _ledColors, _timeout_ms);
} }
void DispmanxWrapper::setGrabbingMode(const GrabbingMode mode) void DispmanxWrapper::kodiPlay()
{ {
switch (mode)
{
case GRABBINGMODE_VIDEO:
case GRABBINGMODE_PAUSE:
_grabber->setFlags(DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL); _grabber->setFlags(DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL);
start(); GrabberWrapper::kodiPlay();
break;
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
_grabber->setFlags(0);
start();
break;
case GRABBINGMODE_OFF:
stop();
break;
} }
void DispmanxWrapper::kodiPause()
{
_grabber->setFlags(0);
GrabberWrapper::kodiPause();
} }
void DispmanxWrapper::setVideoMode(const VideoMode mode) void DispmanxWrapper::setVideoMode(const VideoMode mode)

View File

@ -40,25 +40,6 @@ void FramebufferWrapper::action()
_hyperion->setColors(_priority, _ledColors, _timeout_ms); _hyperion->setColors(_priority, _ledColors, _timeout_ms);
} }
void FramebufferWrapper::setGrabbingMode(const GrabbingMode mode)
{
switch (mode)
{
case GRABBINGMODE_VIDEO:
case GRABBINGMODE_PAUSE:
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
start();
break;
case GRABBINGMODE_OFF:
stop();
break;
}
}
void FramebufferWrapper::setVideoMode(const VideoMode mode) void FramebufferWrapper::setVideoMode(const VideoMode mode)
{ {
_grabber->setVideoMode(mode); _grabber->setVideoMode(mode);

View File

@ -40,24 +40,6 @@ void OsxWrapper::action()
_hyperion->setColors(_priority, _ledColors, _timeout_ms); _hyperion->setColors(_priority, _ledColors, _timeout_ms);
} }
void OsxWrapper::setGrabbingMode(const GrabbingMode mode)
{
switch (mode)
{
case GRABBINGMODE_VIDEO:
case GRABBINGMODE_PAUSE:
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
start();
break;
case GRABBINGMODE_OFF:
stop();
break;
}
}
void OsxWrapper::setVideoMode(const VideoMode mode) void OsxWrapper::setVideoMode(const VideoMode mode)
{ {

View File

@ -73,24 +73,6 @@ void X11Wrapper::action()
_hyperion->setColors(_priority, _ledColors, _timeout_ms); _hyperion->setColors(_priority, _ledColors, _timeout_ms);
} }
void X11Wrapper::setGrabbingMode(const GrabbingMode mode)
{
switch (mode)
{
case GRABBINGMODE_VIDEO:
case GRABBINGMODE_PAUSE:
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
start();
break;
case GRABBINGMODE_OFF:
stop();
break;
}
}
void X11Wrapper::setVideoMode(const VideoMode mode) void X11Wrapper::setVideoMode(const VideoMode mode)
{ {

View File

@ -67,3 +67,41 @@ void GrabberWrapper::componentStateChanged(const hyperion::Components component,
Info(_log, "bb detector change state to %s", (_processor->blackBorderDetectorEnabled() ? "enabled" : "disabled") ); Info(_log, "bb detector change state to %s", (_processor->blackBorderDetectorEnabled() ? "enabled" : "disabled") );
} }
} }
void GrabberWrapper::kodiPlay()
{
start();
}
void GrabberWrapper::kodiPause()
{
start();
}
void GrabberWrapper::kodiOff()
{
stop();
}
void GrabberWrapper::setGrabbingMode(const GrabbingMode mode)
{
switch (mode)
{
case GRABBINGMODE_VIDEO:
case GRABBINGMODE_PAUSE:
kodiPause();
break;
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
kodiPlay();
break;
case GRABBINGMODE_OFF:
kodiOff();
break;
}
}

View File

@ -400,93 +400,79 @@
"grabber-v4l2" : "grabber-v4l2" :
{ {
"type" : "object", "type" : "object",
"required" : false,
"properties" : "properties" :
{ {
"enable" : "enable" :
{ {
"type" : "boolean", "type" : "boolean"
"required" : true
}, },
"device" : "device" :
{ {
"type" : "string", "type" : "string"
"required" : true
}, },
"input" : "input" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"standard" : "standard" :
{ {
"type" : "string", "type" : "string"
"required" : true
}, },
"width" : "width" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"height" : "height" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"frameDecimation" : "frameDecimation" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"sizeDecimation" : "sizeDecimation" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"priority" : "priority" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"mode" : "mode" :
{ {
"type" : "string", "type" : "string"
"required" : true },
"useKodiChecker" :
{
"type" : "boolean"
}, },
"cropLeft" : "cropLeft" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"cropRight" : "cropRight" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"cropTop" : "cropTop" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"cropBottom" : "cropBottom" :
{ {
"type" : "integer", "type" : "integer"
"required" : true
}, },
"redSignalThreshold" : "redSignalThreshold" :
{ {
"type" : "number", "type" : "number"
"required" : true
}, },
"greenSignalThreshold" : "greenSignalThreshold" :
{ {
"type" : "number", "type" : "number"
"required" : true
}, },
"blueSignalThreshold" : "blueSignalThreshold" :
{ {
"type" : "number", "type" : "number"
"required" : true
} }
}, },
"additionalProperties" : false "additionalProperties" : false

View File

@ -562,6 +562,10 @@ void HyperionDaemon::createGrabberV4L2()
Debug(_log, "V4L2 grabber created"); Debug(_log, "V4L2 grabber created");
QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int))); QObject::connect(_v4l2Grabber, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _protoServer, SLOT(sendImageToProtoSlaves(int, const Image<ColorRgb>&, const int)));
if (grabberConfig["useKodiChecker"].toBool(false))
{
QObject::connect(_kodiVideoChecker, SIGNAL(grabbingMode(GrabbingMode)), _v4l2Grabber, SLOT(setGrabbingMode(GrabbingMode)));
}
InfoIf( enableV4l && _v4l2Grabber->start(), _log, "V4L2 grabber started"); InfoIf( enableV4l && _v4l2Grabber->start(), _log, "V4L2 grabber started");
#endif #endif