diff --git a/modules/ANSCV/ANSRTSP.cpp b/modules/ANSCV/ANSRTSP.cpp index 7536d5d..b793a16 100644 --- a/modules/ANSCV/ANSRTSP.cpp +++ b/modules/ANSCV/ANSRTSP.cpp @@ -454,6 +454,25 @@ namespace ANSCENTER { return _pLastFrame; // Shallow copy (fast) } + // Early stale-out: if the decoder hasn't produced a frame in 5s the + // camera is dead. Skip _playerClient->getImage() entirely and return + // the cached frame with unchanged _pts so LabVIEW sees STALE PTS one + // poll earlier and triggers reconnect. Matches the 5000ms threshold + // already used on the duplicate-PTS branch below and in + // areImagesIdentical(), so all three stale paths agree. + if (!_pLastFrame.empty()) { + double ageMs = _playerClient->getLastFrameAgeMs(); + if (ageMs >= 5000.0) { + ANS_DBG("RTSP_GetImage", + "EARLY STALE: ageMs=%.1f pts=%lld url=%s — skipping getImage()", + ageMs, (long long)_pts, _url.c_str()); + width = _imageWidth; + height = _imageHeight; + pts = _pts; + return _pLastFrame; + } + } + int imageW = 0, imageH = 0; int64_t currentPts = 0;