Browse Source

Z991239-5263 #comment 优化摄像头占用流程

80274480 1 year ago
parent
commit
e9ce4fb8f8

+ 13 - 4
Module/mod_mediacontroller/mod_mediacontroller.cpp

@@ -943,8 +943,7 @@ ErrorCodeEnum CMediaControllerEntity::StopAllCameras()
 
 ErrorCodeEnum CMediaControllerEntity::StopCamerasAndRecord()
 {
-	LogEvent(Severity_Middle, EVENT_MOD_PAUSE_RECORD, "pause record.");
-
+	LogTransactionRecordCtrEvt(0);
 	ErrorCodeEnum CamRet = StopAllCameras(); 
 
 	return CamRet;
@@ -953,8 +952,7 @@ ErrorCodeEnum CMediaControllerEntity::StopCamerasAndRecord()
 ErrorCodeEnum CMediaControllerEntity::StartCamerasAndRecord()
 {
 	ErrorCodeEnum CamRet = StartAllCameras();
-	
-	LogEvent(Severity_Middle, EVENT_MOD_CONTINUE_RECORD, "continue record.");
+	LogTransactionRecordCtrEvt(1);
 
 	return CamRet;
 }
@@ -1854,6 +1852,16 @@ void CMediaControllerEntity::OnCameraStopped()
 }
 
 
+void CMediaControllerEntity::LogTransactionRecordCtrEvt(int iEvtType)
+{
+	if (0 == iEvtType) {
+		LogEvent(Severity_Middle, EVENT_MOD_PAUSE_RECORD, "pause record.");
+	}
+	else {
+		LogEvent(Severity_Middle, EVENT_MOD_CONTINUE_RECORD, "continue record.");
+	}
+}
+
 ChannelMediaControllerClient::ChannelMediaControllerClient( CMediaControllerEntity *pEntity ) : ChannelService_ClientBase(pEntity)
 {
 
@@ -2034,6 +2042,7 @@ void MediaServiceSession::Handle_ManipulateCameras(SpReqAnsContext<MediaService_
 			Sleep(200);
 		}
 		else {
+			m_pEntity->LogTransactionRecordCtrEvt(0);
 			Error = Error_Succeed;
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("current is not on business, camera is not on.");
 		}

+ 1 - 0
Module/mod_mediacontroller/mod_mediacontroller.h

@@ -122,6 +122,7 @@ public:
 	virtual CServerSessionBase* OnNewSession(const char* pszRemoteEntityName, const char* pszClass);
 	void OnTimeCameraStatusCheck();
 	ErrorCodeEnum ConnectAssistChannel();
+	void LogTransactionRecordCtrEvt(int iEvtType);
 
 public:
 	bool m_bSendCameraError;

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

@@ -431,7 +431,7 @@ libvideorecord_impl::libvideorecord_impl(bool* pResult, CHostApi* pHostAPI, cons
 	m_iNsPolicy = 2;
 	m_bIsAudioTransOn = false;
 	m_bPauseRecord = false;
-	m_eFormat = eWMV;
+	m_eFormat = eMP4;
 	m_pText = NULL;
 
 	InitRecordParams();
@@ -557,7 +557,7 @@ int libvideorecord_impl::VideoRecord()
 {
 	bool bResult = false;
 	bool bInitRecordParam = false;
-	DWORD nRecordStartTime = 0;					//本段录像开始时间
+	int nRecordStartTime = 0;					//本段录像开始时间
 	int iGetAudioFailedTimes = 0;
 
 	InitRecordParams();
@@ -592,7 +592,7 @@ int libvideorecord_impl::VideoRecord()
 			//计算经过的时间,计算已经经过几帧时间
 			m_iRecordedTime = timeGetTime() - nRecordStartTime - m_iSubTitleTime;
 
-			int nVideoNum = (DWORD)(((double)m_iRecordedTime / 1000.0) * (double)m_nFps);
+			int nVideoNum = (int)(((double)m_iRecordedTime / 1000.0) * (double)m_nFps);
 			//如果是第1帧,或者又经过了1帧的时间,则录制视频,对视频进行压缩
 			if (((nVideoNum == 0) && (m_iRecordVideoNum == 0)) || (nVideoNum > m_iRecordVideoNum)) {
 				int iRet = WriteVideoFrame();
@@ -613,7 +613,7 @@ int libvideorecord_impl::VideoRecord()
 			}
 			//录制音频,计算经过的时间,计算已经经过几帧时间
 			m_iRecordedTime = timeGetTime() - nRecordStartTime - m_iSubTitleTime;
-			int nAudioNum = (DWORD)((double)m_iRecordedTime / 1000.0);
+			int nAudioNum = (int)((double)m_iRecordedTime / 1000.0);
 			if ((nAudioNum > m_iRecordAudioNum) && (m_iAudioBufferLen >= m_iAudioPerSecBufLen)) {
 				int iRet = WriteAudioFrame();
 				if (-1 == iRet) {