派生自 development/c++

pansen
2019-03-07 d3b7bbe7102cd089680a828f5d8f6402c8cf6342
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include "EncodeVideoManager.h"
#include "NewRecordVideoElement.h"
#include <basic/util/app/AppConfig.h>
#include <qdatetime.h>
 
EncodeVideoManager::EncodeVideoManager():
TimerElement(10*1000)
{
   // m_hiredisTool.delKey("")
    int thread_num=appConfig.getIntProperty("encode_thread_num");
 
    for(int i=0;i<thread_num;++i)
    {
         EncodeVideo* newEncodeViedo=new EncodeVideo();
         if(newEncodeViedo)
         {
 
               m_newEncodeVideoVec.push_back(newEncodeViedo);
               newEncodeViedo->start();
         }
 
    }
 
}
EncodeVideoManager::~EncodeVideoManager()
{
    for(int i=0;i<m_newEncodeVideoVec.size();++i)
    {
        if(m_newEncodeVideoVec[i])
        {
            m_newEncodeVideoVec[i]->stop();
            delete m_newEncodeVideoVec[i];
            m_newEncodeVideoVec[i]=nullptr;
        }
    }
    m_newEncodeVideoVec.clear();
 
}
void EncodeVideoManager::timerFunc()
{
        //    std::string tmp="camId="+m_camId+"videoCaptureElement";
            //ClockTimer cl("timerFunc");
   std::map<std::string,int> fileMap=m_hiredisTool.findAllFileStatus();
//   auto it=fileMap.begin();
   for(auto it=fileMap.begin();it!=fileMap.end();it++)
   {
       if(it->second == RECORD_ENDING)
       {
 
           for(int i=0;i<m_newEncodeVideoVec.size();++i)
           {
               if(m_newEncodeVideoVec[i] && !m_newEncodeVideoVec[i]->isBusy())
               {
                  m_hiredisTool.hashSet(file_list,it->first,RECORD_STOP);
                  m_newEncodeVideoVec[i]->setProperty("src_path",it->first);
                  m_newEncodeVideoVec[i]->submit();
                  break;
               }
           }
 
 
       }
       else
       {
           //----/home/basic/work/qiaojia/cut/DS-2CD2T46WDA2-I20180622AACHC30488278/201901/22/2019012210/2019-01-22 10:32:38:171.mp4
 
           std::string file_name=it->first;
           int begin=file_name.find_last_of("/")+1;
           int end= file_name.find(".mp4");
           std::string file_time=file_name.substr(begin,end-begin);
           QDateTime dt = QDateTime::fromString(QString::fromStdString(file_time), "yyyy-MM-dd hh:mm:ss:zzz");
           if( (AppUtil::getCurrentUs()-dt.toMSecsSinceEpoch())>5*60*1000*1000)
           {
               DBG(file_name<<">5*60*1000*1000");
               m_hiredisTool.hashSet(file_list,file_name,RECORD_ENDING);
           }
 
       }
   }
}