2019-12-03 20:23:33 +01:00
|
|
|
#ifndef SUNSHINE_CONFIG_H
|
|
|
|
#define SUNSHINE_CONFIG_H
|
|
|
|
|
2020-03-19 19:59:27 +01:00
|
|
|
#include <bitset>
|
2021-05-17 21:21:57 +02:00
|
|
|
#include <chrono>
|
2020-04-14 00:15:24 +03:00
|
|
|
#include <optional>
|
2021-05-17 21:21:57 +02:00
|
|
|
#include <string>
|
2021-05-29 22:29:10 +02:00
|
|
|
#include <unordered_map>
|
2021-05-26 17:34:25 +02:00
|
|
|
#include <vector>
|
2019-12-03 20:23:33 +01:00
|
|
|
|
|
|
|
namespace config {
|
|
|
|
struct video_t {
|
|
|
|
// ffmpeg params
|
2021-08-03 15:24:04 +02:00
|
|
|
int qp; // higher == more compression and less quality
|
2019-12-06 20:52:08 +01:00
|
|
|
|
2020-04-14 00:15:24 +03:00
|
|
|
int hevc_mode;
|
|
|
|
|
2020-01-20 17:23:57 -08:00
|
|
|
int min_threads; // Minimum number of threads/slices for CPU encoding
|
2020-04-14 00:15:24 +03:00
|
|
|
struct {
|
|
|
|
std::string preset;
|
|
|
|
std::string tune;
|
|
|
|
} sw;
|
2019-12-06 21:41:30 +01:00
|
|
|
|
2020-04-14 00:15:24 +03:00
|
|
|
struct {
|
|
|
|
std::optional<int> preset;
|
|
|
|
std::optional<int> rc;
|
|
|
|
int coder;
|
|
|
|
} nv;
|
2020-01-24 01:05:43 +01:00
|
|
|
|
2021-01-28 18:32:58 -05:00
|
|
|
struct {
|
|
|
|
std::optional<int> quality;
|
2021-09-27 19:12:42 +02:00
|
|
|
std::optional<int> rc_h264;
|
|
|
|
std::optional<int> rc_hevc;
|
2021-01-28 18:32:58 -05:00
|
|
|
int coder;
|
|
|
|
} amd;
|
|
|
|
|
2022-02-24 21:09:00 +01:00
|
|
|
struct {
|
|
|
|
int allow_sw;
|
|
|
|
int require_sw;
|
|
|
|
int realtime;
|
|
|
|
int coder;
|
|
|
|
} vt;
|
|
|
|
|
2020-04-14 00:15:24 +03:00
|
|
|
std::string encoder;
|
2020-01-24 01:05:43 +01:00
|
|
|
std::string adapter_name;
|
|
|
|
std::string output_name;
|
2019-12-03 20:23:33 +01:00
|
|
|
};
|
|
|
|
|
2020-01-18 00:58:27 +01:00
|
|
|
struct audio_t {
|
|
|
|
std::string sink;
|
2021-05-21 14:28:24 +02:00
|
|
|
std::string virtual_sink;
|
2020-01-18 00:58:27 +01:00
|
|
|
};
|
|
|
|
|
2019-12-03 20:23:33 +01:00
|
|
|
struct stream_t {
|
|
|
|
std::chrono::milliseconds ping_timeout;
|
2019-12-11 23:37:20 +01:00
|
|
|
|
2021-06-16 14:34:05 +02:00
|
|
|
std::string file_apps;
|
2019-12-16 22:02:21 +01:00
|
|
|
|
2019-12-11 23:37:20 +01:00
|
|
|
int fec_percentage;
|
2020-02-08 16:26:38 +01:00
|
|
|
|
|
|
|
// max unique instances of video and audio streams
|
|
|
|
int channels;
|
2019-12-03 20:23:33 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct nvhttp_t {
|
2019-12-27 16:04:18 +01:00
|
|
|
// Could be any of the following values:
|
|
|
|
// pc|lan|wan
|
|
|
|
std::string origin_pin_allowed;
|
2021-06-30 15:25:08 +02:00
|
|
|
std::string origin_web_ui_allowed;
|
2019-12-27 16:04:18 +01:00
|
|
|
|
2021-06-16 14:34:05 +02:00
|
|
|
std::string pkey; // must be 2048 bits
|
|
|
|
std::string cert; // must be signed with a key of 2048 bits
|
2019-12-03 20:23:33 +01:00
|
|
|
|
2019-12-26 00:01:06 +01:00
|
|
|
std::string sunshine_name;
|
|
|
|
|
2021-06-16 14:34:05 +02:00
|
|
|
std::string file_state;
|
2019-12-03 20:23:33 +01:00
|
|
|
|
|
|
|
std::string external_ip;
|
2021-05-26 17:34:25 +02:00
|
|
|
std::vector<std::string> resolutions;
|
|
|
|
std::vector<int> fps;
|
2019-12-03 20:23:33 +01:00
|
|
|
};
|
|
|
|
|
2019-12-22 23:34:12 +01:00
|
|
|
struct input_t {
|
2021-08-03 15:24:04 +02:00
|
|
|
std::unordered_map<int, int> keybindings;
|
|
|
|
|
2019-12-22 23:34:12 +01:00
|
|
|
std::chrono::milliseconds back_button_timeout;
|
2020-04-26 00:23:34 +02:00
|
|
|
std::chrono::milliseconds key_repeat_delay;
|
|
|
|
std::chrono::duration<double> key_repeat_period;
|
2021-07-18 15:32:26 +02:00
|
|
|
|
|
|
|
std::string gamepad;
|
2019-12-22 23:34:12 +01:00
|
|
|
};
|
|
|
|
|
2020-03-19 19:59:27 +01:00
|
|
|
namespace flag {
|
|
|
|
enum flag_e : std::size_t {
|
2021-06-20 15:29:51 +02:00
|
|
|
PIN_STDIN = 0, // 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
|
2021-06-30 12:22:37 +02:00
|
|
|
UPNP, // Try Universal Plug 'n Play
|
2021-06-20 15:29:51 +02:00
|
|
|
CONST_PIN, // Use "universal" pin
|
2021-05-18 13:36:12 +02:00
|
|
|
FLAG_SIZE
|
2020-03-19 19:59:27 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-01-09 22:02:01 +01:00
|
|
|
struct sunshine_t {
|
|
|
|
int min_log_level;
|
2020-03-19 19:59:27 +01:00
|
|
|
std::bitset<flag::FLAG_SIZE> flags;
|
2021-06-16 14:34:05 +02:00
|
|
|
std::string credentials_file;
|
2021-06-16 11:26:54 +02:00
|
|
|
|
2021-05-28 22:49:27 +02:00
|
|
|
std::string username;
|
|
|
|
std::string password;
|
|
|
|
std::string salt;
|
2021-06-09 19:12:00 +02:00
|
|
|
|
2021-06-16 14:34:05 +02:00
|
|
|
std::string config_file;
|
2021-06-09 21:55:13 +02:00
|
|
|
|
|
|
|
struct cmd_t {
|
|
|
|
std::string name;
|
|
|
|
int argc;
|
|
|
|
char **argv;
|
|
|
|
} cmd;
|
2021-06-30 12:22:37 +02:00
|
|
|
|
|
|
|
std::uint16_t port;
|
2020-01-09 22:02:01 +01:00
|
|
|
};
|
|
|
|
|
2019-12-03 20:23:33 +01:00
|
|
|
extern video_t video;
|
2020-01-18 00:58:27 +01:00
|
|
|
extern audio_t audio;
|
2019-12-03 20:23:33 +01:00
|
|
|
extern stream_t stream;
|
|
|
|
extern nvhttp_t nvhttp;
|
2019-12-22 23:34:12 +01:00
|
|
|
extern input_t input;
|
2020-01-09 22:02:01 +01:00
|
|
|
extern sunshine_t sunshine;
|
2019-12-03 23:19:00 +01:00
|
|
|
|
2020-03-19 19:59:27 +01:00
|
|
|
int parse(int argc, char *argv[]);
|
2021-06-09 19:12:00 +02:00
|
|
|
std::unordered_map<std::string, std::string> parse_config(const std::string_view &file_content);
|
2021-05-29 22:29:10 +02:00
|
|
|
} // namespace config
|
2019-12-03 20:23:33 +01:00
|
|
|
#endif
|