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 #ifndef __OPAL_LID_H
00226 #define __OPAL_LID_H
00227
00228 #ifdef P_USE_PRAGMA
00229 #pragma interface
00230 #endif
00231
00232
00233 #include "codecs.h"
00234 #include "h323caps.h"
00235
00236
00238
00242 class OpalLineInterfaceDevice : public PObject
00243 {
00244 PCLASSINFO(OpalLineInterfaceDevice, PObject);
00245
00246 public:
00249 OpalLineInterfaceDevice();
00250
00253 virtual BOOL Open(
00254 const PString & device
00255 ) = 0;
00256
00259 virtual BOOL IsOpen() const;
00260
00263 virtual BOOL Close();
00264
00270 virtual PString GetName() const = 0;
00271
00274 virtual unsigned GetLineCount() = 0;
00275
00282 virtual BOOL IsLineTerminal(
00283 unsigned line
00284 );
00285
00286
00289 virtual BOOL IsLinePresent(
00290 unsigned line,
00291 BOOL force = FALSE
00292 );
00293
00294
00300 virtual BOOL IsLineOffHook(
00301 unsigned line
00302 ) = 0;
00303
00309 virtual BOOL SetLineOffHook(
00310 unsigned line,
00311 BOOL newState = TRUE
00312 ) = 0;
00313
00317 virtual BOOL SetLineOnHook(
00318 unsigned line
00319 ) { return SetLineOffHook(line, FALSE); }
00320
00324 virtual BOOL HookFlash(
00325 unsigned line,
00326 unsigned flashTime = 200
00327 );
00328
00331 virtual BOOL HasHookFlash(unsigned line);
00332
00333
00344 virtual BOOL IsLineRinging(
00345 unsigned line,
00346 DWORD * cadence = NULL
00347 );
00348
00359 virtual BOOL RingLine(
00360 unsigned line,
00361 DWORD cadence
00362 );
00363
00378 virtual BOOL RingLine(
00379 unsigned line,
00380 PINDEX nCadence,
00381 unsigned * pattern
00382 );
00383
00384
00388 virtual BOOL IsLineDisconnected(
00389 unsigned line,
00390 BOOL checkForWink = TRUE
00391 );
00392
00393
00396 virtual BOOL SetLineToLineDirect(
00397 unsigned line1,
00398 unsigned line2,
00399 BOOL connect
00400 );
00401
00404 virtual BOOL IsLineToLineDirect(
00405 unsigned line1,
00406 unsigned line2
00407 );
00408
00409
00412 virtual OpalMediaFormat::List GetMediaFormats() const = 0;
00413
00416 virtual BOOL SetReadFormat(
00417 unsigned line,
00418 const OpalMediaFormat & mediaFormat
00419 ) = 0;
00420
00423 virtual BOOL SetWriteFormat(
00424 unsigned line,
00425 const OpalMediaFormat & mediaFormat
00426 ) = 0;
00427
00430 virtual OpalMediaFormat GetReadFormat(
00431 unsigned line
00432 ) = 0;
00433
00436 virtual OpalMediaFormat GetWriteFormat(
00437 unsigned line
00438 ) = 0;
00439
00448 virtual BOOL SetReadCodec(
00449 unsigned line,
00450 RTP_DataFrame::PayloadTypes codec
00451 );
00452
00458 virtual BOOL SetWriteCodec(
00459 unsigned line,
00460 RTP_DataFrame::PayloadTypes codec
00461 );
00462
00473 virtual BOOL SetRawCodec(
00474 unsigned line
00475 );
00476
00479 virtual BOOL StopReadCodec(
00480 unsigned line
00481 );
00482
00485 virtual BOOL StopWriteCodec(
00486 unsigned line
00487 );
00488
00491 virtual BOOL StopRawCodec(
00492 unsigned line
00493 );
00494
00499 virtual BOOL SetReadFrameSize(
00500 unsigned line,
00501 PINDEX frameSize
00502 );
00503
00508 virtual BOOL SetWriteFrameSize(
00509 unsigned line,
00510 PINDEX frameSize
00511 );
00512
00516 virtual PINDEX GetReadFrameSize(
00517 unsigned line
00518 ) = 0;
00519
00523 virtual PINDEX GetWriteFrameSize(
00524 unsigned line
00525 ) = 0;
00526
00529 virtual BOOL ReadFrame(
00530 unsigned line,
00531 void * buf,
00532 PINDEX & count
00533 ) = 0;
00534
00537 virtual BOOL WriteFrame(
00538 unsigned line,
00539 const void * buf,
00540 PINDEX count,
00541 PINDEX & written
00542 ) = 0;
00543
00547 virtual BOOL ReadBlock(
00548 unsigned line,
00549 void * buf,
00550 PINDEX count
00551 );
00552
00555 virtual BOOL WriteBlock(
00556 unsigned line,
00557 const void * buf,
00558 PINDEX count
00559 );
00560
00561
00564 virtual unsigned GetAverageSignalLevel(
00565 unsigned line,
00566 BOOL playback
00567 );
00568
00569
00572 virtual BOOL EnableAudio(
00573 unsigned line,
00574 BOOL enable = TRUE
00575 );
00576
00579 BOOL DisableAudio(
00580 unsigned line
00581 ) { return EnableAudio(line, FALSE); }
00582
00585 virtual BOOL IsAudioEnabled(
00586 unsigned line
00587 );
00588
00589
00590 enum {
00591 MaxVolume = 100
00592 };
00593
00598 virtual BOOL SetRecordVolume(
00599 unsigned line,
00600 unsigned volume
00601 );
00602
00607 virtual BOOL SetPlayVolume(
00608 unsigned line,
00609 unsigned volume
00610 );
00611
00616 virtual BOOL GetRecordVolume(
00617 unsigned line,
00618 unsigned & volume
00619 );
00620
00625 virtual BOOL GetPlayVolume(
00626 unsigned line,
00627 unsigned & volume
00628 );
00629
00630
00631 enum AECLevels {
00632 AECOff,
00633 AECLow,
00634 AECMedium,
00635 AECHigh,
00636 AECAuto,
00637 AECAGC,
00638 AECError
00639 };
00640
00644 virtual AECLevels GetAEC(
00645 unsigned line
00646 );
00647
00651 virtual BOOL SetAEC(
00652 unsigned line,
00653 AECLevels level
00654 );
00655
00659 virtual unsigned GetWinkDuration(
00660 unsigned line
00661 );
00662
00666 virtual BOOL SetWinkDuration(
00667 unsigned line,
00668 unsigned winkDuration
00669 );
00670
00674 virtual BOOL GetVAD(
00675 unsigned line
00676 );
00677
00681 virtual BOOL SetVAD(
00682 unsigned line,
00683 BOOL enable
00684 );
00685
00686
00694 virtual BOOL GetCallerID(
00695 unsigned line,
00696 PString & idString,
00697 BOOL full = FALSE
00698 );
00699
00708 virtual BOOL SetCallerID(
00709 unsigned line,
00710 const PString & idString
00711 );
00712
00721 virtual BOOL SendCallerIDOnCallWaiting(
00722 unsigned line,
00723 const PString & idString
00724 );
00725
00728 virtual BOOL SendVisualMessageWaitingIndicator(
00729 unsigned line,
00730 BOOL on
00731 );
00732
00733
00734 enum {
00735 DefaultDTMFOnTime = 180,
00736 DefaultDTMFOffTime = 120
00737 };
00738
00742 virtual BOOL PlayDTMF(
00743 unsigned line,
00744 const char * digits,
00745 DWORD onTime = DefaultDTMFOnTime,
00746 DWORD offTime = DefaultDTMFOffTime
00747 );
00748
00758 virtual char ReadDTMF(
00759 unsigned line
00760 );
00761
00766 virtual BOOL GetRemoveDTMF(
00767 unsigned line
00768 );
00769
00774 virtual BOOL SetRemoveDTMF(
00775 unsigned line,
00776 BOOL removeTones
00777 );
00778
00779
00780 enum CallProgressTones {
00781 NoTone = 0x00,
00782 DialTone = 0x01,
00783 RingTone = 0x02,
00784 BusyTone = 0x04,
00785 ClearTone = 0x08,
00786 CNGTone = 0x10,
00787 AllTones = 0x1f
00788 };
00789
00792 virtual unsigned IsToneDetected(
00793 unsigned line
00794 );
00795
00798 virtual unsigned WaitForToneDetect(
00799 unsigned line,
00800 unsigned timeout = 3000
00801 );
00802
00805 virtual BOOL WaitForTone(
00806 unsigned line,
00807 CallProgressTones tone,
00808 unsigned timeout = 3000
00809 );
00810
00828 virtual BOOL SetToneFilter(
00829 unsigned line,
00830 CallProgressTones tone,
00831 const PString & description
00832 );
00833
00836 virtual BOOL SetToneFilterParameters(
00837 unsigned line,
00838 CallProgressTones tone,
00839 unsigned lowFrequency,
00840 unsigned highFrequency,
00841 PINDEX numCadences,
00842 const unsigned * onTimes,
00843 const unsigned * offTimes
00844 );
00845
00848 virtual BOOL PlayTone(
00849 unsigned line,
00850 CallProgressTones tone
00851 );
00852
00855 virtual BOOL IsTonePlaying(
00856 unsigned line
00857 );
00858
00861 virtual BOOL StopTone(
00862 unsigned line
00863 );
00864
00867 virtual BOOL PlayAudio(
00868 unsigned line,
00869 const PString & filename
00870 );
00871
00874 virtual BOOL StopAudio(
00875 unsigned line
00876 );
00877
00878
00894 virtual CallProgressTones DialOut(
00895 unsigned line,
00896 const PString & number,
00897 BOOL requireTones = FALSE
00898 );
00899
00900
00901 enum T35CountryCodes {
00902 Japan, Albania, Algeria, AmericanSamoa, Germany, Anguilla, AntiguaAndBarbuda,
00903 Argentina, Ascension, Australia, Austria, Bahamas, Bahrain, Bangladesh,
00904 Barbados, Belgium, Belize, Benin, Bermudas, Bhutan, Bolivia, Botswana,
00905 Brazil, BritishAntarcticTerritory, BritishIndianOceanTerritory,
00906 BritishVirginIslands, BruneiDarussalam, Bulgaria, Myanmar, Burundi,
00907 Byelorussia, Cameroon, Canada, CapeVerde, CaymanIslands,
00908 CentralAfricanRepublic, Chad, Chile, China, Colombia, Comoros, Congo,
00909 CookIslands, CostaRica, Cuba, Cyprus, Czechoslovakia, Cambodia,
00910 DemocraticPeoplesRepublicOfKorea, Denmark, Djibouti, DominicanRepublic,
00911 Dominica, Ecuador, Egypt, ElSalvador, EquatorialGuinea, Ethiopia,
00912 FalklandIslands, Fiji, Finland, France, FrenchPolynesia,
00913 FrenchSouthernAndAntarcticLands, Gabon, Gambia, Germany2, Angola, Ghana,
00914 Gibraltar, Greece, Grenada, Guam, Guatemala, Guernsey, Guinea, GuineaBissau,
00915 Guayana, Haiti, Honduras, Hongkong, Hungary, Iceland, India, Indonesia,
00916 Iran, Iraq, Ireland, Israel, Italy, CotedIvoire, Jamaica, Afghanistan,
00917 Jersey, Jordan, Kenya, Kiribati, KoreaRepublic, Kuwait, Lao, Lebanon,
00918 Lesotho, Liberia, Libya, Liechtenstein, Luxemborg, Macao, Madagascar,
00919 Malaysia, Malawi, Maldives, Mali, Malta, Mauritania, Mauritius, Mexico,
00920 Monaco, Mongolia, Montserrat, Morocco, Mozambique, Nauru, Nepal,
00921 Netherlands, NetherlandsAntilles, NewCaledonia, NewZealand, Nicaragua,
00922 Niger, Nigeria, Norway, Oman, Pakistan, Panama, PapuaNewGuinea, Paraguay,
00923 Peru, Philippines, Poland, Portugal, PuertoRico, Qatar, Romania, Rwanda,
00924 SaintKittsAndNevis, SaintCroix, SaintHelenaAndAscension, SaintLucia,
00925 SanMarino, SaintThomas, SaoTomeAndPrincipe, SaintVicentAndTheGrenadines,
00926 SaudiArabia, Senegal, Seychelles, SierraLeone, Singapore, SolomonIslands,
00927 Somalia, SouthAfrica, Spain, SriLanka, Sudan, Suriname, Swaziland, Sweden,
00928 Switzerland, Syria, Tanzania, Thailand, Togo, Tonga, TrinidadAndTobago,
00929 Tunisia, Turkey, TurksAndCaicosIslands, Tuvalu, Uganda, Ukraine,
00930 UnitedArabEmirates, UnitedKingdom, UnitedStates, BurkinaFaso, Uruguay,
00931 USSR, Vanuatu, VaticanCityState, Venezuela, VietNam, WallisAndFutuna,
00932 WesternSamoa, Yemen, Yemen2, Yugoslavia, Zaire, Zambia, Zimbabwe,
00933 NumCountryCodes,
00934 UnknownCountry = -1
00935 };
00936
00939 T35CountryCodes GetCountryCode() const { return countryCode; }
00940
00943 PString GetCountryCodeName() const;
00944
00947 static PString GetCountryCodeName(T35CountryCodes code);
00948 static T35CountryCodes GetCountryCode(const PString & name);
00949
00955 virtual BOOL SetCountryCode(
00956 T35CountryCodes country
00957 );
00958
00961 virtual BOOL SetCountryCodeName(
00962 const PString & countryName
00963 );
00964
00967 virtual PStringList GetCountryCodeNameList() const;
00968
00969
00972 int GetErrorNumber() const { return osError; }
00973
00976 PString GetErrorText() const;
00977
00978 virtual void PrintOn(
00979 ostream & strm
00980 ) const;
00981
00984 enum DeviceType{
00985 POTSLine,
00986 Gateway,
00987 CellEmulate
00988
00989 };
00990
00993 virtual OpalLineInterfaceDevice::DeviceType GetDeviceType() { return POTSLine; };
00994
00995 protected:
00996 int os_handle;
00997 int osError;
00998 T35CountryCodes countryCode;
00999 PBYTEArray readDeblockingBuffer, writeDeblockingBuffer;
01000 PINDEX readDeblockingOffset, writeDeblockingOffset;
01001
01002 #if PTRACING
01003 friend ostream & operator<<(ostream & o, CallProgressTones t);
01004 #endif
01005 };
01006
01007
01010 class OpalLineChannel : public PChannel
01011 {
01012 PCLASSINFO(OpalLineChannel, PChannel);
01013
01014 public:
01017 OpalLineChannel(
01018 OpalLineInterfaceDevice & device,
01019 unsigned line,
01020 const H323AudioCodec & codec
01021 );
01022 ~OpalLineChannel();
01023
01026 PString GetName() const;
01027
01030 BOOL Close();
01031
01044 virtual BOOL Read(
01045 void * buf,
01046 PINDEX len
01047 );
01048
01060 virtual BOOL Write(
01061 const void * buf,
01062 PINDEX len
01063 );
01064
01065
01068 OpalLineInterfaceDevice & GetDevice() const { return device; }
01069
01072 unsigned GetLineNumber() const { return lineNumber; }
01073
01074
01075 protected:
01076 OpalLineInterfaceDevice & device;
01077 unsigned lineNumber;
01078 BOOL reading;
01079 BOOL useDeblocking;
01080 };
01081
01082
01083
01084
01085
01088 class H323_LIDCapability : public H323AudioCapability
01089 {
01090 PCLASSINFO(H323_LIDCapability, H323AudioCapability);
01091
01092 public:
01097 H323_LIDCapability(
01098 const OpalMediaFormat & mediaFormat
01099 );
01101
01106 Comparison Compare(const PObject & obj) const;
01107
01110 virtual PObject * Clone() const;
01111
01114 virtual PString GetFormatName() const;
01116
01124 virtual unsigned GetSubType() const;
01126
01131 virtual H323Codec * CreateCodec(
01132 H323Codec::Direction direction
01133 ) const;
01134
01137 BOOL IsValid() const;
01138
01141 static void AddAllCapabilities(
01142 const OpalLineInterfaceDevice & device,
01143 H323Capabilities & capabilities,
01144 PINDEX descriptorNum,
01145 PINDEX simultaneous
01146 );
01148
01158 virtual BOOL OnSendingPDU(
01159 H245_AudioCapability & pdu,
01160 unsigned packetSize
01161 ) const;
01162
01170 virtual BOOL OnReceivedPDU(
01171 const H245_AudioCapability & pdu,
01172 unsigned & packetSize
01173 );
01175
01176 protected:
01177 OpalMediaFormat mediaFormat;
01178 PINDEX codecTableIndex;
01179 };
01180
01181
01184 class H323_CiscoG7231aLIDCapability : public H323NonStandardAudioCapability
01185 {
01186 PCLASSINFO(H323_CiscoG7231aLIDCapability, H323NonStandardAudioCapability);
01187
01188 public:
01193 H323_CiscoG7231aLIDCapability();
01195
01200 virtual PObject * Clone() const;
01202
01207 virtual H323Codec * CreateCodec(
01208 H323Codec::Direction direction
01209 ) const;
01211
01216 virtual PString GetFormatName() const;
01218 };
01219
01220
01224 class H323_LIDCodec : public H323AudioCodec
01225 {
01226 PCLASSINFO(H323_LIDCodec, H323AudioCodec);
01227
01228 public:
01231 H323_LIDCodec(
01232 const char * mediaFormat,
01233 Direction direction,
01234 unsigned numFrames,
01235 PINDEX codecTableIndex
01236 );
01237
01254 virtual BOOL Read(
01255 BYTE * buffer,
01256 unsigned & length,
01257 RTP_DataFrame & rtpFrame
01258 );
01259
01272 virtual BOOL Write(
01273 const BYTE * buffer,
01274 unsigned length,
01275 const RTP_DataFrame & frame,
01276 unsigned & written
01277 );
01278
01285 virtual BOOL IsRawDataChannelNative() const;
01286
01293 virtual BOOL DetectSilence();
01294
01299 virtual unsigned GetAverageSignalLevel();
01300
01301
01302 PINDEX GetCodecTableIndex() const { return codecTableIndex; }
01303
01304 protected:
01305 PINDEX codecTableIndex;
01306 unsigned packetSize;
01307 unsigned missedCount;
01308 BYTE lastSID[4];
01309 BOOL lastFrameWasSignal;
01310 };
01311
01312
01313 #endif // __OPAL_LID_H
01314
01315
01316