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/compiler.h>
00278 #include <linux/ixjuser.h>
00279 #endif
00280
00281 #ifdef P_FREEBSD
00282 #include <sys/telephony.h>
00283 #include <sys/ixjuser.h>
00284 #endif
00285
00286
00287
00289
00292 class OpalIxJDevice : public OpalLineInterfaceDevice
00293 {
00294 PCLASSINFO(OpalIxJDevice, OpalLineInterfaceDevice);
00295
00296 enum { MaxIxjDevices = 10 };
00297
00298 public:
00301 OpalIxJDevice();
00302
00306 ~OpalIxJDevice() { Close(); }
00307
00310 virtual BOOL Open(
00311 const PString & device
00312 );
00313
00316 virtual BOOL Close();
00317
00320 virtual PString GetName() const;
00321
00322
00323 enum {
00324 POTSLine,
00325 PSTNLine,
00326 NumLines
00327 };
00328
00331 virtual unsigned GetLineCount();
00332
00333
00336 virtual BOOL IsLineTerminal(
00337 unsigned line
00338 ) { return line == POTSLine; }
00339
00340
00343 virtual BOOL IsLinePresent(
00344 unsigned line,
00345 BOOL force = FALSE
00346 );
00347
00348
00353 virtual BOOL IsLineOffHook(
00354 unsigned line
00355 );
00356
00360 virtual BOOL SetLineOffHook(
00361 unsigned line,
00362 BOOL newState = TRUE
00363 );
00364
00365
00368 virtual BOOL IsLineRinging(
00369 unsigned line,
00370 DWORD * cadence = NULL
00371 );
00372
00376 virtual BOOL RingLine(
00377 unsigned line,
00378 DWORD cadence
00379 );
00380
00395 virtual BOOL RingLine(
00396 unsigned line,
00397 PINDEX nCadence,
00398 unsigned * pattern
00399 );
00400
00401
00404 virtual BOOL IsLineDisconnected(
00405 unsigned line,
00406 BOOL checkForWink = TRUE
00407 );
00408
00409
00412 BOOL SetLineToLineDirect(
00413 unsigned line1,
00414 unsigned line2,
00415 BOOL connect
00416 );
00417
00420 BOOL IsLineToLineDirect(
00421 unsigned line1,
00422 unsigned line2
00423 );
00424
00425
00428 virtual OpalMediaFormat::List GetMediaFormats() const;
00429
00432 virtual BOOL SetReadFormat(
00433 unsigned line,
00434 const OpalMediaFormat & mediaFormat
00435 );
00436
00439 virtual BOOL SetWriteFormat(
00440 unsigned line,
00441 const OpalMediaFormat & mediaFormat
00442 );
00443
00446 virtual OpalMediaFormat GetReadFormat(
00447 unsigned line
00448 );
00449
00452 virtual OpalMediaFormat GetWriteFormat(
00453 unsigned line
00454 );
00455
00466 virtual BOOL SetRawCodec(
00467 unsigned line
00468 );
00469
00472 virtual BOOL StopRawCodec(
00473 unsigned line
00474 );
00475
00478 virtual BOOL StopReadCodec(
00479 unsigned line
00480 );
00481
00484 virtual BOOL StopWriteCodec(
00485 unsigned line
00486 );
00487
00491 virtual PINDEX GetReadFrameSize(
00492 unsigned line
00493 );
00494
00495 virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00496
00500 virtual PINDEX GetWriteFrameSize(
00501 unsigned line
00502 );
00503
00504 virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00505
00508 virtual BOOL ReadFrame(
00509 unsigned line,
00510 void * buf,
00511 PINDEX & count
00512 );
00513
00516 virtual BOOL WriteFrame(
00517 unsigned line,
00518 const void * buf,
00519 PINDEX count,
00520 PINDEX & written
00521 );
00522
00525 virtual unsigned GetAverageSignalLevel(
00526 unsigned line,
00527 BOOL playback
00528 );
00529
00530
00533 virtual BOOL EnableAudio(
00534 unsigned line,
00535 BOOL enable = TRUE
00536 );
00537
00540 virtual BOOL IsAudioEnabled(
00541 unsigned line
00542 );
00543
00544
00549 virtual BOOL SetRecordVolume(
00550 unsigned line,
00551 unsigned volume
00552 );
00553
00558 virtual BOOL SetPlayVolume(
00559 unsigned line,
00560 unsigned volume
00561 );
00562
00567 virtual BOOL GetRecordVolume(
00568 unsigned line,
00569 unsigned & volume
00570 );
00571
00576 virtual BOOL GetPlayVolume(
00577 unsigned line,
00578 unsigned & volume
00579 );
00580
00583 AECLevels GetAEC(
00584 unsigned line
00585 );
00586
00589 BOOL SetAEC(
00590 unsigned line,
00591 AECLevels level
00592 );
00593
00597 unsigned GetWinkDuration(
00598 unsigned line
00599 );
00600
00604 BOOL SetWinkDuration(
00605 unsigned line,
00606 unsigned winkDuration
00607 );
00608
00612 virtual BOOL GetVAD(
00613 unsigned line
00614 );
00615
00619 virtual BOOL SetVAD(
00620 unsigned line,
00621 BOOL enable
00622 );
00623
00624
00632 virtual BOOL GetCallerID(
00633 unsigned line,
00634 PString & idString,
00635 BOOL full = FALSE
00636 );
00637
00646 virtual BOOL SetCallerID(
00647 unsigned line,
00648 const PString & idString
00649 );
00650
00653 virtual BOOL SendCallerIDOnCallWaiting(
00654 unsigned line,
00655 const PString & idString
00656 );
00657
00660 virtual BOOL SendVisualMessageWaitingIndicator(
00661 unsigned line,
00662 BOOL on
00663 );
00664
00665
00666
00670 virtual BOOL PlayDTMF(
00671 unsigned line,
00672 const char * digits,
00673 DWORD onTime = DefaultDTMFOnTime,
00674 DWORD offTime = DefaultDTMFOffTime
00675 );
00676
00682 virtual char ReadDTMF(
00683 unsigned line
00684 );
00685
00690 virtual BOOL GetRemoveDTMF(
00691 unsigned line
00692 );
00693
00698 virtual BOOL SetRemoveDTMF(
00699 unsigned line,
00700 BOOL removeTones
00701 );
00702
00703
00706 virtual unsigned IsToneDetected(
00707 unsigned line
00708 );
00709
00715 virtual BOOL SetToneFilterParameters(
00716 unsigned line,
00717 CallProgressTones tone,
00718 unsigned lowFrequency,
00719 unsigned highFrequency,
00720 PINDEX numCadences,
00721 const unsigned * onTimes,
00722 const unsigned * offTimes
00723 );
00724
00727 virtual BOOL PlayTone(
00728 unsigned line,
00729 CallProgressTones tone
00730 );
00731
00734 virtual BOOL IsTonePlaying(
00735 unsigned line
00736 );
00737
00740 virtual BOOL StopTone(
00741 unsigned line
00742 );
00743
00746 virtual BOOL HasHookFlash(unsigned line);
00747
00753 virtual BOOL SetCountryCode(
00754 T35CountryCodes country
00755 );
00756
00757
00760 virtual DWORD GetSerialNumber();
00761
00762 enum CardTypes {
00763 PhoneJACK = 1,
00764 LineJACK = 3,
00765 PhoneJACK_Lite,
00766 PhoneJACK_PCI,
00767 PhoneCARD,
00768 PhoneJACK_PCI_TJ
00769 };
00770
00773 DWORD GetCardType() const { return dwCardType; }
00774
00775
00778 static PStringArray GetDeviceNames();
00779
00780
00781 protected:
00782
00783 PINDEX LogScaleVolume(unsigned line, PINDEX volume, BOOL isPlay);
00784
00785 PString deviceName;
00786 DWORD dwCardType;
00787 PMutex readMutex, writeMutex;
00788 BOOL readStopped, writeStopped;
00789 PINDEX readFrameSize, writeFrameSize;
00790 PINDEX readCodecType, writeCodecType;
00791 BOOL lastHookState, currentHookState;
00792 PTimer hookTimeout;
00793 BOOL inRawMode;
00794 unsigned enabledAudioLine;
00795 BOOL exclusiveAudioMode;
00796
00797 #if defined(WIN32)
00798 BOOL InternalSetVolume(BOOL record, unsigned id, int volume, int mute);
00799 BOOL InternalPlayTone(unsigned line,
00800 DWORD toneIndex,
00801 DWORD onTime, DWORD offTime,
00802 BOOL synchronous);
00803 BOOL IoControl(DWORD dwIoControlCode,
00804 DWORD inParam = 0,
00805 DWORD * outParam = NULL);
00806 BOOL IoControl(DWORD dwIoControlCode,
00807 LPVOID lpInBuffer,
00808 DWORD nInBufferSize,
00809 LPVOID lpOutBuffer,
00810 DWORD nOutBufferSize,
00811 LPDWORD lpdwBytesReturned,
00812 PWin32Overlapped * overlap = NULL);
00813
00814 HANDLE hDriver;
00815 DWORD driverVersion;
00816 PTimer ringTimeout;
00817 DWORD lastDTMFDigit;
00818 DWORD lastFlashState;
00819 PTimeInterval toneSendCompletionTime;
00820 BOOL vadEnabled;
00821 HANDLE hReadEvent, hWriteEvent;
00822
00823 #elif defined(HAS_IXJ)
00824
00825 public:
00826 class ExceptionInfo {
00827 public:
00828 int fd;
00829
00830 BOOL hasRing;
00831 BOOL hookState;
00832 BOOL hasWink;
00833 BOOL hasFlash;
00834 char dtmf[16];
00835 int dtmfIn;
00836 int dtmfOut;
00837 #ifdef IXJCTL_VMWI
00838 BOOL hasCid;
00839 PHONE_CID cid;
00840 #endif
00841 BOOL filter[4];
00842 BOOL cadence[4];
00843 telephony_exception data;
00844 timeval lastHookChange;
00845 };
00846
00847 static void SignalHandler(int sig);
00848 ExceptionInfo * GetException();
00849 int GetOSHandle() { return os_handle; }
00850
00851 protected:
00852 BOOL ConvertOSError(int err);
00853
00854 static ExceptionInfo exceptionInfo[MaxIxjDevices];
00855 static PMutex exceptionMutex;
00856 static BOOL exceptionInit;
00857
00858 AECLevels aecLevel;
00859 BOOL removeDTMF;
00860 PMutex toneMutex;
00861 BOOL tonePlaying;
00862 PTimer lastRingTime;
00863 BOOL pstnIsOffHook;
00864 BOOL gotWink;
00865 int userPlayVol, userRecVol;
00866
00867 int savedPlayVol, savedRecVol;
00868 AECLevels savedAEC;
00869
00870 #ifdef IXJCTL_VMWI
00871 PHONE_CID callerIdInfo;
00872 #endif
00873
00874 #endif
00875 };
00876
00877
00878 #endif // HAS_IXJ
00879
00880 #endif // __OPAL_IXJLID_H
00881
00882