Sunshine/sunshine/config.h

125 lines
2.5 KiB
C
Raw Normal View History

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