📄 rvwp_ex_ms.c
字号:
wpmsg.d.codec.remoteRtpIpAddr = wpCallInfo[callId].ip;
wpmsg.d.codec.remoteRtpPort = wpCallInfo[callId].rtpPort;
wpmsg.d.codec.localRtpPort = FIRST_RTP_PORT + callId * 2;
strncpy(wpmsg.baseInfo.display, display, MAX_DISPLAY_LENGTH);
wpmsg.baseInfo.display[MAX_DISPLAY_LENGTH] = '\0';
wpmsg.d.codec.rx = wpCallInfo[callId].rxcodeIndex;
wpmsg.d.codec.tx = wpCallInfo[callId].txcodeIndex;
wpmsg.msgId = WP_REC_CONN;
#ifdef INCLUDE_RV_RTP
OpenLocalRtp(callId, &wpmsg.d.codec.localRtpPort,
&wpCallInfo[callId].ip, &wpCallInfo[callId].rtpPort);
#endif
if (wpmsg.d.codec.remoteRtpIpAddr == 0 || wpmsg.d.codec.remoteRtpPort == 0)
{
return -1;
}
wpCallInfo[callId].isConnected = RV_TRUE;
wpmsg.rtpSession = wpCallInfo[callId].rtpSession;
wpSendMsgToApp(&wpmsg);
}
}
break;
}
case cmChannelStateDisconnected:
{
HCALL hsCall;
int ret;
int callId;
ret = cmChannelGetCallHandles(hsChan, &hsCall, 0);
if (ret < 0)
{
/* TRACE("Get call handle of the channel error\n");*/
return 0;
}
callId = wPGetCallIndex(hsCall);
if (stateMode == cmChannelStateModeDisconnectedRemote) /* outgoing OLC was rejected by remote */
{
/* TRACE("Outgoing OLC was rejected by remote\n");*/
if (wpCallInfo[callId].txcodeIndex == wpCallInfo[callId].rxcodeIndex)
return 0;
/* TRACE("Try to open outgoing channel again\n");*/
if (wpCallInfo[callId].rxcodeIndex != -1)
{
wpCallInfo[callId].txcodeIndex = wpCallInfo[callId].rxcodeIndex;
wpOutChannelOpen(hsCall);
}
else
{
needOLCAgain = 1;
}
}
break;
}
default:
break;
}
return 0;
}
/*************************************************************************
* Function: cmEvChannelSetAddress
*
* Description: the function that invoked after cmChannelStateOffering occurs.
*
* input: haChan - Channel struct of the application
* hsChan - Handle for the channel
* ip - Ip address of the remote end
* port - RTP port number of the remote end
*
* output: none
* return: negative on error
*************************************************************************/
int RVCALLCONV cmEvChannelSetAddress
(
IN HAPPCHAN haChan,
IN HCHAN hsChan,
IN RvUint32 ip,
IN RvUint16 port
)
{
HCALL hsCall;
WrapperMsg wpmsg;
ChannelInfo* chan=(ChannelInfo*)haChan;
int callId;
char display[MAX_DISPLAY_LENGTH + 1];
int ret;
/* TRACE("cmEvChannelSetAddress()\n");*/
if (!haChan) return RV_ERROR_UNKNOWN;
ret = cmChannelGetCallHandles(hsChan, &hsCall, 0);
if (ret < 0)
{
/* TRACE("Get call handle of the channel error\n");*/
return -1;
}
callId = wPGetCallIndex(hsCall);
wpCallInfo[callId].ip = ip;
wpCallInfo[callId].rtpPort = port;
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;
wpmsg.d.codec.remoteRtpIpAddr = ip;
wpmsg.d.codec.remoteRtpPort = port;
/* TRACE("Remote rtp ip = %x, port = %d\n", ip, port);*/
wpmsg.d.codec.localRtpPort = FIRST_RTP_PORT + callId * 2;
strncpy(wpmsg.baseInfo.display, display, MAX_DISPLAY_LENGTH);
wpmsg.baseInfo.display[MAX_DISPLAY_LENGTH] = '\0';
wpmsg.d.codec.rx = wpCallInfo[callId].rxcodeIndex;
wpmsg.d.codec.tx = wpCallInfo[callId].txcodeIndex;
wpmsg.msgId = WP_REC_CONN;
#ifdef INCLUDE_RV_RTP
OpenLocalRtp(callId, &wpmsg.d.codec.localRtpPort, &ip, &port);
#endif
wpCallInfo[callId].isConnected = RV_TRUE;
wpmsg.rtpSession = wpCallInfo[callId].rtpSession;
wpSendMsgToApp(&wpmsg);
return 0;
}
int RVCALLCONV cmEvChannelSetRTCPAddress(IN HAPPCHAN haChan,
IN HCHAN hsChan,
IN RvUint32 ip,
IN RvUint16 port)
{
ChannelInfo* chan=(ChannelInfo*)haChan;
if (!haChan) return RV_ERROR_UNKNOWN;
/* TRACE("cmEvChannelSetRTCPAddress()\n");*/
return 0;
}
#if 0
int RVCALLCONV cmEvCallInfo(IN HAPPCALL haCall,
IN HCALL hsCall,
IN char* display,
IN char* userUser,
IN int userUserSize)
{
TRACE("cmEvCallInfo()\n");
return 0;
}
int RVCALLCONV cmEvCallNotify(IN HAPPCALL haCall,
IN HCALL hsCall,
IN int handle)
{
TRACE("cmEvCallNotify()\n");
return 0;
}
#endif
int RVCALLCONV cmEvCallProgress(IN HAPPCALL haCall,
IN HCALL hsCall,
IN int handle)
{
/* TRACE("cmEvCallProgress()\n");*/
return 0;
}
/*extern void printTime();*/
int RVCALLCONV cmEvCallRecvMessage(IN HAPPCALL haCall,
IN HCALL hsCall,
IN int message)
{
char msg[40];
strncpy(msg, cmGetProtocolMessageName(hApp, message),39);
msg[39]='\0';
/* printTime();*/
/* TRACE("cmEvCallRecvMessage(): %s\n", msg);*/
return 0;
}
int RVCALLCONV cmEvCallSendMessage(IN HAPPCALL haCall,
IN HCALL hsCall,
IN int message)
{
char msg[40];
strncpy(msg, cmGetProtocolMessageName(hApp, message), 39);
msg[39] = '\0';
/* printTime();*/
/* TRACE("cmEvCallSendMessage(): %s\n", msg);*/
return 0;
}
#if 0
int RVCALLCONV cmEvCallStatus(IN HAPPCALL haCall,
IN HCALL hsCall,
OUT IN cmCallStatusMessage *callStatusMsg)
{
TRACE("(cmEvCallStatus)\n");
return 0;
}
int RVCALLCONV cmEvCallTunnNewMessage(IN HAPPCALL haCall,
IN HCALL hsCall,
IN int vtNodeId,
IN int vtAddNodeId,
OUT RvBool* wait)
{
TRACE("(cmEvCallTunnNewMessage)\n");
return 0;
}
#endif
int RVCALLCONV cmEvCallNewChannel
(
IN HAPPCALL haCall,
IN HCALL hsCall,
IN HCHAN hsChan,
OUT LPHAPPCHAN lphaChan
)
{
/* TRACE("cmEvCallNewChannel()\n");*/
return 0;
}
/*************************************************************************
* Function: cmEvCallCapabilities
*
* Description: the function that invoked after Q.931 finished. We should search the
* first codec in our codec array(wpCodecList) which is also supported by
* the remote end
*
* Input: haCall - Application handle to the call.
* hsCall - CM handle to the call.
* capabilities - capabilities of the remote end
*
* output: none
* return: negative on error
*************************************************************************/
int RVCALLCONV cmEvCallCapabilities
(
IN HAPPCALL haCall,
IN HCALL hsCall,
IN cmCapStruct * capabilities[]
)
{
int i, j;
int callId;
int capNum = 0;
/* TRACE("cmEvCallCapabilities()\n");*/
callId = wPGetCallIndex(hsCall);
/* TRACE("Remote's capabilities:\n");*/
for (j = 0; capabilities[j] != NULL; j++)
{
/* TRACE("[%d] %s %d %d\n", j, capabilities[j]->name, capabilities[j]->capabilityId,
capabilities[j]->capabilityHandle);*/
capNum++;
if(strcmp(capabilities[j]->name,"dynamicRTPPayloadType")==0)
wpGetCapItemValue(capabilities[j]->capabilityHandle,&wpCallInfo[callId].payload);
}
wpCallInfo[callId].txcodeIndex = -1;
if (!wpCallInfo[callId].isIncoming) /* The call is a outgoing call */
{
for (i = 0; i < AUDIO_CODEC_NUM; i++)
{
if (Codec.codecPrefOrder[i].isUsed)
for (j = 0; capabilities[j] != NULL; j++)
{
if (strcmp(Codec.codecPrefOrder[i].codecName,
capabilities[j]->name) == 0)
{
wpCallInfo[callId].txcodeIndex = i;
/*TRACE("%s: Index of our codec matching remote in wpCodeList = %d\n",
capabilities[j]->name, wpCallInfo[callId].txcodeIndex);*/
return RV_TRUE;
}
}
}
}
else /* The call is a incoming call */
{
CapElem* capEntrySort;
/*CapElem capEntrySort[capNum];*/
capEntrySort = (CapElem* )malloc(sizeof(CapElem)*capNum);
for (i = 0; i < capNum; i++)
{
capEntrySort[i].capEntryNumber = capabilities[i]->capabilityId;
capEntrySort[i].name = capabilities[i]->name;
}
qsort((void *)capEntrySort, capNum, sizeof(CapElem), sort_function);
for (i = 0; i < capNum; i++)
{
for (j = 0; j < AUDIO_CODEC_NUM; j++)
{
if (Codec.codecPrefOrder[j].isUsed
&& strcmp(Codec.codecPrefOrder[j].codecName,
capEntrySort[i].name) == 0)
{
wpCallInfo[callId].txcodeIndex = j;
/* TRACE("%s: Index of the codec matching remote in our wpCodeList = %d\n",
capEntrySort[i].name, wpCallInfo[callId].txcodeIndex);
*/
return RV_TRUE;
}
}
}
}
/* TRACE("No codec in wpCodeList can matching remote");*/
return RV_FALSE;
}
#if 0
int RVCALLCONV cmEvCallControlStateChanged
(
IN HAPPCALL haCall,
IN HCALL hsCall,
IN cmControlState state,
IN cmControlStateMode stateMode
)
{
/* TRACE("cmEvCallControlStateChanged()\n");*/
return 0;
}
int RVCALLCONV cmEvCallControlMessage
(
IN HAPPCALL haCall,
IN HCALL hsCall,
IN HAPPCHAN haCahn,
IN HCHAN hsChan,
IN int message,
IN cmH245MessageType messageType
)
{
TRACE("cmEvCallControlMessage");
return 0;
}
int RVCALLCONV cmEvCallUserInput
(
IN HAPPCALL haCall,
IN HCALL hsCall,
IN RvInt32 userInputId
)
{
char display[128];
RvInt32 len = 128;
cmNonStandardParam nsData;
cmUserInputData userData;
char userDataStr[128];
userData.data = userDataStr;
userData.length = 128;
if (cmUserInputGet(hApp, userInputId, &nsData.info, display, &len, &userData) >= 0)
{
if (userData.length)
{
TRACE("User Input Indication received: %s\n", userData.data);
}
else if (len)
{
TRACE("User Input Indication(nonStandard) received: %s\n", display);
}
}
else
{
TRACE("User Input Indication received: Not nonStandard or alphanumeric\n");
}
return 0;
}
int RVCALLCONV cmEvChannelReplace
(
IN HAPPCHAN haChan,
IN HCHAN hsChan,
IN HAPPCHAN haReplacedChannel,
IN HCHAN hsReplacedChannel)
{
TRACE("cmEvChannelReplace()\n");
return 0;
}
#endif
int RVCALLCONV cmEvChannelParameters
(
IN HAPPCHAN haChan,
IN HCHAN hsChan,
IN char* channelName,
IN HAPPCHAN haChanSameSession,
IN HCHAN hsChanSameSession,
IN HAPPCHAN haChanAssociated,
IN HCHAN hsChanAssociated,
IN RvUint32 rate
)
{
HCALL hsCall;
int callId;
int ret;
/* TRACE("cmEvChannelParameters()\n");*/
ret = cmChannelGetCallHandles(hsChan, &hsCall, 0);
if (ret < 0)
{
/* TRACE("Get call handle of the channel error\n");*/
return RV_FALSE;
}
callId = wPGetCallIndex(hsCall);
if (wpCallInfo[callId].hsChan == hsChan)
{
/* TRACE("This is the outgoing channel, do nothing\n");*/
return RV_FALSE;
}
wpCallInfo[callId].rxcodeIndex = cmpChannelName(channelName);
if (needOLCAgain && wpCallInfo[callId].rxcodeIndex != -1)
{
wpCallInfo[callId].txcodeIndex = wpCallInfo[callId].rxcodeIndex;
wpOutChannelOpen(hsCall);
}
/* TRACE("Remote's OLC codec = %s\n", channelName);*/
return RV_TRUE;
}
#if 0
int RVCALLCONV cmEvChannelRequestCloseStatus
(
IN HAPPCHAN haChan,
IN HCHAN hsChan,
IN cmRequestCloseStatus status
)
{
TRACE("cmEvChannelRequestCloseStatus()\n");
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -