-added event age to evt_t as a way to track the age of the event
 in EventLoop so now only events approching and exceeding
 evMaxSecs will have the video range added for writing.
This commit is contained in:
Zii 2023-06-20 17:49:52 -04:00
parent ff5f95f445
commit 5f9c4be6b2
2 changed files with 40 additions and 24 deletions

View File

@ -253,7 +253,7 @@ EventLoop::EventLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(
bool EventLoop::exec() bool EventLoop::exec()
{ {
if (cycles * 2 >= shared->evMaxSecs) if (!vidList.isEmpty())
{ {
vidList.removeDuplicates(); vidList.removeDuplicates();
@ -282,31 +282,45 @@ bool EventLoop::exec()
vidList.clear(); vidList.clear();
} }
else
{
cycles += 1;
shared->recMutex.lock(); shared->recMutex.lock();
for (auto &&event : shared->recList) QList<int> rmIndx;
{
auto maxFiles = shared->evMaxSecs / 2;
// there's 2 secs in each hls segment
if (highScore < event.score) for (auto i = 0; i < shared->recList.size(); ++i)
{ {
name = event.timeStamp.toString(DATETIME_FMT); auto event = &shared->recList[i];
imgPath = event.imgPath;
highScore = event.score; if (highScore < event->score)
{
name = event->timeStamp.toString(DATETIME_FMT);
imgPath = event->imgPath;
highScore = event->score;
} }
vidList.append(backwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); if (event->queAge >= (shared->evMaxSecs / heartBeat))
vidList.append(forwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); {
auto maxSecs = shared->evMaxSecs / 2;
// half the maxsecs value to get front-back half secs
auto backFiles = backwardFacingFiles("live", ".ts", event->timeStamp, maxSecs);
auto frontFiles = forwardFacingFiles("live", ".ts", event->timeStamp, maxSecs);
vidList.append(backFiles + frontFiles);
rmIndx.append(i);
}
else
{
event->queAge += heartBeat;
}
}
for (auto i : rmIndx)
{
shared->recList.remove(i);
} }
shared->recList.clear();
shared->recMutex.unlock(); shared->recMutex.unlock();
}
return Loop::exec(); return Loop::exec();
} }
@ -377,9 +391,9 @@ DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loo
{ {
pcTimer = 0; pcTimer = 0;
heartBeat = 2; heartBeat = 2;
delayCycles = 8; // this will be used to delay the delayCycles = 12; // this will be used to delay the
// actual start of DetectLoop by // actual start of DetectLoop by
// 16secs. // 24secs.
} }
void DetectLoop::init() void DetectLoop::init()
@ -473,6 +487,7 @@ bool DetectLoop::exec()
event.timeStamp = curDT; event.timeStamp = curDT;
event.score = score; event.score = score;
event.imgPath = images[pos]; event.imgPath = images[pos];
event.queAge = 0;
shared->recMutex.lock(); shared->recMutex.lock();
shared->recList.append(event); mod = true; shared->recList.append(event); mod = true;

View File

@ -29,7 +29,7 @@
using namespace std; using namespace std;
#define APP_VER "3.0.0" #define APP_VER "3.1.t1"
#define APP_NAME "Motion Watch" #define APP_NAME "Motion Watch"
#define APP_BIN "mow" #define APP_BIN "mow"
#define REC_LOG_NAME "rec_log_lines.html" #define REC_LOG_NAME "rec_log_lines.html"
@ -45,6 +45,7 @@ struct evt_t
QDateTime timeStamp; QDateTime timeStamp;
QString imgPath; QString imgPath;
float score; float score;
uint queAge;
}; };
struct shared_t struct shared_t