⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmcall.c

📁 基于h323协议的软phone
💻 C
📖 第 1 页 / 共 5 页
字号:
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);
    HPVT hVal=app->hVal;
    int tmpNodeId,tmpNodeId1;

    __pvtGetNodeIdByFieldIds(tmpNodeId,hVal,message,
                {_q931(message) _anyField _q931(userUser) _q931(h323_UserInformation)
                 _q931(h323_uu_pdu) _q931(h323_message_body) _anyField LAST_TOKEN});

    tmpNodeId1=pvtGetChild(hVal,tmpNodeId,__q931(destinationInfo),NULL);
    cmCallSetParam((HCALL)call,cmParamFullDestinationInfo,0,tmpNodeId1,NULL);

    notifyState((HCALL)call,cmCallStateRingBack,(cmCallStateMode_e)0);

    {
        int establish=1;
        cmCallGetParam((HCALL)call,cmParamEstablishH245,0,&establish,NULL);
        if (establish)
            if (cmFastStartReply(call,tmpNodeId) >= 0)
                deleteFastStart(call);
    }
    return 0;
}

int cmConnect(callElem*call, int message)
{
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);
    H245Control *ctrl=(H245Control *)cmiGetControl((HCALL)call);
    HPVT hVal=app->hVal;
    int messageBody,destInfo;

    __pvtGetNodeIdByFieldIds(messageBody,hVal,message,
                 {_q931(message) _anyField _q931(userUser) _q931(h323_UserInformation)
                 _q931(h323_uu_pdu) _q931(h323_message_body) _anyField LAST_TOKEN});


    destInfo=pvtGetChild(hVal,messageBody,__q931(destinationInfo),NULL);
    cmCallSetParam((HCALL)call,cmParamFullDestinationInfo,0,destInfo,NULL);

    enterCallConnectedState(call);
    {
        int establish=1;
        cmCallGetParam((HCALL)call,cmParamEstablishH245,0,&establish,NULL);
        if (establish)
            cmFastStartReply(call,messageBody);
    }

    deleteFastStart(call);
    m_callset(call, fastStartFinished, RV_TRUE);
    cmcReadyEvent(ctrl);

/** 2004.07.29. fujiangdong. When h245Tunneling is on and faststart is off,
 * we should send our TCS and MSD message through h245 tunneling after 
 * CONNECT message received.
 */
{
	RvInt32 isTunneling = RV_FALSE, isFastStart = RV_FALSE;
	int setupFS = 0, connectFS = 0, alertingFS = 0, callProcFS = 0;
	RvPvtNodeId fastNodeId;				

	setupFS = (cmCallGetParam((HCALL)call, cmParamSetupFastStart, 0, &fastNodeId, NULL) >= 0);
	callProcFS = (cmCallGetParam((HCALL)call, cmParamCallProcFastStart, 0, &fastNodeId, NULL) >= 0);
	alertingFS = (cmCallGetParam((HCALL)call, cmParamAlertingFastStart, 0, &fastNodeId, NULL) >= 0);
	connectFS = (cmCallGetParam((HCALL)call, cmParamConnectFastStart, 0, &fastNodeId, NULL) >= 0);
	if ((callProcFS || alertingFS || connectFS) && setupFS)
		isFastStart = RV_TRUE;
	
	cmCallGetParam((HCALL)call, cmParamH245Tunneling, 0, &isTunneling, NULL);
	
	if (!isFastStart && isTunneling && !setupFS)
		startControl(cmiGetControl((HCALL)call));
}
	
    return 0;
}


int cmReleaseComplete(callElem*call, int message)
{
    HAPP hApp=(HAPP)emaGetInstance((EMAElement)call);
    if (message);
    RvH323TimerCancel(cmGetTimersHandle(hApp),&call->timer);
    dropControl(call);
    reportDisconnectedState(call,reasonReleaseComplete);
    dropRas(call);
    return 0;
}

int cmStatus(callElem*call, int message)
{
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);
    HPVT hVal=app->hVal;

    if (app->cmMyCallEvent.cmEvCallStatus)
    {
        cmCallStatusMessage callStatusMsg;
        int handle,nesting;
        handle=pvtGetChild2(hVal, message, __q931(message),__q931(status));
        cmCallStatusMsg2Struct(hVal,handle,&callStatusMsg);
        cmiCBEnter((HAPP)app,(char*)"cmEvCallStatus(haCall=0x%p,hsCall=0x%p,handle=%ld)",(HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call,handle);
        nesting=emaPrepareForCallback((EMAElement)call);
        emaReturnFromCallback((EMAElement)call,nesting);
        app->cmMyCallEvent.cmEvCallStatus((HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call,&callStatusMsg);
        nesting=emaPrepareForCallback((EMAElement)call);
        emaReturnFromCallback((EMAElement)call,nesting);
        cmiCBExit((HAPP)app,(char*)"cmEvCallStatus");
    }
    return 0;
}

int cmFacility(callElem*call, int message)
{
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);
    HPVT hVal=app->hVal;
    int uuNodeId;
    RvBool proceed=1;
    int tmp;
    RvPstFieldId fieldId=RV_ERROR_UNKNOWN;
    RvBool empty=RV_FALSE;
    int  i=0,j=0;
    RvBool firstE164=RV_TRUE;

    __pvtGetNodeIdByFieldIds(uuNodeId,hVal,message,
        {_q931(message) _anyField _q931(userUser) _q931(h323_UserInformation) _q931(h323_uu_pdu) LAST_TOKEN});

    tmp=pvtGetChild(hVal,uuNodeId,__q931(h323_message_body),NULL);
    empty=(pvtGetChild(hVal,tmp,__q931(empty),NULL)>=0);

    tmp=pvtChild(hVal,tmp);

    {
        RvInt32 establish=1;
        cmCallGetParam((HCALL)call,cmParamEstablishH245,0,&establish,NULL);
        if (establish)
            if (cmFastStartReply(call,tmp) >= 0)
                deleteFastStart(call);
    }

    if (!empty)
    __pvtGetByFieldIds(tmp,hVal,tmp,
        {_q931(reason) _anyField LAST_TOKEN},&fieldId, NULL,NULL);


    if (fieldId!=__q931(routeCallToGatekeeper))
    if (app->cmMyCallEvent.cmEvCallFacility)
    {
        int nesting;

        cmiCBEnter((HAPP)app,(char*)"cmEvCallFacility(haCall=0x%p,hsCall=0x%p,handle=%ld,proceed=&)",(HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call,message);
        nesting=emaPrepareForCallback((EMAElement)call);
        app->cmMyCallEvent.cmEvCallFacility((HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call,message,&proceed);
        emaReturnFromCallback((EMAElement)call,nesting);
        cmiCBExit((HAPP)app,(char*)"cmEvCallFacility proceed=%s",(proceed)?"TRUE":"FALSE");
    }

    if (proceed && !empty && !emaWasDeleted((EMAElement)call))
    {
        cmCallStateMode_e stateMode = 0;

        switch(fieldId)
        {
            case __q931(callForwarded):
            {
                /* remove the destination addresses before setting the new ones */
                int ammAliases = cmCallGetNumOfParams((HCALL)call, cmParamDestinationAddress);
                for(i=1; i<=ammAliases; i++)
                {
                    cmCallDeleteParam((HCALL)call,cmParamDestinationAddress,i);
                }
                /* Also remove the source addresses if we are the call's destination */
                if (!m_callget(call,callInitiator))
                {
                    ammAliases = cmCallGetNumOfParams((HCALL)call, cmParamSourceAddress);
                    for(i=1; i<=ammAliases; i++)
                    {
                        cmCallDeleteParam((HCALL)call,cmParamSourceAddress,i);
                    }
                }
                i=0;
                m_callset(call,newCIDRequired,RV_TRUE);
                stateMode = cmCallStateModeTransferingForwarded;
            }
            case __q931(routeCallToMC):
                cmCallDeleteParam((HCALL)call,cmParamCalledPartyNumber,0);
                cmCallDeleteParam((HCALL)call,cmParamDestCallSignalAddress,0);
            case __q931(routeCallToGatekeeper):
            {
                if (fieldId==__q931(routeCallToMC))
                {
                    char cid[16];
                    RvInt32 size=16;
                    cmCallSetParam((HCALL)call,cmParamConferenceGoal,0,cmJoin,NULL);
                    cmCallGetParam((HCALL)call,cmParamFacilityCID,0,&size,cid);
                    cmCallSetParam((HCALL)call,cmParamCID,0,size,cid);
                    stateMode = cmCallStateModeTransferingRouteToMC;
                }
                if (fieldId==__q931(routeCallToGatekeeper))
                {
                    stateMode = cmCallStateModeTransferingRouteToGatekeeper;
                }

                for (;;)
                {
                    char buffer[256];
                    cmAlias alias;
                    alias.string=buffer;
                    buffer[0]=0;

                    if (cmCallGetParam((HCALL)call,cmParamAlternativeAliasAddress,i++,NULL,(char*)&alias)>=0)
                    {
                        /* if this is the first e164 alias */
                        if (alias.type==cmAliasTypeE164 && firstE164)
                        {
                            cmCallSetParam((HCALL)call,cmParamCalledPartyNumber,0,0,(char*)&alias);
                            firstE164 = RV_FALSE;
                        }
                        cmCallSetParam((HCALL)call,cmParamDestinationAddress,j++,0,(char*)&alias);
                    }
                    else
                        break;
                }

                cmCallDeleteParam((HCALL)call,cmParamCallSignalAddress,0);
                m_callset(call,remoteVersion,0);
                {
                    cmTransportAddress ta;

                    if (cmCallGetParam((HCALL)call,cmParamAlternativeAddress,0,NULL,(char*)&ta)>=0)
                    {
                        if (fieldId==__q931(routeCallToGatekeeper))
                        {
                            cmCallSetParam((HCALL)call,cmParamRouteCallSignalAddress,0,0,(char*)&ta);
                        }
                        cmCallSetParam((HCALL)call,cmParamDestinationIpAddress,0,0,(char*)&ta);
                        if (fieldId!=__q931(routeCallToGatekeeper))
                        {
                            cmCallSetParam((HCALL)call,cmParamDestCallSignalAddress,0,0,(char*)&ta);
                        }
                    }

                }
                dropControl(call);
                cmCallSetParam((HCALL)call,cmParamReleaseCompleteCause,0,16,NULL);
                cmCallSetParam((HCALL)call,cmParamReleaseCompleteReason,0,cmReasonTypeFacilityCallDeflection,NULL);
                q931CallDrop(cmiGetQ931((HCALL)call),-1);
                notifyState((HCALL)call,cmCallStateTransfering, stateMode);
                dropRas(call);
            }
            break;
        }
    }
    return 0;
}

int cmProgress(callElem*call, int message)
{
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);
    HPVT hVal=app->hVal;
    int tmpNodeId,tmpNodeId1;
    if (message || call);

    __pvtGetNodeIdByFieldIds(tmpNodeId,app->hVal,message,
                {_q931(message) _anyField _q931(userUser) _q931(h323_UserInformation)
                 _q931(h323_uu_pdu) _q931(h323_message_body) _anyField LAST_TOKEN});

    tmpNodeId1=pvtGetChild(hVal,tmpNodeId,__q931(destinationInfo),NULL);
    cmCallSetParam((HCALL)call,cmParamFullDestinationInfo,0,tmpNodeId1,NULL);
    {
        RvInt32 establish=1;
        cmCallGetParam((HCALL)call,cmParamEstablishH245,0,&establish,NULL);
        if (establish)
            if (cmFastStartReply(call,tmpNodeId) >= 0)
                deleteFastStart(call);
    }
    if (app->cmMyCallEvent.cmEvCallProgress)
    {
        int nesting;
        cmiCBEnter((HAPP)app,(char*)"cmEvCallProgress(haCall=0x%p,hsCall=0x%p,handle=%ld)",(HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call,message);
        nesting=emaPrepareForCallback((EMAElement)call);
        app->cmMyCallEvent.cmEvCallProgress((HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call,message);
        emaReturnFromCallback((EMAElement)call,nesting);
        cmiCBExit((HAPP)app,(char*)"cmEvCallProgress");
    }
    return 0;
}

int cmSetupAcknowledge(callElem*call, int message)
{
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);

    if (message);

    if (m_callget(call,enableOverlapSending))
    {
        if (app->cmMyCallEvent.cmEvCallIncompleteAddress)
        {
            int nesting;
            cmiCBEnter((HAPP)app,(char*)"cmEvCallIncompleteAddress(haCall=0x%p,hsCall=0x%p)",emaGetApplicationHandle((EMAElement)call),call);
            nesting=emaPrepareForCallback((EMAElement)call);
            app->cmMyCallEvent.cmEvCallIncompleteAddress((HAPPCALL)emaGetApplicationHandle((EMAElement)call),(HCALL)call);
            emaReturnFromCallback((EMAElement)call,nesting);
            cmiCBExit((HAPP)app,(char*)"cmEvCallIncompleteAddress");
        }
    }

    else
    {
        int sMessage=callGetMessage((HCALL)call,cmQ931status);
        {
            HPVT hVal = app->hVal;
            int tmpNodeId,tmpNodeId1;
            __pvtGetNodeIdByFieldIds(tmpNodeId,hVal,sMessage, {_q931(message) _anyField LAST_TOKEN});
            __pvtBuildByFieldIds(tmpNodeId1,hVal,tmpNodeId,
                                {_q931(cause) _q931(octet4) _q931(causeValue) LAST_TOKEN},98,NULL);
            __pvtBuildByFieldIds(tmpNodeId1,hVal,tmpNodeId,
                                {_q931(callState) _q931(callStateValue) LAST_TOKEN},q931GetCallState(cmiGetQ931((HCALL)call)),NULL);
        }
        sendCallMessage((HCALL)call,message);
        callReleaseMessage((HCALL)call,cmQ931status);
    }
    return 0;
}

int cmInformation(callElem*call, int message)
{
    cmElem* app=(cmElem*)emaGetInstance((EMAElement)call);
    HPVT hVal=app->hVal;
    int tmpNodeId,tmpNodeId1,q931NodeId;
    int nesting;
    {
        int size;
        char address[256];
        RvBool sendingComplete=RV_FALSE;
        int nesting;
        address[0]=0;
        __pvtGetNodeIdByFieldIds(q931NodeId,hVal,message, {_q931(message) _anyField LAST_TOKEN});
        tmpNodeId=pvtGetChild(hVal, q931NodeId, __q931(calledPartyNumber), NULL);
   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -