Commit graph

344 commits

Author SHA1 Message Date
PatTheMav 2966c4030e libobs: Use static library for version string information
Switching to a static library that contains version information as
const char strings has multiple benefits:

* The version information provided externally via compiler definitions
  will fail compilation early if malformed
* An updated version string (which will happen with every commit) will
  not invalidate existing compilation units, because only the static
  library is affected by the change
* An update of the version change just requires a recompilation of the
  static library and a linker update
* An update of the version will _not_ infect the rest of the codebase
  (as it does currently, because everything includes obsconfig.h one
  way or another)
* Other modules which used the macro definition directly have been
  updated as much as possible to use the proper getter method from
  `libobs` instead (some Windows-specific modules use preprocessor
  string composition, the value has been added as a compiler definition
  directly in those cases)
* Because the impact of a version change due to a commit hash change
  is limited to the static library, ccache hit rates should be
  improved considerably
2023-05-27 16:48:24 -07:00
Richard Stanway 48a0e7822a
obs-outputs: Remove support for "RTMP Go Away" feature (#8959)
Meta have filed a patent application on the Go Away feature. This goes
against the spirit of free software and puts the use of this feature in
questionable legal status, so let's remove this code until the patent
situation is resolved.

This reverts commits a593fe6755 and
dada82fec1.
2023-05-26 13:55:48 -05: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
Norihiro Kamae e9b65d58bb obs-outputs: Add missing translations 2023-05-20 16:35:05 -07:00
Lain 106c7aa61f Update copyrights/names 2023-05-20 01:31:18 -07:00
PatTheMav f7ec81ca12 obs-outputs: Fix keychain API deprecation warnings on macOS 2023-05-13 16:59:42 -07:00
derrod 72759ae69d obs-outputs: Don't set DTS offset for enhanced FLV SEQ start/end packets
Sequence start and end packets never have a valid DTS, but with a
non-zero offset the timestamp in the packet would end up also being
non-zero, which leads to librtmp attempting to calculate a timestamp
delta and underflowing.

As a fix, simply remove the ability to even set a DTS offset for
start/end packets and always keep it at zero.
2023-04-17 17:42:15 -04:00
derrod 64f3070753 obs-outputs: Fix enhanced RTMP frame type not being set 2023-04-17 16:39:13 -04:00
pkv dfac68b189 obs-outputs: Log encoder incompatible with dynamic bitrate
This logs that dynamic bitrate is disabled when a codec which does not
support bitrate reconfiguration is used, such as aom, svt-av1 ...

Signed-off-by: pkv <pkv@obsproject.com>
2023-04-15 16:33:33 -07:00
derrod 3de564258d obs-outputs: Fix AV1 header parser adding ref count to data
The header packets are only used within the rtmp-output and do not need
or use the ref counter as the data is manually free'd directly.

The presence of this ref counter causes a crash on *nix platforms due to
our memory alignment hack attempting to free memory but reading the
wrong offset due to the ref counter being there rather than the
alignment offset.
2023-04-06 23:30:24 +02:00
nquah eca5c51df0 obs-outputs: Fix HEVC/RTMP composition time missing
Fixes bug in Enhanced RTMP implementation. Populates non-zero
HEVC composition times in the FLV extended video tag header.
2023-04-04 23:14:14 +02:00
PatTheMav 6e07b86729 cmake: Remove EXCLUDE_FROM_ALL directive from interface libraries 2023-04-04 17:27:54 +00:00
derrod aea0867945 obs-outputs: Do not strip AV1 padding for RTMP/FLV 2023-03-29 16:53:33 -04:00
Translation Updater 7c5560bf1b Update translations from Crowdin 2023-03-27 13:39:03 +00:00
derrod 678a98ace2 obs-outputs: Fix compilation without ENABLE_HEVC 2023-03-26 20:43:27 -04: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
Yuriy Chumak 27dc30b672 obs-outputs: Prevent streaming HDR AV1/HEVC over RTMP
Currently unsupported by all remotes accepting enhanced RTMP. This
commit may be removed at a later date.
2023-03-26 16:37:31 +02:00
Yuriy Chumak 2d4f0ac440 obs-outputs: Add support for AV1/HEVC over RTMP
Implements AV1 and HEVC according to enhanced RTMP spec found at
https://github.com/veovera/enhanced-rtmp

Co-authored-by: derrod <dennis@obsproject.com>
2023-03-26 16:37:31 +02:00
tytan652 5e4ed49a2d obs-outputs,obs-ffmpeg: Use connect infos in outputs 2023-03-19 17:38:02 +01:00
tytan652 855956f60e obs-outputs,obs-ffmpeg: Add protocol to service outputs 2023-03-19 15:29:03 +01:00
Richard Stanway c9dd230a72 obs-outputs: Explicitly close RTMP socket on send error
Some send() errors are not treated as fatal but the connection gets shut
down regardless. When this happens, librtmp may send an FCunpublish
message which various services interpret as an "end of stream" message
and disable features like "disconnect protection". Instead, let's
explicitly close the socket so that the remote end is aware that this is
an unclean disconnect.
2023-03-18 15:38:54 -07:00
tytan652 a0905d3972 obs-outputs,UI: Disable Windows-only options on non-Windows
"New Socket Loop" and "Low Latency Mode" RTMP options are only available
on Windows.

Those options should be ignored and forced-disabled on non-Windows
builds.
2023-03-18 15:29:50 -07:00
derrod 5aecbebc98 obs-outputs: Remove Windows 7 sndbuf auto-tuning check 2023-03-18 15:19:48 -07:00
tytan652 278973576e obs-outputs: Fix RTMP undefined symbols if built without Mbed TLS 2023-03-07 17:01:49 -05:00
Norihiro Kamae d89ca58467 obs-outputs: Remove unused macro 2023-01-28 19:03:55 -08:00
tytan652 323d2f60da obs-outputs: Calm some warnings if FTL on Clang and GCC
-Wenum-conversion is only available with GCC from the version 10.
2023-01-19 13:08:46 -05:00
Richard Stanway bf00ef1ea3 obs-outputs: Improvements to Windows interface logging
Now uses GetIfEntry2 which supports 64-bit values for reporting speed, so
10+ gbps adapters are now reported correctly in the log. Also added an
additional log line if the interface error counters are non-zero to possibly
help identify physical faults. Finally the transmit and receive speeds are
logged independently so that asynchronous mediums such as Wi-Fi that might
have good RX but poor TX can be better diagnosed.
2023-01-14 15:48:43 -08:00
Translation Updater 783bd52197 Update translations from Crowdin 2023-01-08 04:10:37 +00:00
Jim 301730f40c obs-outputs: Shorten dynamic bitrate increment timeout
The dynamic increment timeout does not need to be 30 seconds. Change it
to 4 seconds instead to make dynamic bitrate something that people
actually want to use.
2022-11-15 09:37:45 -08:00
Richard Stanway 63c3299a9f
obs-outputs: Increase librtmp send timeout to 15 seconds
Based on what we're seeing after the release of OBS 28, six seconds is
too low and causes disconnects instead of dropped frames.
2022-11-11 20:53:10 +01:00
PatTheMav 5913be9198
obs-outputs: Fix snprintf calls with literals as buffer sizes 2022-11-11 19:51:28 +01:00
PatTheMav bf692d816e
obs-outputs: 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
Georges Basile Stavracas Neto fb51f8b224 obs-outputs: Drop unused config file
The obs-outputs-config.h.in file is not actually used. It only
defines the FTL_FOUND variable, but the build system takes care
of that by setting a compiler argument for that.

Drop that file.
2022-09-17 16:38:50 -07:00
Translation Updater cc2d0791ca Update translations from Crowdin 2022-08-30 09:00:44 +00:00
Translation Updater 4aaa07f93d Update translations from Crowdin 2022-08-17 04:22:50 +00:00
Translation Updater 81734be37c Update translations from Crowdin 2022-07-31 23:40:53 +00:00
tt2468 70f33f7794 obs-outputs: Improve librtmp timeouts on Linux
Replaces the usage of SO_SNDTIMEO with TCP_USER_TIMEOUT on Linux.
- Noted as more effective than SO_SNDTIMEO by multiple sources.
- Drops TCP connection on timeout instead of returning send() errors,
meaning more predictable reconnect timing and reconnect.
- Timeout period actually reflected in practice. SO_SNDTIMEO takes
double the timeout time than actually requested to time out on
unix, whereas WinSock actually waits the specified time.
2022-07-23 17:24:11 -07:00
Ryan Foster 614ff22e8d obs-outputs: Fix TLS_client init for mbedTLS 3.1.0+
When trying to update to mbedTLS 3.2.1, I ran into failures with RTMPS
output. After consulting an mbedTLS implementation example, I determined
that we were not setting up the SSL/TLS context config in the correct
order, causing the connection to fail. Performing the setup in the
recommended order fixes that.
2022-07-23 16:40:59 -07:00
Vainock eb06594381 Use property suffixes for units everywhere 2022-07-22 08:24:51 -04:00
jpark37 cb5f718d1d obs-outputs: Suppress LNK4098
defaultlib 'MSVCRT' conflicts with use of other libs; use
/NODEFAULTLIB:library
2022-07-18 03:52:04 -07:00
jpark37 df96e68ca6 cmake: Disable LNK4099 warning
We are very unlikely to ship PDBs for deps.
2022-07-11 22:07:10 -07:00
tt2468 97756861b4 obs-outputs: Rework RTMP context init/deinit
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.
2022-07-09 17:04:37 -07:00
Richard Stanway 17c39ccb07 obs-ffmpeg, obs-outputs: Check return of obs_encoder_get_extra_data
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.
2022-06-25 16:03:12 -07:00
Richard Stanway dada82fec1
obs-outputs: Don't shutdown RTMP session when silently reconnecting
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.
2022-06-20 22:10:06 +02:00
jp9000 a31d7acb14 obs-outputs: Fix missing function declaration 2022-06-15 00:52:43 -07:00
jp9000 7ba9db3744 obs-outputs: Reset TLS on reconnect
Reverts e8b2b2092b and properly fixes an issue where bad TLS data
would persist through reconnections when the connection is encrypted.
2022-06-15 00:31:08 -07:00
jp9000 e8b2b2092b obs-outputs: Clear RTMP data before initiating connect
Sometimes when reconnecting the internal RTMP data is not cleared
(particularly the TLS data). This can cause TLS data to carry over from
one connection to another, causing issues with the secondary connection.
2022-06-06 10:12:50 -07:00
tytan652 16e19d2e9c obs-output: Fix compiler warnings
* obs-output: Fix unused-parameter warning

* obs-output: Fix pointer type mismatch warning
2022-05-04 01:37:10 -07:00
tt2468 66a7db7f2a obs-outputs: Implement send timeout in librtmp
This fixes a bug where the RTMP send thread can deadlock upon the
underlying TCP connection being broken. By introducing a send timeout,
this allows the thread to unblock and give up, triggering a reconnect
as normal. The correct solution to this problem would be to rewrite
librtmp with asynchronous IO, but that seems like something unlikely
to happen.

**Before**:
- Start stream in OBS
- Use tool (pfSense) to invalidate connection state
- OBS bitrate drops to 0
- Output does not respond to stop signals, and hangs for an undefined
amount of time (usually multiple minutes) before finally giving up

**After**:
- Start stream in OBS
- Use tool (pfSense) to invalidate connection state
- OBS bitrate drops to 0
- Output sits in blocked state for maximum of 8 seconds, then cleans
up and triggers the reconnect logic
2022-04-30 16:22:10 -07:00