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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 #ifndef __OPAL_VPBLID_H
00117 #define __OPAL_VPBLID_H
00118
00119 #ifdef P_USE_PRAGMA
00120 #pragma interface
00121 #endif
00122
00123
00124 #include <opal/buildopts.h>
00125
00126 #ifdef HAS_VPB
00127
00128 #include <lids/lid.h>
00129 #include <vpbapi.h>
00130
00131
00133
00134
00135
00136 class ToneThread : public PThread
00137 {
00138 PCLASSINFO(PThread, ToneThread);
00139
00140 public:
00141 ToneThread(int handle, VPB_TONE tone);
00142 ~ToneThread();
00143 void Main();
00144
00145 private:
00146 int handle;
00147 VPB_TONE vpbtone;
00148 PSyncPoint shutdown;
00149 };
00150
00151
00153
00156 class OpalVpbDevice : public OpalLineInterfaceDevice
00157 {
00158 PCLASSINFO(OpalVpbDevice, OpalLineInterfaceDevice);
00159
00160 public:
00163 OpalVpbDevice();
00164
00168 ~OpalVpbDevice() { Close(); }
00169
00172 virtual BOOL Open(
00173 const PString & device
00174 );
00175
00178 virtual BOOL Close();
00179
00183 virtual PString GetDeviceType() const;
00184
00187 virtual PString GetDeviceName() const;
00188
00191 virtual PStringArray GetAllNames() const;
00192
00195 virtual PString GetDescription() const;
00196
00197
00200 virtual unsigned GetLineCount();
00201
00206 virtual BOOL IsLineOffHook(
00207 unsigned line
00208 );
00209
00213 virtual BOOL SetLineOffHook(
00214 unsigned line,
00215 BOOL newState = TRUE
00216 );
00217
00218
00221 virtual BOOL IsLineRinging(
00222 unsigned line,
00223 DWORD * cadence = NULL
00224 );
00225
00229 virtual BOOL IsLineDisconnected(
00230 unsigned line,
00231 BOOL checkForWink = TRUE
00232 );
00233
00236 virtual OpalMediaFormatList GetMediaFormats() const;
00237
00240 virtual BOOL SetReadFormat(
00241 unsigned line,
00242 const OpalMediaFormat & mediaFormat
00243 );
00244
00247 virtual BOOL SetWriteFormat(
00248 unsigned line,
00249 const OpalMediaFormat & mediaFormat
00250 );
00251
00254 virtual OpalMediaFormat GetReadFormat(
00255 unsigned line
00256 );
00257
00260 virtual OpalMediaFormat GetWriteFormat(
00261 unsigned line
00262 );
00263
00266 virtual BOOL StopReadCodec(
00267 unsigned line
00268 );
00269
00272 virtual BOOL StopWriteCodec(
00273 unsigned line
00274 );
00275
00280 virtual BOOL SetReadFrameSize(
00281 unsigned line,
00282 PINDEX frameSize
00283 );
00284
00289 virtual BOOL SetWriteFrameSize(
00290 unsigned line,
00291 PINDEX frameSize
00292 );
00293
00297 virtual PINDEX GetReadFrameSize(
00298 unsigned line
00299 );
00300
00304 virtual PINDEX GetWriteFrameSize(
00305 unsigned line
00306 );
00307
00310 virtual BOOL ReadFrame(
00311 unsigned line,
00312 void * buf,
00313 PINDEX & count
00314 );
00315
00318 virtual BOOL WriteFrame(
00319 unsigned line,
00320 const void * buf,
00321 PINDEX count,
00322 PINDEX & written
00323 );
00324
00325
00330 virtual BOOL SetRecordVolume(
00331 unsigned line,
00332 unsigned volume
00333 );
00334
00339 virtual BOOL SetPlayVolume(
00340 unsigned line,
00341 unsigned volume
00342 );
00343
00346 int GetOSHandle(
00347 unsigned line
00348 );
00349
00355 virtual char ReadDTMF(
00356 unsigned line
00357 );
00358
00362 virtual BOOL PlayDTMF(
00363 unsigned line,
00364 const char * digits,
00365 DWORD onTime = 90,
00366 DWORD offTime = 30
00367 );
00368
00369
00372 virtual unsigned IsToneDetected(
00373 unsigned line
00374 );
00375
00376 virtual BOOL PlayTone(
00377 unsigned line,
00378 CallProgressTones tone
00379 );
00380
00381 virtual BOOL StopTone(
00382 unsigned line
00383 );
00384
00385 virtual BOOL PlayAudio(
00386 unsigned line,
00387 const PString & filename
00388 );
00389
00390 virtual BOOL StopAudio(
00391 unsigned line
00392 );
00393
00394 protected:
00395 unsigned cardNumber;
00396 unsigned lineCount;
00397
00398 enum { MaxLineCount = 8 };
00399
00400 struct LineState {
00401 BOOL Open(unsigned cardNumber, unsigned lineNumber);
00402 BOOL SetLineOffHook(BOOL newState);
00403 BOOL IsLineRinging(DWORD *);
00404
00405 int handle;
00406 BOOL currentHookState;
00407 PINDEX readFormat, writeFormat;
00408 PINDEX readFrameSize, writeFrameSize;
00409 BOOL readIdle, writeIdle;
00410 PMutex DTMFmutex;
00411 BOOL DTMFplaying;
00412 ToneThread *myToneThread;
00413 } lineState[MaxLineCount];
00414 };
00415
00416
00417 #define OPAL_VPB_TYPE_NAME "VPB"
00418 #define OPAL_REGISTER_VPB() OPAL_REGISTER_LID(OpalVpbDevice, OPAL_VPB_TYPE_NAME)
00419
00420 #else // HAS_VPB
00421
00422 #define OPAL_REGISTER_VPB()
00423
00424 #endif // HAS_VPB
00425
00426 #endif // __OPAL_VPBLID_H
00427
00428