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): distinguish applied bitrate from received video rate
Veyra Goal Agent082db52111b1
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 98d0869d..803f651a 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -583,6 +583,10 @@ if(VEYRA_FFMPEG_ROOT AND EXISTS "${VEYRA_FFMPEG_ROOT}/include/libavformat/avformadd_executable(veyra WIN32 apps/veyra/main.cpp apps/veyra/ui/AppShell.cpp apps/veyra/ui/CapturePanel.cpp apps/veyra/ui/SubtitleOverlay.cpp apps/veyra/SettingsWindow.cpp apps/veyra/TelemetryWindow.cpp)if(VEYRA_ENABLE_REMOTEPLAY)add_executable(veyra_ps5_hw_image_tests tests/integration/Ps5HardwareImageTests.cpp)+ add_executable(veyra_ps5_quality_tests tests/integration/Ps5SourceQualityTests.cpp)+ target_compile_features(veyra_ps5_quality_tests PRIVATE cxx_std_20)+ target_compile_definitions(veyra_ps5_quality_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)+ target_link_libraries(veyra_ps5_quality_tests PRIVATE veyra_engine)target_compile_features(veyra_ps5_hw_image_tests PRIVATE cxx_std_20)target_compile_definitions(veyra_ps5_hw_image_tests PRIVATE NOMINMAX WIN32_LEAN_AND_MEAN)target_link_libraries(veyra_ps5_hw_image_tests PRIVATE veyra_engine)diff --git a/apps/veyra/TelemetryWindow.cpp b/apps/veyra/TelemetryWindow.cppindex 9578fdc5..084239c9 100644--- a/apps/veyra/TelemetryWindow.cpp+++ b/apps/veyra/TelemetryWindow.cpp@@ -18,6 +18,7 @@ void refresh(){auto s=engine->snapshot();const wchar_t* names[]={L"上传/颜色const auto flowName=s.applied.flow==engine::FlowQuality::Performance?L"性能":s.applied.flow==engine::FlowQuality::Balanced?L"平衡":L"质量";const auto& f=s.metrics.flow;const auto& c=f.counters;if(s.remotePlay){const auto& r=s.remoteStream;+ o<<L"\r\n本次连接请求:"<<r.requestedProfile.width<<L"×"<<r.requestedProfile.height<<L" / "<<r.requestedProfile.fps<<L" fps / "<<(r.requestedProfile.codec==remoteplay::Codec::H264?L"H.264":r.requestedProfile.codec==remoteplay::Codec::H265Hdr?L"H.265 HDR":L"H.265")<<L" / "<<r.requestedProfile.bitrateKbps/1000.0<<L" Mbps(并非固定实际流量)";o<<L"\r\nPS5完整视频接收 "<<r.receivedFps<<L" fps / 实际解码 "<<r.decodedFps<<L" fps / 有效码率 "<<r.videoMbps<<L" Mbps"<<L"\r\n实际解码路径:"<<(!r.decodeConfirmed?L"尚未确认":r.hardwareDecode?L"D3D12VA 硬解":r.decodeFallback?L"CPU软件(硬解回退)":L"CPU软件")<<L"\r\n真实解码均值 / P95 "<<value(r.decodeMeanMs)<<L" / "<<value(r.decodeP95Ms)<<L" ms;接收后等待 "<<value(r.ingressWaitMeanMs)diff --git a/apps/veyra/ui/AppShell.cpp b/apps/veyra/ui/AppShell.cppindex 8146468e..0b554d10 100644--- a/apps/veyra/ui/AppShell.cpp+++ b/apps/veyra/ui/AppShell.cpp@@ -344,6 +344,8 @@ case RemotePlay:veyra::ui::showRemotePlayPanel(hwnd,[](veyra::source::RemotePlayresult.active=s.remotePlay&&(s.running||s.transport==veyra::engine::TransportState::Opening||s.transport==veyra::engine::TransportState::Stopping);result.message=s.failed?s.status:s.remoteRecovering?s.remoteRecoveryMessage:s.remotePlay&&s.running?L"PS5 画面已进入播放;关闭此面板不停止串流。":result.active?s.status:L"PS5 串流已停止,可以重新连接。";if(s.remotePlay&&s.running){+ if(!s.failed&&!s.remoteRecovering){const auto& r=s.remoteStream;const auto& p=r.requestedProfile;+ result.message=std::format(L"生效:{}p / {} fps / {} / 请求 {} Mbps\n实收视频 {:.1f} Mbps · 格式/码率更改后需点重连",p.height,p.fps,p.codec==veyra::remoteplay::Codec::H264?L"H.264":p.codec==veyra::remoteplay::Codec::H265Hdr?L"H.265 HDR":L"H.265",p.bitrateKbps/1000,r.videoMbps);}const auto c=remoteController.capabilities();if(remoteViewOnly)result.message+=L"\n仅观看:电脑输入已关闭,手柄由 PS5 处理。";else if(!c.connected)result.message+=L"\n未检测到电脑手柄。";diff --git a/apps/veyra/ui/RemotePlayPanel.cpp b/apps/veyra/ui/RemotePlayPanel.cppindex 5a899b12..9c0ec3f3 100644--- a/apps/veyra/ui/RemotePlayPanel.cpp+++ b/apps/veyra/ui/RemotePlayPanel.cpp@@ -105,8 +105,8 @@ case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);for(auto label:{L"自动 · 优先硬解",L"CPU 软件解码",L"D3D12VA 硬件解码"})SendDlgItemMessageW(h,DecodeChoice,CB_ADDSTRING,0,LPARAM(label));SendDlgItemMessageW(h,DecodeChoice,CB_SETCURSEL,std::min(2u,GetPrivateProfileIntW(L"RemotePlay",L"DecodeMode",0,(remoteplay::profileDirectory()/L"settings.ini").c_str())),0);add(L"STATIC",L"PS5 地址",100,0,20,21,130,25);add(L"STATIC",L"PSN Account ID",101,0,20,65,130,25);- add(L"STATIC",L"8 位配对码",102,0,20,109,130,25);add(L"STATIC",L"串流格式",103,0,20,153,130,25);add(L"STATIC",L"登录 PIN(可选)",104,0,20,253,135,25);- add(L"STATIC",L"码率",105,0,20,298,130,25);add(L"COMBOBOX",L"",Host,CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_TABSTOP);SendDlgItemMessageW(h,Host,CB_LIMITTEXT,253,0);+ add(L"STATIC",L"8 位配对码",102,0,20,109,130,25);add(L"STATIC",L"格式(重连生效)",103,0,20,153,130,25);add(L"STATIC",L"登录 PIN(可选)",104,0,20,253,135,25);+ add(L"STATIC",L"码率请求",105,0,20,298,130,25);add(L"COMBOBOX",L"",Host,CBS_DROPDOWN|CBS_AUTOHSCROLL|WS_TABSTOP);SendDlgItemMessageW(h,Host,CB_LIMITTEXT,253,0);for(int id:{Account,PairPin,LoginPin}){add(L"EDIT",L"",id,WS_TABSTOP|ES_AUTOHSCROLL|((id==PairPin||id==LoginPin)?ES_PASSWORD:0));SendDlgItemMessageW(h,id,EM_SETLIMITTEXT,id==Host?253:id==Account?24:8,0);}add(L"COMBOBOX",L"",Quality,CBS_DROPDOWNLIST|WS_TABSTOP);for(auto label:{L"720p · 30 fps",L"720p · 60 fps",L"1080p · 30 fps",L"1080p · 60 fps"})SendDlgItemMessageW(h,Quality,CB_ADDSTRING,0,LPARAM(label));SendDlgItemMessageW(h,Quality,CB_SETCURSEL,3,0);add(L"COMBOBOX",L"",CodecChoice,CBS_DROPDOWNLIST|WS_TABSTOP);for(auto label:{L"H.264 · SDR",L"H.265 · SDR",L"H.265 · HDR(实验)"})SendDlgItemMessageW(h,CodecChoice,CB_ADDSTRING,0,LPARAM(label));SendDlgItemMessageW(h,CodecChoice,CB_SETCURSEL,0,0);@@ -131,8 +131,8 @@ case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);{Host,L"PS5的局域网IP或已保存主机。找不到时可手填,别把PSN昵称填这里。"},{Account,L"配对用的Base64 PSN Account ID,不是在线昵称。名字相同不代表身份证号码相同。"},{PairPin,L"PS5远程游玩页面显示的8位配对码,有时效。过期了再领一张票。"},- {Quality,L"选择串流分辨率和帧率。请求的是PS5输出,不是增强后目标。"},- {CodecChoice,L"H.264兼容性好,H.265通常更省码率。HDR需要PS5实际输出HDR;关闭增强且Windows HDR开启时原生显示,开启增强则先转SDR,别把两种效果认错。"},+ {Quality,L"选择PS5发送的分辨率和帧率。更改后点击应用设置并重连;当前生效值看下方状态,不要被下拉框骗了。"},+ {CodecChoice,L"H.264兼容性好,H.265通常更省码率;更改后重连生效。HDR需要PS5实际输出HDR;关闭增强且Windows HDR开启时原生显示,开启增强则先转SDR,别把两种效果认错。"},{Pair,L"用账户ID和8位码注册主机,凭据在本机加密保存。"},{Connect,L"使用保存的配对信息连接PS5,把画面送进当前增强链路。"},{Cancel,L"取消当前操作或断开串流,让连接安静收工。"},@@ -140,12 +140,12 @@ case WM_CREATE:{window=h;closing=false;font=makeFont(h);titleTheme(h);{Wake,L"尝试唤醒待机主机;需要已配对且PS5允许联网唤醒。关机不是待机,叫不醒别硬喊。"},{LoginPin,L"主机要求登录PIN时填写。它不是前面的8位配对码。"},{SendPin,L"把登录PIN发给当前串流会话。"},- {Bitrate,L"串流码率越高,压缩损失通常越少,网络负担也更重。别把Wi-Fi喂撑。"},+ {Bitrate,L"这是发给PS5的带宽请求,重连后生效。主机会按画面和网络决定实际码率,选100不代表必须跑满100。下方分别显示本次请求和实收视频码率。"},{Forget,L"删除本机保存的这台主机配对信息;以后需要重新配对。"},{ViewOnly,L"只观看,不向PS5转发电脑手柄输入。不能保证同账号手柄仍能直连主机,这是PS5会话规则。"},{Calibrate,L"手柄放稳后校准陀螺仪,让镜头别自己散步。"},{DecodeChoice,L"自动优先硬解,失败回软件;强制硬解失败会报错。软件解码主要用CPU,硬解用视频解码单元。重连生效。"}});- buttons();arrange();SetTimer(h,1,100,nullptr);+ watching=connectionStatus().active;buttons();arrange();SetTimer(h,1,100,nullptr);if(auto auth=remoteplay::loadPsnAuthorization()){psnRefreshAfter=GetTickCount64()+300000;const bool fillAccount=currentProfile.empty();@@ -177,7 +177,7 @@ case WM_TIMER:if(busy&&done){if(worker.joinable())worker.join();busy=false;OutcopsnRefreshAfter=GetTickCount64()+300000;if(remoteplay::loadPsnAuthorization())launch([](std::stop_token stop){auto result=remoteplay::refreshPsn(stop);Outcome out;out.message=result.ok?L"PSN授权已就绪;已配对主机直接连接。":std::format(L"PSN刷新失败({});局域网配对不受影响。",result.error);return out;});}- if(window&&watching&&!busy){auto state=connectionStatus();SetDlgItemTextW(h,StatusText,state.message.c_str());SetDlgItemTextW(h,Cancel,state.active?L"断开连接":L"取消操作");EnableWindow(GetDlgItem(h,Cancel),state.active);if(!state.active)watching=false;}return 0;+ if(window&&watching&&!busy){auto state=connectionStatus();SetDlgItemTextW(h,Connect,state.active?L"应用设置并重连":L"连接并观看");SetDlgItemTextW(h,StatusText,state.message.c_str());SetDlgItemTextW(h,Cancel,state.active?L"断开连接":L"取消操作");EnableWindow(GetDlgItem(h,Cancel),state.active);if(!state.active)watching=false;}return 0;case WM_COMMAND:switch(LOWORD(wp)){case LoginPsn:{if(busy)break;auto url=remoteplay::psnLoginUrl();if(INT_PTR(ShellExecuteW(h,L"open",url.c_str(),nullptr,nullptr,SW_SHOWNORMAL))>32){psnLoginStarted=GetTickCount64();SetDlgItemTextW(h,StatusText,L"在Sony网页完成登录,复制最终回调URL,再点“从剪贴板提交登录结果”。");}else SetDlgItemTextW(h,StatusText,L"无法打开浏览器,请检查默认浏览器设置。");break;}case CompletePsn:{diff --git a/docs/PS5_SOURCE_QUALITY_AUDIT_2026-09-13.md b/docs/PS5_SOURCE_QUALITY_AUDIT_2026-09-13.mdnew file mode 100644index 00000000..eb8c2dde--- /dev/null+++ b/docs/PS5_SOURCE_QUALITY_AUDIT_2026-09-13.md@@ -0,0 +1,61 @@+# PS5 原始串流画质与码率审计++基线 `5c3fad0`,分支 `codex/ps5-source-quality`。用户选择 100 Mbps,但任务管理器只有约 13–16 Mbps,要求从原始输入解决游玩模糊,不用 SR 掩盖。++## 结论与未完成边界++本机实测没有发现 Veyra 把 100 Mbps 截成 15 Mbps。UI 的 100000 Kbps 原样经过 NativeConnectRequest → ChiakiConnectInfo.video_profile.bitrate → launch_spec.bw_kbps_sent → network.bwKbpsSent。PS5 返回 target_bitrate=97087000,实际视频随场景变化,说明请求不是固定 CBR 流量。15 Mbps 对照返回14563000,证明请求值确实改变主机目标。++**这不证明用户的游玩模糊已经解决。** 用户允许实测,但收到的画面是装备菜单,后续已请求切换实际游戏场景,尚未收到确认。菜单照片不能代表树叶运动、镜头转动、暗场或长时码率回退。不能宣称已提高原始编码画质、H.265 必定更清晰、排除全部丢包或强制主机发满 100 Mbps。++## 实机证据++每轮35秒,RTX 5070 / D3D12VA硬解,1920×1080 / 30 fps。只在测量结束后通过共享颜色路径保存一张1:1 PNG;无SR、NR、FG、NVOF,无重编码、无配对文件修改、无主机输入或电源命令。++| 请求 | PS5目标反馈 | 稳态有效视频均值 | 解码帧 | framesLost / callbackRejected / error |+| --- | --- | --- | --- | --- |+| H.264,100 Mbps | 97.087 Mbps | 10.018 Mbps | 1002 | 0 / 0 / 0 |+| H.265,100 Mbps | 97.087 Mbps | 5.956 Mbps | 992 | 0 / 0 / 0 |+| H.264,15 Mbps | 14.563 Mbps | 5.242 Mbps | 996 | 0 / 0 / 0 |++均值按10秒后有效视频负载字节与单调时钟计算,不含音频、FEC和UDP协议开销,不能与任务管理器进程流量逐点相等。两种100 Mbps请求的完整1920×1080 PNG已查看,文字和服装细节可辨;人物与飘落树叶随时间变化,非逐像素同帧,未做PSNR或宣称其中一种胜出。H.265流量更低也不能单凭流量说更糊。range/matrix/transfer均有实际元数据,日志range=1、matrix=2、transfer=2、display709=true,未标assumed。++本地忽略证据:`logs/ps5-quality-h264-30-100/`、`logs/ps5-quality-h265-30-100/`、`logs/ps5-quality-h264-30-15/`,各自含 `source.log` / `source.png`,同级 `*-result.log`。不得把游戏图像和日志提交源码。++## 已修复的显示问题++原面板更改编码、码率、分辨率不会实时改变已连接会话,却只显示新的下拉值,容易把待应用值当作当前值。现在:++- PS5连接状态显示真正的本次请求:分辨率、帧率、codec、请求Mbps,与实际接收视频Mbps分开。+- 活跃连接的按钮显示“应用设置并重连”;格式标签和悬停说明明确重连生效。不会静默中断用户正在玩的串流。+- 重新打开面板时继续显示正在运行会话的状态,不再只能等下一次手动连接。+- 专业诊断和session-start日志补齐本次实际请求,包括HDR codec区别。未更改任何用户已保存的选择或默认画质,也未改像素处理算法。++涉及 `RemotePlayPanel.cpp`、`AppShell.cpp`、`TelemetryWindow.cpp`、`RemotePlaySource.cpp`。++## 诊断实现与性能边界++`ChiakiBackend` 增加可选品质反馈观察,仅 `VEYRA_TEST_PS5_QUALITY_TRACE` 存在时开启上游verbose格式化;只解析固定前缀中的数值目标和计数,不打印原始上游字符串/密钥。正常软件不打开逐包verbose,不添加常驻大量日志。未修改第三方Chiaki源码、协议、拥塞反馈、码率夹限或SDK。++新增 `tests/integration/Ps5SourceQualityTests.cpp`,CMake目标 `veyra_ps5_quality_tests`,组合真实产品Source/颜色图/PNG sink。该工具不实现第二套播放器。++## 构建与检查++- `cmd /c out/remoteplay/build-source-quality.cmd`:构建上述诊断目标成功(脚本为忽略目录本机命令包装)。等价 `cmake --build out/remoteplay/product-repair --target veyra_ps5_quality_tests -j8`,先初始化MSVC环境。+- `out/remoteplay/product-repair/veyra_ps5_quality_tests.exe --last-paired-ps5 logs/ps5-quality-h264-30-100 0 30 100000`,H.265参数为 `1 30 100000`,低码率对照为 `0 30 15000`;三轮exit0、captured=1。所有增强关闭,NGX初始化被disabled-feature配置跳过,本轮没有执行新的NR/FG Create/Evaluate。+- `cmd /c out/remoteplay/build-extra-delay.cmd`:主程序构建成功,`logs/ps5-quality-product-build.log`。保留既存CMake依赖探测警告及FFmpeg头文件C4244警告。+- `veyra_repair_contract_tests.exe`:103 checks / 0 failures,`logs/ps5-quality-contract-result.log`。`git diff --check`通过。UI新文字尚未做真实鼠标/视觉回归。++## 下一步:定位游玩时的质量损失++1. 退出装备菜单,使用同一实际游戏位置及转镜头路径,分别H.264/H.265、相同fps/码率与显示尺寸;保存未增强原始解码帧和对应本机呈现。不能只用静止菜单或两个不同时刻的随机截图当画质胜负证据。+2. 区分源头已经模糊、局部解码损坏、颜色错误和播放器显示缩放。当前PresentBlit正常稳态是一次双线性contain/zoom,ScaleBlit同尺寸用直接Load,未静态发现持续额外降分辨率;窗口动画期间确有保留buffer的临时DXGI缩放。需要实际失真时对照,不凭静态代码排除运行时错误。+3. 只有原始输入已经变差才进一步研究PS5编码与网络自适应;如果输入清楚而显示糊,修本机呈现。不能为追求100 Mbps数字伪造丢包、关闭拥塞反馈、加入填充流量,或宣称某个未证实协议字段能强制无损/2K/4K。+4. HDR/SDR是独立颜色检查,不能用打开HDR作为“更清晰”的万能修复。保留用户当前选择,先取得游玩场景证据。++## 一手来源++- 本机固定Chiaki commit `0e16950165f06e5c3291537c2eeba6e852be7120`:`lib/src/launchspec.c`、`streamconnection.c`、`congestioncontrol.c`;Veyra目前使用其带既有MSVC/metadata补丁的stage。+- 在线核对:[上游launchspec](https://github.com/streetpea/chiaki-ng/blob/main/lib/src/launchspec.c)、[上游连接与目标反馈](https://github.com/streetpea/chiaki-ng/blob/main/lib/src/streamconnection.c)。在线main可能变化,本机固定版本及真实实测为当前证据,不自动升级依赖。++未推送、未发布、未更换运行DLL。当前交付仅确认请求链路和修正显示;游玩模糊仍待实际场景定位。diff --git a/docs/WORKLOG.md b/docs/WORKLOG.mdindex b6009da4..e9bd9637 100644--- a/docs/WORKLOG.md+++ b/docs/WORKLOG.md@@ -1772,3 +1772,9 @@ apps/veyra/SettingsWindow.cpp调整布局;apps/veyra/ui/AppShell.cpp新增音构建 cmd /c out/remoteplay/build-extra-delay.cmd 成功;cmd /c out/remoteplay/build-clock-tests.cmd 核心73/73;cmd /c out/remoteplay/build-boundary-clock.cmd 后边界通过,合同103/103。实机使用 veyra_live_presentation_tests.exe --last-paired-ps5 <目录> --reconnect:第一轮恢复成功但单点FG性能断言失败;第二轮暴露PS5旧会话短暂RP_IN_USE导致放弃,修成已有恢复预算内继续退避。第三轮50秒PASS:断流前已播放、第二次重连成功、730次恢复后健康采样,NR/SR4K/DLSS2X及WASAPI音频恢复。NR与DLSSG Create=0x1/SEH=0,DLSSG evaluates=1276/Release=0x1。另 --cancel-reconnect PASS,主动停止后idle且不重连。证据 logs/ps5-stream-reconnect3-result.log、对应engine.log及logs/ps5-stream-cancel-result.log;详细失败、命令及修改文件见 docs/PS5_STREAM_RECOVERY_2026-09-13.md。这是可控断流与自动恢复验证,不是最初自然断流根因已查明,也不等于长时PS5/HDR/手柄触觉验收。没有更换运行DLL、没有提交SDK/配对/日志、未推送发布。下一步用户重开桌面PS5测试版长时游玩,如再断流带新诊断定位上游原因。++## 2026-09-13 PS5 原始码率/画质审计++基线5c3fad0,分支codex/ps5-source-quality。用户允许源头实测,禁用SR/NR/FG:H264 1080p30请求100Mbps,PS5反馈目标97.087Mbps,菜单有效视频均值10.018;H265同请求均值5.956;H264请求15Mbps,主机目标14.563、有效均值5.242。各35秒、硬解、1920×1080,完整帧丢失/回调拒绝/错误均0,保存1:1源图已查看。不是Veyra把100截成15;实际码率为内容/主机决定,不能由未跑满推导画质低,也不能靠菜单证明游戏清晰。已请求用户切换实际游戏场景,游玩模糊尚未定位。++修正PS5面板显示待选值却不提示重连的误导:展示本次真正请求/实收视频码率、明确应用设置并重连、重开面板继续跟踪会话;日志与专业诊断加入请求码率及codec。诊断工具仅显式opt-in读取主机数值品质反馈,正常不启用逐包verbose,无原始上游字符串/密钥输出。构建build-source-quality.cmd与build-extra-delay.cmd成功,合同103/103,diff检查通过。三轮实机命令、PNG、日志路径及待验收边界见docs/PS5_SOURCE_QUALITY_AUDIT_2026-09-13.md。没有改像素算法/运行DLL/用户配对,未执行增强Create/Evaluate、未做UI视觉回归、未推送发布。下一步必须是实际游玩原图与呈现对照,不能宣称画质已修好。diff --git a/include/veyra/remoteplay/ChiakiBackend.h b/include/veyra/remoteplay/ChiakiBackend.hindex ed50479c..3ad47a43 100644--- a/include/veyra/remoteplay/ChiakiBackend.h+++ b/include/veyra/remoteplay/ChiakiBackend.h@@ -41,6 +41,8 @@ struct NativeSnapshot {uint64_t callbackRejected=0,packetReceived=0,packetLost=0;uint64_t transportErrors=0,assemblyErrors=0;bool automaticRetryAllowed=true;+ int64_t serverTargetBitrate=-1; // Raw upstream field; diagnostic opt-in only.+ uint64_t qualityReports=0;};BackendResult initializeChiaki();class ChiakiBackend {diff --git a/src/remoteplay/ChiakiBackend.cpp b/src/remoteplay/ChiakiBackend.cppindex 7acf6302..583d80aa 100644--- a/src/remoteplay/ChiakiBackend.cpp+++ b/src/remoteplay/ChiakiBackend.cpp@@ -17,6 +17,8 @@#include <limits>#include <mutex>#include <thread>+#include <cstdio>+#include <cstdlib>namespace veyra::remoteplay {static_assert(CHIAKI_PSN_ACCOUNT_ID_SIZE == 8);static_assert(CHIAKI_SESSION_AUTH_SIZE == 16);@@ -58,6 +60,8 @@ struct ChiakiBackend::Impl {std::atomic<std::uint64_t> warnings=0,errors=0,videoCallbacks=0,audioCallbacks=0;std::atomic<int> quitReason=0,apiError=0;std::atomic<uint64_t> callbackRejected=0,transportErrors=0,assemblyErrors=0;+ std::atomic<int64_t> serverTargetBitrate=-1;+ std::atomic<uint64_t> qualityReports=0;// Only the upstream audio/Opus callback thread reads/writes these fields.std::uint32_t channels=0,rate=0;std::uint64_t sampleIndex=0;@@ -68,6 +72,10 @@ struct ChiakiBackend::Impl {static void logCallback(ChiakiLogLevel level,const char* message,void* user) noexcept {auto& self=*static_cast<Impl*>(user);+ if(message&&level==CHIAKI_LOG_VERBOSE){+ int target=-1;+ if(std::sscanf(message,"StreamConnection received connection quality: target_bitrate=%d,",&target)==1&&target>=0){self.serverTargetBitrate=target;++self.qualityReports;}+ }// Raw upstream log strings/hexdumps may contain keys. Do not forward them.if(level==CHIAKI_LOG_ERROR)++self.errors;if(level==CHIAKI_LOG_WARNING)++self.warnings;@@ -163,7 +171,10 @@ BackendResult ChiakiBackend::start(const NativeConnectRequest& request,SessionInif(!validHost(request.host)||request.video.validate()||token.generation()==0)return {false,-1101,"validate_connect"};auto init=initializeChiaki();if(!init.ok)return init;p_=std::make_unique<Impl>(std::move(token));auto& s=*p_;s.host=request.host;s.profile=request.video;- chiaki_log_init(&s.log,CHIAKI_LOG_WARNING|CHIAKI_LOG_ERROR,Impl::logCallback,&s);+ // Verbose formatting has per-packet overhead: enable only for explicit diagnostics.+ // Callback above whitelists numeric quality fields and never forwards raw text.+ const bool qualityTrace=std::getenv("VEYRA_TEST_PS5_QUALITY_TRACE")!=nullptr;+ chiaki_log_init(&s.log,CHIAKI_LOG_WARNING|CHIAKI_LOG_ERROR|(qualityTrace?CHIAKI_LOG_VERBOSE:0),Impl::logCallback,&s);ChiakiConnectInfo info{};info.ps5=true;info.host=s.host.c_str();std::memcpy(info.regist_key,request.credentials.registrationKey.data(),request.credentials.registrationKey.size());std::memcpy(info.morning,request.credentials.sessionKey.data(),request.credentials.sessionKey.size());@@ -265,6 +276,7 @@ NativeSnapshot ChiakiBackend::snapshot()const{auto& s=*p_;NativeSnapshot out{s.started.load(),s.connected.load(),s.warnings.load(),s.errors.load(),s.videoCallbacks.load(),s.audioCallbacks.load(),s.quitReason.load(),s.apiError.load()};out.callbackRejected=s.callbackRejected;out.transportErrors=s.transportErrors;out.assemblyErrors=s.assemblyErrors;+ out.serverTargetBitrate=s.serverTargetBitrate;out.qualityReports=s.qualityReports;// Upstream packet window may reset itself; do not label this cumulative UDP.if(s.initialized)chiaki_packet_stats_get(&s.session.stream_connection.packet_stats,false,&out.packetReceived,&out.packetLost);// After a stopped session the PS5 may briefly still report RP_IN_USE.diff --git a/src/source/RemotePlaySource.cpp b/src/source/RemotePlaySource.cppindex 7762f037..f8f5f6aa 100644--- a/src/source/RemotePlaySource.cpp+++ b/src/source/RemotePlaySource.cpp@@ -143,9 +143,9 @@ bool RemotePlaySource::connect(const RemotePlayConnectDesc& desc)decoderReady_ = false;waitingForFirstFrame_ = true;pendingOpenFlag_ = true;- veyra::log::info("remoteplay", std::format("session started host={} profile={}x{}@{} codec={}",+ veyra::log::info("remoteplay", std::format("session started host={} profile={}x{}@{} codec={} requestedBitrateKbps={} (bandwidth request, not measured throughput)",request_.host, request_.video.width, request_.video.height, request_.video.fps,- request_.video.codec == remoteplay::Codec::H264 ? "H264" : "H265"));+ request_.video.codec == remoteplay::Codec::H264 ? "H264" : request_.video.codec == remoteplay::Codec::H265Hdr ? "H265_HDR" : "H265",request_.video.bitrateKbps));return true;}diff --git a/tests/integration/Ps5SourceQualityTests.cpp b/tests/integration/Ps5SourceQualityTests.cppnew file mode 100644index 00000000..1fb16871--- /dev/null+++ b/tests/integration/Ps5SourceQualityTests.cpp@@ -0,0 +1,56 @@+#include "veyra/remoteplay/ProfileStore.h"+#include "veyra/source/RemotePlaySource.h"+#include "veyra/pipeline/EnhanceGraph.h"+#include "veyra/sink/ImageExportSink.h"+#include "veyra/gfx/D3D12DeviceContext.h"+#include "veyra/gfx/CommandSlotRing.h"+#include "veyra/Log.h"+#include <chrono>+#include <thread>+#include <iostream>+extern "C" {+#include <libavutil/frame.h>+}+using namespace veyra;+// Local, opt-in source diagnostic. Never rewrites pairing or sends console input.+int wmain(int argc,wchar_t** argv){+ if(argc!=6||std::wstring_view(argv[1])!=L"--last-paired-ps5")return 2;+ const int codec=_wtoi(argv[3]),fps=_wtoi(argv[4]),kbps=_wtoi(argv[5]);+ if((codec!=0&&codec!=1)||(fps!=30&&fps!=60)||kbps<5000||kbps>100000)return 2;+ const auto dir=remoteplay::profileDirectory();wchar_t name[80]{};+ GetPrivateProfileStringW(L"RemotePlay",L"LastProfile",L"",name,80,(dir/L"settings.ini").c_str());+ std::wstring profile=name;if(profile.empty()||profile.find_first_of(L"/\\:")!=profile.npos)return 3;+ auto saved=remoteplay::loadProfile(dir/profile);if(!saved)return 4;+ std::filesystem::create_directories(argv[2]);Logger::instance().openFile((std::filesystem::path(argv[2])/L"source.log").wstring());Logger::instance().setConsoleEnabled(false);+ _putenv_s("VEYRA_TEST_PS5_QUALITY_TRACE","1");+ CoInitializeEx(nullptr,COINIT_MULTITHREADED);gfx::D3D12DeviceContext ctx;gfx::CommandSlotRing ring;Status st;+ if(!ctx.initialize({},st)||!ring.initialize(ctx.device(),ctx.directQueue(),ctx.fence(),ctx.fenceEvent(),6,st))return 5;+ source::RemotePlaySource source;source::RemotePlayConnectDesc desc;desc.request=std::move(*saved);+ desc.request.video={1920,1080,uint32_t(fps),uint32_t(kbps),codec?remoteplay::Codec::H265:remoteplay::Codec::H264};desc.decodeMode=source::RemotePlayConnectDesc::DecodeMode::Hardware;+ ctx.device()->AddRef();desc.decodeDevice={ctx.device(),[](ID3D12Device* d){d->Release();}};+ if(!source.connect(desc))return 6;+ const auto start=std::chrono::steady_clock::now();int last=-1;uint64_t frames=0,baseBytes=0;bool captured=false,failed=false;+ auto measuredAt=start;AVFrame* picture=nullptr;pipeline::ColorDescription color;+ while(std::chrono::steady_clock::now()-start<std::chrono::seconds(35)){+ pipeline::FramePacket p;const AVFrame* frame=nullptr;const auto result=source.read(p,&frame);+ if(result==source::SourceReadStatus::Error){std::cout<<"SOURCE_FAILED code="<<source.sessionSnapshot().errorCode<<std::endl;failed=true;break;}+ const auto now=std::chrono::steady_clock::now();const int seconds=int(std::chrono::duration_cast<std::chrono::seconds>(now-start).count());+ if(result==source::SourceReadStatus::Frame&&frame){++frames;if(seconds>=25&&!picture){picture=av_frame_clone(frame);color=p.colorInfo;}}+ float pcm[960];source.pullAudio(pcm,480,nullptr);+ if(seconds!=last&&seconds%5==0){last=seconds;auto s=source.sessionSnapshot();auto n=source.nativeSnapshot();+ std::cout<<"QUALITY t="<<seconds<<" codec="<<codec<<" fps="<<fps<<" requestKbps="<<kbps<<" decoded="<<s.decodedFrames<<" videoMbps="<<s.videoMbps<<" serverTargetRaw="<<n.serverTargetBitrate<<" reports="<<n.qualityReports<<" loss="<<s.framesLost<<" rejected="<<n.callbackRejected<<" width="<<source.info().width<<" height="<<source.info().height<<std::endl;+ if(seconds==10){baseBytes=s.receivedBytes;measuredAt=now;}+ }+ if(result!=source::SourceReadStatus::Frame)std::this_thread::sleep_for(std::chrono::milliseconds(1));+ }+ auto s=source.sessionSnapshot();const double elapsed=std::chrono::duration<double>(std::chrono::steady_clock::now()-measuredAt).count();+ std::cout<<"SOURCE_MEAN Mbps="<<double(s.receivedBytes-baseBytes)*8/elapsed/1e6<<" frames="<<frames<<" errors="<<s.errorCode<<std::endl;+ // Single diagnostic readback after measurement; no enhancement or resizing.+ if(picture){pipeline::EnhanceGraph graph(ctx,ring);pipeline::EnhanceGraphDesc gd;gd.sourceWidth=gd.workWidth=picture->width;gd.sourceHeight=gd.workHeight=picture->height;gd.enableNr=gd.enableSr=gd.enableFg=false;+ if(graph.initialize(gd)&&graph.createViews()){pipeline::EnhanceGraph::FrameOutputs out;sink::RgbaImage image;+ captured=graph.process(picture,0,true,out,1,&color)&&sink::readRgba8(ctx,ring,graph.videoFrameResource(out.videoSlot),image)&&sink::saveImage((std::filesystem::path(argv[2])/L"source.png").wstring(),image);+ out={};ring.drainQueue();}graph.shutdown();av_frame_free(&picture);+ }+ source.close();ring.shutdown();ctx.shutdown();CoUninitialize();+ std::cout<<"SOURCE_DIAGNOSTIC frames="<<frames<<" captured="<<captured<<" no_enhancement=1"<<std::endl;return !failed&&frames>100&&captured?0:1;+}