Cameron Gutman
e44e4290ed
Use relaxed atomic for receivedDataFromPeer
2026-11-11 00:11:20 -06:00
Cameron Gutman
7bf16de8e2
Verify source addresses for STUN responses
2026-11-03 00:49:12 -06:00
Cameron Gutman
c7dff22963
Add replay detection to RTSP and control streams
...
Replays can do very little harm in these contexts, but let's detect and prevent them anyways.
Fixes #165
Closes #170
2026-11-01 14:07:45 -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
9686f6942f
Consolidate PltCloseThread() and PltJoinThread()
2024-02-17 18:14:03 -06:00
Cameron Gutman
c0e3dc64a4
Add basic QoS attributes to our A/V sockets
2024-02-01 00:15:47 -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
b74b6e883c
Add video encryption support
2024-01-14 14:04:52 -06:00
Cameron Gutman
bbf15af837
Revert "Use connected datagram sockets for audio and video"
...
This causes problems on multi-homed GFE and Sunshine (prior to v0.21) hosts
because audio and video data can be sent back from an address different than
the one we used as our original destination address.
This reverts commit c13f4a323f .
2023-10-26 01:15:27 -05: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
620b4be477
Add separate LC_ASSERT_VT() for asserts that only apply for valid traffic
2023-10-11 20:01:39 -05:00
Cameron Gutman
c13f4a323f
Use connected datagram sockets for audio and video
...
This ensures unwanted data from other sources is dropped and that our own source address doesn't change while streaming.
2023-09-12 23:29:05 -05:00
Cameron Gutman
ec6713fd80
Improve checks for runt video packets
...
Since we always allocate fixed size these aren't likely to be exploitable,
but we ought to fix them anyway. Worst case, we will just read some garbage
and generate corrupt video output.
2023-09-12 22:44:45 -05:00
Cameron Gutman
77c5d5c282
Tune SO_RCVBUF logic
...
- Calculate desired SO_RCVBUF by packet size for the video socket
- Use the OS default SO_RCVBUF for audio and STUN sockets
2023-07-25 18:30:19 -05:00
Cameron Gutman
dc186082a7
Add protocol extension for multi-client-compatible ping support
2023-02-12 01:23:25 -06: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
56ccd99cc7
Dynamically determine audio, video, and control ports from RTSP DESCRIBE response
2021-07-01 23:45:33 -05:00
Cameron Gutman
75999a6e07
Add Video/Audio prefix to ThreadProc names
...
It's easier to find them in stack traces that way.
2021-06-20 10:36:05 -05:00
Cameron Gutman
b58930c687
Don't start the decoder thread in pull-mode
2021-06-13 15:30:37 -05:00
Cameron Gutman
68c784445c
Introduce optional pull-based API for video data
2021-06-13 15:14:38 -05:00
Cameron Gutman
9361c325bb
Rename RtpFecQueue to RtpVideoQueue to match RtpAudioQueue
2021-06-01 22:57:26 -05:00
Cameron Gutman
8f371343cd
Consolidate includes
2021-04-29 17:22:15 -05:00
Cameron Gutman
fe205d838d
Don't check for errors from sendto() in the ping threads
2021-04-28 17:04:44 -05:00
Cameron Gutman
3979dbd082
Allow compilation on OSes without IPv6 support
2021-04-17 23:40:36 -05:00
Cameron Gutman
4304e597d8
Add byteswapping macros for big-endian systems
2021-04-17 21:43:13 -05:00
Cameron Gutman
5f9f7ce407
Code cleanup: use stdbool.h
2020-11-30 20:38:13 -06:00
Cameron Gutman
1b022a0d05
Terminate the connection if we can't receive a key frame in 10 seconds
2020-08-29 21:00:05 -07:00
Cameron Gutman
ae00c09cb6
Restore the 500 ms ping logic to prevent warnings in the server-side logs
2020-08-08 23:16:55 -07:00
Cameron Gutman
f596e80575
Improve logging of video/audio delay and errors
2020-05-01 20:23:44 -07:00
Cameron Gutman
b46e06fcf1
Terminate the connection if video isn't received for 10 seconds
2020-05-01 19:25:24 -07:00
Cameron Gutman
9ffdc79b6f
Add log messages to troubleshoot problems with missing video/audio
2020-04-29 20:17:55 -07:00
Cameron Gutman
f4dad9ae8b
Add presentation timestamp to video frame metadata
2019-11-10 18:07:11 -08:00
Cameron Gutman
31aa893acd
Name our threads on Linux
2019-05-03 18:54:40 -07:00
Cameron Gutman
e01617cd17
Remove unused variable
2019-05-02 19:41:59 -07:00
Cameron Gutman
fe7cb006da
Improve FEC queue packet submission and retrieval from O(n) to O(1)
2019-04-25 23:02:01 -07:00
Cameron Gutman
f395d3056a
Eliminate a copy and allocation for each incoming video packet
2019-04-25 22:07:03 -07:00
Cameron Gutman
d6971983aa
Use an interruptible sleep to allow our threads to exit sooner
2019-04-06 15:26:59 -07:00
Cameron Gutman
40fa4ef3c8
Reduce NAT keepalive packet rate after connection is established
2019-03-24 12:54:41 -07:00
Cameron Gutman
aa9610847e
Ensure termination error code is propagated properly
2019-02-09 21:30:16 -08:00
Cameron Gutman
12eebe0039
Wait for first IDR frame before enabling RFI
2019-01-19 14:44:48 -08:00
Cameron Gutman
6e7965f013
Use SO_RCVTIMEO to avoid the overhead of an extra syscall per packet
2018-07-16 00:46:40 -07:00
Cameron Gutman
4134ea3c23
Prevent the depacketizer from receiving parity packets
2017-06-10 15:42:51 -07:00
Cameron Gutman
c386569754
Remove length prefix on video buffers
2017-06-10 12:55:50 -07:00
Cameron Gutman
86447399a9
Add start and stop callbacks for audio and video renderers
2017-05-21 12:50:53 -07:00
Cameron Gutman
2d7bf5be82
Fix state cleanup if LiStartConnection() fails
2017-05-18 09:52:50 -07:00
Iwan Timmer
9bf8d361a1
Forward Error Correction ( #24 )
...
* Preperation for FEC by adding new queue which buffers whole frames
* Add code for creating recovered RTP packet
* Add checks before repair missing packets
* Initial implementation for single FEC packet
* Implement FEC for multiple packets
2017-05-04 21:22:30 -07:00
Cameron Gutman
f57bd745b4
API update to provide enough information to support GFE 3.0.7
2016-10-05 17:23:59 -07:00
Sunguk Lee
ba27e97698
Add vita environment ( #22 )
...
* vita: initial port
* vita: implement events, enable input thread
* vita: gethostbyname
* vita: Enable audio
* vita: Fix thread crash on discoonect process
* vita: Handle cannot create thread
* vita: now use newlib's socket apis
* vita: Refactoring for moonlight-stream/moonlight-common-c
* Fix review things
https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2436093
- vita may not support IPv6; so add LC_ASSERT them.
- define inet_ntop to sceNetInetNtop
- guard about failure of sceKernelCreateMutex or sceKernelCreateCond
- remove meanless macros
https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2444677
- !*mutex to *mutex
- remove useless LC_ASSERT then change to use inet_ntop
in vita system not defined `sockaddr_in6`, so just use `sockaddr_in` instead this.
https://github.com/moonlight-stream/moonlight-common-c/pull/22#pullrequestreview-2445642
- define sin6_addr
2016-10-05 16:43:33 -07:00
Cameron Gutman
7e5e2cebe2
Increase recv buffer of video stream from 64K to 512K for improved 4K performance
2016-05-06 14:44:16 -04:00
Cameron Gutman
48a5d63045
Reorganize the folder structure and delete the Xcode build files
2016-03-31 07:22:03 -04:00