diff --git a/gui/src/streamsession.cpp b/gui/src/streamsession.cpp index fa696be..e1b8cd6 100644 --- a/gui/src/streamsession.cpp +++ b/gui/src/streamsession.cpp @@ -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"); diff --git a/lib/include/chiaki/session.h b/lib/include/chiaki/session.h index e036cf7..db7bf02 100644 --- a/lib/include/chiaki/session.h +++ b/lib/include/chiaki/session.h @@ -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; diff --git a/lib/src/ctrl.c b/lib/src/ctrl.c index b910fc9..a3b8461 100644 --- a/lib/src/ctrl.c +++ b/lib/src/ctrl.c @@ -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; diff --git a/lib/src/session.c b/lib/src/session.c index 84177ed..1c0c388 100644 --- a/lib/src/session.c +++ b/lib/src/session.c @@ -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; diff --git a/switch/src/host.cpp b/switch/src/host.cpp index 0770ca0..6db9c50 100644 --- a/switch/src/host.cpp +++ b/switch/src/host.cpp @@ -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();