Commit Graph

667 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
ns6089
2a5a1f3e8a Add support for LTR ACK control messages (#122)
* Add support for LTR ACK control messages
2026-01-20 21:47:38 -06:00
Cameron Gutman
435bc6a5a4 Fix pthread_attr leak 2026-01-11 01:46:30 -06:00
Cameron Gutman
3a377e7d7b Only set an explicit pthread stack size on Vita 2026-01-05 00:23:31 -06:00
Cameron Gutman
0586f3d65f Fix thread context leak on non-Vita platforms 2026-01-05 00:21:35 -06:00
Cameron Gutman
b126e481a1 Improve locking for batched mouse and gamepad sensor events
By unlocking the mutex before we enqueue the new entry, we can avoid the input thread immediately contending on the mutex after the new item wakes it up.
2025-11-25 17:30:01 -06:00
Cameron Gutman
20c05eda6a Don't lock the ENet mutex when querying for RTT information 2025-11-25 17:26:01 -06:00
Cameron Gutman
e59a5f5b53 Rewrite gamepad input batching to batch on the enqueue-side
- Allows successful batching of interleaved input from multiple controllers
- Avoids enqueue/dequeue overhead and memory allocation when batching
2025-11-09 15:47:12 -06:00
AorsiniYT
1c86405fd0 Fix: Add inclusion of <psp2/kernel/processmgr.h> for Vita compatibility 2025-11-07 00:37:14 -06:00
Andy Grundman
e356b2cfde Change presentationTimeMs to presentationTimeUs: retain more resolution when dealing with RTP video timestamps from Sunshine. Include raw rtpTimestamp value for use with integer time APIs. 2025-11-06 20:27:01 -06:00
Andy Grundman
fdd026518c macOS/iOS: use clock_gettime_nsec_np(CLOCK_UPTIME_RAW) instead of mach_absolute_time() per Apple's recommendation.
Move has_monotonic_time variable into the final variant of platform-specific time code (used by Linux/Unix).
2025-11-06 20:27:01 -06:00
Andy Grundman
a3ebaaf015 Use uint64_t for DECODE_UNIT presentationTimeMs
This still holds a millisecond value sourced from RTP timestamp, but since we're changing the API anyway, now is a good time to future-proof this field.
2025-11-06 20:27:01 -06:00
Andy Grundman
82ee2d6590 Improve support for high-resolution stats
* This patch adds a new microsecond-resolution function call, LiGetMicroseconds(), to complement
the existing LiGetMillis(). Many variables used by stats have been updated to work at this
higher resolution and now provide better results when displaying e.g. sub-millisecond frametime stats.
To try and avoid confusion, variables that now contain microseconds have been renamed with a suffix
of 'Us', and those ending in 'Ms' contain milliseconds. I originally experimented with nanoseconds but it
felt like overkill for our needs.

Public API in Limelight.h:
uint64_t LiGetMicroseconds(void);
uint64_t LiGetMillis(void);
const RTP_AUDIO_STATS* LiGetRTPAudioStats(void);  // provides access to RTP data for the overlay stats
const RTP_VIDEO_STATS* LiGetRTPVideoStats(void);

Note: Users of this library may need to make changes. If using LiGetMillis() to track the duration of
something that is shown to the user, consider switching to LiGetMicroseconds(). Remember to divide by
1000 at time of display to show in milliseconds.
2025-11-06 20:27:01 -06:00
Cameron Gutman
5f2280183c Fix CGN subnet mask 2025-07-15 09:59:57 -05:00
Cameron Gutman
0975a8684f Implement workaround for bad synthesized IPv6 addresses when connecting through a v4-only VPN on iOS 2025-07-14 22:27:54 -05:00
camelcx
c86e0537d1 Fix some edge case on small MTU devices using qsv codec (#107)
Add fall back logic to prevent edge case where SPS SPP is not included in the same packet and key IDR frame is mislabeled as P frame causing assertion error at validation.
2025-07-05 19:13:06 -05:00
armin-25689
29f298ec88 build: Add __FreeBSD__ compilation condition for pthread_setname_np() 2025-07-05 18:58:07 -05:00
AorsiniYT
34074c9ec0 Fixes for Moonlight compatibility on the PS Vita. (#110)
* Use pthread for vita thread managment

* Add thread name to pthread and remove ipv6 from vita

* Fix inclusion of pthread.h so that it is only included on specific platforms (__vita__)

* Fix memory release in ThreadProc for psvita platform

---------

Co-authored-by: MetalfaceScout <logan.mathis@utahtech.edu>
Co-authored-by: Logan Mathis <33127568+MetalfaceScout@users.noreply.github.com>
2025-07-05 18:57:33 -05:00
Cameron Gutman
58902e342f Zero output parameters when BbGet*() fails 2025-06-08 15:49:52 -05:00
Cameron Gutman
84f37631c2 Add ByteBuffer APIs for reading/writing multiple bytes 2025-06-08 15:46:47 -05:00
ABeltramo
e95feaf495 Protocol extension: DualSense adaptive trigger support (#102) 2025-03-25 18:16:11 -05:00
Cameron Gutman
d3d3e6cf01 Port improved ping interval logic into the control receive loop 2024-10-20 17:34:35 -05:00
Cameron Gutman
dff1690fe1 Validate channel count before parsing Opus param string 2024-10-15 23:00:16 -05:00
ns6089
0fa805d973 Guard against rtsp response with no content 2024-10-15 22:48:59 -05:00
Cameron Gutman
8599b6042a Use SO_NONBLOCK on Haiku 2024-06-10 23:45:51 -05:00
ns6089
907110c4ec Support YUV 4:4:4 formats 2024-06-06 02:31:32 -05: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
eb21561541 Don't depend on outputDataLength to be initialized with mbedTLS
OpenSSL has no such requirement, so MbedTLS breakages snuck in.
2024-03-05 21:09:57 -06:00
Cameron Gutman
48d7f1ace1 Fix incorrect function definition 2024-02-25 15:52:04 -06:00
Cameron Gutman
ba1fc33672 Fix spurious asserts in the unencrypted audio path with Sunshine 2024-02-20 18:03:50 -06:00
GaryOderNichts
3d99869c0c Implement support for userbuffers on Wii U
The Wii U socket implementation has limited memory available. To support larger receive buffers, application memory needs to be provided.
To make sockets use this user memory the `SO_RUSRBUF` option needs to be set on the socket.
2024-02-18 13:39:17 -06:00
Cameron Gutman
8af4562af6 Assert that active objects exist in deleters 2024-02-17 18:20:24 -06:00
Cameron Gutman
59f7f62b62 Fix thread detachment on Vita 2024-02-17 18:14:49 -06:00
Cameron Gutman
9686f6942f Consolidate PltCloseThread() and PltJoinThread() 2024-02-17 18:14:03 -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
cbd0ec1b25 Fix signed/unsigned mismatch warnings 2024-02-03 15:20:56 -06:00
Cameron Gutman
7ab34e709a Improve encrypted RTSP message validation 2024-02-03 14:39:12 -06:00
Cameron Gutman
955f13a18d Implement RTSP encryption support 2024-02-02 22:55:53 -06:00
zoeyjodon
35f730fedd Improve 3DS Reliability (#87)
- Simplifies thread priority setup
- Sets a max socket buffer size of 0x20000 for the 3DS
- Fixes a bug with polling timeouts taking longer than intended
- Removes 3DS global socket definition
2024-02-02 18:33:18 -06:00
Cameron Gutman
c0e3dc64a4 Add basic QoS attributes to our A/V sockets 2024-02-01 00:15:47 -06:00
Cameron Gutman
fb2b103e51 Fix propagation of errors from enet_host_service() in sendMessageEnet() 2024-01-24 22:41:03 -06:00
Cameron Gutman
e8113f0e66 Use the spare field in the encrypted video header as the frame number
This allows us to skip decrypting extra FEC shards after a frame was reassembled.
2024-01-24 18:36:37 -06:00
Cameron Gutman
a517f7cbca Fix -Wsign-compare warnings in debug build 2024-01-18 21:35:20 -06:00
zoey jodon
c104a97fa0 Add platform support for the 3DS
Prevent wildcard port binding on the 3DS
Add 3DS threading logic
Add 3DS socket logic
Bump the connection timeout to 60s for the 3DS
2024-01-18 18:30:20 -06:00
Cameron Gutman
2597b5e779 Use a 12-byte AES-GCM IV for the new encryption features 2024-01-18 18:29:47 -06:00
Elia Zammuto
7f99bebc72 UWP Changes (#85) 2024-01-15 16:36:28 -06:00
Cameron Gutman
298f356acb Adjust the requested packet size to account for the encryption header 2024-01-14 18:42:41 -06:00
Cameron Gutman
06f18be4bf Allow negotiation of audio encryption using new encryption flags 2024-01-14 14:10:45 -06:00
Cameron Gutman
b74b6e883c Add video encryption support 2024-01-14 14:04:52 -06:00