📄 vpbapi.h
字号:
unsigned int tone_id; // prog tone detector tone id
unsigned int call_id; // call progress tone id
unsigned int terminate; // no zero to terminate list
} VPB_TONE_MAP;
#define VPB_MAX_TONE_MAP 10 // maximum number of entries in tone map
// structure used to store call progress config information
typedef struct {
unsigned int dialtones; // number of dialtones (eg internal line, then outside line = 2 dialtones)
unsigned int dialtone_timeout; // wait for dial tone timeout in ms
unsigned int ringback_timeout; // time to wait for initial ringback in ms
unsigned int inter_ringback_timeout; // if ringback stops for this time (ms), call is considered connected
unsigned int answer_timeout; // time to wait for answer after ringback detected in ms
VPB_TONE_MAP tone_map[VPB_MAX_TONE_MAP]; // maps tone_id to call progress tone
} VPB_CALL;
// getting and setting call progress configuration
int WINAPI vpb_get_call(int handle, VPB_CALL *vpb_call);
int WINAPI vpb_set_call(int handle, VPB_CALL *vpb_call);
// call progress return codes
#define VPB_CALL_CONNECTED 0 // call connected successfully
#define VPB_CALL_NO_DIAL_TONE 1 // dial tone time out
#define VPB_CALL_NO_RING_BACK 2 // ring back time out
#define VPB_CALL_BUSY 3 // busy tone
#define VPB_CALL_NO_ANSWER 4 // no answer time out
#define VPB_CALL_DISCONNECTED 5 // no answer time out
// dialling with call progress
int WINAPI vpb_call_sync(int handle, char *dialstr);
int WINAPI vpb_call_async(int handle, char *dialstr);
/*-----------------------------------------------------------------------*\
PROGRAMMABLE TONE GENERATOR
\*-----------------------------------------------------------------------*/
// Programmable tone generator structure ---------------------------------
typedef struct {
unsigned short freq1; // frequency of first tone
unsigned short freq2; // frequency of second tone
unsigned short freq3; // frequency of third tone
short level1; // first tone level in dB, 0dB maximum
short level2; // second tone level in dB, 0dB maximum
short level3; // third tone level in dB, 0dB maximum
unsigned long ton; // on time ms
unsigned long toff; // off time ms
} VPB_TONE;
int WINAPI vpb_settone(char ident, VPB_TONE *vpb_tone);
int WINAPI vpb_gettone(char ident, VPB_TONE *vpb_tone);
int WINAPI vpb_playtone_async(int handle, VPB_TONE *vpb_tone);
int WINAPI vpb_playtone_sync(int handle, VPB_TONE *vpb_tone);
/*-----------------------------------------------------------------------*\
PROGRAMMABLE TONE DETECTOR
\*-----------------------------------------------------------------------*/
// built in tone dectector IDs
#define VPB_DIAL 0 // dial tone detected
#define VPB_RINGBACK 1 // ringback detected
#define VPB_BUSY 2 // busy tone detected
#define VPB_GRUNT 3 // grunt detected
#define VPB_MD 10 // maximum number of tone detectors per device
#define VPB_MS 10 // maximum number of states per cadence state mach
// State transition table consists of one entry for each state transition.
#define VPB_TIMER 0
#define VPB_RISING 1
#define VPB_FALLING 2
#define VPB_DELAY 3
typedef struct {
unsigned short type; // VPB_TIMER, VPB_RISING, or VPB_FALLING
unsigned short tfire; // timer mode only
unsigned short tmin; // minimum tone on/off time (non timer) in ms
unsigned short tmax; // maximum tone on/off time (non timer) in ms
} VPB_STRAN;
typedef struct {
unsigned short nstates; // number of cadence states
unsigned short tone_id; // unique ID number for this tone
unsigned short ntones; // number of tones (1 or 2)
unsigned short freq1; // freq of first tone (Hz)
unsigned short bandwidth1; // bandwidth of first tone (Hz)
unsigned short freq2; // freq of first tone (Hz)
unsigned short bandwidth2; // bandwidth of second tone (Hz)
short minlevel1; // min amp of 1st tone ref 0dBm0
short minlevel2; // min amp of 2nd tone ref 0dbm0
short twist; // allowable difference in tone powers
// If (E1/E2 < twist) AND (E2/E1 < twist) tone OK
short snr; // min signal to noise ratio to accept tone
unsigned short glitch; // short transitions of glitch ms ignored
VPB_STRAN stran[VPB_MS]; // cadence state transition table
} VPB_DETECT;
int WINAPI vpb_settonedet(int handle, VPB_DETECT *d);
int WINAPI vpb_gettonedet(int handle, int id, VPB_DETECT *d);
int WINAPI vpb_debug_tonedet(int handle, int id, char file_name[], int sec);
int WINAPI vpb_tonedet_make_default(VPB_DETECT *d);
/*-------------------------------------------------------------------------*\
TIMER
\*-------------------------------------------------------------------------*/
int WINAPI vpb_timer_open(void **timer, int handle, int id, unsigned long period);
int WINAPI vpb_timer_close(void *timer);
int WINAPI vpb_timer_start(void *timer);
int WINAPI vpb_timer_stop(void *timer);
int WINAPI vpb_timer_restart(void *timer);
int WINAPI vpb_timer_get_unique_timer_id();
int WINAPI vpb_timer_change_period(void *timer, unsigned long newperiod);
/*-------------------------------------------------------------------------*\
VOX
\*-------------------------------------------------------------------------*/
typedef struct {
float onlevel; // switch on level in dB (0 dB maximum)
float offlevel; // switch off level in dB (0 dB maximum)
unsigned short runon; // run on time in ms
} VPB_VOX;
int WINAPI vpb_setvox(int handle, VPB_VOX *vox);
int WINAPI vpb_getvox(int handle, VPB_VOX *vox);
/*-------------------------------------------------------------------------*\
AGC
\*-------------------------------------------------------------------------*/
typedef struct {
float setpoint; // desired signal level
float attack; // agc filter attack
float decay; // agc filter decay
} VPB_AGC;
int WINAPI vpb_setagc(int handle, VPB_AGC *agc);
int WINAPI vpb_getagc(int handle, VPB_AGC *agc);
/*-------------------------------------------------------------------------*\
ADPCM FUNCTIONS
\*-------------------------------------------------------------------------*/
int WINAPI vpb_adpcm_open(void **adpcm);
void WINAPI vpb_adpcm_close(void *adpcm);
int WINAPI vpb_adpcm_decode(void *adpcm,
short linearbuf[], unsigned short *nlinear,
char adpcmbuf[] , unsigned short nadpcmbytes);
/*-------------------------------------------------------------------------*\
WAVE FUNCTIONS
\*-------------------------------------------------------------------------*/
int WINAPI vpb_wave_open_write(void **ppv, char filename[], int mode);
int WINAPI vpb_wave_write(void *wv, char buf[], long n);
void WINAPI vpb_wave_close_write(void *wv);
int WINAPI vpb_wave_open_read(void **ppv, char filename[]);
int WINAPI vpb_wave_read(void *wv, char buf[], long n);
void WINAPI vpb_wave_close_read(void *wv);
void WINAPI vpb_wave_set_sample_rate(void *wv, unsigned short rate);
int WINAPI vpb_wave_seek(void *wv, long offset);
int WINAPI vpb_wave_get_mode(void *wv, unsigned short *mode);
/*-------------------------------------------------------------------------*\
RING FUNCTIONS
\*-------------------------------------------------------------------------*/
int WINAPI vpb_set_ring(int handle, unsigned int rings_to_fire, unsigned int time_out);
int WINAPI vpb_get_ring(int handle, unsigned int *rings_to_fire, unsigned int *time_out);
/*-------------------------------------------------------------------------*\
GET DIGIT FUNCTIONS
\*-------------------------------------------------------------------------*/
typedef struct {
char *term_digits; // string of digits to terminate collection
unsigned short max_digits; // terminate after this many digits collected
unsigned long digit_time_out; // max total time for digit collection (ms)
unsigned long inter_digit_time_out; // max time between digits (ms)
} VPB_DIGITS;
// terminate conditines passed in data field of VPB_EVENT when
// VPB_DIGIT event posted
#define VPB_DIGIT_TERM 0
#define VPB_DIGIT_MAX 1
#define VPB_DIGIT_TIME_OUT 2
#define VPB_DIGIT_INTER_DIGIT_TIME_OUT 3
#define VPB_DIGIT_BUFFER_FULL 4
int WINAPI vpb_flush_digits(int handle);
int WINAPI vpb_get_digits_async(int handle, VPB_DIGITS *digits, char *digbuf);
int WINAPI vpb_get_digits_sync(int handle, VPB_DIGITS *digits, char *digbuf);
int WINAPI get_digits_async(int handle, VPB_DIGITS *newdig, char *buf, unsigned short size);
int WINAPI get_digits_record_async(int handle, VPB_DIGITS *newdig, char *buf);
/*-------------------------------------------------------------------------*\
PIP FUNCTIONS
\*-------------------------------------------------------------------------*/
typedef struct {
unsigned int width; // width of pip pulse in ms
unsigned int period; // period between pip pulse in ms
} VPB_PIP;
int WINAPI vpb_set_pip(VPB_PIP *vpb_pip);
int WINAPI vpb_get_pip(VPB_PIP *vpb_pip);
int WINAPI vpb_pip_on(int handle);
int WINAPI vpb_pip_off(int handle);
#endif // #ifndef __VPBAPI__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -