00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef __VPBAPI__
00031 #define __VPBAPI__
00032
00033 #ifdef WIN32
00034 #define WINAPI __stdcall
00035 #else
00036 #define WINAPI
00037 #endif
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #define VPB_OK 0
00048 #define VPB_NO_EVENTS -1
00049 #define VPB_TIME_OUT -2
00050
00051
00052
00053 #define VPB_MAX_STR 256
00054
00055
00056
00057 #define VPB_ONHOOK 0
00058 #define VPB_OFFHOOK 1
00059
00060
00061
00062
00063
00064
00065
00066 int WINAPI vpb_open(unsigned int board, unsigned int channel);
00067 int WINAPI vpb_close(int handle);
00068 void WINAPI vpb_sleep(long time_ms);
00069 int WINAPI vpb_sethook_async(int handle, int hookstate);
00070 int WINAPI vpb_sethook_sync(int handle, int hookstate);
00071 int WINAPI vpb_get_model(char *s);
00072 int WINAPI vpb_reset_play_fifo_alarm(int handle);
00073 int WINAPI vpb_reset_record_fifo_alarm(int handle);
00074
00075
00076
00077
00078
00079
00080
00081 typedef struct {
00082 int type;
00083 int handle;
00084 int data;
00085 unsigned long data1;
00086 } VPB_EVENT;
00087
00088
00089
00090 #define VPB_RING 0
00091 #define VPB_DIGIT 1
00092 #define VPB_TONEDETECT 2
00093 #define VPB_TIMEREXP 3
00094 #define VPB_VOXON 4
00095 #define VPB_VOXOFF 5
00096 #define VPB_PLAY_UNDERFLOW 6
00097 #define VPB_RECORD_OVERFLOW 7
00098 #define VPB_DTMF 8
00099
00100
00101
00102 #define VPB_PLAYEND 100
00103 #define VPB_RECORDEND 101
00104 #define VPB_DIALEND 102
00105 #define VPB_TONE_DEBUG_END 103
00106 #define VPB_CALLEND 104
00107
00108
00109
00110 #define VPB_MRING (1<<VPB_RING)
00111 #define VPB_MDIGIT (1<<VPB_DIGIT)
00112 #define VPB_MDTMF (1<<VPB_DTMF)
00113 #define VPB_MTONEDETECT (1<<VPB_TONEDETECT)
00114 #define VPB_MTIMEREXP (1<<VPB_TIMEREXP)
00115 #define VPB_MVOXON (1<<VPB_VOXON)
00116 #define VPB_MVOXOFF (1<<VPB_VOXOFF)
00117 #define VPB_MPLAY_UNDERFLOW (1<<VPB_PLAY_UNDERFLOW)
00118 #define VPB_MRECORD_OVERFLOW (1<<VPB_RECORD_OVERFLOW)
00119
00120 int WINAPI vpb_enable_event(int handle, unsigned short mask);
00121 int WINAPI vpb_disable_event(int handle, unsigned short mask);
00122 int WINAPI vpb_get_event_mask(int handle);
00123 int WINAPI vpb_set_event_mask(int handle, unsigned short mask);
00124 int WINAPI vpb_get_event_async(VPB_EVENT *event);
00125 int WINAPI vpb_get_event_sync(VPB_EVENT *event, unsigned int time_out);
00126 int WINAPI vpb_get_event_ch_async(int handle, VPB_EVENT *e);
00127 int WINAPI vpb_get_event_ch_sync(int handle, VPB_EVENT *e, unsigned int time_out);
00128 int WINAPI vpb_put_event(VPB_EVENT *event);
00129 void WINAPI vpb_translate_event(VPB_EVENT *e, char s[]);
00130 int WINAPI vpb_set_event_callback(int handle, void (WINAPI *event_callback)(VPB_EVENT *e, void *context), void *context);
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140 #define VPB_FINISH 1
00141
00142
00143
00144 #define VPB_LINEAR 0 // 128 kbit/s 16 bit linear
00145 #define VPB_ALAW 1 // 64 kbit/s A-law companded
00146 #define VPB_MULAW 2 // 64 kbit/s mu-law companded
00147 #define VPB_OKIADPCM 3 // 32 kbit/s OKI ADPCM
00148 #define VPB_OKIADPCM24 4 // 24 kbit/s OKI ADPCM
00149
00150
00151
00152 typedef struct {
00153 char *term_digits;
00154 } VPB_PLAY;
00155
00156 typedef struct {
00157 char *term_digits;
00158 unsigned int time_out;
00159
00160 } VPB_RECORD;
00161
00162
00163
00164 int WINAPI vpb_play_file_sync(int handle, char file_name[]);
00165 int WINAPI vpb_play_file_async(int handle, char file_name[], int data);
00166 int WINAPI vpb_play_voxfile_sync(int handle, char file_name[],unsigned short mode);
00167 int WINAPI vpb_play_voxfile_async(int handle, char file_name[], unsigned short mode, int data);
00168
00169 int WINAPI vpb_play_buf_start(int handle, unsigned short mode);
00170 int WINAPI vpb_play_buf_sync(int handle, char *buf, unsigned short length);
00171 int WINAPI vpb_play_buf_finish(int handle);
00172 int WINAPI vpb_play_terminate(int handle);
00173 int WINAPI vpb_play_set(int handle, VPB_PLAY *vpb_play);
00174 int WINAPI vpb_play_set_gain(int handle, float gain);
00175 int WINAPI vpb_play_get_gain(int handle, float *gain);
00176
00177
00178
00179 int WINAPI vpb_record_file_sync(int handle, char file_name[], unsigned short mode);
00180 int WINAPI vpb_record_file_async(int handle, char file_name[], unsigned short mode);
00181 int WINAPI vpb_record_voxfile_sync(int handle, char file_name[], unsigned short mode);
00182 int WINAPI vpb_record_voxfile_async(int handle, char file_name[], unsigned short mode);
00183 int WINAPI vpb_record_buf_start(int handle, unsigned short mode);
00184 int WINAPI vpb_record_buf_sync(int handle, char *buf, unsigned short length);
00185 int WINAPI vpb_record_buf_finish(int handle);
00186 int WINAPI vpb_record_terminate(int handle);
00187 int WINAPI vpb_record_set(int handle, VPB_RECORD *vpb_record);
00188 int WINAPI vpb_record_set_gain(int handle, float gain);
00189 int WINAPI vpb_record_get_gain(int handle, float *gain);
00190 int WINAPI vpb_record_buf_async(int handle, unsigned short mode,char *mbuf,unsigned long size);
00191
00192
00193
00194
00195 #define VPB_RECORD_DIGIT 1 // terminated due to Digit String
00196 #define VPB_RECORD_TIMEOUT 2 // terminated due to record timeout
00197 #define VPB_RECORD_ENDOFDATA 3 // terminate due to end of data in buffer
00198 #define VPB_RECORD_MAXDIGIT 4 // terminate due to Maximum digits
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208 #define VPB_DEVELOPMENT 0 // API function error causes program abort
00209 #define VPB_ERROR_CODE 1 // API function error returns error code
00210 #define VPB_EXCEPTION 2 // API function error throw a exception
00211
00212
00213
00214 class VpbException {
00215 public:
00216 int code;
00217 char s[VPB_MAX_STR];
00218 char api_function[VPB_MAX_STR];
00219
00220 VpbException(int c, char trans[], char api_function[]);
00221 };
00222
00223 int WINAPI vpb_seterrormode(int mode);
00224 void WINAPI vpb_throw_exception(int c, char trans[], char api_function[]);
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 int WINAPI vpb_dial_sync(int handle, char *dialstr);
00235 int WINAPI vpb_dial_async(int handle, char *dialstr);
00236
00237
00238
00239 #define VPB_CALL_DISCONNECT 0
00240 #define VPB_CALL_DIALTONE 1
00241 #define VPB_CALL_RINGBACK 2
00242 #define VPB_CALL_BUSY 3
00243 #define VPB_CALL_GRUNT 4
00244
00245 typedef struct {
00246 unsigned int tone_id;
00247 unsigned int call_id;
00248 unsigned int terminate;
00249 } VPB_TONE_MAP;
00250
00251 #define VPB_MAX_TONE_MAP 10 // maximum number of entries in tone map
00252
00253
00254
00255 typedef struct {
00256 unsigned int dialtones;
00257 unsigned int dialtone_timeout;
00258 unsigned int ringback_timeout;
00259 unsigned int inter_ringback_timeout;
00260 unsigned int answer_timeout;
00261 VPB_TONE_MAP tone_map[VPB_MAX_TONE_MAP];
00262 } VPB_CALL;
00263
00264
00265
00266 int WINAPI vpb_get_call(int handle, VPB_CALL *vpb_call);
00267 int WINAPI vpb_set_call(int handle, VPB_CALL *vpb_call);
00268
00269
00270
00271 #define VPB_CALL_CONNECTED 0 // call connected successfully
00272 #define VPB_CALL_NO_DIAL_TONE 1 // dial tone time out
00273 #define VPB_CALL_NO_RING_BACK 2 // ring back time out
00274 #define VPB_CALL_BUSY 3 // busy tone
00275 #define VPB_CALL_NO_ANSWER 4 // no answer time out
00276 #define VPB_CALL_DISCONNECTED 5 // no answer time out
00277
00278
00279
00280 int WINAPI vpb_call_sync(int handle, char *dialstr);
00281 int WINAPI vpb_call_async(int handle, char *dialstr);
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291 typedef struct {
00292 unsigned short freq1;
00293 unsigned short freq2;
00294 unsigned short freq3;
00295 short level1;
00296 short level2;
00297 short level3;
00298 unsigned long ton;
00299 unsigned long toff;
00300 } VPB_TONE;
00301
00302 int WINAPI vpb_settone(char ident, VPB_TONE *vpb_tone);
00303 int WINAPI vpb_gettone(char ident, VPB_TONE *vpb_tone);
00304 int WINAPI vpb_playtone_async(int handle, VPB_TONE *vpb_tone);
00305 int WINAPI vpb_playtone_sync(int handle, VPB_TONE *vpb_tone);
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315 #define VPB_DIAL 0 // dial tone detected
00316 #define VPB_RINGBACK 1 // ringback detected
00317 #define VPB_BUSY 2 // busy tone detected
00318 #define VPB_GRUNT 3 // grunt detected
00319
00320 #define VPB_MD 10 // maximum number of tone detectors per device
00321 #define VPB_MS 10 // maximum number of states per cadence state mach
00322
00323
00324
00325 #define VPB_TIMER 0
00326 #define VPB_RISING 1
00327 #define VPB_FALLING 2
00328 #define VPB_DELAY 3
00329
00330 typedef struct {
00331 unsigned short type;
00332 unsigned short tfire;
00333 unsigned short tmin;
00334 unsigned short tmax;
00335 } VPB_STRAN;
00336
00337 typedef struct {
00338 unsigned short nstates;
00339 unsigned short tone_id;
00340 unsigned short ntones;
00341 unsigned short freq1;
00342 unsigned short bandwidth1;
00343 unsigned short freq2;
00344 unsigned short bandwidth2;
00345 short minlevel1;
00346 short minlevel2;
00347 short twist;
00348
00349 short snr;
00350 unsigned short glitch;
00351
00352 VPB_STRAN stran[VPB_MS];
00353 } VPB_DETECT;
00354
00355 int WINAPI vpb_settonedet(int handle, VPB_DETECT *d);
00356 int WINAPI vpb_gettonedet(int handle, int id, VPB_DETECT *d);
00357 int WINAPI vpb_debug_tonedet(int handle, int id, char file_name[], int sec);
00358 int WINAPI vpb_tonedet_make_default(VPB_DETECT *d);
00359
00360
00361
00362
00363
00364
00365
00366 int WINAPI vpb_timer_open(void **timer, int handle, int id, unsigned long period);
00367 int WINAPI vpb_timer_close(void *timer);
00368 int WINAPI vpb_timer_start(void *timer);
00369 int WINAPI vpb_timer_stop(void *timer);
00370 int WINAPI vpb_timer_restart(void *timer);
00371 int WINAPI vpb_timer_get_unique_timer_id();
00372 int WINAPI vpb_timer_change_period(void *timer, unsigned long newperiod);
00373
00374
00375
00376
00377
00378
00379
00380 typedef struct {
00381 float onlevel;
00382 float offlevel;
00383 unsigned short runon;
00384 } VPB_VOX;
00385
00386 int WINAPI vpb_setvox(int handle, VPB_VOX *vox);
00387 int WINAPI vpb_getvox(int handle, VPB_VOX *vox);
00388
00389
00390
00391
00392
00393
00394
00395 typedef struct {
00396 float setpoint;
00397 float attack;
00398 float decay;
00399 } VPB_AGC;
00400
00401 int WINAPI vpb_setagc(int handle, VPB_AGC *agc);
00402 int WINAPI vpb_getagc(int handle, VPB_AGC *agc);
00403
00404
00405
00406
00407
00408
00409
00410 int WINAPI vpb_adpcm_open(void **adpcm);
00411 void WINAPI vpb_adpcm_close(void *adpcm);
00412 int WINAPI vpb_adpcm_decode(void *adpcm,
00413 short linearbuf[], unsigned short *nlinear,
00414 char adpcmbuf[] , unsigned short nadpcmbytes);
00415
00416
00417
00418
00419
00420
00421
00422 int WINAPI vpb_wave_open_write(void **ppv, char filename[], int mode);
00423 int WINAPI vpb_wave_write(void *wv, char buf[], long n);
00424 void WINAPI vpb_wave_close_write(void *wv);
00425
00426 int WINAPI vpb_wave_open_read(void **ppv, char filename[]);
00427 int WINAPI vpb_wave_read(void *wv, char buf[], long n);
00428 void WINAPI vpb_wave_close_read(void *wv);
00429
00430 void WINAPI vpb_wave_set_sample_rate(void *wv, unsigned short rate);
00431 int WINAPI vpb_wave_seek(void *wv, long offset);
00432 int WINAPI vpb_wave_get_mode(void *wv, unsigned short *mode);
00433
00434
00435
00436
00437
00438
00439
00440 int WINAPI vpb_set_ring(int handle, unsigned int rings_to_fire, unsigned int time_out);
00441 int WINAPI vpb_get_ring(int handle, unsigned int *rings_to_fire, unsigned int *time_out);
00442
00443
00444
00445
00446
00447
00448
00449 typedef struct {
00450 char *term_digits;
00451 unsigned short max_digits;
00452 unsigned long digit_time_out;
00453 unsigned long inter_digit_time_out;
00454 } VPB_DIGITS;
00455
00456
00457
00458
00459 #define VPB_DIGIT_TERM 0
00460 #define VPB_DIGIT_MAX 1
00461 #define VPB_DIGIT_TIME_OUT 2
00462 #define VPB_DIGIT_INTER_DIGIT_TIME_OUT 3
00463 #define VPB_DIGIT_BUFFER_FULL 4
00464
00465 int WINAPI vpb_flush_digits(int handle);
00466 int WINAPI vpb_get_digits_async(int handle, VPB_DIGITS *digits, char *digbuf);
00467 int WINAPI vpb_get_digits_sync(int handle, VPB_DIGITS *digits, char *digbuf);
00468 int WINAPI get_digits_async(int handle, VPB_DIGITS *newdig, char *buf, unsigned short size);
00469 int WINAPI get_digits_record_async(int handle, VPB_DIGITS *newdig, char *buf);
00470
00471
00472
00473
00474
00475
00476
00477 typedef struct {
00478 unsigned int width;
00479 unsigned int period;
00480 } VPB_PIP;
00481
00482 int WINAPI vpb_set_pip(VPB_PIP *vpb_pip);
00483 int WINAPI vpb_get_pip(VPB_PIP *vpb_pip);
00484
00485 int WINAPI vpb_pip_on(int handle);
00486 int WINAPI vpb_pip_off(int handle);
00487
00488 #endif // #ifndef __VPBAPI__