浏览代码

Z991239-5223 #comment 同步音视频相关实体代码到编译器升级分支

80274480 1 年之前
父节点
当前提交
06054e1138
共有 31 个文件被更改,包括 1999 次插入2851 次删除
  1. 4 2
      Module/mod_SalesRecorder/CMakeLists.txt
  2. 3 1
      Module/mod_SalesRecorder/Event.h
  3. 39 39
      Module/mod_SalesRecorder/mod_SalesRecorder.h
  4. 183 159
      Module/mod_SalesRecorder/unix/mod_SalesRecorder.cpp
  5. 169 389
      Module/mod_SalesRecorder/win/mod_SalesRecorder.cpp
  6. 1 3
      Module/mod_counterconnector/http_callrouter.h
  7. 442 442
      Module/mod_livenessdetection/RvcWsServer.cpp
  8. 2 20
      Module/mod_livenessdetection/win/mod_livenessdetection.cpp
  9. 1 4
      Module/mod_mediacontroller/capture.h
  10. 1 1
      Module/mod_mediacontroller/unix/capture.cpp
  11. 395 371
      Module/mod_mediacontroller/win/capture.cpp
  12. 102 296
      Module/mod_mediacontroller/win/mod_mediacontroller.cpp
  13. 5 8
      Module/mod_recorder/mod_recorder.h
  14. 6 5
      Module/mod_recorder/recordinfo.cpp
  15. 5 2
      Module/mod_recorder/recordinfo.h
  16. 23 37
      Module/mod_recorder/unix/mod_recorder.cpp
  17. 308 260
      Module/mod_recorder/win/mod_recorder.cpp
  18. 1 1
      Module/mod_sipphone/mod_sipphone.h
  19. 12 52
      Module/mod_sipphone/win/audio_session.cpp
  20. 15 130
      Module/mod_sipphone/win/endpoint.cpp
  21. 125 292
      Module/mod_sipphone/win/mod_sipphone.cpp
  22. 8 230
      Module/mod_sipphone/win/video_session.cpp
  23. 21 11
      Other/unix/libvideorecord/FFmpegWriter.cpp
  24. 3 2
      Other/unix/libvideorecord/FFmpegWriter.h
  25. 13 12
      Other/unix/libvideorecord/libvideorecord_impl.cpp
  26. 21 11
      Other/win/libvideorecord/FFmpegWriter.cpp
  27. 3 2
      Other/win/libvideorecord/FFmpegWriter.h
  28. 2 3
      Other/win/libvideorecord/libvideorecord.cpp
  29. 3 2
      Other/win/libvideorecord/libvideorecord.h
  30. 74 63
      Other/win/libvideorecord/libvideorecord_impl.cpp
  31. 9 1
      Other/win/libvideorecord/libvideorecord_impl.h

+ 4 - 2
Module/mod_SalesRecorder/CMakeLists.txt

@@ -4,6 +4,8 @@ set(${MODULE_PREFIX}_SRCS
 	Event.h
 	mod_SalesRecorder.h
 	${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_PLAFORM_SUBDIR}/mod_SalesRecorder.cpp
+	${MODULE_BASE_DIR}/mod_recorder/recordinfo.h
+	${MODULE_BASE_DIR}/mod_recorder/recordinfo.cpp
 )
 
 set(MOD_VERSION_STRING "0.0.1-dev1")
@@ -28,9 +30,9 @@ target_link_directories(${MODULE_NAME} PRIVATE
 
 # 添加实体需要依赖的其他共享库(包括系统库)
 if(WIN32)
-set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} wmpplayer libvideorecord)
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} libvideorecord)
 else(WIN32)
-set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} mediaplayer libvideorecord)
+set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} ${RVCCOMM_LIB} libvideorecord)
 endif(WIN32)
 
 target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})

+ 3 - 1
Module/mod_SalesRecorder/Event.h

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

+ 39 - 39
Module/mod_SalesRecorder/mod_SalesRecorder.h

@@ -3,13 +3,9 @@
 #include "SpBase.h"
 #include "SpIni.h"
 
-#ifdef RVC_OS_WIN
-#include "libwmpplayer/libwmpplayer.h"
-#else
-#include "libmediaplayer/libmediaplayer.h"
-#endif // RVC_OS_WIN
 #include "libvideorecord/libvideorecord.h"
 #include "EventCode.h"
+#include "../mod_recorder/recordinfo.h"
 
 #include "SalesRecorder_server_g.h"
 #include "SalesRecorder_msg_g.h"
@@ -17,6 +13,11 @@
 #include "SelfChecker_client_g.h"
 #include "SelfChecker_def_g.h"
 
+
+#ifndef RVC_SALES_RECORD_SUFFIX
+#define RVC_SALES_RECORD_SUFFIX "S_"
+#endif // !RVC_SALES_RECORD_SUFFIX
+
 using namespace SalesRecorder;
 using namespace SelfChecker;
 
@@ -63,15 +64,15 @@ namespace SalesRecorder {
 	};
 
 #ifdef RVC_OS_WIN
-	class CSalesRecorderEntity : public CEntityBase, public CHostApi, public CWmpHostApi, public ILogListener,public ISysVarListener, public ITimerListener
+	class CSalesRecorderEntity : public CEntityBase, public CHostApi, public ILogListener,public ISysVarListener, public ITimerListener
 	{
 	public:
-		CSalesRecorderEntity() : m_pRecorder(NULL), m_bStarted(FALSE), m_loglevel(RECORD_LOG_INFO), m_lowestlevel(RECORD_LOG_DEBUG), m_eRecordType(eWMV) { ZeroMemory(m_SalesVideoName, MAX_PATH); }
+		CSalesRecorderEntity() : m_pRecorder(NULL), m_bStarted(false), m_loglevel(RECORD_LOG_INFO), m_lowestlevel(RECORD_LOG_DEBUG), m_eRecordType(eWMV) { ZeroMemory(m_SalesVideoName, MAX_PATH); }
 #else
-	class CSalesRecorderEntity : public CEntityBase, public CHostApi, public CMediaHostApi, public ILogListener, public ISysVarListener, public ITimerListener
+	class CSalesRecorderEntity : public CEntityBase, public CHostApi, public ILogListener, public ISysVarListener, public ITimerListener
 	{
 	public:
-		CSalesRecorderEntity() : m_pRecorder(NULL), m_bStarted(false), m_bIsShowVideo(false), m_loglevel(RECORD_LOG_INFO), m_lowestlevel(RECORD_LOG_DEBUG) { ZeroMemory(m_SalesVideoName, MAX_PATH); }
+		CSalesRecorderEntity() : m_pRecorder(NULL), m_bStarted(false), m_loglevel(RECORD_LOG_INFO), m_lowestlevel(RECORD_LOG_DEBUG) { ZeroMemory(m_SalesVideoName, MAX_PATH); }
 #endif // RVC_OS_WIN
 
 		virtual ~CSalesRecorderEntity() { /*empty implementation*/ }
@@ -80,7 +81,6 @@ namespace SalesRecorder {
 
 		const char* GetEntityVersion() const { return MODULE_VERSION_FULL; }
 
-
 		virtual bool IsService() const{ return true; }
 
 		virtual CServerSessionBase *OnNewSession(const char* pszRemoteEntityName, const char * pszClass);
@@ -111,23 +111,6 @@ namespace SalesRecorder {
 
 		virtual void OnRecordFinished();
 
-#ifdef RVC_OS_WIN
-		// CWmpHostAPI
-		virtual void WmpDebug(const char *fmt, ...);
-
-		virtual void WmpLogEvt(int ievent, const char* strmsg){};
-
-		virtual BOOL LoadPlayConfig(CWmpPlayConfig &config, int CfgInx) { return TRUE; }
-#else
-		virtual int LoadPlayConfig(CMediaPlayConfig& config, int CfgInx = 0) { return TRUE; }
-		//virtual void Debug(const char* fmt, ...);
-		virtual void MediaPlayFinished(int iMediaType){}
-		virtual int GetMediaPlayerIcoPath(char* strPath, size_t uLen) {}
-		virtual int GetAudioOutDevName(char* strDev, size_t uLen) {}
-		virtual void Debug(media_loglevel log_level, const char* fmt, ...);
-		virtual int PlayingAudioDataCallback(audio_param_t* param, const void* input, unsigned long uaudiolen) {}
-#endif // RVC_OS_WIN
-
 		virtual void OnTimeout(DWORD dwTimerID);
 
 		virtual void OnSysVarEvent(const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName);
@@ -143,10 +126,6 @@ namespace SalesRecorder {
 
 		void StartOnSiteSalesRecord(const int fps, const char* videofilename, int videoquality, int audioOutBitRate, SubtitleParam* subtitleParam, BOOL bWholeSection, BOOL bSessionManage, eRvcRecordType eRecordType);
 
-		bool GetHighQualityOnSiteSalesRecorder(const eRvcRecordType eRecordType);
-
-		bool GetStandardQualityOnSiteSalesRecorder(const eRvcRecordType eRecordType);
-
 		void DeleteAllVideo(const char* wmvfilename);
 
 		ErrorCodeEnum DeleteVideo(const char* wmvfilename);
@@ -166,10 +145,6 @@ namespace SalesRecorder {
 
 		void StartOnSiteSalesRecord(const int fps, const char* videofilename, int videoquality, int audioOutBitRate, SubtitleParam* subtitleParam, BOOL bWholeSection, BOOL bSessionManage, eRvcRecordType eRecordType);
 
-		bool GetStandardQualityOnSiteSalesRecorder();
-
-		bool GetHighQualityOnSiteSalesRecorder();
-
 		ErrorCodeEnum DeleteVideo(const char* videofilename);
 
 		bool SecureClientConnect();
@@ -179,10 +154,14 @@ namespace SalesRecorder {
 		ErrorCodeEnum HandleVideoAppendWatermark(const char* pszVideoName, const wchar_t* pszWaterMark);
 
 		bool InitSalesRecorder();
+
 		bool ReleaseSalesRecorder();
 
 #endif //RVC_OS_WIN
-		
+		bool GetStandardQualityOnSiteSalesRecorder();
+
+		bool GetHighQualityOnSiteSalesRecorder();
+
 		ErrorCodeEnum StopRecord();
 
 		ErrorCodeEnum HandleStopRecord(const char* pszMessage);
@@ -196,26 +175,37 @@ namespace SalesRecorder {
 		// 获取终端准入状态(这个系统变量为A是表示准入通过)
 		CSimpleStringA GetTerminalStage();
 
-		ErrorCodeEnum StopRecordVideo();
-
 		ErrorCodeEnum HandleDisplayVideo();
+
 		ErrorCodeEnum HandleSaveVideo();
+
 		ErrorCodeEnum HandleDeleteVideo();
+
 		void HandleReturnMenu();
+
 		ErrorCodeEnum HandleStartRecord(const char *pszMessage, const bool bRemoteRecord);
+
 		ErrorCodeEnum HandleSalesRecordEntityException(const char* pszMessage);
+
 		ErrorCodeEnum RealSelfCheck();
 
 		void UploadTempPathVideos();
+
 		ErrorCodeEnum SetRecordAudioQuality(int iAudioQuality);
+
 		ErrorCodeEnum SetRecordAudioNsPolicy(int iNsPolicy);
+
 		ErrorCodeEnum SetRecordAudioChannles(int iAudioChannles);
 
 		DeviceTypeEnum RvcGetDeviceType();
 
 		ErrorCodeEnum HandleStopShowVideo();
+
 		ErrorCodeEnum HandlePlaySalesRecordVideo(int iWndX, int iWndY, int iWndWidth, int iWndHeight);
 
+		ErrorCodeEnum PostSalesRecordInfos();
+
+		ErrorCodeEnum AddToSalesRecordList(const char* videopath, const char* strfilename, unsigned long ufilesize);
 	private:
 		DeviceTypeEnum m_eDeviceType;
 		int m_iActiveCamera;
@@ -230,7 +220,6 @@ namespace SalesRecorder {
 #else
 		bool m_bWholeSection;
 		bool m_bApplyHighQuality;
-		bool m_bIsShowVideo;
 #endif // RVC_OS_WIN
 		CAutoArray<CUUID> m_arrListener;
 		char m_SalesVideoName[MAX_PATH];
@@ -254,6 +243,17 @@ namespace SalesRecorder {
 		bool m_bIsAudioNsOn;
 		int m_iAudioNsPolicy;
 		int m_iAudioChannels;
+
+		bool m_bPostOn;
+		
+		CSimpleStringA m_strHttpServerAddr;
+		CSimpleStringA m_strHttpServerAPI;
+		int m_iHttpTimeOut;
+		CSimpleStringA m_strAppVersion;
+		CSimpleStringA m_strTerminalId;
+		vector<record_item_t> m_vRecordList;
+		eRvcBusinessStatus m_eBusinessStatus;
+
 		friend class SalesRecordServiceSession;
 	};
 }

+ 183 - 159
Module/mod_SalesRecorder/unix/mod_SalesRecorder.cpp

@@ -6,6 +6,7 @@
 #include "array.h"
 #include <memutil.h>
 #include <algorithm>
+#include "y2k_time.h"
 #ifdef RVC_OS_WIN
 #include <Windows.h>
 #else
@@ -242,6 +243,14 @@ static CSimpleStringA DecryptString(LPCTSTR lpszEncrpyted)
 	return CSimpleStringA((LPCTSTR)csPlainTxt);
 }
 
+
+static unsigned long GetFileSize(const char* filename)
+{
+	struct stat statbuf;
+	stat(filename, &statbuf);
+	return statbuf.st_size;
+}
+
 void SalesRecordServiceSession::Handle_GetOFLVideoRecords( SpReqAnsContext<SalesRecorderSerVice_GetOFLVideoRecords_Req, SalesRecorderSerVice_GetOFLVideoRecords_Ans>::Pointer ctx )
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
@@ -261,8 +270,7 @@ void SalesRecordServiceSession::Handle_CheckVideoDiskStatus( SpReqAnsContext<Sal
 void SalesRecordServiceSession::Handle_PlayVideo(SpReqAnsContext<SalesRecorderSerVice_PlayVideo_Req, SalesRecorderSerVice_PlayVideo_Ans>::Pointer ctx)
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
-	ErrorCodeEnum ErrorCode = m_pEntity->HandleDisplayVideo();
-	ctx->Answer(ErrorCode);
+	ctx->Answer(Error_Succeed);
 }
 
 void SalesRecordServiceSession::Handle_SaveVideo(SpReqAnsContext<SalesRecorderSerVice_SaveVideo_Req, SalesRecorderSerVice_SaveVideo_Ans>::Pointer ctx)
@@ -290,15 +298,13 @@ void SalesRecordServiceSession::Handle_SetAudioTransFlag(SpReqAnsContext<SalesRe
 void SalesRecordServiceSession::Handle_StopShowVideo(SpReqAnsContext<SalesRecorderSerVice_StopShowVideo_Req, SalesRecorderSerVice_StopShowVideo_Ans>::Pointer ctx)
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
-	ErrorCodeEnum ErrorCode = m_pEntity->HandleStopShowVideo();
-	ctx->Answer(ErrorCode);
+	ctx->Answer(Error_Succeed);
 }
 
 void SalesRecordServiceSession::Handle_PlaySalesRecord(SpReqAnsContext<SalesRecorderSerVice_PlaySalesRecord_Req, SalesRecorderSerVice_PlaySalesRecord_Ans>::Pointer ctx)
 {
 	DbgToBeidou(ctx->link, __FUNCTION__)();
-	ErrorCodeEnum ErrorCode = m_pEntity->HandlePlaySalesRecordVideo(ctx->Req.WndX, ctx->Req.WndY, ctx->Req.WndWidth, ctx->Req.WndHeight);
-	ctx->Answer(ErrorCode);
+	ctx->Answer(Error_Succeed);
 }
 
 void SalesRecordServiceSession::Handle_StartRemoteRecord(SpReqAnsContext<SalesRecorderSerVice_StartRemoteRecord_Req, SalesRecorderSerVice_StartRemoteRecord_Ans>::Pointer ctx)
@@ -345,6 +351,13 @@ ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
 	m_iAudioNsPolicy = 2;
 	m_iAudioChannels = 1;
 
+	m_strHttpServerAPI = RVC_UPLOAD_VIDEORECORDING_HTTP_API;
+	m_iHttpTimeOut = RVC_HTTPTIMEOUT;
+	m_strHttpServerAddr = RVC_UPLOAD_VIDEORECORDING_HTTP_ADDR;
+	m_strAppVersion = NULL;
+	m_strTerminalId = NULL;
+	m_bPostOn = false;
+
 	m_eDeviceType = RvcGetDeviceType();
 
 	int iAudioQuality = 3;
@@ -354,6 +367,9 @@ ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
 	int iLogLevel = 1;
 	int iLowestLevel = 1;
 	int iRecordType = 0;
+	int iTimeOut = RVC_HTTPTIMEOUT;
+	CSimpleStringA strHttpServerAddr("");
+	int iPostOn = 0;
 	m_max_disk_percent = MAX_DISK_PERCENT; 
 	m_audio_samplerate = 8;
 	CSmartPointer<IConfigInfo> spConfig;
@@ -368,6 +384,9 @@ ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
 		spConfig->ReadConfigValueInt("SalesRecorder","AudioChannels",iAudioChannels);
 		spConfig->ReadConfigValueInt("SalesRecorder","LogLevel",iLogLevel);
 		spConfig->ReadConfigValueInt("SalesRecorder","LowestLevel",iLowestLevel);
+		spConfig->ReadConfigValueInt("SalesRecorder", "post_salesrecord_info_on", iPostOn);
+		spConfig->ReadConfigValue("Recorder", "http_video_record_addr", strHttpServerAddr);
+		spConfig->ReadConfigValueInt("Recorder", "http_timeout", iTimeOut);
 	}
 
 	if (m_max_disk_percent <= 0 || m_max_disk_percent >= 100) {
@@ -382,6 +401,18 @@ ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
 		m_lowestlevel = (record_loglevel)iLowestLevel;
 	}
 
+	if (strHttpServerAddr.GetLength() > 0) {
+		m_strHttpServerAddr = strHttpServerAddr;
+	}
+
+	if (iTimeOut > 0 && iTimeOut < 20 * RVC_HTTPTIMEOUT) {
+		m_iHttpTimeOut = iTimeOut;
+	}
+
+	if (1 == iPostOn) {
+		m_bPostOn = true;
+	}
+
 	SetRecordAudioQuality(iAudioQuality);
 	SetRecordAudioNsPolicy(iAudioNsPolicy);
 	SetRecordAudioChannles(iAudioChannels);
@@ -464,6 +495,13 @@ ErrorCodeEnum CSalesRecorderEntity::__OnStart( ErrorCodeEnum preOperationError )
 
 void CSalesRecorderEntity::OnStarted()
 {
+	CSystemStaticInfo si;
+	ErrorCodeEnum Error = GetFunction()->GetSystemStaticInfo(si);
+	if (Error == Error_Succeed) {
+		m_strAppVersion = si.InstallVersion.ToString();
+		m_strTerminalId = si.strTerminalID;
+	}
+
 	InitSalesRecorder();
 	LogEvent(Severity_Middle, LOG_EVT_MOD_SALESRECORDER_STARTED_SUCCESS, "sales recorder entity started successfully.");
 }
@@ -508,46 +546,6 @@ void CSalesRecorderEntity::OnSelfTest(EntityTestEnum eTestType,CSmartPointer<ITr
 	}
 }
 
-
-int CSalesRecorderEntity::GetActiveCamera()
-{
-	return m_iActiveCamera;
-}
-
-int CSalesRecorderEntity::GetCameraState()
-{
-	return m_iCameraState;
-}
-
-void CSalesRecorderEntity::OnRecordFailed(eRvcRecordFailedCase eCase, const char* pszMessage, bool bRecordDevFault )
-{
-	if (eCase < eDefault && eCase >= 0) {
-		LogEvent(Severity_Middle, LOG_EVT_UI_RECORDFAILED, record_failed_case_table[eCase]);
-	}
-
-	char strmsg[MAX_PATH] = { 0 };
-	snprintf(strmsg, MAX_PATH, "{%s}.", pszMessage ? pszMessage : " ");
-	LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_FAILED, strmsg);
-
-	if (eBeginFailed == eCase) {
-		m_bNeedRestart = true;
-		RealSelfCheck();
-	}
-}
-
-void CSalesRecorderEntity::OnRecordEntityExcption()
-{
-	LogEvent(Severity_High,LOG_EVT_SALESRECORD_ENTITY_EXCEPTION,"现场销售双录出现异常,请稍候重录,系统正在恢复中,预计60秒!");
-	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_ENTITY_EXCEPTION, "sales record entity exception!");
-}
-
-
-void CSalesRecorderEntity::OnRecordFinished()
-{
-	LogEvent(Severity_High, LOG_EVT_SALESRECORD_FINISHED, "现场销售双录已完成.");
-	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FINISHED, "现场销售双录已完成.");
-}
-
 void CSalesRecorderEntity::Debug(record_loglevel elevel, const char* fmt, ...)
 {
 	record_loglevel entitylevel = (m_lowestlevel > m_loglevel) ? m_lowestlevel : m_loglevel;
@@ -589,37 +587,46 @@ void CSalesRecorderEntity::vDebug(record_loglevel elevel, const char* str, va_li
 	}
 }
 
+int CSalesRecorderEntity::GetActiveCamera()
+{
+	return m_iActiveCamera;
+}
 
-#ifdef RVC_OS_WIN
-void CSalesRecorderEntity::WmpDebug( const char *fmt, ... )
+int CSalesRecorderEntity::GetCameraState()
 {
-	va_list arg;
-	va_start(arg, fmt);
-	vDbg(fmt, arg);
-	va_end(arg);
+	return m_iCameraState;
 }
-#else
-void CSalesRecorderEntity::Debug(media_loglevel log_level, const char* fmt, ...)
+
+void CSalesRecorderEntity::OnRecordFailed(eRvcRecordFailedCase eCase, const char* pszMessage, bool bRecordDevFault)
 {
-	if (log_level >= MEDIA_LOG_ERROR) {
-		va_list arg;
-		va_start(arg, fmt);
-		int n = vsnprintf(NULL, 0, fmt, arg);
-		if (n >= MAX_PATH) {
-			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);
-		}
-		else {
-			char strlog[MAX_PATH] = { 0 };
-			vsnprintf(strlog, MAX_PATH, fmt, arg);
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s", strlog);
-		}
-		va_end(arg);
+	if (eCase < eDefault && eCase >= 0) {
+		LogEvent(Severity_Middle, LOG_EVT_UI_RECORDFAILED, record_failed_case_table[eCase]);
 	}
+
+	LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SALESRECORD_FAILED, CSimpleStringA::Format("{%s}.", pszMessage ? pszMessage : " ").GetData());
+
+	if (eBeginFailed == eCase) {
+		m_bNeedRestart = true;
+		RealSelfCheck();
+	}
+
+	m_eBusinessStatus = eInterrupt;
+}
+
+void CSalesRecorderEntity::OnRecordEntityExcption()
+{
+	LogEvent(Severity_High,LOG_EVT_SALESRECORD_ENTITY_EXCEPTION,"现场销售双录出现异常,请稍候重录,系统正在恢复中,预计60秒!");
+	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_ENTITY_EXCEPTION, "sales record entity exception!");
 }
-#endif // RVC_OS_WIN
+
+
+void CSalesRecorderEntity::OnRecordFinished()
+{
+	LogEvent(Severity_High, LOG_EVT_SALESRECORD_FINISHED, "现场销售双录已完成.");
+	LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_FINISHED, "现场销售双录已完成.");
+}
+
+
 
 
 void CSalesRecorderEntity::OnTimeout( DWORD dwTimerID )
@@ -723,19 +730,24 @@ void CSalesRecorderEntity::StartOnSiteSalesRecord(const int fps, const char* vid
 	tAudioParams.iAudioOutBitRate = audioOutBitRate;
 	tAudioParams.iAudioChannels = m_iAudioChannels;
 
-	if (eStand2Agent == eRecordType || ePad2Agent == eRecordType) {
+	if (eStand2Agent == eRecordType) {
 		tAudioParams.eOutPutType = eLowDefinition;
 		tAudioParams.bIsNsOn = false;
 	}
 
 	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("init lib video record success! and record type is %s and output audio quality is %s, audio noise suppression flag is %s. noise suppression policy is %d.", record_type_table[eRecordType], audio_quality_type_table[m_eAudioOutQuality], tAudioParams.bIsNsOn ? "true" : "false", tAudioParams.iNsPolicy);
-	if (m_pRecorder->StartVideoRecord(fps, videoquality, eMP4, &tAudioParams, subtitleParam, bWholeSection, false, (LPCSTR)m_TempDir,
+	if (m_pRecorder->StartVideoRecord(fps, videoquality, eMP4, &tAudioParams, subtitleParam, bWholeSection, false, m_TempDir.GetData(),
 		m_TempDir.GetLength(), videofilename, strlen(videofilename)))
 	{
+		m_eBusinessStatus = eSuccess;
 		m_bStarted = true;
 	}
 	else {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Start VideoRecord failed!");
+		m_eBusinessStatus = eFailed;
+		if (m_bPostOn) {
+			PostSalesRecordInfos();
+		}
 	}
 }
 
@@ -759,20 +771,9 @@ ErrorCodeEnum CSalesRecorderEntity::StopRecord()
 	return eCode;
 }
 
-ErrorCodeEnum CSalesRecorderEntity::ShowVideo( const char *videofilename)
-{
-	ErrorCodeEnum ErrorCode = Error_Succeed;
 
-	return ErrorCode;
-}
 
 
-ErrorCodeEnum CSalesRecorderEntity::PlaySalesRecordVideo( const char *videofilename, int iWndX, int iWndY, int iWndWidth, int iWndHeight)
-{
-	ErrorCodeEnum ErrorCode = Error_Succeed;
-
-	return ErrorCode;
-}
 
 
 ErrorCodeEnum CSalesRecorderEntity::DeleteVideo( const char *videofilename)
@@ -816,6 +817,14 @@ ErrorCodeEnum CSalesRecorderEntity::DeleteVideo( const char *videofilename)
 		ErrorCode = Error_NotImpl;
 	}
 
+	if (eInterrupt != m_eBusinessStatus) {
+		m_eBusinessStatus = eCancel;
+	}
+
+	if (m_bPostOn) {
+		PostSalesRecordInfos();
+	}
+
 	return ErrorCode;
 }
 
@@ -828,13 +837,6 @@ Error_NotImpl		方法执行失败
 */
 
 
-static unsigned long GetFileSize(const char* filename)
-{
-	struct stat statbuf;
-	stat(filename, &statbuf);
-	return statbuf.st_size;
-}
-
 
 ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 {
@@ -850,7 +852,7 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 				sourPath += SPLIT_SLASH_STR;
 			}
 			ULONGLONG uVideoCount = 0;
-			// 移动销售录像 edit by ly 2018/03/05
+
 			CSimpleStringA strFindFileName = CSimpleStringA::Format("S_%s*.%s", videofilename, RECORD_MP4_SUFFIX);
 			BOOL bRet = FindMatchedFile((LPCSTR)sourPath, (LPCSTR)strFindFileName, uVideoCount);
 			if(bRet)
@@ -863,7 +865,7 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 					if (destPath.GetLength() > 0 && destPath[destPath.GetLength()-1] != SPLIT_SLASH) {
 						destPath += SPLIT_SLASH_STR;
 					}
-					CSimpleStringA sourFileName, destFileName;
+					CSimpleStringA sourFileName(""), destFileName("");
 					BOOL bMoveSucc = TRUE;
 					for(int i = 0; i != uVideoCount; ++i)
 					{
@@ -874,23 +876,31 @@ ErrorCodeEnum CSalesRecorderEntity::SaveVideo( const char * videofilename)
 						if(rename(sourFileName.GetData(), destFileName.GetData())) {
 							bMoveSucc = FALSE;
 							ErrorCode = Error_NotImpl;
-							LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, CSimpleStringA::Format("Error Code %lu while move %s.", errno, sourFileName.GetData()).GetData());
+							LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, CSimpleStringA::Format("Error Code %lu while move %s.", errno, sourFileName.GetData()).GetData());
 						}
-						if (ufilesize > RVC_MIN_FILESIZE){
-
+						else {
+							CSimpleStringA strVideoName = CSimpleStringA::Format("%s_%d.%s", strFindFileName.GetData(), i, RECORD_MP4_SUFFIX);
+							if (m_bPostOn) {
+								AddToSalesRecordList(destFileName.GetData(), strVideoName.GetData(), ufilesize);
+							}
 						}
-						else{
+
+						if (RVC_MIN_FILESIZE > ufilesize){
 							LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_INVALID_FILE, CSimpleStringA::Format("%s file size is %u.", sourFileName.GetData(), ufilesize).GetData());
 						}
 					}
 					if (bMoveSucc) {
 						LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_SAVED_SUCCESS, CSimpleStringA::Format("succeed to save sales video, move it from %s to %s.", sourFileName.GetData(), destFileName.GetData()).GetData());
+						if (m_bPostOn) {
+							if (Error_Succeed != PostSalesRecordInfos()) {
+								ErrorCode = Error_Failed;
+							}
+						}
 					}
 				}
 			}
-			else
-			{
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, "sales videos not exist or have been deleted");
+			else{
+				LogWarn(Severity_Middle, Error_Debug, LOG_EVT_RECORD_SAVED_FAILED, "sales videos not exist or have been deleted");
 				ErrorCode = Error_NotExist;
 			}
 		}
@@ -925,33 +935,6 @@ void CSalesRecorderEntity::SecureClientRelease()
 }
 
 
-ErrorCodeEnum CSalesRecorderEntity::StopRecordVideo()
-{
-	auto rc = Error_Succeed;
-
-	auto pUIClient = new InteractiveControl::UIService_ClientBase(this);
-
-	if(pUIClient->Connect() != Error_Succeed){
-		pUIClient->SafeDelete();
-		pUIClient = NULL;
-		rc = Error_DevConnFailed;
-	}
-	else{
-		InteractiveControl::UIService_StopRecordVideo_Req req;
-		InteractiveControl::UIService_StopRecordVideo_Ans ans;
-		rc = (*pUIClient)(EntityResource::getLink().upgradeLink())->StopRecordVideo(req, ans, 5000);
-		if(rc != Error_Succeed){
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Stop record video failed return 0x%08x", rc);
-		}
-
-		pUIClient->GetFunction()->CloseSession();
-		pUIClient = NULL;
-	}
-
-	return rc;
-}
-
-
 ErrorCodeEnum CSalesRecorderEntity::HandleStartRecord(const char *pszMessage, const bool bRemoteRecord)
 {
 	ErrorCodeEnum Error = Error_Succeed;
@@ -1096,30 +1079,6 @@ ErrorCodeEnum CSalesRecorderEntity::HandleStopRecord(const char *pszMessage)
 }
 
 
-ErrorCodeEnum CSalesRecorderEntity::HandleDisplayVideo()
-{
-	m_bIsShowVideo = TRUE;
-	ErrorCodeEnum ErrorCode = ShowVideo(m_SalesVideoName);
-	return ErrorCode;
-}
-
-
-ErrorCodeEnum CSalesRecorderEntity::HandlePlaySalesRecordVideo(int iWndX, int iWndY, int iWndWidth, int iWndHeight)
-{
-	m_bIsShowVideo = TRUE;
-	ErrorCodeEnum ErrorCode = PlaySalesRecordVideo(m_SalesVideoName, iWndX, iWndY, iWndWidth, iWndHeight);
-	return ErrorCode;
-}
-
-
-ErrorCodeEnum CSalesRecorderEntity::HandleStopShowVideo()
-{
-	ErrorCodeEnum ErrorCode = Error_Succeed;
-	return ErrorCode;
-}
-
-
-
 ErrorCodeEnum CSalesRecorderEntity::HandleSaveVideo()
 {
 	ErrorCodeEnum ErrorCode = Error_Succeed;
@@ -1179,7 +1138,6 @@ ErrorCodeEnum CSalesRecorderEntity::HandleVideoAppendWatermark(const char* pszVi
 	return Error;
 }
 
-
 ErrorCodeEnum CSalesRecorderEntity::HandleSalesRecordEntityException(const char* pszMessage)
 {
 	// 通知到业务中台
@@ -1237,12 +1195,11 @@ ErrorCodeEnum CSalesRecorderEntity::RealSelfCheck()
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SelfcheckClient connect fail!");
 	}
 
-
 	if (pSelfcheckClient)
 	{
-		SelfChecker::SelfCheckerService_RealCheck_Req req;
+		SelfCheckerService_RealCheck_Req req;
 		req.name = GetEntityName();
-		SelfChecker::SelfCheckerService_RealCheck_Ans ans;
+		SelfCheckerService_RealCheck_Ans ans;
 		DWORD Timeout = 500;
 		Error = pSelfcheckClient->RealCheck(req,ans,Timeout);
 		if (Error!=Error_Succeed){
@@ -1265,7 +1222,7 @@ bool IsMatchedVideo(WIN32_FIND_DATA fileData)
 	if ('S' == fileData.cFileName[0] || 'W' == fileData.cFileName[0]){
 		SYSTEMTIME sysTime;
 		FileTimeToSystemTime(&fileData.ftCreationTime, &sysTime);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("File %s create data info is %d %d %d.", fileData.cFileName, sysTime.wYear, sysTime.wMonth, sysTime.wDay);
+		//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("File %s create data info is %d %d %d.", fileData.cFileName, sysTime.wYear, sysTime.wMonth, sysTime.wDay);
 		if ((2020 == sysTime.wYear) && (sysTime.wMonth == 1)){
 			if (sysTime.wDay >= 3 && sysTime.wDay <= 10){
 				bRet = true;
@@ -1315,8 +1272,6 @@ void CSalesRecorderEntity::UploadTempPathVideos()
 					CSimpleStringA destFileName = CSimpleStringA::Format("%sBAK_%s", (LPCSTR)destPath, FindFileData.cFileName);
 					if(!MoveFile((LPCSTR)sourFileName, (LPCSTR)destFileName)) {
 						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Error Code %lu while move %s ", GetLastError(), (LPCSTR)sourFileName);
-					}else{
-						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Move File %s success.", (LPCSTR)sourFileName);
 					}
 				}
 				else{
@@ -1509,6 +1464,9 @@ DeviceTypeEnum CSalesRecorderEntity::RvcGetDeviceType()
 	else if (stricmp(stStaticinfo.strMachineType, "RVC.Desk1S") == 0) {
 		eType = eDesk1SType;
 	}
+	else if (stricmp(stStaticinfo.strMachineType, "RVC.CardStore") == 0 || stricmp(stStaticinfo.strMachineType, "RVC.CardPrinter") == 0) {
+		eType = eCardStore;
+	}
 	else {
 		eType = eStand2sType;
 	}
@@ -1521,7 +1479,73 @@ DeviceTypeEnum CSalesRecorderEntity::RvcGetDeviceType()
 }
 
 
-SelfChekerClient::SelfChekerClient( CSalesRecorderEntity *pEntity ) : SelfChecker::SelfCheckerService_ClientBase(pEntity)
+
+ErrorCodeEnum CSalesRecorderEntity::AddToSalesRecordList(const char* videopath, const char* strfilename, unsigned long ufilesize)
+{
+	ErrorCodeEnum Error = Error_Failed;
+	if (NULL == videopath || NULL == strfilename) {
+		return Error;
+	}
+
+	record_item_t* item = new record_item_t();
+
+	item->file_path = videopath;
+
+	item->file_length = (int)ufilesize;
+
+	item->file_name = strfilename;
+	
+	m_vRecordList.push_back(*item);
+
+	Error = Error_Succeed;
+
+	return Error;
+}
+
+ErrorCodeEnum CSalesRecorderEntity::PostSalesRecordInfos()
+{
+	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_SalesVideoName + strlen(RVC_SALES_RECORD_SUFFIX);
+	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_SALESRECORD_INFO_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_SALESRECORD_INFO_FAILED, strErrorMsg.GetData());
+	}
+
+	m_vRecordList.clear();
+
+	return Error;
+}
+
+SelfChekerClient::SelfChekerClient( CSalesRecorderEntity *pEntity ) : SelfCheckerService_ClientBase(pEntity)
 {
 
 }

文件差异内容过多而无法显示
+ 169 - 389
Module/mod_SalesRecorder/win/mod_SalesRecorder.cpp


+ 1 - 3
Module/mod_counterconnector/http_callrouter.h

@@ -36,9 +36,7 @@ struct CallRouteHTTPReq : CHTTPReq {
 	std::string addClientLevel;
 
 	virtual string ToJson() {
-		char reqcontent[512] = {0};
-		snprintf(reqcontent, 512, "{\"queueName\":\"%s\",\"terminalNo\":\"%s\",\"addClientLevel\":\"%s\"}", queueName.c_str(), terminalNo.c_str(), addClientLevel.c_str());
-		return reqcontent;
+		return CSimpleStringA::Format("{\"queueName\":\"%s\",\"terminalNo\":\"%s\",\"addClientLevel\":\"%s\"}", queueName.c_str(), terminalNo.c_str(), addClientLevel.c_str()).GetData();
 	}
 };
 

+ 442 - 442
Module/mod_livenessdetection/RvcWsServer.cpp

@@ -11,7 +11,7 @@
 #include "y2k_time.h"
 
 
-namespace LivenessDetection{
+namespace LivenessDetection {
 
 #ifndef RVC_JPEG_QUALITY
 #define RVC_JPEG_QUALITY	100 //图片质量
@@ -42,579 +42,579 @@ namespace LivenessDetection{
 #endif
 
 
-static int rgb2jpg_action(struct jpeg_compress_struct* pCinfo, const unsigned char *pRgbData, const int width, const int height)
-{
-    int depth = RVC_COLOR_PEPTH;
-	JSAMPROW row_pointer[1] = {0};
- 
-    pCinfo->image_width      = width;
-    pCinfo->image_height     = height;
-    pCinfo->input_components = depth;
-    pCinfo->in_color_space   = JCS_RGB;
- 
-    jpeg_set_defaults(pCinfo); 
-    jpeg_set_quality(pCinfo, RVC_JPEG_QUALITY, true);
-    jpeg_start_compress(pCinfo, true);
- 
-    int row_stride = width * depth;
-    while (pCinfo->next_scanline < pCinfo->image_height){
-        row_pointer[0] = (JSAMPROW)(pRgbData + pCinfo->next_scanline * row_stride);
-        jpeg_write_scanlines(pCinfo, row_pointer, 1);
-    }
- 
-    jpeg_finish_compress(pCinfo);
-    jpeg_destroy_compress(pCinfo);
- 
-    return 0;
-}
-
-
-static int bgr2rgb(const unsigned char* bgr_image , const int image_width , const int image_height , unsigned char* rgb_image)
-{
-	if(!bgr_image || !rgb_image) {
-		return 1;
+	static int rgb2jpg_action(struct jpeg_compress_struct* pCinfo, const unsigned char* pRgbData, const int width, const int height)
+	{
+		int depth = RVC_COLOR_PEPTH;
+		JSAMPROW row_pointer[1] = { 0 };
+
+		pCinfo->image_width = width;
+		pCinfo->image_height = height;
+		pCinfo->input_components = depth;
+		pCinfo->in_color_space = JCS_RGB;
+
+		jpeg_set_defaults(pCinfo);
+		jpeg_set_quality(pCinfo, RVC_JPEG_QUALITY, true);
+		jpeg_start_compress(pCinfo, true);
+
+		int row_stride = width * depth;
+		while (pCinfo->next_scanline < pCinfo->image_height) {
+			row_pointer[0] = (JSAMPROW)(pRgbData + pCinfo->next_scanline * row_stride);
+			jpeg_write_scanlines(pCinfo, row_pointer, 1);
+		}
+
+		jpeg_finish_compress(pCinfo);
+		jpeg_destroy_compress(pCinfo);
+
+		return 0;
 	}
 
-	for(int i = 0; i < image_width * image_height; i++){
-		unsigned char b_value = *bgr_image++;
-		unsigned char g_value = *bgr_image++;
-		unsigned char r_value = *bgr_image++;
-		*rgb_image++ = r_value;
-		*rgb_image++ = g_value;
-		*rgb_image++ = b_value;
+
+	static int bgr2rgb(const unsigned char* bgr_image, const int image_width, const int image_height, unsigned char* rgb_image)
+	{
+		if (!bgr_image || !rgb_image) {
+			return 1;
+		}
+
+		for (int i = 0; i < image_width * image_height; i++) {
+			unsigned char b_value = *bgr_image++;
+			unsigned char g_value = *bgr_image++;
+			unsigned char r_value = *bgr_image++;
+			*rgb_image++ = r_value;
+			*rgb_image++ = g_value;
+			*rgb_image++ = b_value;
+		}
+		return 0;
 	}
-	return 0;
-}
 
 
-static int gbr2jpg(const unsigned char *pRgbData, const int width, const int height, char* pDest, unsigned long* pSize, int reverseFlag = 0)
-{
-    struct jpeg_compress_struct cinfo;
-    struct jpeg_error_mgr jerr;
- 
-    cinfo.err = jpeg_std_error(&jerr);
+	static int gbr2jpg(const unsigned char* pRgbData, const int width, const int height, char* pDest, unsigned long* pSize, int reverseFlag = 0)
+	{
+		struct jpeg_compress_struct cinfo;
+		struct jpeg_error_mgr jerr;
+
+		cinfo.err = jpeg_std_error(&jerr);
 
-    jpeg_create_compress(&cinfo);
+		jpeg_create_compress(&cinfo);
 
-	jpeg_mem_dest(&cinfo, (unsigned char**)&pDest, (unsigned long*)pSize);
+		jpeg_mem_dest(&cinfo, (unsigned char**)&pDest, (unsigned long*)pSize);
 
-	unsigned char* prgb = new unsigned char[width*height*3];
+		unsigned char* prgb = new unsigned char[width * height * 3];
 
-	bgr2rgb(pRgbData, width, height, prgb);
+		bgr2rgb(pRgbData, width, height, prgb);
 
 #if defined(RVC_OS_WIN)
-	rgb2jpg_action(&cinfo, prgb, width, height);
+		rgb2jpg_action(&cinfo, prgb, width, height);
 #else
-	unsigned char* reversePrgb = new unsigned char[width * height * 3];
+		unsigned char* reversePrgb = new unsigned char[width * height * 3];
 
-	if (reverseFlag == 0)
-	{
-		for (int i = 0; i < height; i++) {
-			memcpy(reversePrgb + (i * width * 3),
-				prgb + (3 * width * (height - (i + 1))), width * 3);
+		if (reverseFlag == 0)
+		{
+			for (int i = 0; i < height; i++) {
+				memcpy(reversePrgb + (i * width * 3),
+					prgb + (3 * width * (height - (i + 1))), width * 3);
+			}
 		}
-	} 
-	else if (reverseFlag == 1)
-	{
-		for (int i = 0; i < height; i++) {
-			for (int j = 0; j < width; j++) {
-				memcpy(reversePrgb + (3 * ((width * i) + j)),
-					prgb + (3 * ((width * i) + (width - (j + 1)))), 3);
+		else if (reverseFlag == 1)
+		{
+			for (int i = 0; i < height; i++) {
+				for (int j = 0; j < width; j++) {
+					memcpy(reversePrgb + (3 * ((width * i) + j)),
+						prgb + (3 * ((width * i) + (width - (j + 1)))), 3);
+				}
 			}
 		}
-	}
 
-	rgb2jpg_action(&cinfo, reversePrgb, width, height);
+		rgb2jpg_action(&cinfo, reversePrgb, width, height);
 
-	delete reversePrgb;
-	reversePrgb = NULL;
+		delete reversePrgb;
+		reversePrgb = NULL;
 #endif //RVC_OS_WIN
 
-	delete prgb;
-	prgb = NULL;
+		delete prgb;
+		prgb = NULL;
 
-    return 0;
-}
+		return 0;
+	}
 
-static int on_send(RvcWsServer *webserver, eVideoType eType)
-{
-	int iwidth = 0;
-	int iheight = 0;
+	static int on_send(RvcWsServer* webserver, eVideoType eType)
+	{
+		int iwidth = 0;
+		int iheight = 0;
 
-	int isize = 0;
-	if (webserver->m_callback.on_get_videodata){
-		if (ePreview_Type == eType){
-			isize = webserver->m_callback.on_get_videodata(ePreview_Type, webserver->m_ecameraid, &iwidth, &iheight, webserver->m_buffer, webserver->m_ubuffer_size, webserver->m_callback.user_data);
-		}
-		else{
-			isize = webserver->m_callback.on_get_videodata(eCapture_Type, webserver->m_ecameraid, &iwidth, &iheight, webserver->m_capbuffer, webserver->m_ucapbuffer_size, webserver->m_callback.user_data);
-		}
-		
-		if (isize > 0){
-			char pDest[RVC_MAX_JPEG_SIZE] = {0};
-			unsigned long  size = RVC_MAX_JPEG_SIZE;
-			if (ePreview_Type == eType){
-				pDest[0] = 0x01;
+		int isize = 0;
+		if (webserver->m_callback.on_get_videodata) {
+			if (ePreview_Type == eType) {
+				isize = webserver->m_callback.on_get_videodata(ePreview_Type, webserver->m_ecameraid, &iwidth, &iheight, webserver->m_buffer, webserver->m_ubuffer_size, webserver->m_callback.user_data);
+			}
+			else {
+				isize = webserver->m_callback.on_get_videodata(eCapture_Type, webserver->m_ecameraid, &iwidth, &iheight, webserver->m_capbuffer, webserver->m_ucapbuffer_size, webserver->m_callback.user_data);
+			}
+
+			if (isize > 0) {
+				char pDest[RVC_MAX_JPEG_SIZE] = { 0 };
+				unsigned long  size = RVC_MAX_JPEG_SIZE;
+				if (ePreview_Type == eType) {
+					pDest[0] = 0x01;
 #if defined(RVC_OS_WIN)
-				gbr2jpg(webserver->m_buffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size);
+					gbr2jpg(webserver->m_buffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size);
 #else
-				if (webserver->m_ecameraid == 0) 
-				{
-					gbr2jpg(webserver->m_buffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size, 0);
-				} 
-				else if (webserver->m_ecameraid == 1)
-				{
-					gbr2jpg(webserver->m_buffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size, 1); 
-				}
+					if (webserver->m_ecameraid == 0)
+					{
+						gbr2jpg(webserver->m_buffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size, 0);
+					}
+					else if (webserver->m_ecameraid == 1)
+					{
+						gbr2jpg(webserver->m_buffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size, 1);
+					}
 #endif //RVC_OS_WIN
 
-			}
-			else{
-				pDest[0] = 0x02;
-				gbr2jpg(webserver->m_capbuffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size); 
-			}
+				}
+				else {
+					pDest[0] = 0x02;
+					gbr2jpg(webserver->m_capbuffer, iwidth, iheight, pDest + RVC_PICTURE_TYPE_LEN, &size);
+				}
 
-			if (webserver->m_bconnected && webserver->m_bstarttrans){
-				if (false == webserver->m_hdl.expired()){
-					webserver->m_wsserver.send(webserver->m_hdl, (const void*)pDest, size + RVC_PICTURE_TYPE_LEN, websocketpp::frame::opcode::value::binary);
-					//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send picture size is %u.", size+1);
+				if (webserver->m_bconnected && webserver->m_bstarttrans) {
+					if (false == webserver->m_hdl.expired()) {
+						webserver->m_wsserver.send(webserver->m_hdl, (const void*)pDest, size + RVC_PICTURE_TYPE_LEN, websocketpp::frame::opcode::value::binary);
+						//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send picture size is %u.", size+1);
+					}
 				}
 			}
 		}
+
+		return 0;
 	}
-	
-	return 0;
-}
 
 
-static void process(RvcWsServer *webserver)
-{
-	while (webserver->m_bconnected && webserver->m_bstarttrans) 
+	static void process(RvcWsServer* webserver)
 	{
+		while (webserver->m_bconnected && webserver->m_bstarttrans)
+		{
 #ifdef RVC_OS_WIN
-		DWORD dwRet = WaitForSingleObject(webserver->m_evt, 1000 / webserver->m_fps);
-		if (dwRet == WAIT_OBJECT_0) {
-			break;
-		}
-		else if (dwRet == WAIT_TIMEOUT) {
-			if (webserver->m_bconnected && webserver->m_bstarttrans) {
-				on_send(webserver, ePreview_Type);
+			DWORD dwRet = WaitForSingleObject(webserver->m_evt, 1000 / webserver->m_fps);
+			if (dwRet == WAIT_OBJECT_0) {
+				break;
+			}
+			else if (dwRet == WAIT_TIMEOUT) {
+				if (webserver->m_bconnected && webserver->m_bstarttrans) {
+					on_send(webserver, ePreview_Type);
+				}
 			}
-		}
 #else
-		struct timespec ts;
-		clock_gettime(CLOCK_REALTIME, &ts);
-		long unsec = ts.tv_nsec + (1000 * 1000 * (1000 / webserver->m_fps));
-		ts.tv_sec += (unsec / 1000000000);
-		ts.tv_nsec = (unsec % 1000000000);
-
-		if (0 != sem_timedwait(&webserver->m_semt, &ts) && (ETIMEDOUT == errno)) {
-			if (webserver->m_bconnected && webserver->m_bstarttrans) {
-				on_send(webserver, ePreview_Type);
+			struct timespec ts;
+			clock_gettime(CLOCK_REALTIME, &ts);
+			long unsec = ts.tv_nsec + (1000 * 1000 * (1000 / webserver->m_fps));
+			ts.tv_sec += (unsec / 1000000000);
+			ts.tv_nsec = (unsec % 1000000000);
+
+			if (0 != sem_timedwait(&webserver->m_semt, &ts) && (ETIMEDOUT == errno)) {
+				if (webserver->m_bconnected && webserver->m_bstarttrans) {
+					on_send(webserver, ePreview_Type);
+				}
+			}
+			else
+			{
+				break;
 			}
-		} 
-		else 
-		{
-			break;
-		} 
 #endif // RVC_OS_WIN
-	}	
-	webserver->m_bstarttrans = false;
-}
+		}
+		webserver->m_bstarttrans = false;
+	}
 
 
 #if defined(RVC_OS_WIN)
-static unsigned int __stdcall work_proc(void* arg)
+	static unsigned int __stdcall work_proc(void* arg)
 #else
-static void* work_proc(void* arg)
+	static void* work_proc(void* arg)
 #endif //RVC_OS_WIN
-{
-	RvcWsServer *webserver = (RvcWsServer *)arg;
+	{
+		RvcWsServer* webserver = (RvcWsServer*)arg;
 
-	process(webserver);
+		process(webserver);
 
-	return 0;
-}
+		return 0;
+	}
 
 
-RvcWsServer::RvcWsServer(void):m_wsserver()
-{
-	m_bconnected = false;
-	m_struuid = "";
-	m_bstarttrans = false;
-#if defined(RVC_OS_WIN)
-	m_work_thread = NULL;
-#else
-	m_work_threadid = 0;
-#endif //RVC_OS_WIN
-	m_cameraid = 0;
-	m_fps = RVC_DEFAULT_FPS;
-	m_buffer = NULL;
-	m_ubuffer_size = 0;
-	m_capbuffer = NULL;
-	m_ucapbuffer_size = 0;
-	m_ecameraid = eCamera_Env;
-}
-
-
-RvcWsServer::~RvcWsServer(void)
-{
-	m_bconnected = false;
-	m_struuid = "";
-	m_bstarttrans = false;
+	RvcWsServer::RvcWsServer(void) :m_wsserver()
+	{
+		m_bconnected = false;
+		m_struuid = "";
+		m_bstarttrans = false;
 #if defined(RVC_OS_WIN)
-	m_work_thread = NULL;
+		m_work_thread = NULL;
 #else
-	m_work_threadid = 0;
+		m_work_threadid = 0;
 #endif //RVC_OS_WIN
-	m_cameraid = 0;
-	m_fps = RVC_DEFAULT_FPS; 
-	if (NULL != m_buffer){
-		delete m_buffer;
+		m_cameraid = 0;
+		m_fps = RVC_DEFAULT_FPS;
 		m_buffer = NULL;
-	}
-	m_ubuffer_size = 0;
-
-	if (NULL != m_capbuffer){
-		delete m_capbuffer;
+		m_ubuffer_size = 0;
 		m_capbuffer = NULL;
+		m_ucapbuffer_size = 0;
+		m_ecameraid = eCamera_Env;
 	}
-	m_ucapbuffer_size = 0;
-}
 
 
-void on_socket_init(websocketpp::connection_hdl hdl, boost::asio::ip::tcp::socket& s) 
-{
-	boost::asio::ip::tcp::no_delay option(true);
-	s.set_option(option);
-}
+	RvcWsServer::~RvcWsServer(void)
+	{
+		m_bconnected = false;
+		m_struuid = "";
+		m_bstarttrans = false;
+#if defined(RVC_OS_WIN)
+		m_work_thread = NULL;
+#else
+		m_work_threadid = 0;
+#endif //RVC_OS_WIN
+		m_cameraid = 0;
+		m_fps = RVC_DEFAULT_FPS;
+		if (NULL != m_buffer) {
+			delete m_buffer;
+			m_buffer = NULL;
+		}
+		m_ubuffer_size = 0;
 
-int RvcWsServer::Init_WsServer(websocket_callback_t* pcallback, rvc_video_param_t* pparam, int iport)
-{
-	int iret = -1;
-	if (NULL == pcallback){
-		return iret;
+		if (NULL != m_capbuffer) {
+			delete m_capbuffer;
+			m_capbuffer = NULL;
+		}
+		m_ucapbuffer_size = 0;
 	}
 
-	if (iport <= 0){
-		m_listenport = RVC_LIVENESS_WS_PORT;
-	}
-	else{
-		m_listenport = iport;
+
+	void on_socket_init(websocketpp::connection_hdl hdl, boost::asio::ip::tcp::socket& s)
+	{
+		boost::asio::ip::tcp::no_delay option(true);
+		s.set_option(option);
 	}
 
-	m_cameraid = 0;
-	m_fps = RVC_DEFAULT_FPS;
-	memcpy(&m_callback, pcallback, sizeof(websocket_callback_t));
-	
+	int RvcWsServer::Init_WsServer(websocket_callback_t* pcallback, rvc_video_param_t* pparam, int iport)
+	{
+		int iret = -1;
+		if (NULL == pcallback) {
+			return iret;
+		}
+
+		if (iport <= 0) {
+			m_listenport = RVC_LIVENESS_WS_PORT;
+		}
+		else {
+			m_listenport = iport;
+		}
+
+		m_cameraid = 0;
+		m_fps = RVC_DEFAULT_FPS;
+		memcpy(&m_callback, pcallback, sizeof(websocket_callback_t));
+
 #ifdef _MSC_VER
-	m_evt = CreateEventA(NULL, FALSE, FALSE, NULL); 
+		m_evt = CreateEventA(NULL, FALSE, FALSE, NULL);
 #else
-	sem_init(&m_semt, 0, 0);
+		sem_init(&m_semt, 0, 0);
 #endif //_MSC_VER
 
-	m_ubuffer_size = pparam->iwidth*pparam->iheight*3;
-	m_buffer = new unsigned char[m_ubuffer_size];
-	memset(m_buffer, 0, m_ubuffer_size);
+		m_ubuffer_size = pparam->iwidth * pparam->iheight * 3;
+		m_buffer = new unsigned char[m_ubuffer_size];
+		memset(m_buffer, 0, m_ubuffer_size);
 
-	m_ucapbuffer_size = pparam->icapwidth*pparam->icapheight*3;
-	m_capbuffer = new unsigned char[m_ucapbuffer_size];
-	memset(m_capbuffer, 0, m_ucapbuffer_size);
+		m_ucapbuffer_size = pparam->icapwidth * pparam->icapheight * 3;
+		m_capbuffer = new unsigned char[m_ucapbuffer_size];
+		memset(m_capbuffer, 0, m_ucapbuffer_size);
 
-	m_ecameraid = eCamera_Env;
+		m_ecameraid = eCamera_Env;
 
-	try {
-		// Set logging settings
-		m_wsserver.set_access_channels(websocketpp::log::alevel::all);
-		m_wsserver.set_error_channels(websocketpp::log::elevel::all);
+		try {
+			// Set logging settings
+			m_wsserver.set_access_channels(websocketpp::log::alevel::all);
+			m_wsserver.set_error_channels(websocketpp::log::elevel::all);
 
-		// Register our message handler
-		m_wsserver.set_message_handler(websocketpp::lib::bind(&RvcWsServer::on_message, this, websocketpp::lib::placeholders::_1, websocketpp::lib::placeholders::_2));
-		m_wsserver.set_http_handler(websocketpp::lib::bind(&RvcWsServer::on_http, this, websocketpp::lib::placeholders::_1));
-		m_wsserver.set_fail_handler(websocketpp::lib::bind(&RvcWsServer::on_fail, this, websocketpp::lib::placeholders::_1));
-		m_wsserver.set_open_handler(websocketpp::lib::bind(&RvcWsServer::on_open, this, websocketpp::lib::placeholders::_1));
-		m_wsserver.set_close_handler(websocketpp::lib::bind(&RvcWsServer::on_close, this, websocketpp::lib::placeholders::_1));
-		m_wsserver.set_validate_handler(websocketpp::lib::bind(&RvcWsServer::validate, this, websocketpp::lib::placeholders::_1));
+			// Register our message handler
+			m_wsserver.set_message_handler(websocketpp::lib::bind(&RvcWsServer::on_message, this, websocketpp::lib::placeholders::_1, websocketpp::lib::placeholders::_2));
+			m_wsserver.set_http_handler(websocketpp::lib::bind(&RvcWsServer::on_http, this, websocketpp::lib::placeholders::_1));
+			m_wsserver.set_fail_handler(websocketpp::lib::bind(&RvcWsServer::on_fail, this, websocketpp::lib::placeholders::_1));
+			m_wsserver.set_open_handler(websocketpp::lib::bind(&RvcWsServer::on_open, this, websocketpp::lib::placeholders::_1));
+			m_wsserver.set_close_handler(websocketpp::lib::bind(&RvcWsServer::on_close, this, websocketpp::lib::placeholders::_1));
+			m_wsserver.set_validate_handler(websocketpp::lib::bind(&RvcWsServer::validate, this, websocketpp::lib::placeholders::_1));
 
-		// Initialize ASIO
-		m_wsserver.init_asio();
-		m_wsserver.set_reuse_addr(true);
-		m_wsserver.set_socket_init_handler(&on_socket_init);
+			// Initialize ASIO
+			m_wsserver.init_asio();
+			m_wsserver.set_reuse_addr(true);
+			m_wsserver.set_socket_init_handler(&on_socket_init);
 
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_max_message_size is %d.", m_wsserver.get_max_message_size());
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_max_http_body_size is %d.", m_wsserver.get_max_http_body_size());
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_max_message_size is %d.", m_wsserver.get_max_message_size());
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get_max_http_body_size is %d.", m_wsserver.get_max_http_body_size());
 
-		m_wsserver.listen(m_listenport);
-		// Start the server accept loop
-		m_wsserver.start_accept();
+			m_wsserver.listen(m_listenport);
+			// Start the server accept loop
+			m_wsserver.start_accept();
 
-		iret = 0;
+			iret = 0;
 
-		// Start the ASIO io_service run loop
-		m_wsserver.run();
+			// Start the ASIO io_service run loop
+			m_wsserver.run();
 
-		//stop
-		m_wsserver.stop();
+			//stop
+			m_wsserver.stop();
+		}
+		catch (websocketpp::exception const& e) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(e.what());
+		}
+		catch (const std::exception& e) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(e.what());
+		}
+		catch (...) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("other exception");
+		}
+
+		return iret;
 	}
-	catch (websocketpp::exception const & e) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(e.what());
+
+
+	bool RvcWsServer::validate(websocketpp::connection_hdl hdl)
+	{
+		return true;
 	}
-	catch (const std::exception & e) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(e.what());
+
+
+	void RvcWsServer::on_http(websocketpp::connection_hdl hdl)
+	{
+		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("on_http");
+		server::connection_ptr con = m_wsserver.get_con_from_hdl(hdl);
+		std::string res = con->get_request_body();
+		std::stringstream ss;
+		ss << "got HTTP request with " << res.size() << " bytes of body data.";
+		con->set_body(ss.str());
+		con->set_status(websocketpp::http::status_code::ok);
 	}
-	catch (...) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("other exception");
+
+
+	void RvcWsServer::on_fail(websocketpp::connection_hdl hdl)
+	{
+		server::connection_ptr con = m_wsserver.get_con_from_hdl(hdl);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fail handler: %d, %s.", con->get_ec().value(), con->get_ec().message());
 	}
 
-	return iret;
-}
-
-
-bool RvcWsServer::validate(websocketpp::connection_hdl hdl) 
-{
-	return true;
-}
- 
-
-void RvcWsServer::on_http(websocketpp::connection_hdl hdl) 
-{
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("on_http");
-	server::connection_ptr con = m_wsserver.get_con_from_hdl(hdl);
-	std::string res = con->get_request_body();
-	std::stringstream ss;
-	ss << "got HTTP request with " << res.size() << " bytes of body data.";
-	con->set_body(ss.str());
-	con->set_status(websocketpp::http::status_code::ok);
-}
- 
-
-void RvcWsServer::on_fail(websocketpp::connection_hdl hdl) 
-{
-	server::connection_ptr con = m_wsserver.get_con_from_hdl(hdl);
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("fail handler: %d, %s." , con->get_ec().value(), con->get_ec().message());
-}
- 
-
-void RvcWsServer::on_open(websocketpp::connection_hdl hdl)
-{
-	server::connection_ptr con = m_wsserver.get_con_from_hdl(hdl);
-	websocketpp::config::core::request_type requestClient = con->get_request();
-	std::string strMethod = requestClient.get_method();		
-	std::string strUri = requestClient.get_uri();			
-}
- 
-
-void RvcWsServer::on_close(websocketpp::connection_hdl hdl) 
-{
-	m_bconnected = false;
-	if (m_bstarttrans){
-		m_bstarttrans = false;
 
-		unsigned int utranstime = y2k_time_now() - m_utranstime;
-		LogWarn(Severity_Low, Error_Debug, LOG_EVT_STOPVIDEOTRANS, CSimpleStringA::Format("stop video trans for session close, and transmit time is %us.", utranstime).GetData());
+	void RvcWsServer::on_open(websocketpp::connection_hdl hdl)
+	{
+		server::connection_ptr con = m_wsserver.get_con_from_hdl(hdl);
+		websocketpp::config::core::request_type requestClient = con->get_request();
+		std::string strMethod = requestClient.get_method();
+		std::string strUri = requestClient.get_uri();
+	}
 
-		if (RVC_MIN_VIDEO_TRANS_TIME >= utranstime) {
-			LogWarn(Severity_Middle, Error_Debug, LOG_EVT_AUTO_FACE_FAILED, CSimpleStringA::Format("auto face failed and transmit time is %us.", utranstime).GetData());
-		}
 
-		if (RVC_MAX_VIDEO_TRANS_TIME <= utranstime) {
-			LogWarn(Severity_Low, Error_Debug, LOG_EVT_AUTO_FACE_TIMEOUT, CSimpleStringA::Format("auto face timeout and transmit time is %us.", utranstime).GetData());
+	void RvcWsServer::on_close(websocketpp::connection_hdl hdl)
+	{
+		m_bconnected = false;
+		if (m_bstarttrans) {
+			m_bstarttrans = false;
+
+			unsigned int utranstime = y2k_time_now() - m_utranstime;
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_STOPVIDEOTRANS, CSimpleStringA::Format("stop video trans for session close, and transmit time is %us.", utranstime).GetData());
+
+			if (RVC_MIN_VIDEO_TRANS_TIME >= utranstime) {
+				LogWarn(Severity_Middle, Error_Debug, LOG_EVT_AUTO_FACE_FAILED, CSimpleStringA::Format("auto face failed and transmit time is %us.", utranstime).GetData());
+			}
+
+			if (RVC_MAX_VIDEO_TRANS_TIME <= utranstime) {
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_AUTO_FACE_TIMEOUT, CSimpleStringA::Format("auto face timeout and transmit time is %us.", utranstime).GetData());
+			}
 		}
 	}
-}
- 
-
-// Define a callback to handle incoming messages
-void RvcWsServer::on_message(websocketpp::connection_hdl hdl, server::message_ptr msg) 
-{ 
-	try {
-
-		if (m_bconnected == false){	
-			m_struuid = "";
-			if (0 == msg->get_payload().compare(0, strlen(RVC_WS_INIT_STR), RVC_WS_INIT_STR)){
-				handle_initial_instructions(hdl, msg->get_payload());
+
+
+	// Define a callback to handle incoming messages
+	void RvcWsServer::on_message(websocketpp::connection_hdl hdl, server::message_ptr msg)
+	{
+		try {
+
+			if (m_bconnected == false) {
+				m_struuid = "";
+				if (0 == msg->get_payload().compare(0, strlen(RVC_WS_INIT_STR), RVC_WS_INIT_STR)) {
+					handle_initial_instructions(hdl, msg->get_payload());
+				}
 			}
-		}
-		else{
-			if (0 == msg->get_payload().compare(0, m_struuid.length(), m_struuid)){
-				if (0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_START_TRANS_STR), RVC_WS_START_TRANS_STR)){
-					m_bstarttrans = true;
-					m_hdl = hdl;
-					if (0 != StartVideoTransmit()){
-						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video transmit failed.");
+			else {
+				if (0 == msg->get_payload().compare(0, m_struuid.length(), m_struuid)) {
+					if (0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_START_TRANS_STR), RVC_WS_START_TRANS_STR)) {
+						m_bstarttrans = true;
+						m_hdl = hdl;
+						if (0 != StartVideoTransmit()) {
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video transmit failed.");
+						}
+					}
+					else if (0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_STOP_TRANS_STR), RVC_WS_STOP_TRANS_STR)) {
+						StopVideoTransmit();
+						m_bstarttrans = false;
+					}
+					else if (0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_CHANGE_CAMERA_STR), RVC_WS_CHANGE_CAMERA_STR)) {
+						handle_change_camera_instructions(msg->get_payload());
+					}
+					else if (0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_START_CAPTURE_STR), RVC_WS_START_CAPTURE_STR)) {
+						StartVideoCapTransmit();
+					}
+					else
+					{
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown request.");
 					}
 				}
-				else if(0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_STOP_TRANS_STR), RVC_WS_STOP_TRANS_STR)){
-					StopVideoTransmit();
-					m_bstarttrans = false;
-				}
-				else if (0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_CHANGE_CAMERA_STR), RVC_WS_CHANGE_CAMERA_STR)){
-					handle_change_camera_instructions(msg->get_payload());
-				}
-				else if(0 == msg->get_payload().compare(m_struuid.length() + strlen(RVC_WS_CONNECT_IDENTIFIER), strlen(RVC_WS_START_CAPTURE_STR), RVC_WS_START_CAPTURE_STR)){
-					StartVideoCapTransmit();
-				}
-				else
-				{
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown request.");
+				else {
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv invalid request is %s.", msg->get_payload().c_str());
 				}
 			}
-			else{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv invalid request is %s.", msg->get_payload().c_str()); 
-			}
+		}
+		catch (websocketpp::exception const& e) {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send failed because: %s", e.what());
 		}
 	}
-	catch (websocketpp::exception const & e) {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send failed because: %s", e.what()); 
-	}
-}
 
 
-int RvcWsServer::StartVideoTransmit()
-{
-	int iRet = -1;
+	int RvcWsServer::StartVideoTransmit()
+	{
+		int iRet = -1;
 
 #if defined(RVC_OS_WIN)
-	m_work_thread = (HANDLE)_beginthreadex(NULL, 0, &work_proc, this, 0, NULL);
-	if (!m_work_thread)
+		m_work_thread = (HANDLE)_beginthreadex(NULL, 0, &work_proc, this, 0, NULL);
+		if (!m_work_thread) {
 #else
-	if (0 != pthread_create(&m_work_threadid, NULL, work_proc, (void*)this)) {
+		if (0 != pthread_create(&m_work_threadid, NULL, work_proc, (void*)this)) {
 #endif //RVC_OS_WIN
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create start video transmit thread failed.");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create start video transmit thread failed.");
+			return iRet;
+		}
+
+		iRet = 0;
+		LogWarn(Severity_Low, Error_Debug, LOG_EVT_STARTVIDEOTRANS, "start video trans.");
+		m_utranstime = y2k_time_now();
+
 		return iRet;
 	}
-	
-	iRet = 0;
-	LogWarn(Severity_Low, Error_Debug, LOG_EVT_STARTVIDEOTRANS, "start video trans.");
-	m_utranstime = y2k_time_now();
-
-	return iRet;
-}
 
 
-int RvcWsServer::StopVideoTransmit()
-{
-	int iRet = -1;
+	int RvcWsServer::StopVideoTransmit()
+	{
+		int iRet = -1;
 
-	if (m_bconnected && m_bstarttrans) {
+		if (m_bconnected && m_bstarttrans) {
 #if defined(RVC_OS_WIN)
-		SetEvent(m_evt);
+			SetEvent(m_evt);
 
-		if (NULL != m_work_thread) {
-			WaitForSingleObject(m_work_thread, INFINITE);
-			CloseHandle(m_work_thread);
-			m_work_thread = NULL;
-		}
+			if (NULL != m_work_thread) {
+				WaitForSingleObject(m_work_thread, INFINITE);
+				CloseHandle(m_work_thread);
+				m_work_thread = NULL;
+			}
 #else
-		sem_post(&m_semt);
+			sem_post(&m_semt);
 
-		if (0 == pthread_join(m_work_threadid, NULL)) {
-			m_work_threadid = 0;
-		} else {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("thread join video transmit thread failed!");
-		}
+			if (0 == pthread_join(m_work_threadid, NULL)) {
+				m_work_threadid = 0;
+			}
+			else {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("thread join video transmit thread failed!");
+			}
 #endif //RVC_OS_WIN
 
-		unsigned int utranstime = y2k_time_now() - m_utranstime;
-		LogWarn(Severity_Low, Error_Debug, LOG_EVT_STOPVIDEOTRANS, CSimpleStringA::Format("stop video trans for user operation, and transmit time is %us.", utranstime).GetData());
+			unsigned int utranstime = y2k_time_now() - m_utranstime;
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_STOPVIDEOTRANS, CSimpleStringA::Format("stop video trans for user operation, and transmit time is %us.", utranstime).GetData());
 
-		if (RVC_MIN_VIDEO_TRANS_TIME >= utranstime) {
-			LogWarn(Severity_Middle, Error_Debug, LOG_EVT_AUTO_FACE_FAILED, CSimpleStringA::Format("auto face failed and transmit time is %us.", utranstime).GetData());
-		}
+			if (RVC_MIN_VIDEO_TRANS_TIME >= utranstime) {
+				LogWarn(Severity_Middle, Error_Debug, LOG_EVT_AUTO_FACE_FAILED, CSimpleStringA::Format("auto face failed and transmit time is %us.", utranstime).GetData());
+			}
 
-		if (RVC_MAX_VIDEO_TRANS_TIME <= utranstime) {
-			LogWarn(Severity_Low, Error_Debug, LOG_EVT_AUTO_FACE_TIMEOUT, CSimpleStringA::Format("auto face timeout and transmit time is %us.", utranstime).GetData());
+			if (RVC_MAX_VIDEO_TRANS_TIME <= utranstime) {
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_AUTO_FACE_TIMEOUT, CSimpleStringA::Format("auto face timeout and transmit time is %us.", utranstime).GetData());
+			}
+
+			iRet = 0;
 		}
 
-		iRet = 0;
+		return iRet;
 	}
 
-	return iRet;
-}
-
 
-int RvcWsServer::StartVideoCapTransmit()
-{
-	LogWarn(Severity_Low, Error_Debug, LOG_EVT_STARTVIDEOCAPTURE, "start video capture transmit.");
-	return on_send(this, eCapture_Type);
-}
+	int RvcWsServer::StartVideoCapTransmit()
+	{
+		LogWarn(Severity_Low, Error_Debug, LOG_EVT_STARTVIDEOCAPTURE, "start video capture transmit.");
+		return on_send(this, eCapture_Type);
+	}
 
 
-static bool allisnum(std::string str)  
-{
-	for (int i = 0; i < str.size(); i++){
-		int tmp = (int)str[i];
-		if (tmp >= '0' && tmp <= '9'){
-			continue;
-		}
-		else
-		{
-			return false;
-		}
-	} 
-	return true;
-}  
-
-
-int RvcWsServer::handle_initial_instructions(websocketpp::connection_hdl hdl, std::string strinstrut)
-{
-	int iret = -1;
-
-	m_bconnected = true;
-	m_ecameraid = eCamera_Env;
-	CUUID struuid = CUUID::Create(struuid);
-	m_struuid = struuid.ToString();
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("new connect and uuid is %s.", m_struuid.c_str()); 
-	m_wsserver.send(hdl, m_struuid,  websocketpp::frame::opcode::value::text);
-
-	int index = strinstrut.find_first_of(RVC_WS_CONNECT_IDENTIFIER);
-	if (std::string::npos != index){
-		std::string strfps = strinstrut.substr(index + strlen(RVC_WS_CONNECT_IDENTIFIER));
-		if (allisnum(strfps)){
-			int ifps = atoi(strfps.c_str());
-			if (ifps > RVC_MAX_FPS){
-				ifps = RVC_MAX_FPS;
+	static bool allisnum(std::string str)
+	{
+		for (int i = 0; i < str.size(); i++) {
+			int tmp = (int)str[i];
+			if (tmp >= '0' && tmp <= '9') {
+				continue;
 			}
-			if (ifps < RVC_MIN_FPS){
-				ifps = RVC_MIN_FPS;
+			else
+			{
+				return false;
 			}
-			m_fps = ifps;
 		}
+		return true;
 	}
 
-	iret = 0;
 
-	return iret;
-}
+	int RvcWsServer::handle_initial_instructions(websocketpp::connection_hdl hdl, std::string strinstrut)
+	{
+		int iret = -1;
+
+		m_bconnected = true;
+		m_ecameraid = eCamera_Env;
+		CUUID struuid = CUUID::Create(struuid);
+		m_struuid = struuid.ToString();
+		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("new connect and uuid is %s.", m_struuid.c_str()); 
+		m_wsserver.send(hdl, m_struuid, websocketpp::frame::opcode::value::text);
+
+		int index = strinstrut.find_first_of(RVC_WS_CONNECT_IDENTIFIER);
+		if (std::string::npos != index) {
+			std::string strfps = strinstrut.substr(index + strlen(RVC_WS_CONNECT_IDENTIFIER));
+			if (allisnum(strfps)) {
+				int ifps = atoi(strfps.c_str());
+				if (ifps > RVC_MAX_FPS) {
+					ifps = RVC_MAX_FPS;
+				}
+				if (ifps < RVC_MIN_FPS) {
+					ifps = RVC_MIN_FPS;
+				}
+				m_fps = ifps;
+			}
+		}
 
+		iret = 0;
 
-int RvcWsServer::handle_change_camera_instructions(std::string strinstrut)
-{
-	int iret = -1;
+		return iret;
+	}
 
-	if (m_bstarttrans){
-		int index = strinstrut.find_first_of(RVC_WS_CHANGE_CAMERA_STR);
-		if (std::string::npos != index){
-			std::string strcamera = strinstrut.substr(index + strlen(RVC_WS_CHANGE_CAMERA_STR));
-			index = strcamera.find_first_of(RVC_WS_CONNECT_IDENTIFIER);
-			if (std::string::npos != index){
-				std::string strid = strcamera.substr(index + strlen(RVC_WS_CONNECT_IDENTIFIER));
-				if (allisnum(strid)){
-					int icameraid = atoi(strid.c_str());
-					if (eCamera_Env == icameraid || eCamera_Opt == icameraid){
-						m_ecameraid = (eCameraType)icameraid;
+
+	int RvcWsServer::handle_change_camera_instructions(std::string strinstrut)
+	{
+		int iret = -1;
+
+		if (m_bstarttrans) {
+			int index = strinstrut.find_first_of(RVC_WS_CHANGE_CAMERA_STR);
+			if (std::string::npos != index) {
+				std::string strcamera = strinstrut.substr(index + strlen(RVC_WS_CHANGE_CAMERA_STR));
+				index = strcamera.find_first_of(RVC_WS_CONNECT_IDENTIFIER);
+				if (std::string::npos != index) {
+					std::string strid = strcamera.substr(index + strlen(RVC_WS_CONNECT_IDENTIFIER));
+					if (allisnum(strid)) {
+						int icameraid = atoi(strid.c_str());
+						if (eCamera_Env == icameraid || eCamera_Opt == icameraid) {
+							m_ecameraid = (eCameraType)icameraid;
+						}
 					}
 				}
 			}
+
+			iret = 0;
+		}
+		else {
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("current is not in data transmitting.");
 		}
 
-		iret = 0;
-	}
-	else{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("current is not in data transmitting."); 
+		return iret;
 	}
-
-	return iret;
-}
-
 }

+ 2 - 20
Module/mod_livenessdetection/win/mod_livenessdetection.cpp

@@ -82,11 +82,7 @@ static unsigned int __stdcall start_wsserver(void *arg)
 
 void CLivenessDetectionEntity::OnStarted()
 {
-	LOG_FUNCTION();
-	if (Error_Succeed == GetEntityConfigure()){
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[LivenessDetectionFSM] Get Entity Configure Success!");
-	}
-	else{
+	if (Error_Succeed != GetEntityConfigure()){
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[LivenessDetectionFSM] Get Entity Configure Failed!");
 	}
 
@@ -119,14 +115,8 @@ ErrorCodeEnum CLivenessDetectionEntity::__OnStart(ErrorCodeEnum preOperationErro
 	{		
 		if (stricmp(stStaticinfo.strSite,"CMB.FLB")==0)
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is mobile pad");
 			m_eDeviceType = eMobilePadType;
 		}
-		else
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("the type is pad");
-			m_eDeviceType = ePadtype;
-		}
 	}
 	else if (stricmp(stStaticinfo.strMachineType,"RPM.Stand1S")==0) 
 	{
@@ -225,21 +215,18 @@ void CLivenessDetectionEntity::Debug( const char *fmt, ... )
 
 int CLivenessDetectionEntity::GetActiveCamera()
 {
-	//Debug("get camera = %d",nActiveCamera);
 	return nActiveCamera;
 }
 
 void CLivenessDetectionEntity::OnLog( const CAutoArray<CUUID> &SubIDs, const CUUID nLogID,const LogTypeEnum eLogType, const SeverityLevelEnum eLevel, 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)("[dbg] dwUserCode=0x%08x", dwUserCode);
-
+	
 }
 
 void CLivenessDetectionEntity::OnSysVarEvent( const char *pszKey, const char *pszValue,const char *pszOldValue,const char *pszEntityName )
 {
 	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')
 		{
@@ -252,8 +239,6 @@ void CLivenessDetectionEntity::OnSysVarEvent( const char *pszKey, const char *ps
 		else if(pszValue[0] == 'B')   ///////显示贴图
 		{
 			nActiveCamera = CAMERA_TYPE_ERROR;
-			//m_pFsm->NotifyCameraFault();      // 摄像头故障,停止捕获
-			//m_pCapturer->NotifyCameraFault(); // 摄像头故障,停止捕获
 		}
 		else if (pszValue[0] == 'N')
 		{
@@ -352,10 +337,7 @@ ErrorCodeEnum CLivenessDetectionEntity::GetEntityConfigure()
 
 	SpIniMappingTable table;
 	table.AddEntryInt("LivenessDetection","WsServerPort", m_iWsPort, RVC_LIVENESS_WS_PORT);
-	//table.AddEntryInt("MediaController", "VideoCapFrameType", m_iCapType, 0);
 	eErrDev = table.Load(spConfig);
-	
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("center setting web socket port is %d, and video cap type is %d.", m_iWsPort, m_iCapType);
 
 	return eErrDev;
 }

+ 1 - 4
Module/mod_mediacontroller/capture.h

@@ -186,16 +186,13 @@ namespace MediaController {
 	void capture_enum_cameras(CAutoArray<CSimpleStringA>& cams);
 #endif //RVC_OS_WIN
 	int capture_detect_camera_bug(capture_t *cap, int *env_n, int *opt_n,BOOL IsPad);
-	int capture_get_last_frametime(capture_t *cap,  DWORD *env_n,  DWORD *opt_n,BOOL IsPad);
+	int capture_get_last_frametime(capture_t *cap, unsigned int* env_n, unsigned int* opt_n,BOOL IsPad);
 
 	int salesaudio_capture_create(rvc_audio_capture_config_t *config, rvc_sales_audio_capture_t **p_cap);
 	void salesaudio_capture_destroy(rvc_sales_audio_capture_t *cap);
 	ErrorCodeEnum salesrecord_audio_capture_start(rvc_sales_audio_capture_t *cap);
 	void salesrecord_audio_capture_stop(rvc_sales_audio_capture_t *cap);
 
-	int videocap_optdev_fetch(CSimpleStringA frontcam,CSimpleStringA ewscam,CAutoArray<CSimpleStringA> &hspcams,CSimpleStringA &rearcam);
-	int videocap_innerdev_fetch(CSimpleStringA &frontcam,CSimpleStringA &rearcam);
-	int videocap_outerdev_fetch(CSimpleStringA envcam,CSimpleStringA optcam,CSimpleStringA ewscam,CAutoArray<CSimpleStringA> &hspcams,CSimpleStringA &outercam);
 	void capture_lib_term();
 
 	int capture_get_video_device_id(const char *dev_name);

+ 1 - 1
Module/mod_mediacontroller/unix/capture.cpp

@@ -1924,7 +1924,7 @@ namespace MediaController {
 		return 0;
 	}
 
-	int capture_get_last_frametime(capture_t *cap,  DWORD *env_n,  DWORD *opt_n,BOOL IsPad)
+	int capture_get_last_frametime(capture_t *cap,  unsinged int *env_n,  DWORD *opt_n,BOOL IsPad)
 	{
 		*env_n = 0;
 		*opt_n = 0;

+ 395 - 371
Module/mod_mediacontroller/win/capture.cpp

@@ -240,13 +240,13 @@ static void salesrecord_audio_capture_destroy(rvc_audio_capture_t *audio_cap)
 					Sleep(100);
 				}
 				else {
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio_shm_queue length is 0, delete it, and icount = %d.", i);
+					//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio_shm_queue length is 0, delete it, and icount = %d.", i);
 					break;
 				}
 			}
 			delete audio_cap->audio_shm_queue;
 			audio_cap->audio_shm_queue = NULL;
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set audio_cap audio_shm_queue null.");
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set audio_cap audio_shm_queue null.");
 		}
 		free(audio_cap);
 	}
@@ -425,13 +425,13 @@ static void record_audio_capture_stop(rvc_audio_capture_t *audio_cap)
 	if (NULL != audio_cap){
 		if (audio_cap->stream) {
 			PaError Error = Pa_AbortStream(audio_cap->stream);
-			if (paNoError == Error){
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Pa_AbortStream no error.");
-			}
+			//if (paNoError == Error){
+			//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Pa_AbortStream no error.");
+			//}
 			Error = Pa_CloseStream(audio_cap->stream);
-			if (paNoError == Error){
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Pa_CloseStream no error.");
-			}
+			//if (paNoError == Error){
+			//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Pa_CloseStream no error.");
+			//}
 			audio_cap->stream = NULL;
 		}
 		audio_cap->iseriesnumber = 0;
@@ -513,13 +513,13 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 	{
 		if (*cap->config.ref_env_capture_count) 
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("env camera ref_env_capture_count=%d",*cap->config.ref_env_capture_count);
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("env camera ref_env_capture_count=%d",*cap->config.ref_env_capture_count);
 			InterlockedDecrement(cap->config.ref_env_capture_count);
 			LogEvent(Severity_Middle, MOD_EVENT_MEDIACONTROLLER_FINISHED_CAPTURE_ENV, "agent capture env ok, and capture env finished!");
 		} 
 		else if (*cap->config.ref_envopt_capture_count & 2) 
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("env camera ref_envopt_capture_count=%d",*cap->config.ref_envopt_capture_count);
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("env camera ref_envopt_capture_count=%d",*cap->config.ref_envopt_capture_count);
 			_InterlockedAnd(cap->config.ref_envopt_capture_count, 0xfffffffD);
 			if (*cap->config.ref_envopt_capture_count == 0) 
 			{
@@ -561,7 +561,6 @@ static void env_cap_on_frame(void *user_data, video_frame *frame)
 #endif
 		video_frame_free(&rtp_frame);
 	}
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("end env on frame, id=%d, tick=%d", video_cap->frame_id, GetTickCount());;
 }
 
 static void opt_cap_on_frame(void *user_data, video_frame *frame)
@@ -584,7 +583,6 @@ static void opt_cap_on_frame(void *user_data, video_frame *frame)
 
 	video_cap->frame_id++;
 	video_cap->ulastcaptime = y2k_time_now();
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("******************* opt on frame, id=%d, ulastcaptime=%u.", video_cap->frame_id, video_cap->ulastcaptime);
 
 	// prepare for rotation
 	video_frame_alloc(frame->height, frame->width, frame->format, &rframe);
@@ -640,13 +638,12 @@ static void opt_cap_on_frame(void *user_data, video_frame *frame)
 	{
 		if (*cap->config.ref_opt_capture_count) 
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("opt camera ref_opt_capture_count=%d",*cap->config.ref_opt_capture_count);
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("opt camera ref_opt_capture_count=%d",*cap->config.ref_opt_capture_count);
 			InterlockedDecrement(cap->config.ref_opt_capture_count);
 			LogEvent(Severity_Middle, MOD_EVENT_MEDIACONTROLLER_FINISHED_CAPTURE_OPT, "agent capture opt ok, and capture opt finished!");
 		} 
 		else if (*cap->config.ref_envopt_capture_count&1) 
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("opt camera ref_envopt_capture_count=%d",*cap->config.ref_envopt_capture_count);
 			if (InterlockedDecrement(cap->config.ref_envopt_capture_count) == 0) 
 			{
 				LogEvent(Severity_Middle, MOD_EVENT_MEDIACONTROLLER_FINISHED_CAPTURE_ENVOPT, "agent capture opt ok, and capture env opt finished!");
@@ -799,7 +796,7 @@ static int video_capture_start(video_capture_t *video_cap)
 	if (1 == conf->video_cap_type){
 		param.cap_frame_format = VIDEO_FORMAT_YUY2;
 	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("video capture frame format is %s.", param.cap_frame_format == VIDEO_FORMAT_RGB24 ? "VIDEO_FORMAT_RGB24" : "VIDEO_FORMAT_YUY2");
+	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("video capture frame format is %s.", param.cap_frame_format == VIDEO_FORMAT_RGB24 ? "VIDEO_FORMAT_RGB24" : "VIDEO_FORMAT_YUY2");
 	
 	if ((ePadtype == g_eDeviceType)||(eMobilePadType == g_eDeviceType)||(eDesk2SType == g_eDeviceType)||(eDesk1SType == g_eDeviceType)||(eDesk2SIntegratedType == g_eDeviceType)){
 		param.fps = REC_COMMON_VIDEO_PADRAW_FPS;
@@ -829,9 +826,6 @@ static int video_capture_start(video_capture_t *video_cap)
 		video_cap->cap = NULL;
 		return rc;
 	}
-	else{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("videocap start success!");
-	}
 
 	return 0;
 }
@@ -1004,8 +998,8 @@ namespace MediaController {
 			cap->rvc_audio->iaudio_capture_peroid = config->audio_capture_period;
 			cap->rvc_audio->iaudio_capture_samplerate = config->audio_capture_samplerate;
 			*p_cap = cap;
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create sales record audio capture object(0x%08x) success, capture sample rate is %d, and rvc audio(0x%08x) in device is %s.",
-				cap, cap->rvc_audio->iaudio_capture_samplerate, cap->rvc_audio, cap->rvc_audio_config.strAudioIn.GetData());
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create sales record audio capture object(0x%08x) success, capture sample rate is %d, and rvc audio(0x%08x) in device is %s.",
+			//	cap, cap->rvc_audio->iaudio_capture_samplerate, cap->rvc_audio, cap->rvc_audio_config.strAudioIn.GetData());
 			return 0;
 		}
 	}
@@ -1013,12 +1007,12 @@ namespace MediaController {
 	void salesaudio_capture_destroy(rvc_sales_audio_capture_t *cap)
 	{
 		if (NULL != cap){
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sales audio capture destroy, and cap addr is 0x%08x.", cap);
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sales audio capture destroy, and cap addr is 0x%08x.", cap);
 			if (cap->rvc_audio) {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sales audio capture rvc_audio destroy, and rvc_audio addr is 0x%08x.", cap->rvc_audio);
+				//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sales audio capture rvc_audio destroy, and rvc_audio addr is 0x%08x.", cap->rvc_audio);
 				salesrecord_audio_capture_destroy(cap->rvc_audio);
 				cap->rvc_audio = NULL;
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set rvc_audio to null.");
+				//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("set rvc_audio to null.");
 			}
 			free(cap);
 		}
@@ -1071,17 +1065,17 @@ namespace MediaController {
 			if (rc != Error_Succeed) {
 				rslt = (ErrorCodeEnum)rc;
 				if (rslt == Error_AudioIN){
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start audio In object failed! rc:%d", rc);
+					//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start audio In object failed! rc:%d", rc);
 					LogWarn(Severity_Middle, Error_Debug,ERROR_MOD_MEDIACONTROLLER_HANDFREE_OPENFAIL,"open audioIn device fail,please check device");	
 				} 
 				else{
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start audio Out object failed! rc:%d", rc);
+					//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start audio Out object failed! rc:%d", rc);
 					LogWarn(Severity_Middle, Error_Debug,ERROR_MOD_MEDIACONTROLLER_HANDFREE_OPENFAIL,"open audioOut device fail,please check device");	
 				}
 			}
 		}
 		else{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio_capture_t is null.");
+			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("audio_capture_t is null.");
 			rslt = Error_AudioIN;
 		}
 
@@ -1123,7 +1117,6 @@ namespace MediaController {
 					{
 						cap->opt_video->ustarttime = y2k_time_now();
 						LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_OPTCAM_OPEN, "start optcam success.");
-						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start env video capture object failed!");
 						return Error_EnvCamera;
 					}
 				}
@@ -1162,7 +1155,6 @@ namespace MediaController {
 				}
 				else
 				{
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("opt_video = Null");
 					return Error_OptCamera;
 				}
 			}
@@ -1340,16 +1332,12 @@ namespace MediaController {
 		if (cap->env_video) {
 			video_capture_stop(cap->env_video);
 			if (0 != cap->env_video->ustarttime) {
-				char strmsg[MAX_PATH] = { 0 };
-				_snprintf(strmsg, MAX_PATH, "stop envcam, and camera open time is %us.", y2k_time_now() - cap->env_video->ustarttime);
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_ENVCAM_CLOSE, strmsg);
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_ENVCAM_CLOSE, CSimpleStringA::Format("stop envcam, and camera open time is %us.", y2k_time_now() - cap->env_video->ustarttime).GetData());
 			}
 		}
 		if (cap->opt_video) {
 			if (0 != cap->opt_video->ustarttime) {
-				char strinfo[MAX_PATH] = { 0 };
-				_snprintf(strinfo, MAX_PATH, "stop optcam, and camera open time is %us.", y2k_time_now() - cap->opt_video->ustarttime);
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_OPTCAM_CLOSE, strinfo);
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_OPTCAM_CLOSE, CSimpleStringA::Format("stop optcam, and camera open time is %us.", y2k_time_now() - cap->opt_video->ustarttime).GetData());
 			}
 			video_capture_stop(cap->opt_video);
 		}
@@ -1362,18 +1350,14 @@ namespace MediaController {
 		{
 			video_capture_stop(cap->env_video);
 			if (0 != cap->env_video->ustarttime) {
-				char strmsg[MAX_PATH] = { 0 };
-				_snprintf(strmsg, MAX_PATH, "stop envcam, and camera open time is %us.", y2k_time_now() - cap->env_video->ustarttime);
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_ENVCAM_CLOSE, strmsg);
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_ENVCAM_CLOSE, CSimpleStringA::Format("stop envcam, and camera open time is %us.", y2k_time_now() - cap->env_video->ustarttime).GetData());
 			}
 		}
 		else if(cap->opt_video&&(nCamera==OPTCAMERA))
 		{
 			video_capture_stop(cap->opt_video);
 			if (0 != cap->opt_video->ustarttime) {
-				char strinfo[MAX_PATH] = { 0 };
-				_snprintf(strinfo, MAX_PATH, "stop optcam, and camera open time is %us.", y2k_time_now() - cap->opt_video->ustarttime);
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_OPTCAM_CLOSE, strinfo);
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_OPTCAM_CLOSE, CSimpleStringA::Format("stop optcam, and camera open time is %us.", y2k_time_now() - cap->opt_video->ustarttime).GetData());
 			}
 		}
 	}
@@ -1418,7 +1402,7 @@ namespace MediaController {
 	}
 
 	//摄像头没打开返回0,其他情况返回视频队列中最后一幅图像时间
-	int capture_get_last_frametime(capture_t *cap,  DWORD *env_n,  DWORD *opt_n,BOOL IsPad)
+	int capture_get_last_frametime(capture_t *cap, unsigned int*env_n, unsigned int*opt_n,BOOL IsPad)
 	{
 		*env_n = 0;
 		*opt_n = 0;
@@ -1516,15 +1500,8 @@ namespace MediaController {
 			if (dev_name != NULL && strlen(dev_name) > 1 && 
 				strstr(dev_name, ";") == NULL) // 外接摄像头 add by ly at 20160531
 			{
-				/*if (strstr(t, dev_name) != NULL)
-				{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] %s founded in %d cameras.", dev_name, n);
-				return i;
-				}*/
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] device_path: %s",t2);
 				if (strstr(t2,dev_name) != NULL) // 判断外接摄像头DeviceLocationPaths是否是DevicePath的子串
 				{
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] %s founded in %d cameras.", dev_name, n);
 					return i;
 				}
 				if (strcmp(dev_name, t) == 0) // 如果是直接用友好名称查询(适用于高拍仪) add by ly 2017/11/08
@@ -1621,20 +1598,17 @@ namespace MediaController {
 					md5(x, t1, strlen(t1));
 					Bin2Str(x, sizeof(x), t1, sizeof(t1));
 				}
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s;%s", i, t, t1);
+				//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%d = %s;%s", i, t, t1);
 				strJson += CSimpleStringA::Format("\"%d\":\"%s;%s\",", i, t, t1);
 			}
 
 			if (n > 0){
-				char strmsg[MAX_PATH] = {0};
-				_snprintf(strmsg, MAX_PATH, "camera number is %d.", n);
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_CAMERA_COUNT, strmsg);
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_CAMERA_COUNT, CSimpleStringA::Format("camera number is %d.", n).GetData());
 
 				if (strJson.GetLength() > 0){
 					strJson[strJson.GetLength( )-1] = '\0';
 				}
-				CSimpleStringA strJsonData = CSimpleStringA::Format("[{%s}]", strJson.GetData());
-				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_GETCAMERA_INFOS, strJsonData.GetData());
+				LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_GETCAMERA_INFOS, CSimpleStringA::Format("[{%s}]", strJson.GetData()).GetData());
 			} 
 			else{
 				LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_MEDIACONTROLLER_NOCAMERA, "can not find camera.");
@@ -1646,20 +1620,20 @@ namespace MediaController {
 			rc = audio_get_dev_count(&icnt, &ocnt);
 			if (rc == 0) {
 				int i;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio input devices(%d):", icnt);
+				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio input devices(%d):", icnt);
 				*incount = icnt;
 				*ioutcount = ocnt;
 				for (i = 0; i < icnt; ++i) {
 					CSimpleStringA str = audio_get_dev_name(true, i);
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
+					//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
 					if (i == icnt - 1) {
 						strAudioIn = str;
 					}
 				}
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio output devices(%d):", ocnt);
+				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio output devices(%d):", ocnt);
 				for (i = 0; i < ocnt; ++i) {
 					CSimpleStringA str = audio_get_dev_name(false, i);
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
+					//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
 					if (i == ocnt - 1) {
 						strAudioOut = str;
 					}
@@ -1684,184 +1658,180 @@ namespace MediaController {
 		return Error_Succeed;
 	}
 
-	int videocap_innerdev_fetch(CSimpleStringA&frontcam,CSimpleStringA&rearcam) // edit by ly at 20160401
-	{
-		int i, n;
-		frontcam = "$", rearcam = "$";
-		n = videocap_get_device_count();
-		if (n == 2) // 未插入外接时
-		{
-			for (i = 0; i < n; ++i) {
-				WCHAR tmp[256] = {0};
-				char t[256] = {0};
-				WCHAR tmp1[256] = {0};
-				char t1[256] = {0};
-				videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
-				WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
-				videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
-				WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
-				{
-					unsigned char x[MD5_DIGESTSIZE];
-					md5_ctx_t ctx;
-					md5_init(&ctx);
-					md5(x, t1, strlen(t1));
-					Bin2Str(x, sizeof(x), t1, sizeof(t1));
-				}
-				strcat(t, ";");
-				strcat(t, t1);
-				if (i==0)
-				{
-					frontcam = t;
-				}
-				else if(i==1)
-				{
-					rearcam = t;
-				}
-			}
-		}
-		else
-		{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[dbg] detect %d cameras.", n);
-		}
-
-		return n;
-	}
-
-	int videocap_outerdev_fetch( CSimpleStringA envcam,CSimpleStringA optcam,CSimpleStringA ewscam,CAutoArray<CSimpleStringA> &hspcams,CSimpleStringA &outercam )
-	{
-		int i, n;
-		outercam = "$";
-		n = videocap_get_device_count();
-		int m = hspcams.GetCount();  // 高拍仪的个数 add by ly 2017/11/07
-		if (ewscam.GetLength() <= 1) // 如果外部广角摄像头未配置
-		{
-			if (n <= m || n > 3+m)
-			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] [videocap_outerdev_fetch] detect %d cameras.", n);
-			}
-			else
-			{
-				int cnt = 0;
-				for (i = 0; i < n; ++i) {
-					WCHAR tmp[256];
-					char t[256];
-					WCHAR tmp1[256];
-					char t1[256];
-					videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
-					WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
-					videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
-					WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
-					// save DevicePath (add by ly at 20160725)
-					char t2[256];
-					strcpy(t2,t1);
-					for (int j = 0; j < strlen(t2); ++j)
-					{
-						t2[j] = toupper(t2[j]);
-						if (t2[j] == '#') t2[j] = '\\';
-					}
-					{
-						unsigned char x[MD5_DIGESTSIZE];
-						md5_ctx_t ctx;
-						md5_init(&ctx);
-						md5(x, t1, strlen(t1));
-						Bin2Str(x, sizeof(x), t1, sizeof(t1));
-					}
-
-					// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
-					bool isHspCam = false;
-					for (int k = 0; k < m; ++k) {
-						if (!strcmp((LPCTSTR)hspcams[k],t)) {
-							isHspCam = true;
-							break;
-						}
-					}
-					if (isHspCam) {
-						continue;
-					}
-
-					strcat(t, ";");
-					strcat(t, t1);
-					if(strcmp(t,(LPCTSTR)envcam) && strcmp(t,(LPCTSTR)optcam))
-					{
-						if (0 == cnt)
-						{
-							outercam = t2;
-						}
-						++cnt;
-					}
-				}
-				if(cnt != 1)
-				{
-					outercam = "$";
-				}
-			}
-		}
-		else // 如果外部广角摄像头已配置
-		{
-			if (n <= m || n > 4+m)
-			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] [videocap_outerdev_fetch] detect %d cameras.", n);
-			}
-			else
-			{
-				int cnt = 0;
-				for (i = 0; i < n; ++i) {
-					WCHAR tmp[256];
-					char t[256];
-					WCHAR tmp1[256];
-					char t1[256];
-					videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
-					WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
-					videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
-					WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
-					// save DevicePath (add by ly at 20160725)
-					char t2[256];
-					strcpy(t2,t1);
-					for (int j = 0; j < strlen(t2); ++j)
-					{
-						t2[j] = toupper(t2[j]);
-						if (t2[j] == '#') t2[j] = '\\';
-					}
-					{
-						unsigned char x[MD5_DIGESTSIZE];
-						md5_ctx_t ctx;
-						md5_init(&ctx);
-						md5(x, t1, strlen(t1));
-						Bin2Str(x, sizeof(x), t1, sizeof(t1));
-					}
-
-					// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
-					bool isHspCam = false;
-					for (int k = 0; k < m; ++k) {
-						if (!strcmp((LPCTSTR)hspcams[k],t)) {
-							isHspCam = true;
-							break;
-						}
-					}
-					if (isHspCam) {
-						continue;
-					}
-
-					strcat(t, ";");
-					strcat(t, t1);
-					if(strcmp(t,(LPCTSTR)envcam) && strcmp(t,(LPCTSTR)optcam) && !strstr(t2,(LPCTSTR)ewscam))
-					{
-						if (0 == cnt)
-						{
-							outercam = t2;
-						}
-						++cnt;
-					}
-				}
-				if(cnt != 1)
-				{
-					outercam = "$";
-				}
-			}
-		}
-
-		return n;
-	}
+	//int videocap_innerdev_fetch(CSimpleStringA&frontcam,CSimpleStringA&rearcam)
+	//{
+	//	int i, n;
+	//	frontcam = "$", rearcam = "$";
+	//	n = videocap_get_device_count();
+	//	if (n == 2) // 未插入外接时
+	//	{
+	//		for (i = 0; i < n; ++i) {
+	//			WCHAR tmp[256] = {0};
+	//			char t[256] = {0};
+	//			WCHAR tmp1[256] = {0};
+	//			char t1[256] = {0};
+	//			videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+	//			WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+	//			videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
+	//			WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
+	//			{
+	//				unsigned char x[MD5_DIGESTSIZE];
+	//				md5_ctx_t ctx;
+	//				md5_init(&ctx);
+	//				md5(x, t1, strlen(t1));
+	//				Bin2Str(x, sizeof(x), t1, sizeof(t1));
+	//			}
+	//			strcat(t, ";");
+	//			strcat(t, t1);
+	//			if (i==0)
+	//			{
+	//				frontcam = t;
+	//			}
+	//			else if(i==1)
+	//			{
+	//				rearcam = t;
+	//			}
+	//		}
+	//	}
+
+	//	return n;
+	//}
+
+	//int videocap_outerdev_fetch( CSimpleStringA envcam,CSimpleStringA optcam,CSimpleStringA ewscam,CAutoArray<CSimpleStringA> &hspcams,CSimpleStringA &outercam )
+	//{
+	//	int i, n;
+	//	outercam = "$";
+	//	n = videocap_get_device_count();
+	//	int m = hspcams.GetCount();  // 高拍仪的个数 add by ly 2017/11/07
+	//	if (ewscam.GetLength() <= 1) // 如果外部广角摄像头未配置
+	//	{
+	//		if (n <= m || n > 3+m)
+	//		{
+	//			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] [videocap_outerdev_fetch] detect %d cameras.", n);
+	//		}
+	//		else
+	//		{
+	//			int cnt = 0;
+	//			for (i = 0; i < n; ++i) {
+	//				WCHAR tmp[256];
+	//				char t[256];
+	//				WCHAR tmp1[256];
+	//				char t1[256];
+	//				videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+	//				videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
+	//				// save DevicePath (add by ly at 20160725)
+	//				char t2[256];
+	//				strcpy(t2,t1);
+	//				for (int j = 0; j < strlen(t2); ++j)
+	//				{
+	//					t2[j] = toupper(t2[j]);
+	//					if (t2[j] == '#') t2[j] = '\\';
+	//				}
+	//				{
+	//					unsigned char x[MD5_DIGESTSIZE];
+	//					md5_ctx_t ctx;
+	//					md5_init(&ctx);
+	//					md5(x, t1, strlen(t1));
+	//					Bin2Str(x, sizeof(x), t1, sizeof(t1));
+	//				}
+
+	//				// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
+	//				bool isHspCam = false;
+	//				for (int k = 0; k < m; ++k) {
+	//					if (!strcmp((LPCTSTR)hspcams[k],t)) {
+	//						isHspCam = true;
+	//						break;
+	//					}
+	//				}
+	//				if (isHspCam) {
+	//					continue;
+	//				}
+
+	//				strcat(t, ";");
+	//				strcat(t, t1);
+	//				if(strcmp(t,(LPCTSTR)envcam) && strcmp(t,(LPCTSTR)optcam))
+	//				{
+	//					if (0 == cnt)
+	//					{
+	//						outercam = t2;
+	//					}
+	//					++cnt;
+	//				}
+	//			}
+	//			if(cnt != 1)
+	//			{
+	//				outercam = "$";
+	//			}
+	//		}
+	//	}
+	//	else // 如果外部广角摄像头已配置
+	//	{
+	//		if (n <= m || n > 4+m)
+	//		{
+	//			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] [videocap_outerdev_fetch] detect %d cameras.", n);
+	//		}
+	//		else
+	//		{
+	//			int cnt = 0;
+	//			for (i = 0; i < n; ++i) {
+	//				WCHAR tmp[256];
+	//				char t[256];
+	//				WCHAR tmp1[256];
+	//				char t1[256];
+	//				videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+	//				videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
+	//				// save DevicePath (add by ly at 20160725)
+	//				char t2[256];
+	//				strcpy(t2,t1);
+	//				for (int j = 0; j < strlen(t2); ++j)
+	//				{
+	//					t2[j] = toupper(t2[j]);
+	//					if (t2[j] == '#') t2[j] = '\\';
+	//				}
+	//				{
+	//					unsigned char x[MD5_DIGESTSIZE];
+	//					md5_ctx_t ctx;
+	//					md5_init(&ctx);
+	//					md5(x, t1, strlen(t1));
+	//					Bin2Str(x, sizeof(x), t1, sizeof(t1));
+	//				}
+
+	//				// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
+	//				bool isHspCam = false;
+	//				for (int k = 0; k < m; ++k) {
+	//					if (!strcmp((LPCTSTR)hspcams[k],t)) {
+	//						isHspCam = true;
+	//						break;
+	//					}
+	//				}
+	//				if (isHspCam) {
+	//					continue;
+	//				}
+
+	//				strcat(t, ";");
+	//				strcat(t, t1);
+	//				if(strcmp(t,(LPCTSTR)envcam) && strcmp(t,(LPCTSTR)optcam) && !strstr(t2,(LPCTSTR)ewscam))
+	//				{
+	//					if (0 == cnt)
+	//					{
+	//						outercam = t2;
+	//					}
+	//					++cnt;
+	//				}
+	//			}
+	//			if(cnt != 1)
+	//			{
+	//				outercam = "$";
+	//			}
+	//		}
+	//	}
+
+	//	return n;
+	//}
 
 	void capture_lib_term()
 	{
@@ -1982,149 +1952,138 @@ namespace MediaController {
 		}
 	}
 
-	//根据frontcam完整名(包含设备名+逗号+设备路径MD5)、ewscam设备路径、hspcams设备名,找到rearcam的完整名
-	//排除以上设备后的唯一设备即为rearcam
-	int videocap_optdev_fetch( CSimpleStringA frontcam,CSimpleStringA ewscam,CAutoArray<CSimpleStringA> &hspcams,CSimpleStringA &rearcam )
-	{
-		int i, n;
-		rearcam = "$";
-		n = videocap_get_device_count();
-		int m = hspcams.GetCount();  // 高拍仪的个数 add by ly 2017/11/07
-		if (ewscam.GetLength() <= 1) // 如果外部广角摄像头未配置
-		{
-			if (n <= 2+m)
-			{
-				int cnt = 0;
-				for (i = 0; i < n; ++i) {
-					WCHAR tmp[256];
-					char t[256];
-					WCHAR tmp1[256];
-					char t1[256];
-					videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
-					WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
-					videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
-					WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
-					{
-						unsigned char x[MD5_DIGESTSIZE];
-						md5_ctx_t ctx;
-						md5_init(&ctx);
-						md5(x, t1, strlen(t1));
-						Bin2Str(x, sizeof(x), t1, sizeof(t1));
-					}
-
-					// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
-					bool isHspCam = false;
-					for (int k = 0; k < m; ++k) {
-						if (!strcmp((LPCTSTR)hspcams[k],t)) {
-							isHspCam = true;
-							break;
-						}
-					}
-					if (isHspCam) {
-						continue;
-					}
-
-					strcat(t, ";");
-					strcat(t, t1);
-
-					if (strcmp((LPCTSTR)frontcam, t))
-					{
-						if (0 == cnt)
-						{
-							rearcam = t;
-						}
-						cnt++;
-					}
-				}
-				if (1 != cnt) // 未找到或无法识别内置后摄像头
-				{
-					rearcam = "$";
-				}
-			}
-			else
-			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] [videocap_optdev_fetch] detect %d cameras.", n);
-			}
-		}
-		else // 如果外部广角摄像头已配置
-		{
-			if (n <= 3+m)
-			{
-				int cnt = 0;
-				for (i = 0; i < n; ++i) {
-					WCHAR tmp[256];
-					char t[256];
-					WCHAR tmp1[256];
-					char t1[256];
-					videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
-					WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
-					videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
-					WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
-
-					// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
-					bool isHspCam = false;
-					for (int k = 0; k < m; ++k) {
-						if (!strcmp((LPCTSTR)hspcams[k],t)) {
-							isHspCam = true;
-							break;
-						}
-					}
-					if (isHspCam) {
-						continue;
-					}
-
-					// save DevicePath (add by ly at 20160725)
-					char t2[256];
-					strcpy(t2,t1);
-					for (int j = 0; j < strlen(t2); ++j)
-					{
-						t2[j] = toupper(t2[j]);
-						if (t2[j] == '#') t2[j] = '\\';
-					}
-					{
-						unsigned char x[MD5_DIGESTSIZE];
-						md5_ctx_t ctx;
-						md5_init(&ctx);
-						md5(x, t1, strlen(t1));
-						Bin2Str(x, sizeof(x), t1, sizeof(t1));
-					}
-					strcat(t, ";");
-					strcat(t, t1);
-
-					if (strcmp((LPCTSTR)frontcam, t) && !strstr(t2,(LPCTSTR)ewscam))
-					{
-						if (0 == cnt)
-						{
-							rearcam = t;
-						}
-						cnt++;
-					}
-				}
-				if (1 != cnt) // 未找到或无法识别内置后摄像头
-				{
-					rearcam = "$";
-				}
-			}
-			else
-			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[dbg] [videocap_optdev_fetch] detect %d cameras.", n);
-			}
-		}
-
-		return n;
-	}
+	////根据frontcam完整名(包含设备名+逗号+设备路径MD5)、ewscam设备路径、hspcams设备名,找到rearcam的完整名
+	////排除以上设备后的唯一设备即为rearcam
+	//int videocap_optdev_fetch( CSimpleStringA frontcam,CSimpleStringA ewscam,CAutoArray<CSimpleStringA> &hspcams,CSimpleStringA &rearcam )
+	//{
+	//	int i, n;
+	//	rearcam = "$";
+	//	n = videocap_get_device_count();
+	//	int m = hspcams.GetCount();  // 高拍仪的个数 add by ly 2017/11/07
+	//	if (ewscam.GetLength() <= 1) // 如果外部广角摄像头未配置
+	//	{
+	//		if (n <= 2+m)
+	//		{
+	//			int cnt = 0;
+	//			for (i = 0; i < n; ++i) {
+	//				WCHAR tmp[256];
+	//				char t[256];
+	//				WCHAR tmp1[256];
+	//				char t1[256];
+	//				videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+	//				videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
+	//				{
+	//					unsigned char x[MD5_DIGESTSIZE];
+	//					md5_ctx_t ctx;
+	//					md5_init(&ctx);
+	//					md5(x, t1, strlen(t1));
+	//					Bin2Str(x, sizeof(x), t1, sizeof(t1));
+	//				}
+
+	//				// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
+	//				bool isHspCam = false;
+	//				for (int k = 0; k < m; ++k) {
+	//					if (!strcmp((LPCTSTR)hspcams[k],t)) {
+	//						isHspCam = true;
+	//						break;
+	//					}
+	//				}
+	//				if (isHspCam) {
+	//					continue;
+	//				}
+
+	//				strcat(t, ";");
+	//				strcat(t, t1);
+
+	//				if (strcmp((LPCTSTR)frontcam, t))
+	//				{
+	//					if (0 == cnt)
+	//					{
+	//						rearcam = t;
+	//					}
+	//					cnt++;
+	//				}
+	//			}
+	//			if (1 != cnt) // 未找到或无法识别内置后摄像头
+	//			{
+	//				rearcam = "$";
+	//			}
+	//		}
+	//	}
+	//	else // 如果外部广角摄像头已配置
+	//	{
+	//		if (n <= 3+m)
+	//		{
+	//			int cnt = 0;
+	//			for (i = 0; i < n; ++i) {
+	//				WCHAR tmp[256];
+	//				char t[256];
+	//				WCHAR tmp1[256];
+	//				char t1[256];
+	//				videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+	//				videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
+	//				WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
+
+	//				// 检查是否为高拍仪摄像头,若是则直接枚举下一个摄像头
+	//				bool isHspCam = false;
+	//				for (int k = 0; k < m; ++k) {
+	//					if (!strcmp((LPCTSTR)hspcams[k],t)) {
+	//						isHspCam = true;
+	//						break;
+	//					}
+	//				}
+	//				if (isHspCam) {
+	//					continue;
+	//				}
+
+	//				char t2[256];
+	//				strcpy(t2,t1);
+	//				for (int j = 0; j < strlen(t2); ++j)
+	//				{
+	//					t2[j] = toupper(t2[j]);
+	//					if (t2[j] == '#') t2[j] = '\\';
+	//				}
+	//				{
+	//					unsigned char x[MD5_DIGESTSIZE];
+	//					md5_ctx_t ctx;
+	//					md5_init(&ctx);
+	//					md5(x, t1, strlen(t1));
+	//					Bin2Str(x, sizeof(x), t1, sizeof(t1));
+	//				}
+	//				strcat(t, ";");
+	//				strcat(t, t1);
+
+	//				if (strcmp((LPCTSTR)frontcam, t) && !strstr(t2,(LPCTSTR)ewscam))
+	//				{
+	//					if (0 == cnt)
+	//					{
+	//						rearcam = t;
+	//					}
+	//					cnt++;
+	//				}
+	//			}
+	//			if (1 != cnt) // 未找到或无法识别内置后摄像头
+	//			{
+	//				rearcam = "$";
+	//			}
+	//		}
+	//	}
+
+	//	return n;
+	//}
 
 	void capture_clearsnapshotvideo(capture_t *cap,int nCamera)
 	{
 		if((nCamera == ENVCAMERA)&&cap->env_video)
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("clear ENV snapshot video!");
 			cap->env_video->snapshot_shm_queue->ClearVideoQueue();
 			return;
 		}
 		else if((nCamera == OPTCAMERA)&&cap->opt_video)
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("clear OPT snapshot video!");
 			cap->opt_video->snapshot_shm_queue->ClearVideoQueue();
 			return;
 		}
@@ -2132,12 +2091,10 @@ namespace MediaController {
 		{
 			if (cap->env_video)
 			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("clear ENV snapshot video!");
 				cap->env_video->snapshot_shm_queue->ClearVideoQueue();
 			}
 			if (cap->opt_video)
 			{
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("clear OPT snapshot video!");
 				cap->opt_video->snapshot_shm_queue->ClearVideoQueue();
 			}
 			return;
@@ -2179,4 +2136,71 @@ namespace MediaController {
 
 		return iRet;
 	}
+
+
+	int capture_get_audio_device_list(bool in_direction, CSimpleStringA& strdevicelist)
+	{
+		int iret = 0;
+		int icnt = 0, ocnt = 0;
+		int rc = audio_get_dev_count(&icnt, &ocnt);
+		if (rc == 0) {
+			strdevicelist = "[";
+			if (in_direction) {
+				iret = icnt;
+				for (int i = 0; i < icnt; ++i) {
+					CSimpleStringA str = CSimpleStringA::Format("\"%s\"", audio_get_dev_name(true, i).GetData());
+					if (i > 0) {
+						strdevicelist += ",";
+					}
+					strdevicelist += str;
+				}
+			}
+			else {
+				iret = ocnt;
+				for (int i = 0; i < ocnt; ++i) {
+					CSimpleStringA str = CSimpleStringA::Format("\"%s\"",audio_get_dev_name(false, i).GetData());
+					if (i > 0) {
+						strdevicelist += ",";
+					}
+					strdevicelist += str;
+				}
+			}
+			strdevicelist += "]";
+		}
+
+		return iret;
+	}
+
+	int capture_get_video_device_list(CSimpleStringA& strdevicelist)
+	{
+		int iret = 0;
+		strdevicelist = "[";
+		iret = videocap_get_device_count();
+		for (int i = 0; i < iret; ++i) {
+			wchar_t tmp[MAX_PATH] = { 0 };
+			char t[MAX_PATH] = { 0 };
+			wchar_t tmp1[MAX_PATH] = { 0 };
+			char t1[MAX_PATH] = { 0 };
+			videocap_get_device_name(i, tmp, ARRAYSIZE(tmp));
+			WideCharToMultiByte(CP_ACP, 0, tmp, -1, t, sizeof(t), 0, NULL);
+			videocap_get_device_path(i, tmp1, ARRAYSIZE(tmp1));
+			WideCharToMultiByte(CP_ACP, 0, tmp1, -1, t1, sizeof(t1), 0, NULL);
+			{
+				unsigned char x[MD5_DIGESTSIZE] = {0};
+				md5_ctx_t ctx;
+				md5_init(&ctx);
+				md5(x, t1, strlen(t1));
+				Bin2Str(x, sizeof(x), t1, sizeof(t1));
+			}
+
+			CSimpleStringA str = CSimpleStringA::Format("\"%s;%s\"", t, t1);
+			if (i > 0) {
+				strdevicelist += ",";
+			}
+			strdevicelist += str;
+		}
+		strdevicelist += "]";
+
+		return iret;
+	}
 }

文件差异内容过多而无法显示
+ 102 - 296
Module/mod_mediacontroller/win/mod_mediacontroller.cpp


+ 5 - 8
Module/mod_recorder/mod_recorder.h

@@ -21,16 +21,11 @@
 
 #include "recordinfo.h"
 
-
-#ifndef RVC_HTTPTIMEOUT
-#define RVC_HTTPTIMEOUT 10
-#endif // !RVC_HTTPTIMEOUT
-
 namespace Recorder {
 	class CRecorderEntity : public CEntityBase, public CHostApi, public ILogListener, public ISysVarListener
 	{
 	public:
-		CRecorderEntity() : m_bStarted(false), m_pRecorder(NULL), m_LastSaveSessionId("N"), m_iSeriesNum(0), m_iMovedSeriesNum(0), m_bMoveFlag(false), m_bEncFlag(false), m_eRecordType(eMP4), m_iRecordMode(0){
+		CRecorderEntity() : m_bStarted(false), m_pRecorder(NULL), m_LastSaveSessionId("N"), m_iSeriesNum(0), m_iMovedSeriesNum(0), m_bMoveFlag(false), m_bEncFlag(false), m_eRecordType(eWMV), m_iRecordMode(0){
 			m_strHttpServerAPI = RVC_UPLOAD_VIDEORECORDING_HTTP_API;
 			m_iHttpTimeOut = RVC_HTTPTIMEOUT;
 			m_strHttpServerAddr = RVC_UPLOAD_VIDEORECORDING_HTTP_ADDR;
@@ -38,6 +33,7 @@ namespace Recorder {
 			m_strTerminalId = NULL;
 			memset(m_strRecordName, 0, MAX_PATH);
 			m_eBusinessStatus = eInterrupt;
+			m_bPostVideoInfoOn = false;
 		}
 
 		virtual ~CRecorderEntity() {}
@@ -48,10 +44,10 @@ namespace Recorder {
 
 		virtual void OnPreStart(CAutoArray<CSimpleStringA> strArgs, CSmartPointer<ITransactionContext> pTransactionContext);
 		virtual void OnPreClose(EntityCloseCauseEnum eCloseCause, CSmartPointer<ITransactionContext> pTransactionContext);
+
 		ErrorCodeEnum __OnStart(ErrorCodeEnum preOperationError);
 		ErrorCodeEnum __OnClose(ErrorCodeEnum preOperationError);
 #if defined(RVC_OS_WIN)
-		virtual void WmpDebug(const char* fmt, ...);
 #else
 		bool InitRecorder();
 		bool ReleaseRecorder();
@@ -106,11 +102,12 @@ namespace Recorder {
 		CSimpleStringA m_RecordSaveDir;
 		CSimpleStringA m_LastSaveSessionId;
 		int m_iSeriesNum;
-		int m_iMovedSeriesNum;			//相同session号已移动文件数
+		int m_iMovedSeriesNum;			//鐩稿悓session鍙峰凡绉诲姩鏂囦欢鏁�
 		bool m_bMoveFlag;
 		bool m_bEncFlag;
 		eVideoFormat m_eRecordType;
 		int m_iRecordMode;
+		bool m_bPostVideoInfoOn;
 
 		CSimpleStringA m_strHttpServerAddr;
 		CSimpleStringA m_strHttpServerAPI;

+ 6 - 5
Module/mod_recorder/recordinfo.cpp

@@ -8,7 +8,7 @@ void HttpsLogCallBack(const char* logtxt) {
 }
 
 
-int post_video_recordinfo_list(video_record_info_t* pinfo, int itimeout, bool bprintdbg)
+int post_video_recordinfo_list(unsigned int& uposttime, CSimpleStringA& errormsg, video_record_info_t* pinfo, int itimeout, bool bprintdbg)
 {
 	int iret = -1;
 	IHttpFunc* client = create_http(HttpsLogCallBack);
@@ -60,11 +60,12 @@ int post_video_recordinfo_list(video_record_info_t* pinfo, int itimeout, bool bp
 	}
 
 	Json::StyledWriter sw;
+
 	req.m_reqContent = sw.write(rootReq);
 
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("m_reqContent is %s.", req.m_reqContent.c_str());
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("m_reqContent is %s.", req.m_reqContent.c_str());
 
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin http get request, timeout is %d, printdbg flag is %s.", req.m_timeOut, req.m_printDbg ? "true" : "false");
+	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin http get request, timeout is %d, printdbg flag is %s.", req.m_timeOut, req.m_printDbg ? "true" : "false");
 
 	unsigned int ustarttime = get_millisec_time();
 
@@ -72,11 +73,11 @@ int post_video_recordinfo_list(video_record_info_t* pinfo, int itimeout, bool bp
 	if (client->Post(req, ret)) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("post result is %s, returnCode:%s, code:%s, errorMsg:%s, message:%s.",
 			ret.m_success ? "success" : "failed", ret.m_returnCode.c_str(), ret.m_code.c_str(), ret.m_errorMsg.c_str(), ret.m_message.c_str());
-		LogWarn(Severity_Low, Error_Debug, LOG_EVT_POST_RECORDINFO_COST_TIME, CSimpleStringA::Format("post video record infos cost time is %ums.", get_millisec_time()- ustarttime).GetData());
+		uposttime = get_millisec_time() - ustarttime;
 		iret = 0;
 	}
 	else {
-		LogWarn(Severity_Middle, Error_Exception, LOG_EVT_POST_RECORDINFO_FAILED, CSimpleStringA::Format("post video record infos fail, url=%s, syscode=%d, usercode=%s, errmsg=%s", req.m_url.c_str(), ret.m_sysCode, ret.m_userCode.c_str(), ret.m_errMsg.c_str()).GetData());
+		errormsg = CSimpleStringA::Format("post video record infos fail, url=%s, syscode=%d, usercode=%s, errmsg=%s", req.m_url.c_str(), ret.m_sysCode, ret.m_userCode.c_str(), ret.m_errMsg.c_str());
 	}
 
 	return iret;

+ 5 - 2
Module/mod_recorder/recordinfo.h

@@ -24,10 +24,13 @@
 #define RVC_UPLOAD_VIDEORECORDING_HTTP_ADDR "https://uploadservice.paas.cmbchina.cn"
 #endif // !RVC_UPLOAD_VIDEORECORDING_HTTP_ADDR
 
+#ifndef RVC_HTTPTIMEOUT
+#define RVC_HTTPTIMEOUT 10
+#endif // !RVC_HTTPTIMEOUT
 
 #define REFLECTION(var) #var
 
-//ÒµÎñ״̬£¨0 - ʧ°Ü£¬1 - ³É¹¦£¬2 - È¡Ïû£¬3 - Öжϣ©
+//业务状�(0 - 失败,1 - �功,2 - �消,3 - 中断)
 enum eRvcBusinessStatus {
 	eFailed,
 	eSuccess,
@@ -94,7 +97,7 @@ struct RecordInfoHTTPRet : CHTTPRet {
 };
 
 
-int post_video_recordinfo_list(video_record_info_t* pinfo, int itimeout, bool bprintdbg);
+int post_video_recordinfo_list(unsigned int& uposttime, CSimpleStringA& errormsg, video_record_info_t* pinfo, int itimeout, bool bprintdbg);
 
 unsigned int get_millisec_time();
 

+ 23 - 37
Module/mod_recorder/unix/mod_recorder.cpp

@@ -367,11 +367,14 @@ ErrorCodeEnum CRecorderEntity::PostVideoRecordInfos()
 		video_params.vRecordList.push_back(*it);
 	}
 
-	if (0 == post_video_recordinfo_list(&video_params, m_iHttpTimeOut, false)) {
+	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 {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Post video record info failed.");
+		LogWarn(Severity_Middle, Error_Exception, LOG_EVT_POST_RECORDINFO_FAILED, strErrorMsg.GetData());
 	}
 
 	m_vRecordList.clear();
@@ -712,44 +715,34 @@ int CRecorderEntity::HandleEncryptVideoRecord(const char* videofilename)
 	}
 
 #ifdef RVC_OS_WIN
-	filecryption_callback_t cb = { 0 };
+	filecryption_callback_t cb = {0};
 	cb.dbg = &rvcDbg;
-
-	char strOutFile[MAX_PATH] = { 0 };
+	
+	char strOutFile[MAX_PATH] = {0};
 	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!", videofilename, 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);
+	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)){
+			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!", videofilename);
-	}
 
 	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(), videofilename, strOutFile);
-		LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_DELETE_FAILED, videofilename);
-		if (DeleteFile(strOutFile)) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile file %s success!", strOutFile);
+	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)){
+			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!", videofilename);
-		if (!rename(strOutFile, videofilename)) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("rename %s to %s Success!", strOutFile, videofilename);
+	else{
+		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);
+		else{
+			LogWarn(Severity_Low, Error_Debug, LOG_EVT_RECORDER_RENAME_FAILED, CSimpleStringA::Format("Error Code %lu while rename %s.", GetLastError(), strOutFile).GetData());
 		}
 	}
 #endif // RVC_OS_WIN
@@ -939,15 +932,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());
 							}
 						}
 					}
@@ -956,9 +946,7 @@ 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());
@@ -1002,7 +990,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)
@@ -1018,7 +1005,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());

+ 308 - 260
Module/mod_recorder/win/mod_recorder.cpp

@@ -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()

+ 1 - 1
Module/mod_sipphone/mod_sipphone.h

@@ -253,7 +253,7 @@ public:
 	int on_video_box_move(int imessagetype, int ivideotype, int ileft, int ibottom);
 
 #if defined(RVC_OS_WIN)
-	ErrorCodeEnum get_nat_mapped_info(char* strmapip, size_t ulen, int* ivideo_map_port, int* iaudio_map_port, int ivideo_port, int iaudio_port);
+
 #else
 	void video_render(VideoRenderCommand_t* pCmd);
 	int start_video_render(rvc_video_render_params_t* render_param, bool bremote);

+ 12 - 52
Module/mod_sipphone/win/audio_session.cpp

@@ -73,7 +73,6 @@ static int on_rx_audio(char *frame,void*userdata)
 	{
 		if (frame) 
 		{
-			//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv data size %d",strlen(frame));
 			audio_frame frm;
 			frm.bitspersample = 16;
 			frm.format = 1;
@@ -95,11 +94,6 @@ static int on_rx_audio(char *frame,void*userdata)
 
 static void m_on_send_hook(const char *buf, int size, void *arg)
 {
-	//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send audio pkt");
-	//if ((g_nAudioSendNum%60) ==0)
-	//{
-	//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("send audio pkt num %d,single size %d",g_nAudioSendNum,size);
-	//}
 	g_nAudioSendNum++;
 }
 
@@ -130,10 +124,10 @@ static void m_on_recv_hook(const char *buf, int size, void *arg)
 	audio_session_t* psession = (audio_session_t*)arg;
 
 	if (false == psession->baudiorecved){
-		char strmsg[MAX_PATH] = { 0 };
-		_snprintf(strmsg, MAX_PATH, "received first audio packet, and packet size is %d, rtp port (%d <-----> %d).", size, psession->phonemedia_conf.local_rtp_port, psession->phonemedia_conf.remote_rtp_port);
+		//char strmsg[MAX_PATH] = { 0 };
+		//_snprintf(strmsg, MAX_PATH, "received first audio packet, and packet size is %d, rtp port (%d <-----> %d).", size, psession->phonemedia_conf.local_rtp_port, psession->phonemedia_conf.remote_rtp_port);
 		//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_STREAM_RECEIVED, strmsg);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(strmsg);
+		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)(strmsg);
 		psession->baudiorecved = true;
 	}
 
@@ -370,7 +364,6 @@ static int phonemedia_start(audio_session_t *session)
 	in_dev = &session->conf.in_dev[conf->dev_type][0];
 	out_dev = &session->conf.out_dev[conf->dev_type][0];
 	istoptype = media->conf.istoptype;
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("in_dev = %s,out_dev =%s, conf->dir = %d, istoptype = %d.",in_dev,out_dev, conf->dir, istoptype);
 
 	opt_micspk = AMS_OPT_AS_STREAM;
 	if (conf->dir & DIR_TX) {
@@ -446,44 +439,33 @@ static int phonemedia_start(audio_session_t *session)
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_ENGINE_START_FAILED, "audio engine  start failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audioengine_start success!");
 
 	rc = rtp_session_create2(conf->local_rtp_ip, conf->local_rtp_port, 
 		2, &media->rtpsess);
 	if (rc != 0) {
-		char strmsg[MAX_PATH] = { 0 };
-		_snprintf(strmsg, MAX_PATH, "audio rtp session create2 failed and local port is %d, rc=%d", conf->local_rtp_port, rc);
-		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_RTP_SESSION_CREATE_FAILED, strmsg);
+		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_RTP_SESSION_CREATE_FAILED, CSimpleStringA::Format("audio rtp session create2 failed and local port is %d, rc=%d", conf->local_rtp_port, rc).GetData());
 		//LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_RTP_CREATE, strmsg);
 		goto on_error;
 	}
-	else{
-		char strMessage[MAX_PATH] = { 0 };
-		_snprintf(strMessage, MAX_PATH, "audio rtp create2 success and local port is %d.", conf->local_rtp_port);
-		//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_RTP_CREATE, strMessage);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)(strMessage);
-	}
+
 	//rc = rtp_session_reset2(media->rtpsess, conf->dir|RTP_SESSION_FLAG_NO_RTCP, conf->remote_rtp_ip, conf->remote_rtp_port, conf->remote_rtp_port+1);
 	rc = rtp_session_reset2(media->rtpsess, conf->dir, conf->remote_rtp_ip, conf->remote_rtp_port, conf->remote_rtp_port+1);
 	if (rc != 0) {
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_RTP_SESSION_RESET_FAILED, "audio rtp session reset failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("rtp_session_reset2 success!");
 	
 	status = audiobridge_create(media->pool, media->engine, &media->bridge);
 	if (status != APR_SUCCESS){
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_BRIDGE_CREATE_FAILED, "audio bridge create failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audiobridge_create success!");
 
 	status = apr_pool_create(&media->micspk_pool, media->pool);
 	if (status != APR_SUCCESS){
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_APR_POOL_CREATE_FAILED, "create media micspk_pool failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("apr_pool_create success!");
 
 	if (in_agc)
 		opt_micspk |= AMS2_OPT_AGC;
@@ -497,11 +479,9 @@ static int phonemedia_start(audio_session_t *session)
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_MICSPK2_CREATE_FAILED, "create audio micspk2(windows) failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audiomicspk2_create success!");
 	//音频回调
 	media->micspkstream->user_data = media;
 	media->micspkstream->on_rx_audio = &on_rx_audio;
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("init on_rx_audio success!");
 	//status = audiomicspk3_create(media->micspk_pool, media->engine, opt_micspk, AUDIO_CLOCK, in_dev, out_dev, &media->micspkstream);
 
 	if (out_agc || out_ns) {
@@ -511,13 +491,12 @@ static int phonemedia_start(audio_session_t *session)
 			write_opt |= AUDIO_DSP_AGC;
 		if (out_ns)
 			write_opt |= AUDIO_DSP_DENOISE;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audiomicspk2_create success!");
+
 		status = audiodsp_create(media->micspk_pool, media->engine, read_opt, write_opt, AUDIO_CLOCK, &media->dspstream);
 		if (status != APR_SUCCESS){
 			LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_DSP_CREATE_FAILED, "create audio dsp failed!");
 			goto on_error;
 		}
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audiodsp_create success!");
 	}
 #if 0
 	status = audioaec_create(media->pool, media->engine, AUDIO_CLOCK, FRAME_TIME, 
@@ -545,7 +524,6 @@ static int phonemedia_start(audio_session_t *session)
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_RTP_CREATE_FAILED, "create audio rtp failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio_session_t session addr is 0x%08x, audiortp_create success,and media->rtpstream addrs is 0x%08x!",session, media->rtpstream);
 
 	g_nAudioRecvNum = 0;
 	g_nAudioSendNum = 0;
@@ -624,7 +602,6 @@ static int phonemedia_start(audio_session_t *session)
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_CONTEXT_CREATE_FAILED, "create audio context failed!");
 		goto on_error;
 	}
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audiocontext_create success!");
 
 	audiocontext_add_driver(media->context, &media->bridge->base);
 	audioengine_start_context(media->engine, media->context);
@@ -672,20 +649,16 @@ static int phonemedia_stop(audio_session_t *session, int b_record_turn_off)
 		rtp_session_get_local_rtp_port(media->rtpsess, &ilocal_port);
 		rtp_session_destroy(media->rtpsess);
 		{
-			char strInfo[MAX_PATH] = { 0 };
-			_snprintf(strInfo, MAX_PATH, "audio rtp(media->rtpsess) destroy and local port is %u.", ilocal_port);
-			LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_RTP_DESTROY, strInfo);
+			LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_RTP_DESTROY, CSimpleStringA::Format("audio rtp(media->rtpsess) destroy and local port is %u.", ilocal_port).GetData());
 		}
 		media->rtpsess = NULL;
 	}
-	//if (media->aecstream) {
-	//	audioaec_destroy(media->aecstream);
-	//	media->aecstream = NULL;
-	//}
+
 	if (media->dspstream) {
 		audiodsp_destroy(media->dspstream);
 		media->dspstream = NULL;
 	}
+
 	if (media->micspkstream) {
 		audiomicspk2_destroy(media->micspkstream);
 		media->micspkstream = NULL;
@@ -736,9 +709,7 @@ static int phonemedia_chang_dev(audio_session_t *session, e_dev_type t)
 		//apr_status_t status;
 		audiocontext_remove_driver(media->context, &media->bridge->base);
 		if (media->micspkstream) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start audiomicspk2_destroy");
 			audiomicspk2_destroy(media->micspkstream);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start audiomicspk2_destroy success");
 			media->micspkstream = NULL;
 		}
 		if (media->dspstream) {
@@ -753,12 +724,11 @@ static int phonemedia_chang_dev(audio_session_t *session, e_dev_type t)
 			opt_micspk |= AMS2_OPT_NS;
 		if (aec)
 			opt_micspk |= AMS2_OPT_AEC;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start audiomicspk2_create");
+
 		audiomicspk2_create(media->micspk_pool, media->engine, opt_micspk, AUDIO_CLOCK, in_dev, out_dev, istoptype, t, &audio_device_event, &media->micspkstream);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start audiomicspk2_create success");
 		media->micspkstream->on_rx_audio = &on_rx_audio;
 		media->phonemedia_conf.dev_type = t;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("init change device on_rx_audio success!");
+
 		if (out_agc || out_ns) {
 			int read_opt = AUDIO_DSP_NONE;
 			int write_opt = AUDIO_DSP_NONE;
@@ -798,9 +768,7 @@ static int phonemedia_chang_dev(audio_session_t *session, e_dev_type t)
 		}
 
 		audiortp_reset_jitter(media->rtpstream);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("phonemedia_chang_dev start audiocontext_add_driver");
 		audiocontext_add_driver(media->context, &media->bridge->base);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("phonemedia_chang_dev start audiocontext_add_driver success");
 		return 0;
 	} else {
 		return Error_NotInit;
@@ -927,10 +895,8 @@ int audio_lib_init(int* incount, int* ioutcount, CSimpleStringA& strAudioIn, CSi
 		if (rc == 0) {
 			int i;
 			CSimpleStringA strJsonIn;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio input devices(%d):", icnt);
 			for (i = 0; i < icnt; ++i) {
 				CSimpleStringA str = audio_get_dev_name(true, i);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
 				strJsonIn += CSimpleStringA::Format("\"%d\":\"%s\",", i, str.GetData());
 				if (i == icnt - 1) {
 					strAudioIn = str;
@@ -944,10 +910,9 @@ int audio_lib_init(int* incount, int* ioutcount, CSimpleStringA& strAudioIn, CSi
 			LogWarn(Severity_Low, Error_Debug, LOG_EVT_SIPPHONE_GET_AUDIO_IN_INFOS, strJsonInData.GetData());
 
 			CSimpleStringA strJsonOut;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio output devices(%d):", ocnt);
 			for (i = 0; i < ocnt; ++i) {
 				CSimpleStringA str = audio_get_dev_name(false, i);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
+				//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%d = %s", i, str.GetData());
 				strJsonOut += CSimpleStringA::Format("\"%d\":\"%s\",", i, str.GetData());
 				if (i == ocnt - 1) {
 					strAudioOut = str;
@@ -1084,7 +1049,6 @@ int get_audio_dev_name(char*devname,char*in_dev,char*out_dev)
 {
 	int icnt, ocnt;
 	int rc = audio_get_dev_count(&icnt, &ocnt);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get audio input num=%d,output num=%d",icnt,ocnt);
 	if (rc == 0) 
 	{
 		int i;
@@ -1092,10 +1056,8 @@ int get_audio_dev_name(char*devname,char*in_dev,char*out_dev)
 		for (i = 0; i < icnt; ++i) 
 		{		
 			tmp = audio_get_dev_name(TRUE, i);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("input dev = %s!", tmp);
 			if (strstr(tmp,devname)!=NULL)
 			{
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get input dev = %s!", tmp);
 				memcpy(in_dev,tmp.GetData(),tmp.GetLength());
 				rc++;
 			}
@@ -1103,10 +1065,8 @@ int get_audio_dev_name(char*devname,char*in_dev,char*out_dev)
 		for (i = 0; i < ocnt; ++i) 
 		{
 			tmp = audio_get_dev_name(FALSE, i);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("output dev = %s!", tmp);
 			if (strstr(tmp,devname)!=NULL)
 			{
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get output dev = %s!", tmp);
 				memcpy(out_dev,tmp.GetData(),tmp.GetLength());
 				rc++;
 			}

+ 15 - 130
Module/mod_sipphone/win/endpoint.cpp

@@ -183,12 +183,8 @@ static const char* call_type_table[] = {
 static void endpoint_media_change_audio_dev(endpoint_call_t *call, e_dev_type current_dev_type)
 {
 	if (call->audio) {
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin audio_session_change_dev %d", current_dev_type);
-		char strmsg[MAX_PATH] = { 0 };
-		_snprintf(strmsg, MAX_PATH, "change audio device to %s mode.", DEV_PICKUP == current_dev_type ? "pickup" : "hand free");
-		LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_SWITCH, strmsg);
+		LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_SWITCH, CSimpleStringA::Format("change audio device to %s mode.", DEV_PICKUP == current_dev_type ? "pickup" : "hand free").GetData());
 		audio_session_change_dev(call->audio, current_dev_type);
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("end audio_session_change_dev");
 	}
 }
 
@@ -319,9 +315,7 @@ static void endpoint_media_update_video(endpoint_call_t *call, media_desc_t *vid
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video session failed! rc = %d", rc);
 			return;
 		}
-		else{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("make remote call session addr is 0x%08x.",call->video);
-		}
+
 		rc = video_session_start(call->video);
 		if (rc != 0) {
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("start video session failed! rc = %d", rc);
@@ -329,32 +323,24 @@ static void endpoint_media_update_video(endpoint_call_t *call, media_desc_t *vid
 			call->video = NULL;
 			return;
 		}
-		else{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("endpoint media update video, video session start success, and session is 0x%08x.", call->video);
-		}
 	}
 }
 
 static void endpoint_media_update_audio(endpoint_call_t *call, media_desc_t *audio_desc, int dev_type)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("audio dir:%d", audio_desc->media_dir);
 	if (audio_desc->media_dir == DIR_NONE) {
 		if (call->audio) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop audio...");
 			audio_session_stop(call->audio);
 			audio_session_destroy(call->audio);
 			call->audio = NULL;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop audio ok!");
 		}
 		else{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("call->audio is null.");
 		}
 		if (call->video) { // close video also 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop video...");
 			video_session_stop(call->video);
 			video_session_destroy(call->video);
 			call->video = NULL;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop video ok!");
 		}
 		else{
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("call->video is null.");
@@ -365,11 +351,9 @@ static void endpoint_media_update_audio(endpoint_call_t *call, media_desc_t *aud
 	} else {
 		int rc;
 		if (call->audio) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop audio...");
 			audio_session_stop(call->audio);
 			audio_session_destroy(call->audio);
 			call->audio = NULL;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop audio ok!");
 		}
 		if (!call->audio) {
 			endpoint_conf_t *ep_conf = &call->ep->conf;
@@ -417,9 +401,7 @@ static void endpoint_media_update_audio(endpoint_call_t *call, media_desc_t *aud
 		rc = audio_session_start_phonemedia(call->audio, &phone_conf);
 		if (rc != 0) 
 		{
-			char strmsg[MAX_PATH] = {0};
-			_snprintf(strmsg, MAX_PATH, "start audio session failed! rc = %d.", rc);
-			LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_INITFAIL, strmsg);
+			LogWarn(Severity_Low, Error_Debug, ERROR_MOD_SIP_AUDIO_INITFAIL, CSimpleStringA::Format("start audio session failed! rc = %d.", rc).GetData());
 			audio_session_destroy(call->audio);
 			call->audio = NULL;
 			return;
@@ -462,9 +444,7 @@ static const char *call_make_offer(endpoint_call_t *call, char *buf, int size)
 	int need;
 	const char *fmt;
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("make call offer,device type is %s, Call Type is %s", Device_Type_Table[call->eDeviceType], call_type_table[call->nCallType]);
-
-	if ((eMobilePadType == call->eDeviceType) || (ePadtype == call->eDeviceType)||(eDesk2SType == call->eDeviceType)||(eDesk1SType==call->eDeviceType)||(eDesk2SIntegratedType==call->eDeviceType)) //pad
+	if (eMobilePadType == call->eDeviceType) //pad
 	{
 		if(call->nCallType == NORMAL_CALLTYPE || call->nCallType == DOUBLERECORD_CALLTYPE)//如果是可视柜台模式以及外拓版
 		{
@@ -477,10 +457,8 @@ static const char *call_make_offer(endpoint_call_t *call, char *buf, int size)
 					"a=fmtp:18 annexb=no\r\n"
 					"a=ptime:30\r\n"
 					;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pad site = CMB.FLB");
 				if (0 != call->mapped_audio_port){
 					b_internet_access = true;
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Internet access mode.");
 				}
 			}
 			else
@@ -490,7 +468,6 @@ static const char *call_make_offer(endpoint_call_t *call, char *buf, int size)
 					"a=rtpmap:8 PCMA/8000\r\n"
 					"a=ptime:30\r\n"
 					;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pad site = CMB.LIB");
 			}
 
 			if (false == b_internet_access){
@@ -538,7 +515,6 @@ static const char *call_make_offer(endpoint_call_t *call, char *buf, int size)
 #endif
 			//"a=inactive\r\n" //for debug only
 			;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pad site != CMB.FLB");
 	}
 	
 	need = _scprintf(fmt, call->local_ip, local_audio_rtp_port);
@@ -687,10 +663,7 @@ static int get_media_direction(const sdp_media_t *lm, const sdp_media_t *rm)
 
 static int endpoint_get_ipaddress_by_domain(endpoint_call_t *call, const char* plocalip, char* premoteip, size_t ulen, const char* pdomain)
 {
-	if (0 == endpoint_getip_bydomain(premoteip, ulen, pdomain)){
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("domain is %s, and ip is %s.", pdomain, premoteip);
-	}
-	else{
+	if (0 != endpoint_getip_bydomain(premoteip, ulen, pdomain)){
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get ip by domain failed!");
 	}
 	if (0 == strlen(premoteip) || 0 == strcmp(plocalip, premoteip)){
@@ -829,9 +802,9 @@ static void negotiate_sdp(endpoint_call_t *call, const sdp_session_t *local_sdp,
 			translate_ipaddr_from_int(str_remote, RVC_MAX_IP_LEN, audio_desc.remote_ip);
 			endpoint_media_update_audio(call, &audio_desc, call->ep->curr_audio_dev_type);
 			call->last_media_desc_hash = hash_code;
-			char strmsg[MAX_PATH] = {0};
-			_snprintf(strmsg, MAX_PATH, "negotiate audio success!local audio ip=%s port=%d pt=%d,remote audio ip=%s port=%d,pt=%d",str_local,audio_desc.local_port,audio_desc.local_pt,str_remote,audio_desc.remote_port,audio_desc.remote_pt);
-			LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_CALL_AUDIO_NEGOTIATE, strmsg);
+			//char strmsg[MAX_PATH] = {0};
+			//snprintf(strmsg, MAX_PATH, "negotiate audio success!local audio ip=%s port=%d pt=%d,remote audio ip=%s port=%d,pt=%d",str_local,audio_desc.local_port,audio_desc.local_pt,str_remote,audio_desc.remote_port,audio_desc.remote_pt);
+			//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_CALL_AUDIO_NEGOTIATE, strmsg);
 		}
 	}
 
@@ -898,13 +871,9 @@ static void on_state(CONDITION_PARAMS)
 		SOATAG_LOCAL_SDP_STR_REF(local_sdp_str), 
 		TAG_END());
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("state = %d, offer_recv=%d, answer_recv=%d, offer_sent=%d, answer_sent=%d",
-		state, offer_recv, answer_recv, offer_sent, answer_sent);
-
 	switch (state) 
 	{
 	case nua_callstate_calling:
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_calling, has_local_sdp : %d, has_remote_sdp : %d", !!local_sdp_str, !!remote_sdp_str);
 		if (local_sdp_str) {
 			sdp_parser_t *parser = sdp_parse(call->home, local_sdp_str, strlen(local_sdp_str), -1);
 			assert(call->last_sdp == NULL);
@@ -914,8 +883,8 @@ static void on_state(CONDITION_PARAMS)
 		st = CALLING;
 		call->cb.on_call_state(st, state_desc[st], phrase, call->cb.user_data);
 		break;
+		
 	case nua_callstate_proceeding:
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_proceeding, status = %d, has_local_sdp: %d, has_remote_sdp : %d", status, !!local_sdp_str, !!remote_sdp_str);
 		st = PROCEEDING;
 		call->cb.on_call_state(st, state_desc[st], phrase, call->cb.user_data);
 		if (remote_sdp_str) {
@@ -929,9 +898,10 @@ static void on_state(CONDITION_PARAMS)
 			sdp_parser_free(parser);
 		}
 		break;
+		
 	case nua_callstate_completing:
 		st = COMPLETING;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_completing, has_local_sdp : %d, has_remote_sdp : %d", !!local_sdp_str, !!remote_sdp_str);
+		//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_completing, has_local_sdp : %d, has_remote_sdp : %d", !!local_sdp_str, !!remote_sdp_str);
 		call->cb.on_call_state(st, state_desc[st], phrase, call->cb.user_data);
 		if (remote_sdp_str) {
 			sdp_parser_t *parser = sdp_parse(call->home, remote_sdp_str, strlen(remote_sdp_str), -1);
@@ -945,7 +915,7 @@ static void on_state(CONDITION_PARAMS)
 		}
 		break;
 	case nua_callstate_completed:
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_completed, has_local_sdp : %d, has_remote_sdp : %d", !!local_sdp_str, !!remote_sdp_str);
+		//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_completed, has_local_sdp : %d, has_remote_sdp : %d", !!local_sdp_str, !!remote_sdp_str);
 		if (remote_sdp_str) {
 			if (!call->last_sdp) {
 				sdp_parser_t *parser = sdp_parse(call->home, remote_sdp_str, strlen(remote_sdp_str), -1);
@@ -966,7 +936,7 @@ static void on_state(CONDITION_PARAMS)
 		break;
 	case nua_callstate_ready:
 		call->connected = true;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_ready, has_local_sdp : %d, has_remote_sdp : %d.", !!local_sdp_str, !!remote_sdp_str);
+		//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_callstate_ready, has_local_sdp : %d, has_remote_sdp : %d.", !!local_sdp_str, !!remote_sdp_str);
 		st = READY;
 		call->cb.on_call_state(st, state_desc[st], phrase, call->cb.user_data);
 		if (remote_sdp_str) {
@@ -995,7 +965,7 @@ static void on_state(CONDITION_PARAMS)
 		break;
 	case nua_callstate_terminated:
 		st = TERMINATED;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("call terminated! in sofia thread!");
+		//DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("call terminated! in sofia thread!");
 		{
 			media_desc_t audio_desc = {0};
 			audio_desc.media_dir = DIR_NONE;
@@ -1014,8 +984,6 @@ void Terminatedcall(endpoint_call_t *call)
 {
 	int st = TERMINATED;
 	g_IsExternalTerminalted = TRUE;
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("g_IsExternalTerminalted = TRUE");
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("terminated! by timeout!");
 	{
 		media_desc_t audio_desc = {0};
 		audio_desc.media_dir = DIR_NONE;
@@ -1042,7 +1010,6 @@ static void endpoint_callback(nua_event_t   event,
 				if (hmagic == NULL) {
 					handle_invite(status, phrase, nua, (endpoint_t*)magic, nh, (endpoint_call_t*)hmagic, sip, tags);
 				} else {
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("reinvite!");
 					handle_reinvite(status, phrase, nua, (endpoint_t*)magic, nh, (endpoint_call_t*)hmagic, sip, tags);
 				}
 				break;
@@ -1053,11 +1020,9 @@ static void endpoint_callback(nua_event_t   event,
 
 			case nua_i_bye:
 				//.....
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_i_bye");
 				break;
 
 			case nua_i_info:
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_i_info");
 				break;
 
 			case nua_i_state:
@@ -1065,7 +1030,6 @@ static void endpoint_callback(nua_event_t   event,
 				break;
 
 			case nua_i_active:
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_i_active");
 				break;
 
 			case nua_i_options:
@@ -1074,15 +1038,12 @@ static void endpoint_callback(nua_event_t   event,
 				break;
 
 			case nua_r_cancel:
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_r_cancel");
 				if (status > 300) {
 					nua_bye(nh, TAG_END());
 				}
 				break;
 			case nua_i_prack:
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_i_prack");
 			case nua_r_prack:
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("nua_r_prack");
 				break;
 
 			case nua_r_bye:
@@ -1182,7 +1143,7 @@ static endpoint_t *__endpoint_create(CEntityBase *pEntity, const endpoint_conf_t
 	return ep;
 }
 
-static void __endpoint_destroy(endpoint_t *ep)\
+static void __endpoint_destroy(endpoint_t *ep)
 {
 	su_root_destroy(ep->root);
 	su_home_deinit(ep->home);
@@ -1289,14 +1250,10 @@ void endpoint_change_audio_dev(endpoint_t *ep, int dev_type)
 		if (ep->curr_audio_dev_type != dev_type) {
 			ep->curr_audio_dev_type = dev_type;
 			if (ep->active_call) {
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin invoke media change audio device!");
 				endpoint_media_change_audio_dev(ep->active_call, (e_dev_type)dev_type);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("end invoke media change audio device!");
 			} else {
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("active call is null!");
 			}
-		} else {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("current dev_type is the same as dev_type!");
 		}
 	}
 }
@@ -1343,7 +1300,6 @@ endpoint_call_t *endpoint_call_create(endpoint_t *ep, const endpoint_call_params
 	}
 	call->eDeviceType = pcallparam->nDeviceType;
 	call->nCallType = pcallparam->nCallType;
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("endpoint_call_create nCallType = %d.", pcallparam->nCallType);
 	memcpy(&call->cb, cb, sizeof(endpoint_call_callback_t));
 	memcpy(&call->func_cb, func_cb, sizeof(endpoint_function_callback_s));
 	call->id = new_call_id(ep);
@@ -1365,53 +1321,6 @@ on_error:
 }
 
 
-//endpoint_call_t *endpoint_call_create(endpoint_t *ep, const char *to_uri, const char *from_uri, const char *call_id, const char*local_ip, DeviceTypeEnum nDeviceType,CallingTypeEnum nCallType,const endpoint_call_callback_t *cb)
-//{
-//	endpoint_call_t *call = NULL;
-//	su_home_t *home = NULL; 
-//
-//	if (!to_uri)
-//		return NULL;
-//
-//	home = su_home_create();
-//	if (!home)
-//		goto on_error;
-//	call = (endpoint_call_t*)su_home_new(sizeof(endpoint_call_t));
-//	if (!call)
-//		goto on_error;
-//	memset(call, 0, sizeof(endpoint_call_t));
-//	call->connected = 0;
-//	call->ep = ep;
-//	call->home = home;
-//	call->last_media_desc_hash = 0;
-//	call->to_uri = su_strdup(home, to_uri);
-//	if (from_uri != NULL){
-//		call->from_uri = su_strdup(home, from_uri);
-//	}
-//	if (call_id != NULL){
-//		call->call_id = su_strdup(home, call_id);
-//	}
-//	memcpy(call->local_ip,local_ip,RVC_MAX_IP_LEN);
-//	call->eDeviceType = nDeviceType;
-//	call->nCallType = nCallType;
-//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("endpoint_call_create nCallType = %d.", nCallType);
-//	memcpy(&call->cb, cb, sizeof(endpoint_call_callback_t));
-//	call->id = new_call_id(ep);
-//	call->local_media_port = new_media_port(ep);
-//	call->local_video_port = REC_COMMON_VIDEO_PORT;
-//	REF_COUNT_INIT(&call->ref_cnt);
-//	list_add_tail(&call->entry, &ep->call_list);
-//	ep->active_call = call;
-//
-//	return call;
-//
-//on_error:
-//	if (home)
-//		su_home_unref(home);
-//
-//	return call;
-//}
-
 void endpoint_call_destroy(endpoint_call_t *call)
 {
 	endpoint_call_dec_ref(call);
@@ -1454,9 +1363,6 @@ int endpoint_call_start(endpoint_call_t *call)
 
 	call_make_offer(call, sdp, -1);
 	if (0 == strlen(sdp)){
-	//	LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_SDP_INFO, sdp);
-	//} 
-	//else{
 		LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_INVALID_SDP, "invalid sdp.");
 	}
 
@@ -1483,11 +1389,6 @@ int endpoint_call_hangup(endpoint_call_t *call)
 }
 
 
-#ifndef BUFFER_SIZE
-#define BUFFER_SIZE 256
-#endif
-
-
 int endpoint_call_start_video(endpoint_call_t *call, unsigned long remote_ip, int remote_video_rtp, 
 	unsigned long local_ip, int local_video_rtp, 
 	int remote_width, int remote_height,
@@ -1501,7 +1402,6 @@ int endpoint_call_start_video(endpoint_call_t *call, unsigned long remote_ip, in
 	translate_ipaddr_from_int(local_ip_str, RVC_MAX_IP_LEN, local_ip);
 	translate_ipaddr_from_int(remtote_ip_str, RVC_MAX_IP_LEN, remote_ip);
 	
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Assist channel video local: %s:%d, remote_ip:%s:%d", local_ip_str, local_video_rtp, remtote_ip_str, remote_video_rtp);
 	if (call) 
 	{
 		int i = 0;
@@ -1543,7 +1443,6 @@ int endpoint_call_start_video(endpoint_call_t *call, unsigned long remote_ip, in
 		translate_ipaddr_from_int(str_local_ip, RVC_MAX_IP_LEN,video_desc.local_ip);
 		translate_ipaddr_from_int(str_remtote_ip, RVC_MAX_IP_LEN, video_desc.remote_ip);
 
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start video,local video ip=%s port=%d pt=%d,remote ip=%s port=%d pt=%d",str_local_ip,video_desc.local_port,video_desc.local_pt,str_remtote_ip,video_desc.remote_port,video_desc.remote_pt);
 		return 0;
 	} 
 	else 
@@ -1692,9 +1591,6 @@ int local_remote_show_video(endpoint_call_t *call,int local_view_x, int local_vi
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video session failed! rc = %d", rc);
 		return -1;
 	}
-	else{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create video session success!");
-	}
 
 	rc = video_session_start(call->video);
 	if (rc != 0){
@@ -1703,9 +1599,6 @@ int local_remote_show_video(endpoint_call_t *call,int local_view_x, int local_vi
 		call->video = NULL;
 		return -1;
 	}
-	else{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local remote show video success start video session 0x%08x.", call->video);
-	}
 
 	return 0;
 }
@@ -1726,14 +1619,11 @@ int local_play_stop_video(endpoint_call_t *call)
 
 static void __endpoint_call_destroy(endpoint_call_t *call)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("endpoint call destroy! home ref:%d", su_home_refcount(call->home));
 	list_del(&call->entry);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("endpoint call destroy! after list del.");
 	if (call->ep && call->ep->active_call == call) {
 		call->ep->active_call = NULL;
 	}
 	su_home_unref(call->home);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("endpoint call destroy! after su_home_unref.");
 }
 
 
@@ -1766,21 +1656,16 @@ int endpoint_getip_bydomain(char* strbuffer, size_t ulen, const char* pdomain)
 		return iret;
 	}
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("domain is %s.", pdomain);
-
 	phst = gethostbyname(pdomain);
 	if (!phst){
 		return iret;
 	}
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("address type is %s.", (phst->h_addrtype == AF_INET) ? "AF_INET" : "AF_INET6");
 	for (; phst->h_aliases[i]; i++){
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("aliases %d:%s.", i+1, phst->h_aliases[i]);
 	}
 
 	for (i = 0; phst->h_addr_list[i]; i++){
 		char* strip = inet_ntoa(*(struct in_addr*)phst->h_addr_list[i]);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("domain is %s, and ip address %d:%s.",pdomain, i+1, strip);
 		if (0 == i){
 			if (NULL != strip){
 				_snprintf(strbuffer, ulen, "%s", strip);

文件差异内容过多而无法显示
+ 125 - 292
Module/mod_sipphone/win/mod_sipphone.cpp


+ 8 - 230
Module/mod_sipphone/win/video_session.cpp

@@ -5,6 +5,7 @@
 #include "videoframework.h"
 #include "memutil.h"
 #include <ObjBase.h>
+
 #include "videohorflip.h"
 
 #include "opencv2/opencv.hpp"
@@ -57,13 +58,6 @@ video_session_t* pg_last_session = NULL;		// last used session
 #define DEVICE_STANDARD_TYPE		0
 #define DEVICE_PAD_TYPE				1
 #define DEVICE_MOBILEPAD_TYPE		2
-//#define FPS_KEEP_TIME 3
-//动态调整下行帧频,用于移动版,暂时不用,移动版自动将帧频降到1帧/s
-//int g_nSysFps = 0;
-//int g_nDynamicFps = 0;   //当前动态帧频
-//DWORD g_nLastRecFrameTime = 0;  //上一秒收到的第一帧视频的时间
-//int nRecvFrameNum = 0;   //一秒钟内收到的视频帧数
-//int nFpsKeepTime = 0;  //每个帧频保持时间3s,防止频繁跳动
 
 
 static void __dbg(void *user_data, const char *fmt, va_list arg)
@@ -195,7 +189,6 @@ static int video_shm_enqueue(Clibvideoqueue *shm_queue, video_frame *frame, int
 	} 
 	else 
 	{
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("insert shm video ok!");
 		return Error_Succeed;
 	}
 }
@@ -528,7 +521,6 @@ static int on_pull(videoplayer_t *player, void *user_data, video_frame **frame)
 					IplImage*img = cvLoadImage(strPath,1);
 					if (img != NULL)
 					{
-						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("load img success");
 						session->video_error = new videoq_frame;
 						session->video_error->format = VIDEOQ_FORMAT_RGB24;
 						session->video_error->framesize = img->imageSize;
@@ -752,7 +744,6 @@ static int get_local_video_frame(void* user_data, video_frame** frame)
 					IplImage* img = cvLoadImage(strPath, 1);
 					if (img != NULL)
 					{
-						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("load img success");
 						session->video_error = new videoq_frame;
 						session->video_error->format = VIDEOQ_FORMAT_RGB24;
 						session->video_error->framesize = img->imageSize;
@@ -882,7 +873,6 @@ static int get_local_video_frame(void* user_data, video_frame** frame)
 
 int show_agent_picture_proc(void *arg)
 {
-	LOG_FUNCTION();
 	picture_record_t *t_record = (picture_record_t*)arg;
 	if (NULL == t_record){
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("show_agent_picture_proc param valid.");
@@ -910,7 +900,7 @@ int show_agent_picture_proc(void *arg)
 					int rc = video_shm_enqueue(t_record->session->video_shm_q_remote, t_record->record_frame, VIDEOQUEUE_FLAG_VERTICAL_FLIP, iframeid++);
 					if (rc != Error_Succeed) 
 					{
-						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("mobile mod insert remote video to queue.");
+						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("mobile mod insert remote video to queue failed.");
 					}
 				}
 
@@ -925,7 +915,6 @@ int show_agent_picture_proc(void *arg)
 			}
 		} 
 		else {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("show_agent_picture_proc thread exit.");
 			break;
 		}
 	}
@@ -1001,8 +990,6 @@ static int agent_picture_video_start(picture_record_t* t_record)
 
 static int agent_picture_video_stop(picture_record_t* t_record)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("agent picture video stop called, stop static picture show thread.");
-
 	if (t_record->evt) {
 		SetEvent(t_record->evt);
 		if (t_record->work_thread) {
@@ -1031,8 +1018,6 @@ static int agent_picture_video_stop(picture_record_t* t_record)
 		t_record->show_frame = NULL;
 	}
 
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("stop static picture show thread end.");
-
 	return 0;
 }
 
@@ -1102,7 +1087,6 @@ static void	show_remote_agnet_picture(video_session_t *t_session)
 		videoq_frame* vframe = new videoq_frame;
 		if (img != NULL)
 		{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("load img success");
 			vframe->format = VIDEOQ_FORMAT_RGB24;
 			vframe->framesize = img->imageSize;
 			vframe->width = img->width;
@@ -1134,7 +1118,7 @@ static void	show_remote_agnet_picture(video_session_t *t_session)
 		int rc = video_shm_enqueue(t_session->video_shm_q_remote, remote_frame, VIDEOQUEUE_FLAG_VERTICAL_FLIP, 1);
 		if (rc != Error_Succeed) 
 		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("insert agent picture to remote video queue.");
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("insert agent picture to remote video queue failed.");
 		}
 	}
 
@@ -1146,13 +1130,11 @@ static void	show_remote_agnet_picture(video_session_t *t_session)
 		video_frame_copy(showframe, remote_frame);
 	}
 	
-	
 	t_session->pic_record = new picture_record_t();
 	t_session->pic_record->record_frame = remote_frame;
 	t_session->pic_record->show_frame = showframe;
 	t_session->pic_record->session = t_session;
 
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin agent static picture show thread.");
 	agent_picture_video_start(t_session->pic_record);
 }
 
@@ -1207,9 +1189,6 @@ static int start_video_rtpsession(video_session_t* session)
 		videortp_destroy(session->rtp);
 		session->rtp = NULL;
 	}
-	else {
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videortp_start success.");
-	}
 
 	return rc;
 }
@@ -1237,8 +1216,6 @@ static int start_local_video_clock(video_session_t* session)
 			&local_put_frame, session, &local_get_frame, session, &session->local_clock, session->conf.ref_Up_Fps, &__dbg);
 	}
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create session->local_clock addr is 0x%08x", session->local_clock);
-
 	if (0 == rc) {
 		rc = videoclock_start(session->local_clock);
 		if (rc != 0) {
@@ -1246,9 +1223,6 @@ static int start_local_video_clock(video_session_t* session)
 			videoclock_destroy(session->local_clock);
 			session->local_clock = NULL;
 		}
-		else {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videoclock start success!");
-		}
 	}
 	else {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video clock failed!");
@@ -1272,9 +1246,6 @@ static int start_video(video_session_t *session)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get session->local_encode_sws_ctx_env failed.");
 			goto on_error;
 		}
-		else{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get session->local_encode_sws_ctx_env succ.");
-		}
 	}
 	else{
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("session->video_shm_q_env is NULL.");
@@ -1290,19 +1261,13 @@ static int start_video(video_session_t *session)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get session->local_encode_sws_ctx_opt failed.");
 			goto on_error;
 		}
-		else{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("get session->local_encode_sws_ctx_opt succ.");
-		}
 	}
 	else{
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("session->video_shm_q_opt is NULL.");
 	}
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("session nCallType is %d, remote_video_view_cx = %d,remote_video_view_cy = %d,remote_video_width = %d,remote_video_height = %d.", session->conf.nCallType,session->conf.remote_video_view_cx,session->conf.remote_video_view_cy,session->conf.remote_video_width,session->conf.remote_video_height);
-
 	if (eGDI == session->conf.eType){
 		if (DOUBLERECORD_CALLTYPE != session->conf.nCallType){
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create new remote video player");
 			if (session->remote_hwnd)
 			{
 				if (session->conf.eDeviceType == eMobilePadType)
@@ -1323,14 +1288,10 @@ static int start_video(video_session_t *session)
 						NULL,
 						session,
 						&session->remote_player);
-					if (rc != 0) 
-					{
+					if (rc != 0) {
 						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create remote video player failed!");
 						goto on_error;
 					}
-					else{
-						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create remote video player success!");
-					}
 				}
 				else if((session->conf.eDeviceType == ePadtype)||(session->conf.eDeviceType == eDesk2SType)||(session->conf.eDeviceType == eDesk1SType)||(session->conf.eDeviceType == eDesk2SIntegratedType))
 				{
@@ -1354,9 +1315,6 @@ static int start_video(video_session_t *session)
 						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create remote video player failed!");
 						goto on_error;
 					}
-					else{
-						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create remote video player success!");
-					}
 				}
 				else if(session->conf.eDeviceType == eStand2sType)
 				{
@@ -1376,16 +1334,11 @@ static int start_video(video_session_t *session)
 						NULL,
 						session,
 						&session->remote_player);
-					if (rc != 0) 
-					{
+					if (rc != 0) {
 						DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create remote video player failed!");
 						goto on_error;
 					}
-					else{
-						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create remote video player success remote_video_width = %d,remote_video_height = %d.", session->conf.remote_video_width, session->conf.remote_video_height);
-					}
 				}
-
 			}
 			else
 			{
@@ -1396,10 +1349,6 @@ static int start_video(video_session_t *session)
 			if (NULL != pg_last_session){
 				session->remote_player = pg_last_session->remote_player;
 				rc = 0;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("double record call remote_player reuse.");
-			}
-			else{
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pg_last_session is NULL, and call type is %d.", session->conf.nCallType);
 			}
 		}
 
@@ -1417,7 +1366,6 @@ static int start_video(video_session_t *session)
 		}
 
 		if (DOUBLERECORD_CALLTYPE != session->conf.nCallType){
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create new local video player");
 			if (session->conf.eDeviceType == eMobilePadType){
 				rc = videoplayer_create(session->local_hwnd, 
 					0,
@@ -1437,9 +1385,6 @@ static int start_video(video_session_t *session)
 					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create local video player failed!");
 					goto on_error;
 				}
-				else{
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create local video player success!");
-				}
 			} 
 			else if((session->conf.eDeviceType == ePadtype)||(session->conf.eDeviceType == eDesk2SType)||(session->conf.eDeviceType == eDesk1SType)||(session->conf.eDeviceType == eDesk2SIntegratedType))
 			{
@@ -1462,9 +1407,6 @@ static int start_video(video_session_t *session)
 					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create local video player failed!");
 					goto on_error;
 				}
-				else{
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create local video player success!");
-				}
 			}	
 			else if(session->conf.eDeviceType == eStand2sType)
 			{
@@ -1486,9 +1428,6 @@ static int start_video(video_session_t *session)
 					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create local video player failed!");
 					goto on_error;
 				}
-				else{
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create local video player success!");
-				}
 			}
 		}
 		else{
@@ -1520,7 +1459,6 @@ static int start_video(video_session_t *session)
 			}
 			else{
 				pg_last_session = session;			//保存session信息
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin show agent static picture.");
 				show_remote_agnet_picture(session);
 			}
 		}
@@ -1530,10 +1468,6 @@ static int start_video(video_session_t *session)
 			if (NULL != pg_last_session) {
 				session->premote_render = pg_last_session->premote_render;
 				session->plocal_render = pg_last_session->plocal_render;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("double record call local and remote render reuse.");
-			}
-			else {
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("pg_last_session is NULL, and call type is %d.", session->conf.nCallType);
 			}
 		}
 
@@ -1557,7 +1491,6 @@ static int start_video(video_session_t *session)
 				}
 			}
 			else {
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin show agent static picture.");
 				show_remote_agnet_picture(session);
 			}
 		}
@@ -1573,9 +1506,7 @@ static void stop_video(video_session_t *session)
 {
 	LOG_FUNCTION();
 	if (eGDI == session->conf.eType){
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("stop_video param video_session 0x%08x, session->local_clock is 0x%08x, session->remote_hwnd is 0x%08x.", session, session->local_clock, session->remote_hwnd);
 		if (session->local_clock && session->remote_hwnd){
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videoclock_stop local_clock addr is 0x%08x", session->local_clock);
 			videoclock_stop(session->local_clock);
 			videoclock_destroy(session->local_clock);
 			session->local_clock = NULL;
@@ -1585,7 +1516,6 @@ static void stop_video(video_session_t *session)
 	}
 	else{
 		if (session->local_clock){
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videoclock_stop local_clock addr is 0x%08x", session->local_clock);
 			videoclock_stop(session->local_clock);
 			videoclock_destroy(session->local_clock);
 			session->local_clock = NULL;
@@ -1593,7 +1523,6 @@ static void stop_video(video_session_t *session)
 	}
 
 	if (session->rtp){
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin stop video rtp.");
 		videortp_stop(session->rtp);
 		videortp_destroy(session->rtp);
 		session->rtp = NULL;
@@ -1606,13 +1535,11 @@ static void stop_video(video_session_t *session)
 		if (session->local_player) {
 			videoplayer_destroy(session->local_player);
 			session->local_player = NULL;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local video player destroy.");
 		}
 
 		if (session->remote_player && session->remote_hwnd){
 			videoplayer_destroy(session->remote_player);
 			session->remote_player = NULL;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("remote video player destroy.");
 		}
 	} 
 	else{
@@ -1645,7 +1572,6 @@ static bool ReMoveOutOfScreenVideoWindow(HWND hWnd, RECT rect)
 
 	int iScreenWidth = GetSystemMetrics(SM_CXSCREEN);
 	int iScreenHight = GetSystemMetrics(SM_CYSCREEN);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ScreenWidth = %d, ScreenHight = %d.", iScreenWidth, iScreenHight);
 
 	int iVideoWidth = rect.right - rect.left;
 	int iVideoHight = rect.bottom - rect.top;
@@ -1761,16 +1687,13 @@ static int HandleVideoMoveEvent(int iMessageType, HWND hWnd, video_session_t* pS
 	bool bMoved = false;
 	RECT rect;
 	GetWindowRect(hWnd, &rect);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("MessageType = %d, VideoType = %d, rect.left = %d, rect.right = %d, rect.bottom = %d, rect.top = %d", iMessageType, iVideoType, rect.left, rect.right, rect.bottom, rect.top);
-
+	
 	RECT otherect;
 	GetWindowRect(hOtherWnd, &otherect);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("other video Window left = %d, right = %d, bottom = %d, top = %d", otherect.left, otherect.right, otherect.bottom, otherect.top);
 
 	bMoved = ReMoveVideoWindow(hWnd, rect, otherect);
 
 	if (bMoved) {
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("has removed video window.");
 		GetWindowRect(hWnd, &rect);
 	}
 
@@ -1789,17 +1712,13 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
 	switch (msg) {
 	case WM_DESTROY:
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("WndProc session addr is 0x%08x, and receive WM_DESTROY.", session);
 		if (session->local_hwnd == hWnd) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("session->local_hwnd = 0");
 			session->local_hwnd = 0;
 		}
 		else if (session->remote_hwnd == hWnd) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("session->remote_hwnd = 0");
 			session->remote_hwnd = 0;
 		}
 		if (session->local_hwnd == 0 && session->remote_hwnd == 0) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("*****PostQuitMessage****");
 			PostQuitMessage(0);
 		}
 		return 0;
@@ -1836,7 +1755,6 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 	case WM_LBUTTONDBLCLK:
 	case WM_LBUTTONDOWN:
 	case WM_LBUTTONUP:
-		OutputDebugStringA("mouse clicked!");
 		if (session) {
 			if (session->local_hwnd) {
 				//ReleaseCapture();
@@ -1845,30 +1763,24 @@ static LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
 		return 0;
 	case WM_CLOSE:
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("WndProc session addr is 0x%08x, and receive WM_CLOSE", session);
 		stop_video(session);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("WndProc SetEvent session addr is 0x%08x.", session);
 		//SetEvent(session->ui_thread);	
 		DestroyWindow(session->local_hwnd);
 		//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_WINDOW_DESTROY_SUCCESS, "destroy local window.");
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("destroy local window.");
 		DestroyWindow(session->remote_hwnd);
 		//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_REMOTE_WINDOW_DESTROY_SUCCESS, "destroy remote window.");
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("destroy remote window.");
 		return 0;
 	case WM_MOVE:
 		break;
 
 	case WM_ENTERSIZEMOVE:
 		{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("***WM_ENTERSIZEMOVE***");
 			HandleVideoMoveEvent(0, hWnd, session);
 		}
 		break;
 
 	case WM_EXITSIZEMOVE:
 		{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("***WM_EXITSIZEMOVE***");
 			HandleVideoMoveEvent(1, hWnd, session);
 		}
 		break;
@@ -1884,8 +1796,6 @@ static unsigned int __stdcall ui_proc(void *arg)
 {
 	video_session_t *session = (video_session_t*)arg;
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ui_proc session addr is 0x%08x", session);
-
 	WNDCLASSA wc = {0};
 	ATOM a = 0;
 	HWND hWnd = NULL;
@@ -1903,13 +1813,8 @@ static unsigned int __stdcall ui_proc(void *arg)
 		session->local_hwnd = pg_local_hwnd;
 		//SetWindowLongPtrA(session->local_hwnd, GWLP_USERDATA, (LONG_PTR)session);
 		breuse_local_wnd = true;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local video hwnd reuse.");
 	}
 	else{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create local video hwnd and x = %d, y = %d, width = %d, height = %d.",
-			session->conf.local_video_view_x, session->conf.local_video_view_y, session->conf.local_video_view_cx, session->conf.local_video_view_cy);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local video move flag is %d, remote video move flag is %d.", session->conf.local_move, session->conf.remote_move);
-		
 		if (0 != session->conf.local_move){
 			dLocal_style -= WS_EX_NOACTIVATE;
 		}
@@ -1946,7 +1851,6 @@ static unsigned int __stdcall ui_proc(void *arg)
 			}
 			pg_local_hwnd = session->local_hwnd;
 			//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_LOCAL_WINDOW_CREATE_SUCCESS, "create local window success and restore local video hwnd.");
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create local window success and restore local video hwnd.");
 		}
 		else{
 			char strinfo[MAX_PATH] = {0};
@@ -1961,16 +1865,12 @@ static unsigned int __stdcall ui_proc(void *arg)
 	{
 		if (NULL != pg_remote_hwnd){
 			session->remote_hwnd = pg_remote_hwnd;
-			//SetWindowLongPtrA(session->remote_hwnd, GWLP_USERDATA, (LONG_PTR)session);
 			breuse_remote_wnd = true;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("remote video hwnd reuse.");
 			if (NULL != pg_last_session){
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SetEvent pg_last_session->ui_event and ui_event addr is 0x%08x.", pg_last_session->ui_event);
 				record_agent_picture_show_session_destory(pg_last_session);
 			}
 		}
 		else{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create remote video hwnd x = %d, y = %d, width = %d, height = %d.", session->conf.remote_video_view_x, session->conf.remote_video_view_y, session->conf.remote_video_view_cx, session->conf.remote_video_view_cy);
 			session->remote_hwnd = CreateWindowExA(dRemote_style, 
 				WNDCLS_NAME, NULL, WS_POPUP|WS_VISIBLE, 
 				session->conf.remote_video_view_x, session->conf.remote_video_view_y, session->conf.remote_video_view_cx, session->conf.remote_video_view_cy, 
@@ -1982,7 +1882,6 @@ static unsigned int __stdcall ui_proc(void *arg)
 				}
 				pg_remote_hwnd = session->remote_hwnd;
 				//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_REMOTE_WINDOW_CREATE_SUCCESS, "create remote window success and restore remote video hwnd.");
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("create remote window success and restore remote video hwnd.");
 			}
 			else{
 				char strinfo[MAX_PATH] = {0};
@@ -1994,7 +1893,6 @@ static unsigned int __stdcall ui_proc(void *arg)
 	}
 	else
 	{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("remote_hwnd == Null");
 		session->remote_hwnd = NULL;
 	}
 
@@ -2004,7 +1902,6 @@ static unsigned int __stdcall ui_proc(void *arg)
 
 		ShowCursor(FALSE);
 
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SetEvent1 session addr is 0x%08x.", session);
 		SetEvent(session->ui_event);
 		rc = start_video(session);
 		if (rc != 0) {
@@ -2016,14 +1913,13 @@ static unsigned int __stdcall ui_proc(void *arg)
 			while (GetMessageA(&msg, NULL, NULL, NULL)) 
 			{
 				if (msg.message == WM_CLOSE) {
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("session addr is 0x%08x, session->local_hwnd is 0x%08x, rx WM_CLOSE", session, session->local_hwnd);
+
 				}
 
 				TranslateMessage(&msg);
 				DispatchMessageA(&msg);
 			}
 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SetEvent2 session addr is 0x%08x.", session);
 			SetEvent(session->ui_event);
 		}
 	}
@@ -2059,16 +1955,10 @@ static unsigned int __stdcall videorender_func(void* arg)
 {
 	LOG_FUNCTION();
 	video_session_t* session = (video_session_t*)arg;
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d session addr is 0x%08x, session->plocal_render = 0x%08x", __FUNCTION__, __LINE__, session, session->plocal_render);
 	char str_local_ip[MAX_PATH_SIZE] = { 0 };
 	char str_remote_ip[MAX_PATH_SIZE] = { 0 };
 	translate_ipaddr_from_int(str_local_ip, MAX_PATH_SIZE, session->conf.local_rtp_ip);
 	translate_ipaddr_from_int(str_remote_ip, MAX_PATH_SIZE, session->conf.remote_rtp_ip);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videorender_func local_pt: %d local_ip: %s local_rtp_port: %d.", session->conf.local_pt, str_local_ip, session->conf.local_rtp_port);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videorender_func remote_pt: %d remote_ip: %s remote_rtp_port: %d.", session->conf.remote_pt, str_remote_ip, session->conf.remote_rtp_port);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("videorender_func rx_width: %d rx_height: %d.", session->conf.remote_video_width, session->conf.remote_video_height);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d local(%d,%d,%d,%d) remote(%d,%d,%d,%d).", __FUNCTION__, __LINE__, session->conf.local_video_view_x, session->conf.local_video_view_y, session->conf.local_video_view_cx, session->conf.local_video_view_cy,
-		session->conf.remote_video_view_x, session->conf.remote_video_view_y, session->conf.remote_video_view_cx, session->conf.remote_video_view_cy);
 
 	videorender_callback_t t_callback = { 0 };
 	t_callback.debug = &__video_render_log;
@@ -2076,7 +1966,6 @@ static unsigned int __stdcall videorender_func(void* arg)
 	//双录两阶段视频窗口复用
 	if (NULL != pg_local_render){
 		session->plocal_render = (IVideoRender*)pg_local_render;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("local video render reuse.");
 	}
 	else{
 		session->plocal_render = CreateVideoRenderObj(&t_callback);
@@ -2094,7 +1983,6 @@ static unsigned int __stdcall videorender_func(void* arg)
 				session->plocal_render->HideVideoWindow();
 			}
 			else {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d set video render param failed!", __FUNCTION__, __LINE__);
 				return 0;
 			}
 			pg_local_render = session->plocal_render;
@@ -2102,10 +1990,8 @@ static unsigned int __stdcall videorender_func(void* arg)
 	}
 
 	if (session->conf.remote_video_view_x || session->conf.remote_video_view_y || session->conf.remote_video_view_cx || session->conf.remote_video_view_cy){
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d create remote video hwnd x = %d, y = %d, width = %d, height = %d.", __FUNCTION__, __LINE__, session->conf.remote_video_view_x, session->conf.remote_video_view_y, session->conf.remote_video_view_cx, session->conf.remote_video_view_cy);
 		if (NULL != pg_local_render){
 			session->premote_render = (IVideoRender*)pg_remote_render;
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("remote video render reuse.");
 		}
 		else{
 			session->premote_render = CreateVideoRenderObj(&t_callback);
@@ -2154,11 +2040,9 @@ static unsigned int __stdcall videorender_func(void* arg)
 				if (iwindowstate != session->ilast_windstae){
 					set_video_windows(session, iwindowstate);
 					session->ilast_windstae = iwindowstate;
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d, window state is %d.", __FUNCTION__, __LINE__, iwindowstate);
 				}
 				
 				if (NULL != local_video_frame) {
-					//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d, video size is (%d,%d), showPersonArea flag is %d.", __FUNCTION__, __LINE__, local_video_frame->width, local_video_frame->height, *session->conf.ref_Is_showPersonArea);
 					video_frame* localframe = NULL;
 					if (0 == translate_image_resolution(&localframe, session->conf.local_video_view_cx, session->conf.local_video_view_cy, local_video_frame)) {
 						session->plocal_render->RenderVideoFrame(localframe, RVC_FLIP_VERTICAL);
@@ -2172,12 +2056,8 @@ static unsigned int __stdcall videorender_func(void* arg)
 					video_frame_delete(local_video_frame);
 					local_video_frame = NULL;
 				}
-				else {
-					//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d,get video from shm preview queue failed!", __FUNCTION__, __LINE__);
-				}
 			}
 			else {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d videorender_func exit!", __FUNCTION__, __LINE__);
 				session->plocal_render->HideVideoWindow();
 				break;
 			}
@@ -2199,16 +2079,11 @@ static unsigned int __stdcall videorender_func(void* arg)
 
 static int start_ui(video_session_t *session)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("start ui session addr is 0x%08x", session);
-
 	session->ui_event = CreateEventA(NULL, FALSE, FALSE, NULL);
 	if (!session->ui_event) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("phonemedia_start create ui event failed!");
 		return Error_Resource;
 	}
-	else{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("session->ui_event = 0x%08x.", session->ui_event);
-	}
 
 	if (eGDI == session->conf.eType){
 		session->ui_thread = (HANDLE)_beginthreadex(NULL, 0, &ui_proc, session, 0, NULL);
@@ -2223,23 +2098,16 @@ static int start_ui(video_session_t *session)
 		session->ui_event = NULL;
 		return Error_Resource;
 	}
-	else{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("session 0x%08x create session->ui_thread = 0x%08x.", session, session->ui_thread);
-	}
 
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ui thread created ok!");
 	{
 		HANDLE hs[] = {session->ui_event, session->ui_thread};
 		DWORD dwRet = WaitForMultipleObjects(array_size(hs), hs, FALSE, INFINITE);
 		if (dwRet == WAIT_OBJECT_0) { // 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("wait for ui ready event ok!");
+			
 		} else if (dwRet == WAIT_OBJECT_0 + 1) { // thread exit
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ui thread aborted unexpected!");
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_thread 0x%08x.", session->ui_thread);
 			CloseHandle(session->ui_thread);
 			session->ui_thread = NULL;
 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_event 0x%08x.", session->ui_event);
 			CloseHandle(session->ui_event);
 			session->ui_event = NULL;
 			return Error_Resource;
@@ -2249,30 +2117,8 @@ static int start_ui(video_session_t *session)
 }
 
 
-	//if (0 != sem_init(&session->ui_stop_sem, 0, 0)) {
-	//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d create ui stop event failed!", __FUNCTION__, __LINE__);
-	//	return Error_Resource;
-	//}
-	//else{
-	//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("%s:%d create ui stop event success!", __FUNCTION__, __LINE__);
-	//}
-	//int err = pthread_create(&session->ui_threadid, NULL, videorender_func, session);
-	//if (0 == err) {
-	//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video render thread success, thread id is %u.", session->ui_threadid);
-	//}
-	//else {
-	//	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create video render thread failed.");
-	//	return Error_Resource;
-	//}
-
-	//return err;
-
-
-
 static void stop_ui(video_session_t *session)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("%s:%d session addr is 0x%08x.", __FUNCTION__, __LINE__, session);
-
 	if (eGDI == session->conf.eType){
 		if (DOUBLERECORD_CALLTYPE == session->conf.nCallType) {
 			if (NULL != pg_last_session) {
@@ -2291,48 +2137,28 @@ static void stop_ui(video_session_t *session)
 			if (NULL != session->pic_record->work_thread) {
 				SetEvent(session->pic_record->evt);
 
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_thread 0x%08x", session->pic_record->work_thread);
 				CloseHandle(session->pic_record->work_thread);
 				session->pic_record->work_thread = NULL;
 
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_event 0x%08x", session->pic_record->evt);
 				CloseHandle(session->pic_record->evt);
 				session->pic_record->evt = NULL;
 			}
 		}
 
 		if (session->local_hwnd) {
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("PostMessageA WM_CLOSE session addr is 0x%08x, session->local_hwnd = 0x%08x", session, session->local_hwnd);
-
 			BOOL bRet = PostMessageA(session->local_hwnd, WM_CLOSE, 0, 0);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("WaitForSingleObject session addr is 0x%08x, and session->ui_thread is 0x%08x.", session, session->ui_thread);
 			DWORD dCode = WaitForSingleObject(session->ui_thread, INFINITE);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("After WaitForSingleObject (session->ui_thread, INFINITE) session addr is 0x%08x, and session->ui_thread = 0x%08x.", session, session->ui_thread);
-
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_thread 0x%08x", session->ui_thread);
 			CloseHandle(session->ui_thread);
 			session->ui_thread = NULL;
 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_event 0x%08x", session->ui_event);
 			CloseHandle(session->ui_event);
 			session->ui_event = NULL;
 		}
 		pg_last_session = NULL;
 		pg_local_hwnd = NULL;
 		pg_remote_hwnd = NULL;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("set pg_last_session  to null.");
 	}
 	else{
-		//sem_post(&session->ui_stop_sem);
-		//if (session->ui_threadid > 0) {
-		//	if (0 == pthread_join(session->ui_threadid, NULL)){
-		//		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("video render thread %u pthread join success.", session->ui_threadid);
-		//		session->ui_threadid = 0;
-		//	}
-		//	else{
-		//		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("video render thread pthread join error for %s", strerror(errno));
-		//	}
-		//}
 		if (DOUBLERECORD_CALLTYPE == session->conf.nCallType) {
 			if (NULL != pg_last_session) {
 				pg_last_session->rtp = session->rtp;
@@ -2350,34 +2176,21 @@ static void stop_ui(video_session_t *session)
 			if (NULL != session->pic_record->work_thread) {
 				SetEvent(session->pic_record->evt);
 
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_thread 0x%08x", session->pic_record->work_thread);
 				CloseHandle(session->pic_record->work_thread);
 				session->pic_record->work_thread = NULL;
 
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_event 0x%08x", session->pic_record->evt);
 				CloseHandle(session->pic_record->evt);
 				session->pic_record->evt = NULL;
 			}
 		}
 
 		SetEvent(session->ui_event);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("WaitForSingleObject session addr is 0x%08x, and session->ui_thread is 0x%08x.", session, session->ui_thread);
 		DWORD dCode = WaitForSingleObject(session->ui_thread, INFINITE);
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("After WaitForSingleObject (session->ui_thread, INFINITE) session addr is 0x%08x, and session->ui_thread = 0x%08x.", session, session->ui_thread);
-
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_thread 0x%08x", session->ui_thread);
 		CloseHandle(session->ui_thread);
 		session->ui_thread = NULL;
-
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_event 0x%08x", session->ui_event);
 		CloseHandle(session->ui_event);
 		session->ui_event = NULL;
-
 		pg_last_session = NULL;
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("set pg_last_session  to null.");
-
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("ui thread exit!");
-
 		stop_video(session);
 	}
 }
@@ -2432,7 +2245,6 @@ static int load_record_area_png(video_session_t *session)
 				session->recordareamask = cvLoadImage(strRecordAreaPath,0);	
 			}
 		}
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Load record area img Success");
 		iret = 0;
 	}
 	else
@@ -2456,22 +2268,18 @@ int Local_video_session_create(const video_session_conf_t *conf, video_session_t
 		if ((conf->eDeviceType == eDesk2SType||conf->eDeviceType == eDesk1SType||conf->eDeviceType == eDesk2SIntegratedType) && g_bIsSalesRecord) 
 		{
 			session->video_shm_q_preview = new Clibvideoqueue(REC_COMMON_VIDEO_ENV_SHM_PREVIEW_QUEUE);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[dbg] use env preview share memory.");
 		}
 		else
 		{
 			session->video_shm_q_preview = new Clibvideoqueue(REC_COMMON_VIDEO_ENV_SHM_PREVIEW_QUEUE);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[dbg] use env preview share memory");
 		}
 
 		if (bremote){
 			if (eStand2sType == conf->eDeviceType){
 				session->video_shm_q_remote = new Clibvideoqueue(REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[dbg] stand2s device, record remote video use 320*240, and video_shm_q_remote addr is 0x%08x.", session->video_shm_q_remote);
 			}
 			else{
 				session->video_shm_q_remote = new Clibvideoqueue(REC_COMMON_VIDEO_REMOTE_SHM_RTP_QUEUE);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("[dbg] not stand2s device, record remote video use 320*240, and video_shm_q_remote addr is 0x%08x.", session->video_shm_q_remote);
 			}
 		}
 		
@@ -2491,9 +2299,6 @@ int Local_video_session_create(const video_session_conf_t *conf, video_session_t
 
 		if (false == bremote){
 			if (0 == load_record_area_png(session)){
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("load record area picture success.");
-			}
-			else{
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load record area picture failed.");
 			}
 		}
@@ -2513,9 +2318,6 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 		translate_ipaddr_from_int(str_local, MAX_PATH_SIZE, conf->local_rtp_ip);
 		translate_ipaddr_from_int(str_remote, MAX_PATH_SIZE, conf->remote_rtp_ip);
 
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("video_session_create session addr = 0x%08x,local_rtp_ip = %s,local_rtp_port = %d, local_pt = %d, remote_rtp_ip = %s,remote_rtp_port=%d, remote_pt = %d, call type = %d.",
-			session, str_local, conf->local_rtp_port,conf->local_pt, str_remote, conf->remote_rtp_port, conf->remote_pt, conf->nCallType);
-
 		memcpy(&session->conf, conf, sizeof(video_session_conf_t));
 		//session->bshow_remote = false;
 		//session->ilast_windstae = 0;
@@ -2528,7 +2330,6 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 			if (NULL != pg_last_session){
 				session->video_shm_q_remote = (pg_last_session)->video_shm_q_remote;
 				session->video_shm_q_preview = (pg_last_session)->video_shm_q_preview;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("double record the second period, reuse record video queue.");
 			}
 		}
 
@@ -2541,7 +2342,6 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 			IplImage*img = cvLoadImage(strImgPath,1);
 			if (img != NULL)
 			{
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("load img success");
 				session->video_error = new videoq_frame;
 				session->video_error->format = VIDEOQ_FORMAT_RGB24;
 				session->video_error->framesize = 320*180*3;
@@ -2596,10 +2396,6 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 					session->personmask = cvLoadImage(strPersonPath,0);	
 				}
 			}
-			//IplImage*persongrey = cvLoadImage(strPersonPath,CV_LOAD_IMAGE_GRAYSCALE);
-			//二值化提取人形框掩码
-			//cvThreshold(persongrey,session->personmask,150, 255, CV_THRESH_BINARY);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Load person img Success");
 		}
 		else
 		{
@@ -2650,10 +2446,8 @@ void double_record_broadcast_video_session_stop()
 			if (NULL != pg_last_session->pic_record->work_thread)
 			{
 				SetEvent(pg_last_session->pic_record->evt);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_thread 0x%08x", pg_last_session->pic_record->work_thread);
 				CloseHandle(pg_last_session->pic_record->work_thread);
 				pg_last_session->pic_record->work_thread = NULL;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_event 0x%08x", pg_last_session->pic_record->evt);
 				CloseHandle(pg_last_session->pic_record->evt);
 				pg_last_session->pic_record->evt = NULL;
 			}
@@ -2663,7 +2457,6 @@ void double_record_broadcast_video_session_stop()
 		{
 			if (eGDI == pg_last_session->conf.eType) {
 				if (NULL != pg_last_session->local_hwnd){
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("PostMessageA WM_CLOSE session addr is 0x%08x, session->local_hwnd = 0x%08x", pg_last_session, pg_last_session->local_hwnd);
 					BOOL bRet = PostMessageA(pg_last_session->local_hwnd, WM_CLOSE, 0, 0);
 				}
 			}
@@ -2673,27 +2466,20 @@ void double_record_broadcast_video_session_stop()
 				}
 			}
 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("WaitForSingleObject session addr is 0x%08x, and session->ui_thread is 0x%08x.", pg_last_session, pg_last_session->ui_thread);
 			DWORD dCode = WaitForSingleObject(pg_last_session->ui_thread, INFINITE);
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("After WaitForSingleObject (session->ui_thread, INFINITE) session addr is 0x%08x, and session->ui_thread = 0x%08x.",pg_last_session,  pg_last_session->ui_thread);
-
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_thread 0x%08x", pg_last_session->ui_thread);
 			CloseHandle(pg_last_session->ui_thread);
 			pg_last_session->ui_thread = NULL;
 
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle ui_event 0x%08x", pg_last_session->ui_event);
 			CloseHandle(pg_last_session->ui_event);
 			pg_last_session->ui_event = NULL;
 
 			if (eGDI == pg_last_session->conf.eType) {
 				pg_local_hwnd = NULL;
 				pg_remote_hwnd = NULL;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("set pg_last_session, pg_local_hwnd, pg_remote_hwnd to null.");
 			}
 			else{
 				pg_local_render = NULL;
 				pg_remote_render = NULL;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("set pg_last_session, pg_local_render, pg_remote_render to null.");
 			}
 			pg_last_session = NULL;
 		}
@@ -2703,16 +2489,12 @@ void double_record_broadcast_video_session_stop()
 
 void video_session_destroy(video_session_t *session)
 {
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("video_session_destroy video session addr is 0x%08x", session);
 	if (NULL != session) {
 		if (NULL != session->pic_record) {
 			if (NULL != session->pic_record->work_thread) {
 				SetEvent(session->pic_record->evt);
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_thread 0x%08x", session->pic_record->work_thread);
 				CloseHandle(session->pic_record->work_thread);
 				session->pic_record->work_thread = NULL;
-
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("CloseHandle pic_record ui_event 0x%08x", session->pic_record->evt);
 				CloseHandle(session->pic_record->evt);
 				session->pic_record->evt = NULL;
 			}
@@ -2781,10 +2563,6 @@ void av_log_cb(void*ptr, int level, const char*fmt, va_list arg)
 
 int video_lib_init()
 {
-	//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_COM_START_INIT, "sip phone com init start.");
-	//CoInitialize(NULL);
-	//LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_COM_FINISH_INIT, "sip phone com init end.");
-
 	videoframework_init();
 
 	av_log_set_callback(&av_log_cb);

+ 21 - 11
Other/unix/libvideorecord/FFmpegWriter.cpp

@@ -39,11 +39,11 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, LogA
 {
     AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
 
-    pLogApi->Debug("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d",
-                    av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
-                    av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
-                    av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
-                    pkt->stream_index);
+    //pLogApi->Debug("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d",
+    //                av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
+    //                av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
+    //                av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
+    //                pkt->stream_index);
 }
 
 static void log_callback(void* ptr, int level, const char* fmt, va_list vl)
@@ -561,7 +561,7 @@ static int write_video_frame(LogApi* pLogApi, AVFormatContext *oc, OutputStream
 
     vframe = get_video_frame(pLogApi, ost, data, len, input_pix_fmt);
 
-    pLogApi->Debug("get_video_frame pts = %d", vframe->pts);
+    //pLogApi->Debug("get_video_frame pts = %d", vframe->pts);
 
     av_init_packet(&pkt);
 
@@ -572,7 +572,7 @@ static int write_video_frame(LogApi* pLogApi, AVFormatContext *oc, OutputStream
         return -1;
     }
     else {
-        pLogApi->Debug("avcodec_encode_video2 success(%d) and got_packet ret = %d.", iencoderet, got_packet);
+        //pLogApi->Debug("avcodec_encode_video2 success(%d) and got_packet ret = %d.", iencoderet, got_packet);
     }
 
     if (got_packet) {
@@ -715,6 +715,8 @@ bool FFmpegWriter::InitWriter(char* filename, int width, int height, int colorbi
     m_audio_input_buffer = new ByteBuffer(3*nBitPerSample/8 * nchannels* nSamplePsec);
     m_pLogApi->Debug("Init FFmpegWriter success, audio_input_buffer:%d", 3 * nBitPerSample / 8 * nchannels * nSamplePsec);
 
+    m_bstart = false;
+
     return result;
 }
 
@@ -732,11 +734,13 @@ bool FFmpegWriter::StartWrite()
 
     m_pLogApi->Debug("FFmpegWriter StartWrite success");
 
+    m_bstart = true;
+
 	return true;
 }
 
 
-bool FFmpegWriter::End() {
+bool FFmpegWriter::StopWrite() {
     /* Write the trailer, if any. The trailer must be written before you
      * close the CodecContexts open when you wrote the header; otherwise
      * av_write_trailer() may try to use memory that was freed on
@@ -746,12 +750,16 @@ bool FFmpegWriter::End() {
 		return false;
 	}
 	
-    av_write_trailer(m_formatctx);
+    if (m_bstart) {
+        av_write_trailer(m_formatctx);
+    }
 	
 	Close();
 
     av_log_set_callback(NULL);
 
+    m_bstart = false;
+
     m_pLogApi->Debug("FFmpegWriter End success");
 
 	return true;
@@ -763,7 +771,7 @@ void FFmpegWriter::Close()
     if (m_bhave_video) {
         close_stream(m_formatctx, m_video_st);
     }
-        
+
     if (m_bhave_audio) {
         close_stream(m_formatctx, m_audio_st);
     }
@@ -774,7 +782,9 @@ void FFmpegWriter::Close()
     }
 
     /* free the stream */
-    avformat_free_context(m_formatctx);
+    if (m_formatctx) {
+        avformat_free_context(m_formatctx);
+    }
 
     if (m_video_st != NULL) {
         delete m_video_st;

+ 3 - 2
Other/unix/libvideorecord/FFmpegWriter.h

@@ -40,7 +40,7 @@ class FFmpegWriter
 {
 public:
 	FFmpegWriter(LogApi* pLogAPI) {m_pLogApi = pLogAPI; m_video_st = NULL; m_audio_st = NULL; m_outfmt = NULL; m_formatctx = NULL;
-	m_audio_codec = NULL; m_video_codec = NULL; m_bhave_video = false; m_bhave_audio = false; m_audio_input_buffer = NULL;}
+	m_audio_codec = NULL; m_video_codec = NULL; m_bhave_video = false; m_bhave_audio = false; m_audio_input_buffer = NULL; m_bstart = false;}
 	~FFmpegWriter() {}
 
 private://内部成员变量
@@ -56,12 +56,13 @@ private://内部成员变量
 	LogApi* m_pLogApi;
 	ByteBuffer* m_audio_input_buffer;
 	void Close();
+	bool m_bstart;
 
 public:
 	bool InitWriter(char* filename, int width, int height, int colorbit, int nfps,
 		int nSamplePsec, int nchannels, int nBitPerSample, int nmaxspacing, int nquality, int nOutBitRate, int iAudioType);
 	bool StartWrite();
-	bool End();
+	bool StopWrite();
 	bool ReceiveAudioData(unsigned char* pData, unsigned long ulen);
 	bool ReceiveVideoData(unsigned char* pData, unsigned long ulen);
 };

+ 13 - 12
Other/unix/libvideorecord/libvideorecord_impl.cpp

@@ -553,7 +553,7 @@ bool libvideorecord_impl::InitMediaQueueInfos(const char* audioqueuename, const
 bool libvideorecord_impl::EndRecord()
 {
 	if (eMP4 == m_eFormat) {
-		if (!m_pFFmpegWriter->End()) {
+		if (!m_pFFmpegWriter->StopWrite()) {
 			return false;
 		}
 	}
@@ -593,7 +593,7 @@ bool libvideorecord_impl::StartRecord()
 
 	if (0 == pthread_create(&m_nRecordthreadId, NULL, VideoRecordThread, (void*)this)) {
 		bRet = true;
-		m_pHostApi->Debug(RECORD_LOG_INFO, "create video record thread and thread id is %u.", m_nRecordthreadId);
+		//m_pHostApi->Debug(RECORD_LOG_INFO, "create video record thread and thread id is %u.", m_nRecordthreadId);
 	}
 	else {
 		m_pHostApi->Debug(RECORD_LOG_INFO, "create video record thread failed.");
@@ -783,7 +783,7 @@ bool libvideorecord_impl::GetRecordVideoFrameSize()
 			}
 		}
 		else {
-			m_pHostApi->Debug(RECORD_LOG_INFO, "Get Video FrameSize failed time is %d.", i);
+			m_pHostApi->Debug(RECORD_LOG_INFO, "Get Video FrameSize success, and failed times is %d.", i);
 			bRet = true;
 			break;
 		}
@@ -979,6 +979,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameSize(int& iWidth, int& iHeight)
 			iSize = iWidth * iHeight * 3;
 		}
 	}
+
 	return iSize;
 }
 
@@ -993,7 +994,7 @@ int libvideorecord_impl::GetDoubleSideVideoFrameSize(int& iWidth, int& iHeight)
 
 	//如果远端队列不为空,且录制双向视频
 	if (m_remote_videoqueue)  {
-		 if (eStand2Agent == m_eRecordType) //大机以终端的视频大小确定画布,终端为640*360,远端固定为320*240,则画布为640*640+320*240  = 960*640
+		if (eStand2Agent == m_eRecordType) //大机以终端的视频大小确定画布,终端为640*360,远端固定为320*240,则画布为640*640+320*240  = 960*640
 		{
 			//计算画布左边部分的分辨率,640*640
 			int env_width = 0;
@@ -1431,14 +1432,14 @@ bool libvideorecord_impl::ReNameVideo()
 				//前一个文件名
 				snprintf(m_OldFileName, MAX_PATH, "%s%d.%s", name.c_str(), m_iFileSerialNum - 1, m_VideoFomat);
 				snprintf(m_NewFileName, MAX_PATH, "%s%d_end.%s", name.c_str(), m_iFileSerialNum - 1, m_VideoFomat);
-				m_pHostApi->Debug(RECORD_LOG_INFO, "renamefile1 from %s to %s", m_OldFileName, m_NewFileName);
+				m_pHostApi->Debug(RECORD_LOG_DEBUG, "renamefile1 from %s to %s", m_OldFileName, m_NewFileName);
 				ReNameFile(m_OldFileName, m_NewFileName);
 			}
 			//sessionid切换,当前文件需要重命名
 			char m_NewFileName[MAX_PATH] = { 0 };
 			m_iFileSerialNum = 0;
 			snprintf(m_NewFileName, MAX_PATH, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
-			m_pHostApi->Debug(RECORD_LOG_INFO, "renamefile2 from %s to %s", m_VideoFileName, m_NewFileName);
+			m_pHostApi->Debug(RECORD_LOG_DEBUG, "renamefile2 from %s to %s", m_VideoFileName, m_NewFileName);
 			if (ReNameFile(m_VideoFileName, m_NewFileName)) {
 				m_pHostApi->OnASectionFinished(m_NewFileName, m_iFileSerialNum, false);
 				m_iFileSerialNum++;
@@ -1449,7 +1450,7 @@ bool libvideorecord_impl::ReNameVideo()
 			//继续录像,删除当前文件的"END"
 			char m_NewFileName[MAX_PATH] = { 0 };
 			snprintf(m_NewFileName, MAX_PATH, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
-			m_pHostApi->Debug(RECORD_LOG_INFO, "renamefile3 from %s to %s", m_VideoFileName, m_NewFileName);
+			m_pHostApi->Debug(RECORD_LOG_DEBUG, "renamefile3 from %s to %s", m_VideoFileName, m_NewFileName);
 			ReNameFile(m_VideoFileName, m_NewFileName);
 			m_pHostApi->OnASectionFinished(m_NewFileName, m_iFileSerialNum, false);
 			//WMV文件的序列号
@@ -1457,7 +1458,7 @@ bool libvideorecord_impl::ReNameVideo()
 		}
 		//新文件增加END
 		snprintf(m_VideoFileName, MAX_PATH, "%s%s_%d_end.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
-		m_pHostApi->Debug(RECORD_LOG_INFO, "generate new file name %s", m_VideoFileName);
+		m_pHostApi->Debug(RECORD_LOG_DEBUG, "generate new file name %s", m_VideoFileName);
 		m_bCloseVideo = false;
 	}
 	else {
@@ -1589,7 +1590,7 @@ bool libvideorecord_impl::EndRecordWrite()
 	bool bResult = false;
 
 	if (eMP4 == m_eFormat) {
-		bResult = m_pFFmpegWriter->End();
+		bResult = m_pFFmpegWriter->StopWrite();
 	}
 
 	return bResult;
@@ -1676,7 +1677,7 @@ bool libvideorecord_impl::StopVideoRecord()				//退出
 	
 	sem_post(&m_semt);
 	if (0 == pthread_join(m_nRecordthreadId, NULL)) {
-		m_pHostApi->Debug(RECORD_LOG_INFO, "thread join video record thread %u success!", m_nRecordthreadId);
+		m_pHostApi->Debug(RECORD_LOG_DEBUG, "thread join video record thread %u success!", m_nRecordthreadId);
 		m_nRecordthreadId = 0;
 	}
 	else {
@@ -1995,7 +1996,7 @@ bool libvideorecord_impl::GetLocalAudioFrame(int iAudioLens)
 		if (CAPTURE_CLOCK == m_audioframe->samplespersec) {
 			m_iAudioBufferLen += m_audioframe->framesize;
 			m_iAudioFromQueNum++;
-			if (/*(0 == m_iAudioFromQueNum % 100) && */0 != m_audioframe->iseriesnumber) {
+			if ((0 == m_iAudioFromQueNum % 100) && 0 != m_audioframe->iseriesnumber) {
 				m_pHostApi->Debug(RECORD_LOG_DEBUG, "current audio queue len is %d and audio series number is: %d.", iAudioLens, m_audioframe->iseriesnumber);
 			}
 			bRet = true;
@@ -2105,7 +2106,7 @@ int libvideorecord_impl::WriteAudioFrame()
 	if (ReceiveRecordAudioData((BYTE*)m_pRecordAudioBuffer, m_iAudioBufferLen)) {
 		m_iRecordAudioNum++;
 		if (0 == m_iRecordAudioNum % 10) {
-			m_pHostApi->Debug(RECORD_LOG_INFO, "已成功写入音频帧数为(%d), 当前音频包大小为(%d).", m_iRecordAudioNum, m_iAudioBufferLen);
+			m_pHostApi->Debug(RECORD_LOG_DEBUG, "已成功写入音频帧数为(%d), 当前音频包大小为(%d).", m_iRecordAudioNum, m_iAudioBufferLen);
 		}
 
 		m_iAudioBufferLen = 0;

+ 21 - 11
Other/win/libvideorecord/FFmpegWriter.cpp

@@ -41,11 +41,11 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, LogA
 {
     AVRational *time_base = &fmt_ctx->streams[pkt->stream_index]->time_base;
 
-    pLogApi->Debug("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d",
-                    av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
-                    av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
-                    av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
-                    pkt->stream_index);
+    //pLogApi->Debug("pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d",
+    //                av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
+    //                av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
+    //                av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
+    //                pkt->stream_index);
 }
 
 static void log_callback(void* ptr, int level, const char* fmt, va_list vl)
@@ -553,7 +553,7 @@ static int write_video_frame(LogApi* pLogApi, AVFormatContext *oc, OutputStream
 
     vframe = get_video_frame(pLogApi, ost, data, len, input_pix_fmt);
 
-    pLogApi->Debug("get_video_frame pts = %d", vframe->pts);
+    //pLogApi->Debug("get_video_frame pts = %d", vframe->pts);
 
     av_init_packet(&pkt);
 
@@ -564,7 +564,7 @@ static int write_video_frame(LogApi* pLogApi, AVFormatContext *oc, OutputStream
         return -1;
     }
     else {
-        pLogApi->Debug("avcodec_encode_video2 success(%d) and got_packet ret = %d.", iencoderet, got_packet);
+        //pLogApi->Debug("avcodec_encode_video2 success(%d) and got_packet ret = %d.", iencoderet, got_packet);
     }
 
     if (got_packet) {
@@ -707,6 +707,8 @@ bool FFmpegWriter::InitWriter(char* filename, int width, int height, int colorbi
     m_audio_input_buffer = new ByteBuffer(3*nBitPerSample/8 * nchannels* nSamplePsec);
     m_pLogApi->Debug("Init FFmpegWriter success, audio_input_buffer:%d", 3 * nBitPerSample / 8 * nchannels * nSamplePsec);
 
+    m_bstart = false;
+
     return result;
 }
 
@@ -724,11 +726,13 @@ bool FFmpegWriter::StartWrite()
 
     m_pLogApi->Debug("FFmpegWriter StartWrite success");
 
+    m_bstart = true;
+
 	return true;
 }
 
 
-bool FFmpegWriter::End() {
+bool FFmpegWriter::StopWrite() {
     /* Write the trailer, if any. The trailer must be written before you
      * close the CodecContexts open when you wrote the header; otherwise
      * av_write_trailer() may try to use memory that was freed on
@@ -738,12 +742,16 @@ bool FFmpegWriter::End() {
 		return false;
 	}
 	
-    av_write_trailer(m_formatctx);
+    if (m_bstart) {
+        av_write_trailer(m_formatctx);
+    }
 	
 	Close();
 
     av_log_set_callback(NULL);
 
+    m_bstart = false;
+
     m_pLogApi->Debug("FFmpegWriter End success");
 
 	return true;
@@ -755,7 +763,7 @@ void FFmpegWriter::Close()
     if (m_bhave_video) {
         close_stream(m_formatctx, m_video_st);
     }
-        
+
     if (m_bhave_audio) {
         close_stream(m_formatctx, m_audio_st);
     }
@@ -766,7 +774,9 @@ void FFmpegWriter::Close()
     }
 
     /* free the stream */
-    avformat_free_context(m_formatctx);
+    if (m_formatctx) {
+        avformat_free_context(m_formatctx);
+    }
 
     if (m_video_st != NULL) {
         delete m_video_st;

+ 3 - 2
Other/win/libvideorecord/FFmpegWriter.h

@@ -48,7 +48,7 @@ class FFmpegWriter
 {
 public:
 	FFmpegWriter(LogApi* pLogAPI) {m_pLogApi = pLogAPI; m_video_st = NULL; m_audio_st = NULL; m_outfmt = NULL; m_formatctx = NULL;
-	m_audio_codec = NULL; m_video_codec = NULL; m_bhave_video = false; m_bhave_audio = false; m_audio_input_buffer = NULL;}
+	m_audio_codec = NULL; m_video_codec = NULL; m_bhave_video = false; m_bhave_audio = false; m_audio_input_buffer = NULL; m_bstart = false;}
 	~FFmpegWriter() {}
 
 private://内部成员变量
@@ -64,12 +64,13 @@ private://内部成员变量
 	LogApi* m_pLogApi;
 	ByteBuffer* m_audio_input_buffer;
 	void Close();
+	bool m_bstart;
 
 public:
 	bool InitWriter(char* filename, int width, int height, int colorbit, int nfps,
 		int nSamplePsec, int nchannels, int nBitPerSample, int nmaxspacing, int nquality, int nOutBitRate, int iAudioType);
 	bool StartWrite();
-	bool End();
+	bool StopWrite();
 	bool ReceiveAudioData(unsigned char* pData, unsigned long ulen);
 	bool ReceiveVideoData(unsigned char* pData, unsigned long ulen);
 };

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

@@ -1,4 +1,4 @@
-// libwmvrecord.cpp : 定义 DLL 应用程序的导出函数。
+// libvideorecord.cpp : 定义 DLL 应用程序的导出函数。
 //
 
 #include "stdafx.h"
@@ -7,7 +7,7 @@
 
 
 // 这是已导出类的构造函数。
-// 有关类定义的信息,请参阅 libwmvrecord.h
+// 有关类定义的信息,请参阅 libvideorecord.h
 Clibvideorecord::Clibvideorecord(bool *pResult, CHostApi *pHostAPI, const char* audioqueuename, const char* videoqueuename, const char* videoqueue2name, const char* salesaudioqueuename, const char* remotevideoqueuename, const char* remoteaudioqueuename)
 {
 	m_pImpl = new libvideorecord_impl(pResult,pHostAPI,audioqueuename,videoqueuename,videoqueue2name,salesaudioqueuename,remotevideoqueuename,remoteaudioqueuename);
@@ -72,7 +72,6 @@ bool Clibvideorecord::SetRightVideoWaterMark(const char* strWaterMark)
 	}
 
 	size_t ulen = strlen(strWaterMark);
-	
 	return m_pImpl->setRightWaterMark(strWaterMark, ulen);
 }
 

+ 3 - 2
Other/win/libvideorecord/libvideorecord.h

@@ -5,6 +5,7 @@
 // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
 // LIBRECORD_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
 // 符号视为是被导出的。
+
 #ifdef LIBVIDEORECORD_EXPORTS
 #define LIBVIDEORECORD_API __declspec(dllexport)
 #else
@@ -134,7 +135,7 @@ class LIBVIDEORECORD_API Clibvideorecord
 public:
 	Clibvideorecord(bool*pResult, CHostApi *pHostAPI,const char* audioqueuename, const char* videoqueuename, const char* videoqueue2name, const char* salesaudioqueuename=NULL, const char* remotevideoqueuename=NULL, const char* remoteaudioqueuename=NULL);
 	~Clibvideorecord(void);
-	// //开始记录,文件名wmvfilename为空则以当前系统时间做参数
+	// //开始记录,文件名videofilename为空则以当前系统时间做参数
 	bool StartVideoRecord(
 		int fps,
 		int videoquality,
@@ -145,7 +146,7 @@ public:
 		bool bSessionManage = false,
 		const char *pathname = NULL,
 		int pathlength = 0,
-		const char *wmvfilename = NULL,
+		const char *videofilename = NULL,
 		int filenamelength = 0
 		);
 

+ 74 - 63
Other/win/libvideorecord/libvideorecord_impl.cpp

@@ -523,7 +523,7 @@ CHostApi* libvideorecord_impl::GetHostApi()
 bool libvideorecord_impl::EndRecord()
 {
 	if (eMP4 == m_eFormat) {
-		if (!m_pFFmpegWriter->End()) {
+		if (!m_pFFmpegWriter->StopWrite()) {
 			return false;
 		}
 	}
@@ -733,7 +733,7 @@ bool libvideorecord_impl::GetRecordVideoFrameSize()
 		m_iVideoFrameSize = GetDestTypeVideoFrameSize(m_iWidth, m_iHeight, m_eRecordType);
 		if (m_iVideoFrameSize <= 0) {
 			FSleep(50);
-			if (0 == i % 500) {
+			if (0 != i && 0 == i % (RECORD_FAILED_MAX_TIMES/10)) {
 				m_pHostApi->Debug(RECORD_LOG_ERROR, "GetDestTypeVideoFrameSize failed %d times.", i);
 			}
 		}
@@ -760,15 +760,19 @@ bool libvideorecord_impl::GetRecordAudioFrameSize()
 		m_iAudioFrameSize = m_audioqueue->GetFrameSize();
 		if (m_iAudioFrameSize <= 0) {
 			FSleep(10);
+			if (0 != i && 0 == i % (RECORD_FAILED_MAX_TIMES/10)) {
+				m_pHostApi->Debug(RECORD_LOG_ERROR, "get local audio frame size failed %d times.", i);
+			}
 		}
 		else {
+			m_pHostApi->Debug(RECORD_LOG_INFO, "get audio frame size success, and failed time is %d.", i);
 			bRet = true;
 			break;
 		}
 	}
 
 	if (bRet) {
-		m_pHostApi->Debug(RECORD_LOG_DEBUG, "Local Audio Frame Size = %d", m_iAudioFrameSize);
+		m_pHostApi->Debug(RECORD_LOG_DEBUG, "local audio frame size = %d.", m_iAudioFrameSize);
 	}
 
 	return bRet;
@@ -878,7 +882,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameSize(int& iWidth, int& iHeight)
 	int iSize = 0;
 	if (m_env_videoqueue == NULL) {
 		m_pHostApi->Debug(RECORD_LOG_ERROR, "本地视频队列未初始化,不存在!");
-		iSize = 0;
+		return iSize;
 	}
 
 	int env_width = 0;
@@ -916,6 +920,7 @@ int libvideorecord_impl::GetSingleSideVideoFrameSize(int& iWidth, int& iHeight)
 			iSize = iWidth * iHeight * 3;
 		}
 	}
+
 	return iSize;
 }
 
@@ -924,23 +929,13 @@ int libvideorecord_impl::GetDoubleSideVideoFrameSize(int& iWidth, int& iHeight)
 {
 	int iSize = 0;
 	if (m_env_videoqueue == NULL) {
-		//m_pHostApi->Debug(RECORD_LOG_ERROR, "本地视频队列未初始化,不存在!");
-		iSize = 0;
+		m_pHostApi->Debug(RECORD_LOG_ERROR, "本地视频队列未初始化,不存在!");
+		return iSize;
 	}
 
 	//如果远端队列不为空,且录制双向视频
 	if (m_remote_videoqueue)  {
-		//如果PAD版下录制双向视频,视频大小由远端视频决定,如果远端为320*240,则视频大小为640*240
-		if (ePhone2Pad == m_eRecordType || ePad2Agent == m_eRecordType)  //手机到pad,坐席到pad的双向录像
-		{
-			int env_width = 0;
-			int env_height = 0;
-			iSize = m_remote_videoqueue->GetFrameSize(env_width, env_height);
-			iWidth = env_width * 2;
-			iHeight = env_height;
-			iSize = iWidth * iHeight * 3;
-		}
-		else if (eStand2Agent == m_eRecordType) //大机以终端的视频大小确定画布,终端为640*360,远端固定为320*240,则画布为640*640+320*240  = 960*640
+		if (eStand2Agent == m_eRecordType) //大机以终端的视频大小确定画布,终端为640*360,远端固定为320*240,则画布为640*640+320*240  = 960*640
 		{
 			//计算画布左边部分的分辨率,640*640
 			int env_width = 0;
@@ -956,24 +951,26 @@ int libvideorecord_impl::GetDoubleSideVideoFrameSize(int& iWidth, int& iHeight)
 				(opt_width > opt_height) ? (iWidth = iHeight = opt_width) : (iWidth = iHeight = opt_height);
 			}
 
-			//远端视频320*240
-			iWidth = iWidth + 480;
+			if (iWidth > 0 && iHeight > 0) {
+				//远端视频320*240
+				iWidth = iWidth + 480;
 
-			if (!m_SubtitleParam.bSubtitle || !m_SubtitleParam.bSubtitleSection){
-				iSize = iWidth * iHeight * 3;
-			}
-			else{
-				iHeight += 50;
-				iSize = iWidth * iHeight * 3;
-			}
+				if (!m_SubtitleParam.bSubtitle || !m_SubtitleParam.bSubtitleSection) {
+					iSize = iWidth * iHeight * 3;
+				}
+				else {
+					iHeight += 50;
+					iSize = iWidth * iHeight * 3;
+				}
 
-			if (iSize > 0) {
-				int remote_width = 0;
-				int remote_height = 0;
-				int iRemoteSize = m_remote_videoqueue->GetFrameSize(remote_width, remote_height);
-				if (0 == iRemoteSize) {
-					//m_pHostApi->Debug(RECORD_LOG_ERROR, "get remote video frame size failed!");
-					iSize = 0;
+				if (iSize > 0) {
+					int remote_width = 0;
+					int remote_height = 0;
+					int iRemoteSize = m_remote_videoqueue->GetFrameSize(remote_width, remote_height);
+					if (0 == iRemoteSize) {
+						//m_pHostApi->Debug(RECORD_LOG_ERROR, "get remote video frame size failed!");
+						iSize = 0;
+					}
 				}
 			}
 		}
@@ -994,7 +991,6 @@ int libvideorecord_impl::GetDestTypeVideoFrameData(videoq_frame* Video, int flag
 	int iRet = 0;
 	if (m_opt_videoqueue) {  
 		iRet = GetDoubleCameraVideoFrameData(Video, flags, bSwitchCam, iInitCam, eRecordType);
-		//m_pHostApi->Debug(RECORD_LOG_DEBUG, "GetDoubleCameraVideoFrameData result = %d.", iRet);
 	}
 	else {
 		iRet = GetSingleCameraVideoFrameData(Video, flags, eRecordType);
@@ -1006,8 +1002,7 @@ int libvideorecord_impl::GetDestTypeVideoFrameData(videoq_frame* Video, int flag
 int libvideorecord_impl::GetSingleCameraVideoFrameData(videoq_frame* Video, int flags, eRvcRecordType eRecordType)
 {
 	int iRet = 0;
-	if (eSingleSide == m_eRecordType) 
-	{
+	if (eSingleSide == m_eRecordType) {
 		if (!m_SubtitleParam.bSubtitle || !m_SubtitleParam.bSubtitleSection){
 			return m_env_videoqueue->GetVideo(Video, flags) ? 0 : -1;
 		}
@@ -1198,12 +1193,12 @@ int libvideorecord_impl::GetSingleSideVideoFrameData(videoq_frame* Video, int fl
 	return 0;
 }
 
+
 int libvideorecord_impl::GetDoubleCameraVideoFrameData(videoq_frame* Video, int flags, const bool bSwitchCam, int iInitCam, eRvcRecordType eRecordType)
 {
 	int iRet = 0;
 	if (eStand2Agent == m_eRecordType) {  //如果远端队列不为空,且录制双向视频
 		iRet = GetStand2SVideoFrameData(Video, flags, bSwitchCam, iInitCam, eRecordType);
-		//m_pHostApi->Debug(RECORD_LOG_DEBUG, "GetStand2SVideoFrameData result = %d.", iRet);
 	}
 	else if(eSingleSide == eRecordType){
 		iRet = GetSingleSideVideoFrameData(Video, flags, bSwitchCam, iInitCam);
@@ -1212,24 +1207,33 @@ int libvideorecord_impl::GetDoubleCameraVideoFrameData(videoq_frame* Video, int
 		m_pHostApi->Debug(RECORD_LOG_ERROR, "invalid record type.");
 		iRet =  -1;
 	}
+
 	return iRet;
 }
 
 
-bool libvideorecord_impl::IsRecordingCamError(int iRecordingCam)
+bool libvideorecord_impl::IsRecordingCamError(int iRecordingCam, eRvcRecordType eRecordType)
 {
 	bool bRet = false;
-	if (0 == iRecordingCam) {
-		if ('E' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState()) {
-			bRet = true;
+	if (eStand2Agent == eRecordType) {
+		if (0 == iRecordingCam) {
+			if ('E' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState()) {
+				bRet = true;
+			}
+		}
+		else {
+			if ('O' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState() || 'E' == m_pHostApi->GetCameraState()) {
+				bRet = true;
+			}
 		}
 	}
 	else {
-		if ('O' == m_pHostApi->GetCameraState() || 'B' == m_pHostApi->GetCameraState() || 'E' == m_pHostApi->GetCameraState()) {
+		if ('B' == m_pHostApi->GetCameraState()) {
 			bRet = true;
 		}
 	}
 
+
 	return bRet;
 }
 
@@ -1269,10 +1273,10 @@ bool libvideorecord_impl::InitCvxText()
 void libvideorecord_impl::GetVideoFullName()
 {
 	if (m_bWholeSection || !m_bSessionManage) {
-		sprintf_s(m_VideoFileName, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
+		_snprintf(m_VideoFileName, MAX_PATH, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
 	}
 	else {
-		sprintf_s(m_VideoFileName, "%s%s_%d_end.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
+		_snprintf(m_VideoFileName, MAX_PATH, "%s%s_%d_end.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
 	}
 	m_pHostApi->Debug(RECORD_LOG_DEBUG, "m_VideoFileName = %s", m_VideoFileName);
 }
@@ -1350,16 +1354,16 @@ bool libvideorecord_impl::ReNameVideo()
 				string name = FileName.substr(0, FileName.find_first_of('_') + 1);
 				//m_pHostApi->Debug("renamefile1 name =  %s",name.c_str());
 				//前一个文件名
-				sprintf_s(m_OldFileName, "%s%d.%s", name.c_str(), m_iFileSerialNum - 1, m_VideoFomat);
-				sprintf_s(m_NewFileName, "%s%d_end.%s", name.c_str(), m_iFileSerialNum - 1, m_VideoFomat);
-				m_pHostApi->Debug(RECORD_LOG_INFO, "renamefile1 from %s to %s", m_OldFileName, m_NewFileName);
+				_snprintf(m_OldFileName, MAX_PATH, "%s%d.%s", name.c_str(), m_iFileSerialNum - 1, m_VideoFomat);
+				_snprintf(m_NewFileName, MAX_PATH, "%s%d_end.%s", name.c_str(), m_iFileSerialNum - 1, m_VideoFomat);
+				m_pHostApi->Debug(RECORD_LOG_DEBUG, "renamefile1 from %s to %s", m_OldFileName, m_NewFileName);
 				ReNameFile(m_OldFileName, m_NewFileName);
 			}
 			//sessionid切换,当前文件需要重命名
 			char m_NewFileName[MAX_PATH] = { 0 };
 			m_iFileSerialNum = 0;
-			sprintf_s(m_NewFileName, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
-			m_pHostApi->Debug(RECORD_LOG_INFO, "renamefile2 from %s to %s", m_VideoFileName, m_NewFileName);
+			_snprintf(m_NewFileName, MAX_PATH, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
+			m_pHostApi->Debug(RECORD_LOG_DEBUG, "renamefile2 from %s to %s", m_VideoFileName, m_NewFileName);
 			if (ReNameFile(m_VideoFileName, m_NewFileName)) {
 				m_pHostApi->OnASectionFinished(m_NewFileName, m_iFileSerialNum, false);
 				m_iFileSerialNum++;
@@ -1369,23 +1373,23 @@ bool libvideorecord_impl::ReNameVideo()
 		else {
 			//继续录像,删除当前文件的"END"
 			char m_NewFileName[MAX_PATH] = { 0 };
-			sprintf_s(m_NewFileName, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
-			m_pHostApi->Debug(RECORD_LOG_INFO, "renamefile3 from %s to %s", m_VideoFileName, m_NewFileName);
+			_snprintf(m_NewFileName, MAX_PATH, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
+			m_pHostApi->Debug(RECORD_LOG_DEBUG, "renamefile3 from %s to %s", m_VideoFileName, m_NewFileName);
 			ReNameFile(m_VideoFileName, m_NewFileName);
 			m_pHostApi->OnASectionFinished(m_NewFileName, m_iFileSerialNum, false);
 			//WMV文件的序列号
 			m_iFileSerialNum++;
 		}
 		//新文件增加END
-		sprintf_s(m_VideoFileName, "%s%s_%d_end.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
-		m_pHostApi->Debug(RECORD_LOG_INFO, "generate new file name %s", m_VideoFileName);
+		_snprintf(m_VideoFileName, MAX_PATH, "%s%s_%d_end.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
+		m_pHostApi->Debug(RECORD_LOG_DEBUG, "generate new file name %s", m_VideoFileName);
 		m_bCloseVideo = false;
 	}
 	else {
 		//WMV文件的序列号
 		m_pHostApi->OnASectionFinished(m_VideoFileName, m_iFileSerialNum, false);
 		m_iFileSerialNum++;
-		sprintf_s(m_VideoFileName, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
+		_snprintf(m_VideoFileName, MAX_PATH, "%s%s_%d.%s", m_PathName, m_FileName, m_iFileSerialNum, m_VideoFomat);
 	}
 
 	bRet = true;
@@ -1513,7 +1517,7 @@ bool libvideorecord_impl::EndRecordWrite()
 {
 	bool bResult = false;
 	if (eMP4 == m_eFormat) {
-		bResult = m_pFFmpegWriter->End();
+		bResult = m_pFFmpegWriter->StopWrite();
 	}
 	else {
 		bResult = m_pWriter->End();
@@ -1565,6 +1569,7 @@ bool libvideorecord_impl::setRightWaterMark(const char* strWaterMark, size_t ule
 void libvideorecord_impl::Debug(const char* fmt, ...)
 {
 	va_list arg;
+
 	va_start(arg, fmt);
 
 	m_pHostApi->vDebug(RECORD_LOG_DEBUG, fmt, arg);
@@ -1624,7 +1629,7 @@ bool libvideorecord_impl::StartVideoRecord(int fps, int videoquality, eVideoForm
 	if (filenamelength == 0) {
 		SYSTEMTIME nowTime;                             // 系统时间结构体
 		GetLocalTime(&nowTime);
-		sprintf_s(m_FileName, "%4d%02d%02d%02d%02d%02d", nowTime.wYear, nowTime.wMonth, nowTime.wDay, nowTime.wHour, nowTime.wMinute, nowTime.wSecond);
+		_snprintf(m_FileName, MAX_PATH, "%4d%02d%02d%02d%02d%02d", nowTime.wYear, nowTime.wMonth, nowTime.wDay, nowTime.wHour, nowTime.wMinute, nowTime.wSecond);
 	}
 	else {
 		memcpy(m_FileName, wmvfilename, filenamelength);
@@ -1633,10 +1638,10 @@ bool libvideorecord_impl::StartVideoRecord(int fps, int videoquality, eVideoForm
 	m_eFormat = eFormat;
 
 	if (eMP4 == eFormat) {
-		sprintf_s(m_VideoFomat, MAX_PATH, "%s", RECORD_MP4_SUFFIX);
+		_snprintf(m_VideoFomat, MAX_PATH, "%s", RECORD_MP4_SUFFIX);
 	}
 	else {
-		sprintf_s(m_VideoFomat, MAX_PATH, "%s", RECORD_WMV_SUFFIX);
+		_snprintf(m_VideoFomat, MAX_PATH, "%s", RECORD_WMV_SUFFIX);
 	}
 
 	//m_pHostApi->Debug(RECORD_LOG_INFO, "m_VideoFomat = %s", m_VideoFomat);
@@ -1754,8 +1759,14 @@ int libvideorecord_impl::WriteVideoFrame()
 				}
 			}
 			else {
-				FSleep(2);
-				return -2;
+				if (IsRecordingCamError(nInitActiveCam, eSingleSide)) {
+					LogFailedEvent(eVideoGetFailed, "remote recording camera error!");
+					return -1;
+				}
+				else {
+					FSleep(2);
+					return -2;
+				}
 			}
 		}
 		// 加入字幕
@@ -1772,7 +1783,7 @@ int libvideorecord_impl::WriteVideoFrame()
 			}
 
 			char strmsg[MAX_PATH] = { 0 };
-			sprintf_s(strmsg, MAX_PATH, "视频流写入失败, remote_audio_length = %d, nVideoFrameSize = %d, noldvideoNum = %d", iremote_audio_length, m_iVideoFrameSize, m_iRecordVideoNum);
+			_snprintf(strmsg, MAX_PATH, "视频流写入失败, remote_audio_length = %d, nVideoFrameSize = %d, noldvideoNum = %d", iremote_audio_length, m_iVideoFrameSize, m_iRecordVideoNum);
 			if (0 == iremote_audio_length) {
 				LogFailedEvent(eRemoteAudioGetFailed, strmsg);
 			}
@@ -1994,7 +2005,7 @@ int libvideorecord_impl::WriteAudioFrame()
 	if (ReceiveRecordAudioData((BYTE*)m_pRecordAudioBuffer, m_iAudioBufferLen)) {
 		m_iRecordAudioNum++;
 		if (0 == m_iRecordAudioNum % 10) {
-			m_pHostApi->Debug(RECORD_LOG_INFO, "已成功写入音频帧数为(%d), 当前音频包大小为(%d).", m_iRecordAudioNum, m_iAudioBufferLen);
+			m_pHostApi->Debug(RECORD_LOG_DEBUG, "已成功写入音频帧数为(%d), 当前音频包大小为(%d).", m_iRecordAudioNum, m_iAudioBufferLen);
 		}
 
 		m_iAudioBufferLen = 0;
@@ -2006,7 +2017,7 @@ int libvideorecord_impl::WriteAudioFrame()
 	}
 	else {
 		char strinfo[MAX_PATH] = { 0 };
-		sprintf_s(strinfo, MAX_PATH, "音频流写入失败, m_iAudioBufferLen = %d, m_iRecordAudioNum = %d.", m_iAudioBufferLen, m_iRecordAudioNum);
+		_snprintf(strinfo, MAX_PATH, "音频流写入失败, m_iAudioBufferLen = %d, m_iRecordAudioNum = %d.", m_iAudioBufferLen, m_iRecordAudioNum);
 		LogFailedEvent(eAudioStreamWriteFailed, strinfo);
 		return -1;
 	}

+ 9 - 1
Other/win/libvideorecord/libvideorecord_impl.h

@@ -23,6 +23,14 @@
 #define CAPTURE_FRAME_MAX_LEN 2048	    // 48KHZ每20ms输出1920字节
 #endif
 
+#ifndef RECORD_FAILED_MAX_TIMES
+#define RECORD_FAILED_MAX_TIMES	5000
+#endif // !RECORD_FAILED_MAX_TIMES
+
+#ifndef GET_REMOTEVIDEO_FAILED_MAX_TIMES
+#define GET_REMOTEVIDEO_FAILED_MAX_TIMES	15
+#endif // !GET_REMOTEVIDEO_FAILED_MAX_TIMES
+
 
 class libvideorecord_impl :
     public LogApi
@@ -56,7 +64,7 @@ private:
 	int GetVideoFrameSize(int& nWidth, int& nHeight, Clibvideoqueue* queue);
 	//从指定队列读取video
 	bool GetVideoFrame(video_frame* Video, int flags, Clibvideoqueue* queue);
-	bool IsRecordingCamError(int iRecordingCam);
+	bool IsRecordingCamError(int iRecordingCam, eRvcRecordType eRecordType = eStand2Agent);
 	bool InitCvxText();
 	void GetVideoFullName();
 	bool AddCvxText(unsigned char** pData, int iDataSize, int iWidth, int iHeight);

部分文件因为文件数量过多而无法显示