2022-09-22 20:57:46 -04:00
|
|
|
#ifndef COMMON_H
|
|
|
|
#define COMMON_H
|
|
|
|
|
2024-04-10 20:51:56 -04:00
|
|
|
// This file is part of JustMotion.
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2024-04-10 20:51:56 -04:00
|
|
|
// JustMotion is free software: you can redistribute it and/or modify
|
2022-09-22 20:57:46 -04:00
|
|
|
// 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.
|
|
|
|
|
2024-04-10 20:51:56 -04:00
|
|
|
// JustMotion is distributed in the hope that it will be useful,
|
2022-09-22 20:57:46 -04:00
|
|
|
// 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.
|
|
|
|
|
2025-02-01 09:59:19 -05:00
|
|
|
#define FUSE_USE_VERSION 31
|
|
|
|
|
2023-05-15 15:29:47 -04:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QDateTime>
|
2023-05-15 19:39:29 -04:00
|
|
|
#include <QThread>
|
2023-05-21 09:34:57 -04:00
|
|
|
#include <QTimer>
|
2023-05-26 16:12:53 -04:00
|
|
|
#include <QStringList>
|
2023-06-10 21:51:39 -04:00
|
|
|
#include <QMutex>
|
2023-10-08 10:09:15 -04:00
|
|
|
#include <QRegularExpression>
|
2023-11-18 18:40:26 -05:00
|
|
|
#include <QFileSystemWatcher>
|
2024-04-21 08:03:30 -04:00
|
|
|
#include <QDebug>
|
|
|
|
#include <QElapsedTimer>
|
2025-02-01 09:59:19 -05:00
|
|
|
#include <QMutex>
|
2023-07-31 11:16:07 -04:00
|
|
|
#include <iostream>
|
2025-02-01 09:59:19 -05:00
|
|
|
#include <fuse3/fuse.h>
|
|
|
|
#include <fuse3/fuse_lowlevel.h>
|
|
|
|
#include <fuse3/fuse_common.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <cstring>
|
|
|
|
#include <unistd.h>
|
2022-09-22 20:57:46 -04:00
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
2025-02-23 09:24:35 -05:00
|
|
|
#define APP_VERSION "3.6.t10"
|
2024-04-10 20:51:56 -04:00
|
|
|
#define APP_NAME "JustMotion"
|
|
|
|
#define APP_TARGET "jmotion"
|
2023-05-26 16:12:53 -04:00
|
|
|
#define DATETIME_FMT "yyyyMMddhhmmss"
|
2024-11-21 19:06:59 -05:00
|
|
|
#define STRFTIME_FMT "%Y%m%d%H%M%S"
|
2023-08-06 10:17:10 -04:00
|
|
|
#define PREV_IMG "&prev&"
|
|
|
|
#define NEXT_IMG "&next&"
|
2025-02-01 09:59:19 -05:00
|
|
|
#define BLK_SIZE 262144
|
2022-09-22 20:57:46 -04:00
|
|
|
|
2023-10-27 15:43:17 -04:00
|
|
|
enum CmdExeType
|
|
|
|
{
|
|
|
|
MAIN_LOOP,
|
2023-11-05 18:44:50 -05:00
|
|
|
VID_LOOP
|
2023-10-27 15:43:17 -04:00
|
|
|
};
|
|
|
|
|
2025-02-01 09:59:19 -05:00
|
|
|
class ProcControl;
|
|
|
|
class Camera;
|
|
|
|
|
2023-04-20 14:52:59 -04:00
|
|
|
struct evt_t
|
2023-03-05 16:07:07 -05:00
|
|
|
{
|
2025-02-01 09:59:19 -05:00
|
|
|
QStringList vidList;
|
|
|
|
QString timeStamp;
|
|
|
|
QString imgPath;
|
|
|
|
float score;
|
|
|
|
bool inQue;
|
|
|
|
int queAge;
|
|
|
|
};
|
|
|
|
|
|
|
|
class file_t
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
quint64 ino;
|
|
|
|
quint64 ctime;
|
|
|
|
quint64 mtime;
|
|
|
|
quint32 mode;
|
|
|
|
qint32 blks;
|
|
|
|
QByteArray bytes;
|
2023-03-05 16:07:07 -05:00
|
|
|
};
|
|
|
|
|
2022-09-22 20:57:46 -04:00
|
|
|
struct shared_t
|
|
|
|
{
|
2023-05-15 15:29:47 -04:00
|
|
|
QList<evt_t> recList;
|
2025-02-01 09:59:19 -05:00
|
|
|
QString rdMnt;
|
2023-05-15 15:29:47 -04:00
|
|
|
QString conf;
|
2025-02-01 09:59:19 -05:00
|
|
|
QString confPath;
|
2023-10-08 10:09:15 -04:00
|
|
|
QString recordUri;
|
2023-07-18 18:47:14 -04:00
|
|
|
QString buffPath;
|
2025-02-01 09:59:19 -05:00
|
|
|
QString varPath;
|
2023-05-15 15:29:47 -04:00
|
|
|
QString postCmd;
|
|
|
|
QString camName;
|
2023-10-19 15:04:39 -04:00
|
|
|
QString recPath;
|
2023-08-06 10:17:10 -04:00
|
|
|
QString outputType;
|
|
|
|
QString compCmd;
|
2024-04-03 17:28:53 -04:00
|
|
|
QString vidCodec;
|
|
|
|
QString audCodec;
|
2023-10-08 10:09:15 -04:00
|
|
|
QString streamExt;
|
|
|
|
QString recExt;
|
|
|
|
QString thumbExt;
|
2023-10-19 15:04:39 -04:00
|
|
|
QString recScale;
|
|
|
|
QString imgScale;
|
2025-02-01 09:59:19 -05:00
|
|
|
quint64 maxMemSize;
|
2023-11-05 18:44:50 -05:00
|
|
|
int liveSecs;
|
2023-10-19 15:04:39 -04:00
|
|
|
int recFps;
|
2023-05-15 15:29:47 -04:00
|
|
|
int evMaxSecs;
|
|
|
|
int postSecs;
|
|
|
|
int imgThresh;
|
|
|
|
int maxEvents;
|
|
|
|
int retCode;
|
2023-02-07 23:19:41 -05:00
|
|
|
};
|
|
|
|
|
2025-02-01 09:59:19 -05:00
|
|
|
|
|
|
|
|
2023-10-19 15:04:39 -04:00
|
|
|
QString buildThreadCount(int count);
|
2023-05-15 15:29:47 -04:00
|
|
|
QStringList lsFilesInDir(const QString &path, const QString &ext = QString());
|
|
|
|
QStringList lsDirsInDir(const QString &path);
|
2023-05-26 16:12:53 -04:00
|
|
|
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);
|
2023-08-06 10:17:10 -04:00
|
|
|
QStringList parseArgs(const QByteArray &data, int maxArgs, int *pos = nullptr);
|
2025-02-01 09:59:19 -05:00
|
|
|
bool rdConf(const QString &filePath, shared_t *share, bool reset = true);
|
2023-10-19 15:04:39 -04:00
|
|
|
bool mkPath(const QString &path);
|
2023-05-15 15:29:47 -04:00
|
|
|
void rdLine(const QString ¶m, const QString &line, QString *value);
|
|
|
|
void rdLine(const QString ¶m, const QString &line, int *value);
|
2025-02-01 09:59:19 -05:00
|
|
|
void rdLine(const QString ¶m, const QString &line, quint64 *value);
|
2023-10-08 10:09:15 -04:00
|
|
|
void rdLine(const QString ¶m, const QString &line, bool *value);
|
2023-05-15 15:29:47 -04:00
|
|
|
void enforceMaxEvents(shared_t *share);
|
2023-10-19 15:04:39 -04:00
|
|
|
void enforceMaxImages(shared_t *share);
|
2023-11-05 18:44:50 -05:00
|
|
|
void enforceMaxClips(shared_t *share);
|
2023-10-08 10:09:15 -04:00
|
|
|
void extCorrection(QString &ext);
|
2022-09-22 20:57:46 -04:00
|
|
|
|
|
|
|
#endif // COMMON_H
|