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 #ifndef __OPAL_VBLASTERLID_H
00053 #define __OPAL_VBLASTERLID_H
00054
00055 #ifdef P_USE_PRAGMA
00056 #pragma interface
00057 #endif
00058
00059
00060 #define HAS_VBLASTER
00061
00062 #include "lid.h"
00063 #include "h323caps.h"
00064
00065 #include <ptclib/delaychan.h>
00066
00067
00068
00070
00071 class VoipBlasterInterface : public PObject
00072 {
00073 PCLASSINFO(VoipBlasterInterface, PObject)
00074 public:
00075 enum Command {
00076 Command_PHONE_OFF = 0x01,
00077 Command_PHONE_ON = 0x02,
00078 Command_RING_ON = 0x03,
00079 Command_RING_OFF = 0x04,
00080 Command_VOUT_START = 0x05,
00081 Command_VOUT_STOP = 0x06,
00082 Command_VINP_START = 0x07,
00083 Command_VINP_STOP = 0x08,
00084 Command_UNKNOWN_1 = 0x09,
00085 Command_UNKNOWN_2 = 0x0a,
00086 Command_UNKNOWN_3 = 0x0b,
00087 Command_HS_OFFHOOK = 0x0c,
00088 Command_HS_ONHOOK = 0x0d,
00089 Command_SETUP_MODE = 0x0e,
00090 Command_VOUT_DONE = 0x0f,
00091 Command_0x10 = 0x10,
00092 Command_0x11 = 0x11,
00093 Command_MUTE_ON = 0x12,
00094 Command_MUTE_OFF = 0x13,
00095 Command_VOL_0 = 0x34,
00096 Command_VOL_1 = 0x35,
00097 Command_VOL_2 = 0x36,
00098 Command_VOL_3 = 0x37,
00099 Command_VOL_4 = 0x38,
00100 Command_VOL_5 = 0x39,
00101 Command_VOL_6 = 0x3a,
00102 };
00103
00104 enum Status {
00105
00106 Status_HOOK_OFF = 0x01,
00107 Status_HOOK_ON = 0x02,
00108
00109
00110 Status_RINGING_ON = 0x05,
00111 Status_RINGING_OFF = 0x06,
00112 Status_HEADSET_IN = 0x08,
00113 Status_HEADSET_OUT = 0x09,
00114 Status_0x0a = 0x0a,
00115 Status_VOUT_DONE = 0x0c,
00116 Status_Empty
00117 };
00118
00119 VoipBlasterInterface();
00120
00121 BOOL IsDevicePresent(PINDEX deviceIndex);
00122
00123 BOOL OpenCommand(PINDEX deviceIndex);
00124 BOOL WriteCommand(Command cmd);
00125 Status ReadStatus(const PTimeInterval dur = 0);
00126 BOOL CloseCommand();
00127
00128 BOOL OpenData();
00129 BOOL WriteData(const void * data, PINDEX len);
00130 int ReadData (void * data, PINDEX len, const PTimeInterval dur = 0);
00131 void Flush(const PTimeInterval wait = 500);
00132 BOOL CloseData();
00133
00134 PDECLARE_NOTIFIER(PTimer, VoipBlasterInterface, CloseTimeout);
00135
00136 protected:
00137 PINDEX deviceIndex;
00138
00139
00140 #ifdef P_LINUX
00141 #endif
00142
00143
00144 #ifdef _WIN32
00145 enum Pipe {
00146 VoiceOutPipe = 0,
00147 VoiceInPipe = 1,
00148 CommandPipe = 2,
00149 StatusPipe = 3,
00150 NumPipes
00151 };
00152
00153 protected:
00154 int WritePipe(HANDLE fd, const void *bp, DWORD len);
00155 int ReadPipe (HANDLE fd, void *bp, DWORD len, const PTimeInterval dur = 0);
00156 BOOL OpenVOIPPipe(Pipe pipeIndex);
00157
00158 HANDLE pipes[4];
00159 #endif
00160 };
00161
00163
00166 class OpalVoipBlasterDevice : public OpalLineInterfaceDevice
00167 {
00168 PCLASSINFO(OpalVoipBlasterDevice, OpalLineInterfaceDevice);
00169
00170 public:
00171
00172 enum { DTMFQueueSize = 10 };
00173
00174 class ByteQueue : public PObject {
00175 PCLASSINFO(ByteQueue, PObject);
00176 public:
00177 ByteQueue(PINDEX size);
00178 int Dequeue();
00179 BOOL Enqueue(BYTE ch);
00180
00181 protected:
00182 PBYTEArray queue;
00183 PINDEX qLen, qOut, qMax;
00184 PMutex mutex;
00185 };
00186
00189 OpalVoipBlasterDevice();
00190
00194 ~OpalVoipBlasterDevice();
00195
00198 virtual BOOL Open(
00199 const PString & device
00200 );
00201
00204 virtual BOOL Close();
00205
00208 virtual PString GetName() const;
00209
00212 virtual unsigned GetLineCount()
00213 { return 1; }
00214
00217 virtual BOOL IsLineTerminal(
00218 unsigned
00219 ) { return TRUE; }
00220
00221
00224 virtual BOOL IsLinePresent(
00225 unsigned ,
00226 BOOL = FALSE
00227 )
00228 { return FALSE; }
00229
00230
00235 virtual BOOL IsLineOffHook(
00236 unsigned line
00237 );
00238
00242 virtual BOOL SetLineOffHook(
00243 unsigned line,
00244 BOOL newState = TRUE
00245 );
00246
00247
00250 virtual BOOL IsLineRinging(
00251 unsigned line,
00252 DWORD * cadence = NULL
00253 );
00254
00258 virtual BOOL RingLine(
00259 unsigned line,
00260 DWORD cadence
00261 );
00262
00263
00266 virtual BOOL IsLineDisconnected(
00267 unsigned line,
00268 BOOL checkForWink = TRUE
00269 );
00270
00271
00274 BOOL SetLineToLineDirect(
00275 unsigned line1,
00276 unsigned line2,
00277 BOOL connect
00278 );
00279
00282 BOOL IsLineToLineDirect(
00283 unsigned line1,
00284 unsigned line2
00285 );
00286
00287
00290 virtual OpalMediaFormat::List GetMediaFormats() const;
00291
00294 virtual BOOL SetReadFormat(
00295 unsigned line,
00296 const OpalMediaFormat & mediaFormat
00297 );
00298
00301 virtual BOOL SetWriteFormat(
00302 unsigned line,
00303 const OpalMediaFormat & mediaFormat
00304 );
00305
00308 virtual OpalMediaFormat GetReadFormat(
00309 unsigned line
00310 );
00311
00314 virtual OpalMediaFormat GetWriteFormat(
00315 unsigned line
00316 );
00317
00328 virtual BOOL SetRawCodec(
00329 unsigned line
00330 );
00331
00334 virtual BOOL StopRawCodec(
00335 unsigned line
00336 );
00337
00340 virtual BOOL StopReadCodec(
00341 unsigned line
00342 );
00343
00346 virtual BOOL StopWriteCodec(
00347 unsigned line
00348 );
00349
00353 virtual PINDEX GetReadFrameSize(
00354 unsigned line
00355 );
00356
00357 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00358
00362 virtual PINDEX GetWriteFrameSize(
00363 unsigned line
00364 );
00365
00366 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00367
00370 virtual BOOL ReadFrame(
00371 unsigned line,
00372 void * buf,
00373 PINDEX & count
00374 );
00375
00378 virtual BOOL WriteFrame(
00379 unsigned line,
00380 const void * buf,
00381 PINDEX count,
00382 PINDEX & written
00383 );
00384
00387 virtual unsigned GetAverageSignalLevel(
00388 unsigned line,
00389 BOOL playback
00390 );
00391
00392
00395 virtual BOOL EnableAudio(
00396 unsigned line,
00397 BOOL enable = TRUE
00398 );
00399
00400
00405 virtual BOOL SetRecordVolume(
00406 unsigned line,
00407 unsigned volume
00408 );
00409
00414 virtual BOOL SetPlayVolume(
00415 unsigned line,
00416 unsigned volume
00417 );
00418
00423 virtual BOOL GetRecordVolume(
00424 unsigned line,
00425 unsigned & volume
00426 );
00427
00432 virtual BOOL GetPlayVolume(
00433 unsigned line,
00434 unsigned & volume
00435 );
00436
00437
00440 AECLevels GetAEC(
00441 unsigned line
00442 );
00443
00446 BOOL SetAEC(
00447 unsigned line,
00448 AECLevels level
00449 );
00450
00451
00455 virtual BOOL GetVAD(
00456 unsigned line
00457 );
00458
00462 virtual BOOL SetVAD(
00463 unsigned line,
00464 BOOL enable
00465 );
00466
00467
00475 virtual BOOL GetCallerID(
00476 unsigned line,
00477 PString & idString,
00478 BOOL full = FALSE
00479 );
00480
00489 virtual BOOL SetCallerID(
00490 unsigned line,
00491 const PString & idString
00492 );
00493
00496 virtual BOOL SendCallerIDOnCallWaiting(
00497 unsigned line,
00498 const PString & idString
00499 );
00500
00503 virtual BOOL SendVisualMessageWaitingIndicator(
00504 unsigned line,
00505 BOOL on
00506 );
00507
00508
00509
00513 virtual BOOL PlayDTMF(
00514 unsigned line,
00515 const char * digits,
00516 DWORD onTime = DefaultDTMFOnTime,
00517 DWORD offTime = DefaultDTMFOffTime
00518 );
00519
00525 virtual char ReadDTMF(
00526 unsigned line
00527 );
00528
00533 virtual BOOL GetRemoveDTMF(
00534 unsigned line
00535 );
00536
00541 virtual BOOL SetRemoveDTMF(
00542 unsigned line,
00543 BOOL removeTones
00544 );
00545
00546
00549 virtual unsigned IsToneDetected(
00550 unsigned line
00551 );
00552
00555 virtual BOOL PlayTone(
00556 unsigned line,
00557 CallProgressTones tone
00558 );
00559
00562 virtual BOOL IsTonePlaying(
00563 unsigned line
00564 );
00565
00568 virtual BOOL StopTone(
00569 unsigned line
00570 );
00571
00574 virtual BOOL HasHookFlash(unsigned line);
00575
00581 virtual BOOL SetCountryCode(
00582 T35CountryCodes country
00583 );
00584
00585
00588 virtual DWORD GetSerialNumber();
00589
00592 static PStringArray GetDeviceNames();
00593
00597 PDECLARE_NOTIFIER(PThread, OpalVoipBlasterDevice, StatusHandler);
00598
00599 protected:
00600 void HandleStatus(int status);
00601
00602 PThread * statusThread;
00603 BOOL statusRunning;
00604 BOOL hookState;
00605 BOOL headset;
00606 BOOL ringOn;
00607 BOOL firstTime;
00608
00609 ByteQueue dtmfQueue;
00610
00611 PAdaptiveDelay writeDelay;
00612 PAdaptiveDelay readDelay;
00613
00614 PString deviceName;
00615 PMutex readMutex, writeMutex;
00616 BOOL readStopped, writeStopped;
00617 PINDEX readFrameSize, writeFrameSize;
00618 PINDEX readCodecType, writeCodecType;
00619 BOOL lastHookStatus;
00620
00621 PMutex vbMutex;
00622 VoipBlasterInterface vBlaster;
00623 };
00624
00625
00626 #endif // __OPAL_VBLASTERLID_H
00627
00628