Commit Graph

58 Commits

Author SHA1 Message Date
Cameron Gutman
6e9ed871bc Add support for X-SS-Connect-Data in RTSP SETUP for control stream
This allows the host to provide a 32-bit integer that will be sent
in the data of the ENet connect event, similar to X-SS-Ping-Payload
for video and audio.

The host can use this data to uniquely identify a client when IP
addresses are not stable across the various separate connections,
such as when the client is behind a Carrier-Grade NAT.
2023-12-28 16:56:06 -06:00
Cameron Gutman
3ed3ba6253 Remove separate codec, HDR, and remote bitrate adjustments
We currently scale bitrate based on both remote vs local, SDR vs HDR, and H.264 vs
HEVC vs AV1. This has led to a lot of user confusion wondering why the bitrate
doesn't seem to match their selection in some configurations.

In H.264 local streams, we will currently overshoot the selected bitrate by about
20% due to FEC, while remote streams will be right around the selected bitrate due
to remote-specific FEC bitrate adjustments.

HEVC and AV1 streams (as configured by most clients) basically behave similarly
between local and remote, since the codec bitrate adjustment factor of 75% is nearly
the same as the FEC bitrate adjustment factor of 80%. However, this adjustment was
only performed for SDR streams so local HDR streams would overshoot like H.264.

This change cleans up all this mess by using a single non-codec-specific video
bitrate adjustment for FEC in all cases. It also allows Sunshine to perform the FEC
adjustment on its end if the default FEC value of 20% has been overridden by the
user or if we implement dynamic FEC support in the future.

The net result is HEVC and AV1 SDR streams will only see a tiny bitrate increase,
but HDR and H.264 may see noticable 20% bitrate reductions that may require the
user to adjust their bitrate setting to reach the effective value they got before.
However, the new behavior should be more intuitive for users going forward since
changing codecs, using a VPN, or enabling HDR won't cause significant changes to the
video bitrate.
2023-12-03 20:09:34 -06:00
Cameron Gutman
05c3f9c754 Bind our UDP sockets to the same local address used by RTSP handshake
This means we can ensure a consistent local address for our outgoing PING
traffic to keep the UDP flows alive without having to call connect() which breaks
with multi-homed hosts on GFE and Sunshine v0.20 and earlier.
2023-10-26 01:09:26 -05:00
Cameron Gutman
9b5fbff7ba Only disable 4K H.264 RFI with GFE 2023-07-16 15:13:22 -05:00
Cameron Gutman
7608e8e69d Enforce setting serverCodecModeSupport field in SERVER_INFORMATION 2023-07-04 14:56:20 -05:00
Cameron Gutman
e36bde4acc Implement AV1 codec support
This has a breaking change to StreamConfiguration that requires client updates.
2023-07-02 22:16:20 -05:00
Cameron Gutman
9bf09d681e Plumb Sunshine feature flags SDP attribute for protocol extensions 2023-06-18 15:52:51 -05:00
Cameron Gutman
4a48024dc8 Introduce new input extension functions for touch, pen, motion, and controller arrival 2023-06-11 19:38:22 -05:00
Cameron Gutman
dc186082a7 Add protocol extension for multi-client-compatible ping support 2023-02-12 01:23:25 -06:00
Cameron Gutman
50c0a51b10 Improve high quality audio support
High quality audio now works on IPv6 and remote connections
2022-11-04 21:44:07 -05:00
Cameron Gutman
e951302927 Disable RFI when streaming from a server that doesn't support it 2022-10-06 20:01:40 -05:00
Cameron Gutman
5b2cf1b8f7 Fix handling of hostname with multiple candidate IP addresses when using alternate ports 2021-08-14 12:30:04 -05:00
Cameron Gutman
d14f62c26a Fix crash when client provides no video decoder callbacks 2021-07-17 21:55:39 -05:00
Cameron Gutman
3b9d8a3176 Assert that the port numbers are set prior to being used 2021-07-02 01:44:11 -05:00
Cameron Gutman
cdda221d64 Log the parsed ports 2021-07-02 01:30:33 -05:00
Cameron Gutman
5ec8ee7cbf Parse the RTSP port out of the RTSP session URL 2021-07-02 01:17:34 -05:00
Cameron Gutman
56ccd99cc7 Dynamically determine audio, video, and control ports from RTSP DESCRIBE response 2021-07-01 23:45:33 -05:00
Cameron Gutman
5e3aa93479 Add a recording mode for debugging purposes 2021-06-20 11:15:30 -05:00
Cameron Gutman
68c784445c Introduce optional pull-based API for video data 2021-06-13 15:14:38 -05:00
Cameron Gutman
43eb36e17a Simplify and improve graceful disconnect logic 2021-05-14 22:36:13 -05:00
Cameron Gutman
387ff48a65 Perform a graceful disconnection if the termination was locally initiated 2021-05-14 22:06:07 -05:00
Cameron Gutman
5d09d43b08 Disable RFI at 4K until the problems are understood 2021-05-06 22:17:04 -05:00
Cameron Gutman
8f371343cd Consolidate includes 2021-04-29 17:22:15 -05:00
Cameron Gutman
db81f1e512 Add support for audio stream encryption
Clients must opt-in using the new encryptionFlags field
2021-04-22 00:20:17 -05:00
Cameron Gutman
0a00163f0b Fix audio stream init error check 2021-04-09 13:00:35 -05:00
Cameron Gutman
d0c3513504 Reorder audio initialization and RTSP handshake to avoid RTSP PLAY failure on GFE 3.22 2021-04-09 08:39:28 -05:00
Cameron Gutman
5f9f7ce407 Code cleanup: use stdbool.h 2020-11-30 20:38:13 -06:00
Cameron Gutman
7b024c967e Try TCP 47989 and TCP 48010 as fallbacks if 47984 doesn't work 2020-09-06 11:55:25 -07:00
Cameron Gutman
0cda408d3c Warn when streaming above 4K with H.264 or 8K with HEVC 2020-04-04 12:36:09 -07:00
Cameron Gutman
4f9d45fbb5 Round down odd height values to avoid NVENC initialization failure 2020-04-04 11:51:55 -07:00
Cameron Gutman
86751d9162 Move ConnectionListener initialization prior to possible Limelog() usage 2020-04-04 11:51:20 -07:00
Cameron Gutman
607aaca93f Replace AUDIO_CONFIGURATION constants with MAKE_AUDIO_CONFIGURATION() macro 2020-03-31 21:33:34 -07:00
Cameron Gutman
fb60ae6a4d Parse Opus parameters from RTSP DESCRIBE response 2020-03-31 20:52:38 -07:00
Cameron Gutman
2fc278da00 Change errorCode to int for consistency between 32-bit and 64-bit platforms
Unfortunately this requires updating all client code that uses these callbacks.
2020-02-24 23:01:22 -08:00
Cameron Gutman
a9780361a3 Fix high-quality surround sound breaking audio when streaming over the Internet or IPv6 2019-08-04 15:05:40 -07:00
Cameron Gutman
59481c085a Add support for requesting 20 ms audio frames for slow Opus decoders 2019-05-04 15:33:48 -07:00
Cameron Gutman
31aa893acd Name our threads on Linux 2019-05-03 18:54:40 -07:00
Cameron Gutman
aa9610847e Ensure termination error code is propagated properly 2019-02-09 21:30:16 -08:00
Cameron Gutman
860393536d Ensure a connection termination callback is not invoked due to calling LiInterruptConnection() 2018-12-28 15:28:56 -08:00
Cameron Gutman
e8dd103ed9 Use existing cleanup path for handling early-out errors 2018-11-22 12:52:11 -08:00
Cameron Gutman
e741a12a25 Ensure RemoteAddrString is nulled out just in case LiStopConnection() is called 2018-11-21 21:31:18 -08:00
Cameron Gutman
639ff18dbb Allow automatic detection of remote streaming 2018-11-21 20:52:50 -08:00
Cameron Gutman
42df6475c8 Catch forgetting to initialize packetSize field 2018-11-21 20:36:49 -08:00
Cameron Gutman
396b02a94d Test each address returned in the getaddrinfo() call and stop blindly preferring IPv4
Fixes NAT64 on iOS 12 and probably other obscure configurations
2018-11-16 00:37:38 -08:00
Cameron Gutman
9396f6c528 Move resolveHostName() into PlatformSockets.c 2018-10-26 17:02:45 -07:00
Cameron Gutman
679f6e83bb Fix HEVC streams requiring a higher bitrate to enable high quality surround audio 2018-07-27 19:04:25 -07:00
Cameron Gutman
a8b01d6c29 Enable high quality surround sound when the video bitrate is over 15 Mbps 2018-05-27 18:45:09 -07:00
Iwan Timmer
d3fe286eb7 Add audio context and flags 2017-05-28 15:34:56 +02:00
Cameron Gutman
6e31c21815 Round down the specified packet size to the nearest multiple of 16 rather than forcing 1024 all the time 2017-05-26 21:17:43 -07:00
Cameron Gutman
92951e1309 Add LiInterruptConnection() to interrupt LiStartConnection() 2017-05-21 12:24:22 -07:00