#ifndef COMMON_H #define COMMON_H // This file is part of Motion Watch. // Motion Watch is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Motion Watch is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define APP_VER "3.2" #define APP_NAME "Motion Watch" #define APP_BIN "mow" #define REC_LOG_NAME "rec_log_lines.html" #define DET_LOG_NAME "det_log_lines.html" #define UPK_LOG_NAME "upk_log_lines.html" #define DATETIME_FMT "yyyyMMddhhmmss" #define STRFTIME_FMT "%Y%m%d%H%M%S" #define MAX_IMAGES 1000 #define MAX_VIDEOS 1000 #define PREV_IMG "&prev&" #define NEXT_IMG "&next&" struct evt_t { QDateTime timeStamp; QString imgPath; float score; uint queAge; }; struct shared_t { QList recList; QMutex recMutex; QMutex logMutex; QString conf; QString recLog; QString detLog; QString recordUrl; QString outDir; QString tmpDir; QString buffPath; QString postCmd; QString camName; QString webBg; QString webTxt; QString webFont; QString webRoot; QString servPath; QString outputType; QString compCmd; bool skipCmd; int evMaxSecs; int postSecs; int imgThresh; int maxEvents; int maxLogSize; int retCode; }; QString getParam(const QString &key, const QStringList &args); QStringList lsFilesInDir(const QString &path, const QString &ext = QString()); QStringList lsDirsInDir(const QString &path); QStringList listFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs, char dir); QStringList backwardFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs); QStringList forwardFacingFiles(const QString &path, const QString &ext, const QDateTime &stamp, int secs); QStringList parseArgs(const QByteArray &data, int maxArgs, int *pos = nullptr); bool rdConf(const QString &filePath, shared_t *share); int loadServices(const QStringList &args); void listServices(); void rmServices(); void touch(const QString &path); void rdLine(const QString ¶m, const QString &line, QString *value); void rdLine(const QString ¶m, const QString &line, int *value); void enforceMaxEvents(shared_t *share); void enforceMaxImages(); void enforceMaxVids(); #endif // COMMON_H