diff --git a/CMakeLists.txt b/CMakeLists.txt index a4aa5fd..e13ef5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,8 @@ set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_BUILD_TYPE Debug) + find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) diff --git a/src/camera.cpp b/src/camera.cpp index e5c41c1..3ff8b7a 100644 --- a/src/camera.cpp +++ b/src/camera.cpp @@ -97,15 +97,11 @@ void Loop::loopSlot() bool Loop::exec() { - funcMsg("enter: Loop::exec()"); - if (loopTimer->interval() != heartBeat * 1000) { loopTimer->start(heartBeat * 1000); } - funcMsg("enter: Loop::exit()"); - return shared->retCode == 0; } @@ -117,8 +113,6 @@ RecLoop::RecLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(shar void RecLoop::init() { - funcMsg("enter: RecLoop::init()"); - recProc = new QProcess(this); imgProc = new QProcess(this); @@ -127,14 +121,10 @@ void RecLoop::init() updateCmd(); Loop::init(); - - funcMsg("exit: RecLoop::init()"); } void RecLoop::updateCmd() { - funcMsg("enter: RecLoop::updateCmd()"); - QStringList recArgs; QStringList imgArgs; @@ -172,39 +162,27 @@ void RecLoop::updateCmd() recLog("img_args: " + imgArgs.join(" "), shared); curUrl = shared->recordUrl; - - funcMsg("exit: RecLoop::updateCmd()"); } void RecLoop::term() { - funcMsg("enter: RecLoop::term()"); - recProc->kill(); recProc->waitForFinished(); imgProc->kill(); imgProc->waitForFinished(); - - funcMsg("exit: RecLoop::term()"); } void RecLoop::reset() { - funcMsg("enter: RecLoop::reset()"); - recLog("--rec_and_img_cmds_resetting--", shared); term(); updateCmd(); - - funcMsg("exit: RecLoop::reset()"); } void RecLoop::procError(const QString &desc, QProcess *proc) { - funcMsg("enter: RecLoop::procError()"); - if (proc->isOpen() && proc->state() == QProcess::NotRunning) { auto errBlob = QString(proc->readAllStandardError()); @@ -218,14 +196,10 @@ void RecLoop::procError(const QString &desc, QProcess *proc) } } } - - funcMsg("exit: RecLoop::procError()"); } void RecLoop::startProc(const QString &desc, QProcess *proc) { - funcMsg("enter: RecLoop::startProc()"); - if (proc->state() == QProcess::NotRunning) { proc->start(); @@ -240,14 +214,10 @@ void RecLoop::startProc(const QString &desc, QProcess *proc) procError(desc, proc); } } - - funcMsg("exit: RecLoop::startProc()"); } bool RecLoop::exec() { - funcMsg("enter: RecLoop::exec()"); - procError("img", imgProc); procError("rec", recProc); @@ -260,8 +230,6 @@ bool RecLoop::exec() startProc("img", imgProc); startProc("rec", recProc); - funcMsg("exit: RecLoop::exec()"); - return Loop::exec(); } @@ -269,8 +237,6 @@ Upkeep::Upkeep(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop(shared bool Upkeep::exec() { - funcMsg("enter: Upkeep::exec()"); - QDir().mkdir("live"); QDir().mkdir("events"); QDir().mkdir("logs"); @@ -297,8 +263,6 @@ bool Upkeep::exec() genCSS(shared); genHTMLul(shared->webRoot, QString(APP_NAME) + " " + QString(APP_VER), shared); - funcMsg("exit: Upkeep::exec()"); - return Loop::exec(); } @@ -311,17 +275,15 @@ EventLoop::EventLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loop( bool EventLoop::exec() { - funcMsg("enter: EventLoop::exec()"); - if (cycles * 2 >= shared->evMaxSecs) { vidList.removeDuplicates(); - if (!vidList.size() > 1) + if (vidList.size() > 1) { recLog("attempting write out of event: " + name, shared); - if (wrOutVod(name, vidList)) + if (wrOutVod()) { genHTMLvod(name); @@ -346,11 +308,10 @@ bool EventLoop::exec() { cycles += 1; - while (!shared->recList.isEmpty()) - { - shared->recMutex.lock(); + shared->recMutex.lock(); - auto event = shared->recList[0]; + for (auto &&event : shared->recList) + { auto maxFiles = shared->evMaxSecs / 2; // there's 2 secs in each hls segment @@ -364,21 +325,17 @@ bool EventLoop::exec() vidList.append(backwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); vidList.removeLast(); vidList.append(forwardFacingFiles("live", ".ts", event.timeStamp, maxFiles / 2)); - - shared->recList.removeFirst(); - shared->recMutex.unlock(); } - } - funcMsg("exit: EventLoop::exec()"); + shared->recList.clear(); + shared->recMutex.unlock(); + } return Loop::exec(); } -bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) +bool EventLoop::wrOutVod() { - funcMsg("enter: EventLoop::wrOutVod()"); - auto cnt = 0; auto concat = name + ".tmp"; auto ret = false; @@ -387,7 +344,7 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) file.open(QFile::WriteOnly); - for (auto &&vid : vids) + for (auto &&vid : vidList) { recLog("event_src: " + vid, shared); @@ -436,8 +393,6 @@ bool EventLoop::wrOutVod(const QString &name, const QStringList &vids) QFile::remove(concat); } - funcMsg("exit: EventLoop::wrOutVod()"); - return ret; } @@ -452,15 +407,12 @@ DetectLoop::DetectLoop(shared_t *sharedRes, QThread *thr, QObject *parent) : Loo void DetectLoop::init() { - funcMsg("enter: DetectLoop::init()"); - pcTimer = new QTimer(this); mod = false; connect(pcTimer, &QTimer::timeout, this, &DetectLoop::pcBreak); resetTimers(); - funcMsg("exit: DetectLoop::init()"); Loop::init(); } @@ -472,8 +424,6 @@ void DetectLoop::resetTimers() void DetectLoop::pcBreak() { - funcMsg("enter: DetectLoop::pcBreak()"); - if (!shared->postCmd.isEmpty()) { detLog("---POST_BREAK---", shared); @@ -492,15 +442,11 @@ void DetectLoop::pcBreak() } } - funcMsg("exit: DetectLoop::pcBreak()"); - mod = false; } bool DetectLoop::exec() { - funcMsg("enter: DetectLoop::exec()"); - if (delayCycles > 0) { delayCycles -= 1; @@ -558,7 +504,5 @@ bool DetectLoop::exec() } } - funcMsg("exit: DetectLoop::exec()"); - return Loop::exec(); } diff --git a/src/camera.h b/src/camera.h index 679e103..fdef187 100644 --- a/src/camera.h +++ b/src/camera.h @@ -107,7 +107,7 @@ private: float highScore; uint cycles; - bool wrOutVod(const QString &name, const QStringList &vids); + bool wrOutVod(); public: diff --git a/src/common.cpp b/src/common.cpp index 9c5846e..c57b72f 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -12,14 +12,6 @@ #include "common.h" -void funcMsg(const QString &line) -{ - if (DEBUG == 1) - { - QTextStream(stdout) << line << Qt::endl; - } -} - QString getParam(const QString &key, const QStringList &args) { // this can be used by command objects to pick out parameters diff --git a/src/common.h b/src/common.h index 1dcb53f..e0b4868 100644 --- a/src/common.h +++ b/src/common.h @@ -39,7 +39,6 @@ using namespace std; #define STRFTIME_FMT "%Y%m%d%H%M%S" #define MAX_IMAGES 1000 #define MAX_VIDEOS 1000 -#define DEBUG 1 struct evt_t { @@ -86,7 +85,6 @@ void rdLine(const QString ¶m, const QString &line, int *value); void enforceMaxEvents(shared_t *share); void enforceMaxImages(); void enforceMaxVids(); -void funcMsg(const QString &line); class MultiInstance : public QObject {