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

@ -105,6 +105,7 @@ StreamSession::StreamSession(const StreamSessionConnectInfo &connect_info, QObje
chiaki_connect_info.ps5 = chiaki_target_is_ps5(connect_info.target);
chiaki_connect_info.host = host_str.constData();
chiaki_connect_info.video_profile = connect_info.video_profile;
chiaki_connect_info.video_profile_auto_downgrade = true;
if(connect_info.regist_key.size() != sizeof(chiaki_connect_info.regist_key))
throw ChiakiException("RegistKey invalid");

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;

View file

@ -139,10 +139,11 @@ int Host::InitSession(IO *user)
// Build chiaki ps4 stream session
chiaki_opus_decoder_init(&(this->opus_decoder), this->log);
ChiakiAudioSink audio_sink;
ChiakiConnectInfo chiaki_connect_info = {0};
ChiakiConnectInfo chiaki_connect_info = {};
chiaki_connect_info.host = this->host_addr.c_str();
chiaki_connect_info.video_profile = this->video_profile;
chiaki_connect_info.video_profile_auto_downgrade = true;
chiaki_connect_info.ps5 = this->IsPS5();