@@ -61,6 +61,11 @@ void GrabberWrapper::stop()
6161 }
6262}
6363
64+ bool GrabberWrapper::isActive () const
65+ {
66+ return _timer->isActive ();
67+ }
68+
6469QStringList GrabberWrapper::availableGrabbers ()
6570{
6671 QStringList grabbers;
@@ -110,85 +115,49 @@ void GrabberWrapper::setCropping(unsigned cropLeft, unsigned cropRight, unsigned
110115 _ggrabber->setCropping (cropLeft, cropRight, cropTop, cropBottom);
111116}
112117
118+ void GrabberWrapper::updateTimer (int interval)
119+ {
120+ if (_updateInterval_ms != interval)
121+ {
122+ _updateInterval_ms = interval;
123+
124+ const bool & timerWasActive = _timer->isActive ();
125+ _timer->stop ();
126+ _timer->setInterval (_updateInterval_ms);
127+
128+ if (timerWasActive)
129+ _timer->start ();
130+ }
131+ }
132+
113133void GrabberWrapper::handleSettingsUpdate (const settings::type& type, const QJsonDocument& config)
114134{
115- if (type == settings::V4L2 || type == settings::SYSTEMCAPTURE )
135+ if (type == settings::SYSTEMCAPTURE && !_grabberName. startsWith ( " V4L " ) )
116136 {
117137 // extract settings
118138 const QJsonObject& obj = config.object ();
119139
120- if (type == settings::SYSTEMCAPTURE && !_grabberName.startsWith (" V4L" ))
121- {
122- // width/height
123- _ggrabber->setWidthHeight (obj[" width" ].toInt (96 ), obj[" height" ].toInt (96 ));
124-
125- // display index for MAC
126- _ggrabber->setDisplayIndex (obj[" display" ].toInt (0 ));
127-
128- // device path for Framebuffer
129- _ggrabber->setDevicePath (obj[" device" ].toString (" /dev/fb0" ));
130-
131- // pixel decimation for x11
132- _ggrabber->setPixelDecimation (obj[" pixelDecimation" ].toInt (8 ));
133-
134- // crop for system capture
135- _ggrabber->setCropping (
136- obj[" cropLeft" ].toInt (0 ),
137- obj[" cropRight" ].toInt (0 ),
138- obj[" cropTop" ].toInt (0 ),
139- obj[" cropBottom" ].toInt (0 ));
140-
141- // eval new update timer (not for v4l)
142- if (_updateInterval_ms != 1000 /obj[" frequency_Hz" ].toInt (10 ))
143- {
144- _updateInterval_ms = 1000 /obj[" frequency_Hz" ].toInt (10 );
145- const bool & timerWasActive = _timer->isActive ();
146- _timer->stop ();
147- _timer->setInterval (_updateInterval_ms);
148- if (timerWasActive)
149- _timer->start ();
150- }
151- }
152-
153- // v4l instances only!
154- if (type == settings::V4L2 && _grabberName.startsWith (" V4L" ))
155- {
156- // pixel decimation for v4l
157- _ggrabber->setPixelDecimation (obj[" sizeDecimation" ].toInt (8 ));
158-
159- // crop for v4l
160- _ggrabber->setCropping (
161- obj[" cropLeft" ].toInt (0 ),
162- obj[" cropRight" ].toInt (0 ),
163- obj[" cropTop" ].toInt (0 ),
164- obj[" cropBottom" ].toInt (0 ));
165-
166- // device input
167- _ggrabber->setInput (obj[" input" ].toInt (-1 ));
168-
169- // device resolution
170- _ggrabber->setWidthHeight (obj[" width" ].toInt (0 ), obj[" height" ].toInt (0 ));
171-
172- // device framerate
173- _ggrabber->setFramerate (obj[" fps" ].toInt (15 ));
174-
175- // CEC Standby
176- _ggrabber->setCecDetectionEnable (obj[" cecDetection" ].toBool (true ));
177-
178- _ggrabber->setSignalDetectionEnable (obj[" signalDetection" ].toBool (true ));
179- _ggrabber->setSignalDetectionOffset (
180- obj[" sDHOffsetMin" ].toDouble (0.25 ),
181- obj[" sDVOffsetMin" ].toDouble (0.25 ),
182- obj[" sDHOffsetMax" ].toDouble (0.75 ),
183- obj[" sDVOffsetMax" ].toDouble (0.75 ));
184- _ggrabber->setSignalThreshold (
185- obj[" redSignalThreshold" ].toDouble (0.0 )/100.0 ,
186- obj[" greenSignalThreshold" ].toDouble (0.0 )/100.0 ,
187- obj[" blueSignalThreshold" ].toDouble (0.0 )/100.0 );
188- _ggrabber->setDeviceVideoStandard (
189- obj[" device" ].toString (" auto" ),
190- parseVideoStandard (obj[" standard" ].toString (" no-change" )));
191- }
140+ // width/height
141+ _ggrabber->setWidthHeight (obj[" width" ].toInt (96 ), obj[" height" ].toInt (96 ));
142+
143+ // display index for MAC
144+ _ggrabber->setDisplayIndex (obj[" display" ].toInt (0 ));
145+
146+ // device path for Framebuffer
147+ _ggrabber->setDevicePath (obj[" device" ].toString (" /dev/fb0" ));
148+
149+ // pixel decimation for x11
150+ _ggrabber->setPixelDecimation (obj[" pixelDecimation" ].toInt (8 ));
151+
152+ // crop for system capture
153+ _ggrabber->setCropping (
154+ obj[" cropLeft" ].toInt (0 ),
155+ obj[" cropRight" ].toInt (0 ),
156+ obj[" cropTop" ].toInt (0 ),
157+ obj[" cropBottom" ].toInt (0 ));
158+
159+ // eval new update time
160+ updateTimer (1000 /obj[" frequency_Hz" ].toInt (10 ));
192161 }
193162}
194163
0 commit comments