Sunshine latest
Self-hosted game stream host for Moonlight.
config.h File Reference

Declarations for the configuration of Sunshine. More...

#include <bitset>
#include <chrono>
#include <optional>
#include <string>
#include <string_view>
#include <unordered_map>
#include <vector>
#include "nvenc/nvenc_config.h"
Include dependency graph for config.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  config::audio_t
 Audio capture and encoder settings loaded from configuration. More...
struct  config::sunshine_t::cmd_t
 Command-line options parsed before configuration loading. More...
struct  config::video_t::dd_t
 Display-device integration settings. More...
struct  config::input_t
 Input emulation settings loaded from configuration. More...
struct  config::video_t::dd_t::mode_remapping_entry_t
 Single display mode remapping rule from configuration. More...
struct  config::video_t::dd_t::mode_remapping_t
 Collection of display mode remapping rules. More...
struct  config::nvhttp_t
 HTTP and HTTPS settings used by the GameStream pairing server. More...
struct  config::prep_cmd_t
 External preparation command plus its privilege requirement. More...
struct  config::stream_t
 Network stream settings shared by audio, video, and control channels. More...
struct  config::sunshine_t
 Top-level Sunshine configuration and credential state. More...
struct  config::video_t
 Video encoder, capture, and color settings loaded from configuration. More...
struct  config::video_t::dd_t::workarounds_t
 Compatibility workarounds for display-device control. More...

Enumerations

enum  config::flag::flag_e : std::size_t {
  config::flag::PIN_STDIN = 0 , config::flag::FRESH_STATE , config::flag::FORCE_VIDEO_HEADER_REPLACE , config::flag::UPNP ,
  config::flag::CONST_PIN , config::flag::FLAG_SIZE
}
 Enumerates supported flag options. More...

Functions

std::string config::nv::ffmpeg_preset_from_quality (int quality_preset)
 Convert Sunshine's NVENC quality preset number to FFmpeg's stable symbolic name.
void config::log_config_settings (const std::unordered_map< std::string, std::string > &vars, bool save)
 Log parsed configuration entries and optionally record them as modified.
int config::parse (int argc, char *argv[])
 Parse serialized text into the corresponding runtime representation.
std::unordered_map< std::string, std::string > config::parse_config (const std::string_view &file_content)
 Parse Sunshine configuration text into key-value entries.
bool config::persist_config_option_if_missing (std::string_view name, std::string_view value)
 Persist a configuration option when the active file does not already define it.
bool config::select_all_gamepad_drivers_if_licensed (bool virtualhid_licensed)
 Select all available gamepad drivers when a licensed user has not made a choice.

Variables

constexpr int config::ENCRYPTION_MODE_MANDATORY = 2
 Encryption policy that rejects clients without video encryption support.
constexpr int config::ENCRYPTION_MODE_NEVER = 0
 Encryption policy that always sends unencrypted video.
constexpr int config::ENCRYPTION_MODE_OPPORTUNISTIC = 1
 Encryption policy that uses encrypted video only when the client supports it.
constexpr std::string_view config::GAMEPAD_DRIVER_ALL = "all"
 Allow every available Windows virtual gamepad driver.
constexpr std::string_view config::GAMEPAD_DRIVER_VIGEMBUS = "vigembus"
 Allow only ViGEmBus for Windows gamepads.
constexpr std::string_view config::GAMEPAD_DRIVER_VIRTUALHID = "virtualhid"
 Allow only Virtual HID Driver for Windows gamepads.
std::unordered_map< std::string, std::string > config::modified_config_settings
 Configuration keys changed during the current parse or UI update.
constexpr int config::PACKETSIZE_LARGE = 1456
 Default large packet size that avoids common MTU fragmentation.
constexpr int config::PACKETSIZE_MAX = 65535
 Highest accepted configured packet size in bytes.
constexpr int config::PACKETSIZE_MIN = 200
 Lowest accepted configured packet size in bytes.
constexpr int config::PACKETSIZE_SMALL = 500
 Conservative packet size used for low-MTU links.
constexpr std::array config::redacted_config
 Configuration keys whose values must be hidden in logs.

Detailed Description

Declarations for the configuration of Sunshine.

Enumeration Type Documentation

◆ flag_e

enum config::flag::flag_e : std::size_t

Enumerates supported flag options.

Enumerator
PIN_STDIN 

Read PIN from stdin instead of http.

FRESH_STATE 

Do not load or save state.

FORCE_VIDEO_HEADER_REPLACE 

force replacing headers inside video data

UPNP 

Try Universal Plug 'n Play.

CONST_PIN 

Use "universal" pin.

FLAG_SIZE 

Number of flags.

Function Documentation

◆ ffmpeg_preset_from_quality()

std::string config::nv::ffmpeg_preset_from_quality ( int quality_preset)

Convert Sunshine's NVENC quality preset number to FFmpeg's stable symbolic name.

Parameters
quality_presetValidated Sunshine quality preset in the range 1 through 7.
Returns
FFmpeg preset name from p1 through p7.

◆ log_config_settings()

void config::log_config_settings ( const std::unordered_map< std::string, std::string > & vars,
bool save )

Log parsed configuration entries and optionally record them as modified.

Log configuration entries and optionally mark them for persistence.

Parameters
varsParsed configuration entries to log.
saveWhether modified configuration values should be written back to disk.

◆ parse()

int config::parse ( int argc,
char * argv[] )

Parse serialized text into the corresponding runtime representation.

Parameters
argcNumber of command-line arguments.
argvCommand-line argument vector.
Returns
0 on success; nonzero when command-line or configuration parsing fails.

◆ parse_config()

std::unordered_map< std::string, std::string > config::parse_config ( const std::string_view & file_content)

Parse Sunshine configuration text into key-value entries.

Parameters
file_contentRaw configuration file contents to parse.
Returns
Parsed configuration key-value entries.

◆ persist_config_option_if_missing()

bool config::persist_config_option_if_missing ( std::string_view name,
std::string_view value )

Persist a configuration option when the active file does not already define it.

Existing text and comments are retained because the new setting is appended rather than serializing the complete configuration again.

Parameters
nameConfiguration option name.
valueConfiguration option value.
Returns
True when the option was appended successfully; otherwise, false.

◆ select_all_gamepad_drivers_if_licensed()

bool config::select_all_gamepad_drivers_if_licensed ( bool virtualhid_licensed)

Select all available gamepad drivers when a licensed user has not made a choice.

Parameters
virtualhid_licensedWhether Virtual HID Driver has an active machine license.
Returns
True when the all preference was persisted and applied; otherwise, false.

Variable Documentation

◆ redacted_config

std::array config::redacted_config
inlineconstexpr
Initial value:
= {
"csrf_allowed_origins"
}

Configuration keys whose values must be hidden in logs.