Get device UUID from local assigned value

This commit is contained in:
Yukino Song
2024-09-15 13:02:10 +08:00
parent 2f105081b8
commit 4a0d425b7c
4 changed files with 20 additions and 19 deletions

View File

@@ -336,7 +336,7 @@ namespace nvhttp {
}
std::shared_ptr<rtsp_stream::launch_session_t>
make_launch_session(bool host_audio, const args_t &args) {
make_launch_session(bool host_audio, const args_t &args, const std::string& uuid) {
auto launch_session = std::make_shared<rtsp_stream::launch_session_t>();
launch_session->id = ++session_id_counter;
@@ -356,7 +356,7 @@ namespace nvhttp {
x++;
}
launch_session->device_name = (get_arg(args, "devicename", "unknown"));
launch_session->unique_id = (get_arg(args, "uniqueid", "unknown"));
launch_session->unique_id = uuid;
launch_session->appid = util::from_view(get_arg(args, "appid", "unknown"));
launch_session->enable_sops = util::from_view(get_arg(args, "sops", "0"));
launch_session->surround_info = util::from_view(get_arg(args, "surroundAudioInfo", "196610"));
@@ -533,6 +533,11 @@ namespace nvhttp {
static auto constexpr to_string = "NONE"sv;
};
inline crypto::named_cert_t*
get_verified_cert(req_https_t request) {
return (crypto::named_cert_t*)request->userp.get();
}
template <class T>
void
print_req(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Request> request) {
@@ -757,10 +762,9 @@ namespace nvhttp {
serverinfo(std::shared_ptr<typename SimpleWeb::ServerBase<T>::Response> response, std::shared_ptr<typename SimpleWeb::ServerBase<T>::Request> request) {
print_req<T>(request);
int pair_status = 0;
if constexpr (std::is_same_v<SunshineHTTPS, T>) {
BOOST_LOG(info) << "Device " << ((crypto::named_cert_t*)request->userp.get())->name << " getting server info!!!";
BOOST_LOG(info) << "Device " << get_verified_cert(request)->name << " getting server info!!!";
auto args = request->parse_query_string();
auto clientID = args.find("uniqueid"s);
@@ -914,6 +918,8 @@ namespace nvhttp {
launch(bool &host_audio, resp_https_t response, req_https_t request) {
print_req<SunshineHTTPS>(request);
auto named_cert_p = get_verified_cert(request);
pt::ptree tree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
@@ -954,7 +960,7 @@ namespace nvhttp {
}
host_audio = util::from_view(get_arg(args, "localAudioPlayMode"));
auto launch_session = make_launch_session(host_audio, args);
auto launch_session = make_launch_session(host_audio, args, named_cert_p->uuid);
auto encryption_mode = net::encryption_mode_for_address(request->remote_endpoint().address());
if (!launch_session->rtsp_cipher && encryption_mode == config::ENCRYPTION_MODE_MANDATORY) {
@@ -1011,6 +1017,8 @@ namespace nvhttp {
resume(bool &host_audio, resp_https_t response, req_https_t request) {
print_req<SunshineHTTPS>(request);
auto named_cert_p = get_verified_cert(request);
pt::ptree tree;
auto g = util::fail_guard([&]() {
std::ostringstream data;
@@ -1071,7 +1079,7 @@ namespace nvhttp {
}
}
auto launch_session = make_launch_session(host_audio, args);
auto launch_session = make_launch_session(host_audio, args, named_cert_p->uuid);
auto encryption_mode = net::encryption_mode_for_address(request->remote_endpoint().address());
if (!launch_session->rtsp_cipher && encryption_mode == config::ENCRYPTION_MODE_MANDATORY) {

View File

@@ -294,7 +294,7 @@ std::wstring createVirtualDisplay(
uint32_t width,
uint32_t height,
uint32_t fps,
GUID& guid
const GUID& guid
) {
if (SUDOVDA_DRIVER_HANDLE == INVALID_HANDLE_VALUE) {
return std::wstring();
@@ -308,16 +308,6 @@ std::wstring createVirtualDisplay(
s_client_name = s_app_name;
}
if (s_client_uid && strcmp(s_client_uid, "unknown")) {
size_t len = strlen(s_client_uid);
if (len > sizeof(GUID)) {
len = sizeof(GUID);
}
memcpy((void*)&guid, (void*)s_client_uid, len);
} else {
s_client_uid = "unknown";
}
VIRTUAL_DISPLAY_ADD_OUT output;
if (!AddVirtualDisplay(SUDOVDA_DRIVER_HANDLE, width, height, fps, guid, s_client_name, s_client_uid, output)) {
printf("[SUDOVDA] Failed to add virtual display.\n");

View File

@@ -39,7 +39,7 @@ namespace VDISPLAY {
uint32_t width,
uint32_t height,
uint32_t fps,
GUID& guid
const GUID& guid
);
bool removeVirtualDisplay(const GUID& guid);
}

View File

@@ -29,6 +29,7 @@
#include "system_tray.h"
#include "utility.h"
#include "video.h"
#include "uuid.h"
#ifdef _WIN32
// from_utf8() string conversion function
@@ -205,7 +206,9 @@ namespace proc {
VDISPLAY::setRenderAdapterByName(platf::from_utf8(config::video.adapter_name));
}
memcpy(&launch_session->display_guid, &http::uuid, sizeof(GUID));
auto device_uuid = uuid_util::uuid_t::parse(launch_session->unique_id);
memcpy(&launch_session->display_guid, &device_uuid, sizeof(GUID));
std::wstring vdisplayName = VDISPLAY::createVirtualDisplay(
launch_session->unique_id.c_str(),