From 22472d8f9597affaa667770a416172574a634ccd Mon Sep 17 00:00:00 2001 From: johan Date: Fri, 21 Feb 2014 22:30:34 +0100 Subject: [PATCH] Added v4l2 to hyperiond (partial) Former-commit-id: 06684261ec3ac7bb4e8ff0479e5b1472823648ae --- libsrc/grabber/v4l2/V4L2Grabber.cpp | 5 ++++ src/hyperiond/CMakeLists.txt | 4 ++- src/hyperiond/hyperiond.cpp | 41 +++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index 59bd0635..341485a7 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -69,6 +69,11 @@ V4L2Grabber::V4L2Grabber( V4L2Grabber::~V4L2Grabber() { + // stop if the grabber was not stopped + if (_streamNotifier != nullptr && _streamNotifier->isEnabled()) { + stop(); + } + uninit_device(); close_device(); } diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 1a255b17..17b7464f 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -8,7 +8,9 @@ target_link_libraries(hyperiond effectengine jsonserver protoserver - boblightserver) + boblightserver + v4l2-grabber +) if (ENABLE_DISPMANX) target_link_libraries(hyperiond dispmanx-grabber) diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp index 08244158..536bf27e 100644 --- a/src/hyperiond/hyperiond.cpp +++ b/src/hyperiond/hyperiond.cpp @@ -22,6 +22,11 @@ #include #endif +#ifdef ENABLE_V4L2 +// v4l2 grabber +#include +#endif + // XBMC Video checker includes #include @@ -165,6 +170,39 @@ int main(int argc, char** argv) } #endif +#ifdef ENABLE_V4L2 + // construct and start the v4l2 grabber if the configuration is present + V4L2Grabber * v4l2Grabber = nullptr; + if (config.isMember("grabber-v4l2")) + { + const Json::Value & grabberConfig = config["grabber-v4l2"]; + v4l2Grabber = new V4L2Grabber( + grabberConfig.get("device", "/dev/video0").asString(), + grabberConfig.get("input", 0).asInt(), + grabberConfig.get("standard", V4L2Grabber::NONE), + grabberConfig.get("width", -1).asInt(), + grabberConfig.get("height", -1).asInt(), + grabberConfig.get("frameDecimation", 2).asInt(), + grabberConfig.get("sizeDecimation", 8).asInt(), + grabberConfig.get("sizeDecimation", 8).asInt()); + v4l2Grabber->set3D(grabberConfig.get("mode", VIDEO_2D)); + v4l2Grabber->setCropping( + grabberConfig.get("cropLeft", 0).asInt(), + grabberConfig.get("cropRight", 0).asInt(), + grabberConfig.get("cropTop", 0).asInt(), + grabberConfig.get("cropBottom", 0).asInt()); + + // TODO: create handler + v4l2Grabber->start(); + std::cout << "V4l2 grabber created and started" << std::endl; + } +#else + if (config.isMember("grabber-v4l2")) + { + std::cerr << "The v4l2 grabber can not be instantiated, becuse it has been left out from the build" << std::endl; + } +#endif + // Create Json server if configuration is present JsonServer * jsonServer = nullptr; if (config.isMember("jsonServer")) @@ -199,6 +237,9 @@ int main(int argc, char** argv) // Delete all component #ifdef ENABLE_DISPMANX delete dispmanx; +#endif +#ifdef ENABLE_V4L2 + delete v4l2Grabber; #endif delete xbmcVideoChecker; delete jsonServer;