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

📄 structures.h

📁 telcobridges tone develop
💻 H
📖 第 1 页 / 共 2 页
字号:
/*--------------------------------------------------------------------------------------------------------------------------------
 |
 |	Project:    	VoiceLink TB640 sample (tone)
 |
 |	Filename:   	structures.h
 |
 |	Copyright:  	TelcoBridges 2002-2003, All Rights Reserved
 |
 |	Description:	This file contains the required definitions and prototypes for other files to compile.
 |
 |	Notes:      	Tabs = 4
 |
 *-------------------------------------------------------------------------------------------------------------------------------
 |
 |	Revision:   	$Revision: 1.11 $
 |
 *------------------------------------------------------------------------------------------------------------------------------*/

#ifdef WIN32
	#include <stdio.h>
	#include <conio.h>
	#include <windows.h>
#else
	#include <sys/time.h>
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <netinet/tcp.h>
	#include <arpa/inet.h>
	#include <netdb.h>
	#include <unistd.h>
	#include <stdio.h>
	#include <stdlib.h>
	#include <string.h>
#endif

/* Local includes */
#include "tbx_ostypes.h"
#include "tbx_id.h"
#include "tbx_result.h"
#include "tbx_msg.h"
#include "tbx_std.h"
#include "tbx_api.h"
#include "tbx_featmgr.h"
#include "tbx_hash.h"
#include "tbx_timer.h"
#include "tbx_pool_of_buffers.h"
#include "tb640_id.h"
#include "tb640_handle.h"
#include "tb640_adpmgr.h"
#include "tb640_connmgr.h"
#include "tb640_trkmgr.h"
#include "tb640_pmalarmmgr.h"
#include "tbx_stream.h"
#include "tb640_streammgr.h"
#include "tb640_vpmgr.h"
#include "messages.h"
#include "adapter_select.h"


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


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


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Forward declarations
 *------------------------------------------------------------------------------------------------------------------------------*/

/*--------------------------------------------------------------------------------------------------------------------------------
 |  Defines
 *------------------------------------------------------------------------------------------------------------------------------*/
#define TB640_TONE_RECEIVE_TIMEOUT_MSEC				(90 * 1000)

#define TB640_TONE_MAX_NB_TRUNK						64


/*--------------------------------------------------------------------------------------------------------------------------------
 |  Types
 *------------------------------------------------------------------------------------------------------------------------------*/

typedef struct _TONE_COLLECT_CB
{
	TBX_BOOL					fFirstDigitReceived;
	TB640_RESOURCE_HANDLE		hRes;

	TONE_REQ_COLLECTOR_ALLOC	Request;

	TBX_MSG_HANDLE				hNotif;
	PTONE_EVT_COLLECTOR_NOTIF	pNotif;

} TONE_COLLECT_CB, *PTONE_COLLECT_CB;

typedef struct _TONE_EVENTS_THREAD_CONTEXT
{
	TBX_LIB_HANDLE		hLib;
	TBX_ADAPTER_HANDLE	hAdapter;
	TBX_FILTER_HANDLE	hEventsFilter;
	TBX_BOOL			fContinue;
	TBX_BOOL			fRunning;
	TBX_BOOL			fDaisyChain;
	TBX_BOOL			fBurstTest;
	TBX_BOOL			fShortDtmfTest;

} TONE_EVENTS_THREAD_CONTEXT, *PTONE_EVENTS_THREAD_CONTEXT;

typedef struct _TONE_COLLECTOR_THREAD_CONTEXT
{
	TBX_LIB_HANDLE				hLib;
	TBX_ADAPTER_HANDLE			hAdapter;
	TBX_FILTER_HANDLE			hEventsFilter;
	TBX_BOOL					fContinue;
	TBX_BOOL					fRunning;

	TBX_TIMER_HANDLE			hTimer;
	TBX_POOL_OF_BUFFERS_HANDLE	hPool;

} TONE_COLLECTOR_THREAD_CONTEXT, *PTONE_COLLECTOR_THREAD_CONTEXT;

typedef struct _TONE_TIMER_THREAD_CONTEXT
{
	TBX_LIB_HANDLE		hLib;
	TBX_ADAPTER_HANDLE	hAdapter;
	TBX_UINT32			un32Timeout;
	TBX_FILTER_HANDLE	hEventsFilter;
	TBX_BOOL			fContinue;
	TBX_BOOL			fRunning;

} TONE_TIMER_THREAD_CONTEXT, *PTONE_TIMER_THREAD_CONTEXT;

/* This new types contains needed information by the sample for a specific trunk */
typedef struct _TB640_TONE_TRUNK_INFO
{
	TB640_TRUNK_HANDLE			hTrunk;
	TBX_UINT32					unNb64KbpsTimeslotAvailable;
	TBX_BOOL					fAllocated;
	TBX_BOOL					fActivated;

} TB640_TONE_TRUNK_INFO, *PTB640_TONE_TRUNK_INFO;

typedef struct _TBX_FIFO
{
	TBX_UINT16		un16Head;
	TBX_UINT16		un16Tail;
	TBX_UINT16		un16FifoLen;
	TBX_UINT16		un16ObjCnt;		/* unaccurate stats */
	PTBX_VOID*		apObj;

} TBX_FIFO, *PTBX_FIFO;

/*--------------------------------------------------------------------------------------------------------------------------------
 |  Global variables
 *------------------------------------------------------------------------------------------------------------------------------*/
extern TB640_TONE_TRUNK_INFO			g_aTrunkInfo [TB640_TONE_MAX_NB_TRUNK];

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

/*
 * Return TRUE when FIFO is empty
 */
#define TBX_FIFO_EMTPY( _pFifo ) \
		((_pFifo)->un16Tail == (_pFifo)->un16Head)

/*
 * Return TRUE when FIFO is full
 */
#define TBX_FIFO_FULL( _pFifo ) \
		( !TBX_FIFO_EMTPY((_pFifo)) && \
		(((_pFifo)->un16Tail%(_pFifo)->un16FifoLen) == ((_pFifo)->un16Head%(_pFifo)->un16FifoLen)))

/*
 * Get Fifo element count
 */
#define TBX_FIFO_COUNT( _pFifo ) \
		(TBX_FIFO_EMTPY((_pFifo)) ? \
		0 : \
		((TBX_UINT16)((_pFifo)->un16Head - (_pFifo)->un16Tail)))

/*
 * Put an object in the Fifo, if sucessful, the object is nulled
 */
#define TBX_FIFO_PUT( _pFifo, _ppObj ) \
{ \
	if( !TBX_FIFO_FULL( (_pFifo) ) ) \
	{ \
		(_pFifo)->apObj[((_pFifo)->un16Head)%(_pFifo)->un16FifoLen] = *(_ppObj); \
		(_pFifo)->un16Head++; \
		(_pFifo)->un16ObjCnt++; \
		*(_ppObj) = NULL; \
	} \
}

/*
 * Get an object from the Fifo, if sucessful, object is non-null
 */
#define TBX_FIFO_GET( _pFifo, _ppObj ) \
{ \
	if( TBX_FIFO_EMTPY((_pFifo)) ) \
		*(_ppObj) = NULL; \
	else \
	{ \
		*(_ppObj) = (_pFifo)->apObj[((_pFifo)->un16Tail)%(_pFifo)->un16FifoLen]; \
		(_pFifo)->un16Tail++; \
		(_pFifo)->un16ObjCnt--; \
	} \
}

/*
 * Create a Fifo
 */
#define TBX_FIFO_CREATE( _pFifo, _un16FifoLen ) \
	/* Allocate the Fifo Array */ \
	((_pFifo)->apObj = (PTBX_VOID*)calloc( sizeof( *(_pFifo)->apObj ), _un16FifoLen )) ? \
	((_pFifo)->un16FifoLen = (_un16FifoLen)) : 0 ? \
	TBX_RESULT_OK : TBX_RESULT_FAIL \

/*
 * Destroy a Fifo
 */
#define TBX_FIFO_DESTROY( _pFifo ) \
{ \
	if((_pFifo)->apObj) \
		free( (_pFifo)->apObj ); \
}

/*--------------------------------------------------------------------------------------------------------------------------------
 |  Function Prototypes
 *------------------------------------------------------------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  ToneMainMenu:	This function displays the PM application's main menu.
 |
 |  in_hLib         :	Handle to the TBX library returned by TBXOpenLib()
 |  in_hAdapter     :	Handle to an adapter that was previously selected and attached to by SelectAdapter()
 |	in_un32TrunkNo	:	Trunk number to use
 |
 |  Note			:	~
 |
 |  Return          :	TBX_RESULT_OK
 |						TBX_RESULT_FAIL
 |						or others
 |
 *------------------------------------------------------------------------------------------------------------------------------*/
TBX_RESULT ToneMainMenu (
  IN		TBX_LIB_HANDLE			in_hLib,
  IN		TBX_ADAPTER_HANDLE		in_hAdapter,
  IN		TBX_UINT32				in_un32TrunkNo );

/*-------------------------------------------------------------------------------------------------------------------------------
 |
 |  GetMaxAllowedTrunks	:	Retrieve the maximum number of allowed E1 trunks.
 |
 |  in_hLib         :	Handle to the TBX library returned by TBXOpenLib()
 |  in_hAdapter     :	Handle to an adapter that was previously selected and attached to by SelectAdapter()
 |	in_fE1			:	E1 or T1 ?
 |
 |  Note			:	The adapter must support E1 configuration.

⌨️ 快捷键说明

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