Sunshine master
Self-hosted game stream host for Moonlight.
config.cpp File Reference

Definitions for the configuration of Sunshine. More...

#include <algorithm>
#include <filesystem>
#include <format>
#include <fstream>
#include <functional>
#include <iostream>
#include <thread>
#include <unordered_map>
#include <utility>
#include <boost/asio.hpp>
#include <boost/filesystem.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include "config.h"
#include "entry_handler.h"
#include "file_handler.h"
#include "logging.h"
#include "nvhttp.h"
#include "platform/common.h"
#include "rtsp.h"
#include "utility.h"
#include <shellapi.h>
Include dependency graph for config.cpp:

Enumerations

enum  config::qsv::cavlc_e : int { config::qsv::_auto = false , config::qsv::enabled = true , config::qsv::disabled = false }
 Enumerates supported cavlc options. More...
 
enum  config::amd::coder_e : int { config::amd::_auto = AMF_VIDEO_ENCODER_UNDEFINED , config::amd::cabac = AMF_VIDEO_ENCODER_CABAC , config::amd::cavlc = AMF_VIDEO_ENCODER_CALV }
 Enumerates supported coder options. More...
 
enum  config::vt::coder_e : int { config::vt::_auto = 0 , config::vt::cabac , config::vt::cavlc }
 Enumerates supported coder options. More...
 
enum  config::qsv::preset_e : int {
  config::qsv::veryslow = 1 , config::qsv::slower = 2 , config::qsv::slow = 3 , config::qsv::medium = 4 ,
  config::qsv::fast = 5 , config::qsv::faster = 6 , config::qsv::veryfast = 7
}
 Enumerates supported preset options. More...
 
enum class  config::amd::quality_av1_e : int { speed = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED , quality = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_QUALITY , balanced = AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_BALANCED }
 Enumerates supported quality AV1 options. More...
 
enum class  config::amd::quality_h264_e : int { speed = AMF_VIDEO_ENCODER_QUALITY_PRESET_SPEED , quality = AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY , balanced = AMF_VIDEO_ENCODER_QUALITY_PRESET_BALANCED }
 Enumerates supported quality h264 options. More...
 
enum class  config::amd::quality_hevc_e : int { speed = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED , quality = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY , balanced = AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED }
 Enumerates supported quality HEVC options. More...
 
enum class  config::amd::rc_av1_e : int { cbr = AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_CBR , cqp = AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_CONSTANT_QP , vbr_latency = AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR , vbr_peak = AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }
 Enumerates supported rc AV1 options. More...
 
enum class  config::amd::rc_h264_e : int { cbr = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR , cqp = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP , vbr_latency = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR , vbr_peak = AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }
 Enumerates supported rc h264 options. More...
 
enum class  config::amd::rc_hevc_e : int { cbr = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR , cqp = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP , vbr_latency = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR , vbr_peak = AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR }
 Enumerates supported rc HEVC options. More...
 
enum class  config::amd::usage_av1_e : int {
  transcoding = AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING , webcam = AMF_VIDEO_ENCODER_AV1_USAGE_WEBCAM , lowlatency_high_quality = AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY_HIGH_QUALITY , lowlatency = AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY ,
  ultralowlatency = AMF_VIDEO_ENCODER_AV1_USAGE_ULTRA_LOW_LATENCY
}
 Enumerates supported usage AV1 options. More...
 
enum class  config::amd::usage_h264_e : int {
  transcoding = AMF_VIDEO_ENCODER_USAGE_TRANSCODING , webcam = AMF_VIDEO_ENCODER_USAGE_WEBCAM , lowlatency_high_quality = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY_HIGH_QUALITY , lowlatency = AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY ,
  ultralowlatency = AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY
}
 Enumerates supported usage h264 options. More...
 
enum class  config::amd::usage_hevc_e : int {
  transcoding = AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING , webcam = AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM , lowlatency_high_quality = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY , lowlatency = AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY ,
  ultralowlatency = AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY
}
 Enumerates supported usage HEVC options. More...
 

Functions

int config::vt::allow_software_from_view (const std::string_view &software)
 Parse whether VideoToolbox software encoding is allowed.
 
void config::apply_config (std::unordered_map< std::string, std::string > &&vars)
 Apply parsed configuration entries to the global runtime configuration.
 
int config::apply_flags (const char *line)
 Apply single-character command-line flags to the global Sunshine flags bitset.
 
void config::bool_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, bool &input)
 Consume a boolean setting from the parsed configuration map.
 
int config::amd::coder_from_view (const ::std::string_view &coder)
 Parse an entropy-coder mode from configuration text.
 
std::optional< int > config::qsv::coder_from_view (const std::string_view &coder)
 Parse an entropy-coder mode from configuration text.
 
int config::vt::coder_from_view (const std::string_view &coder)
 Parse an entropy-coder mode from configuration text.
 
video_t::dd_t::config_option_e config::dd::config_option_from_view (const std::string_view value)
 Parse display-device preparation mode from configuration text.
 
void config::double_between_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, double &input, const std::pair< double, double > &range)
 Consume a floating-point setting only when it falls inside an inclusive range.
 
void config::double_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, double &input)
 Consume a floating-point setting from the parsed configuration map.
 
bool config::endline (char ch)
 Return whether a character terminates a configuration line.
 
int config::vt::force_software_from_view (const std::string_view &software)
 Parse whether VideoToolbox software encoding is forced.
 
template<typename T , typename F >
void config::generic_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, T &input, F &&f)
 Consume a setting and convert it with a caller-provided parser.
 
std::vector< std::string_view > & config::get_supported_gamepad_options ()
 Get supported gamepad options.
 
video_t::dd_t::hdr_option_e config::dd::hdr_option_from_view (const std::string_view value)
 Parse display-device HDR mode from configuration text.
 
void config::int_between_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, int &input, const std::pair< int, int > &range)
 Consume an integer setting only when it falls inside an inclusive range.
 
void config::int_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, int &input)
 Consume an integer setting from decimal or hexadecimal configuration text.
 
template<class F >
void config::int_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, int &input, F &&f)
 Consume an integer setting from decimal or hexadecimal configuration text.
 
void config::int_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::optional< int > &input)
 Consume an integer setting from decimal or hexadecimal configuration text.
 
template<class F >
void config::int_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::optional< int > &input, F &&f)
 Consume an integer setting from decimal or hexadecimal configuration text.
 
void config::list_int_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::vector< int > &input)
 Consume an integer list setting from decimal or hexadecimal configuration text.
 
void config::list_prep_cmd_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::vector< prep_cmd_t > &input)
 Consume the JSON preparation-command list setting.
 
void config::list_string_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::vector< std::string > &input)
 Consume a comma-separated or bracketed string list setting.
 
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.
 
void config::map_int_int_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::unordered_map< int, int > &input)
 Consume an integer-pair list into a mapping table.
 
video_t::dd_t::mode_remapping_t config::dd::mode_remapping_from_view (const std::string_view value)
 Parse display-mode remapping rules from JSON configuration text.
 
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.
 
std::pair< std::string_view::const_iterator, std::optional< std::pair< std::string, std::string > > > config::parse_option (std::string_view::const_iterator begin, std::string_view::const_iterator end)
 Parse one name = value configuration entry.
 
void config::path_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, fs::path &input)
 Consume a path setting and normalize it under the app data directory when relative.
 
void config::path_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::string &input)
 Consume a path setting and normalize it under the app data directory when relative.
 
std::optional< int > config::qsv::preset_from_view (const std::string_view &preset)
 Parse a QSV encoder preset from configuration text.
 
template<class T >
::std::optional< int > config::amd::quality_from_view (const ::std::string_view &quality_type, const ::std::optional< int >(&original))
 Parse an AMD quality preset while preserving the current value on invalid input.
 
template<class T >
::std::optional< int > config::amd::rc_from_view (const ::std::string_view &rc, const ::std::optional< int >(&original))
 Parse an AMD rate-control mode while preserving the current value on invalid input.
 
video_t::dd_t::refresh_rate_option_e config::dd::refresh_rate_option_from_view (const std::string_view value)
 Parse display-device refresh-rate mode from configuration text.
 
video_t::dd_t::resolution_option_e config::dd::resolution_option_from_view (const std::string_view value)
 Parse display-device resolution mode from configuration text.
 
int config::vt::rt_from_view (const std::string_view &rt)
 Parse the VideoToolbox realtime encoder flag.
 
template<class It >
It config::skip_list (It skipper, It end)
 Advance over a bracketed list while honoring nested brackets.
 
bool config::space_tab (char ch)
 Return whether a character is horizontal parser whitespace.
 
nvenc::nvenc_split_frame_encoding config::nv::split_encode_from_view (const std::string_view &preset)
 Parse the nvenc_split_encode configuration value.
 
void config::string_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::string &input)
 Consume a string setting from the parsed configuration map.
 
void config::string_list_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::vector< std::string > &output)
 Parse a comma-separated string setting into a list.
 
void config::string_restricted_f (std::unordered_map< std::string, std::string > &vars, const std::string &name, std::string &input, const std::vector< std::string_view > &allowed_vals)
 Consume a string setting only when it matches an allowed value.
 
int config::sw::svtav1_preset_from_view (const std::string_view &preset)
 Parse an SVT-AV1 speed preset from configuration text.
 
bool config::to_bool (std::string &boolean)
 Convert common textual boolean forms to a boolean value.
 
std::string config::to_string (const char *begin, const char *end)
 Copy a configuration text range while stripping inline comments.
 
nvenc::nvenc_two_pass config::nv::twopass_from_view (const std::string_view &preset)
 Parse the nvenc_twopass configuration value.
 
template<class T >
::std::optional< int > config::amd::usage_from_view (const ::std::string_view &usage, const ::std::optional< int >(&original))
 Parse an AMD encoder usage mode while preserving the current value on invalid input.
 
bool config::whitespace (char ch)
 Return whether a character should be treated as parser whitespace.
 

Variables

constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_BALANCED = 70
 Fallback AMF enum value for av1 quality preset balanced.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_QUALITY = 30
 Fallback AMF enum value for av1 quality preset quality.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_QUALITY_PRESET_SPEED = 100
 Fallback AMF enum value for av1 quality preset speed.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_CBR = 3
 Fallback AMF enum value for av1 rate control method cbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_CONSTANT_QP = 0
 Fallback AMF enum value for av1 rate control method constant qp.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR = 1
 Fallback AMF enum value for av1 rate control method latency constrained vbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR = 2
 Fallback AMF enum value for av1 rate control method peak constrained vbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY = 1
 Fallback AMF enum value for av1 usage low latency.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_USAGE_LOW_LATENCY_HIGH_QUALITY = 5
 Fallback AMF enum value for av1 usage low latency high quality.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_USAGE_TRANSCODING = 0
 Fallback AMF enum value for av1 usage transcoding.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_USAGE_ULTRA_LOW_LATENCY = 2
 Fallback AMF enum value for av1 usage ultra low latency.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_AV1_USAGE_WEBCAM = 3
 Fallback AMF enum value for av1 usage webcam.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_CABAC = 1
 Fallback AMF enum value for cabac.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_CALV = 2
 Fallback AMF enum value for calv.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_BALANCED = 5
 Fallback AMF enum value for hevc quality preset balanced.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_QUALITY = 0
 Fallback AMF enum value for hevc quality preset quality.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_QUALITY_PRESET_SPEED = 10
 Fallback AMF enum value for hevc quality preset speed.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CBR = 3
 Fallback AMF enum value for hevc rate control method cbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_CONSTANT_QP = 0
 Fallback AMF enum value for hevc rate control method constant qp.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR = 1
 Fallback AMF enum value for hevc rate control method latency constrained vbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR = 2
 Fallback AMF enum value for hevc rate control method peak constrained vbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY = 2
 Fallback AMF enum value for hevc usage low latency.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_USAGE_LOW_LATENCY_HIGH_QUALITY = 5
 Fallback AMF enum value for hevc usage low latency high quality.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_USAGE_TRANSCODING = 0
 Fallback AMF enum value for hevc usage transcoding.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_USAGE_ULTRA_LOW_LATENCY = 1
 Fallback AMF enum value for hevc usage ultra low latency.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_HEVC_USAGE_WEBCAM = 3
 Fallback AMF enum value for hevc usage webcam.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_QUALITY_PRESET_BALANCED = 0
 Fallback AMF enum value for quality preset balanced.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_QUALITY_PRESET_QUALITY = 2
 Fallback AMF enum value for quality preset quality.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_QUALITY_PRESET_SPEED = 1
 Fallback AMF enum value for quality preset speed.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CBR = 1
 Fallback AMF enum value for rate control method cbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_CONSTANT_QP = 0
 Fallback AMF enum value for rate control method constant qp.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_LATENCY_CONSTRAINED_VBR = 3
 Fallback AMF enum value for rate control method latency constrained vbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_RATE_CONTROL_METHOD_PEAK_CONSTRAINED_VBR = 2
 Fallback AMF enum value for rate control method peak constrained vbr.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_UNDEFINED = 0
 Fallback AMF enum value for undefined.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY = 2
 Fallback AMF enum value for usage low latency.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_USAGE_LOW_LATENCY_HIGH_QUALITY = 5
 Fallback AMF enum value for usage low latency high quality.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_USAGE_TRANSCODING = 0
 Fallback AMF enum value for usage transcoding.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_USAGE_ULTRA_LOW_LATENCY = 1
 Fallback AMF enum value for usage ultra low latency.
 
constexpr int config::amd::AMF_VIDEO_ENCODER_USAGE_WEBCAM = 3
 Fallback AMF enum value for usage webcam.
 
const std::string APPS_JSON_PATH = platf::appdata().string() + "/apps.json"
 Default path to the applications JSON file.
 
audio_t config::audio
 Default audio configuration values used before file and CLI overrides.
 
constexpr auto CA_DIR = "credentials"
 Subdirectory under app data that stores Sunshine credentials.
 
const std::string CERTIFICATE_FILE = std::string(CA_DIR) + "/cacert.pem"
 Relative path to the persisted certificate PEM file.
 
input_t config::input
 Default input configuration values used before file and CLI overrides.
 
nvhttp_t config::nvhttp
 Default NVHTTP server configuration values used before file and CLI overrides.
 
const std::string PRIVATE_KEY_FILE = std::string(CA_DIR) + "/cakey.pem"
 Relative path to the persisted private key PEM file.
 
stream_t config::stream
 Default stream configuration values used before file and CLI overrides.
 
sunshine_t config::sunshine
 Default top-level Sunshine configuration values used before file and CLI overrides.
 
video_t config::video
 Default video configuration values used before file and CLI overrides.
 

Detailed Description

Definitions for the configuration of Sunshine.

Enumeration Type Documentation

◆ cavlc_e

Enumerates supported cavlc options.

Enumerator
_auto 

Auto.

enabled 

Enabled.

disabled 

Disabled.

◆ coder_e [1/2]

Enumerates supported coder options.

Enumerator
_auto 

Auto.

cabac 

CABAC.

cavlc 

CAVLC.

◆ coder_e [2/2]

enum config::vt::coder_e : int

Enumerates supported coder options.

Enumerator
_auto 

Auto.

cabac 

CABAC.

cavlc 

CAVLC.

◆ preset_e

Enumerates supported preset options.

Enumerator
veryslow 

veryslow preset

slower 

slower preset

slow 

slow preset

medium 

medium preset

fast 

fast preset

faster 

faster preset

veryfast 

veryfast preset

◆ quality_av1_e

enum class config::amd::quality_av1_e : int
strong

Enumerates supported quality AV1 options.

Enumerator
speed 

Speed preset.

quality 

Quality preset.

balanced 

Balanced preset.

◆ quality_h264_e

enum class config::amd::quality_h264_e : int
strong

Enumerates supported quality h264 options.

Enumerator
speed 

Speed preset.

quality 

Quality preset.

balanced 

Balanced preset.

◆ quality_hevc_e

enum class config::amd::quality_hevc_e : int
strong

Enumerates supported quality HEVC options.

Enumerator
speed 

Speed preset.

quality 

Quality preset.

balanced 

Balanced preset.

◆ rc_av1_e

enum class config::amd::rc_av1_e : int
strong

Enumerates supported rc AV1 options.

Enumerator
cbr 

CBR.

cqp 

CQP.

vbr_latency 

VBR with latency constraints.

vbr_peak 

VBR with peak constraints.

◆ rc_h264_e

enum class config::amd::rc_h264_e : int
strong

Enumerates supported rc h264 options.

Enumerator
cbr 

CBR.

cqp 

CQP.

vbr_latency 

VBR with latency constraints.

vbr_peak 

VBR with peak constraints.

◆ rc_hevc_e

enum class config::amd::rc_hevc_e : int
strong

Enumerates supported rc HEVC options.

Enumerator
cbr 

CBR.

cqp 

CQP.

vbr_latency 

VBR with latency constraints.

vbr_peak 

VBR with peak constraints.

◆ usage_av1_e

enum class config::amd::usage_av1_e : int
strong

Enumerates supported usage AV1 options.

Enumerator
transcoding 

Transcoding preset.

webcam 

Webcam preset.

lowlatency_high_quality 

Low latency high quality preset.

lowlatency 

Low latency preset.

ultralowlatency 

Ultra low latency preset.

◆ usage_h264_e

enum class config::amd::usage_h264_e : int
strong

Enumerates supported usage h264 options.

Enumerator
transcoding 

Transcoding preset.

webcam 

Webcam preset.

lowlatency_high_quality 

Low latency high quality preset.

lowlatency 

Low latency preset.

ultralowlatency 

Ultra low latency preset.

◆ usage_hevc_e

enum class config::amd::usage_hevc_e : int
strong

Enumerates supported usage HEVC options.

Enumerator
transcoding 

Transcoding preset.

webcam 

Webcam preset.

lowlatency_high_quality 

Low latency high quality preset.

lowlatency 

Low latency preset.

ultralowlatency 

Ultra low latency preset.

Function Documentation

◆ allow_software_from_view()

int config::vt::allow_software_from_view ( const std::string_view & software)

Parse whether VideoToolbox software encoding is allowed.

Parameters
softwareWhether the software encoder path is being configured.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ apply_config()

void config::apply_config ( std::unordered_map< std::string, std::string > && vars)

Apply parsed configuration entries to the global runtime configuration.

Parameters
varsParsed configuration entries; consumed keys are erased.

◆ apply_flags()

int config::apply_flags ( const char * line)

Apply single-character command-line flags to the global Sunshine flags bitset.

Parameters
lineConfiguration line being parsed.
Returns
0 when all flags are recognized; -1 when at least one flag is unknown.

◆ bool_f()

void config::bool_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
bool & input )

Consume a boolean setting from the parsed configuration map.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ coder_from_view() [1/3]

int config::amd::coder_from_view ( const ::std::string_view & coder)

Parse an entropy-coder mode from configuration text.

Parameters
coderEntropy-coder mode selected in the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ coder_from_view() [2/3]

std::optional< int > config::qsv::coder_from_view ( const std::string_view & coder)

Parse an entropy-coder mode from configuration text.

Parameters
coderEntropy-coder mode selected in the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ coder_from_view() [3/3]

int config::vt::coder_from_view ( const std::string_view & coder)

Parse an entropy-coder mode from configuration text.

Parameters
coderEntropy-coder mode selected in the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ config_option_from_view()

video_t::dd_t::config_option_e config::dd::config_option_from_view ( const std::string_view value)

Parse display-device preparation mode from configuration text.

Parameters
valueConfiguration text from the display-device preparation setting.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ double_between_f()

void config::double_between_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
double & input,
const std::pair< double, double > & range )

Consume a floating-point setting only when it falls inside an inclusive range.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.
rangeInclusive range accepted for the parsed value.

◆ double_f()

void config::double_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
double & input )

Consume a floating-point setting from the parsed configuration map.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ endline()

bool config::endline ( char ch)

Return whether a character terminates a configuration line.

Parameters
chCharacter currently being classified by the parser.
Returns
True when the tested parser condition is met.

◆ force_software_from_view()

int config::vt::force_software_from_view ( const std::string_view & software)

Parse whether VideoToolbox software encoding is forced.

Parameters
softwareWhether the software encoder path is being configured.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ generic_f()

template<typename T , typename F >
void config::generic_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
T & input,
F && f )

Consume a setting and convert it with a caller-provided parser.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.
fConverter applied to the raw configuration string.

◆ get_supported_gamepad_options()

std::vector< std::string_view > & config::get_supported_gamepad_options ( )

Get supported gamepad options.

Returns
Platform-supported gamepad backend names accepted by configuration.

◆ hdr_option_from_view()

video_t::dd_t::hdr_option_e config::dd::hdr_option_from_view ( const std::string_view value)

Parse display-device HDR mode from configuration text.

Parameters
valueConfiguration text from the display-device HDR setting.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ int_between_f()

void config::int_between_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
int & input,
const std::pair< int, int > & range )

Consume an integer setting only when it falls inside an inclusive range.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.
rangeInclusive range accepted for the parsed value.

◆ int_f() [1/4]

void config::int_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
int & input )

Consume an integer setting from decimal or hexadecimal configuration text.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ int_f() [2/4]

template<class F >
void config::int_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
int & input,
F && f )

Consume an integer setting from decimal or hexadecimal configuration text.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.
fConverter applied to the raw configuration string.

◆ int_f() [3/4]

void config::int_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::optional< int > & input )

Consume an integer setting from decimal or hexadecimal configuration text.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ int_f() [4/4]

template<class F >
void config::int_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::optional< int > & input,
F && f )

Consume an integer setting from decimal or hexadecimal configuration text.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.
fConverter applied to the raw configuration string.

◆ list_int_f()

void config::list_int_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::vector< int > & input )

Consume an integer list setting from decimal or hexadecimal configuration text.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ list_prep_cmd_f()

void config::list_prep_cmd_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::vector< prep_cmd_t > & input )

Consume the JSON preparation-command list setting.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ list_string_f()

void config::list_string_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::vector< std::string > & input )

Consume a comma-separated or bracketed string list setting.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ 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.

◆ map_int_int_f()

void config::map_int_int_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::unordered_map< int, int > & input )

Consume an integer-pair list into a mapping table.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ mode_remapping_from_view()

video_t::dd_t::mode_remapping_t config::dd::mode_remapping_from_view ( const std::string_view value)

Parse display-mode remapping rules from JSON configuration text.

Parameters
valueJSON array text from the display-device mode-remapping setting.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ 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.

◆ parse_option()

std::pair< std::string_view::const_iterator, std::optional< std::pair< std::string, std::string > > > config::parse_option ( std::string_view::const_iterator begin,
std::string_view::const_iterator end )

Parse one name = value configuration entry.

Parameters
beginIterator or pointer marking the start of the input range.
endIterator or pointer marking the end of the input range.
Returns
Iterator for the next line and the parsed key-value pair when one was found.

◆ path_f() [1/2]

void config::path_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
fs::path & input )

Consume a path setting and normalize it under the app data directory when relative.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ path_f() [2/2]

void config::path_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::string & input )

Consume a path setting and normalize it under the app data directory when relative.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ preset_from_view()

std::optional< int > config::qsv::preset_from_view ( const std::string_view & preset)

Parse a QSV encoder preset from configuration text.

Parameters
presetEncoder preset value supplied by the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ quality_from_view()

template<class T >
::std::optional< int > config::amd::quality_from_view ( const ::std::string_view & quality_type,
const ::std::optional< int > & original )

Parse an AMD quality preset while preserving the current value on invalid input.

Parameters
quality_typeConfiguration text naming the AMD quality preset.
originalOriginal text value used when reporting a parsing failure.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ rc_from_view()

template<class T >
::std::optional< int > config::amd::rc_from_view ( const ::std::string_view & rc,
const ::std::optional< int > & original )

Parse an AMD rate-control mode while preserving the current value on invalid input.

Parameters
rcRate-control mode selected in the configuration.
originalOriginal text value used when reporting a parsing failure.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ refresh_rate_option_from_view()

video_t::dd_t::refresh_rate_option_e config::dd::refresh_rate_option_from_view ( const std::string_view value)

Parse display-device refresh-rate mode from configuration text.

Parameters
valueConfiguration text from the display-device refresh-rate setting.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ resolution_option_from_view()

video_t::dd_t::resolution_option_e config::dd::resolution_option_from_view ( const std::string_view value)

Parse display-device resolution mode from configuration text.

Parameters
valueConfiguration text from the display-device resolution setting.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ rt_from_view()

int config::vt::rt_from_view ( const std::string_view & rt)

Parse the VideoToolbox realtime encoder flag.

Parameters
rtReal-time encoder usage selector.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ skip_list()

template<class It >
It config::skip_list ( It skipper,
It end )

Advance over a bracketed list while honoring nested brackets.

Parameters
skipperFunction used to skip characters while parsing.
endIterator or pointer marking the end of the input range.
Returns
Iterator positioned after the matching closing bracket or at the end.

◆ space_tab()

bool config::space_tab ( char ch)

Return whether a character is horizontal parser whitespace.

Parameters
chCharacter currently being classified by the parser.
Returns
True when the tested parser condition is met.

◆ split_encode_from_view()

nvenc::nvenc_split_frame_encoding config::nv::split_encode_from_view ( const std::string_view & preset)

Parse the nvenc_split_encode configuration value.

Parameters
presetEncoder preset value supplied by the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ string_f()

void config::string_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::string & input )

Consume a string setting from the parsed configuration map.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.

◆ string_list_f()

void config::string_list_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::vector< std::string > & output )

Parse a comma-separated string setting into a list.

Parameters
varsConfiguration key-value map.
nameSetting name.
outputParsed string list.

◆ string_restricted_f()

void config::string_restricted_f ( std::unordered_map< std::string, std::string > & vars,
const std::string & name,
std::string & input,
const std::vector< std::string_view > & allowed_vals )

Consume a string setting only when it matches an allowed value.

Parameters
varsParsed configuration entries; consumed keys are erased.
nameConfiguration key to consume.
inputDestination field updated when the setting exists and parses successfully.
allowed_valsAccepted string values for this setting.

◆ svtav1_preset_from_view()

int config::sw::svtav1_preset_from_view ( const std::string_view & preset)

Parse an SVT-AV1 speed preset from configuration text.

Parameters
presetEncoder preset value supplied by the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ to_bool()

bool config::to_bool ( std::string & boolean)

Convert common textual boolean forms to a boolean value.

Parameters
booleanConfiguration string to classify as enabled or disabled.
Returns
True when the tested parser condition is met.

◆ to_string()

std::string config::to_string ( const char * begin,
const char * end )

Copy a configuration text range while stripping inline comments.

Parameters
beginIterator or pointer marking the start of the input range.
endIterator or pointer marking the end of the input range.
Returns
Value converted to string.

◆ twopass_from_view()

nvenc::nvenc_two_pass config::nv::twopass_from_view ( const std::string_view & preset)

Parse the nvenc_twopass configuration value.

Parameters
presetEncoder preset value supplied by the configuration.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ usage_from_view()

template<class T >
::std::optional< int > config::amd::usage_from_view ( const ::std::string_view & usage,
const ::std::optional< int > & original )

Parse an AMD encoder usage mode while preserving the current value on invalid input.

Parameters
usageEncoder usage mode selected in the configuration.
originalOriginal text value used when reporting a parsing failure.
Returns
Parsed enum value, or the setting-specific default when the text is unknown.

◆ whitespace()

bool config::whitespace ( char ch)

Return whether a character should be treated as parser whitespace.

Parameters
chCharacter currently being classified by the parser.
Returns
True when the tested parser condition is met.

Variable Documentation

◆ audio

audio_t config::audio
Initial value:
{
{},
{},
true,
true,
}

Default audio configuration values used before file and CLI overrides.

◆ input

input_t config::input
Initial value:
{
{
{0x10, 0xA0},
{0x11, 0xA2},
{0x12, 0xA4},
},
-1ms,
500ms,
std::chrono::duration<double> {1 / 24.9},
{
platf::supported_gamepads(nullptr).front().name.data(),
platf::supported_gamepads(nullptr).front().name.size(),
},
true,
true,
true,
true,
true,
true,
true,
true,
true,
true,
}
std::vector< supported_gamepad_t > & supported_gamepads(input_t *input)
Gets the supported gamepads for this platform backend.
Definition inputtino.cpp:160

Default input configuration values used before file and CLI overrides.

◆ nvhttp

nvhttp_t config::nvhttp
Initial value:
{
"lan",
platf::get_host_name(),
"sunshine_state.json"s,
{},
}
const std::string PRIVATE_KEY_FILE
Relative path to the persisted private key PEM file.
Definition config.cpp:45
const std::string CERTIFICATE_FILE
Relative path to the persisted certificate PEM file.
Definition config.cpp:46

Default NVHTTP server configuration values used before file and CLI overrides.

◆ stream

stream_t config::stream
Initial value:
{
10s,
20,
0,
}
const std::string APPS_JSON_PATH
Default path to the applications JSON file.
Definition config.cpp:47
constexpr int ENCRYPTION_MODE_OPPORTUNISTIC
Encryption policy that uses encrypted video only when the client supports it.
Definition config.h:221
constexpr int ENCRYPTION_MODE_NEVER
Encryption policy that always sends unencrypted video.
Definition config.h:217

Default stream configuration values used before file and CLI overrides.

◆ sunshine

sunshine_t config::sunshine
Initial value:
{
"en",
2,
0,
{},
{},
{},
{},
platf::appdata().string() + "/sunshine.conf",
{},
47989,
"ipv4",
{},
platf::appdata().string() + "/sunshine.log",
false,
true,
{},
}
std::filesystem::path appdata()
Performs migration if necessary, then returns the appdata directory.
Definition misc.cpp:251

Default top-level Sunshine configuration values used before file and CLI overrides.