Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit 0668426

Browse files
committed
Added v4l2 to hyperiond (partial)
1 parent cf469ba commit 0668426

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

libsrc/grabber/v4l2/V4L2Grabber.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ V4L2Grabber::V4L2Grabber(
6969

7070
V4L2Grabber::~V4L2Grabber()
7171
{
72+
// stop if the grabber was not stopped
73+
if (_streamNotifier != nullptr && _streamNotifier->isEnabled()) {
74+
stop();
75+
}
76+
7277
uninit_device();
7378
close_device();
7479
}

src/hyperiond/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ target_link_libraries(hyperiond
88
effectengine
99
jsonserver
1010
protoserver
11-
boblightserver)
11+
boblightserver
12+
v4l2-grabber
13+
)
1214

1315
if (ENABLE_DISPMANX)
1416
target_link_libraries(hyperiond dispmanx-grabber)

src/hyperiond/hyperiond.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
#include <grabber/DispmanxWrapper.h>
2323
#endif
2424

25+
#ifdef ENABLE_V4L2
26+
// v4l2 grabber
27+
#include <grabber/V4L2Grabber.h>
28+
#endif
29+
2530
// XBMC Video checker includes
2631
#include <xbmcvideochecker/XBMCVideoChecker.h>
2732

@@ -165,6 +170,39 @@ int main(int argc, char** argv)
165170
}
166171
#endif
167172

173+
#ifdef ENABLE_V4L2
174+
// construct and start the v4l2 grabber if the configuration is present
175+
V4L2Grabber * v4l2Grabber = nullptr;
176+
if (config.isMember("grabber-v4l2"))
177+
{
178+
const Json::Value & grabberConfig = config["grabber-v4l2"];
179+
v4l2Grabber = new V4L2Grabber(
180+
grabberConfig.get("device", "/dev/video0").asString(),
181+
grabberConfig.get("input", 0).asInt(),
182+
grabberConfig.get("standard", V4L2Grabber::NONE),
183+
grabberConfig.get("width", -1).asInt(),
184+
grabberConfig.get("height", -1).asInt(),
185+
grabberConfig.get("frameDecimation", 2).asInt(),
186+
grabberConfig.get("sizeDecimation", 8).asInt(),
187+
grabberConfig.get("sizeDecimation", 8).asInt());
188+
v4l2Grabber->set3D(grabberConfig.get("mode", VIDEO_2D));
189+
v4l2Grabber->setCropping(
190+
grabberConfig.get("cropLeft", 0).asInt(),
191+
grabberConfig.get("cropRight", 0).asInt(),
192+
grabberConfig.get("cropTop", 0).asInt(),
193+
grabberConfig.get("cropBottom", 0).asInt());
194+
195+
// TODO: create handler
196+
v4l2Grabber->start();
197+
std::cout << "V4l2 grabber created and started" << std::endl;
198+
}
199+
#else
200+
if (config.isMember("grabber-v4l2"))
201+
{
202+
std::cerr << "The v4l2 grabber can not be instantiated, becuse it has been left out from the build" << std::endl;
203+
}
204+
#endif
205+
168206
// Create Json server if configuration is present
169207
JsonServer * jsonServer = nullptr;
170208
if (config.isMember("jsonServer"))
@@ -199,6 +237,9 @@ int main(int argc, char** argv)
199237
// Delete all component
200238
#ifdef ENABLE_DISPMANX
201239
delete dispmanx;
240+
#endif
241+
#ifdef ENABLE_V4L2
242+
delete v4l2Grabber;
202243
#endif
203244
delete xbmcVideoChecker;
204245
delete jsonServer;

0 commit comments

Comments
 (0)