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 #ifndef __OPAL_VBLASTERLID_H
00085 #define __OPAL_VBLASTERLID_H
00086
00087 #ifdef P_USE_PRAGMA
00088 #pragma interface
00089 #endif
00090
00091
00092 #include <opal/buildopts.h>
00093
00094 #ifdef HAS_VBLASTER
00095
00096 #include <lids/lid.h>
00097 #include <ptclib/delaychan.h>
00098
00099
00100
00102
00103 class VoipBlasterInterface : public PObject
00104 {
00105 PCLASSINFO(VoipBlasterInterface, PObject)
00106 public:
00107 enum Command {
00108 Command_PHONE_OFF = 0x01,
00109 Command_PHONE_ON = 0x02,
00110 Command_RING_ON = 0x03,
00111 Command_RING_OFF = 0x04,
00112 Command_VOUT_START = 0x05,
00113 Command_VOUT_STOP = 0x06,
00114 Command_VINP_START = 0x07,
00115 Command_VINP_STOP = 0x08,
00116 Command_UNKNOWN_1 = 0x09,
00117 Command_UNKNOWN_2 = 0x0a,
00118 Command_UNKNOWN_3 = 0x0b,
00119 Command_HS_OFFHOOK = 0x0c,
00120 Command_HS_ONHOOK = 0x0d,
00121 Command_SETUP_MODE = 0x0e,
00122 Command_VOUT_DONE = 0x0f,
00123 Command_0x10 = 0x10,
00124 Command_0x11 = 0x11,
00125 Command_MUTE_ON = 0x12,
00126 Command_MUTE_OFF = 0x13,
00127 Command_VOL_0 = 0x34,
00128 Command_VOL_1 = 0x35,
00129 Command_VOL_2 = 0x36,
00130 Command_VOL_3 = 0x37,
00131 Command_VOL_4 = 0x38,
00132 Command_VOL_5 = 0x39,
00133 Command_VOL_6 = 0x3a,
00134 };
00135
00136 enum Status {
00137
00138 Status_HOOK_OFF = 0x01,
00139 Status_HOOK_ON = 0x02,
00140
00141
00142 Status_RINGING_ON = 0x05,
00143 Status_RINGING_OFF = 0x06,
00144 Status_HEADSET_IN = 0x08,
00145 Status_HEADSET_OUT = 0x09,
00146 Status_0x0a = 0x0a,
00147 Status_VOUT_DONE = 0x0c,
00148 Status_Empty
00149 };
00150
00151 VoipBlasterInterface();
00152
00153 BOOL IsDevicePresent(PINDEX deviceIndex);
00154
00155 BOOL OpenCommand(PINDEX deviceIndex);
00156 BOOL WriteCommand(Command cmd);
00157 Status ReadStatus(const PTimeInterval dur = 0);
00158 BOOL CloseCommand();
00159
00160 BOOL OpenData();
00161 BOOL WriteData(const void * data, PINDEX len);
00162 int ReadData (void * data, PINDEX len, const PTimeInterval dur = 0);
00163 void Flush(const PTimeInterval wait = 500);
00164 BOOL CloseData();
00165
00166 PDECLARE_NOTIFIER(PTimer, VoipBlasterInterface, CloseTimeout);
00167
00168 protected:
00169 PINDEX deviceIndex;
00170
00171
00172 #ifdef P_LINUX
00173 #endif
00174
00175
00176 #ifdef _WIN32
00177 enum Pipe {
00178 VoiceOutPipe = 0,
00179 VoiceInPipe = 1,
00180 CommandPipe = 2,
00181 StatusPipe = 3,
00182 NumPipes
00183 };
00184
00185 protected:
00186 int WritePipe(HANDLE fd, const void *bp, DWORD len);
00187 int ReadPipe (HANDLE fd, void *bp, DWORD len, const PTimeInterval dur = 0);
00188 BOOL OpenVOIPPipe(Pipe pipeIndex);
00189
00190 HANDLE pipes[4];
00191 #endif
00192 };
00193
00195
00198 class OpalVoipBlasterDevice : public OpalLineInterfaceDevice
00199 {
00200 PCLASSINFO(OpalVoipBlasterDevice, OpalLineInterfaceDevice);
00201
00202 public:
00203
00204 enum { DTMFQueueSize = 10 };
00205
00206 class ByteQueue : public PObject {
00207 PCLASSINFO(ByteQueue, PObject);
00208 public:
00209 ByteQueue(PINDEX size);
00210 int Dequeue();
00211 BOOL Enqueue(BYTE ch);
00212
00213 protected:
00214 PBYTEArray queue;
00215 PINDEX qLen, qOut, qMax;
00216 PMutex mutex;
00217 };
00218
00221 OpalVoipBlasterDevice();
00222
00226 ~OpalVoipBlasterDevice();
00227
00230 virtual BOOL Open(
00231 const PString & device
00232 );
00233
00236 virtual BOOL Close();
00237
00241 virtual PString GetDeviceType() const;
00242
00245 virtual PString GetDeviceName() const;
00246
00249 virtual PStringArray GetAllNames() const;
00250
00253 virtual PString GetDescription() const;
00254
00255
00258 virtual unsigned GetLineCount()
00259 { return 1; }
00260
00263 virtual BOOL IsLineTerminal(
00264 unsigned
00265 ) { return TRUE; }
00266
00267
00270 virtual BOOL IsLinePresent(
00271 unsigned ,
00272 BOOL = FALSE
00273 )
00274 { return FALSE; }
00275
00276
00281 virtual BOOL IsLineOffHook(
00282 unsigned line
00283 );
00284
00288 virtual BOOL SetLineOffHook(
00289 unsigned line,
00290 BOOL newState = TRUE
00291 );
00292
00293
00296 virtual BOOL IsLineRinging(
00297 unsigned line,
00298 DWORD * cadence = NULL
00299 );
00300
00304 virtual BOOL RingLine(
00305 unsigned line,
00306 DWORD cadence
00307 );
00308
00309
00312 virtual BOOL IsLineDisconnected(
00313 unsigned line,
00314 BOOL checkForWink = TRUE
00315 );
00316
00317
00320 BOOL SetLineToLineDirect(
00321 unsigned line1,
00322 unsigned line2,
00323 BOOL connect
00324 );
00325
00328 BOOL IsLineToLineDirect(
00329 unsigned line1,
00330 unsigned line2
00331 );
00332
00333
00336 virtual OpalMediaFormatList GetMediaFormats() const;
00337
00340 virtual BOOL SetReadFormat(
00341 unsigned line,
00342 const OpalMediaFormat & mediaFormat
00343 );
00344
00347 virtual BOOL SetWriteFormat(
00348 unsigned line,
00349 const OpalMediaFormat & mediaFormat
00350 );
00351
00354 virtual OpalMediaFormat GetReadFormat(
00355 unsigned line
00356 );
00357
00360 virtual OpalMediaFormat GetWriteFormat(
00361 unsigned line
00362 );
00363
00374 virtual BOOL SetRawCodec(
00375 unsigned line
00376 );
00377
00380 virtual BOOL StopRawCodec(
00381 unsigned line
00382 );
00383
00386 virtual BOOL StopReadCodec(
00387 unsigned line
00388 );
00389
00392 virtual BOOL StopWriteCodec(
00393 unsigned line
00394 );
00395
00399 virtual PINDEX GetReadFrameSize(
00400 unsigned line
00401 );
00402
00403 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00404
00408 virtual PINDEX GetWriteFrameSize(
00409 unsigned line
00410 );
00411
00412 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00413
00416 virtual BOOL ReadFrame(
00417 unsigned line,
00418 void * buf,
00419 PINDEX & count
00420 );
00421
00424 virtual BOOL WriteFrame(
00425 unsigned line,
00426 const void * buf,
00427 PINDEX count,
00428 PINDEX & written
00429 );
00430
00433 virtual unsigned GetAverageSignalLevel(
00434 unsigned line,
00435 BOOL playback
00436 );
00437
00438
00441 virtual BOOL EnableAudio(
00442 unsigned line,
00443 BOOL enable = TRUE
00444 );
00445
00446
00451 virtual BOOL SetRecordVolume(
00452 unsigned line,
00453 unsigned volume
00454 );
00455
00460 virtual BOOL SetPlayVolume(
00461 unsigned line,
00462 unsigned volume
00463 );
00464
00469 virtual BOOL GetRecordVolume(
00470 unsigned line,
00471 unsigned & volume
00472 );
00473
00478 virtual BOOL GetPlayVolume(
00479 unsigned line,
00480 unsigned & volume
00481 );
00482
00483
00486 AECLevels GetAEC(
00487 unsigned line
00488 );
00489
00492 BOOL SetAEC(
00493 unsigned line,
00494 AECLevels level
00495 );
00496
00497
00501 virtual BOOL GetVAD(
00502 unsigned line
00503 );
00504
00508 virtual BOOL SetVAD(
00509 unsigned line,
00510 BOOL enable
00511 );
00512
00513
00521 virtual BOOL GetCallerID(
00522 unsigned line,
00523 PString & idString,
00524 BOOL full = FALSE
00525 );
00526
00535 virtual BOOL SetCallerID(
00536 unsigned line,
00537 const PString & idString
00538 );
00539
00542 virtual BOOL SendCallerIDOnCallWaiting(
00543 unsigned line,
00544 const PString & idString
00545 );
00546
00549 virtual BOOL SendVisualMessageWaitingIndicator(
00550 unsigned line,
00551 BOOL on
00552 );
00553
00554
00555
00559 virtual BOOL PlayDTMF(
00560 unsigned line,
00561 const char * digits,
00562 DWORD onTime = DefaultDTMFOnTime,
00563 DWORD offTime = DefaultDTMFOffTime
00564 );
00565
00571 virtual char ReadDTMF(
00572 unsigned line
00573 );
00574
00579 virtual BOOL GetRemoveDTMF(
00580 unsigned line
00581 );
00582
00587 virtual BOOL SetRemoveDTMF(
00588 unsigned line,
00589 BOOL removeTones
00590 );
00591
00592
00595 virtual unsigned IsToneDetected(
00596 unsigned line
00597 );
00598
00601 virtual BOOL PlayTone(
00602 unsigned line,
00603 CallProgressTones tone
00604 );
00605
00608 virtual BOOL IsTonePlaying(
00609 unsigned line
00610 );
00611
00614 virtual BOOL StopTone(
00615 unsigned line
00616 );
00617
00620 virtual BOOL HasHookFlash(unsigned line);
00621
00627 virtual BOOL SetCountryCode(
00628 T35CountryCodes country
00629 );
00630
00631
00634 virtual DWORD GetSerialNumber();
00635
00638 static PStringArray GetDeviceNames();
00639
00643 PDECLARE_NOTIFIER(PThread, OpalVoipBlasterDevice, StatusHandler);
00644
00645 protected:
00646 void HandleStatus(int status);
00647
00648 PThread * statusThread;
00649 BOOL statusRunning;
00650 BOOL hookState;
00651 BOOL headset;
00652 BOOL ringOn;
00653 BOOL firstTime;
00654
00655 ByteQueue dtmfQueue;
00656
00657 PAdaptiveDelay writeDelay;
00658 PAdaptiveDelay readDelay;
00659
00660 PString deviceName;
00661 PMutex readMutex, writeMutex;
00662 BOOL readStopped, writeStopped;
00663 PINDEX readFrameSize, writeFrameSize;
00664 PINDEX readCodecType, writeCodecType;
00665 BOOL lastHookStatus;
00666
00667 PMutex vbMutex;
00668 VoipBlasterInterface vBlaster;
00669 };
00670
00671
00672 #define OPAL_VBLASTER_TYPE_NAME "VoIPBlaster"
00673 #define OPAL_REGISTER_VBLASTER() OPAL_REGISTER_LID(OpalVoipBlasterDevice, OPAL_VBLASTER_TYPE_NAME)
00674
00675 #else // HAS_VBLASTER
00676
00677 #define OPAL_REGISTER_VBLASTER()
00678
00679 #endif // HAS_VBLASTER
00680
00681 #endif // __OPAL_VBLASTERLID_H
00682
00683