Просмотр исходного кода

Z991239-5559 #comment 音频设备故障数大于3个或以上,以及配置为空情况下进关门

80274480 1 год назад
Родитель
Сommit
157b32978e

+ 12 - 1
Module/mod_sipphone/mod_sipphone.h

@@ -52,6 +52,17 @@ using namespace AssistantChannel;
 #define RVC_AUDIO_OUT_DEVICE_COUNT 2
 #endif // !RVC_AUDIO_OUT_DEVICE_COUNT
 
+
+typedef enum
+{
+	RVC_AUDIO_NO_ERROR = 0x0,				
+	RVC_AUDIO_HANDFREEIN_ERROR = 0x1,        
+	RVC_AUDIO_HANDFREEOUT_ERROR = 0x2,       
+	RVC_AUDIO_PICKUPIN_ERROR = 0x4,          
+	RVC_AUDIO_PICKUPOUT_ERROR = 0x8    
+} RVC_AudioErrorFlags;
+
+
 class CSIPEntity;
 class CSIPPhoneSession;
 
@@ -329,10 +340,10 @@ private:
 	DeviceTypeEnum RvcGetDeviceType();
 	ErrorCodeEnum RvcGetAudioDeviceInfo();
 	ErrorCodeEnum RvcSetSaveAudioVolume();
-	//eVideoRenderType GetMediaConfig();
 	ErrorCodeEnum LoadEntityConfig();
 	ErrorCodeEnum ConnectAssistChannel();
 	bool IsPostAudioConfigInfo();
+	uint32_t CheckAudioDevice();
 
 public:
 	int m_kept_volume_in[2];

+ 10 - 25
Module/mod_sipphone/unix/mod_sipphone.cpp

@@ -217,6 +217,9 @@ CSIPEntity::CSIPEntity() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhone
 	m_iremotevideo_freshtime = RVC_VIDEO_FRESH_TIME;
 	m_render = NULL;
 	m_iAudioDspUseCenter = 0;
+
+	m_nCallType = NORMAL_CALLTYPE;
+	memset(m_localip, 0, RVC_MAX_IP_LEN);
 }
 
 
@@ -512,6 +515,12 @@ void CSIPEntity::OnStarted()
 		GetFunction()->SetTimer(2, this, 3200);
 	}
 
+	Error = GetLocalIP();
+	if (Error != 0) {
+		CSimpleStringA strErrMsg = "获取本地 IP 地址失败,请检查本地网络是否连接!";
+		LogWarn(Severity_Middle, Error_NetBroken, ERROR_MOD_SIP_GET_LOCAL_IP_FAILED, strErrMsg.GetData());
+	}
+
 	LogEvent(Severity_Middle, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS, "sip phone started successfully.");
 }
 
@@ -610,7 +619,7 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 	//MessageBoxA(0,0,0,0);
 	m_nCallType = NORMAL_CALLTYPE;
 	m_pSipphoneChannel = new ChannelSipphoneClient(this);
-	memset(m_localip,0,256);
+	
 
 #ifdef RVC_OS_LINUX
 	{
@@ -633,13 +642,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 	audio_lib_init();
 	endpoint_init_lib();
 
-	Error = GetLocalIP();
-	if (Error != 0) {
-		CSimpleStringA strErrMsg = "获取本地 IP 地址失败,请检查本地网络是否连接!";
-		LogWarn(Severity_Middle, Error_NetBroken, ERROR_MOD_SIP_GET_LOCAL_IP_FAILED, strErrMsg.GetData());
-		return Error;
-	}
-
 #ifdef RVC_OS_LINUX
 	RvcGetAudioDeviceInfo();
 #endif
@@ -691,23 +693,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 		Func->GetSystemStaticInfo(staticInfo);
 	}
 	
-	CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
-	if (strUri.GetLength() > 0) 
-	{
-		strcpy(conf.uri, strUri);
-		conf.media_start_port = REC_COMMON_AUDIO_PORT_START;
-		conf.media_stop_port = REC_COMMON_AUDIO_PORT_STOP;
-		m_pEndpoint = endpoint_create(this, &conf,DEV_HANDFREE);
-		if (!m_pEndpoint) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create endpoint failed!");
-			return Error_Unexpect;
-		}
-	} 
-	else 
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("strUri length equals zero!");
-		return Error_Unexpect;
-	}
 
 	{
 		CSmartPointer<IEntityFunction> Func = GetFunction();

+ 73 - 103
Module/mod_sipphone/win/mod_sipphone.cpp

@@ -25,22 +25,6 @@
 #define DEVICE_HANDFREE_IN	2
 #define DEVICE_PICKUP_IN	3
 
-#ifndef DEFAULT_RECORD_VIDEO_WIDTH
-#define DEFAULT_RECORD_VIDEO_WIDTH 1056
-#endif
-
-#ifndef DEFAULT_RECORD_VIDEO_HEIGHT
-#define DEFAULT_RECORD_VIDEO_HEIGHT 595
-#endif
-
-#ifndef SMALL_RECORD_VIDEO_WIDTH
-#define SMALL_RECORD_VIDEO_WIDTH 244
-#endif
-
-#ifndef SMALL_RECORD_VIDEO_HEIGHT
-#define SMALL_RECORD_VIDEO_HEIGHT 138
-#endif
-
 #ifndef RVC_MAX_TRY_COUNT
 #define RVC_MAX_TRY_COUNT 1
 #endif
@@ -185,6 +169,17 @@ static CSimpleStringA generateAudioDspFlags(endpoint_audiodsp_config_t conf)
 		ihandfree_aec, ipickup_aec);
 }
 
+static int countnum(uint32_t unum)
+{
+	int icount = 0;
+	while (unum){
+		unum &= (unum - 1);
+		icount++;
+	}
+
+	return icount;
+}
+
 CSIPEntity::CSIPEntity() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhoneState(ePickupMicrophoneState_Off) 
 {
 	m_kept_volume_in[0] = m_kept_volume_in[1] = 0;
@@ -205,6 +200,9 @@ CSIPEntity::CSIPEntity() : m_pCurrentSession(NULL), m_state(INIT),m_iPickupPhone
 	m_itervalTime = RVC_INTERVAL_TIME;
 	m_bStopAutoRestart = false;
 	m_iAudioDspUseCenter = 0;
+
+	m_nCallType = NORMAL_CALLTYPE;
+	memset(m_localip, 0, RVC_MAX_IP_LEN);
 }
 
 
@@ -536,6 +534,12 @@ void CSIPEntity::OnStarted()
 		}
 	}
 
+	Error = GetLocalIP();
+	if (Error != 0) {
+		CSimpleStringA strErrMsg = "获取本地 IP 地址失败,请检查本地网络是否连接!";
+		LogWarn(Severity_Middle, Error_NetBroken, ERROR_MOD_SIP_GET_LOCAL_IP_FAILED, strErrMsg.GetData());
+	}
+
 	LogEvent(Severity_Middle, LOG_EVT_MOD_SIPPHONE_STARTED_SUCCESS, "sipphone entity started successfully.");
 	LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_ENTITY_STARTED, "sipphone entity started.");
 }
@@ -744,10 +748,7 @@ ErrorCodeEnum CSIPEntity::AudioDspFlagsUseCentersetting(endpoint_conf_t* conf)
 
 ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 {
-	ErrorCodeEnum Error;
-	//MessageBoxA(0,0,0,0);
-	m_nCallType = NORMAL_CALLTYPE;
-	memset(m_localip,0,256);
+	ErrorCodeEnum Error = Error_Succeed;
 
 	{
 		audiomgr_callback_t t_callback = { 0 };
@@ -758,7 +759,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 		}
 		else {
 			LogWarn(Severity_Middle, Error_Debug, LOG_EVT_SIPPHONE_AUDIOMGR_INITIAL_FAILED, "audio manager initialize failed!");
-			//return Error_Param;
 		}
 	}
 
@@ -771,13 +771,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 	audio_lib_init();
 	endpoint_init_lib();
 
-	Error = GetLocalIP();
-	if (Error != 0) {
-		CSimpleStringA strErrMsg = "获取本地 IP 地址失败,请检查本地网络是否连接!";
-		LogWarn(Severity_Middle, Error_NetBroken, ERROR_MOD_SIP_GET_LOCAL_IP_FAILED, strErrMsg.GetData());
-		return Error;
-	}
-
 	RvcGetAudioDeviceInfo();
 
 	if (Error_Succeed != LoadEntityConfig()){
@@ -787,18 +780,23 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 	Error = LoadConfig(&conf);
 	if (Error != Error_Succeed) {
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("load config failed!");
-		if (Error_Succeed != Error) {
-			if (!m_bStopAutoRestart) {
-				HandleAudioDeviceErrorEvent();
-			}
-			return Error;
-		}
 	}
 	
 	if (IsPostAudioConfigInfo()) {
 		LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_INFO, generateAudioInfoJson(conf.audio_handfree_in_dev, conf.audio_handfree_out_dev, conf.audio_pickup_in_dev, conf.audio_pickup_out_dev).GetData());
 	}
+	else {
+		//有配置为空的,进关门页
+		return Error_Param;
+	}
 	
+	uint32_t uCheckRet = CheckAudioDevice();
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("error audio device number is %d.", countnum(uCheckRet));
+	if (countnum(uCheckRet) >= 3) {
+		//故障设备数大于3个或以上
+		return Error_Param;
+	}
+
 	int nhandfreeout = 0;
 	int npickupout = 0;
 	int nhanfreein = 0;
@@ -826,29 +824,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 #ifdef RVC_OS_LINUX
 	RvcSetSaveAudioVolume();
 #endif
-		
-	{
-		CSmartPointer<IEntityFunction> Func = GetFunction();
-		Func->GetSystemStaticInfo(staticInfo);
-	}
-	
-	CSimpleStringA strUri = MakeUri(staticInfo.strTerminalID);
-	if (strUri.GetLength() > 0) 
-	{
-		strcpy(conf.uri, strUri);
-		conf.media_start_port = MEDIA_CONFIG_AUDIO_PORT_START;
-		conf.media_stop_port = MEDIA_CONFIG_AUDIO_PORT_STOP;
-		m_pEndpoint = endpoint_create(this, &conf, DEV_HANDFREE);
-		if (!m_pEndpoint) {
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("create endpoint failed!");
-			return Error_Unexpect;
-		}
-	} 
-	else 
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("strUri length equals zero!");
-		return Error_Unexpect;
-	}
 
 	{
 		CSmartPointer<IEntityFunction> Func = GetFunction();
@@ -1002,6 +977,7 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("PICKUP out volume keeper create failed!");
 		}
 	}
+
 	return Error_Succeed;
 }
 
@@ -1166,21 +1142,51 @@ ErrorCodeEnum CSIPEntity::RvcSetSaveAudioVolume()
 bool CSIPEntity::IsPostAudioConfigInfo()
 {
 	bool bRet = false;
-	if (eStand2sType == m_eDeviceType || eStand1SPlusType == m_eDeviceType) {
-		if (strlen(conf.audio_handfree_in_dev) && strlen(conf.audio_handfree_out_dev) && strlen(conf.audio_pickup_in_dev) && strlen(conf.audio_pickup_out_dev)) {
-			bRet = true;
-		}
-	}
-	else {
-		if (strlen(conf.audio_handfree_in_dev) && strlen(conf.audio_handfree_out_dev)) {
-			bRet = true;
-		}
+
+	if (strlen(conf.audio_handfree_in_dev) && strlen(conf.audio_handfree_out_dev) && strlen(conf.audio_pickup_in_dev) && strlen(conf.audio_pickup_out_dev)) {
+		bRet = true;
 	}
 
 	return bRet;
 }
 
 
+uint32_t CSIPEntity::CheckAudioDevice()
+{
+	int id = -1;
+	uint32_t Error = RVC_AUDIO_NO_ERROR;
+
+	id = capture_get_audio_device_id(true, conf.audio_handfree_in_dev);
+	if (id == -1) {
+		LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, CSimpleStringA::Format("hand free in audio device %s does not exist!", conf.audio_handfree_in_dev).GetData());
+		Error = RVC_AUDIO_HANDFREEIN_ERROR;
+	}
+
+	id = capture_get_audio_device_id(false, conf.audio_handfree_out_dev);
+	if (id == -1) {
+		LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, CSimpleStringA::Format("hand free out audio device %s does not exist!", conf.audio_handfree_out_dev).GetData());
+		Error |= RVC_AUDIO_HANDFREEOUT_ERROR;
+	}
+
+	id = capture_get_audio_device_id(true, conf.audio_pickup_in_dev);
+	if (id == -1) {
+		LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, CSimpleStringA::Format("pickup in audio device %s does not exist!", conf.audio_pickup_in_dev).GetData());
+		Error |= RVC_AUDIO_PICKUPIN_ERROR;
+	}
+
+	id = capture_get_audio_device_id(false, conf.audio_pickup_out_dev);
+	if (id == -1) {
+		LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, CSimpleStringA::Format("pickup out audio device %s does not exist!", conf.audio_pickup_out_dev).GetData());
+		Error |= RVC_AUDIO_PICKUPOUT_ERROR;
+	}
+
+	if (RVC_AUDIO_NO_ERROR != Error) {
+		LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_CONFIG_ERROR, CSimpleStringA::Format("config audio device not exist.").GetData());
+	}
+
+	return Error;
+}
+
 ErrorCodeEnum CSIPEntity::GetLocalIP()
 {
 	char tmp[MAX_PATH] = {0};
@@ -1667,7 +1673,6 @@ ErrorCodeEnum CSIPEntity::LoadConfig(endpoint_conf_t *conf)
 		CSimpleStringA strPickupIn;
 		CSimpleStringA strPickupOut;
 
-
 		SpIniMappingTable table;
 		table.AddEntryString("audio", "handfree_in_dev", strHandFreeIn, "$");
 		table.AddEntryString("audio", "handfree_out_dev", strHandFreeOut, "$");
@@ -1705,42 +1710,6 @@ ErrorCodeEnum CSIPEntity::LoadConfig(endpoint_conf_t *conf)
 				LogWarn(Severity_Low, Error_Debug, EVENT_MOD_SIP_CENTER_AUDIO_DSP_FLAGS, generateAudioDspFlags(conf->audio_dsp).GetData());
 			}
 
-			int id = -1;
-			int icount = 0;
-			do{
-				id = capture_get_audio_device_id(true, conf->audio_handfree_in_dev);
-				if (id == -1) {
-					LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, CSimpleStringA::Format("hand free in audio device %s does not exist!", conf->audio_handfree_in_dev).GetData());
-					Error = Error_Param;
-				}
-				
-				id = capture_get_audio_device_id(false, conf->audio_handfree_out_dev);
-				if (id == -1) {
-					LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, CSimpleStringA::Format("hand free out audio device %s does not exist!", conf->audio_handfree_out_dev).GetData());
-					Error = Error_Param;
-				}
-				
-				id = capture_get_audio_device_id(true, conf->audio_pickup_in_dev);
-				if (id == -1) {
-					LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_IN_DEVICE_NOT_EXIST, CSimpleStringA::Format("pickup in audio device %s does not exist!", conf->audio_pickup_in_dev).GetData());
-					Error = Error_Param;
-				}
-				
-				id = capture_get_audio_device_id(false, conf->audio_pickup_out_dev);
-				if (id == -1) {
-					LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_OUT_DEVICE_NOT_EXIST, CSimpleStringA::Format("pickup out audio device %s does not exist!", conf->audio_pickup_out_dev).GetData());
-					Error = Error_Param;
-				}
-				
-				if (Error_Param == Error){
-					icount++;
-					LogWarn(Severity_Middle, Error_Debug, EVENT_MOD_SIP_AUDIO_DEVICE_CONFIG_ERROR, CSimpleStringA::Format("%d times config audio device not exist.", icount).GetData());
-					if (icount < RVC_MAX_TRY_COUNT){
-						Sleep(icount*1000);
-					}
-				}
-			}while(Error_Param == Error && icount < RVC_MAX_TRY_COUNT);
-
 			conf->ref_active_camera = &m_stVideoParam.iActiveCamera;
 			conf->ref_camera_switch = &m_stVideoParam.iCameraSwitch;
 			conf->ref_window_state = &m_stVideoParam.nWindowState;
@@ -1767,6 +1736,7 @@ ErrorCodeEnum CSIPEntity::LoadConfig(endpoint_conf_t *conf)
 			DecideScreenCount(conf->screen_count);
 		}
 	}
+
 	return Error;
 }
 

+ 5 - 2
Module/mod_sipphone/win/volumekeeper.cpp

@@ -155,10 +155,13 @@ Exit:
 
 void *volume_keeper_create(const char *dev_key_name, int in_dev, int kept_value)
 {
-	if (!dev_key_name)
+	if (!dev_key_name) {
 		return NULL;
-	if (kept_value < 0 || kept_value > 100)
+	}
+		
+	if (kept_value < 0 || kept_value > 100) {
 		return NULL;
+	}
 
 	volume_keeper_t *inst = new volume_keeper_t(dev_key_name, in_dev, kept_value);
 	if (SUCCEEDED(inst->Init())) 

+ 1 - 11
Other/libmediaplayer/video.cpp

@@ -227,8 +227,6 @@ static void video_display(player_stat_t *is)
 {
     frame_t *vp = NULL;
 
-	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d", __FUNCTION__, __LINE__);
-
     vp = frame_queue_peek_last(&is->video_frm_queue);
 	if (0 == vp->frame->height || 0 == vp->frame->width){
 		return;
@@ -250,10 +248,8 @@ static void video_display(player_stat_t *is)
               is->m_pfrm_yuv[is->m_icurrent_index]->linesize                 // dst strides
              );
 
-	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "before SDL_WaitEvent %s:%d", __FUNCTION__, __LINE__);
 	//SDL_Event rvcevent;
 	//SDL_WaitEvent(&rvcevent);
-	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "after SDL_WaitEvent %s:%d", __FUNCTION__, __LINE__);
 
 	//if(REFRESH_EVENT == rvcevent.type){
 		//SDL_ShowWindow(is->sdl_video.window);
@@ -268,10 +264,8 @@ static void video_display(player_stat_t *is)
 							 is->m_pfrm_yuv[is->m_icurrent_index]->linesize[2]     // v pitch
 							);
     
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_UpdateYUVTexture %s:%d", __FUNCTION__, __LINE__);
 		// 使用特定颜色清空当前渲染目标
 		SDL_RenderClear(is->sdl_video.renderer);
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_RenderClear %s:%d", __FUNCTION__, __LINE__);
 		// 使用部分图像数据(texture)更新当前渲染目标
 		SDL_RenderCopy(is->sdl_video.renderer,              // sdl renderer
 			           is->sdl_video.texture,               // sdl texture
@@ -279,15 +273,11 @@ static void video_display(player_stat_t *is)
 					   &is->sdl_video.rect                  // dst rect
 					);
     
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_RenderCopy %s:%d", __FUNCTION__, __LINE__);
 
 		// 执行渲染,更新屏幕显示
 		SDL_RenderPresent(is->sdl_video.renderer);
-		//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "SDL_RenderPresent %s:%d", __FUNCTION__, __LINE__);
 		SDL_Delay(1);
 	//}
-
-	//is->rvc_hostapi->Debug(MEDIA_LOG_DEBUG, "%s:%d", __FUNCTION__, __LINE__);
 }
 
 /* called to display each frame */
@@ -373,7 +363,7 @@ static uint32_t get_video_playing_wind_flag(m_eWindType_t eType)
 	uint32_t uFlag = SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL | SDL_WINDOW_ALWAYS_ON_TOP | SDL_WINDOW_SKIP_TASKBAR | SDL_WINDOW_POPUP_MENU | SDL_WINDOW_SHOWN;
 
 #ifndef _WIN32
-	uFlag = SDL_WINDOW_OPENGL|SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP/*|SDL_WINDOW_POPUP_MENU*/;
+	uFlag = SDL_WINDOW_OPENGL|SDL_WINDOW_BORDERLESS|SDL_WINDOW_ALWAYS_ON_TOP|SDL_WINDOW_POPUP_MENU;
 #endif
 
 	return uFlag;