From 61a8166ed71b881863de8c62e45ae3e7803a455e Mon Sep 17 00:00:00 2001
From: pansen <pansen626@sina.com>
Date: 星期一, 28 一月 2019 20:21:20 +0800
Subject: [PATCH] 添加布控等级。对比暂未添加本字段。
---
QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp | 93 ++++++++++++++++++++++++++--------------------
1 files changed, 52 insertions(+), 41 deletions(-)
diff --git a/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp b/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp
index a46ad7c..6897343 100644
--- a/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp
+++ b/QiaoJiaSystem/StructureApp/NewRecordVideoElement.cpp
@@ -1,18 +1,22 @@
#include "NewRecordVideoElement.h"
#include <basic/util/app/AppPreference.hpp>
-
+#include <QString>
+#include <QDateTime>
//#todo index int -> string
NewRecordVideoElement::NewRecordVideoElement(std::string camid) :
-videoEncoderElement(cv::Size(1920, 1080), 5, 0),
+//videoEncoderElement(cv::Size(1920, 1080), 5, 0),
camID(camid)
{
// basicPath();
+ isRecord=false;
m_cutPath= appPref.getStringData("user.loop.absolute.path");
+
+ recordInit(appPref.getIntData("n_cut_min_duration"),appPref.getIntData("n_cut_max_duration"));
}
NewRecordVideoElement::~NewRecordVideoElement() {
- queue<ImgInfo> empty;
+ std::queue<ImgInfo> empty;
empty.swap(m_imgBufQue);
//m_imgBufQue.clear();
@@ -21,25 +25,29 @@
std::string NewRecordVideoElement::startRecord() {
// ImgInfo info=m_HiredisTool.getImage(camID);
+ //isRecord=true;
ImgInfo info;
getImg(info);
std::string srcPath= getFileName(info.time);
+ m_filename=srcPath;
+ // DBG("m_filename: " << m_filename);
-// DBG("fisrt fps time"<<info.time);
- try {
- videoEncoderElement.threadInitial(srcPath, info.img);
- }
- catch (std::exception &e) {
- ERR(e.what())
- }
+ m_hiredisTool.pushImageBuf(m_filename,info.img);
+ m_hiredisTool.addFileInfo(m_filename,RECORD_DOING);
return srcPath;
}
void NewRecordVideoElement::endRecord() {
- doRecord();
- doRecord();
- doRecord();
- videoEncoderElement.threadClosing();
+
+ ImgInfo info;
+ getImg(info);
+// DBG("m_filename: " << m_filename);
+// DBG("recordDelay:" << recordDelay);
+// DBG("videoLength:" << videoLength);
+// DBG("sdkTrigger:" << sdkTrigger);
+ m_hiredisTool.pushImageBuf(m_filename,info.img);
+ m_hiredisTool.addFileInfo(m_filename,RECORD_ENDING);
+ // isRecord=false;
}
void NewRecordVideoElement::doRecord() {
@@ -49,13 +57,13 @@
ImgInfo info;
getImg(info);
-// DBG(" time="<<info.time);
- videoEncoderElement.doFunc(info.img);
+ m_hiredisTool.pushImageBuf(m_filename,info.img);
+ m_hiredisTool.addFileInfo(m_filename,RECORD_DOING);
}
- std::string NewRecordVideoElement::getFileName(std::string timeStamp)
+ std::string NewRecordVideoElement::getFileName(const std::string& timeStamp)
{
- std::string dirPath=makeDir();
+ std::string dirPath=makeDir(timeStamp);
char szDateTime[256] = {0};
sprintf(szDateTime, "%s%s.mp4", dirPath.c_str(), timeStamp.c_str());
@@ -64,7 +72,7 @@
}
-std::string NewRecordVideoElement::makeDir() {
+std::string NewRecordVideoElement::makeDir(const std::string& timeStamp) {
//# ./camIndex/YYYYMM/DD/YYYYMMDDHH/
std::string t_FilePath = m_cutPath;
@@ -73,15 +81,13 @@
t_FilePath.push_back('/');
}
char buf[24];
+ QDateTime dt = QDateTime::fromString(QString::fromStdString(timeStamp), "yyyy-MM-dd hh:mm:ss:zzz");
- time_t t=time(nullptr);
- // 20180901113048 2018-09-01 11:30:48
- strftime(buf,24,"%Y%m%d%H",localtime(&t));
- std::string t_strTime(buf);
- //# ./camIndex/YYYYMM/DD/
+ std::string t_strTime=dt.toString("yyyyMMddhh").toStdString();
+ // DBG("t_strTime="<<t_strTime);
t_FilePath.append(camID + "/" + t_strTime.substr(0, 6)+ "/" +t_strTime.substr(6, 2) + "/");
//YYYYMMDDHH
- t_FilePath.append(t_strTime.substr(0,10) + "/");
+ t_FilePath.append(t_strTime.substr(0,10)+ "/");
std::string t_cmd = "mkdir -p '";
t_cmd.append(t_FilePath + "'");
//#get path mkdir path
@@ -96,32 +102,34 @@
// info.img=img;
info.time=time;
m_imgBufQue.push(info);
+ // if(isRecord)
+ // DBG("camId="<<camID<<"pushtime="<<info.time);
// int size=m_imgBufQue.size();
// DBG("m_imgBufQue size="<<size);
}
void NewRecordVideoElement::getImg(ImgInfo& info)
{
- //todo
- int len=20;
- info=m_imgBufQue.front();
+ info=m_imgBufQue.front();
int size=m_imgBufQue.size();
-// DBG("m_imgBufQue size="<<size<<" time="<<info.time);
- if(size>len)
+// DBG("m_imgBufQue size="<<size<<" camId="<<camID<<" fileMin="<<fileMin/2);
+ if(size>fileMin/2)
{
m_imgBufQue.pop();
}
-
+// if(isRecord)
+// DBG("camId="<<camID<<"gettime="<<info.time);
}
- void NewRecordVideoElement::threadFunc()
- {
- Record();
- }
- void NewRecordVideoElement::threadInitial()
- {
- recordInit(40,100);
- }
+// void NewRecordVideoElement::threadFunc()
+// {
+// Record();
+// }
+// void NewRecordVideoElement::threadInitial()
+// {
+
+
+// }
void NewRecordVideoElement::Record() {
switch(recordStatus)
@@ -194,6 +202,7 @@
void NewRecordVideoElement::setSdkTrigger(bool isTrigger) {
if(isTrigger)
{
+// DBG("setSdkTrigger time=" << AppUtil::getTimeUSecString());
triggerDelay = 0;
sdkTrigger = true;
}
@@ -206,11 +215,13 @@
sdkTrigger = true;
}
}
+ Record();
}
void NewRecordVideoElement::recordInit(int videoMin, int videoMax) {
+
sdkTrigger = false;
- fileMin = videoMin;
- fileMax = videoMax;
+ fileMin = videoMin*8;//fps=8
+ fileMax = videoMax*8;
triggerDelay = fileMin/2;
recordStatus = RECORD_STOP;
--
Gitblit v1.8.0