派生自 development/c++

pansen
2019-03-07 979bc003bce710bf300bc2bd87a8278585678763
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
#include "VideoRecorderManager.h"
 
VideoRecorderManager::VideoRecorderManager(int interval, std::string rtsp, std::string path, std::string fileName)
    :TimerElement(interval),m_strPath(path),m_strFileName(fileName)
{
    ClockTimer ct("VideoRecorderManager::VideoRecorderManager()");
    int nCount = 0;
    while(nCount++ < 10)
    {
        if (m_videoRcd.start(rtsp,path+fileName) >= 0)
        {
            break;
        }
        usleep(10000);//10ms
    }
 
    if (nCount >= 10)
    {
        ERR("open rtsp "<< rtsp <<" failed!");
    }else
    {
        m_dtRecordTime = QDateTime::currentDateTime();
        start();
    }
}
 
double VideoRecorderManager::getLastUs()
{
    return getCurrentUs();
}
 
void VideoRecorderManager::threadInitial()
{
    lastUs = getLastUs();
}
 
void VideoRecorderManager::timerFunc()
{
    ClockTimer ct("VideoRecorderManager::timerFunc()");
    m_videoRcd.stop();
    if (access((m_strPath+m_strFileName).c_str(),F_OK) != 0)
    {
        ERR("file not exist!");
        stop();
        return;
    }
    QString strMvCmd = QString("cd %1 ; mv %2 %3")
            .arg(QString::fromStdString(m_strPath))
            .arg(QString::fromStdString(m_strFileName))
            .arg(m_dtRecordTime.toString("yyyyMMdd_hh:mm:ss:zzz")+".mp4");
    system(strMvCmd.toLatin1().data());
 
    stop();
}