📄 cmctrlmpoint.c
字号:
cmiAPIEnter(hApp, "cmCallSetTerminalLabel: hsCall=0x%p &label=%p", hsCall, terminalLabel);
if (emaLock((EMAElement)hsCall))
{
if (cmCallMasterSlaveStatus(hsCall) == cmMSMaster)
{
terminalLabel->mcuNumber = 255;
terminalLabel->terminalNumber = 255;
ret = RV_ERROR_UNKNOWN;
}
else
{
*terminalLabel=ctrl->myTerminalLabel;
if (terminalLabel->mcuNumber>192) ret=RV_ERROR_UNKNOWN;
}
emaUnlock((EMAElement)hsCall);
}
cmiAPIExit(hApp, "cmCallSetTerminalLabel: label=(%d, %d) [%d].",terminalLabel->mcuNumber, terminalLabel->terminalNumber, ret);
return ret;
}
static
int cmCallSetChannelsInternal(
/* As an Active MC, set transfer channels for remote terminal */
IN HCALL hsCall,
IN int channelSetSize, /* number of elements in channelSet */
IN cmChannelStruct channelSet[],
IN RvBool useNewFields
);
/* The master (MC) terminal shall use cmCallSetChannels() to force the remote terminal to open
the indicated channels for transmit. */
RVAPI
int RVCALLCONV cmCallSetChannels(
/* As an Active MC, set transfer channels for remote terminal */
IN HCALL hsCall,
IN int channelSetSize, /* number of elements in channelSet */
IN cmChannelStruct channelSet[]
)
{
int ret;
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
cmiAPIEnter(hApp, "cmCallSetChannels: hsCall=0x%p channelSetSize=%d", hsCall, channelSetSize);
ret = cmCallSetChannelsInternal(hsCall,channelSetSize,channelSet,RV_FALSE);
cmiAPIExit(hApp, "cmCallSetChannels: [%d].",ret);
return ret;
}
RVAPI
int RVCALLCONV cmCallSetChannelsExt(
/* As an Active MC, set transfer channels for remote terminal */
IN HCALL hsCall,
IN int channelSetSize, /* number of elements in channelSet */
IN cmChannelStruct channelSet[]
)
{
int ret;
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
cmiAPIEnter(hApp, "cmCallSetChannelsExt: hsCall=0x%p channelSetSize=%d", hsCall, channelSetSize);
ret = cmCallSetChannelsInternal(hsCall,channelSetSize,channelSet,RV_TRUE);
cmiAPIExit(hApp, "cmCallSetChannelsExt: [%d].",ret);
return ret;
}
#define markSID(sids,sid) setBitTrue((sids),(sid))
#define checkSID(sids,sid) getBit((sids),(sid))
int markFreeSID(RvUint8 sids[32],cmCapDataType type)
{
int sid;
if (type)
if (!checkSID(sids,type))
{
markSID(sids,type);
return type;
}
sid=get1st0BitNumber(sids, 32, 255);
if (sid<=255)
return sid;
return -1;
}
static
int cmCallSetChannelsInternal(
/* As an Active MC, set transfer channels for remote terminal */
IN HCALL hsCall,
IN int channelSetSize, /* number of elements in channelSet */
IN cmChannelStruct channelSet[],
IN RvBool useNewFields
)
{
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
int i, ret=RV_TRUE;
int message, tableId, elemId=-1;
RvBool dependencySet=RV_TRUE;
H245Control* ctrl=(H245Control*)cmiGetControl(hsCall);
RvUint8 sids[32];
if (!hsCall || !hApp || channelSetSize<=0) return RV_ERROR_UNKNOWN;
cmiAPIEnter(hApp, "cmCallSetChannels: hsCall=0x%p, setSize=%d, &set=0x%p", hsCall, channelSetSize, channelSet);
if (emaLock((EMAElement)hsCall))
{
HPVT hVal = ((cmElem *)hApp)->hVal;
if (ctrl->eState!=ctrlConference || !ctrl->bIsMaster)
{
emaUnlock((EMAElement)hsCall);
cmiAPIExit(hApp, "cmCallSetChannelsExt: [-1]. (Wrong state)");
return RV_ERROR_UNKNOWN;
}
message=pvtAddRoot(hVal,((cmElem*)hApp)->synProtH245,0,NULL);
__pvtBuildByFieldIds(tableId,hVal,message, {_h245(command) _h245(communicationModeCommand)
_h245(communicationModeTable) LAST_TOKEN}, 0, NULL);
memset(sids,0,sizeof(sids));
for (i=0; i<channelSetSize; i++)
{
/*Go through all the incoming channels */
/*Their SID must be preserved */
H245Channel*channel=(H245Channel*)channelSet[i].hsChan;
elemId=pvtAddBranch(hVal, tableId, -800);
if (channel && !channel->bOrigin && channel->sessionId!=0)
{
pvtAdd(hVal, elemId, __h245(sessionID), channel->sessionId, NULL, NULL);
markSID(sids,channel->sessionId);
}
}
elemId = pvtChild(hVal,tableId);
for (i=0; i<channelSetSize; i++)
{
/*Now go through all the outgoing channels */
/*Try to preserve their SID*/
H245Channel*channel=(H245Channel*)channelSet[i].hsChan;
if (channel && channel->bOrigin && channel->sessionId!=0 && !checkSID(sids,channel->sessionId))
{
pvtAdd(hVal, elemId, __h245(sessionID), channel->sessionId, NULL, NULL);
markSID(sids,channel->sessionId);
}
elemId = pvtBrother(hVal,elemId);
}
elemId = pvtChild(hVal,tableId);
for (i=0; i<channelSetSize; i++)
{
H245Channel*channel=(H245Channel*)channelSet[i].hsChan;
RvLogDebug(&((cmElem*)hApp)->log,
(&((cmElem*)hApp)->log, "cmCallSetChannels: [%d] hs=0x%p '%s'(%d) label: %d/%d desc:'%s' rtp=0x%x:%d rtcp=0x%x:%d.",
i, channelSet[i].hsChan,
nprn(channelSet[i].channelName), channelSet[i].channelDataTypeHandle,
channelSet[i].terminalLabel.mcuNumber, channelSet[i].terminalLabel.terminalNumber,
nprn(channelSet[i].sessionDescription),
channelSet[i].rtpAddress.ip, channelSet[i].rtpAddress.port,
channelSet[i].rtcpAddress.ip, channelSet[i].rtcpAddress.port));
/* ADD dataType field */
{
int dataId = pvtAddBranch(hVal, elemId, __h245(dataType));
if (channelSet[i].channelName != NULL || channelSet[i].channelDataTypeHandle >=0)
{ /* new type */
if (channelSet[i].channelName)
{
if (confGetDataType(hVal, ((cmElem*)hApp)->h245Conf, channelSet[i].channelName, dataId, NULL, RV_TRUE) <0)
{
RvLogError(&((cmElem*)hApp)->logERR,
(&((cmElem*)hApp)->logERR, "cmCallSetChannels: No configuration data type available for %s",nprn(channelSet[i].channelName)));
ret=-1;
break;
}
}
else
{
ret = pvtAddTree(hVal, dataId, hVal, (int)channelSet[i].channelDataTypeHandle);
}
}
else
if (channel && channel->dataTypeID>=0)
{
int nonH235DataTypeId=pvtGetChild2(hVal,channel->dataTypeID,__h245(h235Media) , __h245(mediaType));
pvtAddTree(hVal, dataId, hVal, pvtChild(hVal,(int)(nonH235DataTypeId>=0)?nonH235DataTypeId:channel->dataTypeID));
}
else
{ /* dataType must be set in some way*/
RvLogError(&((cmElem*)hApp)->logERR, (&((cmElem*)hApp)->logERR,
"cmCallSetChannels: No data type available"));
ret=-1;
break;
}
/* Add sessionID field in the cases it was impossible to determine it before*/
if (pvtGetChild(hVal,elemId,__h245(sessionID),NULL)<=0)
{
RvPstFieldId fieldId;
cmCapDataType type=cmCapEmpty;
int sid;
pvtGet(hVal,pvtChild(hVal,dataId),&fieldId,NULL,NULL,NULL);
switch(fieldId)
{
case __h245(audioData): type=cmCapAudio;break;
case __h245(videoData): type=cmCapVideo;break;
case __h245(data): type=cmCapData; break;
}
sid=markFreeSID(sids,type);
pvtAdd(hVal, elemId, __h245(sessionID), sid, NULL, NULL);
}
}
/* ADD redundancyEncoding field */
if (useNewFields)
{
int redEncId, redEncodingId=RV_ERROR_UNKNOWN;
if (channelSet[i].redEncodingId>=0)
redEncodingId=channelSet[i].redEncodingId;
else
if (channel && channel->pChannelParams.data.h225Params.redEncID>=0)
redEncodingId=channel->pChannelParams.data.h225Params.redEncID;
if (redEncodingId>=0)
{
redEncId=pvtAddBranch(hVal, elemId, __h245(redundancyEncoding));
pvtSetTree(hVal,redEncId,hVal,redEncodingId);
}
}
/* ADD associatedSessionID field */
if (channelSet[i].hsChanAssociate)
{
H245Channel* channel=(H245Channel*) channelSet[i].hsChanAssociate;
pvtAdd(hVal, elemId, __h245(associatedSessionID), channel->sessionId, NULL, NULL);
}
/* ADD terminalLabel field */
if (channelSet[i].terminalLabel.mcuNumber <= 192 && channelSet[i].terminalLabel.terminalNumber <= 192)
{
int nid = pvtAdd(hVal, elemId, __h245(terminalLabel), 0, NULL, NULL);
int iMCU = channelSet[i].terminalLabel.mcuNumber;
int iTerminal = channelSet[i].terminalLabel.terminalNumber;
pvtAdd(hVal, nid, __h245(mcuNumber), iMCU, NULL, NULL);
ret=pvtAdd(hVal, nid, __h245(terminalNumber), iTerminal, NULL, NULL);
}
/* ADD sessionDescription field */
{
int l=0;
char tmpBuf[258]={0,0};
if (channelSet[i].sessionDescription != NULL && channelSet[i].sessionDescriptionLength>0)
l=chrn2bmp(channelSet[i].sessionDescription, (RvSize_t)RvMin(channelSet[i].sessionDescriptionLength, 128), (RvUint8*)tmpBuf);
if (l<2) l=2;
ret=pvtAdd(hVal, elemId, __h245(sessionDescription), l, tmpBuf, NULL);
}
/* ADD sessionDependency field, if possible */
if (channelSet[i].dependency>=0) dependencySet=RV_TRUE;
else if (channel && channel->pBase)
ret=pvtAdd(hVal, elemId, __h245(sessionDependency), channel->pBase->sessionId, NULL, NULL);
/* ADD mediaControlChannel field */
if (channelSet[i].rtcpAddress.ip !=0 || channelSet[i].rtcpAddress.port != 0)
{
int tmpId = pvtAdd(hVal, elemId, __h245(mediaControlChannel), 0, NULL, NULL);
getGoodAddressForCtrl((HCONTROL)ctrl,&channelSet[i].rtcpAddress);
cmTAToVt_H245(hVal,tmpId,&channelSet[i].rtcpAddress);
}
else if (channel)
{
if (channel->pPartner && channel->pPartner->pChannelParams.data.h225Params.sendRtcpAddressID>=0)
{
int tmpId = pvtAdd(hVal, elemId, __h245(mediaControlChannel), 0, NULL, NULL);
pvtSetTree(hVal,tmpId,hVal,channel->pPartner->pChannelParams.data.h225Params.sendRtcpAddressID);
}
else if (channel->pChannelParams.data.h225Params.sendRtcpAddressID>=0)
{
int tmpId = pvtAdd(hVal, elemId, __h245(mediaControlChannel), 0, NULL, NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -