![]() |
Sunshine latest
Self-hosted game stream host for Moonlight.
|
Declarations for common platform specific utilities. More...
#include <bitset>
#include <filesystem>
#include <functional>
#include <mutex>
#include <string>
#include <boost/core/noncopyable.hpp>
#include "src/config.h"
#include "src/logging.h"
#include "src/thread_safe.h"
#include "src/utility.h"
#include "src/video_colorspace.h"
#include <moonlight-common-c/src/Limelight.h>
Go to the source code of this file.
Classes | |
class | platf::audio_control_t |
struct | platf::avcodec_encode_device_t |
struct | platf::batched_send_info_t |
struct | platf::buffer_descriptor_t |
class | platf::deinit_t |
class | platf::display_t |
struct | platf::encode_device_t |
struct | platf::gamepad_arrival_t |
struct | platf::gamepad_battery_t |
struct | platf::gamepad_feedback_msg_t |
struct | platf::gamepad_id_t |
struct | platf::gamepad_motion_t |
struct | platf::gamepad_state_t |
struct | platf::gamepad_touch_t |
struct | platf::high_precision_timer |
struct | platf::img_t |
class | platf::mic_t |
struct | platf::sink_t::null_t |
struct | platf::nvenc_encode_device_t |
struct | platf::pen_input_t |
struct | platf::send_info_t |
struct | platf::sink_t |
struct | platf::supported_gamepad_t |
struct | platf::touch_input_t |
struct | platf::touch_port_t |
Namespaces | |
namespace | nvenc |
Standalone NVENC encoder. | |
Macros | |
#define | _CONVERT(x) |
#define | SERVICE_NAME "Sunshine" |
#define | SERVICE_TYPE "_nvstream._tcp" |
Typedefs | |
typedef uint32_t | platf::platform_caps::caps_t |
typedef deinit_t | platf::client_input_t |
typedef basic_environment< char > | boost::v1::environment |
using | platf::feedback_queue_t = safe::mail_raw_t::queue_t<gamepad_feedback_msg_t> |
using | platf::input_t = util::safe_ptr<void, freeInput> |
Enumerations | |
enum class | platf::capture_e : int { ok , reinit , timeout , interrupted , error } |
enum class | platf::gamepad_feedback_e { rumble , rumble_triggers , set_motion_event_state , set_rgb_led } |
enum class | platf::mem_type_e { system , vaapi , dxgi , cuda , videotoolbox , unknown } |
enum class | platf::pix_fmt_e { yuv420p , yuv420p10 , nv12 , p010 , ayuv , yuv444p16 , y410 , unknown } |
enum class | platf::qos_data_type_e : int { audio , video } |
enum | platf::speaker::speaker_e { platf::speaker::FRONT_LEFT , platf::speaker::FRONT_RIGHT , platf::speaker::FRONT_CENTER , platf::speaker::LOW_FREQUENCY , platf::speaker::BACK_LEFT , platf::speaker::BACK_RIGHT , platf::speaker::SIDE_LEFT , platf::speaker::SIDE_RIGHT , platf::speaker::MAX_SPEAKERS } |
enum class | platf::thread_priority_e : int { low , normal , high , critical } |
Functions | |
void | platf::abs_mouse (input_t &input, const touch_port_t &touch_port, float x, float y) |
void | platf::adjust_thread_priority (thread_priority_e priority) |
int | platf::alloc_gamepad (input_t &input, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue) |
Create a new virtual gamepad. | |
std::unique_ptr< client_input_t > | platf::allocate_client_input_context (input_t &input) |
Allocate a context to store per-client input data. | |
std::filesystem::path | platf::appdata () |
Performs migration if necessary, then returns the appdata directory. | |
std::unique_ptr< audio_control_t > | platf::audio_control () |
void | platf::button_mouse (input_t &input, int button, bool release) |
std::unique_ptr< high_precision_timer > | platf::create_high_precision_timer () |
Create platform-specific timer capable of high-precision sleep. | |
std::shared_ptr< display_t > | platf::display (mem_type_e hwdevice_type, const std::string &display_name, const video::config_t &config) |
Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monitor that's compatible you can find If you require to use this parameter in a separate thread, make a copy of it. | |
std::vector< std::string > | platf::display_names (mem_type_e hwdevice_type) |
std::unique_ptr< deinit_t > | platf::enable_socket_qos (uintptr_t native_socket, boost::asio::ip::address &address, uint16_t port, qos_data_type_e data_type, bool dscp_tagging) |
Enable QoS on the given socket for traffic to the specified destination. | |
void | platf::free_gamepad (input_t &input, int nr) |
void | platf::freeInput (void *) |
std::string_view | platf::from_pix_fmt (pix_fmt_e pix_fmt) |
std::string | platf::from_sockaddr (const sockaddr *const) |
std::pair< std::uint16_t, std::string > | platf::from_sockaddr_ex (const sockaddr *const) |
void | platf::gamepad_battery (input_t &input, const gamepad_battery_t &battery) |
Send a gamepad battery event to the OS. | |
void | platf::gamepad_motion (input_t &input, const gamepad_motion_t &motion) |
Send a gamepad motion event to the OS. | |
void | platf::gamepad_touch (input_t &input, const gamepad_touch_t &touch) |
Send a gamepad touch event to the OS. | |
void | platf::gamepad_update (input_t &input, int nr, const gamepad_state_t &gamepad_state) |
Updates virtual gamepad with the provided gamepad state. | |
platform_caps::caps_t | platf::get_capabilities () |
Get the supported platform capabilities to advertise to the client. | |
std::string | platf::get_host_name () |
Returns the current computer name in UTF-8. | |
std::string | platf::get_mac_address (const std::string_view &address) |
util::point_t | platf::get_mouse_loc (input_t &input) |
Get the current mouse position on screen. | |
void | platf::hscroll (input_t &input, int distance) |
std::unique_ptr< deinit_t > | platf::init () |
input_t | platf::input () |
void | platf::keyboard_update (input_t &input, uint16_t modcode, bool release, uint8_t flags) |
void | platf::move_mouse (input_t &input, int deltaX, int deltaY) |
bool | platf::needs_encoder_reenumeration () |
Check if GPUs/drivers have changed since the last call to this function. | |
void | platf::open_url (const std::string &url) |
Open a url in the default web browser. | |
void | platf::pen_update (client_input_t *input, const touch_port_t &touch_port, const pen_input_t &pen) |
Send a pen event to the OS. | |
bool | platf::process_group_running (std::uintptr_t native_handle) |
Check if a process group still has running children. | |
bool | platf::request_process_group_exit (std::uintptr_t native_handle) |
Attempt to gracefully terminate a process group. | |
void | platf::restart () |
boost::process::v1::child | platf::run_command (bool elevated, bool interactive, const std::string &cmd, boost::filesystem::path &working_dir, const boost::process::v1::environment &env, FILE *file, std::error_code &ec, boost::process::v1::group *group) |
void | platf::scroll (input_t &input, int distance) |
bool | platf::send (send_info_t &send_info) |
bool | platf::send_batch (batched_send_info_t &send_info) |
int | platf::set_env (const std::string &name, const std::string &value) |
Set an environment variable. | |
std::unique_ptr< deinit_t > | platf::publish::start () |
Main entry point for publication of our service on macOS. | |
void | platf::streaming_will_start () |
void | platf::streaming_will_stop () |
std::vector< supported_gamepad_t > & | platf::supported_gamepads (input_t *input) |
Gets the supported gamepads for this platform backend. | |
void | platf::touch_update (client_input_t *input, const touch_port_t &touch_port, const touch_input_t &touch) |
Send a touch event to the OS. | |
void | platf::unicode (input_t &input, char *utf8, int size) |
int | platf::unset_env (const std::string &name) |
Unset an environment variable. | |
Variables | |
constexpr std::uint32_t | platf::A = 0x1000 |
constexpr std::uint32_t | platf::B = 0x2000 |
constexpr std::uint32_t | platf::BACK = 0x0020 |
constexpr caps_t | platf::platform_caps::controller_touch = 0x02 |
constexpr std::uint32_t | platf::DPAD_DOWN = 0x0002 |
constexpr std::uint32_t | platf::DPAD_LEFT = 0x0004 |
constexpr std::uint32_t | platf::DPAD_RIGHT = 0x0008 |
constexpr std::uint32_t | platf::DPAD_UP = 0x0001 |
constexpr std::uint32_t | platf::HOME = 0x0400 |
constexpr std::uint32_t | platf::LEFT_BUTTON = 0x0100 |
constexpr std::uint32_t | platf::LEFT_STICK = 0x0040 |
constexpr std::uint8_t | platf::speaker::map_stereo [] |
constexpr std::uint8_t | platf::speaker::map_surround51 [] |
constexpr std::uint8_t | platf::speaker::map_surround71 [] |
constexpr auto | platf::MAX_GAMEPADS = 16 |
constexpr std::uint32_t | platf::MISC_BUTTON = 0x200000 |
constexpr std::uint32_t | platf::PADDLE1 = 0x010000 |
constexpr std::uint32_t | platf::PADDLE2 = 0x020000 |
constexpr std::uint32_t | platf::PADDLE3 = 0x040000 |
constexpr std::uint32_t | platf::PADDLE4 = 0x080000 |
constexpr caps_t | platf::platform_caps::pen_touch = 0x01 |
constexpr std::uint32_t | platf::RIGHT_BUTTON = 0x0200 |
constexpr std::uint32_t | platf::RIGHT_STICK = 0x0080 |
constexpr std::uint32_t | platf::START = 0x0010 |
constexpr std::uint32_t | platf::TOUCHPAD_BUTTON = 0x100000 |
constexpr std::uint32_t | platf::X = 0x4000 |
constexpr std::uint32_t | platf::Y = 0x8000 |
Declarations for common platform specific utilities.
#define _CONVERT | ( | x | ) |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
|
strong |
int platf::alloc_gamepad | ( | input_t & | input, |
const gamepad_id_t & | id, | ||
const gamepad_arrival_t & | metadata, | ||
feedback_queue_t | feedback_queue ) |
Create a new virtual gamepad.
input | The global input context. |
id | The gamepad ID. |
metadata | Controller metadata from client (empty if none provided). |
feedback_queue | The queue for posting messages back to the client. |
std::unique_ptr< client_input_t > platf::allocate_client_input_context | ( | input_t & | input | ) |
Allocate a context to store per-client input data.
Allocates a context to store per-client input data.
input | The global input context. |
std::filesystem::path platf::appdata | ( | ) |
Performs migration if necessary, then returns the appdata directory.
This is used for the log directory, so it cannot invoke Boost logging!
std::unique_ptr< high_precision_timer > platf::create_high_precision_timer | ( | ) |
Create platform-specific timer capable of high-precision sleep.
std::shared_ptr< display_t > platf::display | ( | platf::mem_type_e | hwdevice_type, |
const std::string & | display_name, | ||
const video::config_t & | config ) |
Get the display_t instance for the given hwdevice_type. If display_name is empty, use the first monitor that's compatible you can find If you require to use this parameter in a separate thread, make a copy of it.
display_name | The name of the monitor that SHOULD be displayed |
config | Stream configuration |
Pick a display adapter and capture method.
hwdevice_type | enables possible use of hardware encoder |
std::unique_ptr< deinit_t > platf::enable_socket_qos | ( | uintptr_t | native_socket, |
boost::asio::ip::address & | address, | ||
uint16_t | port, | ||
qos_data_type_e | data_type, | ||
bool | dscp_tagging ) |
Enable QoS on the given socket for traffic to the specified destination.
Enables QoS on the given socket for traffic to the specified destination.
native_socket | The native socket handle. |
address | The destination address for traffic sent on this socket. |
port | The destination port for traffic sent on this socket. |
data_type | The type of traffic sent on this socket. |
dscp_tagging | Specifies whether to enable DSCP tagging on outgoing traffic. |
void platf::gamepad_battery | ( | input_t & | input, |
const gamepad_battery_t & | battery ) |
Send a gamepad battery event to the OS.
Sends a gamepad battery event to the OS.
input | The global input context. |
battery | The battery event. |
void platf::gamepad_motion | ( | input_t & | input, |
const gamepad_motion_t & | motion ) |
Send a gamepad motion event to the OS.
Sends a gamepad motion event to the OS.
input | The global input context. |
motion | The motion event. |
void platf::gamepad_touch | ( | input_t & | input, |
const gamepad_touch_t & | touch ) |
Send a gamepad touch event to the OS.
Sends a gamepad touch event to the OS.
input | The global input context. |
touch | The touch event. |
void platf::gamepad_update | ( | input_t & | input, |
int | nr, | ||
const gamepad_state_t & | gamepad_state ) |
Updates virtual gamepad with the provided gamepad state.
input | The input context. |
nr | The gamepad index to update. |
gamepad_state | The gamepad button/axis state sent from the client. |
platform_caps::caps_t platf::get_capabilities | ( | ) |
Get the supported platform capabilities to advertise to the client.
Returns the supported platform capabilities to advertise to the client.
std::string platf::get_host_name | ( | ) |
Returns the current computer name in UTF-8.
util::point_t platf::get_mouse_loc | ( | input_t & | input | ) |
Get the current mouse position on screen.
input | The input_t instance to use. |
Examples
bool platf::needs_encoder_reenumeration | ( | ) |
Check if GPUs/drivers have changed since the last call to this function.
Returns if GPUs/drivers have changed since the last call to this function.
true
if a change has occurred or if it is unknown whether a change occurred. void platf::open_url | ( | const std::string & | url | ) |
Open a url in the default web browser.
url | The url to open. |
void platf::pen_update | ( | client_input_t * | input, |
const touch_port_t & | touch_port, | ||
const pen_input_t & | pen ) |
Send a pen event to the OS.
Sends a pen event to the OS.
input | The client-specific input context. |
touch_port | The current viewport for translating to screen coordinates. |
pen | The pen event. |
bool platf::process_group_running | ( | std::uintptr_t | native_handle | ) |
Check if a process group still has running children.
native_handle | The native handle of the process group. |
true
if processes are still running. bool platf::request_process_group_exit | ( | std::uintptr_t | native_handle | ) |
Attempt to gracefully terminate a process group.
native_handle | The native handle of the process group. |
true
if termination was successfully requested. int platf::set_env | ( | const std::string & | name, |
const std::string & | value ) |
Set an environment variable.
name | The name of the environment variable. |
value | The value to set the environment variable to. |
std::unique_ptr<::platf::deinit_t > platf::publish::start | ( | ) |
Main entry point for publication of our service on macOS.
This function initiates a connection to the macOS mDNS service and requests to register our Sunshine service. Registration will occur asynchronously (unless it fails immediately, which is probably only possible if the host machine is misconfigured).
nullptr
(if the registration fails immediately) or a uniqur_ptr<deinit_t>
, which will manage polling for a response from the mDNS service, and then, when deconstructed, will deregister the service. std::vector< supported_gamepad_t > & platf::supported_gamepads | ( | input_t * | input | ) |
Gets the supported gamepads for this platform backend.
This may be called prior to platf::input()
!
input | Pointer to the platform's input_t or nullptr . |
void platf::touch_update | ( | client_input_t * | input, |
const touch_port_t & | touch_port, | ||
const touch_input_t & | touch ) |
Send a touch event to the OS.
Sends a touch event to the OS.
input | The client-specific input context. |
touch_port | The current viewport for translating to screen coordinates. |
touch | The touch event. |
int platf::unset_env | ( | const std::string & | name | ) |
Unset an environment variable.
name | The name of the environment variable. |
|
constexpr |
|
constexpr |
|
constexpr |