Forráskód Böngészése

Z991239-5381 #comment root.ini 录像加密兼容支持UOS系统

80274480 1 éve
szülő
commit
0467a858f1

+ 3 - 2
Module/mod_SalesRecorder/CMakeLists.txt

@@ -19,6 +19,7 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${OTHER_LIB_PLATFORM_BASE_DIR}
 	${OTHER_LIB_PLATFORM_BASE_DIR}/rvcmediacommon
 	${CMAKE_CURRENT_SOURCE_DIR}
+	${OTHER_LIB_BASE_DIR}/libfilecryption
 )
 
 target_link_directories(${MODULE_NAME} PRIVATE
@@ -29,9 +30,9 @@ target_link_directories(${MODULE_NAME} PRIVATE
 
 # 添加实体需要依赖的其他共享库(包括系统库)
 if(WIN32)
-set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} libvideorecord)
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} libvideorecord libfilecryption)
 else(WIN32)
-set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} libvideorecord)
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} libvideorecord libfilecryption)
 endif(WIN32)
 
 target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

+ 1 - 1
Module/mod_counterconnector/mod_counterconnector.h

@@ -53,7 +53,7 @@ private:
 class CCounterConnectorEntity : public CEntityBase, public ILogListener, public ISysVarListener, public ITimerListener
 {
 public:
-	CCounterConnectorEntity() : m_fsm(), m_pCounterConnectorChannel(NULL), m_bConnectAssist(FALSE), m_bConnectSipphone(FALSE), m_iRouteType(0), m_iPickUpCallType(0){
+	CCounterConnectorEntity() : m_fsm(), m_pCounterConnectorChannel(NULL), m_bConnectAssist(false), m_bConnectSipphone(false), m_iRouteType(0), m_iPickUpCallType(0){
 		m_iConSipphoneFaileTimes = 0;
 	}
 	virtual ~CCounterConnectorEntity() {}

+ 59 - 15
Module/mod_recorder/mod_recorder.cpp

@@ -2,13 +2,13 @@
 
 #ifdef RVC_OS_WIN
 #include "stdafx.h"
-#include "filecryption.h"
 #else
 #include <sys/stat.h>
 #endif // RVC_OS_WIN
 #include "Event.h"
 #include "y2k_time.h"
 #include <string.h>
+#include "filecryption.h"
 
 #include "mod_facetracking/sysvar.h"
 #include "mod_interactivecontrol/Event.h"
@@ -79,13 +79,13 @@ void rvcDbg(const char* fmt, ...)
 	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);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", buf);
 		free(buf);
 	}
 	else{
 		char strlog[MAX_LOG_LEN] = {0};
 		vsnprintf(strlog, MAX_LOG_LEN, fmt, arg);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s", strlog);
 	}
 	va_end(arg);
 }
@@ -108,6 +108,25 @@ static bool rvcMoveFile(const char* strSrcFile, const char* strDstFile)
 }
 
 
+static bool RvcDeleteFile(const char* strSrcFile)
+{
+	bool bRet = false;
+	if (NULL == strSrcFile) {
+		return bRet;
+	}
+
+#ifdef RVC_OS_WIN
+	bRet = DeleteFile(strSrcFile);
+#else
+	if (0 == remove(strSrcFile)) {
+		bRet = true;
+	}
+#endif // RVC_OS_WIN
+	
+	return bRet;
+}
+
+
 void RecordServiceSession::Handle_StartTransactionRecord(SpReqAnsContext<RecorderSerVice_StartTransactionRecord_Req, RecorderSerVice_StartTransactionRecord_Ans>::Pointer ctx)
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
@@ -336,12 +355,15 @@ ErrorCodeEnum CRecorderEntity::LoadEntityConfig()
 	ErrorCodeEnum Error = Error_Succeed;
 
 	int iTimeOut = RVC_HTTPTIMEOUT;
+	int iStopEncflag = 0;
 	CSimpleStringA strHttpServerAddr("");
 	CSmartPointer<IConfigInfo> spConfig;
 	CSmartPointer<IEntityFunction> spFunction = GetFunction();
 	if (spFunction->OpenConfig(Config_CenterSetting, spConfig) == Error_Succeed) {
 		spConfig->ReadConfigValue("Recorder", "http_video_record_addr", strHttpServerAddr);
 		spConfig->ReadConfigValueInt("Recorder", "http_timeout", iTimeOut);
+		spConfig->ReadConfigValueInt("Recorder", "stopencflag", iStopEncflag);
+		
 	}
 	else {
 		Error = Error_Failed;
@@ -357,6 +379,12 @@ ErrorCodeEnum CRecorderEntity::LoadEntityConfig()
 		m_iHttpTimeOut = iTimeOut;
 	}
 
+	if (1 == iStopEncflag) {
+		m_bEncFlag = false;
+	}
+
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("iStopEncflag = %d.", iStopEncflag);
+
 	return Error;
 }
 
@@ -735,38 +763,54 @@ int CRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
 		return iRet;
 	}
 
-#ifdef RVC_OS_WIN
 	filecryption_callback_t cb = {0};
 	cb.dbg = &rvcDbg;
 	
 	char strOutFile[MAX_PATH] = {0};
-	int iresult = encryption_file(strOutFile, MAX_PATH, videofilename, &cb, eVerA);
+	int iresult = encryption_file(strOutFile, MAX_PATH, videofilename, &cb, eVerB);
 	if (0 != iresult){
-		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)){
+		LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_ENCRYPT_FAILED, CSimpleStringA::Format("encryption file %s failed, delete out temp file %s!", videofilename, strOutFile).GetData());
+		if (!RvcDeleteFile(strOutFile)){
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
 		}
 		return iRet;
 	}
 
-	BOOL bRet = DeleteFile(videofilename);
+	bool bRet = RvcDeleteFile(videofilename);
 	if(!bRet) {
-		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)){
+#ifdef RVC_OS_WIN
+		LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, CSimpleStringA::Format("Error Code %lu while delete %s, delete out temp file[%s]!", GetLastError(), videofilename, strOutFile).GetData());
+#else
+		LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, CSimpleStringA::Format("%s(%d) while delete %s, delete out temp file[%s]!", strerror(errno), errno, videofilename, strOutFile).GetData());
+#endif // RVC_OS_WIN
+		if (!RvcDeleteFile(strOutFile)){
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s failed!", strOutFile);
 		}
 		return iRet;
 	}
 	else{
-		if (!rename(strOutFile, videofilename)){
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rename %s to %s Success!",strOutFile, videofilename);
+		if (!rvcMoveFile(strOutFile, videofilename)){
+			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("rename %s to %s Success!",strOutFile, videofilename);
 			iRet = 0;
 		}
 		else{
-			LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
+#ifdef RVC_OS_WIN
+			LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
+#else
+			LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("%s(%d) while rename %s.", strerror(errno), errno, strOutFile).GetData());
+#endif // RVC_OS_WIN	
 		}
 	}
-#endif // RVC_OS_WIN
+
+	char strdecFile[MAX_PATH] = { 0 };
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin decrypt file %s.", videofilename);
+	iresult = decryption_file(strdecFile, MAX_PATH, videofilename, &cb, eVerB);
+	if (0 == iresult) {
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("decrypt file %s -> %s success!", videofilename, strdecFile);
+	}
+	else {
+		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("decrypt file %s -> %s failed!", videofilename, strdecFile);
+	}
 
 	return iRet;
 }
@@ -896,7 +940,7 @@ int CRecorderEntity::SaveExceptionRecordVideos()
 				goto on_next;
 			}
 
-			if (NULL == strstr(FindFileData.cFileName, "S_") && NULL == strstr(FindFileData.cFileName, "G_")){
+			if (NULL == strstr(FindFileData.cFileName, "S_")){
 				CSimpleStringA srcfile = CSimpleStringA::Format("%s%s",m_TempDir.GetData(), FindFileData.cFileName);
 				if (m_bEncFlag){
 					filecryption_callback_t cb = {0};

+ 1 - 1
Module/mod_recorder/mod_recorder.h

@@ -22,7 +22,7 @@ namespace Recorder {
 	class CRecorderEntity : public CEntityBase, public CHostApi, public ILogListener, public ISysVarListener
 	{
 	public:
-		CRecorderEntity() : m_bStarted(false), m_pRecorder(NULL), m_bEncFlag(false), m_eRecordType(eWMV){
+		CRecorderEntity() : m_bStarted(false), m_pRecorder(NULL), m_bEncFlag(true), m_eRecordType(eMP4){
 			m_strHttpServerAPI = RVC_UPLOAD_VIDEORECORDING_HTTP_API;
 			m_iHttpTimeOut = RVC_HTTPTIMEOUT;
 			m_strHttpServerAddr = RVC_UPLOAD_VIDEORECORDING_HTTP_ADDR;

+ 39 - 20
Other/libfilecryption/fileanalysis.cpp

@@ -7,9 +7,19 @@
 #include "cJSON.h"
 
 
+#ifdef _WIN32
+#ifndef FILE_SLASH
+#define FILE_SLASH '\\'
+#endif
+#else
+#ifndef FILE_SLASH
+#define FILE_SLASH '/'
+#endif
+#endif // _WIN32
+
 static unsigned char seedkey[] = "Q&@09#5*AZWSsdff";
 
-int get_srcfile_name(char* pname, size_t ulen, const char* pfilename)
+int get_srcfile_name(char* pname, uint32_t ulen, const char* pfilename)
 {
 	int iret = -1;
 
@@ -17,7 +27,7 @@ int get_srcfile_name(char* pname, size_t ulen, const char* pfilename)
 		return iret;
 	}
 
-	const char* pindex = strrchr(pfilename, '\\');
+	const char* pindex = strrchr(pfilename, FILE_SLASH);
 	const char* pend = strrchr(pfilename, '.');
 	if (pindex&&pend){
 		size_t udatalen = pend - pindex - 1;
@@ -31,7 +41,7 @@ int get_srcfile_name(char* pname, size_t ulen, const char* pfilename)
 }
 
 
-int get_srcfile_format(char* pformat, size_t ulen, const char* pfilename)
+int get_srcfile_format(char* pformat, uint32_t ulen, const char* pfilename)
 {
 	int iret = -1;
 	if (NULL == pfilename){
@@ -51,7 +61,7 @@ int get_srcfile_format(char* pformat, size_t ulen, const char* pfilename)
 }
 
 
-int get_srcfile_hash(char* phash, size_t ulen, const char* pfilename)
+int get_srcfile_hash(char* phash, uint32_t ulen, const char* pfilename)
 {
 	int iret = -1;
 	unsigned char hash[RVC_FILE_HASH_LEN] = { 0 };
@@ -101,42 +111,51 @@ static int bin2str(unsigned char* x, int xlen, char* str, int str_size)
 }
 
 
-int get_encrytion_filename(char* strbuffer, size_t ulen, bool bencname, const char* strprefix, size_t uprefixlen, const char* pfilename)
+int get_encrytion_filename(char* strbuffer, uint32_t ulen, bool bencname, const char* strprefix, uint32_t uprefixlen, const char* pfilename)
 {
 	int iret = -1;
 
-	const char* pIndex = strrchr(pfilename, '\\');
+	const char* pIndex = strrchr(pfilename, FILE_SLASH);
 	if (pIndex){
 		pIndex++;
-		strncpy_s(strbuffer, ulen, pfilename, pIndex - pfilename);
+		int ifolderlen = pIndex - pfilename;
+		char strfolder[MAX_PATH] = { 0 };
+		if (MAX_PATH > ifolderlen) {
+			memcpy(strfolder, pfilename, ifolderlen);
+		}
+		
 		if (false == bencname){
-			strncat_s(strbuffer, ulen - (pIndex - pfilename), strprefix, uprefixlen);
-			strcat_s(strbuffer, ulen - (pIndex - pfilename) - uprefixlen, pIndex);
+			snprintf(strbuffer, ulen, "%s%s%s", strfolder, strprefix, pIndex);
 		} 
 		else{
 			unsigned char strSM[RVC_FILE_HASH_LEN] = {0};
-			CMBSM3Digest((unsigned char*)pIndex, strlen(pIndex+1), strSM);
+			CMBSM3Digest((unsigned char*)pIndex, strlen(pIndex), strSM);
 			char strHash[MAX_PATH] = {0};
 			bin2str(strSM, RVC_FILE_HASH_LEN, strHash, MAX_PATH);
-			strncat_s(strbuffer, ulen - (pIndex - pfilename), strHash, strlen(strHash));
+			snprintf(strbuffer, ulen, "%s%s", strfolder, strHash);
 		}
 		iret = 0;
 	}
-
+	 
 	return iret;
 }
 
 
-int get_decrytion_filename(char* strbuffer, size_t ulen, const char* strprefix, size_t uprefixlen, const char* pfilename)
+int get_decrytion_filename(char* strbuffer, uint32_t ulen, const char* strprefix, uint32_t uprefixlen, const char* pfilename)
 {
 	int iret = -1;
 
-	const char* pIndex = strrchr(pfilename, '\\');
+	const char* pIndex = strrchr(pfilename, FILE_SLASH);
 	if (pIndex){
 		pIndex++;
-		strncpy_s(strbuffer, ulen, pfilename, pIndex - pfilename);
-		strncat_s(strbuffer, ulen - (pIndex - pfilename), strprefix, uprefixlen);
-		strcat_s(strbuffer, ulen - (pIndex - pfilename) - uprefixlen, pIndex);
+		int ifolderlen = pIndex - pfilename;
+		char strfolder[MAX_PATH] = { 0 };
+		if (MAX_PATH > ifolderlen) {
+			memcpy(strfolder, pfilename, ifolderlen);
+		}
+
+		snprintf(strbuffer, ulen, "%s%s%s", strfolder, strprefix, pIndex);
+
 		iret = 0;
 	}
 
@@ -156,7 +175,7 @@ int SM4DecECBMode(unsigned char key[16], unsigned char *input, int length, unsig
 }
 
 
-int GenerateSM4Key(unsigned char* pkey, size_t ukeysize, unsigned char* phash, size_t uhashlen, size_t ufilesize)
+int GenerateSM4Key(unsigned char* pkey, uint32_t ukeysize, unsigned char* phash, uint32_t uhashlen, uint32_t ufilesize)
 {
 	int iret = -1;
 
@@ -196,7 +215,7 @@ int GenerateSM4Key(unsigned char* pkey, size_t ukeysize, unsigned char* phash, s
 }
 
 
-int get_file_json_infos_from_rvc_header(char** pstrjson, size_t* ujsonlen, char* pheader, size_t udatalen)
+int get_file_json_infos_from_rvc_header(char** pstrjson, uint32_t* ujsonlen, char* pheader, uint32_t udatalen)
 {
 	int iret = -1;
 	rvc_fileheader_t t_param = {0};
@@ -227,7 +246,7 @@ int get_file_json_infos_from_rvc_header(char** pstrjson, size_t* ujsonlen, char*
 }
 
 
-int get_file_json_infos_from_file(char** pstrjson, size_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 iret = -1;
 	if (NULL == pFile || NULL == pfilename){

+ 9 - 8
Other/libfilecryption/fileanalysis.h

@@ -1,6 +1,7 @@
 #pragma once
 
 #include <stdio.h>
+#include <stdint.h>
 
 #ifndef HEADER_OBJECT_GUID_LEN
 #define HEADER_OBJECT_GUID_LEN 16
@@ -10,14 +11,14 @@
 #define SM4ENC_BLOCK_SIZE 16
 #endif
 
-int get_srcfile_name(char* pname, size_t ulen, const char* pfilename);
-int get_srcfile_format(char* pformat, size_t ulen, const char* pfilename);
-int get_srcfile_hash(char* phash, size_t ulen, const char* pfilename);
+int get_srcfile_name(char* pname, uint32_t ulen, const char* pfilename);
+int get_srcfile_format(char* pformat, uint32_t ulen, const char* pfilename);
+int get_srcfile_hash(char* phash, uint32_t ulen, const char* pfilename);
 unsigned long get_srcfile_size(const char* pfilename);
-int get_encrytion_filename(char* strbuffer, size_t ulen, bool bencname, const char* strprefix, size_t uprefixlen, const char* pfilename);
-int get_decrytion_filename(char* strbuffer, size_t ulen, const char* strprefix, size_t uprefixlen, const char* pfilename);
+int get_encrytion_filename(char* strbuffer, uint32_t ulen, bool bencname, const char* strprefix, uint32_t uprefixlen, const char* pfilename);
+int get_decrytion_filename(char* strbuffer, uint32_t ulen, const char* strprefix, uint32_t uprefixlen, const char* pfilename);
 int SM4EncECBMode(unsigned char key[16], unsigned char *input, int length, unsigned char *output, int *output_len);
 int SM4DecECBMode(unsigned char key[16], unsigned char *input, int length, unsigned char *output, int *output_len);
-int GenerateSM4Key(unsigned char* pkey, size_t ukeysize, unsigned char* phash, size_t uhashlen, size_t ufilesize);
-int get_file_json_infos_from_rvc_header(char** pstrjson, size_t* ujsonlen, char* pheader, size_t udatalen);
-int get_file_json_infos_from_file(char** pstrjson, size_t* ujsonlen, const char* pfilename, FILE* pFile);
+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);

+ 29 - 22
Other/libfilecryption/filecryption.cpp

@@ -9,8 +9,6 @@
 #include <iostream>
 using namespace std;
 
-#include <stdio.h>
-
 #ifndef RVC_MAX_HEADER_LEN
 #define RVC_MAX_HEADER_LEN 512
 #endif
@@ -33,7 +31,7 @@ using namespace std;
 
 
 
-static int encrypt_asf_file(char* poutfilename, char* phead, size_t uheaderlen, unsigned char* pstrkey, size_t ukeylen, FILE * pSrcFile, const filecryption_callback_t * pcallback)
+static int encrypt_asf_file(char* poutfilename, char* phead, uint32_t uheaderlen, unsigned char* pstrkey, uint32_t ukeylen, FILE * pSrcFile, const filecryption_callback_t * pcallback)
 {
 	int iret = -1;
 
@@ -96,7 +94,7 @@ static int encrypt_asf_file(char* poutfilename, char* phead, size_t uheaderlen,
 }
 
 
-static int encrypt_mp4_file(char* poutfilename, char* phead, size_t uheaderlen, unsigned char* pstrkey, size_t ukeylen, FILE* pSrcFile, const filecryption_callback_t* pcallback)
+static int encrypt_mp4_file(char* poutfilename, char* phead, uint32_t uheaderlen, unsigned char* pstrkey, uint32_t ukeylen, FILE* pSrcFile, const filecryption_callback_t* pcallback)
 {
 	int iret = -1;
 
@@ -152,7 +150,7 @@ static int encrypt_mp4_file(char* poutfilename, char* phead, size_t uheaderlen,
 	safe_log(pcallback, "after encode, moov box length is %u.", iencdatalen);
 
 	//3. 填充加密后的moov box长度
-	fwrite(&iencdatalen, 1, sizeof(int32_t), pDestFile);
+	fwrite(&iencdatalen, 1, sizeof(uint32_t), pDestFile);
 
 	//4. 填充加密后的moov box内容
 	if (iencdatalen > 0) {
@@ -171,7 +169,7 @@ static int encrypt_mp4_file(char* poutfilename, char* phead, size_t uheaderlen,
 }
 
 
-int encryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
+int encryption_file(char* poutfile, uint32_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
 {
 	int iret = -1;
 
@@ -180,14 +178,14 @@ int encryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const
 	}
 
 	char pbuffer[RVC_MAX_HEADER_LEN] = {0};
-	size_t uheaderlen = RVC_MAX_HEADER_LEN;
+	uint32_t uheaderlen = RVC_MAX_HEADER_LEN;
 	int ilen = constrcut_rvc_file_header(pbuffer, &uheaderlen, pfilename, pcallback, eversion);
 	if (0 != ilen){
 		return iret;
 	}
 
 	unsigned char strkey[SM4ENC_BLOCK_SIZE] = {0};
-	size_t uindex = (RVC_FILE_HEADER_FLAG_LEN + sizeof(size_t));
+	uint32_t uindex = (RVC_FILE_HEADER_FLAG_LEN + sizeof(uint32_t));
 	if (get_key_from_header_info(strkey, SM4ENC_BLOCK_SIZE, pbuffer + uindex, uheaderlen - uindex, pcallback)){
 		return iret;
 	}
@@ -214,7 +212,7 @@ int encryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const
 }
 
 
-static int decrypt_asf_file(char* poutfilename, FILE* pSrcFile, unsigned char* pstrkey, size_t ukeylen, const filecryption_callback_t* pcallback)
+static int decrypt_asf_file(char* poutfilename, FILE* pSrcFile, unsigned char* pstrkey, uint32_t ukeylen, const filecryption_callback_t* pcallback)
 {
 	int iret = -1;
 	FILE* pDestFile = fopen(poutfilename, "wb");
@@ -258,7 +256,7 @@ static int decrypt_asf_file(char* poutfilename, FILE* pSrcFile, unsigned char* p
 }
 
 
-static int decrypt_mp4_file(char* poutfilename, FILE* pSrcFile, unsigned char* pstrkey, size_t ukeylen, const filecryption_callback_t* pcallback)
+static int decrypt_mp4_file(char* poutfilename, FILE* pSrcFile, unsigned char* pstrkey, uint32_t ukeylen, const filecryption_callback_t* pcallback)
 {
 	int iret = -1;
 	FILE* pDestFile = fopen(poutfilename, "wb");
@@ -290,7 +288,7 @@ static int decrypt_mp4_file(char* poutfilename, FILE* pSrcFile, unsigned char* p
 
 	//2. 获取加密后的moov box大小
 	int32_t uencryptboxsize = 0;
-	fread(&uencryptboxsize, 1, sizeof(int32_t), pSrcFile);
+	fread(&uencryptboxsize, 1, sizeof(uint32_t), pSrcFile);
 	safe_log(pcallback, "encrypt moov box size is = %d.", uencryptboxsize);
 
 	//3. 读取加密后的moov box
@@ -312,10 +310,12 @@ static int decrypt_mp4_file(char* poutfilename, FILE* pSrcFile, unsigned char* p
 	safe_free(pdecmoovboxdata);
 	safe_free(pmoovboxdata);
 
+	iret = 0;
+
 	return iret;
 }
 
-int decryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
+int decryption_file(char* poutfile, uint32_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
 {
 	int iret = -1;
 
@@ -335,9 +335,10 @@ int decryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const
 	if (0 != memcmp(strrvcflag, rvc_header, RVC_FILE_HEADER_FLAG_LEN)){
 		safe_log(pcallback,"file %s is not encryption!",pfilename);
 		fclose(pSrcFile);
-		iret = 0;
 		return iret;
 	}
+	
+	safe_log(pcallback, "%s:%d.", __FUNCTION__, __LINE__);
 
 	int irvcheadlen = 0;
 	fread(&irvcheadlen, 1, sizeof(int), pSrcFile);
@@ -345,24 +346,30 @@ int decryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const
 	memset(prvcbuffer, 0, irvcheadlen);
 	fread(prvcbuffer, 1, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(int), pSrcFile);
 
-	if (0 != memcmp(prvcbuffer+sizeof(size_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN)){
-		if (0 == memcmp(prvcbuffer+sizeof(size_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN-1)){
+	safe_log(pcallback, "%s:%d.", __FUNCTION__, __LINE__);
+
+	if (0 != memcmp(prvcbuffer+sizeof(uint32_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN)){
+		if (0 == memcmp(prvcbuffer+sizeof(uint32_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN-1)){
 			safe_log(pcallback,"file %s encryption and decryption version is not matched!",pfilename);
 		} 
 		fclose(pSrcFile);
 		return iret;
 	}
+
+	safe_log(pcallback, "%s:%d.", __FUNCTION__, __LINE__);
 	
 	unsigned char strkey[SM4ENC_BLOCK_SIZE] = {0};
 	if (get_key_from_header_info(strkey, SM4ENC_BLOCK_SIZE, prvcbuffer, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(int), pcallback)){
 		return iret;
 	}
 
+	safe_log(pcallback, "%s:%d.", __FUNCTION__, __LINE__);
 
 	if (get_decrytion_filename(poutfile, uoutlen, RVC_FILEDEC_STR, strlen(RVC_FILEDEC_STR), pfilename)){
 		return iret;
 	}
 	
+	safe_log(pcallback, "%s:%d.", __FUNCTION__, __LINE__);
 
 	if (eVerA == eversion) {
 		iret = decrypt_asf_file(poutfile, pSrcFile, strkey, SM4ENC_BLOCK_SIZE, pcallback);
@@ -410,7 +417,7 @@ bool is_file_encrypted(const char* pfilename, const filecryption_callback_t* pca
 	输入:文件路径
 	输出:文件明文头数据,文件明文头长度,加解密前后文件偏移量,自定义头文件头信息
 */
-int rvc_file_decrypt(unsigned char** pdechead, size_t* udecheadlen, int* ioffset, char** pstrjson, size_t* ujsonlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
+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, eRvcCryptionVersion eversion)
 {
 	int iret = -1;
 	if (NULL == pfilename || eversion >= sizeof(cryption_ver_flag_table)/sizeof(char*) || eversion < 0){
@@ -440,13 +447,13 @@ int rvc_file_decrypt(unsigned char** pdechead, size_t* udecheadlen, int* ioffset
 	}
 	else{
 		//safe_log(pcallback,"file %s is encrypted!",pfilename);
-		fread(&irvcheadlen, 1, sizeof(int), pSrcFile);
+		fread(&irvcheadlen, 1, sizeof(uint32_t), pSrcFile);
 		char* prvcbuffer = (char*)malloc(irvcheadlen);
 		memset(prvcbuffer, 0, irvcheadlen);
-		fread(prvcbuffer, 1, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(int), pSrcFile);
+		fread(prvcbuffer, 1, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(uint32_t), pSrcFile);
 
-		if (0 != memcmp(prvcbuffer+sizeof(size_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN)){
-			if (0 == memcmp(prvcbuffer+sizeof(size_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN-1)){
+		if (0 != memcmp(prvcbuffer+sizeof(uint32_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN)){
+			if (0 == memcmp(prvcbuffer+sizeof(uint32_t), cryption_ver_flag_table[eversion], RVC_CRYPTION_VER_FLAG_LEN-1)){
 				safe_log(pcallback,"file %s encryption and decrption version is not matched!",pfilename);
 			} 
 			safe_free(prvcbuffer);
@@ -454,13 +461,13 @@ int rvc_file_decrypt(unsigned char** pdechead, size_t* udecheadlen, int* ioffset
 			return iret;
 		}
 
-		if (get_key_from_header_info(strkey, SM4ENC_BLOCK_SIZE, prvcbuffer, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(int), pcallback)){
+		if (get_key_from_header_info(strkey, SM4ENC_BLOCK_SIZE, prvcbuffer, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(uint32_t), pcallback)){
 			safe_free(prvcbuffer);
 			fclose(pSrcFile);
 			return iret;
 		}
 
-		int ijson = get_file_json_infos_from_rvc_header(pstrjson, ujsonlen, prvcbuffer, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(int));
+		int ijson = get_file_json_infos_from_rvc_header(pstrjson, ujsonlen, prvcbuffer, irvcheadlen - RVC_FILE_HEADER_FLAG_LEN - sizeof(uint32_t));
 		if (0 == ijson){
 			safe_log(pcallback,"get_file_json_infos_from_rvc_header success!");
 		}

+ 4 - 3
Other/libfilecryption/filecryption.h

@@ -1,5 +1,6 @@
 #pragma once
 #include <stddef.h>
+#include <stdint.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -49,10 +50,10 @@ typedef struct filecryption_callback_s  {
 #endif
 
 
-FILECRYPTION_API(int) encryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion);
-FILECRYPTION_API(int) decryption_file(char* poutfile, size_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback = NULL, eRvcCryptionVersion eversion = eVerA);
+FILECRYPTION_API(int) encryption_file(char* poutfile, uint32_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion);
+FILECRYPTION_API(int) decryption_file(char* poutfile, uint32_t uoutlen, const char* pfilename, const filecryption_callback_t* pcallback = NULL, eRvcCryptionVersion eversion = eVerA);
 FILECRYPTION_API(bool) is_file_encrypted(const char* pfilename, const filecryption_callback_t* pcallback);
-FILECRYPTION_API(int) rvc_file_decrypt(unsigned char** pdechead, size_t* udecheadlen, int* ioffset, char** pstrjson, size_t* ujsonlen,const char* pfilename, const filecryption_callback_t* pcallback = NULL, eRvcCryptionVersion eversion = eVerA);
+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);
 
 #ifdef __cplusplus

+ 1 - 16
Other/libfilecryption/mp4info.cpp

@@ -14,21 +14,6 @@ static unsigned int big_to_small_endian_32bit(unsigned int const big)
 }
 
 
-static __int64 big_to_small_endian_64bit(__int64 const big)
-{
-	__int64 data = big;
-	__int64 uret = 0;
-	uret += (data >> 0 & 0xff) << 56;
-	uret += (data >> 8 & 0xff) << 48;
-	uret += (data >> 16 & 0xff) << 40;
-	uret += (data >> 24 & 0xff) << 32;
-	uret += (data >> 32 & 0xff) << 24;
-	uret += (data >> 40 & 0xff) << 16;
-	uret += (data >> 48 & 0xff) << 8;
-	uret += (data >> 56 & 0xff) << 0;
-	return uret;
-}
-
 
 //ftyp, free, mdat box not encryt
 unsigned int get_noencrypt_boxs_size(FILE* pSrcFile, const filecryption_callback_t* pcallback, bool bgetmoov)
@@ -71,7 +56,7 @@ unsigned int get_noencrypt_boxs_size(FILE* pSrcFile, const filecryption_callback
 	}
 	safe_log(pcallback, "get mdat box success, box size is %d.", uboxsize);
 	uret += uboxsize;
-	safe_log(pcallback, "uret is %u.", uret);
+	safe_log(pcallback, "ftyp box, free box and mdat box total size is %u.", uret);
 
 	//moov box
 	if (bgetmoov) {

+ 20 - 20
Other/libfilecryption/rvcfileheader.cpp

@@ -4,7 +4,7 @@
 #include <string.h>
 
 
-int constrcut_rvc_file_header(char* pbuffer, size_t* ulen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
+int constrcut_rvc_file_header(char* pbuffer, uint32_t* ulen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion)
 {
 	int iret = -1;
 
@@ -12,14 +12,14 @@ int constrcut_rvc_file_header(char* pbuffer, size_t* ulen, const char* pfilename
 	size_t udatalen = strlen(rvc_header);
 	memcpy(pbuffer, rvc_header, udatalen);
 	//2. 自定义文件头长度4位
-	udatalen += sizeof(size_t);
+	udatalen += sizeof(uint32_t);
 	//3. 文件加密版本标识
 	const char* strheader = cryption_ver_flag_table[0];
 	if (eversion < sizeof(cryption_ver_flag_table)/sizeof(char*) && eversion >= 0){
 		strheader = cryption_ver_flag_table[eversion];
 	}
 	if (0 == fill_tag_buffer(pbuffer + udatalen, *ulen - udatalen, strheader, strlen(strheader))){
-		udatalen += (strlen(strheader) + sizeof(size_t));
+		udatalen += (strlen(strheader) + sizeof(uint32_t));
 	}
 
 	//4. 源文件hash值
@@ -29,7 +29,7 @@ int constrcut_rvc_file_header(char* pbuffer, size_t* ulen, const char* pfilename
 		return iret;
 	}
 	if (0 == fill_tag_buffer(pbuffer + udatalen, *ulen - udatalen, strhash, RVC_FILE_HASH_LEN)){
-		udatalen += (RVC_FILE_HASH_LEN + sizeof(size_t));
+		udatalen += (RVC_FILE_HASH_LEN + sizeof(uint32_t));
 	}
 
 	//5. 源文件文件大小
@@ -41,23 +41,23 @@ int constrcut_rvc_file_header(char* pbuffer, size_t* ulen, const char* pfilename
 	char strname[MAX_PATH] = {0};
 	get_srcfile_name(strname, MAX_PATH, pfilename);
 	if (0 == fill_tag_buffer(pbuffer + udatalen, *ulen - udatalen, strname, strlen(strname))){
-		udatalen += (strlen(strname) + sizeof(size_t));
+		udatalen += (strlen(strname) + sizeof(uint32_t));
 	}
 	//7. 真实文件格式,后缀名
 	char strformat[MAX_PATH] = {0};
 	get_srcfile_format(strformat, MAX_PATH, pfilename);
 	if (0 == fill_tag_buffer(pbuffer + udatalen, *ulen - udatalen, strformat, strlen(strformat))){
-		udatalen += (strlen(strformat) + sizeof(size_t));
+		udatalen += (strlen(strformat) + sizeof(uint32_t));
 	}
 	safe_log(pcallback,"file name is %s, and file format is %s.",strname, strformat);
 	*ulen = udatalen;
-	memcpy(pbuffer+RVC_FILE_HEADER_FLAG_LEN, &udatalen, sizeof(size_t));
+	memcpy(pbuffer+RVC_FILE_HEADER_FLAG_LEN, &udatalen, sizeof(uint32_t));
 	iret = 0;
 	return iret;
 }
 
 
-int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, size_t ulen, const filecryption_callback_t* pcallback)
+int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, uint32_t ulen, const filecryption_callback_t* pcallback)
 {
 	int iret = -1;
 	if (NULL == pheadbuffer){
@@ -66,14 +66,14 @@ int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, size_t
 	//3. 文件加密版本标识
 	size_t uindex = 0;
 	if (0 == get_tag_value_from_buffer(pdata->strcryptver, RVC_CRYPTION_VER_FLAG_LEN, pheadbuffer+uindex, ulen - uindex)){
-		uindex += (RVC_CRYPTION_VER_FLAG_LEN + sizeof(size_t));
+		uindex += (RVC_CRYPTION_VER_FLAG_LEN + sizeof(uint32_t));
 	}
 	else{
 		return iret;
 	}
 	//4. 源文件hash值
 	if (0 == get_tag_value_from_buffer((char*)pdata->strhash, RVC_FILE_HASH_LEN, pheadbuffer+uindex, ulen - uindex)){
-		uindex += (RVC_FILE_HASH_LEN + sizeof(size_t));
+		uindex += (RVC_FILE_HASH_LEN + sizeof(uint32_t));
 	}
 	else{
 		return iret;
@@ -83,7 +83,7 @@ int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, size_t
 	uindex += sizeof(unsigned long);
 	//6. 源文件文件名
 	if (0 == get_tag_value_from_buffer((char*)pdata->strsrcfilename, MAX_PATH, pheadbuffer+uindex, ulen - uindex)){
-		uindex += (strlen(pdata->strsrcfilename) + sizeof(size_t));
+		uindex += (strlen(pdata->strsrcfilename) + sizeof(uint32_t));
 	}
 	else{
 		return iret;
@@ -97,16 +97,16 @@ int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, size_t
 }
 
 
-int fill_tag_buffer(char* pbuffer, size_t ubuffersize, const char* pdata, size_t udatalen)
+int fill_tag_buffer(char* pbuffer, uint32_t ubuffersize, const char* pdata, uint32_t udatalen)
 {
 	int iret = -1;
 	if (NULL == pdata || NULL == pbuffer){
 		return iret;
 	}
 
-	if (ubuffersize > udatalen + sizeof(size_t)){
-		memcpy(pbuffer, &udatalen, sizeof(size_t));
-		memcpy(pbuffer + sizeof(size_t), pdata, udatalen);
+	if (ubuffersize > udatalen + sizeof(uint32_t)){
+		memcpy(pbuffer, &udatalen, sizeof(uint32_t));
+		memcpy(pbuffer + sizeof(uint32_t), pdata, udatalen);
 		iret = 0;
 	}
 
@@ -114,18 +114,18 @@ int fill_tag_buffer(char* pbuffer, size_t ubuffersize, const char* pdata, size_t
 }
 
 
-int get_tag_value_from_buffer(char* pbuffer, size_t ubuffersize, const char* pdata, size_t udatalen)
+int get_tag_value_from_buffer(char* pbuffer, uint32_t ubuffersize, const char* pdata, uint32_t udatalen)
 {
 	int iret = -1;
-	if (NULL == pdata || NULL == pbuffer || udatalen < sizeof(size_t)){
+	if (NULL == pdata || NULL == pbuffer || udatalen < sizeof(uint32_t)){
 		return iret;
 	}
 
 	int idatalen = 0;
 	memcpy(&idatalen, pdata, sizeof(int));
 
-	if (udatalen >= idatalen + sizeof(size_t) && ubuffersize >= idatalen){
-		memcpy(pbuffer, pdata + sizeof(size_t), idatalen);
+	if (udatalen >= idatalen + sizeof(uint32_t) && ubuffersize >= idatalen){
+		memcpy(pbuffer, pdata + sizeof(uint32_t), idatalen);
 		iret = 0;
 	}
 
@@ -133,7 +133,7 @@ int get_tag_value_from_buffer(char* pbuffer, size_t ubuffersize, const char* pda
 }
 
 
-int get_key_from_header_info(unsigned char* pkey, size_t ukeysize, char* pheader, size_t udatalen, const filecryption_callback_t* pcallback)
+int get_key_from_header_info(unsigned char* pkey, uint32_t ukeysize, char* pheader, uint32_t udatalen, const filecryption_callback_t* pcallback)
 {
 	int iret = -1;
 

+ 6 - 5
Other/libfilecryption/rvcfileheader.h

@@ -1,6 +1,7 @@
 #pragma once
 #include <stdio.h>
 #include "filecryption.h"
+#include <stdint.h>
 
 #ifndef RVC_FILE_HEADER_FLAG_LEN
 #define RVC_FILE_HEADER_FLAG_LEN	16
@@ -49,9 +50,9 @@ typedef struct rvc_fileheader_s{
 	char strsrcfileformat[MAX_PATH];
 }rvc_fileheader_t;
 
-int constrcut_rvc_file_header(char* pbuffer, size_t* ulen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion);
+int constrcut_rvc_file_header(char* pbuffer, uint32_t* ulen, const char* pfilename, const filecryption_callback_t* pcallback, eRvcCryptionVersion eversion);
 // pheadbuffer从自定义的文件头的字段3,文件加密版本标识初开始
-int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, size_t ulen, const filecryption_callback_t* pcallback);
-int fill_tag_buffer(char* pbuffer, size_t ubuffersize, const char* pdata, size_t udatalen);
-int get_tag_value_from_buffer(char* pbuffer, size_t ubuffersize, const char* pdata, size_t udatalen);
-int get_key_from_header_info(unsigned char* pkey, size_t ukeysize, char* pheader, size_t udatalen, const filecryption_callback_t* pcallback);
+int get_rvc_file_header_info(rvc_fileheader_t* pdata, char* pheadbuffer, uint32_t ulen, const filecryption_callback_t* pcallback);
+int fill_tag_buffer(char* pbuffer, uint32_t ubuffersize, const char* pdata, uint32_t udatalen);
+int get_tag_value_from_buffer(char* pbuffer, uint32_t ubuffersize, const char* pdata, uint32_t udatalen);
+int get_key_from_header_info(unsigned char* pkey, uint32_t ukeysize, char* pheader, uint32_t udatalen, const filecryption_callback_t* pcallback);

+ 2 - 2
Other/unix/libvideorecord/libvideorecord_impl.cpp

@@ -751,14 +751,14 @@ bool libvideorecord_impl::GetRecordVideoFrameSize()
 			}
 		}
 		else {
-			m_pHostApi->Debug(RECORD_LOG_INFO, "Get Video FrameSize success, and failed times is %d.", i);
+			m_pHostApi->Debug(RECORD_LOG_INFO, "get video frameSize success, and failed times is %d.", i);
 			bRet = true;
 			break;
 		}
 	}
 
 	if (bRet) {
-		m_pHostApi->Debug(RECORD_LOG_DEBUG, "Get Video FrameSize is %d, and width is %d, height is %d.", m_iVideoFrameSize, m_iWidth, m_iHeight);
+		m_pHostApi->Debug(RECORD_LOG_DEBUG, "get video frameSize is %d, and width is %d, height is %d.", m_iVideoFrameSize, m_iWidth, m_iHeight);
 	}
 		
 	return bRet;

+ 1 - 1
Other/win/libbizchan/bizchan.c

@@ -822,7 +822,7 @@ static void process(bizchan_t *chan)
 												memcpy(chan->remote_client_id, ack_hdr.client_id, sizeof(chan->remote_client_id));
 												chan->remote_version = ack_hdr.version;
 												bizlog(chan, "remote_acm_version:%d", chan->remote_version);
-												chan->connected = TRUE;
+												chan->connected = 1;
 												break;
 											}
 											else {

+ 2 - 2
Other/win/libvideorecord/libvideorecord_impl.cpp

@@ -707,14 +707,14 @@ bool libvideorecord_impl::GetRecordVideoFrameSize()
 			}
 		}
 		else {
-			m_pHostApi->Debug(RECORD_LOG_INFO, "Get Video FrameSize success, and failed times is %d.", i);
+			m_pHostApi->Debug(RECORD_LOG_INFO, "get video framesize success, and failed times is %d.", i);
 			bRet = true;
 			break;
 		}
 	}
 
 	if (bRet) {
-		m_pHostApi->Debug(RECORD_LOG_DEBUG, "Get Video FrameSize is %d, and width is %d, height is %d.", m_iVideoFrameSize, m_iWidth, m_iHeight);
+		m_pHostApi->Debug(RECORD_LOG_DEBUG, "get video framesize is %d, and width is %d, height is %d.", m_iVideoFrameSize, m_iWidth, m_iHeight);
 	}
 		
 	return bRet;