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

Commit 97b281c

Browse files
committed
Merge branch 'master' into merge_v4l2
2 parents 0668426 + ba15d22 commit 97b281c

File tree

10 files changed

+74
-19
lines changed

10 files changed

+74
-19
lines changed

deploy/hyperion.tar.gz

217 Bytes
Binary file not shown.

include/grabber/V4L2Grabber.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,16 @@
1313
#include <utils/ColorRgb.h>
1414
#include <utils/VideoMode.h>
1515

16+
// grabber includes
17+
#include <grabber/VideoStandard.h>
18+
1619
/// Capture class for V4L2 devices
1720
///
1821
/// @see http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html
1922
class V4L2Grabber : public QObject
2023
{
2124
Q_OBJECT
2225

23-
public:
24-
enum VideoStandard {
25-
PAL, NTSC, NO_CHANGE
26-
};
27-
2826
public:
2927
V4L2Grabber(
3028
const std::string & device,

include/grabber/VideoStandard.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
#include <string>
4+
#include <algorithm>
5+
6+
/**
7+
* Enumeration of the possible video standards the grabber can be set to
8+
*/
9+
enum VideoStandard {
10+
VIDEOSTANDARD_PAL,
11+
VIDEOSTANDARD_NTSC,
12+
VIDEOSTANDARD_NO_CHANGE
13+
};
14+
15+
inline VideoStandard parseVideoStandard(std::string videoStandard)
16+
{
17+
// convert to lower case
18+
std::transform(videoStandard.begin(), videoStandard.end(), videoStandard.begin(), ::tolower);
19+
20+
if (videoStandard == "pal")
21+
{
22+
return VIDEOSTANDARD_PAL;
23+
}
24+
else if (videoStandard == "ntsc")
25+
{
26+
return VIDEOSTANDARD_NTSC;
27+
}
28+
29+
// return the default NO_CHANGE
30+
return VIDEOSTANDARD_NO_CHANGE;
31+
}

include/utils/VideoMode.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#pragma once
22

3+
#include <string>
4+
#include <algorithm>
5+
36
/**
47
* Enumeration of the possible modes in which video can be playing (2D, 3D)
58
*/
@@ -9,3 +12,21 @@ enum VideoMode
912
VIDEO_3DSBS,
1013
VIDEO_3DTAB
1114
};
15+
16+
inline VideoMode parse3DMode(std::string videoMode)
17+
{
18+
// convert to lower case
19+
std::transform(videoMode.begin(), videoMode.end(), videoMode.begin(), ::tolower);
20+
21+
if (videoMode == "23DTAB")
22+
{
23+
return VIDEO_3DTAB;
24+
}
25+
else if (videoMode == "3DSBS")
26+
{
27+
return VIDEO_3DSBS;
28+
}
29+
30+
// return the default 2D
31+
return VIDEO_2D;
32+
}

libsrc/grabber/v4l2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SET(V4L2_QT_HEADERS
77
)
88

99
SET(V4L2_HEADERS
10+
${CURRENT_HEADER_DIR}/VideoStandard.h
1011
)
1112

1213
SET(V4L2_SOURCES

libsrc/grabber/v4l2/V4L2Grabber.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
328328
// set the video standard if needed
329329
switch (videoStandard)
330330
{
331-
case PAL:
331+
case VIDEOSTANDARD_PAL:
332332
{
333333
v4l2_std_id std_id = V4L2_STD_PAL;
334334
if (-1 == xioctl(VIDIOC_S_STD, &std_id))
@@ -337,7 +337,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
337337
}
338338
}
339339
break;
340-
case NTSC:
340+
case VIDEOSTANDARD_NTSC:
341341
{
342342
v4l2_std_id std_id = V4L2_STD_NTSC;
343343
if (-1 == xioctl(VIDIOC_S_STD, &std_id))
@@ -346,7 +346,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input)
346346
}
347347
}
348348
break;
349-
case NO_CHANGE:
349+
case VIDEOSTANDARD_NO_CHANGE:
350350
default:
351351
// No change to device settings
352352
break;

libsrc/leddevice/LedDeviceLpd6803.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@ LedDeviceLpd6803::LedDeviceLpd6803(const std::string& outputDevice, const unsign
1919

2020
int LedDeviceLpd6803::write(const std::vector<ColorRgb> &ledValues)
2121
{
22+
unsigned messageLength = 4 + 2*ledValues.size() + ledValues.size()/8 + 1;
2223
// Reconfigure if the current connfiguration does not match the required configuration
23-
if (4 + 2*ledValues.size() != _ledBuffer.size())
24+
if (messageLength != _ledBuffer.size())
2425
{
2526
// Initialise the buffer
26-
_ledBuffer.resize(4 + 2*ledValues.size(), 0x00);
27+
_ledBuffer.resize(messageLength, 0x00);
2728
}
2829

2930
// Copy the colors from the ColorRgb vector to the Ldp6803 data vector
Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
// getoptPlusPLus includes
22
#include <getoptPlusPlus/getoptpp.h>
33

4+
// grabber includes
5+
#include <grabber/VideoStandard.h>
6+
47
using namespace vlofgren;
58

69
/// Data parameter for the video standard
7-
typedef vlofgren::PODParameter<V4L2Grabber::VideoStandard> VideoStandardParameter;
10+
typedef vlofgren::PODParameter<VideoStandard> VideoStandardParameter;
811

912
namespace vlofgren {
1013
/// Translates a string (as passed on the commandline) to a color standard
@@ -13,24 +16,24 @@ namespace vlofgren {
1316
/// @return The color standard
1417
/// @throws Parameter::ParameterRejected If the string did not result in a video standard
1518
template<>
16-
V4L2Grabber::VideoStandard VideoStandardParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
19+
VideoStandard VideoStandardParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
1720
{
1821
QString input = QString::fromStdString(s).toLower();
1922

2023
if (input == "pal")
2124
{
22-
return V4L2Grabber::PAL;
25+
return VIDEOSTANDARD_PAL;
2326
}
2427
else if (input == "ntsc")
2528
{
26-
return V4L2Grabber::NTSC;
29+
return VIDEOSTANDARD_NTSC;
2730
}
2831
else if (input == "no-change")
2932
{
30-
return V4L2Grabber::NO_CHANGE;
33+
return VIDEOSTANDARD_NO_CHANGE;
3134
}
3235

3336
throw Parameter::ParameterRejected("Invalid value for video standard. Valid values are: PAL, NTSC, and NO-CHANGE");
34-
return V4L2Grabber::NO_CHANGE;
37+
return VIDEOSTANDARD_NO_CHANGE;
3538
}
3639
}

src/hyperion-v4l2/hyperion-v4l2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int main(int argc, char** argv)
6969

7070
// set defaults
7171
argDevice.setDefault("/dev/video0");
72-
argVideoStandard.setDefault(V4L2Grabber::NO_CHANGE);
72+
argVideoStandard.setDefault(VIDEOSTANDARD_NO_CHANGE);
7373
argInput.setDefault(-1);
7474
argWidth.setDefault(-1);
7575
argHeight.setDefault(-1);

src/hyperiond/hyperiond.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ int main(int argc, char** argv)
179179
v4l2Grabber = new V4L2Grabber(
180180
grabberConfig.get("device", "/dev/video0").asString(),
181181
grabberConfig.get("input", 0).asInt(),
182-
grabberConfig.get("standard", V4L2Grabber::NONE),
182+
parseVideoStandard(grabberConfig.get("standard", "NONE").asString()),
183183
grabberConfig.get("width", -1).asInt(),
184184
grabberConfig.get("height", -1).asInt(),
185185
grabberConfig.get("frameDecimation", 2).asInt(),
186186
grabberConfig.get("sizeDecimation", 8).asInt(),
187187
grabberConfig.get("sizeDecimation", 8).asInt());
188-
v4l2Grabber->set3D(grabberConfig.get("mode", VIDEO_2D));
188+
v4l2Grabber->set3D(parse3DMode(grabberConfig.get("mode", "2D").asString()));
189189
v4l2Grabber->setCropping(
190190
grabberConfig.get("cropLeft", 0).asInt(),
191191
grabberConfig.get("cropRight", 0).asInt(),

0 commit comments

Comments
 (0)