1136 lines
32 KiB
C++
1136 lines
32 KiB
C++
#include "rm_video_item_2ch.h"
|
|
|
|
#if (RM_USE_SEPARATED_CH_FILE)
|
|
|
|
#include <assert.h>
|
|
#include <qdebug.h>
|
|
#include <qlist.h>
|
|
#include <qdir.h>
|
|
#include <qfileinfo.h>
|
|
|
|
#include "rm_format_avi.h"
|
|
#include "rm_format_mov.h"
|
|
#include "fileio.h"
|
|
#include "../core/fm_strings.h"
|
|
//#include "rm_fileio.h"
|
|
|
|
#include "rm_video_list.h"
|
|
#include "rm_sensordata.h"
|
|
|
|
#if (TRI_CHANNEL)
|
|
RMVideoItem::RMVideoItem(QString path,int ch,QDateTime* pDateTime)
|
|
#else
|
|
RMVideoItem::RMVideoItem(QString path,bool CH2,QDateTime* pDateTime)
|
|
#endif
|
|
{
|
|
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
decodedPath = "";
|
|
#endif
|
|
#if (TRI_CHANNEL2)
|
|
_realCHCount = 0;
|
|
#endif // TRI_CHANNEL2
|
|
filePath = path;
|
|
|
|
added = true; // 추가시 초기화
|
|
if(RMVideoItem::FileExist(filePath) == false)
|
|
{
|
|
return;
|
|
}
|
|
|
|
fileName = QFileInfo(filePath).baseName();
|
|
|
|
//QFileInfo* fileInfo = new QFileInfo(filePath);
|
|
//QString fileExtension = fileInfo->suffix();
|
|
//delete fileInfo;
|
|
|
|
checked = false;
|
|
sensorData = NULL;
|
|
_durationInMSecs = 0;
|
|
width = 0;
|
|
height = 0;
|
|
|
|
#if (RM_MODEL_EMT_KR)
|
|
modelName = "";
|
|
#endif
|
|
|
|
#if (DUAL_CH_FILE && DUAL_CH_1CH_EXIST)
|
|
only1CH = false;
|
|
#endif
|
|
|
|
if(pDateTime != NULL)
|
|
{
|
|
_dateTime = *pDateTime;
|
|
}
|
|
#if !(SKIP_VIDEO_PREINFO)
|
|
#if (TRI_CHANNEL)
|
|
_loadDuration(ch);
|
|
#else // TRI_CHANNEL
|
|
_loadDuration(CH2);
|
|
#endif // TRI_CHANNEL
|
|
#endif // SKIP_VIDEO_PREINFO
|
|
|
|
#if (PRE_LOAD_SENSOR_DATA)
|
|
if(isValid() && getSensorData() == NULL) {
|
|
|
|
//qInfo() << path;
|
|
loadSensorInfo();
|
|
}
|
|
#endif // PRE_LOAD_SENSOR_DATA
|
|
|
|
|
|
// load pre info 에서 filePath 를 사용하므로 마지막에 처리
|
|
// 생성자라 filePathCH2 나 filePath 는 제거해도 관계 없음
|
|
#if (PENTA_CHANNEL)
|
|
filePath = path;
|
|
filePathCH2 = "";
|
|
filePathCH3 = "";
|
|
filePathCH4 = "";
|
|
filePathCH5 = "";
|
|
#else // PENTA_CHANNEL
|
|
#if (TRI_CHANNEL)
|
|
if (ch == 1) // 이미 저장
|
|
{
|
|
filePathCH2 = "";
|
|
filePathCH3 = "";
|
|
}
|
|
else if (ch == 2)
|
|
{
|
|
filePath = "";
|
|
filePathCH2 = filePath;
|
|
filePathCH3 = "";
|
|
}
|
|
else
|
|
{
|
|
filePath = "";
|
|
filePathCH2 = "";
|
|
filePathCH3 = filePath;
|
|
}
|
|
#else // TRI_CHANNEL
|
|
if (CH2 == false)
|
|
{
|
|
filePathCH2 = "";
|
|
}
|
|
else
|
|
{
|
|
filePathCH2 = filePath;
|
|
filePath = "";
|
|
}
|
|
#endif // TRI_CHANNEL
|
|
#endif // #else // PENTA_CHANNEL
|
|
|
|
_fileSize = 0;
|
|
}
|
|
|
|
|
|
#include <Windows.h>
|
|
bool RMVideoItem::FileExist(QString filePath)
|
|
{
|
|
#ifdef Q_OS_WIN
|
|
DWORD dwAttrib = ::GetFileAttributes((LPCTSTR)filePath.utf16());
|
|
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
|
|
!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
|
|
|
#else
|
|
return QFile::exists(filePath);
|
|
#endif
|
|
}
|
|
RMVideoItem::~RMVideoItem()
|
|
{
|
|
if(sensorData != NULL)
|
|
{
|
|
delete sensorData;
|
|
sensorData = NULL;
|
|
}
|
|
}
|
|
|
|
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
void RMVideoItem::removeTemp()
|
|
{
|
|
//qInfo() << __FUNCTION__;
|
|
if(!decodedPath.isEmpty() && QFile(decodedPath).exists()) {
|
|
QFile(decodedPath).remove();
|
|
}
|
|
decodedPath = "";
|
|
}
|
|
#endif // RM_MODEL_TYPE_AN6000
|
|
|
|
QDateTime RMVideoItem::dateTimeInPosition(qreal ratio,double* lat, double* lon)
|
|
{
|
|
//qInfo() << __FUNCTION__;
|
|
|
|
QDateTime dateTime;
|
|
if(lat != NULL && lon != NULL) {
|
|
*lat = *lon = 0.0;
|
|
}
|
|
|
|
// 없으면 시작시간 +
|
|
#if (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
if(true) // GPS 데이터와 시간은 다름
|
|
#else
|
|
if(sensorData == NULL || sensorData->getGPSCount() == 0)
|
|
#endif
|
|
{
|
|
dateTime = _dateTime;
|
|
double ds = (double)(_durationInMSecs) / 1000.0 * ratio;
|
|
dateTime = dateTime.addSecs( (qint64)floor(ds));
|
|
return dateTime;
|
|
}
|
|
|
|
|
|
unsigned int index = (int)((double)(sensorData->getGPSCount()) * ratio);
|
|
|
|
if(index < sensorData->getGPSCount())
|
|
{
|
|
const NMEA_INFO* gps = sensorData->getGPS();
|
|
|
|
QDate date = QDate(gps[index].nYear,gps[index].nMonth,gps[index].nDay);
|
|
dateTime.setDate(date);
|
|
|
|
QTime time = QTime(gps[index].nHour,gps[index].nMin,gps[index].nSec);
|
|
//qInfo() << time << __FUNCTION__;
|
|
|
|
dateTime.setTime(time);
|
|
|
|
//qInfo() << anyFilePath() << __FUNCTION__;
|
|
// XDR-66은 9시간 더해야함
|
|
if(anyFilePath().endsWith(".MOV",Qt::CaseInsensitive)) {
|
|
dateTime = dateTime.addSecs(3600 * 9); // UTC +9
|
|
}
|
|
if(lat != NULL && lon != NULL) {
|
|
*lat = gps[index].Latitude;
|
|
*lon = gps[index].Longitude;
|
|
}
|
|
}
|
|
return dateTime;
|
|
}
|
|
|
|
|
|
int RMVideoItem::IsFeasible(QString path, QDateTime* pDateTime)
|
|
{
|
|
if(QFile::exists(path) == false)
|
|
{
|
|
return RMVideoFileList::TYPE_UNDEFINED;
|
|
}
|
|
|
|
RMVideoFileList::GROUP_TYPE type = RMVideoFileList::TYPE_UNDEFINED;
|
|
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
int serial = 0;
|
|
QString baseName = RMVideoFileList::groupTypeFromFilePath(path,&type,&serial);
|
|
#else // RM_MODEL_TYPE_AN6000
|
|
QString baseName = RMVideoFileList::groupTypeFromFilePath(path,&type);
|
|
#endif // RM_MODEL_TYPE_AN6000
|
|
|
|
if(baseName.isEmpty()) {
|
|
return RMVideoFileList::TYPE_UNDEFINED;
|
|
}
|
|
QDateTime dateTime = RMVideoItem::_fileNameToDateTime(baseName);
|
|
#if (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
// 동일한 시간대의 영상파일(1)을 -> msec 로 시간 추가하여 정렬
|
|
dateTime = dateTime.addMSecs(serial);
|
|
#endif // #if (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
|
|
if(dateTime.isValid() == false)
|
|
{
|
|
#if (RM_SHOW_LIST_LOADING_ERROR)
|
|
RMVideoFileList::GetInstance()->loadingError = RMVideoFileList::LIST_LOADING_ERROR_NAME;
|
|
RMVideoFileList::GetInstance()->loadingErrorPath = path;
|
|
#endif
|
|
return RMVideoFileList::TYPE_UNDEFINED;
|
|
}
|
|
if(pDateTime != NULL)
|
|
{
|
|
*pDateTime = dateTime;
|
|
}
|
|
return (int)type;
|
|
}
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
void RMVideoItem::print()
|
|
{
|
|
qInfo() << filePath << ":" << filePathCH2;
|
|
}
|
|
#endif
|
|
QString RMVideoItem::titlePrefix()
|
|
{
|
|
QFileInfo info = QFileInfo(anyFilePath());
|
|
return info.baseName().split("_")[0];
|
|
}
|
|
QString RMVideoItem::typeString()
|
|
{
|
|
QString baseName = QFileInfo(anyFilePath()).baseName();
|
|
#if (RM_MODEL == RM_MODEL_TYPE_ADT_CAPS && !SUB_MODEL_CARROT_EMT)
|
|
if(baseName.contains("event",Qt::CaseInsensitive)) {
|
|
// 충격
|
|
return MKU8("\xec\xb6\xa9\xea\xb2\xa9");
|
|
}
|
|
else if(baseName.contains("motion",Qt::CaseInsensitive)) {
|
|
// 주차
|
|
return MKU8("\xec\xa3\xbc\xec\xb0\xa8");
|
|
}
|
|
else if(baseName.contains("parkevt",Qt::CaseInsensitive)) {
|
|
// 주차충격
|
|
return MKU8("\xec\xa3\xbc\xec\xb0\xa8\xec\xb6\xa9\xea\xb2\xa9");
|
|
}
|
|
//상시
|
|
return MKU8("\xec\x83\x81\xec\x8b\x9c");
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
return "";
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_NX_DRW22)
|
|
|
|
if(baseName.startsWith("EMER",Qt::CaseInsensitive)) {
|
|
// 衝撃/手動
|
|
return MKU8("\xe8\xa1\x9d\xe6\x92\x83\x2f\xe6\x89\x8b\xe5\x8b\x95");
|
|
}
|
|
//常時
|
|
return MKU8("\xe5\xb8\xb8\xe6\x99\x82");
|
|
#elif (!MODEL_KOREAN_ONLY && (RM_MODEL == RM_MODEL_TYPE_KEIYO1 || RM_MODEL == RM_MODEL_TYPE_MBJ5010 || RM_MODEL == RM_MODEL_TYPE_FC_DR232W))
|
|
switch (type) {
|
|
case RMVideoFileList::TYPE_EVENT:
|
|
return MKU8("\xe8\xa1\x9d\xe6\x92\x83\xe6\xa4\x9c\xe7\x9f\xa5"); // 衝撃検知
|
|
case RMVideoFileList::TYPE_MANUAL:
|
|
return MKU8("\xe6\x89\x8b\xe5\x8b\x95"); // 手動
|
|
case RMVideoFileList::TYPE_PARKING:
|
|
// 주차 이벤트가 파킹, 주차감시로 구분되어 별도처리
|
|
// PNOR190120-211045F.MP4 // 주차 상시
|
|
if (baseName.startsWith("PNOR"))
|
|
{
|
|
return MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe7\x9b\xa3\xe8\xa6\x96"); // 駐車監視
|
|
}
|
|
// if(baseName.startsWith("PARK"))
|
|
return MKU8("\xe3\x83\x91\xe3\x83\xbc\xe3\x82\xad\xe3\x83\xb3\xe3\x82\xb0");
|
|
case RMVideoFileList::TYPE_PARKING_EVENT:
|
|
return MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe8\xa1\x9d\xe6\x92\x83"); // 駐車衝撃
|
|
case RMVideoFileList::TYPE_NORMAL:
|
|
default:
|
|
return MKU8("\xe5\xb8\xb8\xe6\x99\x82"); // 常時
|
|
break;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_BV2000 || MODEL_KOREAN_ONLY || RM_MODEL == RM_MODEL_TYPE_MH9000)
|
|
{
|
|
switch (type) {
|
|
case RMVideoFileList::TYPE_EVENT:
|
|
return FMS::txt("type_event"); // 衝撃検知;
|
|
case RMVideoFileList::TYPE_MANUAL:
|
|
return FMS::txt("type_manual"); //手動
|
|
case RMVideoFileList::TYPE_PARKING:
|
|
// 주차 이벤트가 파킹, 주차감시로 구분되어 별도처리
|
|
// PNOR190120-211045F.MP4 // 주차 상시
|
|
if (baseName.startsWith("PNOR"))
|
|
{
|
|
return FMS::txt("type_parking_normal"); // 駐車監視
|
|
}
|
|
return FMS::txt("type_parking"); // パーキング
|
|
case RMVideoFileList::TYPE_PARKING_EVENT:
|
|
return FMS::txt("type_parking_event"); // 駐車衝撃
|
|
case RMVideoFileList::TYPE_NORMAL:
|
|
default:
|
|
return FMS::txt("type_normal"); // 常時
|
|
break;
|
|
}
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_XLDR_88)
|
|
// S200827_100830FN_Exit
|
|
QString typeString = baseName.mid(14,2).toUpper();
|
|
if(typeString == "FE") {
|
|
return MKU8("\xe8\xa1\x9d\xe6\x92\x83");
|
|
}
|
|
else if(typeString == "FP") {
|
|
if (baseName.length() > 16 && baseName.mid(16,1).toUpper() == "E") { // FPE (PARKING EVENT)
|
|
return MKU8("\xe9\xa7\x90\xe8\xbb\x8a\xe8\xa1\x9d\xe6\x92\x83"); // 2021/07/22 주차 충격
|
|
}
|
|
return MKU8("\xe9\xa7\x90\xe8\xbb\x8a");
|
|
}
|
|
else {
|
|
return MKU8("\xe5\xb8\xb8\xe6\x99\x82");
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_TBD360)
|
|
if(baseName.endsWith("_Gsn",Qt::CaseInsensitive)) {
|
|
return "EVENT";
|
|
}
|
|
//if(baseName.endsWith("_Nor",Qt::CaseInsensitive)) {
|
|
return "NORMAL";
|
|
//}
|
|
#elif (SUB_MODEL_CARROT_EMT)
|
|
return FM_WSTR(L"상시");
|
|
#else
|
|
return "TBD";
|
|
#endif
|
|
}
|
|
|
|
#if (CHECK_VIDEO_BITRATE)
|
|
void RMVideoItem::testBitrate2CH()
|
|
{
|
|
if(filePathCH2.length() > 0) {
|
|
#if (USE_WFOPEN)
|
|
FILE *f = _wfopen(filePathCH2.toStdWString().c_str(),L"rb");
|
|
#else
|
|
FILE *f = fopen(filePathCH2.toLocal8Bit(),"rb");
|
|
#endif
|
|
if(f != NULL)
|
|
{
|
|
VideoPreInfo info = {0,};
|
|
|
|
#if (FILE_FORMAT_MOV)
|
|
if(anyFilePath().toUpper().endsWith(FILE_EXT))
|
|
{
|
|
MOVFormat::movSize(f,&info);
|
|
if(MOVFormat::videoBitrate(&info) < 200)
|
|
{
|
|
filePathCH2 = ""; // 제거
|
|
}
|
|
}
|
|
else
|
|
#endif // FILE_FORMAT_MOV
|
|
{
|
|
AVIRiff::movSize(f,&info);
|
|
if(AVIRiff::videoBitrate(&info) < 200)
|
|
{
|
|
filePathCH2 = ""; // 제거
|
|
}
|
|
}
|
|
|
|
fclose(f);
|
|
}
|
|
}
|
|
}
|
|
#endif // #if (CHECK_VIDEO_BITRATE)
|
|
|
|
#if (RM_MODEL_EMT_KR)
|
|
QString RMVideoItem::title()
|
|
{
|
|
return QFileInfo(anyFilePath()).baseName();
|
|
}
|
|
#else // RM_MODEL_EMT_KR
|
|
QString RMVideoItem::title()
|
|
{
|
|
QString baseName = QFileInfo(anyFilePath()).baseName();
|
|
#if (RM_MODEL == 1)
|
|
QStringList ls = baseName.split("-");
|
|
return ls[0] + "-" + ls[1];
|
|
#elif (RM_MODEL == 4 || RM_MODEL == 6 || RM_MODEL == 7 || RM_MODEL == 8)
|
|
baseName.truncate(baseName.length()-1);
|
|
return baseName;
|
|
#elif (RM_MODEL == 3)
|
|
return titleDate() + " " + titleTime();
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_MH9000)
|
|
return baseName.mid(0,baseName.length()-2);
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
return baseName;
|
|
#else
|
|
QStringList ls = baseName.split("_");
|
|
if(ls.length() == 1) {
|
|
return ls[0];
|
|
}
|
|
return ls[0] + "-" + ls[1];
|
|
#endif
|
|
}
|
|
#endif
|
|
#if !(DUAL_CH_FILE || SINGLE_CH_VIEWER)
|
|
QString RMVideoItem::titleFrontRear()
|
|
{
|
|
#if (LIVE_LANGUAGE_CHANGE)
|
|
#if (FORCE_FM_STRING)
|
|
if(filePath.isEmpty() || filePathCH2.isEmpty()) {
|
|
return FMS::txt("front"); //isJP ? MKU8("\xe5\x89\x8d") : "F";
|
|
}
|
|
return FMS::txt("front_and_rear"); //isJP ? MKU8("\xe5\x89\x8d\xe5\xbe\x8c") : "F/R";
|
|
#else // FORCE_FM_STRING
|
|
bool isJP = RMLanguage::isJP();
|
|
if(filePath.isEmpty() || filePathCH2.isEmpty()) {
|
|
return isJP ? MKU8("\xe5\x89\x8d") : "F";
|
|
}
|
|
return isJP ? MKU8("\xe5\x89\x8d\xe5\xbe\x8c") : "F/R";
|
|
#endif // FORCE_FM_STRING
|
|
#else // LIVE_LANGUAGE_CHANGE
|
|
// 전으로만 표시
|
|
if(filePath.isEmpty() || filePathCH2.isEmpty()) {
|
|
return MKU8("\xe5\x89\x8d");
|
|
}
|
|
return MKU8("\xe5\x89\x8d\xe5\xbe\x8c");
|
|
#endif // LIVE_LANGUAGE_CHANGE
|
|
// QString f(filePath.isEmpty() ? "" : QString::fromUtf8("\xe5\x89\x8d")); // 전
|
|
// QString r(filePathCH2.isEmpty() ? "" : QString::fromUtf8("\xe5\xbe\x8c")); // 후
|
|
// return f + r;
|
|
}
|
|
#endif
|
|
QString RMVideoItem::titleDuration()
|
|
{
|
|
int sec = _durationInMSecs / 1000;
|
|
int min = (int)(sec / 60);
|
|
if(min > 0)
|
|
{
|
|
sec = sec - (min * 60);
|
|
}
|
|
QString timeString;
|
|
#if (MODEL_WATEX)
|
|
timeString.sprintf("00:%02d:%02d",min,sec);
|
|
#else
|
|
timeString.sprintf("%02d:%02d",min,sec);
|
|
#endif
|
|
return timeString;
|
|
}
|
|
QString RMVideoItem::titleSize()
|
|
{
|
|
if(_fileSize == 0)
|
|
{
|
|
if(filePath.length() > 0)
|
|
{
|
|
_fileSize += QFileInfo(filePath).size();
|
|
}
|
|
if(filePathCH2.length() > 0)
|
|
{
|
|
_fileSize += QFileInfo(filePathCH2).size();
|
|
}
|
|
}
|
|
QString sizeString;
|
|
sizeString.sprintf("%dMB", _fileSize / (1024 * 1024));
|
|
return sizeString;
|
|
}
|
|
QString RMVideoItem::titleCapture(qint64 secs)
|
|
{
|
|
// 슬라이더 재생시간 초 사용
|
|
// 슬라이더에서 표시 시점에서 업데이트
|
|
QDateTime captureTime = _dateTime.addMSecs(secs);
|
|
// NEF_190622-172014
|
|
QString prefix = title().split("_")[0];
|
|
|
|
QString suffix = QString::asprintf("%02d%02d%02d-%02d%02d%02d",
|
|
captureTime.date().year()-2000,
|
|
captureTime.date().month(),
|
|
captureTime.date().day(),
|
|
captureTime.time().hour(),
|
|
captureTime.time().minute(),
|
|
captureTime.time().second());
|
|
|
|
return prefix + QString("_") + suffix;
|
|
}
|
|
QString RMVideoItem::titleDateTime()
|
|
{
|
|
if(_dateTime.isValid() == true)
|
|
{
|
|
return _dateTime.toString("yyyy-MM-dd HH:mm:ss");
|
|
}
|
|
return "---------- --:--:--";
|
|
}
|
|
|
|
QString RMVideoItem::titleDate()
|
|
{
|
|
if(_dateTime.isValid() == true)
|
|
{
|
|
return _dateTime.toString("yyyy-MM-dd");
|
|
}
|
|
return "NONAME";
|
|
}
|
|
QString RMVideoItem::titleTime()
|
|
{
|
|
if(_dateTime.isValid() == true)
|
|
{
|
|
return _dateTime.toString("HH:mm:ss");
|
|
}
|
|
return "NONAME";
|
|
}
|
|
void RMVideoItem::loadSensorInfo()
|
|
{
|
|
|
|
|
|
// 한번 로딩하면 다시 로딩하지 않음
|
|
if(sensorData == NULL)
|
|
{
|
|
RMSensorData::FILE_TYPE fileType = (RMSensorData::FILE_TYPE)fileFormat();
|
|
|
|
//#if (FILE_FORMAT_MOV && FILE_FORMAT_AVI)
|
|
// RMSensorData::FILE_TYPE fileType = RMSensorData::FILE_TYPE_MOV;
|
|
//#elif (FILE_FORMAT_MOV)
|
|
// RMSensorData::FILE_TYPE fileType = RMSensorData::FILE_TYPE_MOV;
|
|
//#elif (FILE_FORMAT_AVI)
|
|
// RMSensorData::FILE_TYPE fileType = RMSensorData::FILE_TYPE_AVI;
|
|
//#endif
|
|
// qInfo() << "LOAD SENSOR:" << anyFilePath();
|
|
#if (USE_WFOPEN)
|
|
FILE *f = _wfopen(anyFilePath().toStdWString().c_str(),L"rb");
|
|
#else
|
|
FILE *f = fopen(anyFilePath().toLocal8Bit(),"rb");
|
|
#endif
|
|
|
|
// 재생시간도 확인
|
|
#if (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
VideoPreInfo info = {0,};
|
|
MOVFormat::duration(f,&info);
|
|
_durationInMSecs = info.duration;
|
|
#endif // TB4000
|
|
assert (f!=NULL);
|
|
sensorData = new RMSensorData(f,fileType);
|
|
#if (SENSOR_MATCH_DURATION)
|
|
sensorData->processWithDuration(_durationInMSecs);
|
|
#endif
|
|
|
|
#if (RM_MODEL_EMT_KR)
|
|
modelName = sensorData->modelName;
|
|
#endif
|
|
|
|
|
|
#if (CLIP_SENSOR_DATA)
|
|
sensorData->clipWithDuration(_durationInMSecs);
|
|
sensorData->fixGPS();
|
|
#endif
|
|
fclose(f);
|
|
}
|
|
}
|
|
|
|
QString RMVideoItem::durationString(unsigned int msec,bool hms)
|
|
{
|
|
QString timeString;
|
|
// 1초 단위로 ceil 처리
|
|
int sec = msec / 1000;
|
|
if(sec < 60) // 초단위 재생
|
|
{
|
|
#if (MODEL_WATEX)
|
|
if(hms)
|
|
{
|
|
timeString.sprintf("00:00:%02d",sec);
|
|
}
|
|
else
|
|
{
|
|
timeString.sprintf("00:00:%02d",sec);
|
|
}
|
|
#else
|
|
if(hms)
|
|
{
|
|
timeString.sprintf("00:%02d",sec);
|
|
}
|
|
else
|
|
{
|
|
timeString.sprintf("00:%02d",sec);
|
|
}
|
|
#endif
|
|
}
|
|
else if(sec < (60 * 60)) // 분단위 재생
|
|
{
|
|
int min = sec > 0 ? sec / 60 : 0;
|
|
sec = sec - (min * 60);
|
|
#if (MODEL_WATEX)
|
|
if(hms)
|
|
{
|
|
timeString.sprintf("00:%02d:%02d",min,sec);
|
|
}
|
|
else
|
|
{
|
|
timeString.sprintf("00:%02d:%02d",min,sec);
|
|
}
|
|
#else
|
|
if(hms)
|
|
{
|
|
timeString.sprintf("%02d:%02d",min,sec);
|
|
}
|
|
else
|
|
{
|
|
timeString.sprintf("%02d:%02d",min,sec);
|
|
}
|
|
#endif
|
|
}
|
|
else
|
|
{
|
|
int hour = sec / 3600;
|
|
int mH = (sec - (hour * 3600));
|
|
int min = mH == 0 ? 0 : (sec - (hour * 3600)) / 60;
|
|
sec = (sec - ((hour * 3600) + (min * 60)));
|
|
if(hms)
|
|
{
|
|
timeString.sprintf("%02d:%02d:%02",hour,min,sec);
|
|
}
|
|
else
|
|
{
|
|
timeString.sprintf("%02d:%02d:%02",hour,min,sec);
|
|
}
|
|
}
|
|
return timeString;
|
|
}
|
|
int RMVideoItem::fileFormat()
|
|
{
|
|
QString ext = QFileInfo(anyFilePath()).suffix().toUpper();
|
|
#if (USE_FFMPEG_PW)
|
|
#if (SUPPORT_MP4TB4)
|
|
if(ext == "TB4" || ext == "MP4")
|
|
#else // SUPPORT_MP4TB4
|
|
if(ext == "TB4")
|
|
#endif // SUPPORT_MP4TB4
|
|
{
|
|
return RMSensorData::FILE_TYPE_MOV;
|
|
}
|
|
#else // USE_FFMPEG_PW
|
|
#if (FILE_FORMAT_MOV)
|
|
if(ext == "MOV" || ext == "MP4")
|
|
{
|
|
return RMSensorData::FILE_TYPE_MOV;
|
|
}
|
|
#endif
|
|
|
|
#if (FILE_FORMAT_AVI)
|
|
if (ext == "AVI")
|
|
{
|
|
return RMSensorData::FILE_TYPE_AVI;
|
|
}
|
|
#endif
|
|
#endif // USE_FFMPEG_PW
|
|
return -1;
|
|
}
|
|
#if (CHECK_REAR_DURATION)
|
|
bool RMVideoItem::isRearDuration()
|
|
{
|
|
if(!filePathCH2.isEmpty()) {
|
|
bool bRear = _loadDuration(true);
|
|
#if(REMOVE_REAR_BY_DURATION)
|
|
if(!bRear) // 후방만 없을 경우
|
|
{
|
|
filePathCH2 = "";
|
|
}
|
|
return (_durationInMSecs > 300);
|
|
#else
|
|
return bRear;//(_durationInMSecs > 300);
|
|
#endif
|
|
}
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
#if (TRI_CHANNEL)
|
|
QString RMVideoItem::filePathWithCH(int ch)
|
|
{
|
|
QString path;
|
|
if(ch == 1) {
|
|
path = filePath;
|
|
}
|
|
else if (ch == 2) {
|
|
path = filePathCH2;
|
|
}
|
|
else if (ch == 3) {
|
|
path = filePathCH3;
|
|
}
|
|
if (path.isEmpty()) {
|
|
path = anyFilePath();
|
|
}
|
|
return path;
|
|
}
|
|
#endif
|
|
|
|
#if (TRI_CHANNEL)
|
|
bool RMVideoItem::_loadDuration(int ch) // 1,2,3
|
|
#else
|
|
bool RMVideoItem::_loadDuration(bool rear)
|
|
#endif
|
|
{
|
|
bool bSuccess = true;
|
|
#if (TEST_DURATION_CHECK_SKIP)
|
|
_durationInMSecs = 1;
|
|
#else
|
|
#if (USE_WIN32_FILE_API_ONLY)
|
|
HANDLE f = ::CreateFile((LPCTSTR)filePath.utf16(),GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
|
if(f != INVALID_HANDLE_VALUE && f != NULL)
|
|
{
|
|
_durationInMSecs = AVIRiff::duration(f);
|
|
::CloseHandle(f);
|
|
}
|
|
#else
|
|
|
|
#if (USE_WFOPEN)
|
|
|
|
#if (TRI_CHANNEL)
|
|
QString path = filePathWithCH(ch);
|
|
FILE *f = _wfopen(path.toStdWString().c_str(),L"rb");
|
|
#else // TRI_CHANNEL
|
|
FILE *f = _wfopen(rear ? filePathCH2.toStdWString().c_str() : anyFilePath().toStdWString().c_str(),L"rb");
|
|
#endif // TRI_CHANNEL
|
|
|
|
#else
|
|
FILE *f = fopen(anyFilePath().toLocal8Bit(),"rb");
|
|
#endif
|
|
if(f != NULL)
|
|
{
|
|
VideoPreInfo info = {0,};
|
|
|
|
int format = fileFormat();
|
|
if(format == RMSensorData::FILE_TYPE_AVI) {
|
|
#if (FILE_FORMAT_AVI)
|
|
AVIRiff::duration(f,&info);
|
|
width = info.width;
|
|
height = info.height;
|
|
_durationInMSecs = info.duration;
|
|
#endif
|
|
}
|
|
else if(format == RMSensorData::FILE_TYPE_MOV) {
|
|
#if (FILE_FORMAT_MOV)
|
|
MOVFormat::duration(f,&info);
|
|
width = info.width;
|
|
height = info.height;
|
|
_durationInMSecs = info.duration;
|
|
#endif
|
|
}
|
|
#if (USE_FRONT_DURATION)
|
|
#if (TRI_CHANNEL)
|
|
if(ch == 1 || _durationInMSecs == 0)
|
|
#else
|
|
if(rear == false || _durationInMSecs == 0)
|
|
#endif
|
|
{
|
|
_durationInMSecs = info.duration;
|
|
bSuccess = info.duration > 300; // 0.3초이상
|
|
}
|
|
else {
|
|
bSuccess = info.duration > 300; // 0.3초이상
|
|
}
|
|
// 전방이 0 초 후방이 2.0 초 인 경우가 있음.
|
|
|
|
#endif // USE_FRONT_DURATION
|
|
//qInfo() << "DURATION:" << QFileInfo(filePathCH2).baseName() << _durationInMSecs << LOG_FL;
|
|
fclose(f);
|
|
}
|
|
#endif // USE_WIN32_FILE_API_ONLY
|
|
#endif // TEST_DURATION_CHECK_SKIP
|
|
return bSuccess;
|
|
}
|
|
void RMVideoItem::onChecked()
|
|
{
|
|
|
|
}
|
|
|
|
// --------------------------------------------------------------------------------------
|
|
#if (USE_DEBUG_FUNCTIONS)
|
|
void RMVideoItem::make_many_files(QString path)
|
|
{
|
|
QFileInfo f = QFileInfo(path);
|
|
QDateTime dateTime;
|
|
if(QFile::exists(path) == false || RMVideoItem::IsFeasible(path,&dateTime) == false)
|
|
{
|
|
return;
|
|
}
|
|
QString dirPath = f.absolutePath();
|
|
for(int i=0;i<2000;i++)
|
|
{
|
|
dateTime = dateTime.addSecs(-900);
|
|
QString newBaseName = dateTime.toString("yyyy_MMdd_HHmmss") + "_EVT_FILE.TBA";
|
|
qDebug() << dirPath + "//" + newBaseName;
|
|
QFile::copy(path, dirPath + "//" + newBaseName);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
// 모델별 채널 처리
|
|
#if (RM_MODEL == RM_MODEL_TYPE_NX_DRW22 || \
|
|
RM_MODEL == RM_MODEL_TYPE_BV2000 || \
|
|
RM_MODEL == RM_MODEL_TYPE_KEIYO1 || \
|
|
RM_MODEL == RM_MODEL_TYPE_MBJ5010 || \
|
|
RM_MODEL == RM_MODEL_TYPE_FC_DR232W)
|
|
#if !(FORCE_2CH)
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
|
|
QFileInfo info(path);
|
|
QString baseName = info.baseName();
|
|
#if (TRI_CHANNEL)
|
|
if(baseName.endsWith("R") || baseName.endsWith("F") || baseName.endsWith("I"))
|
|
#else
|
|
if(baseName.endsWith("R") || baseName.endsWith("F"))
|
|
#endif
|
|
{
|
|
baseName.truncate(baseName.length()-1);
|
|
}
|
|
return baseName;
|
|
}
|
|
#endif // #if !(FORCE_2CH)
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
QStringList component = baseName.split("-");
|
|
#if (SUB_MODEL_KEIYO_360)
|
|
// 210212-101925
|
|
QRegExp regexp("^[0-9]{6}-[0-9]{6}");
|
|
if(regexp.exactMatch(baseName)) {
|
|
component = baseName.split("-");
|
|
component[0] = "20" + component[0];
|
|
}
|
|
if(component.count() == 2)
|
|
{
|
|
// 200827-100830
|
|
QString dateString = component[0] + "-" + component[1];
|
|
dateTime = QDateTime::fromString(dateString,"yyyyMMdd-HHmmss");
|
|
|
|
// @TODO
|
|
//qInfo() << dateString << dateTime;
|
|
}
|
|
return dateTime;
|
|
#else // SUB_MODEL_KEIYO_360
|
|
|
|
if(component.count() == 2)
|
|
{
|
|
// 190617-154418
|
|
QString dateString = component[0] + "-" + component[1];
|
|
dateTime = QDateTime::fromString(dateString,"yyMMdd-HHmmss");
|
|
dateTime = dateTime.addYears(100);
|
|
|
|
// 2001/02/29 일 처리해야함
|
|
if(dateTime.date().year() < 1900)
|
|
{
|
|
// 년+월
|
|
QString firstDay = dateString.mid(0,4) + QString("01-") + component[1];
|
|
QDateTime d = QDateTime::fromString(firstDay,"yyMMdd-HHmmss");
|
|
d = d.addYears(100);
|
|
d = d.addDays(qMax(dateString.mid(4,2).toInt()-1,0));
|
|
dateTime = d;
|
|
}
|
|
|
|
// @TODO
|
|
//qInfo() << dateString << dateTime;
|
|
}
|
|
return dateTime;
|
|
#endif // SUB_MODEL_KEIYO_360
|
|
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_MH9000)
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
|
|
QFileInfo info(path);
|
|
QString baseName = info.baseName();
|
|
//#if (PENTA_CHANNEL)
|
|
if(baseName.endsWith("FR") || // 전방
|
|
baseName.endsWith("LS") || // 좌측
|
|
baseName.endsWith("RR") || // 후방
|
|
baseName.endsWith("RS") || // 우측
|
|
baseName.endsWith("IN")) // EX->IN 으로 변경보조
|
|
//#endif
|
|
{
|
|
baseName.truncate(baseName.length()-2);
|
|
}
|
|
return baseName;
|
|
}
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
QRegExp regexp("^(:?NORM|EVEN|PARK|MANU)[0-9]{6}-[0-9]{6}(:?FR|LS|RR|RS|IN)"); // EX 에서 IN 으로 변경
|
|
regexp.setCaseSensitivity(Qt::CaseInsensitive);
|
|
// 240523-174742
|
|
if(regexp.exactMatch(baseName)) {
|
|
QStringList component = baseName.mid(4,13).split('-');
|
|
if(component.count() == 2)
|
|
{
|
|
QString dateString = component[0] + component[1];
|
|
dateTime = QDateTime::fromString(dateString,"yyMMddHHmmss");
|
|
dateTime = dateTime.addYears(100);
|
|
}
|
|
}
|
|
return dateTime;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
|
|
// _normal 은 잘려서 들어옴
|
|
// 2024-01-21-02h-48m-31s_normal
|
|
QRegExp regexp("^[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2}h-[0-9]{2}m-[0-9]{2}s"); // $
|
|
regexp.setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
//qInfo() << baseName << __FUNCTION__;
|
|
if(regexp.exactMatch(baseName)) {
|
|
//qInfo() << "MATCH!!!!!" << baseName << __FUNCTION__;
|
|
QStringList component = baseName.split("-");
|
|
if(component.count() == 6)
|
|
{
|
|
QString dateString = component[0] + component[1] + component[2] + component[3].replace("H","",Qt::CaseInsensitive) + component[4].replace("M","",Qt::CaseInsensitive) + component[5].replace("S","",Qt::CaseInsensitive);
|
|
dateTime = QDateTime::fromString(dateString,"yyyyMMddHHmmss");
|
|
}
|
|
} else {
|
|
//qInfo() << "ERROR!!!!!" << baseName << __FUNCTION__;
|
|
}
|
|
return dateTime;
|
|
|
|
}
|
|
#if !(SINGLE_CH_VIEWER)
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
QFileInfo info(path);
|
|
return info.baseName().toUpper();
|
|
}
|
|
#endif // !(SINGLE_CH_VIEWER)
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_ADT_CAPS && !SUB_MODEL_CARROT_EMT)
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
|
|
QFileInfo info(path);
|
|
QString baseName = info.baseName().toUpper();
|
|
if(baseName.contains("_F_") || baseName.contains("_R_"))
|
|
{
|
|
baseName = baseName.replace("_F_","").replace("_R_","");
|
|
}
|
|
return baseName;
|
|
}
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
// 2020-06-12-18h-13m-53s
|
|
QDateTime dateTime;
|
|
QStringList component = baseName.split("-");
|
|
if(component.count() == 6)
|
|
{
|
|
// QString sec = component[5];
|
|
// sec.truncate(2);
|
|
QString dateString = component[0] + component[1] + component[2] + component[3].replace("H","") + component[4].replace("M","") + component[5].replace("S","");
|
|
dateTime = QDateTime::fromString(dateString,"yyyyMMddHHmmss");
|
|
|
|
}
|
|
return dateTime;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_AN6000)
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
// _normal 은 잘려서 들어옴
|
|
// 2024-01-21-02h-48m-31s_normal
|
|
QRegExp regexp("^[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{2}h-[0-9]{2}m-[0-9]{2}s"); // $
|
|
regexp.setCaseSensitivity(Qt::CaseInsensitive);
|
|
|
|
//qInfo() << baseName << __FUNCTION__;
|
|
if(regexp.exactMatch(baseName)) {
|
|
//qInfo() << "MATCH!!!!!" << __FUNCTION__;
|
|
QStringList component = baseName.split("-");
|
|
if(component.count() == 6)
|
|
{
|
|
QString dateString = component[0] + component[1] + component[2] + component[3].replace("H","",Qt::CaseInsensitive) + component[4].replace("M","",Qt::CaseInsensitive) + component[5].replace("S","",Qt::CaseInsensitive);
|
|
dateTime = QDateTime::fromString(dateString,"yyyyMMddHHmmss");
|
|
}
|
|
}
|
|
return dateTime;
|
|
|
|
}
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
|
|
QFileInfo info(path);
|
|
QString baseName = info.baseName().toUpper();
|
|
if(baseName.contains("_F_") || baseName.contains("_R_"))
|
|
{
|
|
baseName = baseName.replace("_F_","").replace("_R_","");
|
|
}
|
|
return baseName;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_EMT_KR)
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
RMVideoFileList::parseName(baseName,&dateTime,NULL);
|
|
return dateTime;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_TB4000)
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
// 20230727-180017_REC_0000.mp4
|
|
QDateTime dateTime;
|
|
|
|
// 상시일 경우 REC, 모션일 경우 MOT, 절전일 경우 PSR, 센서일 경우 EVT로
|
|
// [\d]{8}-[\d]{6}_(?:REC|MOT|PSR|EVT)[\d]_[\d]{4}
|
|
// 채널정보: 0이면 1,2채널 모두 연결되어 있고 1이면 1채널만, 2면 2채널만 연결되어 있다는 의미입니다.
|
|
// \d -> 사용금지??
|
|
//QRegExp regexp("[0-9]{8}-[0-9]{6}_(?:REC|MOT|PSR|EVT)[0,1,2]_[0-9]{4}"); // $
|
|
// 20240325-113104_PSR0_0073.tb4
|
|
QRegExp regexp("[0-9]{8}-[0-9]{6}_(?:[A-Za-z]{3})[0-9]_[0-9]{4}"); // $
|
|
//qInfo() << baseName << __FUNCTION__;
|
|
if(regexp.exactMatch(baseName)) {
|
|
//qInfo() << "MATCH!!!!!" << __FUNCTION__;
|
|
QStringList component = baseName.split("_");
|
|
dateTime = QDateTime::fromString(component[0],"yyyyMMdd-HHmmss");
|
|
}
|
|
return dateTime;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_TBD360)
|
|
|
|
#if (!FORCE_2CH || (RM_MODEL == RM_MODEL_TYPE_XLDR_88 || SUB_MODEL_CARROT_EMT))
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
|
|
QFileInfo info(path);
|
|
QString baseName = info.baseName();
|
|
QStringList component = baseName.split('_');
|
|
if(component.count() > 2)
|
|
{
|
|
baseName = component.at(0) + "_" + component.at(1);
|
|
}
|
|
return baseName;
|
|
}
|
|
#endif // #if (!FORCE_2CH || (RM_MODEL == RM_MODEL_TYPE_XLDR_88 || SUB_MODEL_CARROT_EMT))
|
|
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
QStringList component = baseName.split("_");
|
|
|
|
// SUFFIX 제거하고 들어옴
|
|
#if (THINKWARE_DEMO)
|
|
QRegExp regexp("^[0-9]{8}_[0-9]{6}");
|
|
if(regexp.exactMatch(baseName)) {
|
|
component = baseName.split("_");
|
|
}
|
|
#elif (TEST_FILENAME)
|
|
QRegExp regexp("^[0-9]{8}-[0-9]{6}");
|
|
if(regexp.exactMatch(baseName)) {
|
|
component = baseName.split("-");
|
|
}
|
|
#else // THINKWARE_DEMO
|
|
#if (TANDF_360_TEST || MH_360_TEST)
|
|
// 210212-101925
|
|
QRegExp regexp("^[0-9]{6}-[0-9]{6}");
|
|
if(regexp.exactMatch(baseName)) {
|
|
component = baseName.split("-");
|
|
component[0] = "20" + component[0];
|
|
}
|
|
#endif // TANDF_360_TEST
|
|
#endif // THINKWARE_DEMO
|
|
|
|
|
|
if(component.count() == 2)
|
|
{
|
|
// 200827-100830
|
|
QString dateString = component[0] + "-" + component[1];
|
|
dateTime = QDateTime::fromString(dateString,"yyyyMMdd-HHmmss");
|
|
|
|
// @TODO
|
|
//qInfo() << dateString << dateTime;
|
|
}
|
|
return dateTime;
|
|
}
|
|
#elif (RM_MODEL == RM_MODEL_TYPE_XLDR_88 || SUB_MODEL_CARROT_EMT)
|
|
QString RMVideoItem::fileNameWithoutChannel(QString& path) {
|
|
|
|
QFileInfo info(path);
|
|
QString baseName = info.baseName();
|
|
if(baseName.endsWith("R") || baseName.endsWith("F"))
|
|
{
|
|
baseName.truncate(baseName.length()-1);
|
|
}
|
|
return baseName;
|
|
}
|
|
QDateTime RMVideoItem::_fileNameToDateTime(QString baseName)
|
|
{
|
|
QDateTime dateTime;
|
|
QStringList component = baseName.split("_");
|
|
if(component.count() == 2)
|
|
{
|
|
// 200827-100830
|
|
QString dateString = component[0] + "-" + component[1];
|
|
dateTime = QDateTime::fromString(dateString,"yyMMdd-HHmmss");
|
|
dateTime = dateTime.addYears(100);
|
|
|
|
// 2001/02/29 일 처리해야함
|
|
if(dateTime.date().year() < 1900)
|
|
{
|
|
// 년+월
|
|
QString firstDay = dateString.mid(0,4) + QString("01-") + component[1];
|
|
QDateTime d = QDateTime::fromString(firstDay,"yyMMdd-HHmmss");
|
|
d = d.addYears(100);
|
|
d = d.addDays(qMax(dateString.mid(4,2).toInt()-1,0));
|
|
dateTime = d;
|
|
}
|
|
|
|
// @TODO
|
|
//qInfo() << dateString << dateTime;
|
|
}
|
|
return dateTime;
|
|
}
|
|
#endif // 모델별 채널 처리
|
|
|
|
#endif // #if !(RM_USE_SEPARATED_CH_FILE)
|