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
00252
00253
00254
00255
00256
00257
00258
00259
00260 #ifndef __OPAL_IXJLID_H
00261 #define __OPAL_IXJLID_H
00262
00263 #ifdef P_USE_PRAGMA
00264 #pragma interface
00265 #endif
00266
00267 #include "openh323buildopts.h"
00268
00269 #ifdef HAS_IXJ
00270
00271 #include "lid.h"
00272 #include "h323caps.h"
00273
00274
00275 #ifdef P_LINUX
00276 #include <linux/telephony.h>
00277 #include <linux/ixjuser.h>
00278 #endif
00279
00280 #ifdef P_FREEBSD
00281 #include <sys/telephony.h>
00282 #include <sys/ixjuser.h>
00283 #endif
00284
00285
00286
00288
00291 class OpalIxJDevice : public OpalLineInterfaceDevice
00292 {
00293 PCLASSINFO(OpalIxJDevice, OpalLineInterfaceDevice);
00294
00295 enum { MaxIxjDevices = 10 };
00296
00297 public:
00300 OpalIxJDevice();
00301
00305 ~OpalIxJDevice() { Close(); }
00306
00309 virtual BOOL Open(
00310 const PString & device
00311 );
00312
00315 virtual BOOL Close();
00316
00319 virtual PString GetName() const;
00320
00321
00322 enum {
00323 POTSLine,
00324 PSTNLine,
00325 NumLines
00326 };
00327
00330 virtual unsigned GetLineCount();
00331
00332
00335 virtual BOOL IsLineTerminal(
00336 unsigned line
00337 ) { return line == POTSLine; }
00338
00339
00342 virtual BOOL IsLinePresent(
00343 unsigned line,
00344 BOOL force = FALSE
00345 );
00346
00347
00352 virtual BOOL IsLineOffHook(
00353 unsigned line
00354 );
00355
00359 virtual BOOL SetLineOffHook(
00360 unsigned line,
00361 BOOL newState = TRUE
00362 );
00363
00364
00367 virtual BOOL IsLineRinging(
00368 unsigned line,
00369 DWORD * cadence = NULL
00370 );
00371
00375 virtual BOOL RingLine(
00376 unsigned line,
00377 DWORD cadence
00378 );
00379
00394 virtual BOOL RingLine(
00395 unsigned line,
00396 PINDEX nCadence,
00397 unsigned * pattern
00398 );
00399
00400
00403 virtual BOOL IsLineDisconnected(
00404 unsigned line,
00405 BOOL checkForWink = TRUE
00406 );
00407
00408
00411 BOOL SetLineToLineDirect(
00412 unsigned line1,
00413 unsigned line2,
00414 BOOL connect
00415 );
00416
00419 BOOL IsLineToLineDirect(
00420 unsigned line1,
00421 unsigned line2
00422 );
00423
00424
00427 virtual OpalMediaFormat::List GetMediaFormats() const;
00428
00431 virtual BOOL SetReadFormat(
00432 unsigned line,
00433 const OpalMediaFormat & mediaFormat
00434 );
00435
00438 virtual BOOL SetWriteFormat(
00439 unsigned line,
00440 const OpalMediaFormat & mediaFormat
00441 );
00442
00445 virtual OpalMediaFormat GetReadFormat(
00446 unsigned line
00447 );
00448
00451 virtual OpalMediaFormat GetWriteFormat(
00452 unsigned line
00453 );
00454
00465 virtual BOOL SetRawCodec(
00466 unsigned line
00467 );
00468
00471 virtual BOOL StopRawCodec(
00472 unsigned line
00473 );
00474
00477 virtual BOOL StopReadCodec(
00478 unsigned line
00479 );
00480
00483 virtual BOOL StopWriteCodec(
00484 unsigned line
00485 );
00486
00490 virtual PINDEX GetReadFrameSize(
00491 unsigned line
00492 );
00493
00494 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00495
00499 virtual PINDEX GetWriteFrameSize(
00500 unsigned line
00501 );
00502
00503 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00504
00507 virtual BOOL ReadFrame(
00508 unsigned line,
00509 void * buf,
00510 PINDEX & count
00511 );
00512
00515 virtual BOOL WriteFrame(
00516 unsigned line,
00517 const void * buf,
00518 PINDEX count,
00519 PINDEX & written
00520 );
00521
00524 virtual unsigned GetAverageSignalLevel(
00525 unsigned line,
00526 BOOL playback
00527 );
00528
00529
00532 virtual BOOL EnableAudio(
00533 unsigned line,
00534 BOOL enable = TRUE
00535 );
00536
00539 virtual BOOL IsAudioEnabled(
00540 unsigned line
00541 );
00542
00543
00548 virtual BOOL SetRecordVolume(
00549 unsigned line,
00550 unsigned volume
00551 );
00552
00557 virtual BOOL SetPlayVolume(
00558 unsigned line,
00559 unsigned volume
00560 );
00561
00566 virtual BOOL GetRecordVolume(
00567 unsigned line,
00568 unsigned & volume
00569 );
00570
00575 virtual BOOL GetPlayVolume(
00576 unsigned line,
00577 unsigned & volume
00578 );
00579
00582 AECLevels GetAEC(
00583 unsigned line
00584 );
00585
00588 BOOL SetAEC(
00589 unsigned line,
00590 AECLevels level
00591 );
00592
00596 unsigned GetWinkDuration(
00597 unsigned line
00598 );
00599
00603 BOOL SetWinkDuration(
00604 unsigned line,
00605 unsigned winkDuration
00606 );
00607
00611 virtual BOOL GetVAD(
00612 unsigned line
00613 );
00614
00618 virtual BOOL SetVAD(
00619 unsigned line,
00620 BOOL enable
00621 );
00622
00623
00631 virtual BOOL GetCallerID(
00632 unsigned line,
00633 PString & idString,
00634 BOOL full = FALSE
00635 );
00636
00645 virtual BOOL SetCallerID(
00646 unsigned line,
00647 const PString & idString
00648 );
00649
00652 virtual BOOL SendCallerIDOnCallWaiting(
00653 unsigned line,
00654 const PString & idString
00655 );
00656
00659 virtual BOOL SendVisualMessageWaitingIndicator(
00660 unsigned line,
00661 BOOL on
00662 );
00663
00664
00665
00669 virtual BOOL PlayDTMF(
00670 unsigned line,
00671 const char * digits,
00672 DWORD onTime = DefaultDTMFOnTime,
00673 DWORD offTime = DefaultDTMFOffTime
00674 );
00675
00681 virtual char ReadDTMF(
00682 unsigned line
00683 );
00684
00689 virtual BOOL GetRemoveDTMF(
00690 unsigned line
00691 );
00692
00697 virtual BOOL SetRemoveDTMF(
00698 unsigned line,
00699 BOOL removeTones
00700 );
00701
00702
00705 virtual unsigned IsToneDetected(
00706 unsigned line
00707 );
00708
00714 virtual BOOL SetToneFilterParameters(
00715 unsigned line,
00716 CallProgressTones tone,
00717 unsigned lowFrequency,
00718 unsigned highFrequency,
00719 PINDEX numCadences,
00720 const unsigned * onTimes,
00721 const unsigned * offTimes
00722 );
00723
00726 virtual BOOL PlayTone(
00727 unsigned line,
00728 CallProgressTones tone
00729 );
00730
00733 virtual BOOL IsTonePlaying(
00734 unsigned line
00735 );
00736
00739 virtual BOOL StopTone(
00740 unsigned line
00741 );
00742
00745 virtual BOOL HasHookFlash(unsigned line);
00746
00752 virtual BOOL SetCountryCode(
00753 T35CountryCodes country
00754 );
00755
00756
00759 virtual DWORD GetSerialNumber();
00760
00761 enum CardTypes {
00762 PhoneJACK = 1,
00763 LineJACK = 3,
00764 PhoneJACK_Lite,
00765 PhoneJACK_PCI,
00766 PhoneCARD,
00767 PhoneJACK_PCI_TJ
00768 };
00769
00772 DWORD GetCardType() const { return dwCardType; }
00773
00774
00777 static PStringArray GetDeviceNames();
00778
00779
00780 protected:
00781
00782 PINDEX LogScaleVolume(unsigned line, PINDEX volume, BOOL isPlay);
00783
00784 PString deviceName;
00785 DWORD dwCardType;
00786 PMutex readMutex, writeMutex;
00787 BOOL readStopped, writeStopped;
00788 PINDEX readFrameSize, writeFrameSize;
00789 PINDEX readCodecType, writeCodecType;
00790 BOOL lastHookState, currentHookState;
00791 PTimer hookTimeout;
00792 BOOL inRawMode;
00793 unsigned enabledAudioLine;
00794 BOOL exclusiveAudioMode;
00795
00796 #if defined(WIN32)
00797 BOOL InternalSetVolume(BOOL record, unsigned id, int volume, int mute);
00798 BOOL InternalPlayTone(unsigned line,
00799 DWORD toneIndex,
00800 DWORD onTime, DWORD offTime,
00801 BOOL synchronous);
00802 BOOL IoControl(DWORD dwIoControlCode,
00803 DWORD inParam = 0,
00804 DWORD * outParam = NULL);
00805 BOOL IoControl(DWORD dwIoControlCode,
00806 LPVOID lpInBuffer,
00807 DWORD nInBufferSize,
00808 LPVOID lpOutBuffer,
00809 DWORD nOutBufferSize,
00810 LPDWORD lpdwBytesReturned,
00811 PWin32Overlapped * overlap = NULL);
00812
00813 HANDLE hDriver;
00814 DWORD driverVersion;
00815 PTimer ringTimeout;
00816 DWORD lastDTMFDigit;
00817 DWORD lastFlashState;
00818 PTimeInterval toneSendCompletionTime;
00819 BOOL vadEnabled;
00820 HANDLE hReadEvent, hWriteEvent;
00821
00822 #elif defined(HAS_IXJ)
00823
00824 public:
00825 class ExceptionInfo {
00826 public:
00827 int fd;
00828
00829 BOOL hasRing;
00830 BOOL hookState;
00831 BOOL hasWink;
00832 BOOL hasFlash;
00833 char dtmf[16];
00834 int dtmfIn;
00835 int dtmfOut;
00836 #ifdef IXJCTL_VMWI
00837 BOOL hasCid;
00838 PHONE_CID cid;
00839 #endif
00840 BOOL filter[4];
00841 BOOL cadence[4];
00842 telephony_exception data;
00843 timeval lastHookChange;
00844 };
00845
00846 static void SignalHandler(int sig);
00847 ExceptionInfo * GetException();
00848 int GetOSHandle() { return os_handle; }
00849
00850 protected:
00851 BOOL ConvertOSError(int err);
00852
00853 static ExceptionInfo exceptionInfo[MaxIxjDevices];
00854 static PMutex exceptionMutex;
00855 static BOOL exceptionInit;
00856
00857 AECLevels aecLevel;
00858 BOOL removeDTMF;
00859 PMutex toneMutex;
00860 BOOL tonePlaying;
00861 PTimer lastRingTime;
00862 BOOL pstnIsOffHook;
00863 BOOL gotWink;
00864 int userPlayVol, userRecVol;
00865
00866 int savedPlayVol, savedRecVol;
00867 AECLevels savedAEC;
00868
00869 #ifdef IXJCTL_VMWI
00870 PHONE_CID callerIdInfo;
00871 #endif
00872
00873 #endif
00874 };
00875
00876
00877 #endif // HAS_IXJ
00878
00879 #endif // __OPAL_IXJLID_H
00880
00881