JustMotion/src/common.h
2026-03-11 12:15:23 -04:00

88 lines
2.7 KiB
C++

#ifndef COMMON_H
#define COMMON_H
// This file is part of JustMotion.
// JustMotion 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.
// JustMotion 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 <QCoreApplication>
#include <QProcess>
#include <QTextStream>
#include <QObject>
#include <QDir>
#include <QFile>
#include <QDateTime>
#include <QThread>
#include <QTimer>
#include <QStringList>
#include <QMutex>
#include <QRegularExpression>
#include <QFileSystemWatcher>
#include <QDebug>
#include <QElapsedTimer>
#include <iostream>
using namespace std;
#define APP_VERSION "1.3"
#define APP_NAME "JustMotion"
#define APP_TARGET "jmotion"
#define DATETIME_FMT "yyyyMMddhhmm"
#define STRFTIME_FMT "%Y%m%d%H%M"
#define PREV_IMG "&prev&"
#define NEXT_IMG "&next&"
struct shared_t
{
QStringList recList;
QString conf;
QString recordUri;
QString detectUri;
QString buffPath;
QString postCmd;
QString camName;
QString recPath;
QString outputType;
QString compCmd;
QString vidCodec;
QString audCodec;
QString streamExt;
QString imgExt;
QString thumbExt;
QString recScale;
bool grayImg;
int evtMax;
int liveMins;
int liveClipSecs;
int recFps;
int secPerImg;
int postSecs;
int imgThresh;
int retCode;
};
QString getStatLineFromProc(QProcess *proc);
QString buildThreadCount(int count);
QStringList lsFilesInDir(const QString &path, const QString &ext = QString());
QStringList lsDirsInDir(const QString &path);
QStringList parseArgs(const QByteArray &data, int maxArgs, int *pos = nullptr);
quint64 byteSize(const QString &path);
bool rdConf(const QString &filePath, shared_t *share);
bool mkPath(const QString &path);
void setupBuffDir(const QString &path, bool del = false);
void rdLine(const QString &param, const QString &line, QString *value);
void rdLine(const QString &param, const QString &line, int *value);
void rdLine(const QString &param, const QString &line, quint64 *value);
void rdLine(const QString &param, const QString &line, bool *value);
void extCorrection(QString &ext);
#endif // COMMON_H