|
|
@@ -6,16 +6,16 @@
|
|
|
#include <io.h>
|
|
|
#include "fileutil.h"
|
|
|
#include "Event.h"
|
|
|
+#include "y2k_time.h"
|
|
|
+
|
|
|
|
|
|
#include "..\\mod_customeraware\\Event.h"
|
|
|
#include "..\\mod_facetracking\\sysvar.h"
|
|
|
+#include "../mod_interactivecontrol/Event.h"
|
|
|
|
|
|
using namespace Recorder;
|
|
|
|
|
|
|
|
|
-#define LOG_EVT_UI_RETURNMENU 0x30B00006 //退出到主菜单
|
|
|
-
|
|
|
-
|
|
|
#ifndef RVC_MAX_VIDEO_NAME_LEN
|
|
|
#define RVC_MAX_VIDEO_NAME_LEN 256
|
|
|
#endif
|
|
|
@@ -43,7 +43,6 @@ using namespace Recorder;
|
|
|
#endif // !RVC_TRANSATCION_RECORD_SUFFIX
|
|
|
|
|
|
|
|
|
-
|
|
|
static struct {
|
|
|
DeviceTypeEnum device_type;
|
|
|
int type_hex;
|
|
|
@@ -71,6 +70,41 @@ static int GetDeviceTypeValue(DeviceTypeEnum eType)
|
|
|
}
|
|
|
|
|
|
|
|
|
+static unsigned long GetFileSize(const char* pfilename)
|
|
|
+{
|
|
|
+ unsigned long usize = 0;
|
|
|
+ if (NULL == pfilename) {
|
|
|
+ return usize;
|
|
|
+ }
|
|
|
+
|
|
|
+ FILE* pFile = fopen(pfilename, "rb");
|
|
|
+ if (pFile) {
|
|
|
+ fseek(pFile, 0, SEEK_END);
|
|
|
+ usize = ftell(pFile);
|
|
|
+ fclose(pFile);
|
|
|
+ }
|
|
|
+
|
|
|
+ return usize;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+static const char* GetFileName(const char* pfilename)
|
|
|
+{
|
|
|
+ if (NULL == pfilename) {
|
|
|
+ return NULL;
|
|
|
+ }
|
|
|
+
|
|
|
+ return strstr(pfilename, RVC_TRANSATCION_RECORD_SUFFIX);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+static void LogVideoSizeInfo(const char* pszMessage)
|
|
|
+{
|
|
|
+ unsigned long ufilesize = GetFileSize(pszMessage);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_VIDEO_SIZE, CSimpleStringA::Format("%s file size is %u byte.", pszMessage, ufilesize).GetData());
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
void rvcDbg(const char* fmt, ...)
|
|
|
{
|
|
|
va_list arg;
|
|
|
@@ -96,15 +130,12 @@ void RecordServiceSession::Handle_StartTransactionRecord(SpReqAnsContext<Recorde
|
|
|
{
|
|
|
DbgToBeidou(ctx->link, __FUNCTION__)();
|
|
|
if (m_pEntity->GetStartFlag()) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Current is recording, stop it.");
|
|
|
m_pEntity->StopRecord();
|
|
|
}
|
|
|
|
|
|
- char strVideoName[MAX_PATH] = { 0 };
|
|
|
- _snprintf(strVideoName, MAX_PATH, "%s%s",RVC_TRANSATCION_RECORD_SUFFIX, ctx->Req.VideoName.GetData());
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("StartRecord and video name is %s.", strVideoName);
|
|
|
+ m_pEntity->SetRecordSessionID(ctx->Req.VideoName.GetData());
|
|
|
|
|
|
- m_pEntity->StartRecord(strVideoName);
|
|
|
+ m_pEntity->StartRecord(CSimpleStringA::Format("%s%s", RVC_TRANSATCION_RECORD_SUFFIX, ctx->Req.VideoName.GetData()).GetData());
|
|
|
|
|
|
ctx->Answer(Error_Succeed);
|
|
|
}
|
|
|
@@ -146,39 +177,7 @@ ErrorCodeEnum CRecorderEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
m_iCameraState = 'N';
|
|
|
bool bRet = false;
|
|
|
|
|
|
- int iEncrytion = 0;
|
|
|
- int iRecordType = 0;
|
|
|
- int iRecordMode = 0;
|
|
|
- UINT64 uMtype = 0x0;
|
|
|
- CSmartPointer<IConfigInfo> spConfig;
|
|
|
- CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
- if (spFunction->OpenConfig(Config_CenterSetting, spConfig) == Error_Succeed) {
|
|
|
- spConfig->ReadConfigValueInt("Recorder","Encryption", iEncrytion);
|
|
|
- spConfig->ReadConfigValueHexInt("Recorder","EncMtype", uMtype);
|
|
|
- spConfig->ReadConfigValueInt("Recorder", "RecordType", iRecordType);
|
|
|
- spConfig->ReadConfigValueInt("InteractiveControl", "RecordMode", iRecordMode);
|
|
|
- }
|
|
|
-
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Encryption flag is %d, and EncMtype is 0x%08x.", iEncrytion, uMtype);
|
|
|
-
|
|
|
- if (1 == iEncrytion && (uMtype & GetDeviceTypeValue(m_eDeviceType))){
|
|
|
- m_bEncFlag = true;
|
|
|
- }
|
|
|
-
|
|
|
- if (1 == iRecordMode) {
|
|
|
- m_iRecordMode = 1;
|
|
|
- }
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Record Mode is %d.", m_iRecordMode);
|
|
|
-
|
|
|
- if (eMobilePadType != m_eDeviceType) {
|
|
|
- if (0 != iRecordType) {
|
|
|
- m_eRecordType = eMP4;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("EncFlag is %s, video format is %s.", m_bEncFlag ? "true" : "false", m_eRecordType == eMP4 ? RECORD_MP4_SUFFIX : RECORD_WMV_SUFFIX);
|
|
|
-
|
|
|
- if ((ePadtype == m_eDeviceType)||(eMobilePadType == m_eDeviceType)||(eDesk2SType == m_eDeviceType)||(eDesk1SType == m_eDeviceType)||(eDesk2SIntegratedType == m_eDeviceType))
|
|
|
+ if (eMobilePadType == m_eDeviceType)
|
|
|
{
|
|
|
//pad 版增加远端视频队列
|
|
|
m_pRecorder = new Clibvideorecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE,
|
|
|
@@ -190,9 +189,8 @@ ErrorCodeEnum CRecorderEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE);
|
|
|
}
|
|
|
|
|
|
- //DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("init libvideorecord success!");
|
|
|
int i = 0;
|
|
|
- m_arrListener.Init(7);
|
|
|
+ m_arrListener.Init(8);
|
|
|
GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_BEGIN_RECORD, NULL, false);
|
|
|
GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_END_RECORD, NULL, false);
|
|
|
GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_RETURNMENU, NULL, false);
|
|
|
@@ -200,7 +198,8 @@ ErrorCodeEnum CRecorderEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_CONTINUE_RECORD, NULL, false);
|
|
|
GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_RECORDER_SECTION_FINISHED, NULL, false);
|
|
|
GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_RECORDER_WHOLE_FINISHED, NULL, false);
|
|
|
-
|
|
|
+ GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, LOG_EVT_START_BUSINESSRECORD_FAILED, NULL, false);
|
|
|
+
|
|
|
GetFunction()->RegistSysVarEvent(SYSVAR_ACTIVETRACKINGCAMERA,this);
|
|
|
GetFunction()->RegistSysVarEvent(SYSVAR_CAMERASTATE,this);
|
|
|
CSimpleStringA strValue;
|
|
|
@@ -208,7 +207,7 @@ ErrorCodeEnum CRecorderEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
m_iCameraState = strValue[0];
|
|
|
if (strValue[0] == 'E'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_OPT;
|
|
|
- if (eDesk1SType == m_eDeviceType || eDesk2SIntegratedType == m_eDeviceType){
|
|
|
+ if (eStand1SPlusType == m_eDeviceType){
|
|
|
m_iActiveCamera = CAMERA_TYPE_ERROR;
|
|
|
}
|
|
|
}
|
|
|
@@ -251,8 +250,26 @@ ErrorCodeEnum CRecorderEntity::__OnStart(ErrorCodeEnum preOperationError)
|
|
|
|
|
|
void CRecorderEntity::OnStarted()
|
|
|
{
|
|
|
+ CSystemStaticInfo si;
|
|
|
+ ErrorCodeEnum Error = GetFunction()->GetSystemStaticInfo(si);
|
|
|
+ if (Error == Error_Succeed) {
|
|
|
+ m_strAppVersion = si.InstallVersion.ToString();
|
|
|
+ m_strTerminalId = si.strTerminalID;
|
|
|
+ }
|
|
|
+
|
|
|
+ LoadEntityConfig();
|
|
|
//DeleteExceptionLogFiles();
|
|
|
SaveExceptionRecordVideos();
|
|
|
+
|
|
|
+ if (m_vRecordList.size() > 0) {
|
|
|
+ HandleExceptionRecordVideos();
|
|
|
+ if (m_bPostVideoInfoOn) {
|
|
|
+ PostVideoRecordInfos();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_vRecordList.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -276,7 +293,6 @@ ErrorCodeEnum CRecorderEntity::__OnClose(ErrorCodeEnum preOperationError)
|
|
|
|
|
|
CServerSessionBase* CRecorderEntity::OnNewSession(const char* pszRemoteEntityName, const char* pszClass)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s connected class = %s!", pszRemoteEntityName, pszClass);
|
|
|
return new RecordServiceSession(this);
|
|
|
}
|
|
|
|
|
|
@@ -322,48 +338,178 @@ void CRecorderEntity::vDebug(record_loglevel elevel, const char* str, va_list li
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// CWmpHostAPI
|
|
|
-void CRecorderEntity::WmpDebug(const char *fmt, ...)
|
|
|
+
|
|
|
+int CRecorderEntity::GetActiveCamera()
|
|
|
{
|
|
|
- va_list arg;
|
|
|
- va_start(arg, fmt);
|
|
|
+ return m_iActiveCamera;
|
|
|
+}
|
|
|
|
|
|
- int n = _vscprintf(fmt, arg);
|
|
|
- if (n >= MAX_LOG_LEN) {
|
|
|
- char* buf = (char*)malloc((size_t)(n + 1));
|
|
|
- vsnprintf(buf, n + 1, fmt, arg);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", buf);
|
|
|
- free(buf);
|
|
|
+
|
|
|
+ErrorCodeEnum CRecorderEntity::LoadEntityConfig()
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = Error_Succeed;
|
|
|
+
|
|
|
+ int iEncrytion = 0;
|
|
|
+ int iRecordType = 0;
|
|
|
+ int iRecordMode = 0;
|
|
|
+ UINT64 uMtype = 0x0;
|
|
|
+ int iTimeOut = RVC_HTTPTIMEOUT;
|
|
|
+ int iPostOn = 0;
|
|
|
+ CSimpleStringA strHttpServerAddr("");
|
|
|
+ CSmartPointer<IConfigInfo> spConfig;
|
|
|
+ CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
+ if (spFunction->OpenConfig(Config_CenterSetting, spConfig) == Error_Succeed) {
|
|
|
+ spConfig->ReadConfigValueInt("Recorder", "Encryption", iEncrytion);
|
|
|
+ spConfig->ReadConfigValueHexInt("Recorder", "EncMtype", uMtype);
|
|
|
+ spConfig->ReadConfigValueInt("Recorder", "RecordType", iRecordType);
|
|
|
+ spConfig->ReadConfigValueInt("InteractiveControl", "RecordMode", iRecordMode);
|
|
|
+ spConfig->ReadConfigValue("Recorder", "http_video_record_addr", strHttpServerAddr);
|
|
|
+ spConfig->ReadConfigValueInt("Recorder", "http_timeout", iTimeOut);
|
|
|
+ spConfig->ReadConfigValueInt("Recorder", "post_videoinfo_on", iPostOn);
|
|
|
}
|
|
|
- else{
|
|
|
- char strlog[MAX_LOG_LEN] = {0};
|
|
|
- vsnprintf(strlog, MAX_LOG_LEN, fmt, arg);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
|
|
|
+ else {
|
|
|
+ Error = Error_Failed;
|
|
|
}
|
|
|
- va_end(arg);
|
|
|
+
|
|
|
+ if (1 == iEncrytion && (uMtype & GetDeviceTypeValue(m_eDeviceType))) {
|
|
|
+ m_bEncFlag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (1 == iRecordMode) {
|
|
|
+ m_iRecordMode = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strHttpServerAddr.GetLength() > 0) {
|
|
|
+ m_strHttpServerAddr = strHttpServerAddr;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (iPostOn > 0) {
|
|
|
+ m_bPostVideoInfoOn = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (eMobilePadType != m_eDeviceType) {
|
|
|
+ if (0 != iRecordType) {
|
|
|
+ m_eRecordType = eMP4;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (iTimeOut > 0 && iTimeOut < 20 * RVC_HTTPTIMEOUT) {
|
|
|
+ m_iHttpTimeOut = iTimeOut;
|
|
|
+ }
|
|
|
+
|
|
|
+ return Error;
|
|
|
}
|
|
|
|
|
|
|
|
|
-int CRecorderEntity::GetActiveCamera()
|
|
|
+ErrorCodeEnum CRecorderEntity::PostVideoRecordInfos()
|
|
|
{
|
|
|
- return m_iActiveCamera;
|
|
|
+ ErrorCodeEnum Error = Error_Failed;
|
|
|
+
|
|
|
+ char strtimenow[MAX_PATH] = { 0 };
|
|
|
+ y2k_time_t nowtime = y2k_time_now();
|
|
|
+ y2k_to_string(nowtime, strtimenow, MAX_PATH);
|
|
|
+ video_record_info_t video_params;
|
|
|
+ video_params.strServerURL = m_strHttpServerAddr;
|
|
|
+ video_params.strAPI = m_strHttpServerAPI;
|
|
|
+ video_params.strAppVersion = m_strAppVersion;
|
|
|
+ video_params.strRecordEndTime = strtimenow;
|
|
|
+ video_params.strTerminalNo = m_strTerminalId;
|
|
|
+ video_params.iBusinessStatus = (int)m_eBusinessStatus;
|
|
|
+ if (eFailed == m_eBusinessStatus) {
|
|
|
+ if (m_vRecordList.size() > 0) {
|
|
|
+ video_params.iBusinessStatus = eInterrupt;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ video_params.strRecordID = m_strRecordName;
|
|
|
+ for (vector<record_item_t>::iterator it = m_vRecordList.begin(); it < m_vRecordList.end(); ++it) {
|
|
|
+ video_params.vRecordList.push_back(*it);
|
|
|
+ }
|
|
|
+
|
|
|
+ unsigned int uposttime = 0;
|
|
|
+ CSimpleStringA strErrorMsg("");
|
|
|
+ if (0 == post_video_recordinfo_list(uposttime, strErrorMsg, &video_params, m_iHttpTimeOut, false)) {
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_POST_RECORDINFO_COST_TIME, CSimpleStringA::Format("post video record infos cost time is %ums.", uposttime).GetData());
|
|
|
+ Error = Error_Succeed;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ LogWarn(Severity_Middle, Error_Exception, LOG_EVT_POST_RECORDINFO_FAILED, strErrorMsg.GetData());
|
|
|
+ }
|
|
|
+
|
|
|
+ m_vRecordList.clear();
|
|
|
+
|
|
|
+ return Error;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ErrorCodeEnum CRecorderEntity::HandleExceptionRecordVideos()
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = Error_Failed;
|
|
|
+ const char* videofilename = m_vRecordList[0].file_path.c_str();
|
|
|
+ if (NULL == videofilename) {
|
|
|
+ return Error;
|
|
|
+ }
|
|
|
+
|
|
|
+ char strSession[RVC_MAX_VIDEO_NAME_LEN] = { 0 };
|
|
|
+ int iSeriesNum = -1;
|
|
|
+ char strFormat[RVC_MAX_VIDEO_NAME_LEN] = { 0 };
|
|
|
+
|
|
|
+ if (-1 == GetRecordVideoInfo(videofilename, strSession, RVC_MAX_VIDEO_NAME_LEN, &iSeriesNum, strFormat, RVC_MAX_VIDEO_NAME_LEN)) {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[%s] get record video info failed.", videofilename);
|
|
|
+ return Error;
|
|
|
+ }
|
|
|
+
|
|
|
+ SetRecordSessionID(strSession + strlen(RVC_TRANSATCION_RECORD_SUFFIX));
|
|
|
+
|
|
|
+ while (--iSeriesNum >= 0) {
|
|
|
+ CSimpleStringA strFilePath("");
|
|
|
+ strFilePath = CSimpleStringA::Format("%s%s_%d.%s", m_RecordSaveDir.GetData(), strSession, iSeriesNum, strFormat);
|
|
|
+ if (ExistsFile(strFilePath.GetData())) {
|
|
|
+ AddToVideoRecordList(strFilePath.GetData());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("File {%s} is not exist.", strFilePath.GetData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+ErrorCodeEnum CRecorderEntity::AddToVideoRecordList(const char* videofilename)
|
|
|
+{
|
|
|
+ ErrorCodeEnum Error = Error_Failed;
|
|
|
+ if (NULL == videofilename) {
|
|
|
+ return Error;
|
|
|
+ }
|
|
|
+
|
|
|
+ record_item_t* item = new record_item_t();
|
|
|
+
|
|
|
+ item->file_path = videofilename;
|
|
|
+
|
|
|
+ item->file_length = (int)GetFileSize(videofilename);
|
|
|
+
|
|
|
+ const char* strfilename = GetFileName(videofilename);
|
|
|
+ if (strfilename) {
|
|
|
+ item->file_name = strfilename;
|
|
|
+ }
|
|
|
+
|
|
|
+ m_vRecordList.push_back(*item);
|
|
|
+
|
|
|
+ Error = Error_Succeed;
|
|
|
+
|
|
|
+ return Error;
|
|
|
}
|
|
|
|
|
|
|
|
|
void CRecorderEntity::OnRecordFailed(eRvcRecordFailedCase eCase, const char *pszMessage, bool bRecordDevFault)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnRecordFailed!");
|
|
|
+ m_eBusinessStatus = eFailed;
|
|
|
if (!bRecordDevFault){
|
|
|
LogEvent(Severity_Middle,LOG_EVT_RECORDFAILED,"0");
|
|
|
- char strmsg[MAX_PATH] = {0};
|
|
|
- _snprintf(strmsg, MAX_PATH, "{%s} 本地录音录像失败,已停止!", pszMessage ? pszMessage : " ");
|
|
|
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDING_FAILED, strmsg);
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDING_FAILED, CSimpleStringA::Format("{%s} 本地录音录像失败,已停止!", pszMessage ? pszMessage : " ").GetData());
|
|
|
}
|
|
|
else{
|
|
|
LogEvent(Severity_Middle,LOG_EVT_RECORDFAILED,"1");
|
|
|
- char strinfo[MAX_PATH] = {0};
|
|
|
- _snprintf(strinfo, MAX_PATH, "{%s} 本地录音录像设备故障,尝试恢复中(预计10s内),请稍等", pszMessage ? pszMessage : " ");
|
|
|
- LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDING_FAILED, strinfo);
|
|
|
+ LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDING_FAILED, CSimpleStringA::Format("{%s} 本地录音录像设备故障,尝试恢复中(预计10s内),请稍等", pszMessage ? pszMessage : " ").GetData());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -376,7 +522,7 @@ void CRecorderEntity::OnRecordEntityExcption()
|
|
|
|
|
|
void CRecorderEntity::OnRecordFinished()
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("OnRecordFinished!");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
int CRecorderEntity:: GetCameraState()
|
|
|
@@ -384,38 +530,9 @@ int CRecorderEntity:: GetCameraState()
|
|
|
return m_iCameraState;
|
|
|
}
|
|
|
|
|
|
-static unsigned long GetFileSize(const char* pfilename)
|
|
|
-{
|
|
|
- unsigned long usize = 0;
|
|
|
- if (NULL == pfilename) {
|
|
|
- return usize;
|
|
|
- }
|
|
|
-
|
|
|
- FILE* pFile = fopen(pfilename, "rb");
|
|
|
- if (pFile) {
|
|
|
- fseek(pFile, 0, SEEK_END);
|
|
|
- usize = ftell(pFile);
|
|
|
- fclose(pFile);
|
|
|
- }
|
|
|
-
|
|
|
- return usize;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-static void LogVideoSizeInfo(const char* pszMessage)
|
|
|
-{
|
|
|
- unsigned long ufilesize = GetFileSize(pszMessage);
|
|
|
- char strmsg[MAX_PATH] = { 0 };
|
|
|
- _snprintf(strmsg, MAX_PATH, "%s file size is %u byte.", pszMessage, ufilesize);
|
|
|
-
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_VIDEO_SIZE, strmsg);
|
|
|
-}
|
|
|
-
|
|
|
|
|
|
void CRecorderEntity::OnASectionFinished(const char *pszMessage, int iSerialNum, bool bfinished)
|
|
|
{
|
|
|
- // filename
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("file %s finished.(SerialNum %d)", pszMessage, iSerialNum);
|
|
|
m_iSeriesNum = iSerialNum;
|
|
|
if (false == bfinished){
|
|
|
LogEvent(Severity_Middle, LOG_EVT_RECORDER_SECTION_FINISHED, pszMessage);
|
|
|
@@ -430,50 +547,21 @@ void CRecorderEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,
|
|
|
const DWORD dwSysError,const DWORD dwUserCode,const DWORD dwEntityInstanceID, const WORD wEntityDevelID,
|
|
|
const CAutoArray<DWORD> &Param, const char *pszEntityName, const char *pszModuleName,const char *pszMessage, const linkContext& pLinkInfo)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("user_code = 0x%08x.", dwUserCode);
|
|
|
switch (dwUserCode)
|
|
|
{
|
|
|
- case EVENT_MOD_BEGIN_RECORD:
|
|
|
- if (0 == m_iRecordMode) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start record!");
|
|
|
- StartRecord(pszMessage);
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case EVENT_MOD_END_RECORD:
|
|
|
- if (0 == m_iRecordMode) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop record!");
|
|
|
- StopRecord();
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- case LOG_EVT_UI_RETURNMENU:
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("exit to main!");
|
|
|
- if (0 == m_iRecordMode) {
|
|
|
- //本地录像,退回到首页关闭当前文件,重新开始录制
|
|
|
- if (m_bStarted) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("return menu,close video file!");
|
|
|
- m_pRecorder->CloseVideoFile();
|
|
|
- }
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
case EVENT_MOD_PAUSE_RECORD:
|
|
|
- if (m_bStarted){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("manipulate media device function called, pause record!");
|
|
|
+ if (m_bStarted) {
|
|
|
m_pRecorder->PauseRecord();
|
|
|
m_pRecorder->CloseVideoFile();
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
case EVENT_MOD_CONTINUE_RECORD:
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("manipulate media device function called, continue record!");
|
|
|
m_pRecorder->ContinueRecord();
|
|
|
break;
|
|
|
|
|
|
case LOG_EVT_RECORDER_SECTION_FINISHED:
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recorder section finished, and message is %s.", pszMessage);
|
|
|
if (m_iRecordMode) {
|
|
|
LogVideoSizeInfo(pszMessage);
|
|
|
}
|
|
|
@@ -486,7 +574,6 @@ void CRecorderEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,
|
|
|
|
|
|
case LOG_EVT_RECORDER_WHOLE_FINISHED:
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recorder whole finished, and message is %s.", pszMessage);
|
|
|
if (m_iRecordMode) {
|
|
|
LogVideoSizeInfo(pszMessage);
|
|
|
}
|
|
|
@@ -494,6 +581,22 @@ void CRecorderEntity::OnLog(const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,
|
|
|
HandleEncryptVideoRecord(pszMessage);
|
|
|
}
|
|
|
HandleFinishedVideoRecord(pszMessage);
|
|
|
+ if (m_bPostVideoInfoOn) {
|
|
|
+ PostVideoRecordInfos();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_vRecordList.clear();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ break;
|
|
|
+
|
|
|
+ case LOG_EVT_START_BUSINESSRECORD_FAILED:
|
|
|
+ m_eBusinessStatus = eFailed;
|
|
|
+ if (m_bPostVideoInfoOn) {
|
|
|
+ PostVideoRecordInfos();
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ m_vRecordList.clear();
|
|
|
}
|
|
|
break;
|
|
|
|
|
|
@@ -507,64 +610,37 @@ void CRecorderEntity::OnSysVarEvent(const char *pszKey, const char *pszValue,con
|
|
|
{
|
|
|
if (_stricmp(pszKey, SYSVAR_CAMERASTATE) == 0)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("camera state from : %c to %c", pszOldValue[0], pszValue[0]);
|
|
|
m_iCameraState = pszValue[0];
|
|
|
- if (pszValue[0] == 'E')
|
|
|
- {
|
|
|
+ if (pszValue[0] == 'E'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_OPT;
|
|
|
- if (eDesk1SType == m_eDeviceType || eDesk2SIntegratedType == m_eDeviceType){
|
|
|
- m_iActiveCamera = CAMERA_TYPE_ERROR;
|
|
|
- }
|
|
|
}
|
|
|
- else if (pszValue[0] == 'O')
|
|
|
- {
|
|
|
+ else if (pszValue[0] == 'O'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_ENV;
|
|
|
}
|
|
|
- else if(pszValue[0] == 'B') ///////显示贴图
|
|
|
- {
|
|
|
+ else if(pszValue[0] == 'B'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_ERROR;
|
|
|
}
|
|
|
- else if (pszValue[0] == 'N')
|
|
|
- {
|
|
|
+ else if (pszValue[0] == 'N'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_ENV;
|
|
|
}
|
|
|
}
|
|
|
else if (_stricmp(pszKey, SYSVAR_ACTIVETRACKINGCAMERA) == 0)
|
|
|
{
|
|
|
- if (m_iCameraState == 'N')
|
|
|
- {
|
|
|
- if (pszValue[0] == 'E')
|
|
|
- {
|
|
|
+ if (m_iCameraState == 'N'){
|
|
|
+ if (pszValue[0] == 'E'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_ENV;
|
|
|
}
|
|
|
- else if (pszValue[0] == 'O')
|
|
|
- {
|
|
|
+ else if (pszValue[0] == 'O'){
|
|
|
m_iActiveCamera = CAMERA_TYPE_OPT;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if(_stricmp(pszKey,"SessionID")==0)
|
|
|
- {
|
|
|
- CSimpleStringA strSessionID;
|
|
|
- GetFunction()->GetSysVar("SessionID",strSessionID);
|
|
|
- //如果sessionid改变且不为空,切换录像文件
|
|
|
- if(_stricmp(strSessionID,"N")!=0)
|
|
|
- {
|
|
|
- if (m_bStarted && (0 == m_iRecordMode))
|
|
|
- {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Session Id change to %s, close record and start new video file.",strSessionID.GetData());
|
|
|
- m_pRecorder->ReNameVideoFile(strSessionID);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
|
-void CRecorderEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
+void CRecorderEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransactionContext> pTransactionContext)
|
|
|
{
|
|
|
- if (Test_ShakeHand == eTestType)
|
|
|
- {
|
|
|
+ if (Test_ShakeHand == eTestType){
|
|
|
pTransactionContext->SendAnswer(Error_Succeed);
|
|
|
}
|
|
|
}
|
|
|
@@ -572,8 +648,6 @@ void CRecorderEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITransac
|
|
|
|
|
|
void CRecorderEntity::StartRecord(const char *videofilename)
|
|
|
{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("videofilename = %s", videofilename);
|
|
|
-
|
|
|
int fps = 5;
|
|
|
Rvc_RecordAudioParam_t tAudioParams;
|
|
|
tAudioParams.eRecordType = eSingleSide;
|
|
|
@@ -587,9 +661,11 @@ void CRecorderEntity::StartRecord(const char *videofilename)
|
|
|
if (m_pRecorder->StartVideoRecord(fps, 75, m_eRecordType, &tAudioParams, NULL, FALSE, TRUE, (LPCSTR)m_TempDir, m_RecordSaveDir.GetLength(), videofilename, strlen(videofilename)))
|
|
|
{
|
|
|
m_bStarted = true;
|
|
|
+ m_eBusinessStatus = eSuccess;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
void CRecorderEntity::StopRecord()
|
|
|
{
|
|
|
if (m_bStarted) {
|
|
|
@@ -599,28 +675,35 @@ void CRecorderEntity::StopRecord()
|
|
|
}
|
|
|
|
|
|
|
|
|
+void CRecorderEntity::SetRecordSessionID(const char* strRecordID)
|
|
|
+{
|
|
|
+ if (NULL != strRecordID) {
|
|
|
+ memset(m_strRecordName, 0 , MAX_PATH);
|
|
|
+ _snprintf(m_strRecordName, MAX_PATH, "%s", strRecordID);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+void CRecorderEntity::GetRecordSessionID(char* strRecordID, size_t uLen)
|
|
|
+{
|
|
|
+ if (NULL != strRecordID) {
|
|
|
+ _snprintf(strRecordID, uLen, "%s", m_strRecordName);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
DeviceTypeEnum CRecorderEntity::RvcGetDeviceType()
|
|
|
{
|
|
|
DeviceTypeEnum eType = eStand2sType;
|
|
|
CSmartPointer<IEntityFunction> spFunction = GetFunction();
|
|
|
CSystemStaticInfo stStaticinfo;
|
|
|
spFunction->GetSystemStaticInfo(stStaticinfo);
|
|
|
- if (_stricmp(stStaticinfo.strMachineType, "RVC.PAD") == 0) {
|
|
|
+ if (_stricmp(stStaticinfo.strMachineType, "RVC.Stand1SPlus") == 0) {
|
|
|
+ eType = eStand1SPlusType;
|
|
|
+ }
|
|
|
+ else if (_stricmp(stStaticinfo.strMachineType, "RVC.PAD") == 0) {
|
|
|
if (_stricmp(stStaticinfo.strSite, "CMB.FLB") == 0) {
|
|
|
eType = eMobilePadType;
|
|
|
}
|
|
|
- else {
|
|
|
- eType = ePadtype;
|
|
|
- }
|
|
|
- }
|
|
|
- else if (_stricmp(stStaticinfo.strMachineType, "RVC.Desk2S") == 0) {
|
|
|
- eType = eDesk2SType;
|
|
|
- WORD nMajor = stStaticinfo.MachineVersion.GetMajor();
|
|
|
- WORD nMinor = stStaticinfo.MachineVersion.GetMinor();
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MachineVersion is %d.%d", nMajor, nMinor);
|
|
|
- if (2 == nMajor) {
|
|
|
- eType = eDesk2SIntegratedType;
|
|
|
- }
|
|
|
}
|
|
|
else if (_stricmp(stStaticinfo.strMachineType, "RPM.Stand1S") == 0) {
|
|
|
eType = eRpm1sType;
|
|
|
@@ -645,10 +728,10 @@ DeviceTypeEnum CRecorderEntity::RvcGetDeviceType()
|
|
|
}
|
|
|
|
|
|
|
|
|
-int CRecorderEntity::HandleFinishedVideoRecord(const char* wmvfilename)
|
|
|
+int CRecorderEntity::HandleFinishedVideoRecord(const char* videofilename)
|
|
|
{
|
|
|
int iRet = -1;
|
|
|
- if (NULL == wmvfilename){
|
|
|
+ if (NULL == videofilename){
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
@@ -656,8 +739,8 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* wmvfilename)
|
|
|
int iSeriesNum = -1;
|
|
|
char strFormat[RVC_MAX_VIDEO_NAME_LEN] = {0};
|
|
|
|
|
|
- if (-1 == GetRecordVideoInfo(wmvfilename, strSession, RVC_MAX_VIDEO_NAME_LEN, &iSeriesNum, strFormat, RVC_MAX_VIDEO_NAME_LEN)){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[%s] get record video info failed.", wmvfilename);
|
|
|
+ if (-1 == GetRecordVideoInfo(videofilename, strSession, RVC_MAX_VIDEO_NAME_LEN, &iSeriesNum, strFormat, RVC_MAX_VIDEO_NAME_LEN)){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[%s] get record video info failed.", videofilename);
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
@@ -668,12 +751,10 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* wmvfilename)
|
|
|
if (ExistsFile(srcfile.GetData())){
|
|
|
bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if(!bRet) {
|
|
|
- char strmsg[MAX_PATH] = {0};
|
|
|
- _snprintf(strmsg, MAX_PATH, "Error Code %u while move %s ", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strmsg);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("record finished move file form %s to %s success.", srcfile.GetData(), dstfile.GetData());
|
|
|
+ AddToVideoRecordList(dstfile.GetData());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -682,12 +763,10 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* wmvfilename)
|
|
|
if (ExistsFile(srcfile.GetData())){
|
|
|
bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if(!bRet) {
|
|
|
- char strinfo[MAX_PATH] = {0};
|
|
|
- _snprintf(strinfo, MAX_PATH, "Error Code %u while move %s ", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strinfo);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("record finished move file form %s to %s success.", srcfile.GetData(), dstfile.GetData());
|
|
|
+ AddToVideoRecordList(dstfile.GetData());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -698,10 +777,10 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* wmvfilename)
|
|
|
}
|
|
|
|
|
|
|
|
|
-int CRecorderEntity::HandleEncryptVideoRecord(const char* wmvfilename)
|
|
|
+int CRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
|
|
|
{
|
|
|
int iRet = -1;
|
|
|
- if (NULL == wmvfilename){
|
|
|
+ if (NULL == videofilename){
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
@@ -709,40 +788,30 @@ int CRecorderEntity::HandleEncryptVideoRecord(const char* wmvfilename)
|
|
|
cb.dbg = &rvcDbg;
|
|
|
|
|
|
char strOutFile[MAX_PATH] = {0};
|
|
|
- int iresult = encryption_file(strOutFile, MAX_PATH, wmvfilename, &cb, eVerA);
|
|
|
+ int iresult = encryption_file(strOutFile, MAX_PATH, videofilename, &cb, eVerA);
|
|
|
if (0 != iresult){
|
|
|
- char strmsg[MAX_PATH] = {0};
|
|
|
- _snprintf(strmsg, MAX_PATH, "encryption file %s failed, delete out temp file %s!", wmvfilename, strOutFile);
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_ENCRYPT_FAILED, strmsg);
|
|
|
- if (DeleteFile(strOutFile)){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s success!", strOutFile);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_ENCRYPT_FAILED, CSimpleStringA::Format("encryption file %s failed, delete out temp file %s!", videofilename, strOutFile).GetData());
|
|
|
+ if (!DeleteFile(strOutFile)){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
|
|
|
}
|
|
|
return iRet;
|
|
|
}
|
|
|
- else{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Encrypt file %s Success!", wmvfilename);
|
|
|
- }
|
|
|
|
|
|
- BOOL bRet = DeleteFile(wmvfilename);
|
|
|
+ BOOL bRet = DeleteFile(videofilename);
|
|
|
if(!bRet) {
|
|
|
- char strinfo[MAX_PATH] = {0};
|
|
|
- _snprintf(strinfo, MAX_PATH, "Error Code %lu while delete %s, delete out temp file[%s]!", GetLastError(), wmvfilename, strOutFile);
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, wmvfilename);
|
|
|
- if (DeleteFile(strOutFile)){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s success!", strOutFile);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, CSimpleStringA::Format("Error Code %lu while delete %s, delete out temp file[%s]!", GetLastError(), videofilename, strOutFile).GetData());
|
|
|
+ if (!DeleteFile(strOutFile)){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
|
|
|
}
|
|
|
return iRet;
|
|
|
}
|
|
|
else{
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Delete %s Success!", wmvfilename);
|
|
|
- if (!rename(strOutFile,wmvfilename)){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rename %s to %s Success!",strOutFile, wmvfilename);
|
|
|
+ if (!rename(strOutFile, videofilename)){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rename %s to %s Success!",strOutFile, videofilename);
|
|
|
iRet = 0;
|
|
|
}
|
|
|
else{
|
|
|
- char strtext[MAX_PATH] = {0};
|
|
|
- _snprintf(strtext, MAX_PATH, "Error Code %lu while rename %s.", GetLastError(), strOutFile);
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, strtext);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -751,10 +820,10 @@ int CRecorderEntity::HandleEncryptVideoRecord(const char* wmvfilename)
|
|
|
|
|
|
|
|
|
|
|
|
-int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
+int CRecorderEntity::HandleSaveVideoRecord(const char* videofilename)
|
|
|
{
|
|
|
int iRet = -1;
|
|
|
- if (NULL == wmvfilename){
|
|
|
+ if (NULL == videofilename){
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
@@ -762,8 +831,8 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
int iSeriesNum = -1;
|
|
|
char strFormat[RVC_MAX_VIDEO_NAME_LEN] = {0};
|
|
|
|
|
|
- if (-1 == GetRecordVideoInfo(wmvfilename, strSession, RVC_MAX_VIDEO_NAME_LEN, &iSeriesNum, strFormat, RVC_MAX_VIDEO_NAME_LEN)){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[%s] get record video info failed.", wmvfilename);
|
|
|
+ if (-1 == GetRecordVideoInfo(videofilename, strSession, RVC_MAX_VIDEO_NAME_LEN, &iSeriesNum, strFormat, RVC_MAX_VIDEO_NAME_LEN)){
|
|
|
+ DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[%s] get record video info failed.", videofilename);
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
@@ -773,12 +842,10 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
if (ExistsFile(srcfile.GetData())) {
|
|
|
BOOL bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if (!bRet) {
|
|
|
- char strmsg[MAX_PATH] = { 0 };
|
|
|
- _snprintf(strmsg, MAX_PATH, "Error Code %u while move %s ", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strmsg);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()));
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("section finished move file form %s to %s success.", srcfile.GetData(), dstfile.GetData());
|
|
|
+ AddToVideoRecordList(dstfile.GetData());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -789,12 +856,7 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
if (ExistsFile(srcfile.GetData())) {
|
|
|
BOOL bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if (!bRet) {
|
|
|
- char strmsg[MAX_PATH] = { 0 };
|
|
|
- _snprintf(strmsg, MAX_PATH, "Error Code %u while move %s ", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strmsg);
|
|
|
- }
|
|
|
- else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("section finished move file form %s to %s success.", srcfile.GetData(), dstfile.GetData());
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
m_iMovedSeriesNum = iSeriesNum - 1;
|
|
|
}
|
|
|
@@ -802,7 +864,6 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
else {
|
|
|
if (0 == m_iMovedSeriesNum) {
|
|
|
if (false == m_bMoveFlag) {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("First record video, ignore it.");
|
|
|
m_bMoveFlag = true;
|
|
|
}
|
|
|
else {
|
|
|
@@ -811,12 +872,10 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
CSimpleStringA dstfile = CSimpleStringA::Format("%s%s_%d_end.%s", (LPCTSTR)m_RecordSaveDir, (LPCTSTR)m_LastSaveSessionId, 0, strFormat);
|
|
|
BOOL bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if (!bRet) {
|
|
|
- char strtext[MAX_PATH] = { 0 };
|
|
|
- _snprintf(strtext, MAX_PATH, "Error Code %u while move %s ", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strtext);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s ", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("section finished move file form %s to %s success.", srcfile.GetData(), dstfile.GetData());
|
|
|
+ AddToVideoRecordList(dstfile.GetData());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -827,19 +886,15 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
CSimpleStringA dstfile = CSimpleStringA::Format("%s%s_%d_end.%s", (LPCTSTR)m_RecordSaveDir, (LPCTSTR)m_LastSaveSessionId, m_iMovedSeriesNum + 1, strFormat);
|
|
|
BOOL bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if (!bRet) {
|
|
|
- char strinfo[MAX_PATH] = { 0 };
|
|
|
- _snprintf(strinfo, MAX_PATH, "Error Code %u while move %s ", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strinfo);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s.", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
else {
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("section finished move file form %s to %s success.", srcfile.GetData(), dstfile.GetData());
|
|
|
+ AddToVideoRecordList(dstfile.GetData());
|
|
|
}
|
|
|
}
|
|
|
m_iMovedSeriesNum = 0;
|
|
|
}
|
|
|
-
|
|
|
m_LastSaveSessionId = strSession;
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("New set last save session id is %s ", m_LastSaveSessionId.GetData());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -849,14 +904,14 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* wmvfilename)
|
|
|
}
|
|
|
|
|
|
|
|
|
-int CRecorderEntity::GetRecordVideoInfo(const char* wmvfilename, char* strSession, size_t uSessionLen, int* iSeriesNum, char* strFormat, size_t uFormatLen)
|
|
|
+int CRecorderEntity::GetRecordVideoInfo(const char* videofilename, char* strSession, size_t uSessionLen, int* iSeriesNum, char* strFormat, size_t uFormatLen)
|
|
|
{
|
|
|
int iRet = -1;
|
|
|
|
|
|
char strFileName[RVC_MAX_VIDEO_NAME_LEN] = {0};
|
|
|
- size_t uLen = strlen(wmvfilename);
|
|
|
+ size_t uLen = strlen(videofilename);
|
|
|
if (uLen <= RVC_MAX_VIDEO_NAME_LEN){
|
|
|
- const char *pIndex = strrchr(wmvfilename, '\\');
|
|
|
+ const char *pIndex = strrchr(videofilename, '\\');
|
|
|
if (pIndex){
|
|
|
_snprintf(strFileName, RVC_MAX_VIDEO_NAME_LEN, "%s", pIndex + 1);
|
|
|
}
|
|
|
@@ -903,8 +958,6 @@ int CRecorderEntity::GetRecordVideoInfo(const char* wmvfilename, char* strSessio
|
|
|
|
|
|
iRet = 0;
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("video name info:(session is %s, series number is %d, video format is %s).", strSession, *iSeriesNum, strFormat);
|
|
|
-
|
|
|
return iRet;
|
|
|
}
|
|
|
|
|
|
@@ -918,13 +971,13 @@ int CRecorderEntity::SaveExceptionRecordVideos()
|
|
|
bool fFinished = false;
|
|
|
char strVideoFormat[MAX_PATH] = { 0 };
|
|
|
if (eMP4 == m_eRecordType) {
|
|
|
- sprintf_s(strVideoFormat, MAX_PATH, "%s", RECORD_MP4_SUFFIX);
|
|
|
+ _snprintf(strVideoFormat, MAX_PATH, "%s", RECORD_MP4_SUFFIX);
|
|
|
}
|
|
|
else {
|
|
|
- sprintf_s(strVideoFormat, MAX_PATH, "%s", RECORD_WMV_SUFFIX);
|
|
|
+ _snprintf(strVideoFormat, MAX_PATH, "%s", RECORD_WMV_SUFFIX);
|
|
|
}
|
|
|
|
|
|
- sprintf_s(srcFilePath, MAX_PATH, "%s*.%s", m_TempDir.GetData(), strVideoFormat);
|
|
|
+ _snprintf(srcFilePath, MAX_PATH, "%s*.%s", m_TempDir.GetData(), strVideoFormat);
|
|
|
|
|
|
hFind = FindFirstFile(srcFilePath, &FindFileData);
|
|
|
|
|
|
@@ -950,15 +1003,12 @@ int CRecorderEntity::SaveExceptionRecordVideos()
|
|
|
memcpy(strname, pIndex+strlen(RVC_FILEENC_STR), strlen(pIndex+strlen(RVC_FILEENC_STR)));
|
|
|
CSimpleStringA tempsrcfile = CSimpleStringA::Format("%s%s",m_TempDir.GetData(), strname);
|
|
|
if (!rename(srcfile.GetData(),tempsrcfile.GetData())){
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rename %s to %s Success!",srcfile.GetData(),tempsrcfile.GetData());
|
|
|
srcfile = tempsrcfile;
|
|
|
memset(FindFileData.cFileName, 0, MAX_PATH);
|
|
|
memcpy(FindFileData.cFileName, strname, strlen(strname));
|
|
|
}
|
|
|
else{
|
|
|
- char strinfo[MAX_PATH] = {0};
|
|
|
- _snprintf(strinfo, MAX_PATH, "Error Code %lu while rename %s.", GetLastError(), srcfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, strinfo);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), srcfile.GetData()).GetData());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -967,11 +1017,10 @@ int CRecorderEntity::SaveExceptionRecordVideos()
|
|
|
CSimpleStringA dstfile = CSimpleStringA::Format("%s%s",m_RecordSaveDir.GetData(), FindFileData.cFileName);
|
|
|
BOOL bRet = MoveFile(srcfile.GetData(), dstfile.GetData());
|
|
|
if(!bRet) {
|
|
|
- char strmsg[MAX_PATH] = {0};
|
|
|
- _snprintf(strmsg, MAX_PATH, "Error Code %u while move %s -> %s", GetLastError(), srcfile.GetData(), dstfile.GetData());
|
|
|
- LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, strmsg);
|
|
|
+ LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_MOVE_FAILED, CSimpleStringA::Format("Error Code %u while move %s -> %s", GetLastError(), srcfile.GetData(), dstfile.GetData()).GetData());
|
|
|
}
|
|
|
else{
|
|
|
+ AddToVideoRecordList(dstfile.GetData());
|
|
|
iRet = 0;
|
|
|
}
|
|
|
}
|
|
|
@@ -1010,7 +1059,6 @@ int CRecorderEntity::DeleteExceptionLogFiles()
|
|
|
char srcFilePath[MAX_PATH]={0};
|
|
|
sprintf_s(srcFilePath, MAX_PATH, "%s\\*.*", logPath);
|
|
|
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("srcFilePath is %s.", srcFilePath);
|
|
|
hFind = FindFirstFile(srcFilePath, &FindFileData);
|
|
|
|
|
|
if (INVALID_HANDLE_VALUE != hFind)
|
|
|
@@ -1026,7 +1074,6 @@ int CRecorderEntity::DeleteExceptionLogFiles()
|
|
|
if (nSize > MAX_LOGFILE_SIZE)
|
|
|
{
|
|
|
CSimpleStringA dstfile = CSimpleStringA::Format("%s\\%s",logPath, FindFileData.cFileName);
|
|
|
- DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("srcFilePath is %s.", dstfile.GetData());
|
|
|
BOOL bRet = DeleteFile(dstfile.GetData());
|
|
|
if(bRet) {
|
|
|
LogWarn(Severity_Low, Error_Debug, LOG_EVT_DELETE_BIG_LOGFILE, dstfile.GetData());
|
|
|
@@ -1049,6 +1096,7 @@ on_next:
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
SP_BEGIN_ENTITY_MAP()
|
|
|
SP_ENTITY(CRecorderEntity)
|
|
|
SP_END_ENTITY_MAP()
|