Fix build

(Never wanna merge again)
This commit is contained in:
Yukino Song
2025-01-15 09:01:33 +08:00
parent 1dc6465f12
commit fcbdaed1e0
12 changed files with 93 additions and 109 deletions

View File

@@ -486,8 +486,7 @@ namespace config {
{}, // mode_remapping
{} // wa
}, // display_device
1 // min_fps_factor
1, // min_fps_factor
"1920x1080x60", // fallback_mode
};

View File

@@ -583,20 +583,11 @@ namespace confighttp {
print_req(request);
pt::ptree outputTree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
pt::write_json(data, outputTree);
response->write(data.str());
});
auto args = request->parse_query_string();
if (
args.find("uuid"s) == std::end(args)
) {
outputTree.put("status", false);
outputTree.put("error", "Missing a required launch parameter");
bad_request(response, request, "Missing a required parameter to delete app");
return;
}
@@ -619,6 +610,10 @@ namespace confighttp {
fileTree.push_back(std::make_pair("apps", newApps));
pt::write_json(config::stream.file_apps, fileTree);
pt::ptree outputTree;
outputTree.put("status", true);
send_response(response, outputTree);
}
catch (std::exception &e) {
BOOST_LOG(warning) << "DeleteApp: "sv << e.what();
@@ -1019,12 +1014,6 @@ namespace confighttp {
pt::ptree outputTree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
pt::write_json(data, outputTree);
response->write(data.str());
});
try {
auto args = request->parse_query_string();
auto it = args.find("passphrase");
@@ -1049,12 +1038,11 @@ namespace confighttp {
outputTree.put("name", config::nvhttp.sunshine_name);
outputTree.put("status", true);
outputTree.put("message", "OTP created, effective within 3 minutes.");
send_response(response, outputTree);
}
catch (std::exception &e) {
BOOST_LOG(warning) << "OTP creation failed: "sv << e.what();
outputTree.put("status", false);
outputTree.put("message", e.what());
return;
bad_request(response, request, e.what());
}
}
@@ -1069,24 +1057,17 @@ namespace confighttp {
pt::ptree inputTree, outputTree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
pt::write_json(data, outputTree);
response->write(data.str());
});
try {
pt::read_json(ss, inputTree);
std::string uuid = inputTree.get<std::string>("uuid");
std::string name = inputTree.get<std::string>("name");
auto perm = (crypto::PERM)inputTree.get<uint32_t>("perm") & crypto::PERM::_all;
outputTree.put("status", nvhttp::update_device_info(uuid, name, perm));
send_response(response, outputTree);
}
catch (std::exception &e) {
BOOST_LOG(warning) << "Update Client: "sv << e.what();
outputTree.put("status", false);
outputTree.put("error", e.what());
return;
bad_request(response, request, e.what());
}
}
@@ -1155,19 +1136,11 @@ namespace confighttp {
pt::ptree outputTree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
pt::write_json(data, outputTree);
response->write(data.str());
});
auto args = request->parse_query_string();
if (
args.find("uuid"s) == std::end(args)
) {
outputTree.put("status", false);
outputTree.put("error", "Missing a required launch parameter");
bad_request(response, request, "Missing a required launch parameter");
return;
}
@@ -1190,14 +1163,12 @@ namespace confighttp {
auto launch_session = nvhttp::make_launch_session(true, appid, args, &named_cert);
auto err = proc::proc.execute(appid, app, launch_session);
if (err) {
outputTree.put("status", false);
outputTree.put("error",
err == 503
bad_request(response, request, err == 503
? "Failed to initialize video capture/encoding. Is a display connected and turned on?"
: "Failed to start the specified application");
return;
} else {
outputTree.put("status", true);
send_response(response, outputTree);
}
return;
@@ -1205,8 +1176,7 @@ namespace confighttp {
}
BOOST_LOG(error) << "Couldn't find app with uuid ["sv << uuid << ']';
outputTree.put("status", false);
outputTree.put("error", "Cannot find requested application");
bad_request(response, request, "Cannot find requested application");
}
void
@@ -1220,12 +1190,6 @@ namespace confighttp {
pt::ptree inputTree, outputTree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
pt::write_json(data, outputTree);
response->write(data.str());
});
try {
pt::read_json(ss, inputTree);
std::string uuid = inputTree.get<std::string>("uuid");
@@ -1233,9 +1197,9 @@ namespace confighttp {
}
catch (std::exception &e) {
BOOST_LOG(warning) << "Disconnect: "sv << e.what();
outputTree.put("status", false);
outputTree.put("error", e.what());
bad_request(response, request, e.what());
}
send_response(response, outputTree);
}
/**

View File

@@ -986,17 +986,12 @@ namespace nvhttp {
print_req<SunshineHTTPS>(request);
pt::ptree tree;
bool revert_display_configuration { false };
auto g = util::fail_guard([&]() {
std::ostringstream data;
pt::write_xml(data, tree);
response->write(data.str());
response->close_connection_after_response = true;
if (revert_display_configuration) {
display_device::revert_configuration();
}
});
auto named_cert_p = get_verified_cert(request);
@@ -1084,9 +1079,6 @@ namespace nvhttp {
tree.put("root.gamesession", 1);
rtsp_stream::launch_session_raise(launch_session);
// Stream was started successfully, we will revert the config when the app or session terminates
revert_display_configuration = false;
}
void

View File

@@ -166,13 +166,6 @@ namespace proc {
// Save the original output name in case we modify it temporary later
std::string output_name_orig = config::video.output_name;
// Executed when returning from function
auto fg = util::fail_guard([&]() {
// Restore to user defined output name
config::video.output_name = output_name_orig;
terminate();
});
_app = app;
_app_id = app_id;
_launch_session = launch_session;
@@ -199,7 +192,19 @@ namespace proc {
}
#ifdef _WIN32
if (config::video.headless_mode || launch_session->virtual_display || _app.virtual_display) {
bool create_virtual_display = config::video.headless_mode || launch_session->virtual_display || _app.virtual_display;
// Executed when returning from function
auto fg = util::fail_guard([&]() {
// Restore to user defined output name
config::video.output_name = output_name_orig;
terminate();
if (!create_virtual_display) {
display_device::revert_configuration();
}
});
if (create_virtual_display) {
if (vDisplayDriverStatus != VDISPLAY::DRIVER_STATUS::OK) {
// Try init driver again
initVDisplayDriver();
@@ -280,7 +285,19 @@ namespace proc {
config::video.output_name = this->display_name;
}
}
} else {
display_device::configure_display(config::video, *launch_session);
}
#else
// Executed when returning from function
auto fg = util::fail_guard([&]() {
// Restore to user defined output name
config::video.output_name = output_name_orig;
terminate();
display_device::revert_configuration();
});
display_device::configure_display(config::video, *launch_session);
#endif
// Probe encoders again before streaming to ensure our chosen
@@ -419,7 +436,9 @@ namespace proc {
// We should have got the actual streaming display by now
std::string currentDisplay = this->display_name;
if (!currentDisplay.empty()) {
if (currentDisplay.empty()) {
BOOST_LOG(warning) << "Not getting current display in time! HDR will not be toggled.";
} else {
auto currentDisplayW = platf::from_utf8(currentDisplay).c_str();
this->initial_display = currentDisplay;

View File

@@ -11,6 +11,10 @@
#include "crypto.h"
#include "thread_safe.h"
#ifdef _WIN32
#include <windows.h>
#endif
// Resolve circular dependencies
namespace stream {
struct session_t;