📄 rvwp_ex_ms.c
字号:
}
}
wpCallInfo[callId].rtcpSession = rtpGetRTCPSession(wpCallInfo[callId].rtpSession);
if (remoteIp != NULL && remotePort != NULL)
{
/*TRACE("rtp set remote ip:%x, port:%d\n", *remoteIp, *remotePort);*/
rtpSetRemoteAddress(wpCallInfo[callId].rtpSession, *remoteIp, *remotePort);
rtcpSetRemoteAddress(wpCallInfo[callId].rtcpSession, *remoteIp, *remotePort+1);
}
}
#endif /* INCLUDE_RV_RTP */
RvBool sendOLCReject(IN void* context)
{
HCHAN hsChan = (HCHAN)context;
/* TRACE("Send OLJ message to the remote\n");*/
if (cmChannelRejectReason(hsChan, cmRejectReasonMasterSlaveConflict) >= 0)
{
/* TRACE("Reject the incoming channel ok\n");*/
}
else
{
/* TRACE("Reject the incoming channel error\n");*/
}
}
/*************************************************************************
* Function: wpOutChannelOpen
*
* Description: Open an outgoing channel
*
*************************************************************************/
int wpOutChannelOpen(HCALL hsCall)
{
HCHAN hsChan;
int callId;
int rtpPort;
int retVal;
WrapperMsg wpmsg;
/* TRACE("wpOutChannelOpen()\n");*/
callId = wPGetCallIndex(hsCall);
if (wpCallInfo[callId].txcodeIndex == -1)
{
wpmsg.msgId = WP_REC_NO_CAPACITY;
wpmsg.baseInfo.callIndex = callId;
/* TRACE("Remote has not capabilities matching ours, can't send OpenLogicalChannel");*/
wpSendMsgToApp(&wpmsg);
return RV_FALSE;
}
/* Create new channel */
retVal = cmChannelNew(hsCall, (HAPPCHAN)&wpCallInfo[callId].hsChan, &hsChan);
if (retVal < 0)
{
/* TRACE("Create the new channel error\n");*/
return RV_FALSE;
}
#ifdef INCLUDE_RV_RTP
OpenLocalRtp(callId, &rtpPort, NULL, NULL);
#else
rtpPort = FIRST_RTP_PORT + callId * 2;
#endif
/* set RTCP address and open the channel */
if (cmChannelSetRTCPAddress(hsChan, 0, rtpPort+1) >= 0)
{
if (!Codec.codecPrefOrder[wpCallInfo[callId].txcodeIndex].isUsed)
{
/* TRACE("callId = %d, the txcodeIndex %d is not used\n", callId, wpCallInfo[callId].txcodeIndex);*/
return RV_FALSE;
}
if (cmChannelOpen(hsChan,
Codec.codecPrefOrder[wpCallInfo[callId].txcodeIndex].codecName, NULL, NULL, 0) < 0)
{
/* TRACE("cmChannelOpen failed\n");*/
return RV_FALSE;
}
wpCallInfo[callId].hsChan = hsChan;
/* TRACE("Open an outgoing channel ok, hsChan = %x, txcodeIndex = %d\n",
hsChan, wpCallInfo[callId].txcodeIndex);*/
}
needOLCAgain = 0;
wpCallInfo[callId].needOLC = FALSE;
return RV_TRUE;
}
/*************************************************************************
* Function: cmEvNewCall
*
* Description: Notify the application about new incoming call (Setup message
* was received).
*
* Input: CmHCall - CM handle to the new call.
* Output: AppHCall - Pointer for the application handle to the new call.
* return: none
*************************************************************************/
int RVCALLCONV cmEvNewCall
(
IN HAPP hApp,
IN HCALL hsCall,
OUT LPHAPPCALL lphaCall
)
{
int callId;
/* TRACE("cmEvNewCall()\n");*/
callId = wPGetCallIndex(hsCall);
if (callId == -1)
{
callId = wPGetCallIndex(0);
if (callId == -1)
{
return -1;
}
}
wpCallInfo[callId].hsCall = hsCall;
return 0;
/* After this function called by CM, cmEvCallStateChanged() will be called,
the state parameter will be set to cmCallStateOffering. We deal with the
Setup message in there.
*/
}
/*************************************************************************
* Function: cmEvCallFastStart
*
* Description: Notify the application at the incoming side of the call that fast start
* proposals were received in the current message.The application
* can use the api function CM_CallGetFastStartProposal to retrieve
* the proposals one by one.
*
* Input: haCall - Application handle to the call.
* hsCall - CM handle to the call.
* Output: fsMessage
* return: none
*************************************************************************/
int RVCALLCONV cmEvCallFastStart
(
IN HAPPCALL haCall,
IN HCALL hsCall
)
{
int callId;
/* TRACE("cmEvCallFastStart()\n");*/
if (!allowFastStart)
{
return;
}
callId = wPGetCallIndex(hsCall);
if (callId == -1)
{
callId = wPGetCallIndex(0);
if (callId == -1)
{
return -1;
}
}
wpCallInfo[callId].hsCall = hsCall;
wpCallInfo[callId].isFastConnect = RV_TRUE;
return;
}
/*************************************************************************
* Function: cmEvChannelStateChanged
*
* Description: the function that invoked when event ChannelStateChange occurs.
*
* input: haChan - Channel struct of the application
* hsChan - handle for the channel
* state - current state of the channel
* stateMode - New state mode. This parameter describes why or how
* the channel enters a new state
* output: none
* return: negative on error
*************************************************************************/
int RVCALLCONV cmEvChannelStateChanged
(
IN HAPPCHAN haChan,
IN HCHAN hsChan,
IN RvUint32 state,
IN RvUint32 stateMode
)
{
RvUint16 rtpPort;
int ret;
static char* chState[] = {
"cmChannelStateDialtone",
"cmChannelStateRingBack",
"cmChannelStateConnected",
"cmChannelStateDisconnected",
"cmChannelStateIdle",
"cmChannelStateOffering"
};
static char* chstateM[] = {
"cmChannelStateModeOn",
"cmChannelStateModeOff",
"cmChannelStateModeDisconnectedLocal",
"cmChannelStateModeDisconnectedRemote",
"cmChannelStateModeDisconnectedMasterSlaveConflict",
"cmChannelStateModeDuplex",
"cmChannelStateModeDisconnectedReasonUnknown",
"cmChannelStateModeDisconnectedReasonReopen",
"cmChannelStateModeDisconnectedReasonReservationFailure"
};
/* TRACE("cmEvChannelStateChanged()\n hsChan = %x, state:%s, mode:%s\n", hsChan, chState[state], chstateM[stateMode]);*/
switch (state)
{
case cmChannelStateOffering:
{
HCALL hsCall;
int callId;
/* TRACE("cmChannelStateoffering\n");*/
RvH323TimerCancel(rv_timer, &rvTimer);
ret = cmChannelGetCallHandles(hsChan, &hsCall, 0);
if (ret < 0)
{
/* TRACE("Get call handle of the channel error\n");*/
return 0;
}
callId = wPGetCallIndex(hsCall);
if (wpCallInfo[callId].rxcodeIndex == -1)
{
/* TRACE("We don't support remote's incoming OLC codec, prepare to reject it\n");*/
rvTimer = RvH323TimerStart(rv_timer, sendOLCReject, (void*)hsChan, 500);
/*TRACE("We don't support remote's incoming OLC codec, reject it\n");
if (cmChannelRejectReason(hsChan, cmRejectReasonMasterSlaveConflict) >= 0)
{
TRACE("Reject the incoming channel ok\n");
}
else
{
TRACE("Reject the incoming channel error\n");
}*/
return 0;
}
if (wpCallInfo[callId].rxcodeIndex != wpCallInfo[callId].txcodeIndex)
{
if (!wpCallInfo[callId].isIncoming) /* The call is a outgoing call */
{
/* TRACE("Remote's incoming OLC codec does not match ours, prepare to reject it\n");*/
rvTimer = RvH323TimerStart(rv_timer, sendOLCReject, (void*)hsChan, 500);
/*if (cmChannelRejectReason(hsChan, cmRejectReasonMasterSlaveConflict) >= 0)
{
TRACE("Reject the incoming channel ok\n");
}
else
{
TRACE("Reject the incoming channel error\n");
}*/
return 0;
}
else /* The call is a incoming call */
{
/* TRACE("The call is a incoming call, we set txcodeIndex = rxcodeIndex = %d\n",
wpCallInfo[callId].rxcodeIndex);*/
wpCallInfo[callId].txcodeIndex = wpCallInfo[callId].rxcodeIndex;
cmChannelDropReason(wpCallInfo[callId].hsChan, cmCloseReasonNormal);
wpCallInfo[callId].needOLC = TRUE;
/*wpOutChannelOpen(hsCall);*/
}
}
#ifndef INCLUDE_RV_RTP
rtpPort = FIRST_RTP_PORT + callId * 2;
cmChannelSetAddress(hsChan, 0, rtpPort);
cmChannelSetRTCPAddress(hsChan, 0, rtpPort + 1);
#else
OpenLocalRtp(callId, &ret, NULL, NULL);
rtpPort = ret;
cmChannelSetAddress(hsChan, 0, rtpPort);
cmChannelSetRTCPAddress(hsChan, 0, rtpPort + 1);
#endif
if (cmChannelAnswer(hsChan) >= 0)
{
/* TRACE("Answer the incoming channel ok\n");*/
}
else
{
/* TRACE("Answer the incoming channel error\n");*/
}
break;
}
case cmChannelStateIdle:
{
HCALL hsCall;
int callId;
int ret;
ret = cmChannelClose(hsChan);
if (ret < 0)
{
/* TRACE("Close the channel error\n");*/
}
else
{
/* TRACE("Close the channel ok\n");*/
ret = cmChannelGetCallHandles(hsChan, &hsCall, 0);
if (ret < 0)
{
/* TRACE("Get call handle of the channel error\n");*/
return -1;
}
callId = wPGetCallIndex(hsCall);
if (hsChan == wpCallInfo[callId].hsChan
&& wpCallInfo[callId].needOLC)
{
/* TRACE("Outgoing OLC will be reopened by local\n");*/
wpOutChannelOpen(hsCall);
}
}
break;
}
case cmChannelStateConnected:
{
HCALL hsCall;
int ret;
ret = cmChannelGetCallHandles(hsChan, &hsCall, 0);
if (ret < 0)
{
/* TRACE("Get call handle of the channel error\n");*/
return -1;
}
/* Outgoing fast start call */
if (stateMode == cmChannelStateModeOn)
{
int connectFS = 0, alertingFS = 0, callProcFS = 0;
RvPvtNodeId fastNodeId;
callProcFS = (cmCallGetParam(hsCall, cmParamCallProcFastStart, 0, &fastNodeId, NULL) >= 0);
alertingFS = (cmCallGetParam(hsCall, cmParamAlertingFastStart, 0, &fastNodeId, NULL) >= 0);
connectFS = (cmCallGetParam(hsCall, cmParamConnectFastStart, 0, &fastNodeId, NULL) >= 0);
if ((callProcFS || alertingFS || connectFS) && allowFastStart)
{
WrapperMsg wpmsg;
int callId;
int i;
char display[MAX_DISPLAY_LENGTH + 1];
/* int i, size;*/
int channelId = 0;
cmCapDataType dataType;
cmChannelDirection chanDir;
cmFastStartChannel fsChan;
/* cmTransportAddress callta;*/
/* TRACE("Remote end reply fast start:\n");*/
/* TRACE("CallProcFastStart = %d, AlertingFastStart = %d, ConnectFastStart = %d\n",
callProcFS, alertingFS, connectFS);*/
callId = wPGetCallIndex(hsCall);
wpmsg.baseInfo.callIndex = callId;
/*if (cmCallGetParam(hsCall, cmParamDestCallSignalAddress, 0, &size, (char*)&callta) < 0)
{
TRACE("can't get dst call signal address\n");
wpmsg.baseInfo.remoteIpAddr = 0;
}
else
{
TRACE("get dst CallSignalAddress:%x:%d\n", callta.ip, callta.port);
wpmsg.baseInfo.remoteIpAddr = callta.ip;
}*/
memset(display, 0, sizeof(display));
ret = cmCallGetDisplayInfo(hsCall, display, sizeof(display));
if (ret <= 0)
{
/* TRACE("Get the remote display info error\n");*/
}
strncpy(wpmsg.baseInfo.display, display, MAX_DISPLAY_LENGTH);
wpmsg.baseInfo.display[MAX_DISPLAY_LENGTH] = '\0';
wpmsg.msgId = WP_REC_CONN;
for ( i=0; channelId >= 0; i++)
{
/* RvPvtNodeId ackChan;*/
int codecIndex;
channelId = cmFastStartGetByIndex(hsCall, i);
if(channelId < 0)
{
break;
}
cmFastStartGet(hsCall, channelId, &dataType, &chanDir, &fsChan);
codecIndex = cmpChannelName(fsChan.channelName);
if (codecIndex == -1)
continue;
if (fsChan.rtcp.port != 0)
{
wpmsg.d.codec.rx = cmpChannelName(fsChan.channelName);
wpmsg.d.codec.tx = wpmsg.d.codec.rx;
wpmsg.d.codec.remoteRtpIpAddr = fsChan.rtcp.ip;
/* TRACE("Remote rtp ip addr = %x, port = %d\n",
fsChan.rtcp.ip, fsChan.rtcp.port - 1);*/
wpmsg.d.codec.remoteRtpPort = fsChan.rtcp.port - 1;
}
}
#ifndef INCLUDE_RV_RTP
wpmsg.d.codec.localRtpPort = FIRST_RTP_PORT + callId * 2;
#else
OpenLocalRtp(callId, &wpmsg.d.codec.localRtpPort, &wpmsg.d.codec.remoteRtpIpAddr, &wpmsg.d.codec.remoteRtpPort);
#endif
wpCallInfo[callId].isConnected = RV_TRUE;
wpmsg.rtpSession = wpCallInfo[callId].rtpSession;
wpSendMsgToApp(&wpmsg);
}
else
{
int callId;
char display[MAX_DISPLAY_LENGTH + 1];
WrapperMsg wpmsg;
callId = wPGetCallIndex(hsCall);
if (wpCallInfo[callId].isFastConnect && allowFastStart)
{
/* TRACE("Incoming call is FS, need not care channel state changed\n");*/
return -1;
}
if (wpCallInfo[callId].rxcodeIndex == -1
|| wpCallInfo[callId].txcodeIndex == -1
|| wpCallInfo[callId].rxcodeIndex != wpCallInfo[callId].txcodeIndex)
{
/* TRACE("OLC processing not finished, waiting...\n");*/
return -1;
}
memset(display, 0, sizeof(display));
ret = cmCallGetDisplayInfo(hsCall, display, sizeof(display));
if (ret <= 0)
{
/* TRACE("Get the remote display info error\n");*/
}
wpmsg.baseInfo.callIndex = callId;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -