From 59ec7673733be229f60297ee8ab97821ce0b20e0 Mon Sep 17 00:00:00 2001 From: brindosch Date: Wed, 4 Oct 2017 21:23:45 +0200 Subject: [PATCH] Add SECAM video standard to v4l2 --- assets/webconfig/i18n/de.json | 1 + assets/webconfig/i18n/en.json | 1 + config/hyperion.config.json.commented | 2 +- include/grabber/VideoStandard.h | 5 +++++ libsrc/grabber/v4l2/V4L2Grabber.cpp | 19 ++++++++++++++----- .../hyperion/schema/schema-grabberV4L2.json | 4 ++-- src/hyperion-v4l2/hyperion-v4l2.cpp | 3 ++- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json index 75ecee0d..01725bab 100644 --- a/assets/webconfig/i18n/de.json +++ b/assets/webconfig/i18n/de.json @@ -416,6 +416,7 @@ "edt_conf_enum_linear" : "Linear", "edt_conf_enum_PAL" : "PAL", "edt_conf_enum_NTSC" : "NTSC", + "edt_conf_enum_SECAM" : "SECAM", "edt_conf_enum_logsilent" : "Stille", "edt_conf_enum_logwarn" : "Warnung", "edt_conf_enum_logverbose" : "Ausführlich", diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json index 1a4e1452..9b1ce747 100644 --- a/assets/webconfig/i18n/en.json +++ b/assets/webconfig/i18n/en.json @@ -417,6 +417,7 @@ "edt_conf_enum_linear" : "Linear", "edt_conf_enum_PAL" : "PAL", "edt_conf_enum_NTSC" : "NTSC", + "edt_conf_enum_SECAM" : "SECAM", "edt_conf_enum_logsilent" : "Silent", "edt_conf_enum_logwarn" : "Warning", "edt_conf_enum_logverbose" : "Verbose", diff --git a/config/hyperion.config.json.commented b/config/hyperion.config.json.commented index f403bcc3..74525844 100644 --- a/config/hyperion.config.json.commented +++ b/config/hyperion.config.json.commented @@ -102,7 +102,7 @@ /// * enable : Enable or disable the v4lgrabber (true/false) /// * device : V4L2 Device to use [default="/dev/video0"] /// * input : V4L2 input to use [default=0] - /// * standard : Video standard (no-change/PAL/NTSC) [default="no-change"] + /// * standard : Video standard (PAL/NTSC/SECAM) [default="PAL"] /// * width : V4L2 width to set [default=-1] /// * height : V4L2 height to set [default=-1] /// * frameDecimation : Frame decimation factor [default=2] diff --git a/include/grabber/VideoStandard.h b/include/grabber/VideoStandard.h index 72e7b58e..3bbc20a9 100644 --- a/include/grabber/VideoStandard.h +++ b/include/grabber/VideoStandard.h @@ -6,6 +6,7 @@ enum VideoStandard { VIDEOSTANDARD_PAL, VIDEOSTANDARD_NTSC, + VIDEOSTANDARD_SECAM, VIDEOSTANDARD_NO_CHANGE }; @@ -22,6 +23,10 @@ inline VideoStandard parseVideoStandard(QString videoStandard) { return VIDEOSTANDARD_NTSC; } + else if (videoStandard == "secam") + { + return VIDEOSTANDARD_SECAM; + } // return the default NO_CHANGE return VIDEOSTANDARD_NO_CHANGE; diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp index 5c150ec5..16df0b17 100644 --- a/libsrc/grabber/v4l2/V4L2Grabber.cpp +++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp @@ -90,7 +90,7 @@ bool V4L2Grabber::init() { getV4Ldevices(); QString v4lDevices_str; - + // show list only once if ( ! QString(QSTRING_CSTR(_deviceName)).startsWith("/dev/") ) { @@ -153,7 +153,7 @@ bool V4L2Grabber::init() ErrorIf( !_deviceAutoDiscoverEnabled, _log, "V4l2 init failed (%s)", e.what()); } } - + return _initialized; } @@ -161,7 +161,7 @@ void V4L2Grabber::getV4Ldevices() { QDirIterator it("/sys/class/video4linux/", QDirIterator::NoIteratorFlags); while(it.hasNext()) - { + { //_v4lDevices QString dev = it.next(); if (it.fileName().startsWith("video")) @@ -462,6 +462,15 @@ void V4L2Grabber::init_device(VideoStandard videoStandard, int input) } } break; + case VIDEOSTANDARD_SECAM: + { + v4l2_std_id std_id = V4L2_STD_SECAM; + if (-1 == xioctl(VIDIOC_S_STD, &std_id)) + { + throw_errno_exception("VIDIOC_S_STD"); + } + } + break; case VIDEOSTANDARD_NO_CHANGE: default: // No change to device settings @@ -768,7 +777,7 @@ int V4L2Grabber::read_frame() emit readError(e.what()); rc = false; } - + return rc ? 1 : 0; } @@ -810,7 +819,7 @@ void V4L2Grabber::process_image(const uint8_t * data) unsigned xMax = image.width() * _x_frac_max; unsigned yMax = image.height() * _y_frac_max; - + for (unsigned x = xOffset; noSignal && x < xMax; ++x) { for (unsigned y = yOffset; noSignal && y < yMax; ++y) diff --git a/libsrc/hyperion/schema/schema-grabberV4L2.json b/libsrc/hyperion/schema/schema-grabberV4L2.json index 2cd5da5d..20ab9df2 100644 --- a/libsrc/hyperion/schema/schema-grabberV4L2.json +++ b/libsrc/hyperion/schema/schema-grabberV4L2.json @@ -40,10 +40,10 @@ { "type" : "string", "title" : "edt_conf_v4l2_standard_title", - "enum" : ["PAL","NTSC"], + "enum" : ["PAL","NTSC","SECAM"], "default" : "PAL", "options" : { - "enum_titles" : ["edt_conf_enum_PAL", "edt_conf_enum_NTSC"] + "enum_titles" : ["edt_conf_enum_PAL", "edt_conf_enum_NTSC", "edt_conf_enum_SECAM"] }, "required" : true, "propertyOrder" : 4 diff --git a/src/hyperion-v4l2/hyperion-v4l2.cpp b/src/hyperion-v4l2/hyperion-v4l2.cpp index b77594f4..5eb4adc3 100644 --- a/src/hyperion-v4l2/hyperion-v4l2.cpp +++ b/src/hyperion-v4l2/hyperion-v4l2.cpp @@ -57,7 +57,7 @@ int main(int argc, char** argv) Parser parser("V4L capture application for Hyperion"); Option & argDevice = parser.add