From 43b9236e78cd7c34887539c7e76796d7d8a18185 Mon Sep 17 00:00:00 2001 From: Thinner77 <59623671+Thinner77@users.noreply.github.com> Date: Mon, 21 Aug 2023 00:58:24 +0200 Subject: [PATCH] V4L: allow setting of V4L device input, Fixes #537 (#540) --- sources/grabber/v4l2/V4L2Grabber.cpp | 19 +++++++++++-------- www/js/grabber.js | 8 ++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/sources/grabber/v4l2/V4L2Grabber.cpp b/sources/grabber/v4l2/V4L2Grabber.cpp index 86931b0e9..337817c00 100644 --- a/sources/grabber/v4l2/V4L2Grabber.cpp +++ b/sources/grabber/v4l2/V4L2Grabber.cpp @@ -275,9 +275,9 @@ bool V4L2Grabber::init() try { Info(_log, "*************************************************************************************************"); - Info(_log, "Starting V4L2 grabber. Selected: %s [%s] %d x %d @ %d fps %s", QSTRING_CSTR(foundDevice), QSTRING_CSTR(dev.name), + Info(_log, "Starting V4L2 grabber. Selected: %s [%s] %d x %d @ %d fps %s input %d", QSTRING_CSTR(foundDevice), QSTRING_CSTR(dev.name), dev.valid[foundIndex].x, dev.valid[foundIndex].y, dev.valid[foundIndex].fps, - QSTRING_CSTR(pixelFormatToString(dev.valid[foundIndex].pf))); + QSTRING_CSTR(pixelFormatToString(dev.valid[foundIndex].pf)), _input); Info(_log, "*************************************************************************************************"); if (init_device(foundDevice, dev.valid[foundIndex])) @@ -548,11 +548,14 @@ void V4L2Grabber::enumerateV4L2devices(bool silent) if (properties.valid.size() == 0 && realName.indexOf("usbtv ", 0, Qt::CaseInsensitive) == 0) { Warning(_log, "To have proper colors when using UTV007 grabber, you may need to add 'sudo systemctl stop hyperhdr@pi && v4l2-ctl -s pal-B && sudo systemctl start hyperhdr@pi' to /etc/rc.local or run it manually to set the PAL standard"); - { DevicePropertiesItem diL; diL.x = 320; diL.y = 240; diL.fps = 30; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = 0; properties.valid.append(diL); } - { DevicePropertiesItem diL; diL.x = 320; diL.y = 288; diL.fps = 25; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = 0; properties.valid.append(diL); } - { DevicePropertiesItem diL; diL.x = 360; diL.y = 240; diL.fps = 30; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = 0; properties.valid.append(diL); } - { DevicePropertiesItem diL; diL.x = 720; diL.y = 480; diL.fps = 30; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = 0; properties.valid.append(diL); } - { DevicePropertiesItem diL; diL.x = 720; diL.y = 576; diL.fps = 25; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = 0; properties.valid.append(diL); } + for (int input = 0; input < properties.inputs.size(); input++) + { + { DevicePropertiesItem diL; diL.x = 320; diL.y = 240; diL.fps = 30; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = input; properties.valid.append(diL); } + { DevicePropertiesItem diL; diL.x = 320; diL.y = 288; diL.fps = 25; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = input; properties.valid.append(diL); } + { DevicePropertiesItem diL; diL.x = 360; diL.y = 240; diL.fps = 30; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = input; properties.valid.append(diL); } + { DevicePropertiesItem diL; diL.x = 720; diL.y = 480; diL.fps = 30; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = input; properties.valid.append(diL); } + { DevicePropertiesItem diL; diL.x = 720; diL.y = 576; diL.fps = 25; diL.pf = identifyFormat(V4L2_PIX_FMT_YUYV); diL.v4l2PixelFormat = V4L2_PIX_FMT_YUYV; diL.input = input; properties.valid.append(diL); } + } } _deviceProperties.insert(realName, properties); @@ -562,7 +565,7 @@ void V4L2Grabber::enumerateV4L2devices(bool silent) for (int i = 0; i < properties.valid.count(); i++) { const auto& di = properties.valid[i]; - Info(_log, "%s [%s] %d x %d @ %d fps %s", QSTRING_CSTR(realName), QSTRING_CSTR(properties.name), di.x, di.y, di.fps, QSTRING_CSTR(pixelFormatToString(di.pf))); + Info(_log, "%s [%s] %d x %d @ %d fps %s input %d", QSTRING_CSTR(realName), QSTRING_CSTR(properties.name), di.x, di.y, di.fps, QSTRING_CSTR(pixelFormatToString(di.pf)), di.input); } } } diff --git a/www/js/grabber.js b/www/js/grabber.js index aa8c493ac..ecd712ef2 100644 --- a/www/js/grabber.js +++ b/www/js/grabber.js @@ -747,6 +747,14 @@ $(document).ready( function(){ if (checkExists(window.schema.videoGrabber.properties.videoEncoding.enum, name)) window.schema.videoGrabber.properties.videoEncoding.options.enum_titles.push(name); } + + for(var i = 0; i < currentInfo.inputs.length && currentInfo.inputs.length > 1; i++) + { + var inputnr = parseInt((currentInfo.inputs[i].inputIndex).toString()); + var name = (currentInfo.inputs[i].inputName).toString(); + if (checkExists(window.schema.videoGrabber.properties.input.enum, inputnr)) + window.schema.videoGrabber.properties.input.options.enum_titles.push(inputnr.toString() + ": " + name); + } }