📄 income.c
字号:
#include <stdlib.h>
#include <malloc.h>
#include "rvmemory.h"
#include "rvwpt.h"
#include <stdio.h>
#include <string.h>
extern int allowFastStart;
extern FILE* fp;
extern RvSemaphore* fileSem;
int RVCALLCONV cmCallOffer(
IN HAPPCALL haCall,
IN HCALL hsCall,
IN cmCallState_e state,
IN cmCallStateMode_e stateMode,
IN WrapperMsg* wpmsg
)
{
int callIndex;
RvInt32 IsFastConnect = RV_FALSE;
char display[MAX_DISPLAY_LENGTH + 1];
RvInt32 size = MAX_DISPLAY_LENGTH;
cmCallType callType = 0;
cmTransportAddress callta;
cmAlias callAlias;
int i;
int ret;
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"Received Setup message\n");
ReleaseSemaphore(fileSem,1,NULL);
}
*/ memset(wpmsg, 0 ,sizeof(WrapperMsg));
wpmsg->msgId = WP_REC_QUERY_AVA;
IsFastConnect = (cmCallGetParam(hsCall, cmParamSetupFastStart, 0, &IsFastConnect, NULL) >= 0);
callIndex = wPGetCallIndex(hsCall);
if (callIndex == -1)
{
callIndex = wPGetCallIndex(0);
if (callIndex == -1)
{
return -1;
}
}
wpCallInfo[callIndex].hsCall = hsCall;
wpmsg->baseInfo.callIndex = callIndex;
wpCallInfo[callIndex].isFastConnect = IsFastConnect;
wpCallInfo[callIndex].isIncoming = RV_TRUE;
memset(display, 0, sizeof(display));
if (cmCallGetParam(hsCall, cmParamDisplay, 0, &size, display) < 0)
{
strcpy(display, "unknown");
}
strncpy(wpmsg->baseInfo.display, display, MAX_DISPLAY_LENGTH);
wpmsg->baseInfo.display[MAX_DISPLAY_LENGTH] = '\0';
if (cmCallGetParam(hsCall, cmParamCallType, 0, (RvInt32*)&callType, NULL) < 0)
{
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"can't get call type from incoming call!\n");
ReleaseSemaphore(fileSem,1,NULL);
}*/
}
if (callType == cmCallTypeP2P)
{
ret = 0;
i = 0;
callAlias.string = (char *) malloc(sizeof(char)*250);
while (ret >= 0)
{
ret = cmCallGetParam(hsCall, cmParamSourceAddress, i,
(int *) sizeof(callAlias), (char *) &callAlias);
if (ret >= 0)
{
switch (callAlias.type)
{
case cmAliasTypeE164:
case cmAliasTypePartyNumber:
{
callAlias.string[callAlias.length] = '\0';
strncpy(wpmsg->baseInfo.remoteE164Num, callAlias.string, MAX_E164NUM_LENGTH);
wpmsg->baseInfo.remoteE164Num[MAX_E164NUM_LENGTH] = '\0';
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"Remote E.164 number = %s\n", callAlias.string);
ReleaseSemaphore(fileSem,1,NULL);
}
*/ break;
}
case cmAliasTypeH323ID:
{
int i;
callAlias.string[callAlias.length] = '\0';
/*memset(wpmsg->baseInfo.remoteH323Id, 0, callAlias.length+20);*/
for (i = 0; i < callAlias.length/2; i++)
{
wpmsg->baseInfo.remoteH323Id[i] = callAlias.string[i*2+1];
}
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"Remote H.323 Id = %s\n", wpmsg->baseInfo.remoteH323Id);
ReleaseSemaphore(fileSem,1,NULL);
}
*/ break;
}
default:
{
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"Other alias type, ignore it\n");
ReleaseSemaphore(fileSem,1,NULL);
}*/
}
}
i++;
}
}
/* Get the calling end's number from [SourceAddress] first, if failed,
* try to get from [CallingPartyNumber].
*/
if (wpmsg->baseInfo.remoteE164Num == NULL || wpmsg->baseInfo.remoteE164Num[0] == 0)
{
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"Try to get remote number from CallingPartyNumber\n");
ReleaseSemaphore(fileSem,1,NULL);
}*/
ret = cmCallGetParam(hsCall, cmParamCallingPartyNumber, 0,
(int *) sizeof(callAlias), (char *) &callAlias);
if (ret >= 0)
{
callAlias.string[callAlias.length] = '\0';
strncpy(wpmsg->baseInfo.remoteE164Num, callAlias.string, MAX_E164NUM_LENGTH);
wpmsg->baseInfo.remoteE164Num[MAX_E164NUM_LENGTH] = '\0';
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"Remote calling party number = %s\n", callAlias.string);
ReleaseSemaphore(fileSem,1,NULL);
}*/
}
}
free(callAlias.string);
size = sizeof(cmTransportAddress);
if (cmCallGetParam(hsCall, cmParamSrcCallSignalAddress, 0, &size, (char*)&callta) < 0)
{
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"can't get src call signal address from incoming call!\n");
ReleaseSemaphore(fileSem,1,NULL);
}*/
wpmsg->baseInfo.remoteIpAddr = 0;
}
else
{
/* if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0)
{
fprintf(fp,"get srcCallSignalAddress:%x:%d\n", callta.ip, callta.port);
ReleaseSemaphore(fileSem,1,NULL);
}*/
wpmsg->baseInfo.remoteIpAddr = callta.ip;
}
}
else if (callType == cmCallTypeN2Nw)
{
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -