Commit Graph

66 Commits

Author SHA1 Message Date
Cameron Gutman 07c32c80f9 Use a valid port when calling connect() for local address detection
BSDs (including Darwin) don't like using port 0.
2026-02-06 22:53:54 -06:00
7mile 305993b013 fix: use UDP connect to probe local address (#121) 2026-01-29 18:52:06 -06:00
Cameron Gutman c245fe599d Use higher packet size for remote streaming over end-to-end IPv6 connection
The IPv6 spec guarantees a minimum of 1280 byte MTUs
2024-05-29 13:57:50 -04:00
Cameron Gutman 48d7f1ace1 Fix incorrect function definition 2024-02-25 15:52:04 -06:00
GaryOderNichts 9545dd7603 Implement detached threads (#88)
The `AsyncTerm` thread is never joined but its handle is immediately closed. This works fine on Windows, but causes issues on other platforms where threads need to be explicitly detached if never joined (pthread, wiiu).

This adds a new `PltDetachThread` function, which can be used instead of `PltCloseThread` to explictly detach a thread, requiring it to no longer be closed.
2024-02-17 17:54:32 -06:00
Cameron Gutman 955f13a18d Implement RTSP encryption support 2024-02-02 22:55:53 -06:00
Cameron Gutman b6bbb4fb26 Add new RTSP encryption flags 2024-01-14 12:08:37 -06:00
Cameron Gutman 15b55a441b Add LiGetExtraLaunchArgs()
The string returned from this function should be appended to the end of the /resume and /launch query parameters.
2024-01-14 11:48:59 -06:00
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