Переглянути джерело

Z991239-5745 #comment 优化获取音频设备列表json串结构

80274480 1 рік тому
батько
коміт
9ea1923306

+ 14 - 34
Module/mod_counterconnector/ConnectorFSM.cpp

@@ -800,7 +800,7 @@ void ACMCallFSM::s8_on_entry()
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("get call route list failed.");
 	}
 	
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304C1")("start remote video call");
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C1")("start remote video call");
 
 	int time = GetDelayTime();
 
@@ -870,8 +870,6 @@ void ACMCallFSM::s11_on_entry()
 	m_uConnectTime = y2k_time_now();
 	m_bConnected = false;
 	m_lConnectCostTime = SP::Module::Comm::RVCGetTickCount();
-	
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304Z80101")("begin remote video call");
 
 	if (m_nCurSipServer == CurServerNum::Error_Server){
 		m_LastSipError = Error_NetBroken;
@@ -937,13 +935,11 @@ void ACMCallFSM::s11_on_entry()
 	if (m_LastSipError != Error_Succeed) 
 	{
 		PostEventFIFO(new FSMEvent(USER_EVT_JMP_FAIL));
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80201").setResultCode("RTA3421")("send sip failed!");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C2").setResultCode("RTA3421")("send sip failed!");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C2").setResultCode("RTA3421")("send sip failed!");
 	}
 	else
 	{
 		ScheduleTimer(11,SIP_CALL_TIMER);
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304Z80201")("send sip success!");
 	}
 }
 
@@ -973,8 +969,7 @@ unsigned int ACMCallFSM::s11_on_event(FSMEvent* event)
 		}
 		(bool)m_nCurSipServer?(m_nCurSipServer= CurServerNum::Error_Server):(m_nCurSipServer= CurServerNum::BACK_SERVER);
 		m_nSipErrorNum++;
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80301").setResultCode("RTA3432")("sip connect failed for server error.");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C2").setResultCode("RTA3432")("sip connect failed for server error.");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C2").setResultCode("RTA3432")("sip connect failed for server error.");
 	} 
 	else if (event->iEvt == USER_EVT_ASSISTCHAN_IDEL)
 	{
@@ -1005,8 +1000,7 @@ unsigned int ACMCallFSM::s11_on_event(FSMEvent* event)
 		if (ReConnectionSipphone()) {
 			m_bConSipphone = true;
 		}
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80301").setResultCode("RTA3434")("sip connect failed for entity error");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C2").setResultCode("RTA3434")("sip connect failed for entity error");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C2").setResultCode("RTA3434")("sip connect failed for entity error");
 	}
 	else if (event->iEvt == EVT_TIMER)
 	{
@@ -1021,8 +1015,7 @@ unsigned int ACMCallFSM::s11_on_event(FSMEvent* event)
 		}
 		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("sip call timeout,release call");
 		m_nSipErrorNum++;
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80301").setResultCode("RTA3435")("sip connect failed for timeout");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C2").setResultCode("RTA3435")("sip connect failed for timeout");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C2").setResultCode("RTA3435")("sip connect failed for timeout");
 	}
 	else if (event->iEvt == USER_EVT_JMP_FAIL)
 	{
@@ -1036,8 +1029,7 @@ unsigned int ACMCallFSM::s11_on_event(FSMEvent* event)
 			LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_COUNTERCONNECT_SIPCONNECT_FUNC_FAILED,"sipphone connect func failed, error server");
 		}
 		m_nSipErrorNum++;
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80301").setResultCode("RTA3436")("sip connect failed for entity error");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C2").setResultCode("RTA3436")("sip connect failed for entity error");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C2").setResultCode("RTA3436")("sip connect failed for entity error");
 	}
 	else if (event->iEvt == USER_EVT_STOPLOACALREMOTEVIDEO) 
 	{
@@ -1050,9 +1042,7 @@ unsigned int ACMCallFSM::s11_on_event(FSMEvent* event)
 
 void ACMCallFSM::s12_on_entry() 
 {
-	//ErrorCodeEnum Error = Error_Succeed;
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304Z80301")("sip connect success!");
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304C2")("sip channel connect success!");
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C2")("sip channel connect success!");
 	m_LastAssistError = Error_Succeed;
 	if (m_nCurChanServer == CurServerNum::Error_Server)
 	{
@@ -1081,21 +1071,15 @@ void ACMCallFSM::s12_on_entry()
 	if (m_LastAssistError != Error_Succeed) {
 		PostEventFIFO(new FSMEvent(USER_EVT_JMP_FAIL));
 		if (Error_NetBroken == m_LastAssistError) {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80401").setResultCode("RTA3441")("assistant channel connect failed for net broken");
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C3").setResultCode("RTA3441")("assistant channel connect failed for net broken");
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3").setResultCode("RTA3441")("assistant channel connect failed for net broken");
 		}
 		else if (Error_Param == m_LastAssistError) {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80401").setResultCode("RTA3442")("assistant channel connect failed error param");
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C3").setResultCode("RTA3442")("assistant channel connect failed error param");
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3").setResultCode("RTA3442")("assistant channel connect failed error param");
 		}
 		else {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80401").setResultCode("RTA3443")("assistant channel connect failed");
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C3").setResultCode("RTA3443")("assistant channel connect failed");
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3").setResultCode("RTA3443")("assistant channel connect failed");
 		}
 	}
-	else {
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304Z80401")("assistant channel connect success!");
-	}
 }
 
 void ACMCallFSM::s12_on_exit() {}
@@ -1136,8 +1120,7 @@ unsigned int ACMCallFSM::s12_on_event(FSMEvent* event)
 				LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_COUNTERCONNECT_CHANCONNECT_CHANSTATE_IDLE,"chan connect server failed, error server");
 			}
 			(bool)m_nCurChanServer?(m_nCurChanServer= CurServerNum::Error_Server):(m_nCurChanServer= CurServerNum::BACK_SERVER);
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80501").setResultCode("RTA3452")("assistant channel bridge failed for server error");
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C3").setResultCode("RTA3452")("assistant channel bridge failed for server error");
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3").setResultCode("RTA3452")("assistant channel bridge failed for server error");
 		}
 		HangupCall();
 		//StopVideo();
@@ -1146,8 +1129,7 @@ unsigned int ACMCallFSM::s12_on_event(FSMEvent* event)
 	{
 		ChanStateConnectedEvent *e = static_cast<ChanStateConnectedEvent *>(event);
 		StartVideo(e->m_param.GetData());
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304Z80501")("assistant channel bridge success!");
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER).setLogCode("QLR0402304C3")("assistant channel bridge success!");
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3")("assistant channel bridge success!");
 	}
 	else if (event->iEvt == USER_EVT_ASSISTCHAN_IDEL)
 	{
@@ -1164,8 +1146,7 @@ unsigned int ACMCallFSM::s12_on_event(FSMEvent* event)
 		if (ReConnectionAssistchan()) {
 			m_bConAssist = true;
 		}
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80501").setResultCode("RTA3453")("assistant channel bridge failed for entity restart");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C3").setResultCode("RTA3453")("assistant channel bridge failed for entity restart");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3").setResultCode("RTA3453")("assistant channel bridge failed for entity restart");
 	}
 	else if (event->iEvt == USER_EVT_SIPPHONE_IDEL)
 	{
@@ -1200,8 +1181,7 @@ unsigned int ACMCallFSM::s12_on_event(FSMEvent* event)
 		else{
 			LogWarn(Severity_Low, Error_Unexpect, LOG_WARN_COUNTERCONNECT_CHANCONNECT_FUNC_FAILED,"chan connect func failed, error server");
 		}
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304Z80501").setResultCode("RTA3454")("assistant channel bridge failed for entity error");
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER).setLogCode("QLR0402304C3").setResultCode("RTA3454")("assistant channel bridge failed for entity error");
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setLogCode("QLR0402304C3").setResultCode("RTA3454")("assistant channel bridge failed for entity error");
 	}
 	
 	return 0;

+ 0 - 2
Module/mod_sipphone/CMakeLists.txt

@@ -149,7 +149,6 @@ set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS}
 	libaudions
 	audiomgr
 	videorender
-	libpublicFun
 )
 else(WIN32)
 set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS} 	
@@ -173,7 +172,6 @@ set(${MODULE_PREFIX}_LIBS  ${MODULE_BASE_LIBS}
 	videorender
 	audiomgr
 	libaudions
-	libpublicFun
 )
 endif(WIN32)
 

+ 17 - 29
Module/mod_sipphone/audio_session.cpp

@@ -10,9 +10,6 @@
 #include <string>
 #include "iaudionsinterface.h"
 
-#include <map>
-#include "CommEntityUtil.hpp"
-
 #ifdef RVC_OS_WIN
 #include <portaudio.h>
 #endif
@@ -361,7 +358,6 @@ static int phonemedia_start(audio_session_t *session)
 	if (rc != 0) {
 		LogWarn(Severity_Middle, Error_Debug, ERROR_MOD_SIP_AUDIO_RTP_SESSION_CREATE_FAILED, CSimpleStringA::Format("audio rtp session create2 failed and local port is %d, rc=%d", conf->local_rtp_port, rc).GetData());
 		DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_SYSTEM).setLogCode("QLR0402301A5").setResultCode("RTA310F")("创建音频流通道失败");
-		//LogWarn(Severity_Low, Error_InvalidState, EVENT_MOD_SIP_AUDIO_RTP_CREATE, CSimpleStringA::Format("audio rtp session create2 failed and local port is %d, rc=%d", conf->local_rtp_port, rc).GetData());
 		goto on_error;
 	}
 
@@ -395,7 +391,7 @@ static int phonemedia_start(audio_session_t *session)
 		opt_micspk |= AMS2_OPT_AEC;
 #ifdef RVC_OS_WIN
 	//create Spk 
-status = audiomicspk2_create(media->micspk_pool, media->engine, opt_micspk, AUDIO_CLOCK, in_dev, out_dev, conf->dev_type, &audio_device_event, &media->micspkstream);
+	status = audiomicspk2_create(media->micspk_pool, media->engine, opt_micspk, AUDIO_CLOCK, in_dev, out_dev, conf->dev_type, &audio_device_event, &media->micspkstream);
 #else
 	status = audiomicspkpulse_create(media->micspk_pool, media->engine, opt_micspk, AUDIO_CLOCK, in_dev, out_dev, conf->dev_type, &audio_device_event, &media->micspkstream);
 #endif
@@ -480,12 +476,9 @@ status = audiomicspk2_create(media->micspk_pool, media->engine, opt_micspk, AUDI
 		audiortp_set_param(media->rtpstream, AUDIO_RTP_FLAG_SEND_PTIME, &param);
 		param = conf->remote_ptime;
 		audiortp_set_param(media->rtpstream, AUDIO_RTP_FLAG_RECV_PTIME, &param);
-		//media->rtpstream->m_on_send_hook = &m_on_recv_hook;
-		//DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("recv hook addr %d,send hook addr %d", &m_on_recv_hook,&m_on_send_hook);
 		audiortp_set_param(media->rtpstream, AUDIO_RTP_FLAG_HOOK_ARG, media);
 		audiortp_set_param(media->rtpstream, AUDIO_RTP_FLAG_RECV_HOOK, (const void*)&recv_hook_callback);
 		audiortp_set_param(media->rtpstream, AUDIO_RTP_FLAG_SEND_HOOK, (const void*)&send_hook_callback);
-		//audiortp_set_param(media->rtpstream, AUDIO_RTP_FLAG_HOOK_ARG, media->rtpstream);
 		audiortp_init(media->rtpstream);
 	}
 
@@ -954,16 +947,18 @@ CSimpleStringA audio_get_dev_infos(bool in_direction)
 	int cnt = Pa_GetDeviceCount();
 	
 	CSimpleStringA strAudioJson("");
+	Json::Value rootReq;
 	for (int i = 0; i < cnt; ++i) {
 		const PaDeviceInfo* pinfo = Pa_GetDeviceInfo(i);
-		std::map<std::string, std::string> msgInfo;
+		Json::Value item;
 		if (in_direction) {
 			if (pinfo->maxInputChannels > 0) {
-				msgInfo["name"] = pinfo->name;
-				msgInfo["samprate"] = CSimpleStringA::Format("%d", (int)pinfo->defaultSampleRate).GetData();
-				msgInfo["channels"] = CSimpleStringA::Format("%d", pinfo->maxInputChannels).GetData();
-				msgInfo["low_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultLowInputLatency).GetData();
-				msgInfo["high_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultHighInputLatency).GetData();
+				item["name"] = pinfo->name;
+				item["samprate"] = CSimpleStringA::Format("%d", (int)pinfo->defaultSampleRate).GetData();
+				item["channels"] = CSimpleStringA::Format("%d", pinfo->maxInputChannels).GetData();
+				item["low_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultLowInputLatency).GetData();
+				item["high_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultHighInputLatency).GetData();
+				rootReq["MicrophoneInfo"].append(item);
 			}
 			else {
 				continue;
@@ -971,28 +966,21 @@ CSimpleStringA audio_get_dev_infos(bool in_direction)
 		}
 		else {
 			if (pinfo->maxOutputChannels > 0) {
-				msgInfo["name"] = pinfo->name;
-				msgInfo["samprate"] = CSimpleStringA::Format("%d", (int)pinfo->defaultSampleRate).GetData();
-				msgInfo["channels"] = CSimpleStringA::Format("%d", pinfo->maxOutputChannels).GetData();
-				msgInfo["low_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultLowOutputLatency).GetData();
-				msgInfo["high_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultHighOutputLatency).GetData();
+				item["name"] = pinfo->name;
+				item["samprate"] = CSimpleStringA::Format("%d", (int)pinfo->defaultSampleRate).GetData();
+				item["channels"] = CSimpleStringA::Format("%d", pinfo->maxOutputChannels).GetData();
+				item["low_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultLowOutputLatency).GetData();
+				item["high_latency"] = CSimpleStringA::Format("%.2f", pinfo->defaultHighOutputLatency).GetData();
+				rootReq["SpeakerInfo"].append(item);
 			}
 			else {
 				continue;
 			}
 		}
-
-		std::pair<bool, std::string> strResult;
-		strResult = generateJsonStr(msgInfo);
-		if (strResult.first) {
-			strAudioJson += strResult.second.c_str();
-			strAudioJson += ",";
-		}
 	}
 
-	if (strAudioJson.GetLength() > 0) {
-		strAudioJson[strAudioJson.GetLength() - 1] = '\0';
-	}
+	Json::StyledWriter sw;
+	strAudioJson = sw.write(rootReq).c_str();
 
 	return strAudioJson;
 }

+ 1 - 0
Module/mod_sipphone/audio_session.h

@@ -6,6 +6,7 @@
 #include "../mod_counterconnector/CallType.h"
 #include "EventCode.h"
 #include "Event.h"
+#include "json/json.h"
 
 enum e_dev_type
 {

+ 25 - 20
Module/mod_sipphone/mod_sipphone.cpp

@@ -853,6 +853,8 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 {
 	ErrorCodeEnum Error = Error_Succeed;
 
+	m_eDeviceType = RvcGetDeviceType();
+
 	audiomgr_callback_t t_callback = { 0 };
 	t_callback.debug = &__audiomgrlog;
 	m_pAudioMgr = CreateAudioMgrObj(&t_callback);
@@ -866,7 +868,6 @@ ErrorCodeEnum CSIPEntity::__OnStart(ErrorCodeEnum preOperationError)
 	}
 	SetSoundCardSysVar(SOUNDCARD_INIT_STATE);
 
-	m_eDeviceType = RvcGetDeviceType();
 	m_stVideoParam.bActiveInspect = 0;
 	m_stVideoParam.bShowActiveImg = 0;
 	m_stVideoParam.nWindowState = 0;
@@ -2376,32 +2377,36 @@ void CSIPEntity::ShowBothVideo()
 CSimpleStringA CSIPEntity::GetAudioDeviceJsonInfos(bool bmicro)
 {
 	CSimpleStringA strAudioDevJson("");
+	Json::Value rootReq;
 	if (NULL != m_pAudioMgr) {
-		int iaudiocount = m_pAudioMgr->audio_get_device_count(bmicro);
+		char* strkey = NULL;
+		if (bmicro) {
+			strkey = "MicrophoneInfo";
+		}
+		else {
+			strkey = "SpeakerInfo";
+		}
+
+		int iaudiocount = m_pAudioMgr->audio_get_device_count(bmicro);		
 		for (int i = 0; i < iaudiocount; i++) {
 			rvc_audio_device_t* audio_dev = m_pAudioMgr->audio_get_device_infos(bmicro, i);
 
-			std::map<std::string, std::string> msgInfo;
-			msgInfo["name"] = audio_dev->name;
-			msgInfo["description"] = audio_dev->description;
-			msgInfo["samprate"] = CSimpleStringA::Format("%d", audio_dev->samprate).GetData();
-			msgInfo["channels"] = CSimpleStringA::Format("%d", audio_dev->channels).GetData();
-			msgInfo["low_latency"] = CSimpleStringA::Format("%.2f", audio_dev->low_latency).GetData();
-			msgInfo["high_latency"] = CSimpleStringA::Format("%.2f", audio_dev->high_latency).GetData();
-		
-			std::pair<bool, std::string> strResult;
-			strResult = generateJsonStr(msgInfo);
-			if (strResult.first) {
-				strAudioDevJson += strResult.second.c_str();
-				strAudioDevJson += ",";
-			}
-		}
-
-		if (strAudioDevJson.GetLength() > 0) {
-			strAudioDevJson[strAudioDevJson.GetLength() - 1] = '\0';
+			Json::Value item;
+			item["name"] = audio_dev->name;
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("item[\"name\"] = %s.", item["name"].asCString());
+			item["description"] = audio_dev->description;
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("item[\"description\"] = %s.", item["description"].asCString());
+			item["samprate"] = CSimpleStringA::Format("%d", audio_dev->samprate).GetData();
+			item["channels"] = CSimpleStringA::Format("%d", audio_dev->channels).GetData();
+			item["low_latency"] = CSimpleStringA::Format("%.2f", audio_dev->low_latency).GetData();
+			item["high_latency"] = CSimpleStringA::Format("%.2f", audio_dev->high_latency).GetData();
+			rootReq[strkey].append(item);
 		}
 	}
 
+	Json::StyledWriter sw;
+	strAudioDevJson = sw.write(rootReq).c_str();
+
 	return strAudioDevJson;
 }