Skip to content

Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.

C++

fix(remoteplay): RP_IN_USE gets a long backoff instead of burning all retries in the release window

Veyra Goal Agentaf88d2fe063a
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e4432b65..01edb403 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -754,6 +754,17 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avform
veyra_shader_parity_decode veyra_shader_scale_blit
veyra_shader_nv12_upload veyra_shader_nvof_densify)
+ # Headless Remote Play probe: drives the product session stack with a saved
+ # profile so codec/bitrate variants can be compared without the GUI.
+ if(VEYRA_ENABLE_REMOTEPLAY)
+ add_executable(veyra_remoteplay_probe tools/remoteplay_probe/main.cpp)
+ target_compile_features(veyra_remoteplay_probe PRIVATE cxx_std_20)
+ target_compile_options(veyra_remoteplay_probe PRIVATE /WX-)
+ target_compile_definitions(veyra_remoteplay_probe PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX)
+ target_include_directories(veyra_remoteplay_probe PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
+ target_link_libraries(veyra_remoteplay_probe PRIVATE veyra_sources veyra_gfx ${FFMPEG_LIBRARIES})
+ endif()
+
# Phase 6 realtime engine probe: decode -> SR -> NR -> NVOF -> DLSSG -> present.
if(VEYRA_ENABLE_EXPERIMENTAL_DLSSNR AND EXISTS "${VEYRA_NVOF_SDK_ROOT}/NvOFInterface/nvOpticalFlowCommon.h")
add_executable(veyra_player_probe
diff --git a/src/source/RemotePlaySessionSource.cpp b/src/source/RemotePlaySessionSource.cpp
index c25ae8c7..3fbdeaea 100644
--- a/src/source/RemotePlaySessionSource.cpp
+++ b/src/source/RemotePlaySessionSource.cpp
@@ -26,13 +26,16 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
for(;;){
recovery.beginAttempt(milliseconds());
bool retry=false;
+ // RP_IN_USE needs its own, much longer backoff: the console keeps the old
+ // session slot for roughly twenty seconds after it ends.
+ bool retryWasRpInUse=false;
uint64_t receivedBase=0,droppedBase=0;
{std::lock_guard lock(mutex_);receivedBase=rates_.received;droppedBase=rates_.ingressDropped;}
std::jthread feeder;
std::jthread monitor;
try {
const bool ok=source.connect(desc);
- if(!ok)retry=recovery.poll(milliseconds(),false,true)==remoteplay::StreamRecovery::Action::Reconnect;
+ if(!ok){retryWasRpInUse=source.nativeSnapshot().startupRetryAllowed;retry=recovery.poll(milliseconds(),false,true)==remoteplay::StreamRecovery::Action::Reconnect;}
{std::lock_guard lock(mutex_);publishedInfo_=source.info();if(!initialized_)started_=ok;failed_=!ok&&!retry;initialized_=true;telemetryInbox_=source.telemetryInbox();
if(failed_)recovery_.message=L"PS5 串流连接失败,请检查主机及网络;已保存的配对无需重输。";}
ready_.notify_all();
@@ -127,7 +130,7 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
if(action==remoteplay::StreamRecovery::Action::Keyframe){
source.recoverVideo();log::warn("remoteplay-recovery",std::format("request keyframe; received={} decoded={} videoCallbacks={} rejected={} packetReceived={} packetLost={}",snapshot.video.accessUnits,snapshot.decodedFrames,native.videoCallbacks,native.callbackRejected,native.packetReceived,native.packetLost));
std::lock_guard lock(mutex_);recovery_.active=true;recovery_.message=L"画面中断,正在请求关键帧恢复…";
- }else if(action==remoteplay::StreamRecovery::Action::Reconnect){retry=true;break;}
+ }else if(action==remoteplay::StreamRecovery::Action::Reconnect){retryWasRpInUse=native.startupRetryAllowed;retry=true;break;}
else if(action==remoteplay::StreamRecovery::Action::Fail){
log::error("remoteplay-recovery",std::format("recovery stopped attempts={} quitReason={} error={}",recovery.reconnects(),native.lastQuitReason,snapshot.errorCode));
std::lock_guard lock(mutex_);failed_=true;recovery_.active=false;
@@ -145,7 +148,10 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
ready_.notify_all();
}
if(retry&&!stop.stop_requested()){
- std::lock_guard lock(mutex_);recovery_={true,recovery.episodeRetries(),std::format(L"串流中断,正在重新连接({}/3)…",recovery.episodeRetries())};
+ std::lock_guard lock(mutex_);
+ recovery_={true,recovery.episodeRetries(),retryWasRpInUse
+ ?std::format(L"PS5 正在释放上一个串流会话,等待后自动重试({}/3)…",recovery.episodeRetries())
+ :std::format(L"串流中断,正在重新连接({}/3)…",recovery.episodeRetries())};
latest_.reset();pendingControllers_.clear();controller_={};feedback_={};
}
log::info("remoteplay-recovery",std::format("teardown begin attempt={} retry={} cancelled={}",recovery.reconnects(),retry,stop.stop_requested()));
@@ -156,8 +162,14 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
log::info("remoteplay-recovery",std::format("teardown complete attempt={}",recovery.reconnects()));
if(!retry||stop.stop_requested())break;
log::warn("remoteplay-recovery",std::format("old session joined; reconnect={} using existing in-memory pairing",recovery.reconnects()));
- // Interruptible 1/2/4 second backoff; manual Stop prevents the next start.
- for(unsigned i=0;i<(1u<<(recovery.episodeRetries()-1))*20&&!stop.stop_requested();++i)std::this_thread::sleep_for(std::chrono::milliseconds(50));
+ // Interruptible backoff; manual Stop prevents the next start. The console
+ // keeps the previous session slot for ~20 s after it ends, so an RP_IN_USE
+ // refusal gets 10/20/40 s instead of the generic 1/2/4 s: the short budget
+ // spent all three retries inside that window (field log 2026-09-17: three
+ // refusals in 11 s, while a 25 s wait reconnected fine).
+ const unsigned backoffSeconds=retryWasRpInUse?(10u<<(recovery.episodeRetries()-1)):(1u<<(recovery.episodeRetries()-1));
+ if(retryWasRpInUse)log::warn("remoteplay-recovery",std::format("PS5 still holds the previous session; waiting {}s before retry {}/3",backoffSeconds,recovery.episodeRetries()));
+ for(unsigned i=0;i<backoffSeconds*20&&!stop.stop_requested();++i)std::this_thread::sleep_for(std::chrono::milliseconds(50));
if(stop.stop_requested())break;
}
{std::lock_guard lock(mutex_);recovery_.active=false;}
diff --git a/tools/remoteplay_probe/main.cpp b/tools/remoteplay_probe/main.cpp
new file mode 100644
index 00000000..dd3a51fd
--- /dev/null
+++ b/tools/remoteplay_probe/main.cpp
@@ -0,0 +1,131 @@
+// Headless Remote Play probe: drives the exact product session stack with a
+// saved (already paired) profile so codec/bitrate variables can be compared
+// without the GUI. It never prints credentials.
+#include "veyra/remoteplay/ProfileStore.h"
+#include "veyra/source/RemotePlaySessionSource.h"
+#include "veyra/gfx/D3D12DeviceContext.h"
+#include "veyra/Log.h"
+
+#include <chrono>
+#include <filesystem>
+#include <iostream>
+#include <string>
+#include <thread>
+
+using namespace veyra;
+
+namespace {
+
+std::string narrow(const std::wstring& value) {
+ if (value.empty()) return {};
+ const int size = WideCharToMultiByte(CP_UTF8, 0, value.c_str(), int(value.size()), nullptr, 0, nullptr, nullptr);
+ std::string result(size_t(size), '\0');
+ WideCharToMultiByte(CP_UTF8, 0, value.c_str(), int(value.size()), result.data(), size, nullptr, nullptr);
+ return result;
+}
+
+const char* stateName(remoteplay::SessionState state) {
+ switch (state) {
+ case remoteplay::SessionState::Idle: return "idle";
+ case remoteplay::SessionState::Connecting: return "connecting";
+ case remoteplay::SessionState::WaitingFirstFrame: return "waiting-first-frame";
+ case remoteplay::SessionState::Streaming: return "streaming";
+ case remoteplay::SessionState::LoginPinRequired: return "login-pin-required";
+ case remoteplay::SessionState::Failed: return "failed";
+ case remoteplay::SessionState::Stopping: return "stopping";
+ }
+ return "?";
+}
+
+} // namespace
+
+int wmain(int argc, wchar_t** argv) {
+ std::string codec = "keep";
+ unsigned bitrate = 0;
+ int seconds = 20;
+ std::filesystem::path profile;
+ for (int i = 1; i < argc; ++i) {
+ const std::wstring arg = argv[i];
+ if (arg == L"--codec" && i + 1 < argc) codec = narrow(argv[++i]);
+ else if (arg == L"--bitrate" && i + 1 < argc) bitrate = unsigned(wcstoul(argv[++i], nullptr, 10));
+ else if (arg == L"--seconds" && i + 1 < argc) seconds = _wtoi(argv[++i]);
+ else if (arg == L"--profile" && i + 1 < argc) profile = argv[++i];
+ }
+ if (profile.empty()) {
+ // The GUI saves one <32-hex-account-id>.dat per paired console; fall
+ // back to the first one when the caller does not name a profile.
+ const auto directory = remoteplay::profileDirectory();
+ profile = directory / L"remoteplay-profile.dat";
+ if (!std::filesystem::exists(profile)) {
+ std::error_code error;
+ for (const auto& entry : std::filesystem::directory_iterator(directory, error)) {
+ const auto stem = entry.path().stem().wstring();
+ const bool hex = stem.size() == 32 && std::all_of(stem.begin(), stem.end(), [](wchar_t c) {
+ return (c >= L'0' && c <= L'9') || (c >= L'a' && c <= L'f');
+ });
+ if (hex && entry.path().extension() == L".dat") { profile = entry.path(); break; }
+ }
+ }
+ }
+ std::cout << "profile=" << profile.string() << "\n";
+ auto request = remoteplay::loadProfile(profile);
+ if (!request) { std::cout << "PROBE profile-unavailable\n"; return 2; }
+ if (codec == "h264") request->video.codec = remoteplay::Codec::H264;
+ else if (codec == "h265") request->video.codec = remoteplay::Codec::H265;
+ else if (codec == "h265hdr") request->video.codec = remoteplay::Codec::H265Hdr;
+ if (bitrate != 0) request->video.bitrateKbps = bitrate;
+ std::cout << "host=" << request->host << " codec=" << int(request->video.codec)
+ << " bitrate=" << request->video.bitrateKbps << " profile=" << request->video.width << "x"
+ << request->video.height << "@" << request->video.fps << "\n";
+
+ gfx::D3D12DeviceContext context;
+ gfx::DeviceContextDesc desc;
+ Status status;
+ if (!context.initialize(desc, status)) { std::cout << "PROBE no-d3d12\n"; return 3; }
+ context.device()->AddRef();
+
+ source::RemotePlayConnectDesc connect;
+ connect.request = std::move(*request);
+ connect.decodeMode = source::RemotePlayConnectDesc::DecodeMode::Automatic;
+ connect.decodeDevice = std::shared_ptr<ID3D12Device>(context.device(), [](ID3D12Device* device) { device->Release(); });
+
+ source::RemotePlaySessionSource session;
+ if (!session.connect(std::move(connect))) { std::cout << "PROBE connect-refused\n"; return 4; }
+
+ pipeline::FramePacket packet;
+ const AVFrame* frame = nullptr;
+ uint64_t frames = 0;
+ int lastState = -1;
+ std::wstring lastMessage;
+ const auto deadline = std::chrono::steady_clock::now() + std::chrono::seconds(seconds);
+ while (std::chrono::steady_clock::now() < deadline) {
+ const auto result = session.read(packet, &frame);
+ if (result == source::SourceReadStatus::Frame) ++frames;
+ else if (result == source::SourceReadStatus::Error) break;
+ const auto snapshot = session.sessionSnapshot();
+ if (int(snapshot.state) != lastState) {
+ lastState = int(snapshot.state);
+ std::cout << "state=" << stateName(snapshot.state) << " t="
+ << std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - (deadline - std::chrono::seconds(seconds))).count() << "s\n";
+ }
+ if (snapshot.state == remoteplay::SessionState::LoginPinRequired) { std::cout << "PROBE pin-required\n"; break; }
+ // A Failed session state must NOT end the probe: the recovery layer owns
+ // the retry (including the RP_IN_USE backoff), so the deadline decides.
+ const auto recovery = session.recoveryStatus();
+ if (recovery.active && recovery.message != lastMessage) {
+ lastMessage = recovery.message;
+ std::wcout << L"recovery: " << recovery.message << L"\n";
+ }
+ std::this_thread::sleep_for(std::chrono::milliseconds(5));
+ }
+ const auto snapshot = session.sessionSnapshot();
+ std::cout << "RESULT frames=" << frames << " state=" << stateName(snapshot.state)
+ << " received=" << snapshot.video.accessUnits << " decoded=" << snapshot.decodedFrames
+ << " waitingIdr=" << (snapshot.video.waitingForIdr ? 1 : 0) << " idrRequests=" << snapshot.video.idrRequests
+ << " errorCode=" << snapshot.errorCode << " recoveredFrames=" << snapshot.framesLost
+ << " hwDecode=" << (snapshot.hardwareDecode ? 1 : 0) << " decodeFallback=" << (snapshot.decodeFallback ? 1 : 0) << "\n";
+ const auto recovery = session.recoveryStatus();
+ if (!recovery.message.empty()) std::wcout << L"recovery: " << recovery.message << L"\n";
+ session.close();
+ return frames > 30 ? 0 : 1;
+}