#include "NewRecordVideoElement.h" #include #include #include //#todo index int -> string NewRecordVideoElement::NewRecordVideoElement(std::string camid) : //videoEncoderElement(cv::Size(1920, 1080), 5, 0), camID(camid) { // basicPath(); m_cutPath= appPref.getStringData("user.loop.absolute.path"); recordInit(60,360); } NewRecordVideoElement::~NewRecordVideoElement() { std::queue empty; empty.swap(m_imgBufQue); //m_imgBufQue.clear(); } std::string NewRecordVideoElement::startRecord() { // ImgInfo info=m_HiredisTool.getImage(camID); ImgInfo info; getImg(info); std::string srcPath= getFileName(info.time); m_filename=srcPath; DBG("m_filename: " << m_filename); m_hiredisTool.pushImageBuf(m_filename,info.img); m_hiredisTool.addFileInfo(m_filename,RECORD_DOING); return srcPath; } void NewRecordVideoElement::endRecord() { 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); } void NewRecordVideoElement::doRecord() { // ImgInfo info=m_HiredisTool.getImage(camID); ImgInfo info; getImg(info); m_hiredisTool.pushImageBuf(m_filename,info.img); m_hiredisTool.addFileInfo(m_filename,RECORD_DOING); } std::string NewRecordVideoElement::getFileName(const std::string& timeStamp) { std::string dirPath=makeDir(timeStamp); char szDateTime[256] = {0}; sprintf(szDateTime, "%s%s.mp4", dirPath.c_str(), timeStamp.c_str()); DBG(szDateTime); return szDateTime; } std::string NewRecordVideoElement::makeDir(const std::string& timeStamp) { //# ./camIndex/YYYYMM/DD/YYYYMMDDHH/ std::string t_FilePath = m_cutPath; if (t_FilePath.back() != '/') { t_FilePath.push_back('/'); } char buf[24]; QDateTime dt = QDateTime::fromString(QString::fromStdString(timeStamp), "yyyy-MM-dd hh:mm:ss:zzz"); std::string t_strTime=dt.toString("yyyyMMddhh").toStdString(); DBG("t_strTime="<