MCPcopy Create free account
hub / github.com/RGAA-Software/GoDesk / LoadSettings

Method LoadSettings

src/render/settings/rd_settings.cpp:17–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15{
16
17 bool RdSettings::LoadSettings(const std::string& path) {
18 toml::parse_result result;
19 try {
20 result = toml::parse_file(path);
21 } catch (std::exception& e) {
22 return false;
23 }
24
25 // description
26 desc_.author_ = result["description"]["author"].value_or("");
27 desc_.version_ = result["description"]["version"].value_or("0.0.1");
28
29 auto encoder_format = result["encoder"]["format"].value_or("h264");
30 encoder_.encoder_format_ = [&]() {
31 if (std::string(encoder_format) == std::string("h264")) {
32 return Encoder::EncoderFormat::kH264;
33 }
34 else if (std::string(encoder_format) == std::string("hevc")) {
35 return Encoder::EncoderFormat::kHEVC;
36 }
37 else {
38 return Encoder::EncoderFormat::kH264;
39 }
40 } ();
41
42 encoder_.bitrate_ = result["encoder"]["bitrate"].value_or(6);
43
44 if (std::string("origin") == result["encoder"]["encode-resolution-type"].value_or("origin")) {
45 encoder_.encode_res_type_ = Encoder::EncodeResolutionType::kOrigin;
46 } else {
47 encoder_.encode_res_type_ = Encoder::EncodeResolutionType::kSpecify;
48 }
49 encoder_.encode_width_ = result["encoder"]["encode-width"].value_or(1280);
50 encoder_.encode_height_ = result["encoder"]["encode-height"].value_or(720);
51
52 // capture
53 capture_.enable_audio_ = result["capture"]["enable-audio"].value_or(true);
54 std::string capture_audio_type_name = result["capture"]["audio-capture-type"].value_or("global");
55 capture_.capture_audio_type_ = [&]() -> Capture::CaptureAudioType {
56 if (capture_audio_type_name == "hook") {
57 return Capture::CaptureAudioType::kAudioInner;
58 }
59 else {
60 return Capture::CaptureAudioType::kAudioGlobal;
61 }
62 }();
63
64 capture_.enable_video_ = result["capture"]["enable-video"].value_or(true);
65 std::string capture_video_type_name = result["capture"]["video-capture-type"].value_or("hook");
66 capture_.capture_video_type_ = [&]() -> Capture::CaptureVideoType {
67 if (capture_video_type_name == "hook") {
68 return Capture::CaptureVideoType::kVideoInner;
69 }
70 else {
71 return Capture::CaptureVideoType::kCaptureScreen;
72 }
73 }();
74

Callers 1

mainFunction · 0.45

Calls 1

IsSteamUrlMethod · 0.80

Tested by

no test coverage detected