Hermes 0.7.0
Linux game streaming host
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1
5#pragma once
6
7// standard includes
8#include <bitset>
9#include <chrono>
10#include <optional>
11#include <set>
12#include <string>
13#include <unordered_map>
14#include <vector>
15
16// local includes
17#include "nvenc/nvenc_config.h"
18
19namespace config {
20 // track modified config options
21 inline std::unordered_map<std::string, std::string> modified_config_settings;
22
23 struct video_t {
24 bool headless_mode;
25 bool limit_framerate;
26 bool double_refreshrate;
27 // ffmpeg params
28 int qp; // higher == more compression and less quality
29
30 int hevc_mode;
31 int av1_mode;
32
33 int min_threads; // Minimum number of threads/slices for CPU encoding
34 int default_scale_factor; // Host-side default resolution scale factor in percent; 100 = unchanged.
35
36 struct {
37 std::string sw_preset;
38 std::string sw_tune;
39 std::optional<int> svtav1_preset;
40 } sw;
41
43
44 struct {
45 int preset;
46 int multipass;
47 int h264_coder;
48 int aq;
49 int vbv_percentage_increase;
50 } nv_legacy;
51
52 struct {
53 bool strict_rc_buffer;
54 int quality; // ffmpeg VAAPI quality option, -1 = leave codec default.
55 bool intra_refresh; // rolling intra refresh, so a lost frame heals without a key frame
56 } vaapi;
57
58 std::string capture;
59 std::string encoder;
60 std::string adapter_name;
61 std::string output_name;
62 std::string virtual_display_backend;
63 bool hermes_kms_multi_output;
64 bool hermes_kms_isolated_sessions;
65 std::string gamescope_backend;
66 std::string hermes_kms_session_compositor;
67 std::string isolation_method;
68
69 struct dd_t {
71 std::chrono::milliseconds hdr_toggle_delay;
72 };
73
74 enum class config_option_e {
75 disabled,
76 verify_only,
77 ensure_active,
78 ensure_primary,
79 ensure_only_display
80 };
81
83 disabled,
84 automatic,
85 manual
86 };
87
89 disabled,
90 automatic,
91 manual
92 };
93
94 enum class hdr_option_e {
95 disabled,
96 automatic
97 };
98
100 std::string requested_resolution;
101 std::string requested_fps;
102 std::string final_resolution;
103 std::string final_refresh_rate;
104 };
105
107 std::vector<mode_remapping_entry_t> mixed;
108 std::vector<mode_remapping_entry_t> resolution_only;
109 std::vector<mode_remapping_entry_t> refresh_rate_only;
110 };
111
112 config_option_e configuration_option;
113 resolution_option_e resolution_option;
114 std::string manual_resolution;
115 refresh_rate_option_e refresh_rate_option;
117 hdr_option_e hdr_option;
118 std::chrono::milliseconds config_revert_delay;
120 mode_remapping_t mode_remapping;
121 workarounds_t wa;
122 } dd;
123
124 int max_bitrate; // Maximum bitrate, sets ceiling in kbps for bitrate requested from client
126
127 std::string fallback_mode;
128 bool isolated_virtual_display_option;
129 bool ignore_encoder_probe_failure;
130 bool pyrowave;
131 };
132
133 struct audio_t {
134 std::string sink;
135 bool stream;
136 bool stream_mic;
137 bool keep_default;
138 bool auto_capture;
139 };
140
141 constexpr int ENCRYPTION_MODE_NEVER = 0; // Never use video encryption, even if the client supports it
142 constexpr int ENCRYPTION_MODE_OPPORTUNISTIC = 1; // Use video encryption if available, but stream without it if not supported
143 constexpr int ENCRYPTION_MODE_MANDATORY = 2; // Always use video encryption and refuse clients that can't encrypt
144
145 struct stream_t {
146 std::chrono::milliseconds ping_timeout;
147
148 std::string file_apps;
149
150 int fec_percentage;
151
152 // Size FEC parity from the client's own loss reports instead of the fixed
153 // percentage above, never exceeding adaptive_fec_max_percentage.
154 bool adaptive_fec;
155 int adaptive_fec_max_percentage;
156
157 // Video encryption settings for LAN and WAN streams
158 int lan_encryption_mode;
159 int wan_encryption_mode;
160 };
161
162 struct nvhttp_t {
163 // Could be any of the following values:
164 // pc|lan|wan
165 std::string origin_web_ui_allowed;
166
167 std::string pkey;
168 std::string cert;
169
170 std::string sunshine_name;
171
172 std::string file_state;
173
174 std::string external_ip;
175 };
176
177 struct input_t {
178 std::unordered_map<int, int> keybindings;
179
180 std::chrono::milliseconds back_button_timeout;
181 std::chrono::milliseconds key_repeat_delay;
182 std::chrono::duration<double> key_repeat_period;
183
184 std::string gamepad;
185 std::string linux_gamepad_backend;
186 bool ds4_back_as_touchpad_click;
187 bool motion_as_ds4;
188 bool touchpad_as_ds4;
189 bool virtualhid_randomize_mac;
190
191 bool keyboard;
192 bool mouse;
193 bool controller;
194
195
196 bool high_resolution_scrolling;
197 bool native_pen_touch;
198 bool isolated_ignore_mouse_wiggle;
199 bool isolated_hide_hid_gamepads;
200 bool virtualhid_stable_mac;
201
202 bool enable_input_only_mode;
203 bool forward_rumble;
204 };
205
206 namespace flag {
215 } // namespace flag
216
217 struct prep_cmd_t {
218 prep_cmd_t(std::string &&do_cmd, std::string &&undo_cmd, bool &&elevated):
219 do_cmd(std::move(do_cmd)),
220 undo_cmd(std::move(undo_cmd)),
221 elevated(std::move(elevated)) {
222 }
223
224 explicit prep_cmd_t(std::string &&do_cmd, bool &&elevated):
225 do_cmd(std::move(do_cmd)),
226 elevated(std::move(elevated)) {
227 }
228
229 std::string do_cmd;
230 std::string undo_cmd;
231 bool elevated;
232 };
233
234 struct server_cmd_t {
235 server_cmd_t(std::string &&cmd_name, std::string &&cmd_val, bool &&elevated):
236 cmd_name(std::move(cmd_name)),
237 cmd_val(std::move(cmd_val)),
238 elevated(std::move(elevated)) {
239 }
240 std::string cmd_name;
241 std::string cmd_val;
242 bool elevated;
243 };
244
245 struct sunshine_t {
246 bool hide_tray_controls;
247 bool enable_pairing;
248 bool enable_discovery;
249 bool envvar_compatibility_mode;
256 std::string locale;
257 int min_log_level;
258 std::bitset<flag::FLAG_SIZE> flags;
259 std::string credentials_file;
260
261 std::string username;
262 std::string password;
263 std::string salt;
264
265 std::string config_file;
266
267 struct cmd_t {
268 std::string name;
269 int argc;
270 char **argv;
271 } cmd;
272
273 std::uint16_t port;
274 std::string address_family;
275
276 std::string log_file;
277 bool notify_pre_releases;
282 bool legacy_ordering;
283 bool system_tray;
284 std::vector<prep_cmd_t> prep_cmds;
285 std::vector<prep_cmd_t> state_cmds;
286 std::vector<server_cmd_t> server_cmds;
287
292 };
293
294 extern video_t video;
295 extern audio_t audio;
296 extern stream_t stream;
297 extern nvhttp_t nvhttp;
298 extern input_t input;
299 extern sunshine_t sunshine;
300
301 int parse(int argc, char *argv[]);
302 std::unordered_map<std::string, std::string> parse_config(const std::string_view &file_content);
303
316 const std::set<std::string> &server_computed_keys();
317} // namespace config
318
const std::set< std::string > & server_computed_keys()
Keys the Web UI's config response carries but that are never configuration: server-computed status,...
Definition config.cpp:407
@ UPNP
Try Universal Plug 'n Play.
Definition config.h:211
@ FRESH_STATE
Do not load or save state.
Definition config.h:209
@ FLAG_SIZE
Number of flags.
Definition config.h:213
@ PIN_STDIN
Read PIN from stdin instead of http.
Definition config.h:208
@ FORCE_VIDEO_HEADER_REPLACE
force replacing headers inside video data
Definition config.h:210
@ CONST_PIN
Use "universal" pin.
Definition config.h:212
Contains all the functions and variables related to the nvhttp (GameStream) server.
Definition nvhttp.cpp:47
Handles the system tray icon and notification system.
Declarations for NVENC encoder configuration.
bool inhibit_screen_lock
Definition config.h:291
Definition config.h:99
std::vector< mode_remapping_entry_t > refresh_rate_only
To be use when only refresh_rate_option is set to automatic.
Definition config.h:109
std::vector< mode_remapping_entry_t > mixed
To be used when resolution_option and refresh_rate_option is set to automatic.
Definition config.h:107
std::vector< mode_remapping_entry_t > resolution_only
To be use when only resolution_option is set to automatic.
Definition config.h:108
std::chrono::milliseconds hdr_toggle_delay
Specify whether to apply HDR high-contrast color workaround and what delay to use.
Definition config.h:71
std::string manual_resolution
Manual resolution in case resolution_option == resolution_option_e::manual.
Definition config.h:114
bool config_revert_on_disconnect
Specify whether to revert display configuration on client disconnect.
Definition config.h:119
std::chrono::milliseconds config_revert_delay
Time to wait until settings are reverted (after stream ends/app exists).
Definition config.h:118
std::string manual_refresh_rate
Manual refresh rate in case refresh_rate_option == refresh_rate_option_e::manual.
Definition config.h:116
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:125
NVENC encoder configuration.