Add fallback mode config

This commit is contained in:
Yukino Song
2024-09-19 08:51:01 +08:00
parent f8c57be702
commit 2c3a08574b
8 changed files with 56 additions and 16 deletions

View File

@@ -380,6 +380,8 @@ namespace config {
{}, // encoder
{}, // adapter_name
{}, // output_name
"1920x1080x60", // fallback_mode
};
audio_t audio {
@@ -1052,6 +1054,7 @@ namespace config {
string_f(vars, "encoder", video.encoder);
string_f(vars, "adapter_name", video.adapter_name);
string_f(vars, "output_name", video.output_name);
string_f(vars, "fallback_mode", video.fallback_mode);
int_between_f(vars, "min_fps_factor", video.min_fps_factor, { 1, 3 });
path_f(vars, "pkey", nvhttp.pkey);

View File

@@ -77,6 +77,8 @@ namespace config {
std::string encoder;
std::string adapter_name;
std::string output_name;
std::string fallback_mode;
};
struct audio_t {

View File

@@ -356,16 +356,6 @@ namespace nvhttp {
std::copy(rikey.cbegin(), rikey.cend(), std::back_inserter(launch_session->gcm_key));
launch_session->host_audio = host_audio;
std::stringstream mode = std::stringstream(get_arg(args, "mode", "0x0x0"));
// Split mode by the char "x", to populate width/height/fps
int x = 0;
std::string segment;
while (std::getline(mode, segment, 'x')) {
if (x == 0) launch_session->width = atoi(segment.c_str());
if (x == 1) launch_session->height = atoi(segment.c_str());
if (x == 2) launch_session->fps = atoi(segment.c_str());
x++;
}
// Encrypted RTSP is enabled with client reported corever >= 1
auto corever = util::from_view(get_arg(args, "corever", "0"));
@@ -387,10 +377,17 @@ namespace nvhttp {
uint32_t prepend_iv = util::endian::big<uint32_t>(util::from_view(get_arg(args, "rikeyid")));
auto prepend_iv_p = (uint8_t *) &prepend_iv;
std::copy(prepend_iv_p, prepend_iv_p + sizeof(prepend_iv), std::begin(launch_session->iv));
} else {
launch_session->width = 0;
launch_session->height = 0;
launch_session->fps = 0;
}
std::stringstream mode = std::stringstream(get_arg(args, "mode", config::video.fallback_mode.c_str()));
// Split mode by the char "x", to populate width/height/fps
int x = 0;
std::string segment;
while (std::getline(mode, segment, 'x')) {
if (x == 0) launch_session->width = atoi(segment.c_str());
if (x == 1) launch_session->height = atoi(segment.c_str());
if (x == 2) launch_session->fps = atoi(segment.c_str());
x++;
}
launch_session->device_name = named_cert_p->name.empty() ? "ApolloDisplay"s : named_cert_p->name;

View File

@@ -223,7 +223,7 @@ namespace proc {
std::wstring currentPrimaryDisplayName = VDISPLAY::getPrimaryDisplay();
// When launched through config ui, don't change display settings
// Don't change display settings when no params are given
if (launch_session->width && launch_session->height && launch_session->fps) {
// Apply display settings
VDISPLAY::changeDisplaySettings(vdisplayName.c_str(), render_width, render_height, launch_session->fps);