It is expected that capture might fail, like when a window is minimized.
In these cases we dont want the log to be spammed by X11 errors so
install a noop error handler while we try to import.
Direct access to `[AVCaptureDevice devices]` is deprecated since macOS
10.15. An `AVCaptureDeviceDiscoverySession` is to be used instead, which
this PR implements.
When running on older macOS versions or compiling against older platform
SDKs, the deprecated method is used.
PS: The formatting is not proper ObjC style, but that's clang-format's
doing with our current settings.
This commit fixes what is arguably a long-winded series of previous
commits that have possibly caused just as many problems as they have
fixed. I'll spare the details, but basically, there's no reason that
any of the RTMP object should ever be used across socket sessions.
This provides a slight enhancement by removing the `RTMP_Init` call
in `rtmp_stream_create()`, since it effectively just initializes TLS
just for `try_connect` to deinitialize it before it is even used.
This also fixes the current `SO_RCVTIMEO` timeout functionality by
making sure that `RTMP_Reset` is called last.
To improve readability of the capture thread function
`AJASource::CaptureThread`, audio part is split into two functions.
Behavior is not changed.
Also fixed one of warnings.
When too many audio frames are captured and at the same time the ring
buffer on the card is wrapped, memory overrun was not captured before
DMA transfer, which resulted in corruption of memory contents. This
commit moves the overrun check before the DMA transfer.
This fixes a bug where the new circular buffer code is hit by protocols
such as rist or srt although the buffer was meant for files.
Signed-off-by: pkv <pkv@obsproject.com>
It is reported that the encoder does not follow the bitrate settings.
This commit tries to correct the timestamps so that the bitrate control
in the encoder works.
This change fixes a memory leak in the mac-virtualcam plugin that causes
OBS to not release the CVPixelBuffers (and underlying IOSurfaces)
it emits to the virtual camera consumers.
Pull request https://github.com/obsproject/obs-studio/pull/6573 (Avoid
transcoding where possible) updated the mac-virtualcam to share the
virtual camera feed with other processes via IOSurfaces.
Although the changes work correctly, users have observed that OBS memory
usage keeps increasing when the virtual camera is active until OBS runs
out of memory or the consuming application is closed.
See the report by @SciTechNick for more information:
https://github.com/obsproject/obs-studio/pull/6573#issuecomment-1161979765
After some debugging, I have found that the plugin is leaking Mach ports
associated with IOSurfaces, preventing them from being re-used. The
previous approach using `NSMachPort` does not seem to properly release
the Mach port allocated via `CVPixelBufferGetIOSurface` and
`IOSurfaceLookupFromMachPort`. Instead, we must explicitly deallocate
the port using `mach_port_deallocate`.
I have tested the changes on a Macbook Pro (M1) running macOS Monterey with
Google Chrome, Zoom, and Cameo. OBS shows no signs of memory leakage
after multiple minutes.
A race condition can occur in obs-outputs where the send_thread is in
the process of (re)connecting but the encoder was shut down in the
meantime. This causes the expected header data to be garbage, resulting
in a crash.
Sorry this is such a massive commit. The entangled nature of the
code in pipewire.c makes it impossible to reasonably split this
in smaller commits.
Move all D-Bus / portals code from pipewire.c into the recently
introduced screencast-portal.c.
This is the start of what will be a rather incisive surgery on
pipewire.c. Move a couple of functions to portal.c, since they're
not really related to the PipeWire code.
As we slowly split portal code from PipeWire code, what is currently
called pipewire-capture will become the screencast portal specific
code.
Preemptively rename the corresponding files and functions. Next commits
will continue the excision of portal code from pipewire.c.
The silent reconnect (GOAWAY) is supposed to be used for switching the
connection to a different server. As such, cleanly shutting down the
RTMP connection can destroy state that needs to be preserved in order
for the GOAWAY-enabled server to properly resume the same stream on
reconnect.
This commit closes the TLS/TCP connection before calling RTMP_Close,
causing librtmp to skip the FCUnpublish and deleteStream messages.
Buffering inside libobs is enabled by default and it causes latency of
video. This commit provides a property to switch the buffering.
Since the latency of the buffering changes every startup, set the
default to unbuffered mode, though the previous implementation was
enabled buffering.
When the mode is set to auto, the API sometimes send frames with 0x0
size. Without filtering such frames, which causes libobs to output error
messages.
This change fixes an issue with the CMIO DAL plugin where the CMIO
subsystem would log multiple errors when starting the virtual camera,
due to certain properties that could not be set (frame rate and format).
For now, we just ignore the assignment, but mark the property as
settable to suppress the error messages that are reported by the CMIO
subsystem.
This change fixes an issue in the Mach server exposed by the macOS
virtual camera for OBS, where it would not invalidate ports that were
disconnected by the remote application, causing sporadic crashes.
These crashes can be reproduced in the previous builds by opening the
virtual camera in a remote application and closing the application
(without stopping the virtual camera).
This change updates the implementation of the mac-virtualcam plugin to
not use any global state and instead rely on the state object that is
passed by the OBS module system.
This approach is similar to the virtual camera implementations for Linux
and Windows.
This change removes the unused CMSampleBuffer utility functions that
were still left from the previous implementation. Since we construct the
CMSampleBuffer directly from an IOSurface, we do not need any custom
construction logic anymore, since that is now performed by the OBS
plugin.