Add "Ignore unsupported resolutions" option (#13 fix)

This commit is contained in:
rock88 2020-06-23 11:19:37 +03:00
parent 044a787c4b
commit 698d138b9f
4 changed files with 21 additions and 1 deletions

View file

@ -126,6 +126,10 @@ void Settings::load() {
}
}
if (json_t* ignore_unsupported_resolutions = json_object_get(settings, "ignore_unsupported_resolutions")) {
m_ignore_unsupported_resolutions = json_typeof(ignore_unsupported_resolutions) == JSON_TRUE;
}
if (json_t* click_by_tap = json_object_get(settings, "click_by_tap")) {
m_click_by_tap = json_typeof(click_by_tap) == JSON_TRUE;
}
@ -174,6 +178,7 @@ void Settings::save() {
json_object_set(settings, "fps", json_integer(m_fps));
json_object_set(settings, "video_codec", json_integer(m_video_codec));
json_object_set(settings, "bitrate", json_integer(m_bitrate));
json_object_set(settings, "ignore_unsupported_resolutions", m_ignore_unsupported_resolutions ? json_true() : json_false());
json_object_set(settings, "decoder_threads", json_integer(m_decoder_threads));
json_object_set(settings, "click_by_tap", m_click_by_tap ? json_true() : json_false());
json_object_set(settings, "sops", m_sops ? json_true() : json_false());

View file

@ -78,6 +78,14 @@ public:
m_bitrate = bitrate;
}
void set_ignore_unsupported_resolutions(bool ignore_unsupported_resolutions) {
m_ignore_unsupported_resolutions = ignore_unsupported_resolutions;
}
bool ignore_unsupported_resolutions() const {
return m_ignore_unsupported_resolutions;
}
bool click_by_tap() const {
return m_click_by_tap;
}
@ -135,6 +143,7 @@ private:
int m_fps = 60;
VideoCodec m_video_codec = H264;
int m_bitrate = 10000;
bool m_ignore_unsupported_resolutions = false;
bool m_click_by_tap = false;
int m_decoder_threads = 4;
bool m_sops = true;

View file

@ -92,7 +92,7 @@ void GameStreamClient::connect(const std::string &address, ServerCallback<SERVER
perform_async([this, address, callback] {
// TODO: mem leak here :(
int status = gs_init(&m_server_data[address], (char *)(new std::string(address))->c_str(), Settings::settings()->key_dir().c_str(), false);
int status = gs_init(&m_server_data[address], (char *)(new std::string(address))->c_str(), Settings::settings()->key_dir().c_str(), Settings::settings()->ignore_unsupported_resolutions());
nanogui::async([this, address, callback, status] {
if (status == GS_OK) {

View file

@ -49,6 +49,12 @@ SettingsWindow::SettingsWindow(nanogui::Widget* parent): ContentWindow(parent, "
DEFAULT;
}
auto ignore_unsupported_resolutions = left_container->add<CheckBox>("Ignore unsupported resolutions");
ignore_unsupported_resolutions->set_checked(Settings::settings()->ignore_unsupported_resolutions());
ignore_unsupported_resolutions->set_callback([](auto value) {
Settings::settings()->set_ignore_unsupported_resolutions(value);
});
left_container->add<Label>("FPS");
std::vector<std::string> fps = { "30", "60" };
auto fps_combo_box = left_container->add<ComboBox>(fps);