0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00
Commit Graph

85 Commits

Author SHA1 Message Date
PatTheMav
121fb8b2fd obs-outputs: Fix provision of CA certificates to mbedTLS on macOS 2023-08-28 10:39:21 -04:00
PatTheMav
57849bb0e7 obs-outputs: Refine certificate selection on macOS
Query for trusted and valid (based on datetime) certificates only.
2023-08-05 16:41:41 -07:00
James Hurley
cca1cbf11b obs-outputs: Add log message on successful connection 2023-07-24 16:55:42 -07:00
James Hurley
ba41613ab8 obs-outputs: Adopt Happy Eyeballs in RTMP
This commit adopts the happy eyeballs utility in the RTMP
output module, replacing the existing TCP connection logic.
2023-07-24 16:55:13 -07:00
PatTheMav
f7ec81ca12 obs-outputs: Fix keychain API deprecation warnings on macOS 2023-05-13 16:59:42 -07: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
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
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
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
jp9000
a31d7acb14 obs-outputs: Fix missing function declaration 2022-06-15 00:52:43 -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
tytan652
7d07b57993 obs-outputs,librtmp: Remove encrypted RTMP support
RC4 and Diffie-Hellmann Key related codes are removed
2022-03-18 13:34:03 -07:00
tytan652
179ad9e67b librtmp: Add mbedtls 3 compatibility
Since Mbed TLS 3 doesn't support RC4 algorithm,
encrypted RTMP is disabled if OBS is built with
the version 3 or later of Mbed TLS.
2022-03-18 13:34:03 -07:00
jp9000
b4fb1db460 obs-outputs/librtmp: Add custom connect data callback
Allows the ability to add custom connect data to the connect signal
encoding
2021-12-21 09:44:21 -08:00
Thulinma
244b6c92e6 obs-outputs: Fix RTMP restart not always working
Bug is caused by the internal connection variables not being reset on
reconnect, leading OBS to both be unable to parse valid packets from and
send valid packets to the remote end.  This commit splits RTMP_Init off
into a new RTMP_Reset function, which resets these internal variables
without re-initing the rest of the library.  The original RTMP_Init
calls the new function, perfectly preserving the old behaviour while
adding a new reset function to address the issue with.

Fixes obsproject/obs-studio#2865
2021-01-31 18:44:11 -08:00
Ryan Foster
548938c210 obs-outputs: Log unhandled status description as debug level
Certain RTMP status descriptions can contain stream keys. We don't want
to log those normally, so log the description for unhandled status codes
as RTMP_LOGDEBUG. If someone needs to debug an RTMP server's return
messages, they can compile OBS with the RTMP Log Level set to
RTMP_LOGDEBUG.
2020-11-24 14:17:49 -08:00
Vadim Zhukov
0d222b6b56 Add OpenBSD support 2020-11-14 11:55:22 -08:00
Shaolin
420823bfaa plugins: Clear compile warnings on Linux 2020-08-26 01:34:03 -03:00
Jim
aef10d46c4
Merge pull request #3322 from kkartaltepe/unused-var-cleanup
obs-filters/obs-outputs: Cleanup unused var warns
2020-08-23 12:40:54 -07:00
Kurt Kartaltepe
43da6eacd0 obs-filters/obs-outputs: Cleanup unused var warns
Fix unused variables when compiling without rnnoise
Fix unused variable warnings in GCC when using assert() in release
2020-08-23 12:09:59 -07:00
jp9000
746a522986 obs-outputs: Don't assume @setDataFrame
Don't assume @setDataFrame when using an info packet.  I'm guessing
librtmp did this because the only time this packet type was normally
used was when you use onMetaData.
2020-08-22 08:27:58 -07:00
Eric Lindvall
1939472912 obs-outputs: Log unhandled rtmp status responses
rtmp status responses that are not handled are currently silently ignored
making it difficult to identify issues.
2020-06-18 18:00:45 -07:00
Eric Lindvall
6a880530f1 obs-outputs: Handle rtmp NetStream.Publish.BadName response
Adobe Media Server and nginx-rtmp can return this status response to a
publisher if the key is already being used to publish.
2020-06-18 18:00:45 -07:00
Kurt Kartaltepe
107c632220 obs-outputs: Fix warnings WITH_RTMPS=OFF
Some unused variables were not marked unused when RTMPS was disabled.
2020-04-04 11:09:12 -07:00
Richard Stanway
1dc2c6a3be obs-outputs: Fix mbed TLS build issues
Version test macro was using the wrong version, and the non-crypto
MD5 only code was accidentally moved into an #ifdef which ended up
disabling it.

Fixes https://github.com/obsproject/obs-studio/issues/2426
2020-03-23 17:32:39 +01:00
Richard Stanway
452a4b5085 obs-outputs: Fix RTMP authentication
RTMP authentication requires the curStreamIdx and nStreams be set
between the disconnect / reconnect that occurs in PublisherAuth. Now
that there's no good place to clean them up, zero the whole rtmp->Link
before starting a new stream.
2020-03-06 22:52:50 +01:00
Richard Stanway
ee4cbb1199 obs-outputs: Properly reset stream count on RTMP_Close
Every addStream call would increment this counter. After merging the
mbedTLS fixes, we no longer have extraneous RTMP_Init calls which were
masking the prescence of this bug. This caused every stream after the
first stream to have the wrong channel index, and eventually OBS would
crash due to an out of bounds write if the counter reached
RTMP_MAX_STREAMS.
2020-02-23 01:04:14 +01:00
Richard Stanway
c465212414 obs-outputs: Remove hard-coded certificate paths on Linux
The report in https://github.com/obsproject/obs-studio/issues/2350
identified the issue as being caused by mbedtls not following symbolic
links, but it turns out the issue was the mbedtls_x509_crt_parse_path
return value which was already fixed in 4d89123c. So these changes are
no longer necessary.
2020-01-30 19:48:23 +01:00
Richard Stanway
2f4447a7a1 obs-outputs: Remove server support from librtmp
This code is very old and seems to be non-functional in its current
state. The TLS support is also complicated to maintain across multiple
deprecated mbedtls functions.
2020-01-25 19:31:48 +01:00
Richard Stanway
5f62cd153b obs-outputs: Remove unused variable 2020-01-25 19:25:43 +01:00
Richard Stanway
baa559813c obs-outputs: Fix build with older mbedtls versions
Compilation with older versions of mbedtls was broken by
https://github.com/obsproject/obs-studio/pull/2304, unfortunately the
older version is still present in Ubuntu 16 LTS.
2020-01-25 18:58:05 +01:00
Richard Stanway
476b727fea obs-outputs: Show UI error if the root certs don't load
Though this should now be very rare, it's more helpful than "Failed to
connect to server". Other TLS error codes are now also stored for future
use instead of copying them on a case by case basis.
2020-01-25 17:35:07 +01:00
Richard Stanway
d1159087f1 obs-outputs: Add additional paths for root certificates on Linux
Fixes https://github.com/obsproject/obs-studio/issues/2350. Also adds
some log file output for when the root certificates can't be loaded to
make it more obvious what the problem is.
2020-01-25 16:49:11 +01:00
Richard Stanway
2b131d212f obs-outputs: Fix librtmp mbedtls thread safety
Per mbedtls documentation, "If you share a context between threads, you
need to call these functions only from the main thread, at the beginning
and end of the context's lifetime.". OBS violated this since librtmp
uses a global context and it was allocated and freed in different
threads such as the auto config test.

This commit attaches the mbedtls context to an RTMP structure so there
is no more global state. It also fixes a rare double-free crash that
could occur if RTMP_TLS_Free was called twice (this happened in rare
situations such as the auto config running followed by a mode change
from Advanced to Simple).
2020-01-23 00:11:23 +01:00
Kurt Kartaltepe
4d89123cdc librtmp: Allow partial success for mbedtls
mbedtls_x509_crt_parse_path returns a positive number if it partially
succeeds and a negative number on complete failure. This changes the
positive result to no longer error and prevent TLS connections (OBS
verifies all endpoints so having no CA chain prevents TLS).
2020-01-12 13:31:39 -08:00
Florian Zwoch
2699bbbd77 obs-outputs: Fix mbedtls use of deprecated functions
mbedtls_md5_starts(), mbedtls_md5_update() and mbedtls_md5_finish()
have been marked deprecated since mbedtls version 2.7 and may go
away in the future.

These function have been superseded by versions with a return
value. They are suffixed with "_ret". We do not actually check
return values.

Also the header "mbedtls/net.h" has been superseded by
"mbedtls/net_sockets.h".
2020-01-08 11:45:55 +01:00
jp9000
53615ee10f clang-format: Add clang-format files 2019-06-23 01:53:56 -07:00
James Park
2ff9cf17c0 obs-outputs: Fix undefined MSG_NOSIGNAL
Define MSG_NOSIGNAL even if CRYPTO is not defined.
2019-05-09 22:38:34 -07:00
Tristan Matthews
94c881b891 obs-outputs: Return error instead emitting SIGPIPE
This could happen if writing to a socket which was closed by the peer.
2019-05-09 17:05:38 -07:00
pkv
a5b837518e obs-outputs: Fix leak with certs for rtmp 2019-04-21 23:54:27 +02:00
Jim
06488a55ce
Merge pull request #1416 from admshao/cleanup-macro-declaration
Cleanup Compilation warnings
2018-09-07 00:51:58 -07:00
Shaolin
bf72435db8 obs-outputs: Fix unused variable compiler warning
Some security layer libraries code path used by the rtmp output had a
not used variable and not used param on HMAC_finish macro that was
triggering warnings during compilation.
2018-09-06 22:10:29 -03:00
Shaolin
d500ef3bb5 obs-outputs: Make rtmp packet alloc code path clearer
On 64bit systems, this check will always evaluate to false due to
SIZE_MAX type and triggers a compiler warning.

This both makes it clearer that its only needed on 32bit system and
clear the compiler warning.
2018-09-06 22:10:24 -03:00
Richard Stanway
c68d022f9c
obs-outputs: Revert f1f49bc1 to fix RTMP authentication
This reverts commit f1f49bc197, which
breaks RTMP authentication as these parameters are intended to "leak"
into the next use of the RTMP context.
2018-08-27 15:04:39 +02:00
Michael Goulet
e67e2e12e6 obs-outputs: Add support for and use mbedTLS for SSL
This diff adds mbedTLS support to the obs-outputs plugin.  PolarSSL and
mbedTLS have grown so different between 2015-or-so when libRTMP was
written, and now it's no longer feasible to just use the USE_POLARSSL
flag.

This commit adds a WITH_RTMPS tri-state CMake variable (auto/on/off),
set to "Auto" by default.  "Auto" will use RTMPS if mbedTLS is found,
otherwise will disable RTMPS.  "On" will make it require mbedTLS,
otherwise fails configuration, and "Off" disables RTMPS support
altogether.

Closes obsproject/obs-studio#1360
2018-08-05 18:40:49 -07:00
Richard Stanway
cc69ec16ec
obs-outputs: Update librtmp with upstream patches
Mostly security / reliability related, fixing various access to
uninitialized data, integer overflows, etc from
https://git.ffmpeg.org/rtmpdump
2018-07-23 23:22:37 +02:00
pkviet
f1f49bc197 librtmp: Fix memory leak
A leak was introduced by commit 1682d77 (July 11 2015).
This is a fix.
2018-06-07 00:44:29 +02:00