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

📄 voip_prototypes_adapter.h

📁 telcobridges voip develop
💻 H
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |	Project:    	VOIP sample
 |
 |	Filename:   	voip_prototypes_adapter.h
 |
 |	Copyright:  	TelcoBridges 2002-2004, All Rights Reserved
 |
 |	Description:	This file contains macros and function prototypes
 |					of functions used to communicate with adapters.
 |
 |	Notes:      	Tabs = 4
 |
 *-------------------------------------------------------------------------------------------------------------------------------
 |
 |	Revision:   	$Revision: 1.25 $
 |
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Define header file
 *------------------------------------------------------------------------------------------------------------------------------*/
#ifndef __VOIP_PROTOTYPES_ADAPTER_H__
#define __VOIP_PROTOTYPES_ADAPTER_H__


/*--------------------------------------------------------------------------------------------------------------------------------
 |  C++ support
 *------------------------------------------------------------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Global variables
 *------------------------------------------------------------------------------------------------------------------------------*/


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Macros
 *------------------------------------------------------------------------------------------------------------------------------*/

#define VOIP_SEND_REQUEST_BODY_PART1( _MSG_NAME, _un32ExtraBytes )				\
{																				\
	TBX_RESULT							Result;									\
	TBX_MSG_HANDLE						hMsg;									\
	PTB640_MSG_##_MSG_NAME				pMsg;									\
	TBX_UINT32							un32MsgSize;							\
																				\
	CODE																		\
	{																			\
		/* Initialize local variables */										\
		Result				= TBX_RESULT_OK;									\
																				\
		/* Compute message size */												\
		un32MsgSize = sizeof(*pMsg) + (_un32ExtraBytes);						\
																				\
		/* Get a message buffer */												\
		Result = TBXGetMsg (g_pContext->hTbxLib, un32MsgSize, &hMsg);			\
		if (TBX_RESULT_FAILURE (Result))										\
		{																		\
			TBX_EXIT_ERROR (Result, 0, "Failed to get message buffer.");		\
		}																		\
																				\
		/* Clear the buffer... */												\
		memset (TBX_MSG_PAYLOAD_POINTER (hMsg), 0, TBX_MSG_PAYLOAD_MAX_LENGTH_GET (hMsg));	\
																				\
		/* Set the message header */											\
		TBX_FORMAT_MSG_HEADER													\
		(																		\
			hMsg,																\
			TB640_MSG_ID_##_MSG_NAME,											\
			TBX_MSG_TYPE_REQUEST,												\
			un32MsgSize,														\
			in_pAdapterContext->AdapterInfo.hAdapter,							\
			VOIP_USER_CONTEXT,													\
			0																	\
		);																		\
																				\
		/* Fill the request */													\
		pMsg = (PTB640_MSG_##_MSG_NAME) TBX_MSG_PAYLOAD_POINTER (hMsg);			\
		pMsg->Request.un32MsgVersion	= 1;									\


#define VOIP_SEND_REQUEST_BODY_PART2(__szFctName__)								\
																				\
		/* Send the request */													\
		Result = TBXSendMsg (g_pContext->hTbxLib, hMsg, NULL);					\
		hMsg			= TBX_HANDLE_INVALID;									\
		pMsg			= NULL;													\
																				\
		if (TBX_RESULT_FAILURE (Result))										\
		{																		\
			TBX_EXIT_ERROR (Result, 0, "Failed to send message buffer.");		\
		}																		\
																				\
		/* Count this expected response */										\
		in_pAdapterContext->un32NbResponsesExpected++;							\
																				\
		/* End of the code (skip to cleanup) */									\
		TBX_EXIT_SUCCESS (TBX_RESULT_OK);										\
	}																			\
																				\
	ERROR_HANDLING																\
	{																			\
		VoipCliAdapterStatePrint(												\
			in_pAdapterContext,													\
			TRACE_LEVEL_ERROR,													\
			FRED __szFctName__": %s (Result 0x%08X, %s, line %d)\n",					\
			TBX_ERROR_DESCRIPTION,												\
			(int)TBX_ERROR_RESULT,												\
			__FILE__,															\
			TBX_ERROR_LINE);													\
	}																			\
																				\
	CLEANUP																		\
	{																			\
		if( hMsg != TBX_HANDLE_INVALID )										\
		{																		\
			TBXReleaseMsg (g_pContext->hTbxLib, hMsg);							\
			hMsg = TBX_HANDLE_INVALID;											\
		}																		\
	}																			\
																				\
	RETURN;																		\
}

#define VOIP_TREE_INSERT( _pParent, _pChildPtr, _pChild, _pParentPtr )			\
{																				\
	if( (_pChildPtr) )															\
	{																			\
		(_pChild)->pNext	= (_pChildPtr);										\
		(_pChildPtr)->pPrev	= (_pChild);										\
		(_pChildPtr)		= (_pChild);										\
	}																			\
	else																		\
	{																			\
		(_pChildPtr)		= (_pChild);										\
	}																			\
	(_pParentPtr)			= (_pParent);										\
}

#define VOIP_TREE_REMOVE( _pToUnlink, _pParentFirst )							\
{																				\
	if( (_pToUnlink)->pNext )													\
		(_pToUnlink)->pNext->pPrev = (_pToUnlink)->pPrev;						\
	if( (_pToUnlink)->pPrev )													\
		(_pToUnlink)->pPrev->pNext = (_pToUnlink)->pNext;						\
	else																		\
		(_pParentFirst) = (_pToUnlink)->pNext;									\
	(_pToUnlink)->pNext = (_pToUnlink)->pPrev = NULL;							\
}


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Function prototypes
 *------------------------------------------------------------------------------------------------------------------------------*/

/* Adapter states get */
TBX_RESULT	VoipUpdateAllAdaptersStates( TBX_VOID );
TBX_RESULT	VoipAdapterUpdateStates( PVOIP_ADAPTER_CONTEXT );

/* Adapter state clear */
TBX_RESULT	VoipAdapterClearSubState1( PVOIP_ADAPTER_CONTEXT, TBX_BOOL );
TBX_RESULT	VoipAdapterClearSubState2( PVOIP_ADAPTER_CONTEXT, TBX_BOOL );
TBX_RESULT	VoipAdapterClearSubState3( PVOIP_ADAPTER_CONTEXT, TBX_BOOL );

/* Adapter state alloc */
TBX_RESULT	VoipAdapterAllocSubState1( PVOIP_ADAPTER_CONTEXT );
TBX_RESULT	VoipAdapterAllocSubState2( PVOIP_ADAPTER_CONTEXT );
TBX_RESULT	VoipAdapterAllocSubState3( PVOIP_ADAPTER_CONTEXT );

/* Adapter state ready */
TBX_BOOL	VoipAdapterIsConnectMessage( TBX_MSG_HANDLE );
TBX_BOOL	VoipAdapterIsDisconnectMessage( TBX_MSG_HANDLE );
TBX_RESULT	VoipAdapterHandleConnectMessage(PVOIP_ADAPTER_CONTEXT, TBX_MSG_HANDLE );
TBX_RESULT	VoipAdapterHandleDisconnectMessage(PVOIP_ADAPTER_CONTEXT, TBX_MSG_HANDLE );

/* Adapter attach */
TBX_RESULT	VoipSendAdapterAttach( PVOIP_ADAPTER_CONTEXT );

⌨️ 快捷键说明

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