Browse Source

Z991239-5945 #comment 优化摄像头分辨率不符合应用要求处理逻辑

80274480 8 tháng trước cách đây
mục cha
commit
a1a3e571e4

+ 11 - 3
Module/mod_mediacontroller/capture.cpp

@@ -48,8 +48,16 @@ static void __dbg(const char *fmt, va_list arg)
 	}
 }
 
+static void handle_no_matched_resolution_evt(void* user_data, int idevid) 
+{
+	video_capture_t* video_cap = (video_capture_t*)user_data;
+	if (NULL != video_cap) {
+		capture_t* cap = video_cap->parent;
+		cap->config.capevent(cap->config.user_data, idevid);
+	}
+}
 
-static void __logevent(int ilogtype, int idevid, const char* strmessage)
+static void __logevent(void* user_data, int ilogtype, int idevid, const char* strmessage)
 {
 	if (0 == ilogtype){
 		LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_CAMERA_MATCHED_FORMAT, strmessage);
@@ -61,8 +69,8 @@ static void __logevent(int ilogtype, int idevid, const char* strmessage)
 		LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_CAMOPEN_FAILED_INFO, strmessage);
 	}
 	else if (3 == ilogtype) {
-		LogEvent(Severity_Middle, LOG_EVT_MEDIACONTROLLER_NOMATCHED_RESOLUTION, CSimpleStringA::Format("%d", idevid).GetData());
-
+		handle_no_matched_resolution_evt(user_data, idevid);
+		LogWarn(Severity_Low, Error_Debug, LOG_EVT_MEDIACONTROLLER_NOMATCHED_RESOLUTION, strmessage);
 	}
 	else{
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown type event.");

+ 4 - 2
Module/mod_mediacontroller/capture.h

@@ -83,6 +83,8 @@ namespace MediaController {
 		pthread_mutex_t* opt_mutex;
 		pthread_mutex_t* envopt_mutex;
 #endif
+		void (*capevent)(void* user_data, int ierrdevid);
+		void* user_data;
 	}capture_config_t;
 
 
@@ -172,11 +174,11 @@ namespace MediaController {
 	};
 
 	int capture_create(const capture_config_t *config, capture_t **p_cap, bool bstartaudio = true);
-	ErrorCodeEnum capture_create(const capture_config_t *config,capture_t *cap,int nCamera);
+	ErrorCodeEnum capture_create(const capture_config_t *config,capture_t *cap, int nCamera);
 	void capture_destroy(capture_t *cap);
 	ErrorCodeEnum capture_start(capture_t *cap, bool bstartaudio = true);
 	ErrorCodeEnum start_audio_capture(audio_capture_t *paudio);
-	ErrorCodeEnum capture_start(capture_t *cap,int nCamera);
+	ErrorCodeEnum capture_start(capture_t *cap, int nCamera);
 	void capture_stop(capture_t *cap);
 	int capture_lib_init(int* ivideonum);
 

+ 41 - 39
Module/mod_mediacontroller/mod_mediacontroller.cpp

@@ -81,6 +81,12 @@ static void __audiomgrlog(void* user_data, const char* fmt, va_list arg)
 }
 #endif
 
+static void __capevent(void* user_data, int ierrdevid)
+{
+	CMediaControllerEntity* pEntity = (CMediaControllerEntity*)user_data;
+	pEntity->UpdateCameraState(ierrdevid);
+}
+
 static int GetFormatString(char* strVala, size_t uValaLen, char* strValb, size_t uValbLen, const char* pSrc, size_t uSrcLen, char cWord)
 {
 	int iRet = -1;
@@ -206,7 +212,7 @@ void CMediaControllerEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmar
 
 	int i = 0;
 
-	m_arrListener.Init(16);
+	m_arrListener.Init(15);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, MOD_EVENT_SNAPSHOT_START_CAPTURE_ENV);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, MOD_EVENT_SNAPSHOT_START_CAPTURE_OPT);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, MOD_EVENT_SNAPSHOT_START_CAPTURE_ENVOPT);
@@ -222,7 +228,6 @@ void CMediaControllerEntity::OnPreStart(CAutoArray<CSimpleStringA> strArgs,CSmar
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_Middle, Error_IgnoreAll, EVENT_MOD_CONNECT_BEGAIN_RECORD_CALL, NULL, false);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STARTCAMERACAPTURE, NULL, false);
 	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_UI_STOPCAMERACAPTURE, NULL, false);
-	GetFunction()->SubscribeLog(m_arrListener[i++], this, Log_Event, Severity_None, Error_IgnoreAll, LOG_EVT_MEDIACONTROLLER_NOMATCHED_RESOLUTION, NULL, false);
 	
 	pTransactionContext->SendAnswer(Error_Succeed);
 }
@@ -1650,43 +1655,6 @@ void CMediaControllerEntity::OnLog( const CAutoArray<CUUID> &SubIDs, const CUUID
 	}
 	break;
 
-	case LOG_EVT_MEDIACONTROLLER_NOMATCHED_RESOLUTION:
-	{
-		if (pszMessage) {
-			char cdevid = pszMessage[0];
-			int idevid = cdevid - '0';
-			if (idevid == capture_get_video_device_id(conf.strVideoEnv)) {
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402208V3").setResultCode("RTA2810")("上摄像分辨率不符合要求");
-				if (eStand1SPlusType == m_eDeviceType) {
-					m_nCameraErrorCode = Error_AllCamera;
-				}
-				else {
-					if (m_nCameraErrorCode == Error_Succeed) {
-						m_nCameraErrorCode = Error_EnvCamera;
-					}
-					else if (m_nCameraErrorCode == Error_OptCamera) {
-						m_nCameraErrorCode = Error_AllCamera;
-					}
-				}
-				ChangeSysvar(m_nCameraErrorCode);
-			}
-			else if(idevid == capture_get_video_device_id(conf.strVideoOpt)){
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402208V3").setResultCode("RTA2810")("下摄像分辨率不符合要求");
-				if (m_nCameraErrorCode == Error_Succeed){
-					m_nCameraErrorCode = Error_OptCamera;
-				}
-				else if (m_nCameraErrorCode == Error_EnvCamera){
-					m_nCameraErrorCode = Error_AllCamera;
-				}
-				ChangeSysvar(m_nCameraErrorCode);
-			}
-			else {
-				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("no mathed device id.");
-			}
-		}
-	}
-	break;
-
 	default:
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("unknown event.");
 		break;
@@ -1802,6 +1770,8 @@ ErrorCodeEnum CMediaControllerEntity::StartCamera(bool bstartaudio)
 		conf.envopt_mutex = &m_envopt_mutex;
 #endif
 		conf.uintervaltime = m_interValTime;
+		conf.capevent = &__capevent;
+		conf.user_data = this;
 		Error = (ErrorCodeEnum)capture_create(&conf, &m_capture, bstartaudio);
 		if (Error == Error_Succeed) 
 		{
@@ -2336,6 +2306,38 @@ bool CMediaControllerEntity::IsOnlineState()
 	return bret;
 }
 
+void CMediaControllerEntity::UpdateCameraState(int ierrdevid)
+{
+	if (ierrdevid == capture_get_video_device_id(conf.strVideoEnv)) {
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402208V3").setResultCode("RTA2810")("上摄像分辨率不符合要求");
+		if (eStand1SPlusType == m_eDeviceType) {
+			m_nCameraErrorCode = Error_AllCamera;
+		}
+		else {
+			if (m_nCameraErrorCode == Error_Succeed) {
+				m_nCameraErrorCode = Error_EnvCamera;
+			}
+			else if (m_nCameraErrorCode == Error_OptCamera) {
+				m_nCameraErrorCode = Error_AllCamera;
+			}
+		}
+		ChangeSysvar(m_nCameraErrorCode);
+	}
+	else if (ierrdevid == capture_get_video_device_id(conf.strVideoOpt)) {
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402208V3").setResultCode("RTA2810")("下摄像分辨率不符合要求");
+		if (m_nCameraErrorCode == Error_Succeed) {
+			m_nCameraErrorCode = Error_OptCamera;
+		}
+		else if (m_nCameraErrorCode == Error_EnvCamera) {
+			m_nCameraErrorCode = Error_AllCamera;
+		}
+		ChangeSysvar(m_nCameraErrorCode);
+	}
+	else {
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("no mathed device id.");
+	}
+}
+
 ChannelMediaControllerClient::ChannelMediaControllerClient( CMediaControllerEntity *pEntity ) : ChannelService_ClientBase(pEntity)
 {
 

+ 1 - 0
Module/mod_mediacontroller/mod_mediacontroller.h

@@ -143,6 +143,7 @@ public:
 	void SetCameraBrightness(SpReqAnsContext<MediaService_SetCameraBrightness_Req, MediaService_SetCameraBrightness_Ans>::Pointer ctx);
 	ErrorCodeEnum PostCameraBrightnessInfos(int iBrightness);
 	bool IsOnlineState();
+	void UpdateCameraState(int ierrdevid);
 
 public:
 	DeviceTypeEnum m_eDeviceType;

+ 1 - 1
Other/unix/libvideocapture/ivideocaptureinterface.h

@@ -128,7 +128,7 @@ typedef struct videocap_callback_s {
 	void (*onvideocapexcption)();
 #ifdef _WIN32
 #else
-	void (*logevent)(int itype, int idevid, const char* strmessage);
+	void (*logevent)(void* user_data, int ilogtype, int idevid, const char* strmessage);
 #endif
 	
 	void* user_data;

+ 1 - 1
Other/unix/libvideocapture/linux/videocapture_linux.cpp

@@ -1139,6 +1139,6 @@ void VideoCaptureImpl::CapLog(const char* fmt, ...)
 void VideoCaptureImpl::CapLogEvent(int itype, const char* strmessage)
 {
 	if (m_callback.logevent) {
-		(*m_callback.logevent)(itype, m_deviceId, strmessage);
+		(*m_callback.logevent)(m_callback.user_data, itype, m_deviceId, strmessage);
 	}
 }

+ 1 - 1
Other/win/libvideoframework/videocap.cpp

@@ -44,7 +44,7 @@ int RGB24DataSize(int height, int stride_y, int stride_u, int stride_v) {
 static void capLogEvent(videocap_param *cap, int ilogtype, const char* strmessage)
 {
 	if (cap->logevent) {
-		(*cap->logevent)(ilogtype, cap->dev_id, strmessage);
+		(*cap->logevent)(cap->user_data, ilogtype, cap->dev_id, strmessage);
 	}
 }
 

+ 1 - 1
Other/win/libvideoframework/videocap.h

@@ -146,7 +146,7 @@ typedef struct videocap_param
 	/* after grab */
 	void (*on_grab)(void *user_data, video_frame *frame);
 	void (*dbg)(const char *fmt, va_list arg);
-	void (*logevent)(int itype, int idevid, const char* strmessage);
+	void (*logevent)(void* user_data, int ilogtype, int idevid, const char* strmessage);
     void *user_data;
 
     int option; /* combination of VIDEOCAP_OPT_ xxx */