Add Video Profile Auto Downgrade

This commit is contained in:
Florian Märkl 2020-12-28 17:07:37 +01:00
commit c19c7869d5
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
5 changed files with 24 additions and 2 deletions

View file

@ -76,6 +76,7 @@ typedef struct chiaki_connect_info_t
char regist_key[CHIAKI_SESSION_AUTH_SIZE]; // must be completely filled (pad with \0)
uint8_t morning[0x10];
ChiakiConnectVideoProfile video_profile;
bool video_profile_auto_downgrade; // Downgrade video_profile if server does not seem to support it.
bool enable_keyboard;
} ChiakiConnectInfo;
@ -159,6 +160,7 @@ typedef struct chiaki_session_t
uint8_t morning[CHIAKI_RPCRYPT_KEY_SIZE];
uint8_t did[CHIAKI_RP_DID_SIZE];
ChiakiConnectVideoProfile video_profile;
bool video_profile_auto_downgrade;
bool enable_keyboard;
} connect_info;

View file

@ -963,7 +963,24 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
}
}
if(!response.server_type_valid)
if(response.server_type_valid)
{
uint8_t server_type = response.rp_server_type[0]; // 0 = PS4, 1 = PS4 Pro, 2 = PS5
CHIAKI_LOGI(session->log, "Ctrl got Server Type: %u", (unsigned int)server_type);
if(server_type == 0
&& session->connect_info.video_profile_auto_downgrade
&& session->connect_info.video_profile.height == 1080)
{
CHIAKI_LOGI(session->log, "1080p was selected but server would not support it. Downgrading.");
chiaki_connect_video_profile_preset(
&session->connect_info.video_profile,
CHIAKI_VIDEO_RESOLUTION_PRESET_720p,
session->connect_info.video_profile.max_fps == 60
? CHIAKI_VIDEO_FPS_PRESET_60
: CHIAKI_VIDEO_FPS_PRESET_30);
}
}
else
CHIAKI_LOGE(session->log, "No valid Server Type in ctrl response");
ctrl->sock = sock;

View file

@ -224,6 +224,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_session_init(ChiakiSession *session, Chiaki
memcpy(session->connect_info.did + sizeof(session->connect_info.did) - sizeof(did_suffix), did_suffix, sizeof(did_suffix));
session->connect_info.video_profile = connect_info->video_profile;
session->connect_info.video_profile_auto_downgrade = connect_info->video_profile_auto_downgrade;
session->connect_info.enable_keyboard = connect_info->enable_keyboard;
return CHIAKI_ERR_SUCCESS;