|
Sunshine master
Self-hosted game stream host for Moonlight.
|
Definitions for the streaming protocols. More...
#include <fstream>#include <future>#include <queue>#include <boost/endian/arithmetic.hpp>#include <openssl/err.h>#include <rs.h>#include <moonlight-common-c/src/Limelight-internal.h>#include "config.h"#include "display_device.h"#include "globals.h"#include "input.h"#include "logging.h"#include "network.h"#include "platform/common.h"#include "process.h"#include "stream.h"#include "sync.h"#include "system_tray.h"#include "thread_safe.h"#include "utility.h"Classes | |
| struct | stream::audio_fec_packet_t |
| Packed RTP and FEC headers for an audio recovery packet. More... | |
| struct | stream::audio_packet_t |
| Packed RTP header for an audio packet. More... | |
| struct | stream::broadcast_ctx_t |
| UDP broadcast socket and target address state. More... | |
| struct | stream::control_adaptive_triggers_t |
| Control payload that configures DualSense adaptive triggers. More... | |
| struct | stream::control_encrypted_t |
| Packed encrypted control-channel envelope. More... | |
| struct | stream::control_hdr_mode_t |
| Control payload that toggles HDR mode and carries metadata. More... | |
| struct | stream::control_header_v2 |
| Packed control-channel header used before control payloads. More... | |
| struct | stream::control_rumble_t |
| Control payload that sets controller rumble motors. More... | |
| struct | stream::control_rumble_triggers_t |
| Control payload that sets trigger rumble motors. More... | |
| class | stream::control_server_t |
| ENet control server that routes incoming control packets to stream sessions. More... | |
| struct | stream::control_set_motion_event_t |
| Control payload that enables or disables motion reports. More... | |
| struct | stream::control_set_rgb_led_t |
| Control payload that sets controller RGB LED color. More... | |
| struct | stream::control_terminate_t |
| Control-channel termination message payload. More... | |
| struct | stream::fec::fec_t |
| Reed-Solomon FEC encoder state for video packets. More... | |
| struct | stream::session_t |
| Runtime state for one audio/video streaming session. More... | |
| struct | stream::video_packet_enc_prefix_t |
| AES-GCM prefix written before encrypted video packet payloads. More... | |
| struct | stream::video_packet_raw_t |
| Packed RTP and video headers for an unencrypted video packet. More... | |
| struct | stream::video_short_frame_header_t |
| Packed short video frame header sent before video payload bytes. More... | |
Typedefs | |
| using | stream::audio_aes_t = std::array<char, round_to_pkcs7_padded(MAX_AUDIO_PACKET_SIZE)> |
| AES key storage used for audio packet encryption. | |
| using | stream::av_session_id_t = std::variant<asio::ip::address, std::string> |
| Audio/video session identifier carried by GameStream packets. | |
| typedef struct stream::control_encrypted_t * | stream::control_encrypted_p |
| Packed encrypted control-channel envelope. | |
| using | stream::message_queue_queue_t = std::shared_ptr<safe::queue_t<std::tuple<socket_e, av_session_id_t, message_queue_t>>> |
| Shared queue set used to distribute packet queues to broadcast workers. | |
| using | stream::message_queue_t = std::shared_ptr<safe::queue_t<std::pair<udp::endpoint, std::string>>> |
| Mail queue carrying encoded stream packets to sender threads. | |
| using | stream::fec::rs_t |
| Owning pointer for a Reed-Solomon encoder instance. | |
Enumerations | |
| enum class | stream::socket_e : int { video , audio } |
| Enumerates supported socket options. More... | |
Functions | |
| std::shared_ptr< session_t > | stream::session::alloc (config_t &config, rtsp_stream::launch_session_t &launch_session) |
| Allocate and initialize platform input state for a stream. | |
| void | stream::audioBroadcastThread (udp::socket &sock) |
| Run the broadcast audio sender thread. | |
| void | stream::audioThread (session_t *session) |
| Run the session audio capture and encode thread. | |
| const std::string & | stream::session::client_cert (session_t &session) |
| Return the paired client certificate for this session. | |
| std::vector< uint8_t > | stream::concat_and_insert (uint64_t insert_size, uint64_t slice_size, const std::string_view &data1, const std::string_view &data2) |
| Combines two buffers and inserts new buffers at each slice boundary of the result. | |
| void | stream::controlBroadcastThread (control_server_t *server) |
| Run the broadcast control-channel worker thread. | |
| void | stream::end_broadcast (broadcast_ctx_t &ctx) |
| Stop broadcast processing. | |
| void | stream::session::join (session_t &session) |
| Wait for worker threads owned by the session to exit. | |
| int | stream::recv_ping (session_t *session, decltype(broadcast)::ptr_t ref, socket_e type, std::string_view expected_payload, udp::endpoint &peer, std::chrono::milliseconds timeout) |
| Receive ping data. | |
| void | stream::recvThread (broadcast_ctx_t &ctx) |
| Receive thread data. | |
| std::vector< uint8_t > | stream::replace (const std::string_view &original, const std::string_view &old, const std::string_view &_new) |
| Replace a byte sequence in an encoded packet. | |
| constexpr std::size_t | stream::round_to_pkcs7_padded (std::size_t size) |
| Round a byte count up to the next PKCS#7 padding boundary. | |
| int | stream::send_feedback_msg (session_t *session, platf::gamepad_feedback_msg_t &msg) |
| Pass gamepad feedback data back to the client. | |
| int | stream::send_hdr_mode (session_t *session, video::hdr_info_t hdr_info) |
| Send the selected HDR mode to the connected client over the control channel. | |
| int | stream::session::start (session_t &session, const std::string &addr_string) |
| Start the audio, video, and control workers for a streaming session. | |
| int | stream::start_broadcast (broadcast_ctx_t &ctx) |
| Start periodic mDNS and service-discovery broadcasts. | |
| state_e | stream::session::state (session_t &session) |
| Platform handle returned from stream setup. | |
| void | stream::session::stop (session_t &session) |
| Stop the active streaming session and prevent new packets from being queued. | |
| void | stream::videoBroadcastThread (udp::socket &sock) |
| Run the broadcast video sender thread. | |
| void | stream::videoThread (session_t *session) |
| Run the session video capture and encode thread. | |
Definitions for the streaming protocols.
| typedef struct stream::control_encrypted_t * stream::control_encrypted_p |
Packed encrypted control-channel envelope.
Alias for control encrypted p.
| using stream::fec::rs_t |
Owning pointer for a Reed-Solomon encoder instance.
|
strong |
| std::shared_ptr< session_t > stream::session::alloc | ( | config_t & | config, |
| rtsp_stream::launch_session_t & | launch_session ) |
Allocate and initialize platform input state for a stream.
| config | Configuration values to apply. |
| launch_session | Launch session. |
| void stream::audioBroadcastThread | ( | udp::socket & | sock | ) |
Run the broadcast audio sender thread.
| sock | Socket used to read or write the protocol message. |
| void stream::audioThread | ( | session_t * | session | ) |
Run the session audio capture and encode thread.
| session | Active streaming or pairing session for the request. |
| const std::string & stream::session::client_cert | ( | session_t & | session | ) |
Return the paired client certificate for this session.
Return the paired client certificate for a stream session.
| session | Active streaming or pairing session for the request. |
| std::vector< uint8_t > stream::concat_and_insert | ( | uint64_t | insert_size, |
| uint64_t | slice_size, | ||
| const std::string_view & | data1, | ||
| const std::string_view & | data2 ) |
Combines two buffers and inserts new buffers at each slice boundary of the result.
| insert_size | The number of bytes to insert. |
| slice_size | The number of bytes between insertions. |
| data1 | The first data buffer. |
| data2 | The second data buffer. |
| void stream::controlBroadcastThread | ( | control_server_t * | server | ) |
Run the broadcast control-channel worker thread.
| server | RTSP server instance handling the request. |
| void stream::end_broadcast | ( | broadcast_ctx_t & | ctx | ) |
Stop broadcast processing.
| ctx | Native context object used by the operation or callback. |
| void stream::session::join | ( | session_t & | session | ) |
Wait for worker threads owned by the session to exit.
| session | Active streaming or pairing session for the request. |
| int stream::recv_ping | ( | session_t * | session, |
| decltype(broadcast)::ptr_t | ref, | ||
| socket_e | type, | ||
| std::string_view | expected_payload, | ||
| udp::endpoint & | peer, | ||
| std::chrono::milliseconds | timeout ) |
Receive ping data.
| session | Active streaming or pairing session for the request. |
| ref | Reference frame metadata used by the encoder. |
| type | Protocol, message, or resource type selector. |
| expected_payload | Expected payload. |
| peer | Remote endpoint associated with the socket. |
| timeout | Maximum time to wait for the operation. |
| void stream::recvThread | ( | broadcast_ctx_t & | ctx | ) |
Receive thread data.
| ctx | Native context object used by the operation or callback. |
| std::vector< uint8_t > stream::replace | ( | const std::string_view & | original, |
| const std::string_view & | old, | ||
| const std::string_view & | _new ) |
Replace a byte sequence in an encoded packet.
| original | Original text value used when reporting a parsing failure. |
| old | Byte sequence to replace in encoded packets. |
| _new | Replacement byte sequence inserted into encoded packets. |
|
constexpr |
Round a byte count up to the next PKCS#7 padding boundary.
| size | Number of bytes or elements requested. |
size rounded up to the next PKCS#7 block boundary. | int stream::send_feedback_msg | ( | session_t * | session, |
| platf::gamepad_feedback_msg_t & | msg ) |
Pass gamepad feedback data back to the client.
| session | The session object. |
| msg | The message to pass. |
| int stream::send_hdr_mode | ( | session_t * | session, |
| video::hdr_info_t | hdr_info ) |
Send the selected HDR mode to the connected client over the control channel.
| session | Active streaming or pairing session for the request. |
| hdr_info | HDR info. |
| int stream::session::start | ( | session_t & | session, |
| const std::string & | addr_string ) |
Start the audio, video, and control workers for a streaming session.
Start a streaming session for the supplied peer address.
| session | Active streaming or pairing session for the request. |
| addr_string | Addr string. |
| int stream::start_broadcast | ( | broadcast_ctx_t & | ctx | ) |
Start periodic mDNS and service-discovery broadcasts.
Bind the GameStream UDP and control sockets used for a streaming session.
| ctx | Native context object used by the operation or callback. |
| state_e stream::session::state | ( | session_t & | session | ) |
Platform handle returned from stream setup.
| session | Active streaming or pairing session for the request. |
| void stream::session::stop | ( | session_t & | session | ) |
Stop the active streaming session and prevent new packets from being queued.
Stop a streaming session and prevent more packets from being queued.
| session | Active streaming or pairing session for the request. |
| void stream::videoBroadcastThread | ( | udp::socket & | sock | ) |
Run the broadcast video sender thread.
| sock | Socket used to read or write the protocol message. |
| void stream::videoThread | ( | session_t * | session | ) |
Run the session video capture and encode thread.
| session | Active streaming or pairing session for the request. |