187 Commits

Author SHA1 Message Date
Translation Updater
81734be37c Update translations from Crowdin 2022-07-31 23:40:53 +00:00
Kurt Kartaltepe
57c9844f15 v4l2,scripting: Add more thread names
This sets some thread names for the scripting backend's defer thread and
the v4l2 udev thread.
2022-07-24 09:21:58 +10:00
tytan652
17ba8359e4 deps,libobs,plugins: Fix discarded-qualifiers warnings with FFmpeg 5 2022-07-22 08:50:36 -04:00
Grzegorz Godlewski
c5015d0e6c linux-v4l2: Add support for H.264 2022-06-17 18:49:12 +10:00
Grzegorz Godlewski
b98ce32670 linux-v4l2: Fix camera reconnecting issue
Unable to add device after OBS start. Function device_added is never
called. HAVE_UDEV is not set correctly by cmake.
2022-05-16 13:29:52 -04:00
tytan652
096ec55c83 linux-v4l2: Fix format-truncation warning 2022-05-04 01:37:10 -07:00
jpark37
848e128435 libobs,plugins: Replace video matrix function
video_format_get_parameters_for_format provides a more accurate matrix
than video_format_get_parameters.
2022-04-07 19:28:51 -07:00
PatTheMav
aae3a6a466 cmake: Fix diverging prefix padding for OBS status outputs
Status output related to OBS configuration is prefixed with the string
"OBS" and added padding for enabled and disabled features. This padding
was not aligned between platforms.

By moving the padding and prefix decoration into its own function,
both elements are controlled in a single place. CMake scripts were
changed to use this new function `obs_status` instead of using CMake's
`message` function directly.
2022-03-26 09:44:23 -04:00
PatTheMav
49e9d49943
plugins: Update CMakeLists.txt for included plugins 2022-03-16 23:11:08 +01:00
obiwac
93c2e681ca linux-v4l2: scandir with alphasort on non-Linux
Sort video device entries with `alphasort` on non-Linux platforms,
as opposed to `versionsort` on Linux.
(`versionsort` is a GNU extension, unavailable on e.g. FreeBSD.)

UI: Fix call to `to_string` on FreeBSD
2022-02-26 15:36:08 -08:00
Kurt Kartaltepe
c639255142 linux-v4l2: Fix warnings in mjpeg
Previously the switch did not catch all cases issuing a quite large
warning. Also there was a const-ness warning for codecs on ffmpeg 5.0
that this addresses.
2022-02-25 12:22:22 -03:00
Kurt Kartaltepe
23feac1323 linux-v4l2: Use decoded MJPEG pixel format
Previously we assumed mjpeg was always decoded to 422 but it seems some
cameras provide frames that decode to different pixel formats such as
420.

This change delays setting the obs frame pixel format until after we
have decoded the v4l2 frame.

fixes #5821
2022-02-19 23:53:41 -03:00
Translation Updater
ac8dbf67be Update translations from Crowdin 2022-02-06 02:24:08 +00:00
Ryan Foster
a7d3df3763 linux-v4l2: Fix timeout logging
The timeout_usec variable is uint64_t, but the log format was set to %ld
(signed long int), so it would sometimes log a nonsensical value. Let's
use $PRIu64 instead, which should be equivalent to %llu (unsigned long
long int).

Fixes #5797.
2022-01-14 20:43:25 -08:00
Translation Updater
261345f9ef Update translations from Crowdin 2021-12-12 02:38:59 +00:00
Florian Zwoch
88aec3b43c linux-v4l2: Change search strategy for v4l2loopback devices
Instead of trying to open devices /dev/video<0-63> check /dev for
all /dev/videoX devices that are existent in the tree. This allows
finding devices with higher names than 63. E.g. /dev/video100 can
now be found and opened which previously failed.

_GNU_SOURCE #define is introduced for versionsort() which is a GNU
extension.

Fixes #4347.
2021-11-10 19:32:30 -03:00
Morten Bøgeskov
1c2aea4f89 linux-v4l2: Support for Motion-JPEG codec 2021-11-02 06:04:54 -07:00
Alexis King
08d4456339 v4l2: Ignore menu controls with no permissible values
At least one V4L2 device reports a menu control when queried with
QUERYCTRL yet does not report supporting a single value in its legal
range when queried with QUERYMENU. Such devices are arguably
ill-behaved, but the Linux UVC driver takes no special care to ignore
such pathological controls, so we have to do it ourselves.

Without this patch, a menu control with no valid values would cause
v4l2_control_changed to go into an infinite loop, since every S_CTRL
request on such pathological control properties would always fail,
triggering an additional modification event. By ignoring these
properties altogether, we avoid that problem, and the user benefits by
not having the UI cluttered by a confusing and useless menu control.
2021-10-16 15:24:20 -07:00
Vainock
11a690b038 Update translations from Crowdin 2021-09-24 09:42:08 -07:00
Translation
ef2b1eb1c6 Update translations from Crowdin 2021-06-11 07:18:15 -07:00
Gol-D-Ace
90df8d44df Update translations from Crowdin 2021-05-30 20:33:35 +02:00
Georges Basile Stavracas Neto
7a87777225 linux-v4l2: Use flatpak-spawn when inside a Flatpak sandbox
It is not possible to run host system executables like modinfo, pkexec,
and modprobe inside a Flatpak sandbox. However, Flatpak provides a way
to run command on the host system: the flatpak-spawn executable.

flatpak-spawn is a tiny helper that, when executed with the '--host'
parameter, talks to the org.freedesktop.Flatpak D-Bus interface to run
and retrieve the return value of the executable. This provides OBS Studio
a way to escape this sandbox limitation without opening large holes in
the sandbox.

Make v4l2's implementation of VirtualCam run system commands using
flatpak-spawn when inside a Flatpak sandbox. The detection of the sandbox
is done by checking the existence of the /.flatpak-info file, which is
created by Flatpak itself, and only exists inside the sandbox. If OBS
Studio is not running inside a Flatpak sandbox, run the exact same command
it used to run before this commit.

Add the permission to talk to the org.freedesktop.Flatpak D-Bus interface
to the Flatpak manifest, so we can run flatpak-spawn with the '--host'
parameter.

Notice that the same constraints apply with and without Flatpak: the host
system needs to have the v4l2loopback kernel module available for the v4l2
implementation of VirtualCam to work.
2021-04-18 17:27:33 -07:00
jpark37
2c1610017d linux-v4l2: Fix ignored return value 2021-01-30 00:25:25 -08:00
Frank Löffler
8f3d4b6758 linux-v4l2: added range check for try_connect()
While the current code only ever calls try_connect() with the input
argument 'device' in the range of 0 and MAX_DEVICES, this adds a check
to ensure that future code does not break the following sprintf.

In addition, use snprintf instead of sprintf to ensure that if anything
breaks, the sprintf does not lead to memory corruption. Again, the new
check should already make sure of that, but the additional effort of
using snprintf instead of sprintf is so low that it is worth to have a
little more security in the future.
2021-01-29 09:24:42 -08:00
Kurt Kartaltepe
d8a25ef943 linux-v4l2: Improve module detection
Expand PATH for Debian-like systems.
Improve detection when the module is already loaded.
2021-01-25 04:14:29 -08:00
Kurt Kartaltepe
d8a253c42f libobs, linux-v4l2: Set thread names
Sets thread names for the hotkey and v4l2 capture threads.
2021-01-25 04:13:24 -08:00
Piotr Esden-Tempski
d7ec87ff0e linux-v4l2: Add auto reset on timeout option
Adds frame time multiple based timeout option, instead of the hardcoded
1 second timeout.

Adds optional automatic device stream reset when the device times out.
Helps with devices that "lock up" or "freeze", for example Magewell and
Elgato USB HDMI capture devices.

The automatic reset is by default off and optional. Turning it on can
cause issues for devices that work but drop a lot of frames.
2021-01-20 16:45:05 -08:00
Piotr Esden-Tempski
bb264b2b33 linux-v4l2: Improve error and debug logging
The capture loop errors are now logged as such.
Increased the amount of information logged in debug mode, including
state of all buffers on timeout.
Add device name to all capture loop debug output, especially useful when
debugging issues with multiple v4l2 video streams.
2021-01-12 09:33:11 -08:00
Gol-D-Ace
7368a2c7cc Update translations from Crowdin 2020-12-14 00:29:44 +01:00
stump
eac6604a83 linux-v4l2: Fix bashism in v4l2loopback module detection
When /bin/sh isn't bash, the previous line always appears to succeed,
and modinfo's output is not redirected, because it actually runs
modinfo in the background (which always succeeds) then opens and closes
/dev/null without doing anything to it. This causes us to always think
that the v4l2loopback module is installed, even when it isn't.
2020-12-08 13:51:40 +11:00
Gol-D-Ace
7ab98ca00f Update translations from Crowdin 2020-11-25 20:11:39 +01:00
Ed Maste
b9a1516254 linux-v4l2: avoid OOB write
v4l2_outputparm includes unused fields, defined as
	__u32		reserved[4]

Accesses to reserved[4] was out of bounds.  Fix this and simplify by
just zeroing the entire struct v4l2_streamparm instead.
2020-11-01 20:47:35 -08:00
Kurt Kartaltepe
dc7d829751 linux-v4l2: Hide modinfo from terminal
Using modinfo dumps all the output into the terminal instead redirect
all output to dev/null.
2020-10-31 21:00:51 -07:00
Clayton Groeneveld
6af8726c74 linux-v4l2: Add virtual camera output 2020-10-30 02:00:14 -07:00
Gol-D-Ace
c66ebde080 Update translations from Crowdin 2020-09-27 23:07:27 +02:00
Kurt Kartaltepe
be7dcb8bf6 v4l2-linux: Fix fourcc order
v4l2 pixfmt fourcc's are always stored little-endian.
ref: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/vidioc-enum-fmt.html?highlight=vidioc_enum_fmt
2020-09-27 00:08:48 -07:00
Kurt Kartaltepe
0cad2abbbe v4l2-linux: Fix nv12 linesize
unlike other YUV based formats nv12 chroma plane has the same padding as
the luma plane.
ref: https://01.org/linuxgraphics/gfx-docs/drm/media/uapi/v4l/pixfmt-nv12.html
2020-09-27 00:07:37 -07:00
Nathan-Huckleberry
b1bf31dbe7 linux-v4l2: Fix boolean and menu control types
Previously, changing boolean or menu settings would send incorrect
values to the ioctl.  This change fixes the support.
2020-09-14 21:31:30 -07:00
Juliane Holzt
19890b25ee
linux-v4l2: Fix case of variables to snake_case
This commit fixes the case of two recently added attributes of the
v4l2_data struct (in PR #2978). The new attributes were named
"frameRateUnchanged" and "resolutionUnchanged", i.e. using CamelCase
while all other attributes use snake_case. This change changes the
name of the two attributes to snake_case.
2020-07-13 21:20:49 +02:00
Ioan Loosley
8814e2bf4c
linux-v4l2: Selective stream restart
This commit adds a basic check to see if the v4l2 stream requires a
restart. This is primarly implemented on the basis of the fact that
the options requiring a restart have values stored in the v4l2_data
structure. A restart is only needed if any of the values have changed
since the last update.
2020-05-24 17:05:00 +01:00
Kurt Kartaltepe
d928bfd1ea cmake: Fix warnings and normalize variables/errors
As of 3.17 using find_package_handle_standard_args checks that the name
of the FindXXX file and the first argument are the same case.

Some modules used non-standard variables or the old singular variables
instead of plurals. This normalizes variable usage to the new-style.

Some CMakeLists.txt did custom error checking instead of propagating
find_package errors. These were changes to call find_package with
REQUIRED or without QUIET where needed and shortens the custom status
messages. This helps users who want to enable that functionality see
what precisely wasnt found.
2020-05-21 18:45:16 -07:00
jp9000
8d6f29ffc7 Revert "Merge pull request #2637 from kkartaltepe/cmake-variety-fixes"
This reverts commit d777000a60cb9ccd78b3bdf1fbae3583b55aac0c, reversing
changes made to c9e5f30a78d087e42434813df1c56076049d62c3.
2020-05-21 00:03:09 -07:00
Jim
d777000a60
Merge pull request #2637 from kkartaltepe/cmake-variety-fixes
cmake: Fix warnings and normalize variables/errors
2020-05-20 23:45:25 -07:00
jp9000
7993179466 cmake: Add cmake folders 2020-05-13 06:52:37 -07:00
Ed Maste
ec7fbadcdb linux-v4l2: Fix build with Clang 10.0
add_control_property() was previously static inline bool, but did not
return a value and failed to build on FreeBSD-CURRENT with Clang 10.0,
with:

error: non-void function 'add_control_property' should return a value
2020-04-12 18:41:36 -04:00
Kurt Kartaltepe
c5b731e48f cmake: Fix warnings and normalize variables/errors
As of 3.17 using find_package_handle_standard_args checks that the name
of the FindXXX file and the first argument are the same case.

Some modules used non-standard variables or the old singular variables
instead of plurals. This normalizes variable usage to the new-style.

Some CMakeLists.txt did custom error checking instead of propagating
find_package errors. These were changes to call find_package with
REQUIRED or without QUIET where needed and shortens the custom status
messages. This helps users who want to enable that functionality see
what precisely wasnt found.
2020-04-03 21:32:10 -07:00
Kurt Kartaltepe
b822faf73b linux-v4l2: Fixup invalid id
Previous fix in #2547 altered id before they were handed off to
callbacks and v4l2 wont strip its own flags from ids resulting in
invalid ids in the ioctl.

Instead add cleanup section and jump all branches there before looping.

(Jim edit: I'm changing this entire function so that it isn't horrible.)
2020-03-23 18:12:14 -07:00
Kurt Kartaltepe
7b71a3b33d linux-v4l2: readonly controls cause infinite loop
v4l2_ioctl will clear the V4L2_CTRL_FLAG_NEXT_CTRL flag resulting in
infinite loops for any driver that reported readonly, disabled, or
volitile controls.
2020-03-22 10:48:36 -07:00
Gol-D-Ace
d74fc65047 Update translations from Crowdin 2020-03-16 20:14:50 +01:00
Jiaxun Yang
3b39a0af74 linux-v4l2: Use LP64 macro to determine pointer size
As currently all 64bit Linux platforms are respecting LP64
data model and most 32bit platforms are respecting ILP32, we
don't have to discuss pointer size case by case. LP64 is effective
enough to tell pointer size.

This fixes build for armhf and powerpc.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
2020-03-07 09:56:01 +08:00