13#include <unordered_map>
24 using config_map_t = std::unordered_map<std::string, std::string, util::transparent_string_hash, std::equal_to<>>;
33 std::string ffmpeg_preset_from_quality(
int quality_preset);
55 "csrf_allowed_origins"
64 void log_config_settings(
const config_map_t &vars,
bool save);
131 std::optional<int>
blbrc;
212 std::vector<mode_remapping_entry_t>
mixed;
425 void apply_config_for_test(std::string_view file_content);
435 int parse(
int argc,
char *argv[]);
bool select_all_gamepad_drivers_if_licensed(const bool virtualhid_licensed)
Select all available gamepad drivers when a licensed user has not made a choice.
Definition config.cpp:1068
stream_t stream
Default stream configuration values used before file and CLI overrides.
Definition config.cpp:819
config_map_t parse_config(const std::string_view &file_content)
Parse Sunshine configuration text into key-value entries.
Definition config.cpp:1024
input_t input
Default input configuration values used before file and CLI overrides.
Definition config.cpp:848
int parse(int argc, char *argv[])
Parse serialized text into the corresponding runtime representation.
Definition config.cpp:1977
video_t video
Default video configuration values used before file and CLI overrides.
Definition config.cpp:719
sunshine_t sunshine
Default top-level Sunshine configuration values used before file and CLI overrides.
Definition config.cpp:877
audio_t audio
Default audio configuration values used before file and CLI overrides.
Definition config.cpp:808
bool persist_config_option_if_missing(const std::string_view name, const std::string_view value)
Persist a configuration option when the active file does not already define it.
Definition config.cpp:1049
constexpr int PACKETSIZE_MAX
Highest accepted configured packet size in bytes.
Definition config.h:38
std::unordered_map< std::string, std::string, util::transparent_string_hash, std::equal_to<> > config_map_t
Owning configuration entries supporting lookup by string view or C string.
Definition config.h:24
config_map_t modified_config_settings
Configuration keys changed during the current parse or UI update.
Definition config.h:48
constexpr int ENCRYPTION_MODE_OPPORTUNISTIC
Encryption policy that uses encrypted video only when the client supports it.
Definition config.h:255
flag_e
Enumerates supported flag options.
Definition config.h:329
@ UPNP
Try Universal Plug 'n Play.
Definition config.h:333
@ FRESH_STATE
Do not load or save state.
Definition config.h:331
@ FLAG_SIZE
Number of flags.
Definition config.h:335
@ PIN_STDIN
Read PIN from stdin instead of http.
Definition config.h:330
@ FORCE_VIDEO_HEADER_REPLACE
force replacing headers inside video data
Definition config.h:332
@ CONST_PIN
Use "universal" pin.
Definition config.h:334
constexpr std::array redacted_config
Configuration keys whose values must be hidden in logs.
Definition config.h:54
constexpr int PACKETSIZE_LARGE
Default large packet size that avoids common MTU fragmentation.
Definition config.h:40
constexpr std::string_view GAMEPAD_DRIVER_VIRTUALHID
Use Virtual HID Broker for gamepads on Windows or macOS.
Definition config.h:43
constexpr int PACKETSIZE_MIN
Lowest accepted configured packet size in bytes.
Definition config.h:37
constexpr int ENCRYPTION_MODE_MANDATORY
Encryption policy that rejects clients without video encryption support.
Definition config.h:259
constexpr int ENCRYPTION_MODE_NEVER
Encryption policy that always sends unencrypted video.
Definition config.h:251
constexpr std::string_view GAMEPAD_DRIVER_VIGEMBUS
Allow only ViGEmBus for Windows gamepads.
Definition config.h:44
constexpr std::string_view GAMEPAD_DRIVER_NONE
Disable virtual gamepads on Windows and macOS.
Definition config.h:45
constexpr int PACKETSIZE_SMALL
Conservative packet size used for low-MTU links.
Definition config.h:39
constexpr std::string_view GAMEPAD_DRIVER_ALL
Allow every available Windows virtual gamepad driver.
Definition config.h:42
Contains all the functions and variables related to the nvhttp (GameStream) server.
Definition nvhttp.cpp:46
Handles the system tray icon and notification system.
Definition system_tray.cpp:90
Declarations for NVENC encoder configuration.
Transparent hashing for containers with owning string keys.
Audio capture and encoder settings loaded from configuration.
Definition config.h:238
bool external_audio
Windows capture-only mode; an external router owns endpoint defaults and formats.
Definition config.h:243
bool stream
Enable audio streaming to clients.
Definition config.h:241
bool install_steam_drivers
Install Steam audio drivers for enhanced compatibility.
Definition config.h:242
std::string sink
Audio output device/sink to use for audio capture.
Definition config.h:239
std::string virtual_sink
Virtual audio sink for audio routing.
Definition config.h:240
std::string format
Encoded audio format: Opus, AC-3, or E-AC-3.
Definition config.h:244
bool high_quality_audio
Use higher bitrates for negotiated Dolby streams; ignored for Opus.
Definition config.h:245
HTTP and HTTPS settings used by the GameStream pairing server.
Definition config.h:282
std::string file_state
Path to the persisted Sunshine state file.
Definition config.h:292
std::string external_ip
External address advertised to clients when configured.
Definition config.h:294
std::string cert
Certificate PEM string or path.
Definition config.h:288
std::string pkey
Private key PEM string or path.
Definition config.h:287
std::string sunshine_name
Host name advertised to Moonlight clients.
Definition config.h:290
std::string origin_web_ui_allowed
Origin policy used for Web UI access checks.
Definition config.h:285
prep_cmd_t(std::string &&do_cmd, bool &&elevated)
Build a preparation command entry from parsed configuration data.
Definition config.h:362
prep_cmd_t(std::string &&do_cmd, std::string &&undo_cmd, bool &&elevated)
Build a preparation command entry from parsed configuration data.
Definition config.h:350
std::string undo_cmd
Command to run after the application exits.
Definition config.h:368
std::string do_cmd
Command to run before the application starts.
Definition config.h:367
bool elevated
Whether the process should be launched elevated.
Definition config.h:369
Network stream settings shared by audio, video, and control channels.
Definition config.h:264
int lan_encryption_mode
Video encryption policy for LAN clients.
Definition config.h:272
std::string file_apps
Path to the configured applications file.
Definition config.h:267
int wan_encryption_mode
Video encryption policy for WAN clients.
Definition config.h:273
int fec_percentage
Percentage of forward-error-correction packets to add to the stream (0-100); 0 disables FEC.
Definition config.h:269
int packetsize
Maximum payload size for network packets.
Definition config.h:276
std::chrono::milliseconds ping_timeout
Timeout used when waiting for client ping responses.
Definition config.h:265
Command-line options parsed before configuration loading.
Definition config.h:390
char ** argv
Command-line argument vector.
Definition config.h:393
int argc
Number of command-line arguments.
Definition config.h:392
std::string name
Executable name from the command line.
Definition config.h:391
Top-level Sunshine configuration and credential state.
Definition config.h:375
std::string salt
Salt used when hashing the Web UI password.
Definition config.h:383
std::string address_family
Address family requested for listening sockets.
Definition config.h:399
std::string password
Password hash or secret for the local Web UI account.
Definition config.h:382
std::string config_file
Path to the active Sunshine configuration file.
Definition config.h:385
std::uint16_t port
TCP port used by Sunshine services.
Definition config.h:398
std::string credentials_file
Path to the stored pairing credentials file.
Definition config.h:379
std::string locale
Locale selected for Sunshine UI and log messages.
Definition config.h:376
std::vector< prep_cmd_t > prep_cmds
Preparation commands executed around application launch.
Definition config.h:405
std::string log_file
Path to the configured log file.
Definition config.h:402
std::string username
Username for the local Web UI account.
Definition config.h:381
int min_log_level
Minimum severity level written to the configured log sink.
Definition config.h:377
std::bitset< flag::FLAG_SIZE > flags
Runtime flags parsed from command-line options.
Definition config.h:378
bool notify_pre_releases
Notify users about pre-release updates.
Definition config.h:403
cmd_t cmd
Command line used to launch the application.
Definition config.h:396
std::string bind_address
Local address Sunshine should bind to.
Definition config.h:400
std::vector< std::string > csrf_allowed_origins
Additional origins allowed by CSRF validation.
Definition config.h:409
std::optional< int > amd_quality_h264
AMF H.264 quality preset; unset uses the encoder default.
std::optional< int > amd_quality_av1
AMF AV1 quality preset; unset uses the encoder default.
std::optional< int > amd_quality_hevc
AMF HEVC quality preset; unset uses the encoder default.
std::optional< int > amd_rc_av1
AMF AV1 rate-control mode; unset uses the encoder default.
std::optional< int > amd_max_au_size
Maximum AMF H.264/HEVC access unit size in bits; unset uses the encoder default.
int amd_coder
AMF entropy-coding mode.
std::optional< int > amd_rc_hevc
AMF HEVC rate-control mode; unset uses the encoder default.
std::optional< int > amd_usage_hevc
AMF HEVC usage profile; unset uses the encoder default.
std::optional< int > amd_vbaq
AMF variance-based adaptive-quantization setting; unset uses the encoder default.
std::optional< int > amd_usage_h264
AMF H.264 usage profile; unset uses the encoder default.
std::optional< int > amd_enforce_hrd
AMF HRD enforcement setting; unset uses the encoder default.
std::optional< int > amd_rc_h264
AMF H.264 rate-control mode; unset uses the encoder default.
std::optional< int > amd_usage_av1
AMF AV1 usage profile; unset uses the encoder default.
std::optional< int > amd_preanalysis
AMF pre-analysis setting; unset uses the encoder default.
int h264_coder
Legacy NVENC H.264 entropy-coding mode.
int vbv_percentage_increase
Legacy NVENC VBV buffer-size percentage increase.
int spatial_aq
FFmpeg NVENC spatial adaptive-quantization mode.
std::string preset
FFmpeg NVENC preset name shared by supported FFmpeg versions.
int multipass
Legacy NVENC multipass mode.
std::optional< int > qsv_preset
Intel Quick Sync preset; unset uses the encoder default.
bool qsv_slow_hevc
Whether to enable the slower Intel Quick Sync HEVC path.
std::optional< int > qsv_cavlc
Intel Quick Sync CAVLC selection; unset uses the encoder default.
std::optional< int > svtav1_preset
SVT-AV1 preset; unset uses the encoder default.
std::string sw_tune
FFmpeg software-encoder tuning profile.
std::string sw_preset
FFmpeg software-encoder preset.
std::optional< int > blbrc
VA-API block-level bitrate-control setting; unset uses the encoder default.
std::optional< int > vaapi_quality
VA-API quality setting; unset uses the encoder default.
std::optional< int > vaapi_rc
VA-API rate-control mode; unset uses the encoder default.
bool strict_rc_buffer
Whether VA-API must strictly enforce the rate-control buffer.
std::string vaapi_rc_str
Text representation of the selected VA-API rate-control mode.
int tune
Vulkan encoder tuning mode: default, HQ, LL, ULL, or lossless.
int quality
Vulkan encoder quality preset: 1 = speed, 2 = balanced (default), 3 = quality.
int rc_mode
Vulkan encoder rate-control mode: driver, CQP, CBR, or VBR.
int vt_coder
VideoToolbox entropy-coding mode.
int vt_allow_sw
Whether VideoToolbox may use software encoding.
int vt_realtime
Whether VideoToolbox uses realtime encoding mode.
int vt_require_sw
Whether VideoToolbox must use software encoding.
Single display mode remapping rule from configuration.
Definition config.h:201
std::string final_refresh_rate
Refresh-rate string to apply after remapping.
Definition config.h:205
std::string requested_fps
Refresh-rate string requested by the client.
Definition config.h:203
std::string final_resolution
Resolution string to apply after remapping.
Definition config.h:204
std::string requested_resolution
Resolution string requested by the client.
Definition config.h:202
Collection of display mode remapping rules.
Definition config.h:211
std::vector< mode_remapping_entry_t > refresh_rate_only
To be use when only refresh_rate_option is set to automatic.
Definition config.h:214
std::vector< mode_remapping_entry_t > mixed
To be used when resolution_option and refresh_rate_option is set to automatic.
Definition config.h:212
std::vector< mode_remapping_entry_t > resolution_only
To be use when only resolution_option is set to automatic.
Definition config.h:213
Compatibility workarounds for display-device control.
Definition config.h:157
std::chrono::milliseconds hdr_toggle_delay
Specify whether to apply HDR high-contrast color workaround and what delay to use.
Definition config.h:158
Display-device integration settings.
Definition config.h:153
refresh_rate_option_e refresh_rate_option
Refresh-rate selection mode selected by configuration.
Definition config.h:220
std::string manual_resolution
Manual resolution in case resolution_option == resolution_option_e::manual.
Definition config.h:219
refresh_rate_option_e
Selects how Sunshine chooses the stream display refresh rate.
Definition config.h:184
hdr_option_e
Selects how Sunshine handles HDR state for the stream display.
Definition config.h:193
bool config_revert_on_disconnect
Specify whether to revert display configuration on client disconnect.
Definition config.h:224
std::chrono::milliseconds config_revert_delay
Time to wait until settings are reverted (after stream ends/app exists).
Definition config.h:223
std::string manual_refresh_rate
Manual refresh rate in case refresh_rate_option == refresh_rate_option_e::manual.
Definition config.h:221
config_option_e
Selects how Sunshine prepares the active display before streaming.
Definition config.h:164
hdr_option_e hdr_option
HDR-selection mode selected by configuration.
Definition config.h:222
resolution_option_e
Selects how Sunshine chooses the stream display resolution.
Definition config.h:175
mode_remapping_t mode_remapping
Display mode remapping rules grouped by automatic selection mode.
Definition config.h:225
workarounds_t wa
Display-device compatibility workarounds.
Definition config.h:226
config_option_e configuration_option
Display-preparation mode selected by configuration.
Definition config.h:217
resolution_option_e resolution_option
Resolution-selection mode selected by configuration.
Definition config.h:218
Video encoder, capture, and color settings loaded from configuration.
Definition config.h:69
std::string encoder
Encoder backend name selected by configuration.
Definition config.h:146
bool nv_realtime_hags
Enable the NVIDIA realtime HAGS workaround.
Definition config.h:88
std::string capture
Capture backend name selected by configuration.
Definition config.h:144
int qp
Quantization parameter used by encoders where higher values trade quality for compression.
Definition config.h:74
int max_bitrate
Maximum bitrate ceiling in kbps for bitrate requested from the client.
Definition config.h:231
int min_threads
Minimum number of threads or slices for CPU encoding.
Definition config.h:79
std::string adapter_name
Display adapter name selected in configuration.
Definition config.h:147
std::string output_name
Display output name selected in configuration.
Definition config.h:148
struct config::video_t::@274203255166134055042140142125316060346267075326 nv_legacy
Legacy NVIDIA encoder options kept for config compatibility.
double minimum_fps_target
Lowest framerate that will be used when streaming. Range 0-1000, 0 = half of client's requested frame...
Definition config.h:232
bool nv_sunshine_high_power_mode
Request NVIDIA high-power mode for Sunshine.
Definition config.h:90
int av1_mode
AV1 support mode advertised to clients.
Definition config.h:77
nvenc::nvenc_config nv
NVIDIA NVENC encoder settings.
Definition config.h:87
int hevc_mode
HEVC support mode advertised to clients.
Definition config.h:76
dd_t dd
Display-device integration settings.
Definition config.h:229
bool nv_opengl_vulkan_on_dxgi
Prefer NVIDIA OpenGL/Vulkan-on-DXGI interop.
Definition config.h:89
bool fp16_sdr_gamma_encoded
Treat FP16 captures of SDR displays as already sRGB gamma-encoded (Windows).
Definition config.h:145
NVENC encoder configuration.
Definition nvenc_config.h:30