Merge branch 'master' into merge_v4l2

Former-commit-id: 97b281cc14b3bc239fc5eab1f66c9d15e67f753f
This commit is contained in:
johan 2014-02-23 21:36:39 +01:00
commit e58f84d5c8
10 changed files with 75 additions and 20 deletions

View File

@ -1 +1 @@
f3afa39f64294a9ce71af8e424e4bab72d2b29cb
8f880f994b0855ace23e27818896fc34ba1677a8

View File

@ -13,6 +13,9 @@
#include <utils/ColorRgb.h>
#include <utils/VideoMode.h>
// grabber includes
#include <grabber/VideoStandard.h>
/// Capture class for V4L2 devices
///
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
@ -20,11 +23,6 @@ class V4L2Grabber : public QObject
{
Q_OBJECT
public:
enum VideoStandard {
PAL, NTSC, NO_CHANGE
};
public:
V4L2Grabber(
const std::string & device,

View File

@ -0,0 +1,31 @@
#pragma once
#include <string>
#include <algorithm>
/**
* Enumeration of the possible video standards the grabber can be set to
*/
enum VideoStandard {
VIDEOSTANDARD_PAL,
VIDEOSTANDARD_NTSC,
VIDEOSTANDARD_NO_CHANGE
};
inline VideoStandard parseVideoStandard(std::string videoStandard)
{
// convert to lower case
std::transform(videoStandard.begin(), videoStandard.end(), videoStandard.begin(), ::tolower);
if (videoStandard == "pal")
{
return VIDEOSTANDARD_PAL;
}
else if (videoStandard == "ntsc")
{
return VIDEOSTANDARD_NTSC;
}
// return the default NO_CHANGE
return VIDEOSTANDARD_NO_CHANGE;
}

View File

@ -1,5 +1,8 @@
#pragma once
#include <string>
#include <algorithm>
/**
* Enumeration of the possible modes in which video can be playing (2D, 3D)
*/
@ -9,3 +12,21 @@ enum VideoMode
VIDEO_3DSBS,
VIDEO_3DTAB
};
inline VideoMode parse3DMode(std::string videoMode)
{
// convert to lower case
std::transform(videoMode.begin(), videoMode.end(), videoMode.begin(), ::tolower);
if (videoMode == "23DTAB")
{
return VIDEO_3DTAB;
}
else if (videoMode == "3DSBS")
{
return VIDEO_3DSBS;
}
// return the default 2D
return VIDEO_2D;
}

View File

@ -7,6 +7,7 @@ SET(V4L2_QT_HEADERS
)
SET(V4L2_HEADERS
${CURRENT_HEADER_DIR}/VideoStandard.h
)
SET(V4L2_SOURCES

View File

@ -328,7 +328,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
// set the video standard if needed
switch (videoStandard)
{
case PAL:
case VIDEOSTANDARD_PAL:
{
v4l2_std_id std_id = V4L2_STD_PAL;
if (-1 == xioctl(VIDIOC_S_STD, &std_id))
@ -337,7 +337,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
}
}
break;
case NTSC:
case VIDEOSTANDARD_NTSC:
{
v4l2_std_id std_id = V4L2_STD_NTSC;
if (-1 == xioctl(VIDIOC_S_STD, &std_id))
@ -346,7 +346,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
}
}
break;
case NO_CHANGE:
case VIDEOSTANDARD_NO_CHANGE:
default:
// No change to device settings
break;

View File

@ -19,11 +19,12 @@ LedDeviceLpd6803::LedDeviceLpd6803(const std::string& outputDevice, const unsign
int LedDeviceLpd6803::write(const std::vector<ColorRgb> &ledValues)
{
unsigned messageLength = 4 + 2*ledValues.size() + ledValues.size()/8 + 1;
// Reconfigure if the current connfiguration does not match the required configuration
if (4 + 2*ledValues.size() != _ledBuffer.size())
if (messageLength != _ledBuffer.size())
{
// Initialise the buffer
_ledBuffer.resize(4 + 2*ledValues.size(), 0x00);
_ledBuffer.resize(messageLength, 0x00);
}
// Copy the colors from the ColorRgb vector to the Ldp6803 data vector

View File

@ -1,10 +1,13 @@
// getoptPlusPLus includes
#include <getoptPlusPlus/getoptpp.h>
// grabber includes
#include <grabber/VideoStandard.h>
using namespace vlofgren;
/// Data parameter for the video standard
typedef vlofgren::PODParameter<V4L2Grabber::VideoStandard> VideoStandardParameter;
typedef vlofgren::PODParameter<VideoStandard> VideoStandardParameter;
namespace vlofgren {
/// Translates a string (as passed on the commandline) to a color standard
@ -13,24 +16,24 @@ namespace vlofgren {
/// @return The color standard
/// @throws Parameter::ParameterRejected If the string did not result in a video standard
template<>
V4L2Grabber::VideoStandard VideoStandardParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
VideoStandard VideoStandardParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
{
QString input = QString::fromStdString(s).toLower();
if (input == "pal")
{
return V4L2Grabber::PAL;
return VIDEOSTANDARD_PAL;
}
else if (input == "ntsc")
{
return V4L2Grabber::NTSC;
return VIDEOSTANDARD_NTSC;
}
else if (input == "no-change")
{
return V4L2Grabber::NO_CHANGE;
return VIDEOSTANDARD_NO_CHANGE;
}
throw Parameter::ParameterRejected("Invalid value for video standard. Valid values are: PAL, NTSC, and NO-CHANGE");
return V4L2Grabber::NO_CHANGE;
return VIDEOSTANDARD_NO_CHANGE;
}
}

View File

@ -69,7 +69,7 @@ int main(int argc, char** argv)
// set defaults
argDevice.setDefault("/dev/video0");
argVideoStandard.setDefault(V4L2Grabber::NO_CHANGE);
argVideoStandard.setDefault(VIDEOSTANDARD_NO_CHANGE);
argInput.setDefault(-1);
argWidth.setDefault(-1);
argHeight.setDefault(-1);

View File

@ -179,13 +179,13 @@ int main(int argc, char** argv)
v4l2Grabber = new V4L2Grabber(
grabberConfig.get("device", "/dev/video0").asString(),
grabberConfig.get("input", 0).asInt(),
grabberConfig.get("standard", V4L2Grabber::NONE),
parseVideoStandard(grabberConfig.get("standard", "NONE").asString()),
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->set3D(parse3DMode(grabberConfig.get("mode", "2D").asString()));
v4l2Grabber->setCropping(
grabberConfig.get("cropLeft", 0).asInt(),
grabberConfig.get("cropRight", 0).asInt(),