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 #ifndef __OPAL_VBLASTERLID_H
00056 #define __OPAL_VBLASTERLID_H
00057
00058 #ifdef P_USE_PRAGMA
00059 #pragma interface
00060 #endif
00061
00062
00063 #define HAS_VBLASTER
00064
00065 #include "lid.h"
00066 #include "h323caps.h"
00067
00068 #include <ptclib/delaychan.h>
00069
00070
00071
00073
00074 class VoipBlasterInterface : public PObject
00075 {
00076 PCLASSINFO(VoipBlasterInterface, PObject)
00077 public:
00078 enum Command {
00079 Command_PHONE_OFF = 0x01,
00080 Command_PHONE_ON = 0x02,
00081 Command_RING_ON = 0x03,
00082 Command_RING_OFF = 0x04,
00083 Command_VOUT_START = 0x05,
00084 Command_VOUT_STOP = 0x06,
00085 Command_VINP_START = 0x07,
00086 Command_VINP_STOP = 0x08,
00087 Command_UNKNOWN_1 = 0x09,
00088 Command_UNKNOWN_2 = 0x0a,
00089 Command_UNKNOWN_3 = 0x0b,
00090 Command_HS_OFFHOOK = 0x0c,
00091 Command_HS_ONHOOK = 0x0d,
00092 Command_SETUP_MODE = 0x0e,
00093 Command_VOUT_DONE = 0x0f,
00094 Command_0x10 = 0x10,
00095 Command_0x11 = 0x11,
00096 Command_MUTE_ON = 0x12,
00097 Command_MUTE_OFF = 0x13,
00098 Command_VOL_0 = 0x34,
00099 Command_VOL_1 = 0x35,
00100 Command_VOL_2 = 0x36,
00101 Command_VOL_3 = 0x37,
00102 Command_VOL_4 = 0x38,
00103 Command_VOL_5 = 0x39,
00104 Command_VOL_6 = 0x3a,
00105 };
00106
00107 enum Status {
00108
00109 Status_HOOK_OFF = 0x01,
00110 Status_HOOK_ON = 0x02,
00111
00112
00113 Status_RINGING_ON = 0x05,
00114 Status_RINGING_OFF = 0x06,
00115 Status_HEADSET_IN = 0x08,
00116 Status_HEADSET_OUT = 0x09,
00117 Status_0x0a = 0x0a,
00118 Status_VOUT_DONE = 0x0c,
00119 Status_Empty
00120 };
00121
00122 VoipBlasterInterface();
00123
00124 BOOL IsDevicePresent(PINDEX deviceIndex);
00125
00126 BOOL OpenCommand(PINDEX deviceIndex);
00127 BOOL WriteCommand(Command cmd);
00128 Status ReadStatus(const PTimeInterval dur = 0);
00129 BOOL CloseCommand();
00130
00131 BOOL OpenData();
00132 BOOL WriteData(const void * data, PINDEX len);
00133 int ReadData (void * data, PINDEX len, const PTimeInterval dur = 0);
00134 void Flush(const PTimeInterval wait = 500);
00135 BOOL CloseData();
00136
00137 PDECLARE_NOTIFIER(PTimer, VoipBlasterInterface, CloseTimeout);
00138
00139 protected:
00140 PINDEX deviceIndex;
00141
00142
00143 #ifdef P_LINUX
00144 #endif
00145
00146
00147 #ifdef _WIN32
00148 enum Pipe {
00149 VoiceOutPipe = 0,
00150 VoiceInPipe = 1,
00151 CommandPipe = 2,
00152 StatusPipe = 3,
00153 NumPipes
00154 };
00155
00156 protected:
00157 int WritePipe(HANDLE fd, const void *bp, DWORD len);
00158 int ReadPipe (HANDLE fd, void *bp, DWORD len, const PTimeInterval dur = 0);
00159 BOOL OpenVOIPPipe(Pipe pipeIndex);
00160
00161 HANDLE pipes[4];
00162 #endif
00163 };
00164
00166
00169 class OpalVoipBlasterDevice : public OpalLineInterfaceDevice
00170 {
00171 PCLASSINFO(OpalVoipBlasterDevice, OpalLineInterfaceDevice);
00172
00173 public:
00174
00175 enum { DTMFQueueSize = 10 };
00176
00177 class ByteQueue : public PObject {
00178 PCLASSINFO(ByteQueue, PObject);
00179 public:
00180 ByteQueue(PINDEX size);
00181 int Dequeue();
00182 BOOL Enqueue(BYTE ch);
00183
00184 protected:
00185 PBYTEArray queue;
00186 PINDEX qLen, qOut, qMax;
00187 PMutex mutex;
00188 };
00189
00192 OpalVoipBlasterDevice();
00193
00197 ~OpalVoipBlasterDevice();
00198
00201 virtual BOOL Open(
00202 const PString & device
00203 );
00204
00207 virtual BOOL Close();
00208
00211 virtual PString GetName() const;
00212
00215 virtual unsigned GetLineCount()
00216 { return 1; }
00217
00220 virtual BOOL IsLineTerminal(
00221 unsigned
00222 ) { return TRUE; }
00223
00224
00227 virtual BOOL IsLinePresent(
00228 unsigned ,
00229 BOOL = FALSE
00230 )
00231 { return FALSE; }
00232
00233
00238 virtual BOOL IsLineOffHook(
00239 unsigned line
00240 );
00241
00245 virtual BOOL SetLineOffHook(
00246 unsigned line,
00247 BOOL newState = TRUE
00248 );
00249
00250
00253 virtual BOOL IsLineRinging(
00254 unsigned line,
00255 DWORD * cadence = NULL
00256 );
00257
00261 virtual BOOL RingLine(
00262 unsigned line,
00263 DWORD cadence
00264 );
00265
00266
00269 virtual BOOL IsLineDisconnected(
00270 unsigned line,
00271 BOOL checkForWink = TRUE
00272 );
00273
00274
00277 BOOL SetLineToLineDirect(
00278 unsigned line1,
00279 unsigned line2,
00280 BOOL connect
00281 );
00282
00285 BOOL IsLineToLineDirect(
00286 unsigned line1,
00287 unsigned line2
00288 );
00289
00290
00293 virtual OpalMediaFormat::List GetMediaFormats() const;
00294
00297 virtual BOOL SetReadFormat(
00298 unsigned line,
00299 const OpalMediaFormat & mediaFormat
00300 );
00301
00304 virtual BOOL SetWriteFormat(
00305 unsigned line,
00306 const OpalMediaFormat & mediaFormat
00307 );
00308
00311 virtual OpalMediaFormat GetReadFormat(
00312 unsigned line
00313 );
00314
00317 virtual OpalMediaFormat GetWriteFormat(
00318 unsigned line
00319 );
00320
00331 virtual BOOL SetRawCodec(
00332 unsigned line
00333 );
00334
00337 virtual BOOL StopRawCodec(
00338 unsigned line
00339 );
00340
00343 virtual BOOL StopReadCodec(
00344 unsigned line
00345 );
00346
00349 virtual BOOL StopWriteCodec(
00350 unsigned line
00351 );
00352
00356 virtual PINDEX GetReadFrameSize(
00357 unsigned line
00358 );
00359
00360 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00361
00365 virtual PINDEX GetWriteFrameSize(
00366 unsigned line
00367 );
00368
00369 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00370
00373 virtual BOOL ReadFrame(
00374 unsigned line,
00375 void * buf,
00376 PINDEX & count
00377 );
00378
00381 virtual BOOL WriteFrame(
00382 unsigned line,
00383 const void * buf,
00384 PINDEX count,
00385 PINDEX & written
00386 );
00387
00390 virtual unsigned GetAverageSignalLevel(
00391 unsigned line,
00392 BOOL playback
00393 );
00394
00395
00398 virtual BOOL EnableAudio(
00399 unsigned line,
00400 BOOL enable = TRUE
00401 );
00402
00403
00408 virtual BOOL SetRecordVolume(
00409 unsigned line,
00410 unsigned volume
00411 );
00412
00417 virtual BOOL SetPlayVolume(
00418 unsigned line,
00419 unsigned volume
00420 );
00421
00426 virtual BOOL GetRecordVolume(
00427 unsigned line,
00428 unsigned & volume
00429 );
00430
00435 virtual BOOL GetPlayVolume(
00436 unsigned line,
00437 unsigned & volume
00438 );
00439
00440
00443 AECLevels GetAEC(
00444 unsigned line
00445 );
00446
00449 BOOL SetAEC(
00450 unsigned line,
00451 AECLevels level
00452 );
00453
00454
00458 virtual BOOL GetVAD(
00459 unsigned line
00460 );
00461
00465 virtual BOOL SetVAD(
00466 unsigned line,
00467 BOOL enable
00468 );
00469
00470
00478 virtual BOOL GetCallerID(
00479 unsigned line,
00480 PString & idString,
00481 BOOL full = FALSE
00482 );
00483
00492 virtual BOOL SetCallerID(
00493 unsigned line,
00494 const PString & idString
00495 );
00496
00499 virtual BOOL SendCallerIDOnCallWaiting(
00500 unsigned line,
00501 const PString & idString
00502 );
00503
00506 virtual BOOL SendVisualMessageWaitingIndicator(
00507 unsigned line,
00508 BOOL on
00509 );
00510
00511
00512
00516 virtual BOOL PlayDTMF(
00517 unsigned line,
00518 const char * digits,
00519 DWORD onTime = DefaultDTMFOnTime,
00520 DWORD offTime = DefaultDTMFOffTime
00521 );
00522
00528 virtual char ReadDTMF(
00529 unsigned line
00530 );
00531
00536 virtual BOOL GetRemoveDTMF(
00537 unsigned line
00538 );
00539
00544 virtual BOOL SetRemoveDTMF(
00545 unsigned line,
00546 BOOL removeTones
00547 );
00548
00549
00552 virtual unsigned IsToneDetected(
00553 unsigned line
00554 );
00555
00558 virtual BOOL PlayTone(
00559 unsigned line,
00560 CallProgressTones tone
00561 );
00562
00565 virtual BOOL IsTonePlaying(
00566 unsigned line
00567 );
00568
00571 virtual BOOL StopTone(
00572 unsigned line
00573 );
00574
00577 virtual BOOL HasHookFlash(unsigned line);
00578
00584 virtual BOOL SetCountryCode(
00585 T35CountryCodes country
00586 );
00587
00588
00591 virtual DWORD GetSerialNumber();
00592
00595 static PStringArray GetDeviceNames();
00596
00600 PDECLARE_NOTIFIER(PThread, OpalVoipBlasterDevice, StatusHandler);
00601
00602 protected:
00603 void HandleStatus(int status);
00604
00605 PThread * statusThread;
00606 BOOL statusRunning;
00607 BOOL hookState;
00608 BOOL headset;
00609 BOOL ringOn;
00610 BOOL firstTime;
00611
00612 ByteQueue dtmfQueue;
00613
00614 PAdaptiveDelay writeDelay;
00615 PAdaptiveDelay readDelay;
00616
00617 PString deviceName;
00618 PMutex readMutex, writeMutex;
00619 BOOL readStopped, writeStopped;
00620 PINDEX readFrameSize, writeFrameSize;
00621 PINDEX readCodecType, writeCodecType;
00622 BOOL lastHookStatus;
00623
00624 PMutex vbMutex;
00625 VoipBlasterInterface vBlaster;
00626 };
00627
00628
00629 #endif // __OPAL_VBLASTERLID_H
00630
00631