Feature/CEC detection (#877)

* Add CEC functionality

* Initial commit

* removed libCEC from the system skip list

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
Murat Seker
2020-07-20 20:06:41 +02:00
committed by GitHub
parent a3ce4fa706
commit c124e2136a
35 changed files with 651 additions and 89 deletions

View File

@@ -14,5 +14,5 @@ target_link_libraries(v4l2-grabber
if(TURBOJPEG_FOUND)
target_link_libraries(v4l2-grabber ${TurboJPEG_LIBRARY})
elseif (JPEG_FOUND)
target_link_libraries(v4l2-grabber ${JPEG_LIBRARY})
target_link_libraries(v4l2-grabber ${JPEG_LIBRARY})
endif(TURBOJPEG_FOUND)

View File

@@ -52,6 +52,8 @@ V4L2Grabber::V4L2Grabber(const QString & device
, _noSignalCounterThreshold(40)
, _noSignalThresholdColor(ColorRgb{0,0,0})
, _signalDetectionEnabled(true)
, _cecDetectionEnabled(true)
, _cecStandbyActivated(false)
, _noSignalDetected(false)
, _noSignalCounter(0)
, _x_frac_min(0.25)
@@ -1031,6 +1033,9 @@ bool V4L2Grabber::process_image(const void *p, int size)
void V4L2Grabber::process_image(const uint8_t * data, int size)
{
if (_cecDetectionEnabled && _cecStandbyActivated)
return;
Image<ColorRgb> image(_width, _height);
/* ----------------------------------------------------------
@@ -1291,6 +1296,15 @@ void V4L2Grabber::setSignalDetectionEnable(bool enable)
}
}
void V4L2Grabber::setCecDetectionEnable(bool enable)
{
if (_cecDetectionEnabled != enable)
{
_cecDetectionEnabled = enable;
Info(_log, QString("CEC detection is now %1").arg(enable ? "enabled" : "disabled").toLocal8Bit());
}
}
void V4L2Grabber::setPixelDecimation(int pixelDecimation)
{
if (_pixelDecimation != pixelDecimation)
@@ -1383,3 +1397,19 @@ QStringList V4L2Grabber::getFramerates(QString devicePath)
{
return _deviceProperties.value(devicePath).framerates;
}
void V4L2Grabber::handleCecEvent(CECEvent event)
{
switch (event)
{
case CECEvent::On :
Debug(_log,"CEC on event received");
_cecStandbyActivated = false;
return;
case CECEvent::Off :
Debug(_log,"CEC off event received");
_cecStandbyActivated = true;
return;
default: break;
}
}

View File

@@ -90,7 +90,22 @@ bool V4L2Wrapper::getSignalDetectionEnable()
return _grabber.getSignalDetectionEnabled();
}
void V4L2Wrapper::setCecDetectionEnable(bool enable)
{
_grabber.setCecDetectionEnable(enable);
}
bool V4L2Wrapper::getCecDetectionEnable()
{
return _grabber.getCecDetectionEnabled();
}
void V4L2Wrapper::setDeviceVideoStandard(QString device, VideoStandard videoStandard)
{
_grabber.setDeviceVideoStandard(device, videoStandard);
}
void V4L2Wrapper::handleCecEvent(CECEvent event)
{
_grabber.handleCecEvent(event);
}