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

📄 rvwp_sys_dep.c

📁 基于h323协议的软phone
💻 C
字号:
/*************************************************************************
 * Name :		rvwp_sys_dep.c
 *
 * Type :			C source file
 *
 * Description :	Wrapper system-dependent functions
 *
 * Date : 			2004-03-22
 *
 *************************************************************************/
/* deleted by mxd 2004.1.19 for windows*/
/*
#include <vxworks.h>
#include <semLib.h>
#include <stdlib.h>
#include <MsgQLib.h>
*/
#include <stdio.h>
#include "rvwpt.h"
#include "cm.h"
#include "ci.h"
#include "cmintr.h"
#include "seli.h"
#ifdef INCLUDE_RV_RTP
#include "rvrtp.h"
#endif

/*deleted by mxd 2005.1.18 for windows*/
//static MSG_Q_ID theMsgQId = NULL;


/*************************************************************************
 * Function:		wPGetCallIndex
 *
 * Description:	Find the index of the call buffer.
 *
 * Input:			hsCall - call handle which stored in the call buffer.
 *
 * Returns:		int - return the index.
 *
 *************************************************************************/
/*deleted by mxd 2005.1.18 for windows*/
// SEM_ID       callIndexSem, rtpSem;
RvSemaphore* callIndexSem;
RvSemaphore* rtpSem;
RvSemaphore* fileSem;
RvH323TimerPoolHandle rv_timer;
RvTimerQueue* rv_timersQueue;
FILE *fp;


extern AudioInfo   Codec;
int wpInit()
{
/* modified by mxd 2004.1.18 for windows*/
/*	callIndexSem = semBCreate( SEM_Q_PRIORITY, SEM_EMPTY );
	semGive(callIndexSem);
	rtpSem = semBCreate( SEM_Q_PRIORITY, SEM_EMPTY );
	semGive(rtpSem);
*/	
	
	RvUint32 startcount = RvUint32Const(1);

	int i;
	char *name[] = {"g7231", "g711Ulaw64k", "g711Alaw64k"};

	fp = fopen("syslog","w+");
	fileSem = CreateSemaphore(NULL,(long)startcount,RV_INT32_MAX,NULL);
/*	ReleaseSemaphore(*fileSem,1,NULL);*/
	callIndexSem = CreateSemaphore(NULL,(long)startcount,RV_INT32_MAX,NULL);
/*	ReleaseSemaphore(*callIndexSem,1,NULL);*/
	rtpSem = CreateSemaphore(NULL,(long)startcount,RV_INT32_MAX,NULL);
/*	ReleaseSemaphore(*rtpSem,1,NULL);*/
	rv_timer = RvH323TimerConstruct(5, &rv_timersQueue);

	for (i = 0; i < 3; i++)
	{
		Codec.codecPrefOrder[i].isUsed = 1;
		Codec.codecPrefOrder[i].codecType = cmCapAudio;
		strcpy(Codec.codecPrefOrder[i].codecName, name[i]);
	}
	return 0;
}

int wPGetCallIndex(HCALL hsCall)
{
	int i;
/* modified by mxd 2005.1.18 for windows */
/*	semTake(callIndexSem, WAIT_FOREVER);*/
	if(WaitForSingleObject(callIndexSem,INFINITE) == WAIT_OBJECT_0)
	{
		for (i = 0; i < MAX_CONCURRENT_CALL_NUM; i++)
		{
			if (wpCallInfo[i].hsCall == hsCall)
			{
				ReleaseSemaphore(callIndexSem,1,NULL);
				return i;
			}
		}
	}
	ReleaseSemaphore(callIndexSem,1,NULL);
	return -1;
}

int wpRelsCall(HCALL hsCall)
{
	int i;
	if(WaitForSingleObject(callIndexSem, INFINITE) == WAIT_OBJECT_0)
	{
		for (i = 0; i < MAX_CONCURRENT_CALL_NUM; i++)
		{
			if (wpCallInfo[i].hsCall == hsCall)
			{
	#ifdef INCLUDE_RV_RTP
				if(WaitForSingleObject(rtpSem, INFINITE) == WAIT_OBJECT_0)
				{
					if (wpCallInfo[i].rtpSession != NULL)
					{				
						rtpClose(wpCallInfo[i].rtpSession);
						wpCallInfo[i].rtpSession = NULL;
					}
				}
				ReleaseSemaphore(rtpSem,1,NULL);
	#endif
				memset(&wpCallInfo[i], 0, sizeof(CallInfo));
	/*			wpCallInfo[i].hsCall = NULL;*/
				ReleaseSemaphore(callIndexSem,1,NULL);
				return 0;
			}
		}
	}
	ReleaseSemaphore(*callIndexSem,1,NULL);
	return -1;
}


/*************************************************************************
 * Function:		wpSendMsgToApp
 *
 * Description:	create a VxWork message and send it to the application
 *
 *************************************************************************/
HWND haWnd;
RVAPI void RVCALLCONV wpGetWnd(HWND AppWnd)
{
	haWnd = AppWnd;
}
RvUint8 wpSendMsgToApp(WrapperMsg *givenMsg)
{

/*	if(WaitForSingleObject(fileSem,INFINITE) == WAIT_OBJECT_0) 
	{ 
		fprintf(fp,"wpSendMsgToApp(): MsgId = %d\n", givenMsg->msgId);
		ReleaseSemaphore(fileSem,1,NULL);
	}
	*/
	SendMessage(haWnd,WM_MSG,(WPARAM)0,(LPARAM)(givenMsg));
	
	return RV_TRUE;
}

⌨️ 快捷键说明

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