cmctrlrmode.c
来自「基于h323协议的软phone」· C语言 代码 · 共 519 行 · 第 1/2 页
C
519 行
return res;
}
RVAPI int RVCALLCONV
cmCallRequestModeReject(
/* Reject the request */
IN HCALL hsCall,
IN char* causeName /* requestModeReject.cause */
)
{
H245Control* ctrl=(H245Control*)cmiGetControl(hsCall);
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
int nodeId;
InRequestModeInfo* in_RM;
int message, res = RV_ERROR_UNKNOWN;
HPVT hVal;
if (!hsCall || !hApp || !causeName) return RV_ERROR_UNKNOWN;
cmiAPIEnter(hApp, "cmCallRequestModeReject: hsCall=0x%p, '%s'.", hsCall, nprn(causeName));
if (emaLock((EMAElement)hsCall))
{
int iSq;
hVal = ((cmElem *)hApp)->hVal;
in_RM=&ctrl->inRequestMode;
message=pvtAddRoot(hVal,((cmElem*)hApp)->synProtH245,0,NULL);
nodeId=pvtAddBranch2(hVal,message, __h245(response),__h245(requestModeReject));
iSq = in_RM->seqNum;
pvtAdd(hVal,nodeId,__h245(sequenceNumber),iSq,NULL,NULL);
pvtBuildByPath(hVal, pvtAddBranch(hVal,nodeId,__h245(cause)), causeName, 0, NULL);
res = sendMessageH245((HCONTROL)ctrl, message);
pvtDelete(hVal,message);
emaUnlock((EMAElement)hsCall);
}
cmiAPIExit(hApp, "cmCallRequestModeReject=%d", res);
return res;
}
RVAPI int RVCALLCONV /* request mode node id or RV_ERROR_UNKNOWN */
cmRequestModeBuild(
/* Build request mode msg */
/* Note: entryId overrides name */
IN HAPP hApp,
IN cmReqModeEntry ** modes[] /* modes matrix in preference order. NULL terminated arrays */
)
{
int rootId, i, j, _descId, _entryId, id,ret;
HPVT hVal;
if (!hApp || !modes) return RV_ERROR_UNKNOWN;
if (!modes[0]) return RV_ERROR_UNKNOWN; /* must contain at least one entry */
cmiAPIEnter(hApp, "cmRequestModeBuild: hApp=0x%p",hApp);
hVal = ((cmElem *)hApp)->hVal;
if ((rootId=pvtAddRootByPath(hVal, ((cmElem*)hApp)->synProtH245,
(char*)"request.requestMode.requestedModes", 0, NULL)) <0)
{
cmiAPIExit(hApp,"cmRequestModeBuild: [%d]",rootId);
return rootId;
}
for (i=0; modes[i]; i++)
{
_descId = pvtAdd(hVal, rootId, -444, 0, NULL, NULL);
if (_descId<0)
{
cmiAPIExit(hApp,"cmRequestModeBuild: [%d]",_descId);
return _descId;
}
for (j=0; modes[i][j]; j++)
{
if (modes[i][j]->entryId >=0)
{
_entryId = pvtAdd(hVal, _descId, -445, 0, NULL, NULL);
if (_entryId<0)
{
cmiAPIExit(hApp,"cmRequestModeBuild: [%d]",_entryId);
return _entryId;
}
pvtMoveTree(hVal, _entryId, modes[i][j]->entryId);
}
else
{
if (confGetModeEntry(hVal, ((cmElem*)hApp)->h245Conf, modes[i][j]->name, &id)==RV_TRUE)
{
ret =pvtAddTree(hVal, _descId, hVal, id);
if (ret<0)
{
cmiAPIExit(hApp,"cmRequestModeBuild: [%d]",ret);
return ret;
}
}
}
}
}
cmiAPIExit(hApp,"cmRequestModeBuild: hApp=0x%p, root =%d",hApp,rootId);
return rootId;
}
/*
#define CM_MAX_MODES 32
#define CM_MAX_MODES_PTR (CM_MAX_MODES+10)
*/
int /* RV_TRUE or RV_ERROR_UNKNOWN */
cmGetModeTypeName(
/* Generate dataName using field name as in H.245 standard. */
IN HPVT hVal,
IN int dataTypeId, /* ModeElement node id */
IN int dataNameSize,
OUT char *dataName, /* copied into user allocate space [128 chars] */
OUT confDataType* type, /* of data */
OUT RvInt32* typeId /* node id of media type */
)
{
HPST synConf = pvtGetSynTree(hVal, dataTypeId);
int dataId = pvtChild(hVal, dataTypeId);
int choice=-1;
RvPstFieldId fieldId=-1;
RvInt32 _typeId=dataId;
choice = pvtGetSyntaxIndex(hVal, dataId);
switch(choice)
{
case 1: /* non standard */
case 2:
case 3: /* video and audio */
_typeId = pvtChild(hVal, dataId);
break;
case 4: /* data */
_typeId = pvtChild(hVal, pvtChild(hVal, dataId));
break;
default:
strncpy(dataName, "encryptionData - not supported", (RvSize_t)dataNameSize);
break;
}
if (dataName)
{
pvtGet(hVal, _typeId, &fieldId, NULL, NULL, NULL);
pstGetFieldName(synConf, fieldId, dataNameSize, dataName);
}
if (type) *type=(confDataType)choice;
if (typeId) *typeId = _typeId;
return RV_TRUE;
}
int
cmRequestModeBuildStructEntry(
/* Set the request mode structure by entry id */
IN HPVT hVal,
IN RvInt32 entryId,
cmReqModeEntry *entry
)
{
entry->entryId = entryId;
cmGetModeTypeName(hVal, pvtChild(hVal, entryId), sizeof(entry->name), entry->name, NULL, NULL);
return RV_TRUE;
}
RVAPI int RVCALLCONV /* RV_TRUE or RV_ERROR_UNKNOWN */
cmRequestModeStructBuild(
/* Build request mode matrix structure from msg */
/* Note: entry name as in h.245 standard */
IN HAPP hApp,
IN RvInt32 descId, /* requestMode.requestedModes node id */
IN cmReqModeEntry **entries, /* user allocated entries */
IN int entriesSize, /* number of entries */
IN void **entryPtrs, /* pool of pointers to construct modes */
IN int ptrsSize, /* number of ptrs */
/* modes matrix in preference order. NULL terminated arrays */
OUT cmReqModeEntry ***modes[]
)
{
/*
D: Descriptor
E: Entry
-: null
---------------------------------------------------------------------------
| D(1) D(2) ... D - E(1,1) E2(1,2) ... E - E(2,1) - ... - E... E - - ===> |
---------------------------------------------------------------------------
*/
/*
cmReqModeEntry entries[CM_MAX_MODES];
void *entryPtrs[CM_MAX_MODES_PTR];
*/
int _descNum, _entryNum, _descId, _entryId, i, j;
int _entryPos=0; /* vacant position in entries */
int _entryPtrPos=0; /* next array position */
HPVT hVal;
if (!hApp || !modes || descId<0 || !entries || !entryPtrs) return RV_ERROR_UNKNOWN;
cmiAPIEnter(hApp, "cmRequestModeStructBuild: hApp=0x%p",hApp);
hVal = ((cmElem *)hApp)->hVal;
if ((_descNum = pvtNumChilds(hVal, descId)) > ptrsSize)
{
cmiAPIExit(hApp, "cmRequestModeStructBuild: hApp=0x%p: Overflow",hApp);
return RV_ERROR_UNKNOWN; /* overflow */
}
entryPtrs[_descNum]=NULL; /* terminator */
_entryPtrPos = _descNum+1;
for (i=0; i<_descNum; i++)
{
_descId = pvtGetByIndex(hVal, descId, i+1, NULL);
_entryNum = pvtNumChilds(hVal, _descId);
entryPtrs[i]=&entryPtrs[_entryPtrPos];
for (j=0; j<_entryNum; j++)
{
_entryId = pvtGetByIndex(hVal, _descId, j+1, NULL);
if (_entryPtrPos+j >= ptrsSize || _entryPos >= entriesSize) /* overflow */
{
cmiAPIExit(hApp, "cmRequestModeStructBuild: RV_ERROR_UNKNOWN");
return RV_ERROR_UNKNOWN;
}
cmRequestModeBuildStructEntry(hVal, _entryId, entries[_entryPos]);
entryPtrs[_entryPtrPos+j] = entries[_entryPos];
_entryPos++;
}
entryPtrs[_entryPtrPos+j]=NULL;
_entryPtrPos+=_entryNum+1;
}
*modes = (cmReqModeEntry***)entryPtrs;
cmiAPIExit(hApp, "cmRequestModeStructBuild: hApp=0x%p",hApp);
return RV_TRUE;
}
#ifdef __cplusplus
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?