?? cmctrlmpoint.c
字號:
/***********************************************************************
Copyright (c) 2002 RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Ltd.. No part of this document may be reproduced in any
form whatsoever without written prior approval by RADVISION Ltd..
RADVISION Ltd. reserve the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
***********************************************************************/
#include "rvinternal.h"
#include "cmictrl.h"
#include "pvaltreeStackApi.h"
#include "cmConf.h"
#include "caputils.h"
#include "strutils.h"
#include "cmutils.h"
#include "oidutils.h"
#include "stkutils.h"
#include "copybits.h"
#include "h245.h"
#include "cmChanGetByXXX.h"
#include "cmdebprn.h"
#include "cmchan.h"
#include "cmCall.h"
#include "cmCtrlMPoint.h"
#ifdef __cplusplus
extern "C" {
#endif
int notifyChannelState(
IN H245Channel* channel,
IN cmChannelState_e state,
IN cmChannelStateMode_e stateMode);
/* Multipoint __________________________________________________________________________________*/
/************************************************************************
* conferenceMessage
* purpose: Deal with various incoming H245 conference messages
* This function uses the callback to the application to handle
* the message
* input : ctrl - H245 control object of the call
* lcn - Logical channel of this message.
* 0 if no channel is related to this call
* message - root node ID of the message to handle
* messaheType - Type of message
* output : none
* return : Non-negative value on success
* Negative value on failure
************************************************************************/
int conferenceMessage(
IN H245Control* ctrl,
IN int lcn,
IN int message,
IN cmH245MessageType messageType)
{
HCALL call=(HCALL)cmiGetByControl((HCONTROL)ctrl);
cmElem* app=(cmElem*)emaGetInstance((EMAElement)cmiGetByControl((HCONTROL)ctrl));
H245Channel* channel=NULL;
if(lcn>0)
channel=getOutChanByLCN((HCONTROL)ctrl,lcn);
if(app->cmMySessionEvent.cmEvCallControlMessage)
{
cmiCBEnter((HAPP)app, "cmEvCallControlMessage(hsCall=0x%p, hsChan=0x%p, message=%d, messageType=%d)", call, channel, message, messageType);
app->cmMySessionEvent.cmEvCallControlMessage(
(HAPPCALL)emaGetApplicationHandle((EMAElement)call), call,
(HAPPCHAN)emaGetApplicationHandle((EMAElement)channel), (HCHAN)channel,
message, messageType);
cmiCBExit((HAPP)app, "cmEvCallControlMessage");
}
return RV_TRUE;
}
int multipointConference(H245Control* ctrl,int lcn)
{
if (lcn);
ctrl->eState=ctrlConference;
cmiReportControl(cmiGetByControl((HCONTROL)ctrl),cmControlStateConference,(cmControlStateMode)0);
return RV_TRUE;
}
int cancelMultipointConference(H245Control* ctrl,int lcn)
{
if (lcn);
ctrl->eState=ctrlConnected;
cmiReportControl(cmiGetByControl((HCONTROL)ctrl),cmControlStateConnected,(cmControlStateMode)0);
return RV_TRUE;
}
RVAPI int RVCALLCONV
cmCallStartConference(
/* enter call conference mode */
IN HCALL hsCall
)
{
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
int nodeId, message, res = RV_ERROR_UNKNOWN;
H245Control* ctrl=(H245Control*)cmiGetControl(hsCall);
if (!hsCall || !hApp) return RV_ERROR_UNKNOWN;
if (cmCallMasterSlaveStatus(hsCall) != cmMSMaster) return RV_ERROR_UNKNOWN; /* master only operation */
cmiAPIEnter(hApp, "cmCallStartConference: hsCall=0x%p", hsCall);
if (emaLock((EMAElement)hsCall))
{
HPVT hVal = ((cmElem *)hApp)->hVal;
message=pvtAddRoot(hVal,((cmElem*)hApp)->synProtH245,0,NULL);
nodeId=pvtAddBranch2(hVal,message, __h245(indication), __h245(miscellaneousIndication));
pvtAddBranch2(hVal,nodeId, __h245(type), __h245(multipointConference));
pvtAdd(hVal,nodeId,__h245(logicalChannelNumber),1,NULL,NULL);
res = sendMessageH245((HCONTROL)ctrl, message);
pvtDelete(hVal,message);
if (res >= 0)
{
ctrl->eState=ctrlConference;
cmiReportControl(cmiGetByControl((HCONTROL)ctrl),cmControlStateConference,(cmControlStateMode)0);
}
emaUnlock((EMAElement)hsCall);
}
cmiAPIExit(hApp, "cmCallStartConference=%d", res);
return res;
}
RVAPI int RVCALLCONV
cmCallCancelConference(
/* cancel the call conference mode */
IN HCALL hsCall
)
{
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
H245Control* ctrl=(H245Control*)cmiGetControl(hsCall);
int nodeId, message, res = RV_ERROR_UNKNOWN;
if (!hsCall || !hApp) return RV_ERROR_UNKNOWN;
if (cmCallMasterSlaveStatus(hsCall) != cmMSMaster)
return RV_ERROR_UNKNOWN; /* only master can cancel conference mode */
cmiAPIEnter(hApp, "cmCallCancelConference: hsCall=0x%p", hsCall);
if (emaLock((EMAElement)hsCall))
{
HPVT hVal = ((cmElem *)hApp)->hVal;
if (ctrl->eState!=ctrlConference)
{
emaUnlock((EMAElement)hsCall);
cmiAPIExit(hApp, "cmCallCancelConference: [-1]. (Wrong state)");
return RV_ERROR_UNKNOWN;
}
message=pvtAddRoot(hVal,((cmElem*)hApp)->synProtH245,0,NULL);
nodeId=pvtAddBranch2(hVal,message, __h245(indication), __h245(miscellaneousIndication));
pvtAddBranch2(hVal,nodeId, __h245(type), __h245(cancelMultipointConference));
pvtAdd(hVal,nodeId,__h245(logicalChannelNumber),1,NULL,NULL);
res = sendMessageH245((HCONTROL)ctrl, message);
pvtDelete(hVal,message);
if (res >= 0)
{
ctrl->eState=ctrlConnected;
cmiReportControl(cmiGetByControl((HCONTROL)ctrl),cmControlStateConnected,(cmControlStateMode)0);
}
emaUnlock((EMAElement)hsCall);
}
cmiAPIExit(hApp, "cmCallCancelConference=%d", res);
return res;
}
/* When the conference becomes active, the master (MC) terminal shall call cmCallDeclareMC() to
indicate the new conference status. */
RVAPI int RVCALLCONV
cmCallDeclareMC(
/* declare this terminal to be the MC of the call */
IN HCALL hsCall
)
{
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
H245Control* ctrl=(H245Control*)cmiGetControl(hsCall);
int nodeId, message, res = RV_ERROR_UNKNOWN;
cmTransportAddress ta;
if (!hsCall || !hApp) return RV_ERROR_UNKNOWN;
if (cmCallMasterSlaveStatus(hsCall) != cmMSMaster)
return RV_ERROR_UNKNOWN; /* only master can be active MC */
cmiAPIEnter(hApp, "cmCallDeclareMC: hsCall=0x%p", hsCall);
if (emaLock((EMAElement)hsCall))
{
HPVT hVal = ((cmElem *)hApp)->hVal;
cmGetLocalCallSignalAddress(hApp,&ta);
message=pvtAddRoot(hVal,((cmElem*)hApp)->synProtH245,0,NULL);
__pvtBuildByFieldIds(nodeId,hVal,message, {_h245(indication) _h245(mcLocationIndication)
_h245(signalAddress) LAST_TOKEN}, 0, NULL);
cmTAToVt_H245(hVal, nodeId, &ta);
res = sendMessageH245((HCONTROL)ctrl, message);
pvtDelete(hVal,message);
if (res >= 0)
{
ctrl->eState=ctrlConference;
cmiReportControl(cmiGetByControl((HCONTROL)ctrl),cmControlStateConference,(cmControlStateMode)0);
}
emaUnlock((EMAElement)hsCall);
}
cmiAPIExit(hApp, "cmCallDeclareMC=%d", res);
return res;
}
int mcLocationIndication(H245Control* ctrl, int message)
{
HAPP hApp=(HAPP)emaGetInstance((EMAElement)cmiGetByControl((HCONTROL)ctrl));
HPVT hVal = ((cmElem *)hApp)->hVal;
cmVtToTA_H245(hVal,pvtGetChild(hVal,message,__h245(signalAddress),NULL), &(ctrl->mcLocationTA));
cmiReportControl(cmiGetByControl((HCONTROL)ctrl),cmControlStateConference,(cmControlStateMode)0);
ctrl->eState=ctrlConference;
return RV_TRUE;
}
/* When the conference becomes active, this function provides the address of the Active MC. */
RVAPI
int RVCALLCONV cmCallGetMCAddress(
/* get active MC address */
IN HCALL hsCall,
OUT RvUint32* ip,
OUT RvUint16* port
)
{
HAPP hApp=(HAPP)emaGetInstance((EMAElement)hsCall);
H245Control* ctrl=(H245Control*)cmiGetControl(hsCall);
if (!hsCall || !hApp) return RV_ERROR_UNKNOWN;
if (ctrl->mcLocationTA.distribution<0) return RV_ERROR_UNKNOWN;
cmiAPIEnter(hApp, "cmCallGetMCAddress: hsCall=0x%p, &ip=0x%p, &port=0x%p", hsCall, ip, port);
if (emaLock((EMAElement)hsCall))
{
if (ip) *ip = ctrl->mcLocationTA.ip;
if (port) *port = (RvUint16)ctrl->mcLocationTA.port;
emaUnlock((EMAElement)hsCall);
}
cmiAPIExit(hApp, "cmCallGetMCAddress: ip=0x%x, port=%d [%d].", 0, (ip)?*ip:0, (port)?*port:-1);
return 0;
}
/* This enumeration is used as the CHOICE values of the ConferenceIndication
type in the H.245 ASN.1. The order of this enumeration should not be different
than that of the choices in this type and should begin from 1. */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -