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
#ifndef __OPAL_IXJLID_H
00248
#define __OPAL_IXJLID_H
00249
00250
#ifdef P_USE_PRAGMA
00251
#pragma interface
00252
#endif
00253
00254
#include "openh323buildopts.h"
00255
00256
#ifdef HAS_IXJ
00257
00258
#include "lid.h"
00259
#include "h323caps.h"
00260
00261
00262
#ifdef P_LINUX
00263
#include <linux/telephony.h>
00264
#include <linux/ixjuser.h>
00265
#endif
00266
00267
#ifdef P_FREEBSD
00268
#include <sys/telephony.h>
00269
#include <sys/ixjuser.h>
00270
#endif
00271
00272
00273
00275
00278 class OpalIxJDevice :
public OpalLineInterfaceDevice
00279 {
00280 PCLASSINFO(
OpalIxJDevice,
OpalLineInterfaceDevice);
00281
00282
enum { MaxIxjDevices = 10 };
00283
00284
public:
00287
OpalIxJDevice();
00288
00292 ~OpalIxJDevice() {
Close(); }
00293
00296
virtual BOOL Open(
00297
const PString & device
00298 );
00299
00302
virtual BOOL
Close();
00303
00306
virtual PString
GetName() const;
00307
00308
00309 enum {
00310 POTSLine,
00311 PSTNLine,
00312 NumLines
00313 };
00314
00317
virtual unsigned GetLineCount();
00318
00319
00322 virtual BOOL
IsLineTerminal(
00323
unsigned line
00324 ) {
return line ==
POTSLine; }
00325
00326
00329
virtual BOOL IsLinePresent(
00330
unsigned line,
00331 BOOL force = FALSE
00332 );
00333
00334
00339
virtual BOOL IsLineOffHook(
00340
unsigned line
00341 );
00342
00346
virtual BOOL SetLineOffHook(
00347
unsigned line,
00348 BOOL newState = TRUE
00349 );
00350
00351
00354
virtual BOOL IsLineRinging(
00355
unsigned line,
00356 DWORD * cadence = NULL
00357 );
00358
00362
virtual BOOL RingLine(
00363
unsigned line,
00364 DWORD cadence
00365 );
00366
00381
virtual BOOL RingLine(
00382
unsigned line,
00383 PINDEX nCadence,
00384
unsigned * pattern
00385 );
00386
00387
00390
virtual BOOL IsLineDisconnected(
00391
unsigned line,
00392 BOOL checkForWink = TRUE
00393 );
00394
00395
00398 BOOL SetLineToLineDirect(
00399
unsigned line1,
00400
unsigned line2,
00401 BOOL connect
00402 );
00403
00406 BOOL IsLineToLineDirect(
00407
unsigned line1,
00408
unsigned line2
00409 );
00410
00411
00414
virtual OpalMediaFormat::List
GetMediaFormats() const;
00415
00418 virtual BOOL SetReadFormat(
00419
unsigned line,
00420 const
OpalMediaFormat & mediaFormat
00421 );
00422
00425 virtual BOOL SetWriteFormat(
00426
unsigned line,
00427 const
OpalMediaFormat & mediaFormat
00428 );
00429
00432 virtual
OpalMediaFormat GetReadFormat(
00433
unsigned line
00434 );
00435
00438 virtual
OpalMediaFormat GetWriteFormat(
00439
unsigned line
00440 );
00441
00452 virtual BOOL SetRawCodec(
00453
unsigned line
00454 );
00455
00458 virtual BOOL StopRawCodec(
00459
unsigned line
00460 );
00461
00464 virtual BOOL StopReadCodec(
00465
unsigned line
00466 );
00467
00470 virtual BOOL StopWriteCodec(
00471
unsigned line
00472 );
00473
00477 virtual PINDEX GetReadFrameSize(
00478
unsigned line
00479 );
00480
00481 virtual BOOL SetReadFrameSize(
unsigned, PINDEX);
00482
00486 virtual PINDEX GetWriteFrameSize(
00487
unsigned line
00488 );
00489
00490 virtual BOOL SetWriteFrameSize(
unsigned, PINDEX);
00491
00494 virtual BOOL ReadFrame(
00495
unsigned line,
00496
void * buf,
00497 PINDEX & count
00498 );
00499
00502 virtual BOOL WriteFrame(
00503
unsigned line,
00504 const
void * buf,
00505 PINDEX count,
00506 PINDEX & written
00507 );
00508
00511 virtual
unsigned GetAverageSignalLevel(
00512
unsigned line,
00513 BOOL playback
00514 );
00515
00516
00519 virtual BOOL EnableAudio(
00520
unsigned line,
00521 BOOL enable = TRUE
00522 );
00523
00526 virtual BOOL IsAudioEnabled(
00527
unsigned line
00528 );
00529
00530
00535 virtual BOOL SetRecordVolume(
00536
unsigned line,
00537
unsigned volume
00538 );
00539
00544 virtual BOOL SetPlayVolume(
00545
unsigned line,
00546
unsigned volume
00547 );
00548
00553 virtual BOOL GetRecordVolume(
00554
unsigned line,
00555
unsigned & volume
00556 );
00557
00562 virtual BOOL GetPlayVolume(
00563
unsigned line,
00564
unsigned & volume
00565 );
00566
00569 AECLevels GetAEC(
00570
unsigned line
00571 );
00572
00575 BOOL SetAEC(
00576
unsigned line,
00577 AECLevels level
00578 );
00579
00583
unsigned GetWinkDuration(
00584
unsigned line
00585 );
00586
00590 BOOL SetWinkDuration(
00591
unsigned line,
00592
unsigned winkDuration
00593 );
00594
00598 virtual BOOL GetVAD(
00599
unsigned line
00600 );
00601
00605 virtual BOOL SetVAD(
00606
unsigned line,
00607 BOOL enable
00608 );
00609
00610
00618 virtual BOOL GetCallerID(
00619
unsigned line,
00620 PString & idString,
00621 BOOL full = FALSE
00622 );
00623
00632 virtual BOOL SetCallerID(
00633
unsigned line,
00634 const PString & idString
00635 );
00636
00639 virtual BOOL SendCallerIDOnCallWaiting(
00640
unsigned line,
00641 const PString & idString
00642 );
00643
00646 virtual BOOL SendVisualMessageWaitingIndicator(
00647
unsigned line,
00648 BOOL on
00649 );
00650
00651
00652
00656 virtual BOOL PlayDTMF(
00657
unsigned line,
00658 const
char * digits,
00659 DWORD onTime = DefaultDTMFOnTime,
00660 DWORD offTime = DefaultDTMFOffTime
00661 );
00662
00668 virtual
char ReadDTMF(
00669
unsigned line
00670 );
00671
00676 virtual BOOL GetRemoveDTMF(
00677
unsigned line
00678 );
00679
00684 virtual BOOL SetRemoveDTMF(
00685
unsigned line,
00686 BOOL removeTones
00687 );
00688
00689
00692 virtual
unsigned IsToneDetected(
00693
unsigned line
00694 );
00695
00701 virtual BOOL SetToneFilterParameters(
00702
unsigned line,
00703 CallProgressTones tone,
00704
unsigned lowFrequency,
00705
unsigned highFrequency,
00706 PINDEX numCadences,
00707 const
unsigned * onTimes,
00708 const
unsigned * offTimes
00709 );
00710
00713 virtual BOOL PlayTone(
00714
unsigned line,
00715 CallProgressTones tone
00716 );
00717
00720 virtual BOOL IsTonePlaying(
00721
unsigned line
00722 );
00723
00726 virtual BOOL StopTone(
00727
unsigned line
00728 );
00729
00732 virtual BOOL HasHookFlash(
unsigned line);
00733
00739 virtual BOOL SetCountryCode(
00740 T35CountryCodes country
00741 );
00742
00743
00746 virtual DWORD GetSerialNumber();
00747
00748 enum CardTypes {
00749
PhoneJACK = 1,
00750
LineJACK = 3,
00751
PhoneJACK_Lite,
00752
PhoneJACK_PCI,
00753
PhoneCARD,
00754
PhoneJACK_PCI_TJ
00755 };
00756
00759 DWORD
GetCardType()
const {
return dwCardType; }
00760
00761
00764
static PStringArray
GetDeviceNames();
00765
00766
00767
protected:
00768
00769 PINDEX LogScaleVolume(
unsigned line, PINDEX volume, BOOL isPlay);
00770
00771 PString
deviceName;
00772 DWORD
dwCardType;
00773 PMutex
readMutex,
writeMutex;
00774 BOOL
readStopped,
writeStopped;
00775 PINDEX
readFrameSize,
writeFrameSize;
00776 PINDEX
readCodecType,
writeCodecType;
00777 BOOL
lastHookState,
currentHookState;
00778 PTimer
hookTimeout;
00779 BOOL
inRawMode;
00780 unsigned enabledAudioLine;
00781 BOOL
exclusiveAudioMode;
00782
00783
#if defined(WIN32)
00784
BOOL InternalSetVolume(BOOL record,
unsigned id,
int volume,
int mute);
00785 BOOL InternalPlayTone(
unsigned line,
00786 DWORD toneIndex,
00787 DWORD onTime, DWORD offTime,
00788 BOOL synchronous);
00789 BOOL IoControl(DWORD dwIoControlCode,
00790 DWORD inParam = 0,
00791 DWORD * outParam = NULL);
00792 BOOL IoControl(DWORD dwIoControlCode,
00793
LPVOID lpInBuffer,
00794 DWORD nInBufferSize,
00795 LPVOID lpOutBuffer,
00796 DWORD nOutBufferSize,
00797 LPDWORD lpdwBytesReturned,
00798 PWin32Overlapped * overlap = NULL);
00799
00800 HANDLE hDriver;
00801 DWORD driverVersion;
00802 PTimer ringTimeout;
00803 DWORD lastDTMFDigit;
00804 DWORD lastFlashState;
00805 PTimeInterval toneSendCompletionTime;
00806 BOOL vadEnabled;
00807 HANDLE hReadEvent, hWriteEvent;
00808
00809
#elif defined(HAS_IXJ)
00810
00811
public:
00812 class ExceptionInfo {
00813
public:
00814 int fd;
00815
00816 BOOL
hasRing;
00817 BOOL
hookState;
00818 BOOL
hasWink;
00819 BOOL
hasFlash;
00820 char dtmf[16];
00821 int dtmfIn;
00822 int dtmfOut;
00823
#ifdef IXJCTL_VMWI
00824
BOOL hasCid;
00825 PHONE_CID cid;
00826
#endif
00827 BOOL
filter[4];
00828 BOOL
cadence[4];
00829 telephony_exception
data;
00830 timeval
lastHookChange;
00831 };
00832
00833
static void SignalHandler(
int sig);
00834
ExceptionInfo *
OpalIxJDevice::GetException();
00835 int GetOSHandle() {
return os_handle; }
00836
00837
protected:
00838 BOOL ConvertOSError(
int err);
00839
00840 static ExceptionInfo exceptionInfo[MaxIxjDevices];
00841 static PMutex
exceptionMutex;
00842 static BOOL
exceptionInit;
00843
00844 AECLevels
aecLevel;
00845 BOOL
removeDTMF;
00846 PMutex
toneMutex;
00847 BOOL
tonePlaying;
00848 PTimer
lastRingTime;
00849 BOOL
pstnIsOffHook;
00850 BOOL
gotWink;
00851 int userPlayVol,
userRecVol;
00852
00853 int savedPlayVol,
savedRecVol;
00854 AECLevels
savedAEC;
00855
00856
#ifdef IXJCTL_VMWI
00857
PHONE_CID callerIdInfo;
00858
#endif
00859
00860
#endif
00861
};
00862
00863
00864
#endif // HAS_IXJ
00865
00866
#endif // __OPAL_IXJLID_H
00867
00868