-Reload MF Grabber only once per WebUI update

- Cleanup
This commit is contained in:
Paulchen Panther 2021-01-26 20:01:23 +01:00
parent b0afa7cd03
commit 456cccd9cf
10 changed files with 109 additions and 147 deletions

View File

@ -56,7 +56,7 @@ public:
QList<DevicePropertiesItem> valid = QList<DevicePropertiesItem>(); QList<DevicePropertiesItem> valid = QList<DevicePropertiesItem>();
}; };
MFGrabber(const QString & device, const unsigned width, const unsigned height, const unsigned fps, const unsigned input, int pixelDecimation, QString flipMode); MFGrabber(const QString & device, const unsigned width, const unsigned height, const unsigned fps, int pixelDecimation, QString flipMode);
~MFGrabber() override; ~MFGrabber() override;
void receive_image(const void *frameImageBuffer, int size); void receive_image(const void *frameImageBuffer, int size);
@ -74,14 +74,15 @@ public:
void setSignalDetectionEnable(bool enable) override; void setSignalDetectionEnable(bool enable) override;
void setPixelDecimation(int pixelDecimation) override; void setPixelDecimation(int pixelDecimation) override;
void setCecDetectionEnable(bool enable) override; void setCecDetectionEnable(bool enable) override;
void setDeviceVideoStandard(QString device, VideoStandard videoStandard) override; bool setDevice(QString device) override;
bool setInput(int input) override;
bool setWidthHeight(int width, int height) override; bool setWidthHeight(int width, int height) override;
bool setFramerate(int fps) override; bool setFramerate(int fps) override;
void setFpsSoftwareDecimation(int decimation); void setFpsSoftwareDecimation(int decimation);
void setEncoding(QString enc); bool setEncoding(QString enc);
void setFlipMode(QString flipMode); void setFlipMode(QString flipMode);
void setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue); bool setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue);
void reloadGrabber();
public slots: public slots:
bool start(); bool start();
@ -105,7 +106,7 @@ private:
QMap<QString, MFGrabber::DeviceProperties> _deviceProperties; QMap<QString, MFGrabber::DeviceProperties> _deviceProperties;
HRESULT _hr; HRESULT _hr;
SourceReaderCB* _sourceReaderCB; SourceReaderCB* _sourceReaderCB;
PixelFormat _pixelFormat; PixelFormat _pixelFormat, _pixelFormatConfig;
int _pixelDecimation, int _pixelDecimation,
_lineLength, _lineLength,
_frameByteSize, _frameByteSize,

View File

@ -51,25 +51,15 @@ private:
tjtransform* _xform; tjtransform* _xform;
#endif #endif
static volatile bool _isActive; static volatile bool _isActive;
volatile bool _isBusy; volatile bool _isBusy;
QSemaphore _semaphore; QSemaphore _semaphore;
unsigned int _threadIndex; unsigned int _threadIndex;
PixelFormat _pixelFormat; PixelFormat _pixelFormat;
uint8_t* _localData; uint8_t* _localData, *_flipBuffer;
int _localDataSize, int _scalingFactorsCount, _width, _height, _lineLength, _subsamp, _currentFrame, _pixelDecimation;
_scalingFactorsCount, unsigned long _size;
_size, unsigned _cropLeft, _cropTop, _cropBottom, _cropRight;
_width,
_height,
_lineLength,
_subsamp,
_currentFrame,
_pixelDecimation;
unsigned _cropLeft,
_cropTop,
_cropBottom,
_cropRight;
FlipMode _flipMode; FlipMode _flipMode;
ImageResampler _imageResampler; ImageResampler _imageResampler;
}; };

View File

@ -8,7 +8,7 @@ class MFWrapper : public GrabberWrapper
Q_OBJECT Q_OBJECT
public: public:
MFWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned fps, const unsigned input, int pixelDecimation, QString flipMode); MFWrapper(const QString & device, const unsigned grabWidth, const unsigned grabHeight, const unsigned fps, int pixelDecimation, QString flipMode);
~MFWrapper() override; ~MFWrapper() override;
bool getSignalDetectionEnable() const; bool getSignalDetectionEnable() const;
@ -23,17 +23,11 @@ public slots:
void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax); void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax);
void setSignalDetectionEnable(bool enable); void setSignalDetectionEnable(bool enable);
void setCecDetectionEnable(bool enable); void setCecDetectionEnable(bool enable);
void setDeviceVideoStandard(const QString& device, VideoStandard videoStandard); bool setDevice(const QString& device);
void handleSettingsUpdate(settings::type type, const QJsonDocument& config) override;
///
/// @brief set software decimation (v4l2)
///
void setFpsSoftwareDecimation(int decimation); void setFpsSoftwareDecimation(int decimation);
bool setEncoding(QString enc);
void setEncoding(QString enc); bool setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue);
void handleSettingsUpdate(settings::type type, const QJsonDocument& config) override;
void setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue);
private slots: private slots:
void newFrame(const Image<ColorRgb> & image); void newFrame(const Image<ColorRgb> & image);

View File

@ -92,10 +92,15 @@ public:
virtual void setCecDetectionEnable(bool enable) {} virtual void setCecDetectionEnable(bool enable) {}
/// ///
/// @brief Apply device and videoStanded (used from v4l) /// @brief Apply device and videoStandard (used from v4l)
/// ///
virtual void setDeviceVideoStandard(QString device, VideoStandard videoStandard) {} virtual void setDeviceVideoStandard(QString device, VideoStandard videoStandard) {}
///
/// @brief Apply device (used from MediaFoundation)
///
virtual bool setDevice(QString device) { return false; }
/// ///
/// @brief Apply display index (used from qt) /// @brief Apply display index (used from qt)
/// ///

View File

@ -4,7 +4,7 @@
// Constants // Constants
namespace { const bool verbose = false; } namespace { const bool verbose = false; }
MFGrabber::MFGrabber(const QString & device, unsigned width, unsigned height, unsigned fps, unsigned input, int pixelDecimation, QString flipMode) MFGrabber::MFGrabber(const QString & device, unsigned width, unsigned height, unsigned fps, int pixelDecimation, QString flipMode)
: Grabber("V4L2:"+device) : Grabber("V4L2:"+device)
, _deviceName(device) , _deviceName(device)
, _hr(S_FALSE) , _hr(S_FALSE)
@ -30,11 +30,9 @@ MFGrabber::MFGrabber(const QString & device, unsigned width, unsigned height, un
, _x_frac_max(0.75) , _x_frac_max(0.75)
, _y_frac_max(0.75) , _y_frac_max(0.75)
{ {
setInput(input);
setWidthHeight(width, height); setWidthHeight(width, height);
setFramerate(fps); setFramerate(fps);
setFlipMode(flipMode); setFlipMode(flipMode);
// setDeviceVideoStandard(device, videoStandard); // TODO
CoInitializeEx(0, COINIT_MULTITHREADED); CoInitializeEx(0, COINIT_MULTITHREADED);
_hr = MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET); _hr = MFStartup(MF_VERSION, MFSTARTUP_NOSOCKET);
@ -178,7 +176,8 @@ HRESULT MFGrabber::init_device(QString deviceName, DevicePropertiesItem props)
IMFMediaType* type = nullptr; IMFMediaType* type = nullptr;
HRESULT hr = S_OK; HRESULT hr = S_OK;
Debug(_log, "Init %s, %d x %d @ %d fps (%s) => %s", QSTRING_CSTR(deviceName), props.x, props.y, props.fps, QSTRING_CSTR(pixelFormatToString(pixelformat)), QSTRING_CSTR(guid)); Debug(_log, "Init %s, %d x %d @ %d fps (%s)", QSTRING_CSTR(deviceName), props.x, props.y, props.fps, QSTRING_CSTR(pixelFormatToString(pixelformat)));
DebugIf(verbose, _log, "Symbolic link: %s", QSTRING_CSTR(guid));
hr = MFCreateAttributes(&deviceAttributes, 2); hr = MFCreateAttributes(&deviceAttributes, 2);
if(FAILED(hr)) if(FAILED(hr))
@ -426,7 +425,7 @@ void MFGrabber::enumVideoCaptureDevices()
IMFActivate** devices; IMFActivate** devices;
if(SUCCEEDED(MFEnumDeviceSources(attr, &devices, &count))) if(SUCCEEDED(MFEnumDeviceSources(attr, &devices, &count)))
{ {
Debug(_log, "Detected devices: %u", count); DebugIf(verbose, _log, "Detected devices: %u", count);
for(UINT32 i = 0; i < count; i++) for(UINT32 i = 0; i < count; i++)
{ {
UINT32 length; UINT32 length;
@ -441,7 +440,7 @@ void MFGrabber::enumVideoCaptureDevices()
MFGrabber::DeviceProperties properties; MFGrabber::DeviceProperties properties;
properties.name = QString::fromUtf16((const ushort*)symlink); properties.name = QString::fromUtf16((const ushort*)symlink);
Info(_log, "Found capture device: %s", QSTRING_CSTR(dev)); Debug(_log, "Found capture device: %s", QSTRING_CSTR(dev));
IMFMediaSource *pSource = nullptr; IMFMediaSource *pSource = nullptr;
if(SUCCEEDED(devices[i]->ActivateObject(IID_PPV_ARGS(&pSource)))) if(SUCCEEDED(devices[i]->ActivateObject(IID_PPV_ARGS(&pSource))))
{ {
@ -523,7 +522,7 @@ void MFGrabber::enumVideoCaptureDevices()
void MFGrabber::start_capturing() void MFGrabber::start_capturing()
{ {
if (_sourceReader) if (_initialized && _sourceReader)
{ {
HRESULT hr = _sourceReader->ReadSample(MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, NULL, NULL, NULL); HRESULT hr = _sourceReader->ReadSample(MF_SOURCE_READER_FIRST_VIDEO_STREAM, 0, NULL, NULL, NULL, NULL);
if (!SUCCEEDED(hr)) if (!SUCCEEDED(hr))
@ -610,7 +609,7 @@ bool MFGrabber::start()
try try
{ {
_threadManager.start(); _threadManager.start();
Info(_log, "Decoding threads: %d",_threadManager._maxThreads); DebugIf(verbose, _log, "Decoding threads: %d",_threadManager._maxThreads);
if(init()) if(init())
{ {
@ -631,10 +630,11 @@ void MFGrabber::stop()
{ {
if(_initialized) if(_initialized)
{ {
_initialized = false;
_threadManager.stop(); _threadManager.stop();
uninit_device(); uninit_device();
_pixelFormat = _pixelFormatConfig;
_deviceProperties.clear(); _deviceProperties.clear();
_initialized = false;
Info(_log, "Stopped"); Info(_log, "Stopped");
} }
} }
@ -741,6 +741,16 @@ void MFGrabber::setCecDetectionEnable(bool enable)
} }
} }
bool MFGrabber::setDevice(QString device)
{
if(_deviceName != device)
{
_deviceName = device;
return true;
}
return false;
}
void MFGrabber::setPixelDecimation(int pixelDecimation) void MFGrabber::setPixelDecimation(int pixelDecimation)
{ {
if(_pixelDecimation != pixelDecimation) if(_pixelDecimation != pixelDecimation)
@ -753,46 +763,11 @@ void MFGrabber::setFlipMode(QString flipMode)
Grabber::setFlipMode(parseFlipMode(flipMode)); Grabber::setFlipMode(parseFlipMode(flipMode));
} }
void MFGrabber::setDeviceVideoStandard(QString device, VideoStandard videoStandard)
{
if(_deviceName != device)
{
_deviceName = device;
if(_initialized && !device.isEmpty())
{
Debug(_log,"Restarting Media Foundation grabber");
uninit();
start();
}
}
}
bool MFGrabber::setInput(int input)
{
if(Grabber::setInput(input))
{
bool started = _initialized;
uninit();
if(started)
start();
return true;
}
return false;
}
bool MFGrabber::setWidthHeight(int width, int height) bool MFGrabber::setWidthHeight(int width, int height)
{ {
if(Grabber::setWidthHeight(width,height)) if(Grabber::setWidthHeight(width, height))
{ {
Debug(_log,"Set width:height to: %i:&i", width, height); Debug(_log,"Set width:height to: %i:%i", width, height);
if(_initialized)
{
Debug(_log,"Restarting Media Foundation grabber");
uninit();
start();
}
return true; return true;
} }
return false; return false;
@ -803,12 +778,6 @@ bool MFGrabber::setFramerate(int fps)
if(Grabber::setFramerate(fps)) if(Grabber::setFramerate(fps))
{ {
Debug(_log,"Set fps to: %i", fps); Debug(_log,"Set fps to: %i", fps);
if(_initialized)
{
Debug(_log,"Restarting Media Foundation grabber");
uninit();
start();
}
return true; return true;
} }
return false; return false;
@ -821,22 +790,20 @@ void MFGrabber::setFpsSoftwareDecimation(int decimation)
Debug(_log,"Every %ith image per second are processed", decimation); Debug(_log,"Every %ith image per second are processed", decimation);
} }
void MFGrabber::setEncoding(QString enc) bool MFGrabber::setEncoding(QString enc)
{ {
if(_pixelFormat != parsePixelFormat(enc)) if(_pixelFormatConfig != parsePixelFormat(enc))
{ {
Debug(_log,"Set encoding to: %s", QSTRING_CSTR(enc)); Debug(_log,"Set hardware encoding to: %s", QSTRING_CSTR(enc.toUpper()));
_pixelFormat = parsePixelFormat(enc); _pixelFormatConfig = parsePixelFormat(enc);
if(_initialized) if(!_initialized)
{ _pixelFormat = _pixelFormatConfig;
Debug(_log,"Restarting Media Foundation Grabber"); return true;
uninit();
start();
}
} }
return false;
} }
void MFGrabber::setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue) bool MFGrabber::setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue)
{ {
if(_brightness != brightness || _contrast != contrast || _saturation != saturation || _hue != hue) if(_brightness != brightness || _contrast != contrast || _saturation != saturation || _hue != hue)
{ {
@ -846,12 +813,21 @@ void MFGrabber::setBrightnessContrastSaturationHue(int brightness, int contrast,
_hue = hue; _hue = hue;
Debug(_log,"Set brightness to %i, contrast to %i, saturation to %i, hue to %i", _brightness, _contrast, _saturation, _hue); Debug(_log,"Set brightness to %i, contrast to %i, saturation to %i, hue to %i", _brightness, _contrast, _saturation, _hue);
return true;
}
return false;
}
if(_initialized) void MFGrabber::reloadGrabber()
{ {
Debug(_log,"Restarting Media Foundation Grabber"); if(_initialized)
uninit(); {
start(); Debug(_log,"Reloading Media Foundation Grabber");
} // stop grabber
uninit();
// restore pixelformat to configs value
_pixelFormat = _pixelFormatConfig;
// start grabber
start();
} }
} }

View File

@ -331,7 +331,13 @@ public:
STDMETHODIMP OnFlush(DWORD) { return S_OK; } STDMETHODIMP OnFlush(DWORD) { return S_OK; }
private: private:
virtual ~SourceReaderCB() {} virtual ~SourceReaderCB()
{
_transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0);
_transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_STREAMING, 0);
SAFE_RELEASE(_transform);
}
void NotifyError(HRESULT hr) { Error(_grabber->_log, "Source Reader error"); } void NotifyError(HRESULT hr) { Error(_grabber->_log, "Source Reader error"); }
private: private:

View File

@ -6,7 +6,6 @@ MFThread::MFThread()
: _isBusy(false) : _isBusy(false)
, _semaphore(1) , _semaphore(1)
, _localData(nullptr) , _localData(nullptr)
, _localDataSize(0)
, _scalingFactorsCount(0) , _scalingFactorsCount(0)
, _scalingFactors(nullptr) , _scalingFactors(nullptr)
, _transform(nullptr) , _transform(nullptr)
@ -28,7 +27,6 @@ MFThread::~MFThread()
{ {
free(_localData); free(_localData);
_localData = nullptr; _localData = nullptr;
_localDataSize = 0;
} }
} }
@ -41,7 +39,7 @@ void MFThread::setup(
_threadIndex = threadIndex; _threadIndex = threadIndex;
_lineLength = lineLength; _lineLength = lineLength;
_pixelFormat = pixelFormat; _pixelFormat = pixelFormat;
_size = size; _size = (unsigned long) size;
_width = width; _width = width;
_height = height; _height = height;
_subsamp = subsamp; _subsamp = subsamp;
@ -59,15 +57,10 @@ void MFThread::setup(
_imageResampler.setHorizontalPixelDecimation(_pixelDecimation); _imageResampler.setHorizontalPixelDecimation(_pixelDecimation);
_imageResampler.setVerticalPixelDecimation(_pixelDecimation); _imageResampler.setVerticalPixelDecimation(_pixelDecimation);
if (size > _localDataSize) if (_localData)
{ tjFree(_localData);
if (_localData)
tjFree(_localData);
_localData = (uint8_t*)tjAlloc(size + 1);
_localDataSize = size;
}
_localData = (uint8_t*)tjAlloc(size + 1);
memcpy(_localData, sharedData, size); memcpy(_localData, sharedData, size);
} }
@ -121,21 +114,13 @@ void MFThread::processImageMjpeg()
if (_flipMode == FlipMode::BOTH || _flipMode == FlipMode::HORIZONTAL) if (_flipMode == FlipMode::BOTH || _flipMode == FlipMode::HORIZONTAL)
{ {
_xform->op = TJXOP_HFLIP; _xform->op = TJXOP_HFLIP;
uint8_t* dstBuf = nullptr; tjTransform(_transform, _localData, _size, 1, &_localData, &_size, _xform, TJFLAG_FASTDCT | TJFLAG_FASTUPSAMPLE);
unsigned long dstSize = 0;
tjTransform(_transform, _localData, _size, 1, &dstBuf, &dstSize, _xform, TJFLAG_FASTDCT | TJFLAG_FASTUPSAMPLE);
_localData = dstBuf;
_size = dstSize;
} }
if (_flipMode == FlipMode::BOTH || _flipMode == FlipMode::VERTICAL) if (_flipMode == FlipMode::BOTH || _flipMode == FlipMode::VERTICAL)
{ {
_xform->op = TJXOP_VFLIP; _xform->op = TJXOP_VFLIP;
uint8_t *dstBuf = nullptr; tjTransform(_transform, _localData, _size, 1, &_localData, &_size, _xform, TJFLAG_FASTDCT | TJFLAG_FASTUPSAMPLE);
unsigned long dstSize = 0;
tjTransform(_transform, _localData, _size, 1, &dstBuf, &dstSize, _xform, TJFLAG_FASTDCT | TJFLAG_FASTUPSAMPLE);
_localData = dstBuf;
_size = dstSize;
} }
if (!_decompress) if (!_decompress)

View File

@ -5,9 +5,9 @@
// qt // qt
#include <QTimer> #include <QTimer>
MFWrapper::MFWrapper(const QString &device, unsigned grabWidth, unsigned grabHeight, unsigned fps, unsigned input, int pixelDecimation, QString flipMode) MFWrapper::MFWrapper(const QString &device, unsigned grabWidth, unsigned grabHeight, unsigned fps, int pixelDecimation, QString flipMode)
: GrabberWrapper("V4L2:"+device, &_grabber, grabWidth, grabHeight, 10) : GrabberWrapper("V4L2:"+device, &_grabber, grabWidth, grabHeight, 10)
, _grabber(device, grabWidth, grabHeight, fps, input, pixelDecimation, flipMode) , _grabber(device, grabWidth, grabHeight, fps, pixelDecimation, flipMode)
{ {
_ggrabber = &_grabber; _ggrabber = &_grabber;
@ -79,9 +79,9 @@ bool MFWrapper::getCecDetectionEnable() const
return _grabber.getCecDetectionEnabled(); return _grabber.getCecDetectionEnabled();
} }
void MFWrapper::setDeviceVideoStandard(const QString& device, VideoStandard videoStandard) bool MFWrapper::setDevice(const QString& device)
{ {
_grabber.setDeviceVideoStandard(device, VideoStandard::NO_CHANGE); return _grabber.setDevice(device);
} }
void MFWrapper::setFpsSoftwareDecimation(int decimation) void MFWrapper::setFpsSoftwareDecimation(int decimation)
@ -89,14 +89,14 @@ void MFWrapper::setFpsSoftwareDecimation(int decimation)
_grabber.setFpsSoftwareDecimation(decimation); _grabber.setFpsSoftwareDecimation(decimation);
} }
void MFWrapper::setEncoding(QString enc) bool MFWrapper::setEncoding(QString enc)
{ {
_grabber.setEncoding(enc); return _grabber.setEncoding(enc);
} }
void MFWrapper::setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue) bool MFWrapper::setBrightnessContrastSaturationHue(int brightness, int contrast, int saturation, int hue)
{ {
_grabber.setBrightnessContrastSaturationHue(brightness, contrast, saturation, hue); return _grabber.setBrightnessContrastSaturationHue(brightness, contrast, saturation, hue);
} }
void MFWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& config) void MFWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& config)
@ -105,20 +105,23 @@ void MFWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& c
{ {
// extract settings // extract settings
const QJsonObject& obj = config.object(); const QJsonObject& obj = config.object();
// reload state
bool reload = false;
// device name, video standard // device name, video standard
_grabber.setDeviceVideoStandard( if (_grabber.setDevice(obj["device"].toString("auto")))
obj["device"].toString("auto"), reload = true;
parseVideoStandard(obj["standard"].toString("no-change")));
// device input // device input
_grabber.setInput(obj["input"].toInt(-1)); _grabber.setInput(obj["input"].toInt(-1));
// device resolution // device resolution
_grabber.setWidthHeight(obj["width"].toInt(0), obj["height"].toInt(0)); if (_grabber.setWidthHeight(obj["width"].toInt(0), obj["height"].toInt(0)))
reload = true;
// device framerate // device framerate
_grabber.setFramerate(obj["fps"].toInt(15)); if (_grabber.setFramerate(obj["fps"].toInt(15)))
reload = true;
// image size decimation // image size decimation
_grabber.setPixelDecimation(obj["sizeDecimation"].toInt(8)); _grabber.setPixelDecimation(obj["sizeDecimation"].toInt(8));
@ -134,10 +137,8 @@ void MFWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& c
obj["cropBottom"].toInt(0)); obj["cropBottom"].toInt(0));
// Brightness, Contrast, Saturation, Hue // Brightness, Contrast, Saturation, Hue
_grabber.setBrightnessContrastSaturationHue(obj["hardware_brightness"].toInt(0), if (_grabber.setBrightnessContrastSaturationHue(obj["hardware_brightness"].toInt(0), obj["hardware_contrast"].toInt(0), obj["hardware_saturation"].toInt(0), obj["hardware_hue"].toInt(0)))
obj["hardware_contrast"].toInt(0), reload = true;
obj["hardware_saturation"].toInt(0),
obj["hardware_hue"].toInt(0));
// CEC Standby // CEC Standby
_grabber.setCecDetectionEnable(obj["cecDetection"].toBool(true)); _grabber.setCecDetectionEnable(obj["cecDetection"].toBool(true));
@ -146,6 +147,7 @@ void MFWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& c
_grabber.setFpsSoftwareDecimation(obj["fpsSoftwareDecimation"].toInt(1)); _grabber.setFpsSoftwareDecimation(obj["fpsSoftwareDecimation"].toInt(1));
// Signal detection // Signal detection
_grabber.setSignalDetectionEnable(obj["signalDetection"].toBool(true));
_grabber.setSignalDetectionOffset( _grabber.setSignalDetectionOffset(
obj["sDHOffsetMin"].toDouble(0.25), obj["sDHOffsetMin"].toDouble(0.25),
obj["sDVOffsetMin"].toDouble(0.25), obj["sDVOffsetMin"].toDouble(0.25),
@ -156,9 +158,13 @@ void MFWrapper::handleSettingsUpdate(settings::type type, const QJsonDocument& c
obj["greenSignalThreshold"].toDouble(0.0)/100.0, obj["greenSignalThreshold"].toDouble(0.0)/100.0,
obj["blueSignalThreshold"].toDouble(0.0)/100.0, obj["blueSignalThreshold"].toDouble(0.0)/100.0,
obj["noSignalCounterThreshold"].toInt(50) ); obj["noSignalCounterThreshold"].toInt(50) );
_grabber.setSignalDetectionEnable(obj["signalDetection"].toBool(true));
// Hardware encoding format // Hardware encoding format
_grabber.setEncoding(obj["encoding"].toString("NO_CHANGE")); if (_grabber.setEncoding(obj["encoding"].toString("NO_CHANGE")))
reload = true;
// Reload the Grabber if any settings have been changed that require it
if (reload)
_grabber.reloadGrabber();
} }
} }

View File

@ -15,7 +15,7 @@ GrabberWrapper::GrabberWrapper(const QString& grabberName, Grabber * ggrabber, u
: _grabberName(grabberName) : _grabberName(grabberName)
, _timer(new QTimer(this)) , _timer(new QTimer(this))
, _updateInterval_ms(1000/updateRate_Hz) , _updateInterval_ms(1000/updateRate_Hz)
, _log(Logger::getInstance(grabberName)) , _log(Logger::getInstance(grabberName.toUpper()))
, _ggrabber(ggrabber) , _ggrabber(ggrabber)
, _image(0,0) , _image(0,0)
{ {

View File

@ -604,7 +604,6 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
grabberConfig["width"].toInt(0), grabberConfig["width"].toInt(0),
grabberConfig["height"].toInt(0), grabberConfig["height"].toInt(0),
grabberConfig["fps"].toInt(15), grabberConfig["fps"].toInt(15),
grabberConfig["input"].toInt(-1),
grabberConfig["sizeDecimation"].toInt(8), grabberConfig["sizeDecimation"].toInt(8),
grabberConfig["flip"].toString("auto")); grabberConfig["flip"].toString("auto"));
@ -619,9 +618,10 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
_mfGrabber->setFpsSoftwareDecimation(grabberConfig["fpsSoftwareDecimation"].toInt(1)); _mfGrabber->setFpsSoftwareDecimation(grabberConfig["fpsSoftwareDecimation"].toInt(1));
// Hardware encoding format // Hardware encoding format
_mfGrabber->setEncoding(grabberConfig["encoding"].toString("NONE")); _mfGrabber->setEncoding(grabberConfig["encoding"].toString("NO_CHANGE"));
// Signal detection // Signal detection
_mfGrabber->setSignalDetectionEnable(grabberConfig["signalDetection"].toBool(true));
_mfGrabber->setSignalDetectionOffset( _mfGrabber->setSignalDetectionOffset(
grabberConfig["sDHOffsetMin"].toDouble(0.25), grabberConfig["sDHOffsetMin"].toDouble(0.25),
grabberConfig["sDVOffsetMin"].toDouble(0.25), grabberConfig["sDVOffsetMin"].toDouble(0.25),
@ -632,7 +632,6 @@ void HyperionDaemon::handleSettingsUpdate(settings::type settingsType, const QJs
grabberConfig["greenSignalThreshold"].toDouble(0.0) / 100.0, grabberConfig["greenSignalThreshold"].toDouble(0.0) / 100.0,
grabberConfig["blueSignalThreshold"].toDouble(0.0) / 100.0, grabberConfig["blueSignalThreshold"].toDouble(0.0) / 100.0,
grabberConfig["noSignalCounterThreshold"].toInt(50) ); grabberConfig["noSignalCounterThreshold"].toInt(50) );
_mfGrabber->setSignalDetectionEnable(grabberConfig["signalDetection"].toBool(true));
// CEC Standby // CEC Standby
_mfGrabber->setCecDetectionEnable(grabberConfig["cecDetection"].toBool(true)); _mfGrabber->setCecDetectionEnable(grabberConfig["cecDetection"].toBool(true));