فهرست منبع

Z991239-5614 #comment 增加记录录像文件hash值信息

80274480 1 سال پیش
والد
کامیت
fa9d849cf5

+ 1 - 1
Module/mod_SalesRecorder/Event.h

@@ -13,7 +13,7 @@
 #define LOG_EVT_RECORD_SAVED_SUCCESS					0x31510006				//双录文件保存成功
 #define LOG_EVT_RECORD_SAVED_FAILED						0x31510007				//双录文件保存失败
 #define LOG_EVT_RECORD_INVALID_FILE						0x31510008				//无效的录像文件
-#define LOG_EVT_RECORD_FILESIZE							0x31510009				//双录文件大小
+#define LOG_EVT_RECORD_FILEINFO							0x31510009				//双录文件信息
 #define LOG_EVT_ENTITY_RESTART							0x3151000A				//实体自动重启
 #define LOG_EVT_POST_SALESRECORD_INFO_FAILED			0x3151000B				//上报销售录像信息失败
 #define LOG_EVT_POST_SALESRECORD_INFO_COST_TIME			0x3151000C				//上报销售录像信息耗时

+ 3 - 1
Module/mod_SalesRecorder/mod_SalesRecorder.cpp

@@ -1008,7 +1008,9 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 						sourFileName = CSimpleStringA::Format("%s%s_%d.%s", sourPath.GetData(), strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
 						destFileName = CSimpleStringA::Format("%s%s_%d.%s", destPath.GetData(), strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
 						unsigned long ufilesize = GetFileSize(sourFileName.GetData());
-						LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FILESIZE, CSimpleStringA::Format("%s file size is %u byte.", sourFileName.GetData(), ufilesize).GetData());
+						char strhash[MAX_PATH] = { 0 };
+						get_file_sm3digest(strhash, MAX_PATH, sourFileName.GetData());
+						LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FILEINFO, CSimpleStringA::Format("%s file size is %u byte, sm3 digist is %s.", sourFileName.GetData(), ufilesize, strhash).GetData());
 						bRet = rvcMoveFile(sourFileName.GetData(), destFileName.GetData());
 						if (!bRet) {
 							ErrorCode = Error_NotImpl;

+ 1 - 1
Module/mod_recorder/Event.h

@@ -3,7 +3,7 @@
 #define LOG_EVT_RECORDFAILED						0x31200001				//录像失败
 #define LOG_EVT_RECORDER_SECTION_FINISHED			0x31200002				//一段录像完成
 #define LOG_EVT_RECORDER_WHOLE_FINISHED			    0x31200003				//整个录像完成
-#define LOG_EVT_RECORDER_VIDEO_SIZE					0x31200004				//录像文件大小
+#define LOG_EVT_RECORDER_VIDEO_INFO					0x31200004				//录像文件信息
 #define LOG_EVT_INVALID_RECORD_FILE					0x31200005				//无效的录像文件
 
 #define LOG_EVT_RECORDER_ENCRYPT_FAILED			    0x31210001				//文件加密失败

+ 6 - 4
Module/mod_recorder/mod_recorder.cpp

@@ -81,11 +81,13 @@ static const char* GetFileName(const char* pfilename)
 	return strstr(pfilename, RVC_TRANSATCION_RECORD_SUFFIX);
 }
 
-static void LogRecordFileSize(const char* pszMessage)
+static void LogRecordFileInfo(const char* pszMessage)
 {
 	unsigned long ufilesize = GetFileSize(pszMessage);
+	char strhash[MAX_PATH] = { 0 };
+	get_file_sm3digest(strhash, MAX_PATH, pszMessage);
 
-	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_VIDEO_SIZE, CSimpleStringA::Format("%s file size is %u byte.", pszMessage, ufilesize).GetData());
+	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_VIDEO_INFO, CSimpleStringA::Format("%s file size is %u byte, sm3 digist is %s.", pszMessage, ufilesize, strhash).GetData());
 }
 
 static void rvcDbg(filecrypt_loglevel elevel, const char* fmt, ...)
@@ -763,7 +765,7 @@ int CRecorderEntity::HandleFinishedVideoRecord(const char* videofilename)
 	CSimpleStringA dstfile = CSimpleStringA::Format("%s%s_%d_end.%s", m_RecordSaveDir.GetData(), strSession, iSeriesNum, strFormat);
 	bool bRet = false;
 	if (ExistsFile(srcfile.GetData())){
-		LogRecordFileSize(srcfile.GetData());
+		LogRecordFileInfo(srcfile.GetData());
 		bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
 		if(!bRet) {
 #ifdef RVC_OS_WIN
@@ -887,7 +889,7 @@ int CRecorderEntity::HandleSaveVideoRecord(const char* videofilename)
 	CSimpleStringA srcfile = CSimpleStringA::Format("%s%s_%d.%s", m_TempDir.GetData(), strSession, iSeriesNum, strFormat);
 	CSimpleStringA dstfile = CSimpleStringA::Format("%s%s_%d.%s", m_RecordSaveDir.GetData(), strSession, iSeriesNum, strFormat);
 	if (ExistsFile(srcfile.GetData())) {
-		LogRecordFileSize(srcfile.GetData());
+		LogRecordFileInfo(srcfile.GetData());
 		bool bRet = rvcMoveFile(srcfile.GetData(), dstfile.GetData());
 		if (!bRet) {
 #ifdef RVC_OS_WIN

+ 20 - 0
Other/libfilecryption/fileanalysis.cpp

@@ -289,3 +289,23 @@ int get_file_json_infos_from_file(char** pstrjson, uint32_t* ujsonlen, const cha
 	}
 	return iret;
 }
+
+
+int get_file_hashstring(char* pbuffer, uint32_t ubuflen, const char* pfilename)
+{
+	int iret = -1;
+	if (!pbuffer || !pfilename) {
+		return iret;
+	}
+
+	unsigned char strhash[RVC_FILE_HASH_LEN] = { 0 };
+	if (0 != get_srcfile_hash((char*)strhash, RVC_FILE_HASH_LEN, pfilename)) {
+		return iret;
+	}
+
+	if (0 == bin2str(strhash, RVC_FILE_HASH_LEN, pbuffer, ubuflen)) {
+		iret = 0;
+	}
+
+	return iret;
+}

+ 2 - 1
Other/libfilecryption/fileanalysis.h

@@ -21,4 +21,5 @@ int SM4EncECBMode(unsigned char key[16], unsigned char *input, int length, unsig
 int SM4DecECBMode(unsigned char key[16], unsigned char *input, int length, unsigned char *output, int *output_len);
 int GenerateSM4Key(unsigned char* pkey, uint32_t ukeysize, unsigned char* phash, uint32_t uhashlen, uint32_t ufilesize);
 int get_file_json_infos_from_rvc_header(char** pstrjson, uint32_t* ujsonlen, char* pheader, uint32_t udatalen);
-int get_file_json_infos_from_file(char** pstrjson, uint32_t* ujsonlen, const char* pfilename, FILE* pFile);
+int get_file_json_infos_from_file(char** pstrjson, uint32_t* ujsonlen, const char* pfilename, FILE* pFile);
+int get_file_hashstring(char* pbuffer, uint32_t ubuflen, const char* pfilename);

+ 5 - 0
Other/libfilecryption/filecryption.cpp

@@ -529,4 +529,9 @@ int rvc_free_data(void** pdechead)
 bool is_file_completed(const char* pfilename, const filecryption_callback_t* pcallback)
 {
 	return is_mp4file_completed(pfilename, pcallback);
+}
+
+int get_file_sm3digest(char* strbuf, uint32_t ubuflen, const char* pfilename)
+{
+	return get_file_hashstring(strbuf, ubuflen, pfilename);
 }

+ 1 - 0
Other/libfilecryption/filecryption.h

@@ -62,6 +62,7 @@ FILECRYPTION_API(bool) is_file_encrypted(const char* pfilename, const filecrypti
 FILECRYPTION_API(int) rvc_file_decrypt(unsigned char** pdechead, uint32_t* udecheadlen, int* ioffset, char** pstrjson, uint32_t* ujsonlen,const char* pfilename, const filecryption_callback_t* pcallback = NULL, eRvcCryptionVersion eversion = eVerA);
 FILECRYPTION_API(int) rvc_free_data(void** pdechead);
 FILECRYPTION_API(bool) is_file_completed(const char* pfilename, const filecryption_callback_t* pcallback);
+FILECRYPTION_API(int) get_file_sm3digest(char* strbuf, uint32_t ubuflen, const char* pfilename);
 
 #ifdef __cplusplus
 } // extern "C" {