#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();
|
}
|