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

📄 rvwp_api.c

📁 基于h323协议的软phone
💻 C
📖 第 1 页 / 共 3 页
字号:
{
	HCALL hsCall;
	cmUserInputData userData;
	RvPvtNodeId nodeId;

/*	TRACE("wpSendUserInputId(): user input = %d\n", userInputId);*/

	hsCall = wpCallInfo[callIndex].hsCall;

	wpCallConnectH245Control(callIndex);

	userData.data = &userInputId;
	userData.length = 1;
	if ((nodeId = cmUserInputBuildAlphanumeric(hApp, &userData)) < 0)
	{
	/*	TRACE("cmUserInputBuildAlphanumeric: Build the user input pvt tree error\n");*/
		return RV_FALSE;
	}	

	if (cmCallSendUserInput(hsCall, nodeId) < 0)
	{
	/*	TRACE("Send user input indication error\n");*/
		return RV_FALSE;
	}
	else
	{
	/*	TRACE("Send user input indication ok\n");*/
	}
	return RV_TRUE;
}
/*deleted by mxd 2005.1.19 for windows */
//#include <semLib.h>

#ifdef INCLUDE_RV_RTP

#if 0
extern RvUint32 rtp_last_time;
extern RvSemaphore *rtpSem;
extern RvUint8 sendCodec;

static int sendDtmfEvent
(
	IN HRTPSESSION hRTP,
	IN rtpDtmfEvent newEvent,
	IN RvUint8 vol,
	IN RvUint32 duration,
	IN char num,
	IN unsigned char callIndex
)
{
	rtpParam p;
	rtpDtmfEventParams dtmf;
	static char buffer[40];
	int len = 16;
	int i;
	int times;
	int payload;
	int rtptimestamp;
	int callId= callIndex;
/*	TRACE("sendDtmfEvent()\n");*/

	if (wpCallInfo[callId].payload >= 96 && wpCallInfo[callId].payload <= 127)
		payload = wpCallInfo[callId].payload;
	else
		payload = 101;
	if(WaitForSingleObject(rtpSem, INFINITE) == WAIT_OBJECT_0)
		rtptimestamp = rtp_last_time; 
	ReleaseSemaphore(rtpSem,1,NULL);
	for(i=0;i<6;i++)
	{
		dtmf.end = 0;
		dtmf.duration = 0; 
		p.marker = 1;
		dtmf.event = newEvent;
		dtmf.volume = 0;
		p.payload = payload;
		p.sByte = 16;
	//	semTake(rtpSem, WAIT_FOREVER);
		if(WaitForSingleObject(rtpSem, INFINITE) == WAIT_OBJECT_0)	
		{
			p.timestamp = rtptimestamp; 
			rtpDtmfEventPack(buffer, p.sByte, &p, &dtmf);
			if (rtpWrite(hRTP, buffer, len, &p) < 0)
			{
			/*	TRACE("rtpWrite error\n");*/
				ReleaseSemaphore(rtpSem,1,NULL);
				return -1;
			}
		}
		ReleaseSemaphore(*rtpSem,1,NULL);
	}
 	switch (sendCodec)
		{
			case PCMU:
			case PCMA: 
				dtmf.duration += G711_TIMESTAMP_INTERVAL;
				break;
			case G729:
				dtmf.duration += G729_TIMESTAMP_INTERVAL/2;
				break;	
			case G7231:
				dtmf.duration += G723_TIMESTAMP_INTERVAL;
				break;
			default:
				dtmf.duration += G711_TIMESTAMP_INTERVAL;
				break;
		}
	for(i=0;i<6;i++)
	{
		dtmf.end = 0;
		p.marker = 0;
		dtmf.event = newEvent;
		dtmf.volume = 0;
		p.payload = payload;
		p.sByte = 16;
	//	semTake(rtpSem, WAIT_FOREVER);
		if(WaitForSingleObject(rtpSem, INFINITE) == WAIT_OBJECT_0)
		{
			p.timestamp = rtptimestamp; 
			rtpDtmfEventPack(buffer, p.sByte, &p, &dtmf);
			if (rtpWrite(hRTP, buffer, len, &p) < 0)
			{
			/*	TRACE("rtpWrite error\n");*/
				ReleaseSemaphore(rtpSem,1,NULL);
				return -1;
			}
		}
		ReleaseSemaphore(*rtpSem,1,NULL);
	}

	switch (sendCodec)
		{
			case PCMU:
			case PCMA: 
				dtmf.duration += G711_TIMESTAMP_INTERVAL;
				break;
			case G729:
				dtmf.duration += G729_TIMESTAMP_INTERVAL/2;
				break;	
			case G7231:
				dtmf.duration += G723_TIMESTAMP_INTERVAL;
				break;
			default:
				dtmf.duration += G711_TIMESTAMP_INTERVAL;
				break;
		}
	for(i=0;i<6;i++)
	{
		dtmf.end = 1;
		p.marker = 0;
		dtmf.event = newEvent;
		dtmf.volume = 0;
		p.payload = payload;
		p.sByte = 16;
	//	semTake(rtpSem, WAIT_FOREVER);
		if(WaitForSingleObject(rtpSem, INFINITE) == WAIT_OBJECT_0)
		{
			p.timestamp = rtptimestamp; 
			rtpDtmfEventPack(buffer, p.sByte, &p, &dtmf);
			if (rtpWrite(hRTP, buffer, len, &p) < 0)
			{
			/*	TRACE("rtpWrite error\n");*/
				ReleaseSemaphore(rtpSem,1,NULL);
				return -1;
			}
		}
		ReleaseSemaphore(*rtpSem,1,NULL);

	}

/*	TRACE("Send event %c ok\n", num);*/
	return 0;
}


static int sendDtmfTones
(
	IN HRTPSESSION rtpSession,
	IN RvUint16 *frequencyList,
	IN RvInt8 numOfFreq,
	IN RvUint8 vol,
	IN RvUint32 duration,
	IN char num
)
{
	static rtpParam p;
	static rtpDtmfTonesParams tones;
	static char buffer[20];
	int len = 16;
	

/*	TRACE("sendDtmfTones()\n");*/

	/* set the appropriate parameters for DTMF header */
	tones.duration = duration<<3; /* multiplying by 8 - to get to the timestamp units - 0.125ms */
	tones.T = 0;
	tones.modulation = 0;
	tones.volume = 0;
	tones.freqListLength = numOfFreq;
	tones.freqList = frequencyList;

	/* set the appropriate parameters for RTP header */
	p.payload = 96;
	p.marker = 1;
	/* each doubleWord contains 2 frequencies. however a doubleWord can also
	contain 1 frequency provided it's the last one. */
	p.sByte = 16 + 4 * ((numOfFreq+1)/2);
	p.len = 16 + 4 * ((numOfFreq+1)/2);     /* the packet contain no other payload than DTMF info */

	switch (sendCodec)
	{
		case PCMU:
		case PCMA: 
			rtp_last_time += G711_TIMESTAMP_INTERVAL; break;
		case G729:
			rtp_last_time += G729_TIMESTAMP_INTERVAL; break;	
		case G7231:
			rtp_last_time += G723_TIMESTAMP_INTERVAL; break;
		default:
			rtp_last_time += G711_TIMESTAMP_INTERVAL; break;
	}

	p.timestamp = rtp_last_time;/*(timerGetTimeInMilliseconds() - dtmf_startTime) * 8;*/

	/* build the DTMF-tone format header, for RTP packet */
	rtpDtmfTonesPack(buffer, p.sByte, &p, &tones);
	
	/* build the RTP header, and send the packet */
	if (rtpWrite(rtpSession, buffer, p.len, &p) < 0)
	{
	/*	TRACE("rtpWrite error\n");*/
		return -1;
	}
	
/*	TRACE("Send tone %c ok\n", num);*/
	return 0;
}
#endif
RVAPI void RVCALLCONV wpSendInformation(unsigned char callIndex,char userInput)
{
	int nodeID;
	nodeID = cmCallUserInformationCreate(wpCallInfo[callIndex].hsCall, &userInput, NULL);

    /* Send Notify message */
  	cmCallUserInformationSend(wpCallInfo[callIndex].hsCall, nodeID);
}
#if 0
/* ==== DTMF telephony tones ==== */
RVAPI int RVCALLCONV wpSendDTMF2833(unsigned char callIndex, char userInput, unsigned char isTone)
{
	int time, volume;	

/*	TRACE("wpSendDTMF2833()\n");*/
     /*  atc = atoi(TclGetVariable("Script(atcd)"));*/
	time = 0;
	volume = 0; /* that will just give 1 */

	if (isTone)
	{
		static RvUint16 frequencyList[2];
		RvInt8 numOfFreq = 2;
		/* set the appropriate DTMF telephony tones - there
		2 frequencies that modulate a single DTMF tone */
		switch (userInput)
		{
			case '0': frequencyList[0] = FrequencyTable[13].freq1; frequencyList[1] = FrequencyTable[13].freq2; break;
			case '1': frequencyList[0] = FrequencyTable[0].freq1; frequencyList[1] = FrequencyTable[0].freq2; break;
			case '2': frequencyList[0] = FrequencyTable[1].freq1; frequencyList[1] = FrequencyTable[1].freq2; break;
			case '3': frequencyList[0] = FrequencyTable[2].freq1; frequencyList[1] = FrequencyTable[2].freq2; break;
			case '4': frequencyList[0] = FrequencyTable[4].freq1; frequencyList[1] = FrequencyTable[4].freq2; break;
			case '5': frequencyList[0] = FrequencyTable[5].freq1; frequencyList[1] = FrequencyTable[5].freq2; break;
			case '6': frequencyList[0] = FrequencyTable[6].freq1; frequencyList[1] = FrequencyTable[6].freq2; break;
			case '7': frequencyList[0] = FrequencyTable[8].freq1; frequencyList[1] = FrequencyTable[8].freq2; break;
			case '8': frequencyList[0] = FrequencyTable[9].freq1; frequencyList[1] = FrequencyTable[9].freq2; break;
			case '9': frequencyList[0] = FrequencyTable[10].freq1; frequencyList[1] = FrequencyTable[10].freq2; break;
			case '*': frequencyList[0] = FrequencyTable[12].freq1; frequencyList[1] = FrequencyTable[12].freq2; break;
			case '#': frequencyList[0] = FrequencyTable[14].freq1; frequencyList[1] = FrequencyTable[14].freq2; break;
			case 'A': frequencyList[0] = FrequencyTable[3].freq1; frequencyList[1] = FrequencyTable[3].freq2; break;
			case 'B': frequencyList[0] = FrequencyTable[7].freq1; frequencyList[1] = FrequencyTable[7].freq2; break;
			case 'C': frequencyList[0] = FrequencyTable[11].freq1; frequencyList[1] = FrequencyTable[11].freq2; break;
			case 'D': frequencyList[0] = FrequencyTable[15].freq1; frequencyList[1] = FrequencyTable[15].freq2; break;
			default: /*TRACE("User Input is invalid\n");*/ return;
		}
		sendDtmfTones(wpCallInfo[callIndex].rtpSession, frequencyList, numOfFreq, 0, (RvUint32)time, userInput);
	}
	else
	{
		rtpDtmfEvent    event;
		/* set the appropriate DTMF event */
		switch (userInput)
		{
			case '0': event = rtpDtmfEvent_0; break;
			case '1': event = rtpDtmfEvent_1; break;
			case '2': event = rtpDtmfEvent_2; break;
			case '3': event = rtpDtmfEvent_3; break;
			case '4': event = rtpDtmfEvent_4; break;
			case '5': event = rtpDtmfEvent_5; break;
			case '6': event = rtpDtmfEvent_6; break;
			case '7': event = rtpDtmfEvent_7; break;
			case '8': event = rtpDtmfEvent_8; break;
			case '9': event = rtpDtmfEvent_9; break;
			case '*': event = rtpDtmfEvent_asterisk; break;
			case '#': event = rtpDtmfEvent_pound; break;
			case 'A': event = rtpDtmfEvent_A; break;
			case 'B': event = rtpDtmfEvent_B; break;
			case 'C': event = rtpDtmfEvent_C; break;
			case 'D': event = rtpDtmfEvent_D; break;
			default: /*TRACE("User Input is invalid\n"); */return;
		}
		sendDtmfEvent(wpCallInfo[callIndex].rtpSession, event, (RvUint8)volume, (RvUint32)time, userInput,callIndex);
	}
}
#endif
#endif /* INCLUDE_RV_RTP */

⌨️ 快捷键说明

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