Commit graph

207 commits

Author SHA1 Message Date
gxalpha 79822a58c3 libobs,plugins: Remove new obs_output_*2 functions
Effectively reverting parts of d314d47, this commit removes the new
functions that got added to remove the flags parameter. Instead, it just
marks the parameter as unused and documents this. Having what is
effectively an API break just to remove a parameter is a bit overkill.
The other parts of d314d47 which cleaned up the usage of the flags
parameter are untouched here.
2023-06-10 16:13:05 -07:00
tt2468 d314d4725d libobs, plugins: Deprecate obs_output_t functions with flag parameters
This deprecates the following functions, replacing them with new
versions:
- `obs_output_can_begin_data_capture()` - now `*capture2()`
- `obs_output_initialize_encoders()` - now `*encoders2()`
- `obs_output_begin_data_capture()` - now `*capture2()`

The flags parameter was initially designed to support audio-only or
video-only operation of an output which had the `OBS_OUTPUT_AV` flag,
however, full support for that was never implemented, and there are
likely fundamental issues with an implementation, mainly that most
outputs are programmed assuming that there will always be at least one
audio and one video track. This requires new flags specifying support
for optional audio/video, among other things.

An implementation to allow audio/video to be optional is best done
using the flag technique above, with audio/video enablement specified
by whether media (raw, `video_t/audio_t`) or encoder (`obs_encoder_t`)
objects are specified.

Since every implementation I could find always specifies `flags` as 0,
I was able to safely conclude that immediately removing the parameter's
functionality is safe to do.
2023-05-20 16:41:55 -07:00
Translation Updater a0fbdc3c34 Update translations from Crowdin 2023-05-01 23:11:13 +00:00
Translation Updater 7c5560bf1b Update translations from Crowdin 2023-03-27 13:39:03 +00:00
PatTheMav 349372b3b3 cmake: Add changes for CMake build framework 3.0
New code path only taken if OBS_CMAKE_VERSION is set to 3.0.0 or
greater, old functionality remains unchanged.
2023-03-26 18:20:38 -04:00
cg2121 1ac609f1ff UI, libobs: Fix not handled in switch warnings
These warnings were being spit out by GCC on Linux.
2023-03-26 10:47:01 +11:00
9p4 23ce4fe2f1 linux-v4l2: Fix fallback framerate for camera 2023-03-19 09:39:36 +11:00
tytan652 2839837ed6 plugins: Fix -Wsign-compare on Linux 2023-01-19 13:08:46 -05:00
Translation Updater 783bd52197 Update translations from Crowdin 2023-01-08 04:10:37 +00:00
PatTheMav ecdbab6c7a
linux-v4l2: Replace invocations of sprintf with snprintf
Fixes deprecation warnings in Xcode 14/clang on macOS and reduces
chance of buffer overflows.
2022-11-11 19:51:27 +01:00
Translation Updater f065f20ce1 Update translations from Crowdin 2022-10-25 22:32:14 +00:00
Stefan Hoffmeister fca624ea4f linux-v4l2: Send STREAMON/STREAMOFF on vcam start/stop
This implements a suggestion made in
https://github.com/floe/backscrub/issues/133#issuecomment-1085598710 to
address what appears to be a problem in the v4l2loopback driver.
And better aligns OBS' usage to the v4l2 kernel interface.

fixes #4808
Co-authored-by: Norihiro Kamae <norihiro@nagater.net>
2022-10-20 18:35:35 -07:00
Stefan Hoffmeister fbb7b93226 linux-v4l2: Remove redundant non-NULL check on FILE 2022-09-17 16:14:05 -07:00
Stefan Hoffmeister e8f27c2a79 linux-v4l2: Fix resource leak on device open error path 2022-09-17 16:14:05 -07:00
Translation Updater cc2d0791ca Update translations from Crowdin 2022-08-30 09:00:44 +00:00
Norihiro Kamae f393adb7e6 plugins: Rename Partial to Limited in localization files
The commit 9409ce1ea7 rephrased Limited instead of Partial. Other
plugins should follow the updated phrase.
2022-08-29 10:03:12 -07:00
Ed Maste 8b370c4218 linux-v4l2: Correct udev fd poll event test
Parentheses are needed due to operator precedence (although the previous
code happened to work because POLLIN has the value 1).

Fixes:		91f986ec99 ("linux-v4l2: Check udev fd events")
2022-08-17 12:32:47 -03:00
Translation Updater 4aaa07f93d Update translations from Crowdin 2022-08-17 04:22:50 +00:00
Ed Maste 91f986ec99 linux-v4l2: Check udev fd events
udev_event_thread calls poll with two fds: the udev fd, and an eventfd
used for shutdown.  On FreeBSD we were hanging on shutdown in
udev_monitor_receive_device after receiving the eventfd event.

Now, if the udev fd reports no events skip the
udev_monitor_receive_device call.

At shutdown the loop will exit via os_event_try().
2022-08-16 20:46:06 -07:00
Kurt Kartaltepe f788e9f6b7 linux-v4l2: Add eventfd to signal udev on shutdown
Currently we use signals based on os_event's but the udev code blocks in
a 1s select (now poll) that cannot be signalled without an FD. This adds
an extra eventfd which will be signalled along with the os_event to
trigger the poll.

Also switches from select to poll to avoid issues with large fd values.
2022-08-15 16:58:09 -03:00
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