Browse Source

Z991239-1954 #comment fix: 解决客户感知进入和离开多次存在交易录像失败问题

陈礼鹏80274480 4 năm trước cách đây
mục cha
commit
4081f3f8f3
1 tập tin đã thay đổi với 34 bổ sung16 xóa
  1. 34 16
      Module/mod_recorder/mod_recorder.cpp

+ 34 - 16
Module/mod_recorder/mod_recorder.cpp

@@ -83,7 +83,6 @@ public:
 		ErrorCodeEnum Error = Error_Succeed;
 		nActiveCamera = CAMERA_TYPE_ENV;
 		m_iCameraState = 'N';
-		BOOL bRet = FALSE;
 
 		//int nCameraCount = 0;
 		//Error = DecideCameraCount(nCameraCount);
@@ -91,19 +90,6 @@ public:
 		//	LOG_TRACE("decide camera count failed!");
 		//	return Error;
 		//}
-		if ((ePadtype == m_eDeviceType )||(eMobilePadType == m_eDeviceType)||(eDesk2SType == m_eDeviceType))
-		{
-			//pad 版增加远端视频队列
-			m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE, 
-				REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,NULL);
-		} 
-		else 
-		{ 
-			//  == 2
-			m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE, 
-				REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE,REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE);
-		}
-		Dbg("init libwmvrecord success!");
 		
 		GetFunction()->SubscribeLog(m_SubIDStartRecord, this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_BEGIN_RECORD, NULL, false);
 		GetFunction()->SubscribeLog(m_SubIDStopRecord, this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_END_RECORD, NULL, false);
@@ -219,6 +205,35 @@ public:
 		Dbg("OnRecordFinished!");
 	}
 
+	BOOL InitRecorder()
+	{
+		BOOL bRet = FALSE;
+
+		if ((ePadtype == m_eDeviceType) || (eMobilePadType == m_eDeviceType) || (eDesk2SType == m_eDeviceType))
+		{
+			//pad 版增加远端视频队列
+			m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE,
+				REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE, NULL);
+		}
+		else
+		{
+			//  == 2
+			m_pRecorder = new Clibwmvrecord(&bRet, this, REC_COMMON_AUDIO_SHM_QUEUE,
+				REC_COMMON_VIDEO_ENV_SHM_RTP_QUEUE, REC_COMMON_VIDEO_OPT_SHM_RTP_QUEUE);
+		}
+		Dbg("init libwmvrecord success!");
+
+		return bRet;
+	}
+
+	BOOL ReleaseRecorder()
+	{
+		if (m_pRecorder){
+			delete m_pRecorder;
+			m_pRecorder = NULL;
+		}
+	}
+
 	virtual void 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)
@@ -226,17 +241,20 @@ public:
 		if (/*(dwUserCode == EVENT_MOD_CUSTOMERAWARE_BEGIN)||*/(dwUserCode == EVENT_MOD_BEGIN_RECORD))
 		{ 
 			Dbg("start record!");
-			StartRecord(pszMessage);
+			if (InitRecorder()){
+				StartRecord(pszMessage);
+			}
 		} 
 		else if (/*(dwUserCode == EVENT_MOD_CUSTOMERAWARE_END)||*/(dwUserCode == EVENT_MOD_END_RECORD)) 
 		{
 			Dbg("stop record!");
 			StopRecord();
+			ReleaseRecorder();
 		}
 		else if (dwUserCode == LOG_EVT_UI_RETURNMENU) // 返回主菜单
 		{
 			//本地录像,退回到首页关闭当前文件,重新开始录制
-			if (m_bStarted)
+			if (m_bStarted&&m_pRecorder)
 			{
 				Dbg("return menu,close video file!");
 				m_pRecorder->CloseVideoFile();