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++

feat(remoteplay): expose independent receive and decode progress

Veyra Goal Agent959776f00f20
diff --git a/docs/PS5_TELEMETRY_SCHEDULER_EXECUTION_2026-09-12.md b/docs/PS5_TELEMETRY_SCHEDULER_EXECUTION_2026-09-12.md
new file mode 100644
index 00000000..03e30ea1
--- /dev/null
+++ b/docs/PS5_TELEMETRY_SCHEDULER_EXECUTION_2026-09-12.md
@@ -0,0 +1,13 @@
+# PS5遥测、停帧、FG调度与解码施工记录
+
+目标active,未完成,不发布。当前分支codex/ps5-scheduler-telemetry-decode;开工adff31b,tag checkpoint/ps5-scheduler-decode-pre-repair-2026-09-12。方案PS5_TELEMETRY_STALL_FG_DECODE_REPAIR_PLAN_2026-09-12.md,用户要求全部完成。
+
+## P0第一步:独立接收/解码观测
+
+SessionInbox追加一秒有界窗口、完整视频payload速率/接收与解码fps、最后视频/音频/解码时间、实际解码调用平均/P95和接收后等待。不是UDP线速、不是网络端到端延迟。RemotePlaySource在submit/drain位置计时和计数,SessionSource安全共享只读inbox快照;Engine::snapshot直接读这些线程安全数据,不再只能等GPU循环推送。
+
+FrameFlow记录最后GPU就绪、提交和Present;独立monitor每秒输出remoteplay-progress,即使解码owner卡在调用内仍能观察接收进度。视频停顿在Streaming状态下1秒触发受限关键帧恢复,后续间隔2秒,一次停顿最多3次;恢复后重置次数,最终沿用30秒失败边界。没有强杀线程、无无限重建。尚需故障注入与用户停帧复测,不宣称冻结根因已经修复。
+
+实际命令:out/remoteplay/audit-20260911/build-product.cmd;日志logs/ps5-p0-progress-build.log(31步成功)、ps5-p0-progress-tests-build.log(2步)。scripts/run-short-test.ps1运行veyra_remoteplay_boundary_tests,TimeoutSeconds30,logs/ps5-p0-progress-boundary.stdout.log,exit0;新增用例验证独立快照的真实解码耗时和一秒后旧样本不显示为实时。
+
+尚未完成:P0视频阶段UI/完整恢复矩阵,P1文件提前增强和FG恢复,P2面板,P3硬解。不能将此节点称为整体完成。
diff --git a/docs/WORKLOG.md b/docs/WORKLOG.md
index 3939fe29..fee7b828 100644
--- a/docs/WORKLOG.md
+++ b/docs/WORKLOG.md
@@ -1660,3 +1660,6 @@ build-product/native-source/off-check成功;boundary默认与virtual、H264/H2
### 同日追加:用户复现4K30原生NR+2X锁原帧率
新日志revision4确认NR/flow/FG均4K,690次FG候选中682次拒绝、8次Evaluate(1预热+7有效),7有效全部过期,generatedPresented=0;原帧约30fps且媒体1×。文件一批处理/等待呈现完成后才处理下一批,与插帧中点早于B原帧截止时间的差异形成强疑点。方案P1增加有界提前增强/呈现解耦,不能只调整FG阈值。日志与SHA256见方案补充节;这是用户复现加日志/静态审查,不是Agent新执行的负载测试,产品尚未修改。
+
+## 2026-09-12 全部修复目标开工:P0独立进度
+开工adff31b,分支codex/ps5-scheduler-telemetry-decode。独立inbox接收/解码窗口、GPU/Present进度、受限关键帧恢复已构建和窄测通过;故障注入尚未验证,其他P1-P3继续。详见docs/PS5_TELEMETRY_SCHEDULER_EXECUTION_2026-09-12.md。目标active,无发布。
diff --git a/include/veyra/diagnostics/FrameMetrics.h b/include/veyra/diagnostics/FrameMetrics.h
index 2a1b278a..b4edaa47 100644
--- a/include/veyra/diagnostics/FrameMetrics.h
+++ b/include/veyra/diagnostics/FrameMetrics.h
@@ -37,6 +37,7 @@ struct FrameFlowCounters {
uint32_t commandSlotsInFlight=0,commandSlotHighWater=0,presentationBatchHighWater=0;
};
struct FrameFlowMetrics {
+ int64_t lastReady100ns=0,lastPresent100ns=0,lastSubmit100ns=0;
FrameFlowIdentity latest;
FrameFlowCounters counters;
std::optional<double> slotReuseWaitMs,captureArrivalToPresentReturnMs,gpuReadyWaitMs,deadlineWaitMs;
diff --git a/include/veyra/engine/EngineController.h b/include/veyra/engine/EngineController.h
index 151f2ab8..4df1927c 100644
--- a/include/veyra/engine/EngineController.h
+++ b/include/veyra/engine/EngineController.h
@@ -10,6 +10,7 @@
#include "veyra/diagnostics/FrameMetrics.h"
#include "veyra/engine/PreviewView.h"
#include "veyra/sink/CaptureAudioSession.h"
+#include "veyra/remoteplay/SessionInbox.h"
namespace veyra::source { struct RemotePlayConnectDesc; class RemotePlaySessionSource; }
namespace veyra::remoteplay { struct ControllerState;struct ControllerFeedback; }
namespace veyra::sink { struct RgbaImage; }
@@ -52,6 +53,7 @@ struct PlayerSnapshot {
bool fgBudgetLimited=false,xessGenerationSuppressed=false;
bool running=false,failed=false,image=false,capture=false,remotePlay=false;
int remotePlayState=0; uint64_t remotePlaySkipped=0;
+ remoteplay::SessionInbox::Snapshot remoteStream;
double remoteReceivedFps=0,remoteDecodedFps=0;bool remoteRatesReady=false;uint64_t remoteReceived=0,remoteDecoded=0,remoteIngressDropped=0;
};
class EngineController {
diff --git a/include/veyra/engine/FrameFlowWindow.h b/include/veyra/engine/FrameFlowWindow.h
index 21f642ee..57146a5e 100644
--- a/include/veyra/engine/FrameFlowWindow.h
+++ b/include/veyra/engine/FrameFlowWindow.h
@@ -98,6 +98,7 @@ public:
if(!batch||readyBatches_[batch%readyBatches_.size()]==batch)return;
readyBatches_[batch%readyBatches_.size()]=batch;
metrics_.counters.fgReadyValid+=valid;metrics_.counters.fgInvalid+=invalid;
+ metrics_.lastReady100ns=now;
if(real)++metrics_.counters.realReady;
rates_->ready(real,valid,now);
}
@@ -114,6 +115,7 @@ public:
std::lock_guard lock(mutex_);
if(generated)++metrics_.counters.generatedPresented;else ++metrics_.counters.realPresented;
metrics_.latest.consumerFence=fence;rates_->presented(now);
+ metrics_.lastPresent100ns=now;
}
diagnostics::FrameFlowMetrics snapshot(int64_t now)const{
std::lock_guard lock(mutex_);auto m=metrics_;rates_->snapshot(m,now);
diff --git a/include/veyra/remoteplay/SessionInbox.h b/include/veyra/remoteplay/SessionInbox.h
index d69e7eb7..ad5a74f0 100644
--- a/include/veyra/remoteplay/SessionInbox.h
+++ b/include/veyra/remoteplay/SessionInbox.h
@@ -14,6 +14,11 @@ public:
Generation generation=0;SessionState state=SessionState::Idle;HostTime commonOrigin100ns=0;
std::uint64_t staleCallbacks=0;int errorCode=0;
VideoQueueStats video;AudioQueueStats audio;
+ HostTime lastVideo100ns=0,lastAudio100ns=0,decodeStarted100ns=0,lastDecoded100ns=0;
+ uint64_t decodedFrames=0,receivedBytes=0,framesLost=0,framesRecovered=0;
+ double receivedFps=0,decodedFps=0,videoMbps=0;
+ std::optional<double> decodeMeanMs,decodeP95Ms,ingressWaitMeanMs;
+ bool ratesReady=false;
};
class Token {
public:
@@ -40,6 +45,9 @@ public:
void decodeFailed(Generation);
bool isCurrent(Generation)const;
Snapshot snapshot()const;
+ void decodeStarted(HostTime now,HostTime arrival);
+ void decodeFinished(HostTime now);
+ void frameDecoded(HostTime now);
private:
std::shared_ptr<Shared> shared_;
};
diff --git a/include/veyra/source/RemotePlaySessionSource.h b/include/veyra/source/RemotePlaySessionSource.h
index 0855aec7..801b8987 100644
--- a/include/veyra/source/RemotePlaySessionSource.h
+++ b/include/veyra/source/RemotePlaySessionSource.h
@@ -44,6 +44,7 @@ private:
std::shared_ptr<AVFrame> view_;
SourceInfo info_, publishedInfo_;
remoteplay::SessionInbox::Snapshot snapshot_;
+ std::shared_ptr<const remoteplay::SessionInbox> telemetryInbox_;
remoteplay::ControllerState controller_;
std::deque<std::pair<remoteplay::HostTime,remoteplay::ControllerState>> pendingControllers_;
remoteplay::HostTime controllerStamp_=0;
diff --git a/include/veyra/source/RemotePlaySource.h b/include/veyra/source/RemotePlaySource.h
index 33479f34..4f9cdbd7 100644
--- a/include/veyra/source/RemotePlaySource.h
+++ b/include/veyra/source/RemotePlaySource.h
@@ -43,6 +43,8 @@ public:
remoteplay::ControllerFeedback takeFeedback(){return backend_.takeFeedback();}
bool connected() const noexcept { return connected_; }
remoteplay::SessionInbox::Snapshot sessionSnapshot() const;
+ std::shared_ptr<const remoteplay::SessionInbox> telemetryInbox()const{return inbox_;}
+ void recoverVideo(){flushDecoder();if(token_)inbox_->decodeFailed(token_->generation());}
const SourceInfo& info() const override { return info_; }
SourceReadStatus read(pipeline::FramePacket& out, const AVFrame** decodedFrame) override;
@@ -67,7 +69,7 @@ private:
pipeline::FramePacket makePacket(const remoteplay::VideoSample& sample,
std::uint64_t sourceIndex, std::uint64_t epoch, bool reset);
- std::unique_ptr<remoteplay::SessionInbox> inbox_;
+ std::shared_ptr<remoteplay::SessionInbox> inbox_;
remoteplay::ChiakiBackend backend_;
std::optional<remoteplay::SessionInbox::Token> token_;
remoteplay::RemotePlayClock clock_;
diff --git a/src/engine/EngineController.cpp b/src/engine/EngineController.cpp
index 6fdb96c0..2551bc05 100644
--- a/src/engine/EngineController.cpp
+++ b/src/engine/EngineController.cpp
@@ -94,6 +94,14 @@ PlayerSnapshot EngineController::snapshot()const{
std::lock_guard lock(mutex_);auto copy=snapshot_;copy.volume=volume_;copy.muted=muted_;
const bool playing=copy.running&&!copy.image&&copy.transport==TransportState::Playing;
if(activeFlow_)copy.metrics.flow=activeFlow_->snapshot(monotonic100ns());
+#ifdef VEYRA_ENABLE_REMOTEPLAY
+ if(copy.remotePlay&&activeRemote_){
+ const auto s=activeRemote_->sessionSnapshot();copy.remoteStream=s;copy.remotePlayState=int(s.state);
+ copy.remoteReceivedFps=s.receivedFps;copy.remoteDecodedFps=s.decodedFps;copy.remoteRatesReady=s.ratesReady;
+ copy.remoteReceived=s.video.accessUnits;copy.remoteDecoded=s.decodedFrames;copy.remoteIngressDropped=s.video.dropped;
+ copy.remotePlaySkipped=activeRemote_->skipped();copy.captureAudio=activeRemote_->audioState();copy.audioAvailable=copy.captureAudio.available;
+ }
+#endif
auto& flow=copy.metrics.flow;
if(!playing){flow.sourceCompletedFps=flow.outputCompletedFps=flow.validGeneratedFps=flow.presentSubmitFps=flow.xessSdkSubmitFps=0;}
copy.fps=flow.sourceCompletedFps;copy.submissionFps=flow.presentSubmitFps;
@@ -631,6 +639,7 @@ void EngineController::run(HWND window,std::wstring path,PlayerOptions options,s
processTimes.add(processMs);
traceFrame(diagnostics::TraceKind::Submitted,out.batch.identity,out.batch.batchId,std::max(out.videoFenceValue,out.genFenceValue),out.batch.b100ns,out.fgSkippedBeforeEval,out.fgEvaluated,processMs);
frameFlow->cpu(diagnostics::CpuStage::Decode,decodeMs,host100ns());
+ frameFlow->update([&](auto& m){m.lastSubmit100ns=host100ns();});
frameFlow->cpu(diagnostics::CpuStage::Submit,processMs,host100ns());
frameFlow->cpu(diagnostics::CpuStage::SlotWait,processSlotWaitMs,host100ns());
frameFlow->update([&](auto& m){m.latest.frame=out.batch.identity;m.latest.batchId=out.batch.batchId;m.latest.readyFence=std::max(out.videoFenceValue,out.genFenceValue);m.counters.sourceAccepted+=!rereadCached;++m.counters.realSubmitted;m.counters.previewSkippedBeforeGraph+=previewSkippedSinceSubmit;m.counters.fgCandidate+=out.fgCandidates;m.counters.fgEvaluated+=out.fgEvaluated;m.counters.fgSkippedBeforeEval+=out.fgSkippedBeforeEval;if(!out.hasGenerated)m.counters.fgWarmup+=out.fgEvaluated;});
diff --git a/src/remoteplay/SessionInbox.cpp b/src/remoteplay/SessionInbox.cpp
index 42c599a1..5f613192 100644
--- a/src/remoteplay/SessionInbox.cpp
+++ b/src/remoteplay/SessionInbox.cpp
@@ -1,12 +1,21 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "veyra/remoteplay/SessionInbox.h"
#include <limits>
+#include <algorithm>
+#include <vector>
namespace veyra::remoteplay {
struct SessionInbox::Shared {
explicit Shared(QueueLimits limits):video(limits){}
mutable std::mutex mutex;Generation generation=0;SessionState state=SessionState::Idle;
HostTime origin=0;bool accepting=false;std::uint64_t stale=0;int error=0;
VideoIngress video;AudioIngress audio;
+ HostTime lastVideo=0,lastAudio=0,decodeStart=0,lastDecoded=0;
+ uint64_t decodedFrames=0,receivedBytes=0,framesLost=0,framesRecovered=0;
+ struct Sample {HostTime time;double value;};
+ std::deque<Sample> received,decoded,decodeTimes,ingressWait;
+ static void add(std::deque<Sample>& q,HostTime now,double value){
+ while(!q.empty()&&(q.size()>=4096||q.front().time<=now-10000000))q.pop_front();q.push_back({now,value});
+ }
bool current(Generation g){if(!accepting||g!=generation){++stale;return false;}return true;}
};
SessionInbox::SessionInbox(QueueLimits l):shared_(std::make_shared<Shared>(l)){}
@@ -17,6 +26,8 @@ SessionInbox::Token SessionInbox::begin(HostTime origin){
if(s.state!=SessionState::Idle)throw std::logic_error("Stop and join previous backend before a new session");
if(s.generation==std::numeric_limits<Generation>::max())throw std::overflow_error("Session generation exhausted");
++s.generation;s.video.begin(s.generation);s.audio.begin(s.generation);s.origin=origin;s.state=SessionState::Connecting;s.accepting=true;s.error=0;
+ s.lastVideo=s.lastAudio=s.decodeStart=s.lastDecoded=0;s.decodedFrames=s.receivedBytes=s.framesLost=s.framesRecovered=0;
+ s.received.clear();s.decoded.clear();s.decodeTimes.clear();s.ingressWait.clear();
return Token{shared_,s.generation};
}
void SessionInbox::invalidate(){auto& s=*shared_;std::lock_guard l(s.mutex);s.accepting=false;if(s.state!=SessionState::Idle)s.state=SessionState::Stopping;s.video.close();s.audio.close();}
@@ -32,16 +43,31 @@ std::optional<PcmBlock> SessionInbox::tryAudio(){auto& s=*shared_;std::lock_guar
bool SessionInbox::takeIdrRequest(HostTime now){auto& s=*shared_;std::lock_guard l(s.mutex);return s.accepting&&s.video.takeIdrRequest(now);}
void SessionInbox::decodeFailed(Generation g){auto& s=*shared_;std::lock_guard l(s.mutex);if(s.accepting&&s.generation==g)s.video.requireKeyframe();}
SessionInbox::Snapshot SessionInbox::snapshot()const{
- auto& s=*shared_;std::lock_guard l(s.mutex);return {s.generation,s.state,s.origin,s.stale,s.error,s.video.stats(),s.audio.stats()};
+ auto& s=*shared_;std::lock_guard l(s.mutex);Snapshot result{s.generation,s.state,s.origin,s.stale,s.error,s.video.stats(),s.audio.stats()};
+ const auto now=monotonic100ns();result.lastVideo100ns=s.lastVideo;result.lastAudio100ns=s.lastAudio;
+ result.decodeStarted100ns=s.decodeStart;result.lastDecoded100ns=s.lastDecoded;
+ result.decodedFrames=s.decodedFrames;result.receivedBytes=s.receivedBytes;result.framesLost=s.framesLost;result.framesRecovered=s.framesRecovered;
+ result.ratesReady=now-s.origin>=10000000;
+ for(const auto& v:s.received)if(v.time>now-10000000){++result.receivedFps;result.videoMbps+=v.value*8/1000000;}
+ for(const auto& v:s.decoded)if(v.time>now-10000000)++result.decodedFps;
+ auto aggregate=[&](const auto& q,std::optional<double>& mean,std::optional<double>* p95){
+ std::vector<double> values;double sum=0;for(const auto& v:q)if(v.time>now-10000000){values.push_back(v.value);sum+=v.value;}
+ if(values.empty())return;mean=sum/values.size();if(p95){std::sort(values.begin(),values.end());*p95=values[(values.size()*95+99)/100-1];}
+ };
+ aggregate(s.decodeTimes,result.decodeMeanMs,&result.decodeP95Ms);aggregate(s.ingressWait,result.ingressWaitMeanMs,nullptr);return result;
}
+void SessionInbox::decodeStarted(HostTime now,HostTime arrival){auto& s=*shared_;std::lock_guard l(s.mutex);s.decodeStart=now;if(arrival>0&&now>=arrival)Shared::add(s.ingressWait,now,double(now-arrival)/10000);}
+void SessionInbox::decodeFinished(HostTime now){auto& s=*shared_;std::lock_guard l(s.mutex);if(s.decodeStart>0&&now>=s.decodeStart)Shared::add(s.decodeTimes,now,double(now-s.decodeStart)/10000);s.decodeStart=0;}
+void SessionInbox::frameDecoded(HostTime now){auto& s=*shared_;std::lock_guard l(s.mutex);s.lastDecoded=now;++s.decodedFrames;Shared::add(s.decoded,now,1);}
bool SessionInbox::Token::video(VideoSample sample)const noexcept{
try{auto s=shared_.lock();if(!s)return false;std::lock_guard l(s->mutex);if(!s->current(generation_))return false;
if(sample.generation!=generation_)return false;
+ if(sample.kind==SampleKind::AccessUnit){s->lastVideo=monotonic100ns();s->receivedBytes+=sample.payload.bytes().size();s->framesLost+=std::max(0,sample.framesLost);s->framesRecovered+=sample.referenceRecovered?1:0;Shared::add(s->received,s->lastVideo,double(sample.payload.bytes().size()));}
const auto r=s->video.push(std::move(sample),monotonic100ns());return r==PushStatus::Accepted||r==PushStatus::ConfigStored;
}catch(...){failed(-1001);return false;}
}
bool SessionInbox::Token::audio(PcmBlock block)const noexcept{
- try{auto s=shared_.lock();if(!s)return false;std::lock_guard l(s->mutex);if(!s->current(generation_)||block.generation!=generation_)return false;return s->audio.push(std::move(block));}
+ try{auto s=shared_.lock();if(!s)return false;std::lock_guard l(s->mutex);if(!s->current(generation_)||block.generation!=generation_)return false;s->lastAudio=monotonic100ns();return s->audio.push(std::move(block));}
catch(...){failed(-1002);return false;}
}
void SessionInbox::Token::connected()const noexcept{
diff --git a/src/source/RemotePlaySessionSource.cpp b/src/source/RemotePlaySessionSource.cpp
index f12f9b29..dd1c0708 100644
--- a/src/source/RemotePlaySessionSource.cpp
+++ b/src/source/RemotePlaySessionSource.cpp
@@ -18,12 +18,21 @@ bool RemotePlaySessionSource::connect(RemotePlayConnectDesc desc) {
void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc desc) {
RemotePlaySource source;
std::jthread feeder;
+ std::jthread monitor;
try {
const bool ok=source.connect(desc);
desc.request.credentials=remoteplay::PairingCredentials{};
- {std::lock_guard lock(mutex_);publishedInfo_=source.info();started_=ok;failed_=!ok;initialized_=true;}
+ {std::lock_guard lock(mutex_);publishedInfo_=source.info();started_=ok;failed_=!ok;initialized_=true;telemetryInbox_=source.telemetryInbox();}
ready_.notify_all();
if(ok) {
+ monitor=std::jthread([inbox=source.telemetryInbox()](std::stop_token cancel){
+ while(!cancel.stop_requested()){
+ const auto s=inbox->snapshot();const auto now=remoteplay::monotonic100ns();
+ const auto age=[&](auto stamp){return stamp>0?double(now-stamp)/10000:-1.0;};
+ log::info("remoteplay-progress",std::format("state={} received={} decoded={} inputFps={:.1f} decodeFps={:.1f} videoMbps={:.3f} receiveAgeMs={:.1f} decodeAgeMs={:.1f} decodeBusyMs={:.1f} queue={} waitingIdr={} idrRequests={} errors={} (complete-video callback; not network latency)",int(s.state),s.video.accessUnits,s.decodedFrames,s.receivedFps,s.decodedFps,s.videoMbps,age(s.lastVideo100ns),age(s.lastDecoded100ns),age(s.decodeStarted100ns),s.video.depth,s.video.waitingForIdr,s.video.idrRequests,s.errorCode));
+ for(int i=0;i<10&&!cancel.stop_requested();++i)std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+ });
WAVEFORMATEX format{}; format.wFormatTag=WAVE_FORMAT_IEEE_FLOAT;format.nChannels=2;
format.nSamplesPerSec=48000;format.wBitsPerSample=32;format.nBlockAlign=8;format.nAvgBytesPerSec=384000;
if(audio_.configure(format)&&audio_.start()) {
@@ -47,6 +56,8 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
auto lastFrame=std::chrono::steady_clock::now();
auto nextController=lastFrame;
auto rateStart=lastFrame;uint64_t previousReceived=0,previousDecoded=0;
+ unsigned recoveryAttempts=0;
+ auto nextRecovery=lastFrame+std::chrono::seconds(1);
while(!stop.stop_requested()) {
std::string pin;
{std::lock_guard lock(mutex_);pin.swap(pin_);}
@@ -77,7 +88,12 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
if(result==SourceReadStatus::Frame && frame) {
publishDecoded(frame,packet,source.info());
lastFrame=now;
+ recoveryAttempts=0;nextRecovery=now+std::chrono::seconds(1);
} else {
+ if(snapshot.state==remoteplay::SessionState::Streaming&&now>=nextRecovery&&recoveryAttempts<3){
+ ++recoveryAttempts;source.recoverVideo();nextRecovery=now+std::chrono::seconds(2);
+ log::warn("remoteplay-recovery",std::format("no decoded progress; request keyframe attempt={} received={} decoded={} lastReceiveAgeMs={:.1f}",recoveryAttempts,snapshot.video.accessUnits,snapshot.decodedFrames,snapshot.lastVideo100ns?double(remoteplay::monotonic100ns()-snapshot.lastVideo100ns)/10000:-1));
+ }
// A missing console or unrecoverable stream must not leave
// a perpetual opening spinner. Login PIN allows more time.
const auto deadline=snapshot.state==remoteplay::SessionState::LoginPinRequired?std::chrono::seconds(120):std::chrono::seconds(30);
@@ -94,6 +110,7 @@ void RemotePlaySessionSource::run(std::stop_token stop, RemotePlayConnectDesc de
{std::lock_guard lock(mutex_);failed_=true;initialized_=true;}
ready_.notify_all();
}
+ if(monitor.joinable()){monitor.request_stop();monitor.join();}
if(feeder.joinable()){feeder.request_stop();feeder.join();}
audio_.stop();
source.close();
@@ -140,7 +157,10 @@ remoteplay::ControllerState RemotePlaySessionSource::takeControllerLocked(remote
return controller_;
}
void RemotePlaySessionSource::loginPin(std::string pin){std::lock_guard lock(mutex_);SecureZeroMemory(pin_.data(),pin_.size());pin_=std::move(pin);}
-remoteplay::SessionInbox::Snapshot RemotePlaySessionSource::sessionSnapshot()const{std::lock_guard lock(mutex_);return snapshot_;}
+remoteplay::SessionInbox::Snapshot RemotePlaySessionSource::sessionSnapshot()const{
+ std::shared_ptr<const remoteplay::SessionInbox> inbox;{std::lock_guard lock(mutex_);inbox=telemetryInbox_;if(!inbox)return snapshot_;}
+ return inbox->snapshot();
+}
RemotePlaySessionSource::Rates RemotePlaySessionSource::rates()const{std::lock_guard lock(mutex_);return rates_;}
remoteplay::ControllerFeedback RemotePlaySessionSource::takeFeedback(){std::lock_guard lock(mutex_);auto result=std::move(feedback_);feedback_={};return result;}
uint64_t RemotePlaySessionSource::skipped()const{std::lock_guard lock(mutex_);return skipped_;}
diff --git a/src/source/RemotePlaySource.cpp b/src/source/RemotePlaySource.cpp
index 8e12eea7..19e9fe53 100644
--- a/src/source/RemotePlaySource.cpp
+++ b/src/source/RemotePlaySource.cpp
@@ -47,7 +47,7 @@ pipeline::SourcePixelFormat pixelFormatFromFrame(const AVFrame& frame)
} // namespace
RemotePlaySource::RemotePlaySource()
- : inbox_(std::make_unique<remoteplay::SessionInbox>())
+ : inbox_(std::make_shared<remoteplay::SessionInbox>())
{
}
@@ -83,7 +83,7 @@ bool RemotePlaySource::connect(const RemotePlayConnectDesc& desc)
origin100ns_ = static_cast<std::uint64_t>(remoteplay::monotonic100ns());
try {
- inbox_ = std::make_unique<remoteplay::SessionInbox>(desc.queueLimits);
+ inbox_ = std::make_shared<remoteplay::SessionInbox>(desc.queueLimits);
} catch (...) {
request_.credentials = remoteplay::PairingCredentials{};
veyra::log::error("remoteplay", "invalid queue limits");
@@ -255,6 +255,7 @@ bool RemotePlaySource::drainDecoder(std::uint64_t sourceIndex, const pipeline::F
(void)sourceIndex;
if (ready_.size() >= 4) return false;
ready_.push_back({std::move(clone), packet});
+ inbox_->frameDecoded(remoteplay::monotonic100ns());
}
}
@@ -262,6 +263,8 @@ bool RemotePlaySource::submitPacket(std::span<const std::uint8_t> bytes,
std::uint64_t sourceIndex, const pipeline::FramePacket& sourcePacket)
{
if (!decoderReady_ || bytes.empty()) return false;
+ inbox_->decodeStarted(remoteplay::monotonic100ns(),sourcePacket.arrivalHost100ns);
+ struct Finish {remoteplay::SessionInbox& inbox;~Finish(){inbox.decodeFinished(remoteplay::monotonic100ns());}} finish{*inbox_};
AVPacket* packet = av_packet_alloc();
if (packet == nullptr || av_new_packet(packet, static_cast<int>(bytes.size())) < 0) {
av_packet_free(&packet);
diff --git a/tests/remoteplay/ProductBoundaryTests.cpp b/tests/remoteplay/ProductBoundaryTests.cpp
index 55a8b051..55142fd7 100644
--- a/tests/remoteplay/ProductBoundaryTests.cpp
+++ b/tests/remoteplay/ProductBoundaryTests.cpp
@@ -15,6 +15,14 @@ struct RemotePlaySessionSourceTestAccess {
static void mailbox(){
RemotePlaySessionSource s;s.started_=true;
const auto now=remoteplay::monotonic100ns();
+ auto inbox=std::make_shared<remoteplay::SessionInbox>();auto token=inbox->begin(now-20000000);token.connected();
+ inbox->decodeStarted(now-15000000,now-15050000);inbox->decodeFinished(now-14900000);inbox->frameDecoded(now-14900000);
+ s.telemetryInbox_=inbox;
+ auto progress=s.sessionSnapshot();
+ if(progress.decodedFrames!=1||progress.decodedFps!=0||progress.decodeMeanMs||!progress.ratesReady)throw std::runtime_error("stale decode telemetry");
+ inbox->decodeStarted(now-100000,now-150000);inbox->decodeFinished(now);inbox->frameDecoded(now);
+ progress=s.sessionSnapshot();
+ if(progress.decodedFrames!=2||progress.decodedFps!=1||progress.decodeMeanMs!=10.0||progress.ingressWaitMeanMs!=5.0||progress.decodeStarted100ns)throw std::runtime_error("independent decode telemetry");
remoteplay::ControllerState down;down.inputActive=true;down.touches[0].id=1;
s.controller(down);s.controller({});
if(s.takeControllerLocked(now)!=remoteplay::ControllerState{})throw std::runtime_error("focus loss must cancel pending actions");