Browse Source

Z991239-4787 #comment 优化关闭摄像头定时器处理流程

80274480 2 years ago
parent
commit
252ee5afcb

+ 3 - 0
Module/mod_mediacontroller/Event.h

@@ -76,6 +76,9 @@
 #define LOG_EVT_MEDIACONTROLLER_BEGIN_FACETRACKING			0x20890001	//开始人脸捕获
 #define LOG_EVT_MEDIACONTROLLER_END_FACETRACKING			0x20890002  //停止人脸捕获
 
+#define LOG_EVT_MEDIACONTROLLER_SETTIMER_ERROR				0x20890003	//设置定时器异常
+#define LOG_EVT_MEDIACONTROLLER_KILLTIMER_ERROR				0x20890004  //停止定时器异常
+
 
 //sysvar
 #define SYSVAR_CAMERASTATE	"CameraState"

+ 37 - 12
Module/mod_mediacontroller/mod_mediacontroller.cpp

@@ -65,7 +65,9 @@ void CMediaControllerEntity::OnSysVarEvent(const char *pszKey, const char *pszVa
 	}
 	else if (_stricmp(pszKey, SYSVAR_CALLSTATE) == 0)
 	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sys call state from: %c to %c", pszOldValue[0], pszValue[0]);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("sys call state from: %c to %c", pszOldValue[0], pszValue[0]);\
+		CSimpleStringA strState;
+		auto err = GetFunction()->GetSysVar("UIState", strState);
 		if ('C' == pszValue[0]) {
 			if (1 == m_iCamOnMode) {
 				if (!m_bStartCamera) {
@@ -75,18 +77,29 @@ void CMediaControllerEntity::OnSysVarEvent(const char *pszKey, const char *pszVa
 					}
 				}
 				else {
-					GetFunction()->KillTimer(3);
-					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("KillTimer.");
+					if ("M" == strState) {
+						if (Error_Succeed == GetFunction()->KillTimer(3)) {
+							DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("KillTimer 3 success.");
+						}
+						else {
+							LogWarn(Severity_Middle, Error_Debug, LOG_EVT_MEDIACONTROLLER_KILLTIMER_ERROR, "Call State is Connecting, and UIState is M, KillTimer 3 failed.");
+						}
+					}
 				}
 			}
 		}
 		else if ('O' == pszValue[0]){
 			if (1 == m_iCamOnMode) {
-				GetFunction()->SetTimer(3, this, m_iDelayTime * 1000);
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SetTimer.");
+				if ("M" == strState) {
+					if (Error_Succeed == GetFunction()->SetTimer(3, this, m_iDelayTime * 1000)) {
+						DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("SetTimer 3 success.");
+					}
+					else {
+						LogWarn(Severity_Middle, Error_Debug, LOG_EVT_MEDIACONTROLLER_SETTIMER_ERROR, "Call State is OffLine, and UIState is M, SetTimer 3 failed.");
+					}
+				}
 			}
 		}
-	
 	}
 }
 
@@ -613,8 +626,12 @@ void CMediaControllerEntity::OnTimeout(DWORD dwTimerID)
 				m_capture = NULL;
 			}
 			m_bStartCamera = FALSE;
-			GetFunction()->KillTimer(3);
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("KillTimer.");
+			if (Error_Succeed == GetFunction()->KillTimer(3)) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("Stop Camera, KillTimer 3 success.");
+			}
+			else {
+				LogWarn(Severity_Middle, Error_Debug, LOG_EVT_MEDIACONTROLLER_KILLTIMER_ERROR, "Stop Camera, KillTimer 3 failed.");
+			}
 		}
 	}
 }
@@ -1380,8 +1397,12 @@ void CMediaControllerEntity::OnLog( const CAutoArray<CUUID> &SubIDs, const CUUID
 				}
 			}
 			else {
-				GetFunction()->KillTimer(3);
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("KillTimer.");
+				if (Error_Succeed == GetFunction()->KillTimer(3)) {
+					DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("begin handle business, and camera is already on, KillTimer 3 success.");
+				}
+				else {
+					LogWarn(Severity_Middle, Error_Debug, LOG_EVT_MEDIACONTROLLER_KILLTIMER_ERROR, "begin handle business, and camera is already on, KillTimer 3 failed.");
+				}
 			}
 		}
 		break;
@@ -1389,8 +1410,12 @@ void CMediaControllerEntity::OnLog( const CAutoArray<CUUID> &SubIDs, const CUUID
 	case LOG_EVT_END_HANDLE_BUSINESS:
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("end handle business.");
 		if (1 == m_iCamOnMode) {
-			GetFunction()->SetTimer(3, this, m_iDelayTime*1000);
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("SetTimer.");
+			if (Error_Succeed == GetFunction()->SetTimer(3, this, m_iDelayTime * 1000)) {
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("end handle business, SetTimer 3 success.");
+			}
+			else {
+				LogWarn(Severity_Middle, Error_Debug, LOG_EVT_MEDIACONTROLLER_SETTIMER_ERROR, "end handle business, SetTimer 3 failed.");
+			}
 		}
 		break;