Merge remote-tracking branch 'origin/master'
This commit is contained in:
125
src/config.cpp
125
src/config.cpp
@@ -330,6 +330,91 @@ namespace config {
|
||||
}
|
||||
} // namespace sw
|
||||
|
||||
namespace dd {
|
||||
video_t::dd_t::config_option_e
|
||||
config_option_from_view(const std::string_view value) {
|
||||
#define _CONVERT_(x) \
|
||||
if (value == #x##sv) return video_t::dd_t::config_option_e::x
|
||||
_CONVERT_(disabled);
|
||||
_CONVERT_(verify_only);
|
||||
_CONVERT_(ensure_active);
|
||||
_CONVERT_(ensure_primary);
|
||||
_CONVERT_(ensure_only_display);
|
||||
#undef _CONVERT_
|
||||
return video_t::dd_t::config_option_e::disabled; // Default to this if value is invalid
|
||||
}
|
||||
|
||||
video_t::dd_t::resolution_option_e
|
||||
resolution_option_from_view(const std::string_view value) {
|
||||
#define _CONVERT_2_ARG_(str, val) \
|
||||
if (value == #str##sv) return video_t::dd_t::resolution_option_e::val
|
||||
#define _CONVERT_(x) _CONVERT_2_ARG_(x, x)
|
||||
_CONVERT_(disabled);
|
||||
_CONVERT_2_ARG_(auto, automatic);
|
||||
_CONVERT_(manual);
|
||||
#undef _CONVERT_
|
||||
#undef _CONVERT_2_ARG_
|
||||
return video_t::dd_t::resolution_option_e::disabled; // Default to this if value is invalid
|
||||
}
|
||||
|
||||
video_t::dd_t::refresh_rate_option_e
|
||||
refresh_rate_option_from_view(const std::string_view value) {
|
||||
#define _CONVERT_2_ARG_(str, val) \
|
||||
if (value == #str##sv) return video_t::dd_t::refresh_rate_option_e::val
|
||||
#define _CONVERT_(x) _CONVERT_2_ARG_(x, x)
|
||||
_CONVERT_(disabled);
|
||||
_CONVERT_2_ARG_(auto, automatic);
|
||||
_CONVERT_(manual);
|
||||
#undef _CONVERT_
|
||||
#undef _CONVERT_2_ARG_
|
||||
return video_t::dd_t::refresh_rate_option_e::disabled; // Default to this if value is invalid
|
||||
}
|
||||
|
||||
video_t::dd_t::hdr_option_e
|
||||
hdr_option_from_view(const std::string_view value) {
|
||||
#define _CONVERT_2_ARG_(str, val) \
|
||||
if (value == #str##sv) return video_t::dd_t::hdr_option_e::val
|
||||
#define _CONVERT_(x) _CONVERT_2_ARG_(x, x)
|
||||
_CONVERT_(disabled);
|
||||
_CONVERT_2_ARG_(auto, automatic);
|
||||
#undef _CONVERT_
|
||||
#undef _CONVERT_2_ARG_
|
||||
return video_t::dd_t::hdr_option_e::disabled; // Default to this if value is invalid
|
||||
}
|
||||
|
||||
video_t::dd_t::mode_remapping_t
|
||||
mode_remapping_from_view(const std::string_view value) {
|
||||
const auto parse_entry_list { [](const auto &entry_list, auto &output_field) {
|
||||
for (auto &[_, entry] : entry_list) {
|
||||
auto requested_resolution = entry.template get_optional<std::string>("requested_resolution"s);
|
||||
auto requested_fps = entry.template get_optional<std::string>("requested_fps"s);
|
||||
auto final_resolution = entry.template get_optional<std::string>("final_resolution"s);
|
||||
auto final_refresh_rate = entry.template get_optional<std::string>("final_refresh_rate"s);
|
||||
|
||||
output_field.push_back(video_t::dd_t::mode_remapping_entry_t {
|
||||
requested_resolution.value_or(""),
|
||||
requested_fps.value_or(""),
|
||||
final_resolution.value_or(""),
|
||||
final_refresh_rate.value_or("") });
|
||||
}
|
||||
} };
|
||||
|
||||
// We need to add a wrapping object to make it valid JSON, otherwise ptree cannot parse it.
|
||||
std::stringstream json_stream;
|
||||
json_stream << "{\"dd_mode_remapping\":" << value << "}";
|
||||
|
||||
boost::property_tree::ptree json_tree;
|
||||
boost::property_tree::read_json(json_stream, json_tree);
|
||||
|
||||
video_t::dd_t::mode_remapping_t output;
|
||||
parse_entry_list(json_tree.get_child("dd_mode_remapping.mixed"), output.mixed);
|
||||
parse_entry_list(json_tree.get_child("dd_mode_remapping.resolution_only"), output.resolution_only);
|
||||
parse_entry_list(json_tree.get_child("dd_mode_remapping.refresh_rate_only"), output.refresh_rate_only);
|
||||
|
||||
return output;
|
||||
}
|
||||
} // namespace dd
|
||||
|
||||
video_t video {
|
||||
false, // headless_mode
|
||||
false, // follow_client_hdr
|
||||
@@ -339,7 +424,6 @@ namespace config {
|
||||
0, // hevc_mode
|
||||
0, // av1_mode
|
||||
|
||||
1, // min_fps_factor
|
||||
2, // min_threads
|
||||
{
|
||||
"superfast"s, // preset
|
||||
@@ -391,6 +475,19 @@ namespace config {
|
||||
{}, // adapter_name
|
||||
{}, // output_name
|
||||
|
||||
{
|
||||
video_t::dd_t::config_option_e::verify_only, // configuration_option
|
||||
video_t::dd_t::resolution_option_e::automatic, // resolution_option
|
||||
{}, // manual_resolution
|
||||
video_t::dd_t::refresh_rate_option_e::automatic, // refresh_rate_option
|
||||
{}, // manual_refresh_rate
|
||||
video_t::dd_t::hdr_option_e::automatic, // hdr_option
|
||||
3s, // config_revert_delay
|
||||
{}, // mode_remapping
|
||||
{} // wa
|
||||
}, // display_device
|
||||
|
||||
1 // min_fps_factor
|
||||
"1920x1080x60", // fallback_mode
|
||||
};
|
||||
|
||||
@@ -998,9 +1095,9 @@ namespace config {
|
||||
bool_f(vars, "follow_client_hdr", video.follow_client_hdr);
|
||||
bool_f(vars, "set_vdisplay_primary", video.set_vdisplay_primary);
|
||||
int_f(vars, "qp", video.qp);
|
||||
int_f(vars, "min_threads", video.min_threads);
|
||||
int_between_f(vars, "hevc_mode", video.hevc_mode, { 0, 3 });
|
||||
int_between_f(vars, "av1_mode", video.av1_mode, { 0, 3 });
|
||||
int_f(vars, "min_threads", video.min_threads);
|
||||
string_f(vars, "sw_preset", video.sw.sw_preset);
|
||||
if (!video.sw.sw_preset.empty()) {
|
||||
video.sw.svtav1_preset = sw::svtav1_preset_from_view(video.sw.sw_preset);
|
||||
@@ -1071,8 +1168,25 @@ namespace config {
|
||||
string_f(vars, "encoder", video.encoder);
|
||||
string_f(vars, "adapter_name", video.adapter_name);
|
||||
string_f(vars, "output_name", video.output_name);
|
||||
string_f(vars, "fallback_mode", video.fallback_mode);
|
||||
|
||||
generic_f(vars, "dd_configuration_option", video.dd.configuration_option, dd::config_option_from_view);
|
||||
generic_f(vars, "dd_resolution_option", video.dd.resolution_option, dd::resolution_option_from_view);
|
||||
string_f(vars, "dd_manual_resolution", video.dd.manual_resolution);
|
||||
generic_f(vars, "dd_refresh_rate_option", video.dd.refresh_rate_option, dd::refresh_rate_option_from_view);
|
||||
string_f(vars, "dd_manual_refresh_rate", video.dd.manual_refresh_rate);
|
||||
generic_f(vars, "dd_hdr_option", video.dd.hdr_option, dd::hdr_option_from_view);
|
||||
{
|
||||
int value = -1;
|
||||
int_between_f(vars, "dd_config_revert_delay", value, { 0, std::numeric_limits<int>::max() });
|
||||
if (value >= 0) {
|
||||
video.dd.config_revert_delay = std::chrono::milliseconds { value };
|
||||
}
|
||||
}
|
||||
generic_f(vars, "dd_mode_remapping", video.dd.mode_remapping, dd::mode_remapping_from_view);
|
||||
bool_f(vars, "dd_wa_hdr_toggle", video.dd.wa.hdr_toggle);
|
||||
|
||||
int_between_f(vars, "min_fps_factor", video.min_fps_factor, { 1, 3 });
|
||||
string_f(vars, "fallback_mode", video.fallback_mode);
|
||||
|
||||
path_f(vars, "pkey", nvhttp.pkey);
|
||||
path_f(vars, "cert", nvhttp.cert);
|
||||
@@ -1171,6 +1285,7 @@ namespace config {
|
||||
}
|
||||
|
||||
string_restricted_f(vars, "locale", config::sunshine.locale, {
|
||||
"bg"sv, // Bulgarian
|
||||
"de"sv, // German
|
||||
"en"sv, // English
|
||||
"en_GB"sv, // English (UK)
|
||||
@@ -1179,10 +1294,14 @@ namespace config {
|
||||
"fr"sv, // French
|
||||
"it"sv, // Italian
|
||||
"ja"sv, // Japanese
|
||||
"ko"sv, // Korean
|
||||
"pl"sv, // Polish
|
||||
"pt"sv, // Portuguese
|
||||
"pt_BR"sv, // Portuguese (Brazilian)
|
||||
"ru"sv, // Russian
|
||||
"sv"sv, // Swedish
|
||||
"tr"sv, // Turkish
|
||||
"uk"sv, // Ukrainian
|
||||
"zh"sv, // Chinese
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user