Commit graph

10 commits

Author SHA1 Message Date
pkv b15fc60d63 obs-ffmpeg: Fix rendezvous mode with SRT
Rendezvous mode with SRT protocol is used to punch through firewalls.
Although caller or listener mode are much more widespread, it is
sometimes in use. The rendezvous mode was broken in obs because we
would bind to the remote IP, instead of a local IP. This fixes the bug.
Note that there is also a bug in libsrt preventing our code to work.
But Version 1.5.2+ of libsrt fixes that.

Signed-off-by: pkv <pkv@obsproject.com>
2023-07-18 15:55:22 -04:00
tt2468 b2375a0660 obs-ffmpeg: Initialize SRT stats object before requesting stats
The `srt_bstats()` function is not guaranteed to zero the stats object
before filling in stats. If a socket was connected, then disconnected,
without any data being sent over it, the stats object would remain
uninitialized, and weird results could occur.
2023-02-08 11:13:41 -08:00
Richard Stanway 668775f4f0
obs-ffmpeg: Use gai_strerrorA for error logging on Windows
Avoids wide characters in the format string which cause truncation.
2023-01-27 23:41:07 +01:00
tytan652 d473c9416f obs-ffmpeg: Fix compilation warnings on Clang and GCC
- Fix format warnings
- Fix unused-parameter warnings
2023-01-19 13:08:46 -05:00
pkv ece4d1e90e obs-ffmpeg: Allow srt stream to disconnect after timeout
Fixes #7848
Currently OBS_OUTPUT_INVALID_STREAM is emitted when a wrong password is
used. This commit expands the signal emission to case of timeouts.

Signed-off-by: pkv <pkv@obsproject.com>
2022-12-03 15:02:03 -08:00
tt2468 24d7bea41f obs-ffmpeg: Improve RIST/SRT log messages
Overall improvements to match behavior of other log sources.
2022-11-19 18:16:05 -08:00
tytan652 c8a01f92ee
obs-ffmpeg: Fix SRT error type comparison (#7802) 2022-11-18 03:17:54 -06:00
pkv fcb6df1f63 obs-ffmpeg: Direct setting of encryption & auth for SRT & RIST
Also modifies UI.

This allows the direct use of passphrase (SRT & RIST) used for
encryption, user + password (RIST) as well as streamid (SRT).
Previously, these parameters had to be set in the URL in the form:
URL?option1=value1&option2=value2.
They still can but there is also the option to set them in the stream
key and username/password fields.
SRT:
- the stream_id is set in the stream key (more info on it: [1]);
- the encryption passphrase is set in the password auth field.
RIST:
- the encryption passphrase is set in the stream key;
- the srp_username and srp_password are set in the user/password auth
fields [2].

Additionally, some error logging has been added when there's a
disconnect caused by a wrong password.
Lastly, this solves a bug when auto-reconnect is set and a wrong
passphrase is provided for srt; the output would keep trying to
reconnect. With this commit, an OBS_OUTPUT_INVALID_STREAM signal is
emitted and the stream is immediately stopped.

[1] https://github.com/Haivision/srt/blob/master/docs/features/access-control.md
[2] https://code.videolan.org/rist/librist/-/wikis/Authentication-and-the-ristsrppasswd-Utility

Signed-off-by: pkv <pkv@obsproject.com>
2022-11-17 21:56:38 -05:00
tytan652 4303e31268 obs-ffmpeg: Replace ftime on *nix platforms
ftime is deprecated on newer version of glibc.
2022-07-31 21:48:13 -07:00
pkv e7d097cab8
obs-ffmpeg: Native SRT/RIST for mpegts output
Currently the ffmpeg_mpegts_muxer output is integrated with ffmpeg-mux.
Both use obs native encoders in contrast with obs-ffmpeg-output which
relies on avcodec library.
This allowed easy implementation of SRT, RIST & HLS protocols through
avformat library.
The main drawback is that obs-ffmpeg-mux exe doesn't allow for easy
debugging nor logging of the protocols.
It was written initially as a separate binary designed for recording so
that if obs fails for some reason, the recording can still terminate
gracefully.

In this commit the ffmpeg_mpegts_muxer is rewritten so that a pipe to
the ffmpeg-mux binary is not used any more.
The muxing to mpegts is still delegated to avformat.
But it can be traced more easily in all its steps.
Also the protocol part for SRT & RIST is implemented natively.
Custom avio_contexts for SRT & RIST are used to that end.
This allows to pass our own implementation of librist and libsrt
libraries instead of relying on avformat. This is very advantageous :
- this allows better logging.
- this allows better bug fixing and maintainance without having to rely
on hypothetical upstream fixes.

One immediate bonus of native implementation is that fixes bugs which
were not previously fixable.

Fixes: SRT & RIST auto-reconnect partly broken  #6749
Fixes: SRT: OBS unusable and uncloseable after starting stream to
invalid srt server #5791

Signed-off-by: pkv <pkv@obsproject.com>
2022-07-30 17:03:10 +02:00