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
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 #ifndef __OPAL_IXJLID_H
00252 #define __OPAL_IXJLID_H
00253
00254 #ifdef P_USE_PRAGMA
00255 #pragma interface
00256 #endif
00257
00258 #include "openh323buildopts.h"
00259
00260 #ifdef HAS_IXJ
00261
00262 #include "lid.h"
00263 #include "h323caps.h"
00264
00265
00266 #ifdef P_LINUX
00267 #include <linux/telephony.h>
00268 #include <linux/compiler.h>
00269 #include <linux/ixjuser.h>
00270 #endif
00271
00272 #ifdef P_FREEBSD
00273 #include <sys/telephony.h>
00274 #include <sys/ixjuser.h>
00275 #endif
00276
00277
00278
00280
00283 class OpalIxJDevice : public OpalLineInterfaceDevice
00284 {
00285 PCLASSINFO(OpalIxJDevice, OpalLineInterfaceDevice);
00286
00287 enum { MaxIxjDevices = 10 };
00288
00289 public:
00292 OpalIxJDevice();
00293
00297 ~OpalIxJDevice() { Close(); }
00298
00301 virtual BOOL Open(
00302 const PString & device
00303 );
00304
00307 virtual BOOL Close();
00308
00311 virtual PString GetName() const;
00312
00313
00314 enum {
00315 POTSLine,
00316 PSTNLine,
00317 NumLines
00318 };
00319
00322 virtual unsigned GetLineCount();
00323
00324
00327 virtual BOOL IsLineTerminal(
00328 unsigned line
00329 ) { return line == POTSLine; }
00330
00331
00334 virtual BOOL IsLinePresent(
00335 unsigned line,
00336 BOOL force = FALSE
00337 );
00338
00339
00344 virtual BOOL IsLineOffHook(
00345 unsigned line
00346 );
00347
00351 virtual BOOL SetLineOffHook(
00352 unsigned line,
00353 BOOL newState = TRUE
00354 );
00355
00356
00359 virtual BOOL IsLineRinging(
00360 unsigned line,
00361 DWORD * cadence = NULL
00362 );
00363
00367 virtual BOOL RingLine(
00368 unsigned line,
00369 DWORD cadence
00370 );
00371
00386 virtual BOOL RingLine(
00387 unsigned line,
00388 PINDEX nCadence,
00389 unsigned * pattern
00390 );
00391
00392
00395 virtual BOOL IsLineDisconnected(
00396 unsigned line,
00397 BOOL checkForWink = TRUE
00398 );
00399
00400
00403 BOOL SetLineToLineDirect(
00404 unsigned line1,
00405 unsigned line2,
00406 BOOL connect
00407 );
00408
00411 BOOL IsLineToLineDirect(
00412 unsigned line1,
00413 unsigned line2
00414 );
00415
00416
00419 virtual OpalMediaFormat::List GetMediaFormats() const;
00420
00423 virtual BOOL SetReadFormat(
00424 unsigned line,
00425 const OpalMediaFormat & mediaFormat
00426 );
00427
00430 virtual BOOL SetWriteFormat(
00431 unsigned line,
00432 const OpalMediaFormat & mediaFormat
00433 );
00434
00437 virtual OpalMediaFormat GetReadFormat(
00438 unsigned line
00439 );
00440
00443 virtual OpalMediaFormat GetWriteFormat(
00444 unsigned line
00445 );
00446
00457 virtual BOOL SetRawCodec(
00458 unsigned line
00459 );
00460
00463 virtual BOOL StopRawCodec(
00464 unsigned line
00465 );
00466
00469 virtual BOOL StopReadCodec(
00470 unsigned line
00471 );
00472
00475 virtual BOOL StopWriteCodec(
00476 unsigned line
00477 );
00478
00482 virtual PINDEX GetReadFrameSize(
00483 unsigned line
00484 );
00485
00486 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00487
00491 virtual PINDEX GetWriteFrameSize(
00492 unsigned line
00493 );
00494
00495 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00496
00499 virtual BOOL ReadFrame(
00500 unsigned line,
00501 void * buf,
00502 PINDEX & count
00503 );
00504
00507 virtual BOOL WriteFrame(
00508 unsigned line,
00509 const void * buf,
00510 PINDEX count,
00511 PINDEX & written
00512 );
00513
00516 virtual unsigned GetAverageSignalLevel(
00517 unsigned line,
00518 BOOL playback
00519 );
00520
00521
00524 virtual BOOL EnableAudio(
00525 unsigned line,
00526 BOOL enable = TRUE
00527 );
00528
00531 virtual BOOL IsAudioEnabled(
00532 unsigned line
00533 );
00534
00535
00540 virtual BOOL SetRecordVolume(
00541 unsigned line,
00542 unsigned volume
00543 );
00544
00549 virtual BOOL SetPlayVolume(
00550 unsigned line,
00551 unsigned volume
00552 );
00553
00558 virtual BOOL GetRecordVolume(
00559 unsigned line,
00560 unsigned & volume
00561 );
00562
00567 virtual BOOL GetPlayVolume(
00568 unsigned line,
00569 unsigned & volume
00570 );
00571
00574 AECLevels GetAEC(
00575 unsigned line
00576 );
00577
00580 BOOL SetAEC(
00581 unsigned line,
00582 AECLevels level
00583 );
00584
00588 unsigned GetWinkDuration(
00589 unsigned line
00590 );
00591
00595 BOOL SetWinkDuration(
00596 unsigned line,
00597 unsigned winkDuration
00598 );
00599
00603 virtual BOOL GetVAD(
00604 unsigned line
00605 );
00606
00610 virtual BOOL SetVAD(
00611 unsigned line,
00612 BOOL enable
00613 );
00614
00615
00623 virtual BOOL GetCallerID(
00624 unsigned line,
00625 PString & idString,
00626 BOOL full = FALSE
00627 );
00628
00637 virtual BOOL SetCallerID(
00638 unsigned line,
00639 const PString & idString
00640 );
00641
00644 virtual BOOL SendCallerIDOnCallWaiting(
00645 unsigned line,
00646 const PString & idString
00647 );
00648
00651 virtual BOOL SendVisualMessageWaitingIndicator(
00652 unsigned line,
00653 BOOL on
00654 );
00655
00656
00657
00661 virtual BOOL PlayDTMF(
00662 unsigned line,
00663 const char * digits,
00664 DWORD onTime = DefaultDTMFOnTime,
00665 DWORD offTime = DefaultDTMFOffTime
00666 );
00667
00673 virtual char ReadDTMF(
00674 unsigned line
00675 );
00676
00681 virtual BOOL GetRemoveDTMF(
00682 unsigned line
00683 );
00684
00689 virtual BOOL SetRemoveDTMF(
00690 unsigned line,
00691 BOOL removeTones
00692 );
00693
00694
00697 virtual unsigned IsToneDetected(
00698 unsigned line
00699 );
00700
00706 virtual BOOL SetToneFilterParameters(
00707 unsigned line,
00708 CallProgressTones tone,
00709 unsigned lowFrequency,
00710 unsigned highFrequency,
00711 PINDEX numCadences,
00712 const unsigned * onTimes,
00713 const unsigned * offTimes
00714 );
00715
00718 virtual BOOL PlayTone(
00719 unsigned line,
00720 CallProgressTones tone
00721 );
00722
00725 virtual BOOL IsTonePlaying(
00726 unsigned line
00727 );
00728
00731 virtual BOOL StopTone(
00732 unsigned line
00733 );
00734
00737 virtual BOOL HasHookFlash(unsigned line);
00738
00744 virtual BOOL SetCountryCode(
00745 T35CountryCodes country
00746 );
00747
00748
00751 virtual DWORD GetSerialNumber();
00752
00753 enum CardTypes {
00754 PhoneJACK = 1,
00755 LineJACK = 3,
00756 PhoneJACK_Lite,
00757 PhoneJACK_PCI,
00758 PhoneCARD,
00759 PhoneJACK_PCI_TJ
00760 };
00761
00764 DWORD GetCardType() const { return dwCardType; }
00765
00766
00769 static PStringArray GetDeviceNames();
00770
00771
00772 protected:
00773
00774 PINDEX LogScaleVolume(unsigned line, PINDEX volume, BOOL isPlay);
00775
00776 PString deviceName;
00777 DWORD dwCardType;
00778 PMutex readMutex, writeMutex;
00779 BOOL readStopped, writeStopped;
00780 PINDEX readFrameSize, writeFrameSize;
00781 PINDEX readCodecType, writeCodecType;
00782 BOOL lastHookState, currentHookState;
00783 PTimer hookTimeout;
00784 BOOL inRawMode;
00785 unsigned enabledAudioLine;
00786 BOOL exclusiveAudioMode;
00787
00788 #if defined(WIN32)
00789 BOOL InternalSetVolume(BOOL record, unsigned id, int volume, int mute);
00790 BOOL InternalPlayTone(unsigned line,
00791 DWORD toneIndex,
00792 DWORD onTime, DWORD offTime,
00793 BOOL synchronous);
00794 BOOL IoControl(DWORD dwIoControlCode,
00795 DWORD inParam = 0,
00796 DWORD * outParam = NULL);
00797 BOOL IoControl(DWORD dwIoControlCode,
00798 LPVOID lpInBuffer,
00799 DWORD nInBufferSize,
00800 LPVOID lpOutBuffer,
00801 DWORD nOutBufferSize,
00802 LPDWORD lpdwBytesReturned,
00803 PWin32Overlapped * overlap = NULL);
00804
00805 HANDLE hDriver;
00806 DWORD driverVersion;
00807 PTimer ringTimeout;
00808 DWORD lastDTMFDigit;
00809 DWORD lastFlashState;
00810 PTimeInterval toneSendCompletionTime;
00811 BOOL vadEnabled;
00812 HANDLE hReadEvent, hWriteEvent;
00813
00814 #elif defined(HAS_IXJ)
00815
00816 public:
00817 class ExceptionInfo {
00818 public:
00819 int fd;
00820
00821 BOOL hasRing;
00822 BOOL hookState;
00823 BOOL hasWink;
00824 BOOL hasFlash;
00825 char dtmf[16];
00826 int dtmfIn;
00827 int dtmfOut;
00828 #ifdef IXJCTL_VMWI
00829 BOOL hasCid;
00830 PHONE_CID cid;
00831 #endif
00832 BOOL filter[4];
00833 BOOL cadence[4];
00834 telephony_exception data;
00835 timeval lastHookChange;
00836 };
00837
00838 static void SignalHandler(int sig);
00839 ExceptionInfo * OpalIxJDevice::GetException();
00840 int GetOSHandle() { return os_handle; }
00841
00842 protected:
00843 BOOL ConvertOSError(int err);
00844
00845 static ExceptionInfo exceptionInfo[MaxIxjDevices];
00846 static PMutex exceptionMutex;
00847 static BOOL exceptionInit;
00848
00849 AECLevels aecLevel;
00850 BOOL removeDTMF;
00851 PMutex toneMutex;
00852 BOOL tonePlaying;
00853 PTimer lastRingTime;
00854 BOOL pstnIsOffHook;
00855 BOOL gotWink;
00856 int userPlayVol, userRecVol;
00857
00858 int savedPlayVol, savedRecVol;
00859 AECLevels savedAEC;
00860
00861 #ifdef IXJCTL_VMWI
00862 PHONE_CID callerIdInfo;
00863 #endif
00864
00865 #endif
00866 };
00867
00868
00869 #endif // HAS_IXJ
00870
00871 #endif // __OPAL_IXJLID_H
00872
00873