Commit graph

96 commits

Author SHA1 Message Date
Translation Updater 8999d9fef9 Update translations from Crowdin 2024-06-07 09:47:58 +00:00
tytan652 78cd07bd58 UI,plugin: Refactor virtual camera enablement 2024-03-30 16:43:30 -07:00
Vainock 7ae66c72fd Update translations from Crowdin 2024-02-28 14:20:05 -05:00
Translation Updater ac484a066f Update translations from Crowdin 2024-01-29 20:47:38 +00:00
jcm 354150a992 mac-virtualcam: Reduce excessive polling for new sample buffers 2024-01-06 17:43:42 -06:00
PatTheMav 7dbde70de1 cmake: Remove support for generators besides Xcode on macOS 2023-12-19 17:59:44 -05:00
PatTheMav eae5cc1e38 plugins: Update CMake formatting with manual format choices 2023-12-19 17:59:44 -05:00
Translation Updater f674d17168 Update translations from Crowdin 2023-12-05 22:04:31 +00:00
jcm 311fb69175 mac-virtualcam: Correct device timer firing rate 2023-10-27 10:08:19 -04:00
gxalpha c41633d998 mac-virtualcam: Log when extension replacement is requested 2023-10-11 13:07:04 -04:00
Translation Updater 0d450a34a0 Update translations from Crowdin 2023-10-10 13:34:41 +00:00
gxalpha e85b257562 mac-virtualcam: Check result of finished extension installation
Adds a switch to distinguish between the possible results that could
occur. While we expect to received RequestCompleted for our camera
extension (RequestWillCompleteAfterReboot is usually more of a network
extension thing), we can't be sure that this always is what we receive
unless we check it.
2023-10-09 18:28:02 -06:00
gxalpha 1781289f22 mac-virtualcam: Treat extension installation cancellation as error
OSSystemExtensionErrorRequestCanceled is called when the activation
delegate returns OSSystemExtensionReplacementActionCancel on request
actionForReplacingExtension withExtension. As per the previous (parent)
commit we no longer request cancellation, so we can be sure that
receiving a "cancelled" error is an actual error and not something that
is supposed to happen.
This commit also removes the "error" from the log prefix, as the message
sent may also be a warning instead, and the LOG_LEVEL conveys the
severity of the log line anyways.
2023-10-09 17:24:38 -06:00
gxalpha 61a4922364 mac-virtualcam: Always replace camera extension when requested
Current code assumes that a newer version of the extension is always
better. However that's not true - when the user installs an old version
of OBS, we should also install the old version of the camera extension
to have a version compatible with the installed OBS.
For normal users this method is only called when the versions in the
Info.plist do not match. In system extensions developer mode it's called
every time an installation is requested (meaning on every start), which
is probably desired as well; and by never returning
"ReplacementActionCancel" we can now always treat "ErrorRequestCanceled"
as an error and not something that we requested to happen.
2023-10-09 17:24:38 -06:00
PatTheMav f8f2c6d989 mac-virtualcam: Switch pixel format of camera extension to BGRA
BGRA was used by default in Apple's example code and is also already
supported by OBS.
2023-09-05 10:41:41 -04:00
Translation Updater ecf914dd67 Update translations from Crowdin 2023-08-13 14:09:15 +00:00
PatTheMav 914392fcc0 mac-virtualcam: Fix crash on macOS when starting virtualcam output 2023-08-10 17:53:59 -04:00
PatTheMav 7628265099 Update .clang-format rules for ObjC files for version 16 2023-08-10 17:12:30 -04:00
tytan652 63a9d372bb mac-virtualcam: Replace variable-length arrays with NSMutableData
Co-authored-by: Patrick Heyer <PatTheMav@users.noreply.github.com>
2023-08-06 01:31:02 +02:00
PatTheMav 914951a28d mac-virtualcam: Fix use of collection without explicit type
Swift 5.0 requires empty collections to carry explicit type definitions.
2023-07-04 15:41:12 +02:00
PatTheMav 0b325c0e34 cmake: Add separate function to set Xcode-based target properties 2023-06-17 12:23:33 -04:00
PatTheMav 59904a66a3 cmake: Update Framework link definition for macOS builds 2023-06-17 12:23:33 -04:00
PatTheMav 9805b706d1 cmake: Remove legacy files for macOS builds 2023-06-17 12:23:33 -04:00
PatTheMav 50a4e83251 cmake: Remove Info.plist template files for macOS builds
Creation of Info.plist files through Xcode is more canonical and
future-proof, as it will automatically pick up changes/updates
introduced by Apple. Non-standard keys can still be added via a
template file, which will then be extended by Xcode with the default
keys.
2023-06-17 12:23:33 -04:00
PatTheMav eb3d9963a0 cmake: Update macOS compiler configuration
Compiler extensions are disabled before the first `project` call to
force CMake into considering compilers to not support GNU extensions
(even though clang and gcc do).

Also sets common clang compiler options so they can be used across all
supported platforms.

`openmp-simd` support is enabled by default as there is no performance
penalty on x86_64 systems and intrinsics are enabled on arm64.

Also implements CMake's `CMAKE_COMPILE_WARNING_AS_ERROR` flag to
enable the desired behavior and configuration time.
2023-06-17 12:23:33 -04:00
PatTheMav 0235ac2fb2 mac-virtualcam: Use explicit access to object members in async block 2023-06-16 14:12:58 -04:00
PatTheMav f8e00d6071 clang-format: Update formatting of all ObjC and ObjC++ files 2023-06-11 14:56:45 +02:00
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
gxalpha 2a4c8594a1 mac-virtualcam: Release pixel buffer pool for DAL as well
The pixel buffer pool is used to create pixel buffers with both the CMIO
extension and the DAL plugin. As such, it is created independent of
which camera type is used, and should be released independent of it as
well.
2023-05-27 17:37:11 +02:00
gxalpha 8151785c45 mac-virtualcam: Adjust admin privilege strings to use Apple terminology 2023-05-25 14:50:44 -04:00
gxalpha a874c19bef mac-virtualcam: Fix admin password locale string 2023-05-23 03:58:34 -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
gxalpha 47d6d7e943 mac-virtualcam: Omit enqueue result codes 2023-05-21 01:35:43 +02:00
Lain 106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
PatTheMav 3f85e447a8 mac-virtualcam: Add Camera Extension to main CMake plugin project
Camera Extensions require specific entitlements for the hosting app,
which also require a provisioning profile. To avoid breaking local
builds that do not require the camera extension, an additional
entitlements file that will not trigger the provisioning profile
requirement will be used if the virtualcam (but not the Camera
Extension) is configured.
2023-05-18 14:41:08 -04:00
gxalpha aae2f7e8ff mac-virtualcam: Update obs-plugin to support macOS camera extensions
Co-authored-by: PatTheMav <PatTheMav@users.noreply.github.com>
2023-05-18 14:41:08 -04:00
gxalpha 5c6e471a56 mac-virtualcam: Add macOS camera extension project
Co-authored-by: PatTheMav <PatTheMav@users.noreply.github.com>
2023-05-18 14:41:08 -04:00
PatTheMav ea60fc2869 mac-virtualcam: Fix DAL plugin entrypoint not being exported
With the recent change to enforce C17 standard for compilers, default
visibility was also enforced to be hidden. This also automatically hid
the `PlugInMain` symbol required for DAL plugins. Adding the
`__exported` decorator makes the symbol explicitly visible.
2023-04-15 16:51:18 -07:00
PatTheMav 6e07b86729 cmake: Remove EXCLUDE_FROM_ALL directive from interface libraries 2023-04-04 17:27:54 +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
Mathijs Kadijk 970c284a65 mac-virtualcam: Prevent PTS rounding
All presentation time stamps are rounded to whole seconds during the
conversion from nanoseconds to seconds, because of the immediate cast
to `int64_t`. This results in the same presentation time stamp being
send to consumers for a whole second.

In previews/live streams this isn't super visible as last frame is
often assumed to be the newest and the stream is updated. It's more
problematic when recording since APIs like Apple's AVFoundation don't
allow duplicate presentation time stamps or it can look like frames are
produced in huge bursts once per second.

In this PR `CMTimeMakeWithSeconds` is used instead of `CMTimeMake` to
make sure the conversion is done correctly and simplify the calculation
we have to do a little.
2023-03-09 15:45:48 +01:00
Mathijs Kadijk ecaa5466cb mac-virtualcam: Fix incorrect PTS on Apple Silicon
The `fillFrame` method of the mac-virtualcam plugin is creating samples
directly using the value from `mach_absolute_time()` as `hostTime`.
This assumes this value is in nanoseconds, while it is in fact in mach
tick units. On Intel Macs mach tick units will be exactly 1 nanosecond
resulting in valid values, but on Apple Silicon macs this is no longer
the case.

This results in sample buffers with the placeholder image that have
much lower presentation time stamps than the samples containing content
produced by OBS. In previews/live streams this shows due to the last
content sample being shown frozen until the whole buffer is filled with
samples containing the placeholder image. Applications recording the
video stream are even more confused and crash or record videos with
wildly incorrect lengths.

In this PR `clock_gettime_nsec_np` is used to convert from mach tick units
to nanoseconds. This will make sure the `hostTime` value is correct on
both Apple Silicon and Intel macs. Making sure we produce stable
presentation time stamps from the virtual camera plugin at all times.
2023-03-09 15:45:48 +01:00
PatTheMav 8c8a44b26a mac-virtualcam: Fix compiler warnings
CMake build framework 3.0 introduces more strict typing checks, which
require additional code fixes to silence.

* Fixes warnings about implicit casts
* Fixes warnings about weak references used multiple times inside
  blocks
2023-02-18 15:22:33 -08:00
PatTheMav 447adfbe38 mac-virtualcam: Fix memory access issues for shared IOSurfaces
The DAL plugin-based virtualcamera shares data between OBS and the
plugin using an IOSurface. IOSurface locks are necessary to ensure
race conditions between data generation (OBS side) and consumption
(virtual camera side) and also that an IOSurface is not offloaded to
GPU memory when it is indeed needed in CPU memory.

Also moves the invalidation of the NSMachPort for the frames to after
the IOSurface data has been converted into a pixelbuffer and added to
the frame queue of the virtual camera, as an early invalidation will
cut off access to the pixel data shared with the DAL plugin.
2023-01-16 12:16:16 -05:00
PatTheMav 0b0ac1b958
mac-virtualcam: Remove unnecessary IOSurfaceLocks in Mach Server
IOSurface locks are only necessary when any processing with the data
contained in the surface is done and an explicit copy of data from GPU
memory back to CPU memory is needed.
2022-10-19 01:59:11 +02:00
PatTheMav 558c2a7074
mac-virtualcam: Remove unnecessary use of NSAppleEventDescriptor 2022-10-19 01:59:11 +02:00
PatTheMav a754cacc7f
mac-virtualcam: Use IOSurfaceLock on Intel-based Macs only
Apple Silicon-based Macs have a unified memory architecture, as such
an IOSurface will always be available in memory accessible to the CPU
and GPU (and an off-load of the IOSurface will not take place).

eGPUs are not supported on Apple Silicon-based Macs either, so an
IOSurface lock to ensure data is copied back to CPU memory is not
necessary.
2022-10-19 01:59:11 +02:00
PatTheMav 36a86f5217
mac-virtualcam: Fix random crashes in applications loading VirtualCam
Without invalidating the mach port used for sharing the IOSurface
between OBS and the application displaying the virtual camera output,
IOKit seems to run into the issue of receiving "shared" mach ports,
possibly because of port exhaustion. IOKit requires a "new" port
however and crashes upon that error otherwise.

Co-authored-by: Steven Michaud <smichaud@pobox.com>
2022-10-19 01:59:11 +02:00
PatTheMav 967bce5e15 mac-virtualcam: Fix distorted virtual cam image when using full range
The root cause of the issue is `swscale` dropping the second plane of
biplanar pixel data, resulting in an "incomplete" frame being fed to the
CVPixelBuffer.

As CVPixelBuffers have dedicated support for full range colour, use
these directly, which improves performance even further (as any
conversion for full range data is avoided as well).

To ensure that OBS does not implicitly enable conversion via `swscale`
a video conversion struct needs to be set in any case, ensuring that the
output range and colourspace match the output configuration.
2022-09-21 11:04:25 -04:00
PatTheMav ee34d8fbfe mac-virtualcam: Fix virtualcam video on Intel-based Macs
This issue primarily seems to affect Intel-based Macs without unified
memory: While an IOSurface is supposed to be shared via a mach port
with other processes, each process needs to lock the surface during
access (as is common with other shared resources).

Apple Silicon-based Macs seem to be less affected as a switch between
GPU and CPU memory (which can happen dynamically for IOSurfaces) would
still point to the same unified memory.
2022-09-21 11:04:25 -04:00