📄 cmchan.c
字号:
__pvtBuildByFieldIds(h225ID, hVal, forwardLCP_ID, {_h245(multiplexParameters) _h245(h2250LogicalChannelParameters) LAST_TOKEN}, 0, NULL);
/* Add the dynamic payload type if we have one */
if (channel->pChannelParams.data.h225Params.dynamicPayloadNumber >= 0)
{
pvtAdd(hVal, h225ID, __h245(dynamicRTPPayloadType), channel->pChannelParams.data.h225Params.dynamicPayloadNumber, NULL, NULL);
}
if ((channel->pBase != NULL) && (channel->pBase->eState == ChannelStateEstablished))
{
/* Add dependency information if we have */
pvtAdd(hVal, forwardLCP_ID, __h245(forwardLogicalChannelDependency), channel->pBase->myLogicalChannelNum, NULL, NULL);
if (channel->pBase->reverseLogicalChannelNum > 0)
pvtAdd(hVal, reverseLCP_ID, __h245(reverseLogicalChannelDependency), channel->pBase->reverseLogicalChannelNum, NULL, NULL);
}
if ((channel->pReplacementCh != NULL) && (channel->pReplacementCh->eState == ChannelStateEstablished))
{
/* Add replacement information if we have */
pvtAdd(hVal, forwardLCP_ID, __h245(replacementFor), channel->pReplacementCh->myLogicalChannelNum, NULL, NULL);
if (channel->pReplacementCh->reverseLogicalChannelNum > 0)
pvtAdd(hVal, reverseLCP_ID, __h245(replacementFor), channel->pReplacementCh->reverseLogicalChannelNum, NULL, NULL);
}
/* Set the Logical H245Channel Number (LCN) */
pvtAdd(hVal, olcID, __h245(forwardLogicalChannelNumber), channel->myLogicalChannelNum, NULL, NULL);
/* Set session ID in message */
pvtAdd(hVal, h225ID, __h245(sessionID), channel->sessionId, NULL, NULL);
/* Add association if we have any */
if (channel->pAssociated != NULL)
pvtAdd(hVal, h225ID, __h245(associatedSessionID), channel->pAssociated->sessionId, NULL, NULL);
/* Add redundancy encoding information for the channel */
if (channel->pChannelParams.data.h225Params.redEncID >= 0)
pvtSetTree(hVal, pvtAddBranch(hVal, h225ID, __h245(redundancyEncoding)), hVal, channel->pChannelParams.data.h225Params.redEncID);
/* Set transport capability information if we have */
if (channel->pChannelParams.data.h225Params.transCapID >= 0)
pvtSetTree(hVal, pvtAddBranch(hVal, h225ID, __h245(transportCapability)), hVal, channel->pChannelParams.data.h225Params.transCapID);
/* Add RTP address */
if (channel->pChannelParams.data.h225Params.recvRtpAddressID >= 0)
pvtSetTree(hVal, pvtAddBranch(hVal, h225ID, __h245(mediaChannel)), hVal, channel->pChannelParams.data.h225Params.recvRtpAddressID);
/* Set ATM port number for this channel if we have one */
if ((channel->pChannelParams.data.h225Params.portNumber > 0) && (channel->pChannelParams.data.h225Params.portNumber < 65536))
pvtAdd(hVal, forwardLCP_ID, __h245(portNumber), channel->pChannelParams.data.h225Params.portNumber, NULL, NULL);
if (channel->pChannelParams.data.h225Params.source.mcuNumber != 0xff)
{
/* We have an MCU number on the side of the source */
int sID = pvtAddBranch(hVal, h225ID, __h245(source));
int iMCU = channel->pChannelParams.data.h225Params.source.mcuNumber;
int iTerminal = channel->pChannelParams.data.h225Params.source.terminalNumber;
pvtAdd(hVal, sID, __h245(mcuNumber), iMCU, NULL, NULL);
pvtAdd(hVal, sID, __h245(terminalNumber), iTerminal, NULL, NULL);
}
if (channel->pChannelParams.data.h225Params.destination.mcuNumber!=0xff)
{
/* We have an MCU number on the side of the destination */
int sID = pvtAddBranch(hVal, h225ID, __h245(source));
int iMCU = channel->pChannelParams.data.h225Params.destination.mcuNumber;
int iTerminal = channel->pChannelParams.data.h225Params.destination.terminalNumber;
pvtAdd(hVal, sID, __h245(mcuNumber), iMCU, NULL, NULL);
pvtAdd(hVal, sID, __h245(terminalNumber), iTerminal, NULL, NULL);
}
/* Add separate stack information if we have to */
if ((channel->pChannelParams.data.h225Params.separateStackID >= 0) ||
(channel->pChannelParams.data.h225Params.t120SetupProcedure > 0))
{
int separateStack, tmpNodeId;
/* Put the separateStack local area address */
separateStack = pvtAddBranch(hVal, olcID, __h245(separateStack));
if (channel->pChannelParams.data.h225Params.separateStackID >= 0)
{
__pvtBuildByFieldIds(tmpNodeId, hVal, separateStack, {_h245(networkAddress) _h245(localAreaAddress) LAST_TOKEN}, 0, NULL);
pvtSetTree(hVal, tmpNodeId, hVal, channel->pChannelParams.data.h225Params.separateStackID);
/* Put externalReference information if we have */
if (channel->pChannelParams.data.h225Params.externalReferenceLength > 0)
pvtAdd(hVal, separateStack, __h245(externalReference), channel->pChannelParams.data.h225Params.externalReferenceLength, channel->pChannelParams.data.h225Params.externalReference, NULL);
/* Put association information */
pvtAdd(hVal, separateStack, __h245(associateConference), (RvInt32)channel->pChannelParams.data.h225Params.isAssociated, NULL, NULL);
}
/* Add the right t120 setup procedure */
if (channel->pChannelParams.data.h225Params.t120SetupProcedure > 0)
{
static int t120s[] = {__h245(originateCall), __h245(waitForCall), __h245(issueQuery)};
pvtAddBranch2(hVal, separateStack, __h245(t120SetupProcedure), t120s[channel->pChannelParams.data.h225Params.t120SetupProcedure-cmOriginateCall]);
}
}
if (channel->bIsDuplex)
{
/* duplex default parameter setting.*/
/* Add reverse channel's parameters */
if ((tmpID = pvtAddBranch(hVal, reverseLCP_ID, __h245(dataType))) >= 0)
pvtSetTree(hVal, tmpID, hVal, dataType);
/* Put the session ID here also */
__pvtBuildByFieldIds(tmpID, hVal, reverseLCP_ID, {_h245(multiplexParameters) _h245(h2250LogicalChannelParameters) _h245(sessionID) LAST_TOKEN}, channel->sessionId, NULL);
}
else
{
/* uni-directional channel */
/* See from where do we get the RTCP address */
int srcRtcpID;
if ((channel->pPartner != NULL) && (channel->pPartner->pChannelParams.data.h225Params.recvRtcpAddressID >= 0))
{
/* If we have a partner ID with a receive RTCP address, we should use it instead of
our own address, since most chances are that we don't even have such an address. */
srcRtcpID = channel->pPartner->pChannelParams.data.h225Params.recvRtcpAddressID;
}
else
srcRtcpID = channel->pChannelParams.data.h225Params.recvRtcpAddressID;
if (srcRtcpID >= 0)
pvtSetTree(hVal, pvtAddBranch(hVal, h225ID, __h245(mediaControlChannel)), hVal, srcRtcpID);
}
/* Notify channel's states. These are used to simulate earlier version behavior on channels */
channel->eState = ChannelStateIdle;
notifyChannelState(channel, cmChannelStateDialtone, cmChannelStateModeOff);
notifyChannelState(channel, cmChannelStateRingBack, cmChannelStateModeOff);
/* Finally, we send message */
if (!emaWasDeleted((EMAElement)channel))
{
/* Send the message and delete it */
ret = sendMessageH245(channel->hCtrl, message);
pvtDelete(hVal, message);
{
/* Set a timer on this channel while we wait for an ack */
int timeout = 29;
pvtGetChildValue(hVal, app->h245Conf, __h245(channelsTimeout), &(timeout), NULL);
RvH323TimerCancel(cmGetTimersHandle((HAPP)app), &channel->pTimer);
channel->pTimer = RvH323TimerStart(cmGetTimersHandle((HAPP)app), channelTimeoutEventsHandler, (void*)channel, timeout * 1000);
}
/* Change the state of this channel */
channel->eState = ChannelStateAwaitingEstablishment;
}
return ret;
}
RVAPI int RVCALLCONV
cmChannelOpenDynamic(
IN HCHAN hsChan,
IN int dataTypeHandle, /* data type (HPVT) tree handle */
IN HCHAN hsChanSameSession,
IN HCHAN hsChanAssociated,
IN RvBool isDynamicPayloadType
)
{
cmElem *app=(cmElem *)emaGetInstance((EMAElement)hsChan);
HPVT hVal;
if (!app)
return RV_ERROR_UNKNOWN;
cmiAPIEnter((HAPP)app, "cmChannelOpenDynamic: hsChan=0x%p, dataTypeHandle=%d, hsChanSameSession=0x%p, hsChanAssociated=0x%p, isDynamicPayloadType=%d.",
hsChan, dataTypeHandle, hsChanSameSession, hsChanAssociated, isDynamicPayloadType);
if (emaLock((EMAElement)hsChan))
{
HCONTROL ctrl;
H245Control* ctrlE;
H245Channel* channel=(H245Channel*)hsChan;
callElem * call;
hVal = app->hVal;
ctrl = channel->hCtrl;
call = (callElem *)cmiGetByControl(ctrl);
ctrlE = (H245Control*)ctrl;
if (m_callget(call,control) && (ctrlE->eState != ctrlConnected) && (ctrlE->eState != ctrlConference))
{
channel->eState = ChannelStateReleased;
notifyChannelState(channel,cmChannelStateDisconnected,cmChannelStateModeDisconnectedLocal);
notifyChannelState(channel,cmChannelStateIdle, cmChannelStateModeOff);
emaUnlock((EMAElement)hsChan);
cmiAPIExit((HAPP)app, "cmChannelOpenDynamic: Control is not in a connected state, state=%d", ctrlE->eState);
return RV_ERROR_UNKNOWN;
}
deriveChannels(channel->hCtrl);
if (hsChanSameSession != NULL)
{
channel->pPartner=(H245Channel*)hsChanSameSession; /* -- join session */
channel->sessionId=channel->pPartner->sessionId;
}
if (hsChanAssociated != NULL) channel->pAssociated=(H245Channel*)hsChanAssociated;/* -- associate session */
if (channel->pBase && channel->pBase->eState==ChannelStateAwaitingRelease)
{
channel->eState = ChannelStateReleased;
notifyChannelState(channel,cmChannelStateDisconnected,cmChannelStateModeDisconnectedLocal);
notifyChannelState(channel,cmChannelStateIdle, cmChannelStateModeOff);
emaUnlock((EMAElement)hsChan);
cmiAPIExit((HAPP)app, "cmChannelOpenDynamic: Base channel released [Invalid Circumstances]");
return RV_ERROR_UNKNOWN;
}
if (channel->dataTypeID<0)
channel->dataTypeID=pvtAddRoot(hVal,app->h245DataType,0,NULL);
pvtAddTree(hVal,channel->dataTypeID,hVal,dataTypeHandle);
if (isDynamicPayloadType)
{
cmLock((HAPP)app);
app->dynamicPayloadNumber = (char)((app->dynamicPayloadNumber+1)%32);
channel->pChannelParams.data.h225Params.dynamicPayloadNumber=app->dynamicPayloadNumber+96;
cmUnlock((HAPP)app);
}
if (channel->pBase && channel->pBase->eState==ChannelStateAwaitingEstablishment)
{
emaUnlock((EMAElement)hsChan);
cmiAPIExit((HAPP)app, "cmChannelOpenDynamic: Waiting for base channel [OK]");
return RV_TRUE;
}
if (!channel->bIsDuplex)
{
if (!channel->pPartner)
{ /* new id */
RvPstFieldId fieldId;
int nodeId = pvtGet(hVal,pvtChild(hVal,channel->dataTypeID),&fieldId,NULL,NULL,NULL);
if (fieldId==__h245(h235Media))
pvtGet(hVal,pvtChild(hVal,pvtGetChild(hVal,nodeId,__h245(mediaType),NULL)),&fieldId,NULL,NULL,NULL);
channel->sessionId=0;
if (ctrlE->bFirstAudioOut && fieldId==__h245(audioData)) { ctrlE->bFirstAudioOut=0; channel->sessionId=1; channel->pPartner=getInChanBySID(ctrl,channel->sessionId);}
else if (ctrlE->bFirstVideoOut && fieldId==__h245(videoData)){ ctrlE->bFirstVideoOut=0; channel->sessionId=2; channel->pPartner=getInChanBySID(ctrl,channel->sessionId);}
else if (ctrlE->bFirstDataOut && fieldId==__h245(data)) { ctrlE->bFirstDataOut=0; channel->sessionId=3; channel->pPartner=getInChanBySID(ctrl,channel->sessionId);}
else if (ctrlE->bIsMaster)
{
if ((channel->sessionId = getFreeSID(ctrl))<0)
{
channel->eState = ChannelStateReleased;
notifyChannelState(channel,cmChannelStateDisconnected,cmChannelStateModeDisconnectedLocal);
notifyChannelState(channel,cmChannelStateIdle, cmChannelStateModeOff);
emaUnlock((EMAElement)hsChan);
cmiAPIExit((HAPP)app, "cmChannelOpenDynamic: Out of session IDs [Resource Problem]");
return RV_ERROR_OUTOFRESOURCES;
}
}
}
else
/* check database for partner lcn. In case of first audio or video */
{ /* use partner sid */
if (channel->sessionId==1) ctrlE->bFirstAudioOut=0;
if (channel->sessionId==2) ctrlE->bFirstVideoOut=0;
if (channel->sessionId==3) ctrlE->bFirstDataOut=0;
}
}
else
{
if (!channel->pPartner)
{ /* new id */
RvPstFieldId fieldId;
int nodeId = pvtGet(hVal,pvtChild(hVal,channel->dataTypeID),&fieldId,NULL,NULL,NULL);
if (fieldId==__h245(h235Media))
pvtGet(hVal,pvtChild(hVal,pvtGetChild(hVal,nodeId,__h245(mediaType),NULL)),&fieldId,NULL,NULL,NULL);
channel->sessionId=0;
if (ctrlE->bFirstAudioOut && fieldId==__h245(audioData)) { ctrlE->bFirstAudioOut=0; ctrlE->bFirstAudioIn=0; channel->sessionId=1;}
else if (ctrlE->bFirstVideoOut && fieldId==__h245(videoData)){ ctrlE->bFirstVideoOut=0; ctrlE->bFirstVideoIn=0; channel->sessionId=2;}
else if (ctrlE->bFirstDataOut && fieldId==__h245(data)) { ctrlE->bFirstDataOut=0; ctrlE->bFirstDataIn=0; channel->sessionId=3;}
else if (ctrlE->bIsMaster)
{
if ((channel->sessionId = getFreeSID(ctrl))<0)
{
channel->eState = ChannelStateReleased;
notifyChannelState(channel,cmChannelStateDisconnected,cmChannelStateModeDisconnectedLocal);
notifyChannelState(channel,cmChannelStateIdle, cmChannelStateModeOff);
emaUnlock((EMAElement)hsChan);
cmiAPIExit((HAPP)app, "cmChannelOpenDynamic: Out of session IDs [Resource Problem]");
return RV_ERROR_OUTOFRESOURCES;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -