|
@@ -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;
|
|
|
}
|
|
|
|