Improve ANSCV
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameOps.h"
|
||||
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
|
||||
#include "ANSLicense.h" // ANS_DBG macro
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include "media_codec.h"
|
||||
@@ -251,6 +252,23 @@ namespace ANSCENTER {
|
||||
return _pLastFrame; // Shallow copy (fast)
|
||||
}
|
||||
|
||||
// Early stale-out: if the decoder hasn't produced a frame in 5s the
|
||||
// source 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.
|
||||
if (!_pLastFrame.empty()) {
|
||||
double ageMs = _playerClient->getLastFrameAgeMs();
|
||||
if (ageMs >= 5000.0) {
|
||||
ANS_DBG("FLV_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;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameOps.h"
|
||||
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
|
||||
#include "ANSLicense.h" // ANS_DBG macro
|
||||
#include <memory>
|
||||
#include <cstdint>
|
||||
#include "media_codec.h"
|
||||
@@ -239,6 +240,23 @@ namespace ANSCENTER {
|
||||
return _pLastFrame; // Shallow copy (fast)
|
||||
}
|
||||
|
||||
// Early stale-out: if the decoder hasn't produced a frame in 5s the
|
||||
// source 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.
|
||||
if (!_pLastFrame.empty()) {
|
||||
double ageMs = _playerClient->getLastFrameAgeMs();
|
||||
if (ageMs >= 5000.0) {
|
||||
ANS_DBG("MJPEG_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;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -155,7 +155,9 @@ namespace ANSCENTER
|
||||
std::recursive_mutex _mutex;
|
||||
|
||||
//std::once_flag licenseOnceFlag; // For one-time license check
|
||||
bool _licenseValid = false;
|
||||
// Atomic so lock-free methods (ImageResize, ImageResizeWithRatio,
|
||||
// MatToBinaryData, EncodeJpegString) can read it without _mutex.
|
||||
std::atomic<bool> _licenseValid{ false };
|
||||
public:
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameOps.h"
|
||||
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
|
||||
#include "ANSLicense.h" // ANS_DBG macro
|
||||
#include <memory>
|
||||
#include "media_codec.h"
|
||||
#include <cstdint>
|
||||
@@ -245,6 +246,23 @@ namespace ANSCENTER {
|
||||
return _pLastFrame; // Shallow copy (fast)
|
||||
}
|
||||
|
||||
// Early stale-out: if the decoder hasn't produced a frame in 5s the
|
||||
// source 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.
|
||||
if (!_pLastFrame.empty()) {
|
||||
double ageMs = _playerClient->getLastFrameAgeMs();
|
||||
if (ageMs >= 5000.0) {
|
||||
ANS_DBG("RTMP_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;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ANSMatRegistry.h"
|
||||
#include "ANSGpuFrameOps.h"
|
||||
#include "ANSCVVendorGate.h" // anscv_vendor_gate::IsNvidiaGpuAvailable()
|
||||
#include "ANSLicense.h" // ANS_DBG macro
|
||||
#include <memory>
|
||||
#include "media_codec.h"
|
||||
#include <cstdint>
|
||||
@@ -253,6 +254,23 @@ namespace ANSCENTER {
|
||||
return _pLastFrame; // Shallow copy (fast)
|
||||
}
|
||||
|
||||
// Early stale-out: if the decoder hasn't produced a frame in 5s the
|
||||
// source 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.
|
||||
if (!_pLastFrame.empty()) {
|
||||
double ageMs = _playerClient->getLastFrameAgeMs();
|
||||
if (ageMs >= 5000.0) {
|
||||
ANS_DBG("SRT_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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user