Skip to content

Commit

Permalink
V4L: allow setting of V4L device input, Fixes #537 (#540)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thinner77 authored Aug 20, 2023
1 parent a25481c commit 43b9236
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
19 changes: 11 additions & 8 deletions sources/grabber/v4l2/V4L2Grabber.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions www/js/grabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}


Expand Down

0 comments on commit 43b9236

Please sign in to comment.