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
#ifndef __OPAL_LID_H
00220
#define __OPAL_LID_H
00221
00222
#ifdef P_USE_PRAGMA
00223
#pragma interface
00224
#endif
00225
00226
00227
#include "codecs.h"
00228
#include "h323caps.h"
00229
00230
00232
00236 class OpalLineInterfaceDevice :
public PObject
00237 {
00238 PCLASSINFO(
OpalLineInterfaceDevice, PObject);
00239
00240
public:
00243
OpalLineInterfaceDevice();
00244
00247
virtual BOOL
Open(
00248
const PString & device
00249 ) = 0;
00250
00253
virtual BOOL
IsOpen()
const;
00254
00257
virtual BOOL
Close();
00258
00264
virtual PString
GetName()
const = 0;
00265
00268
virtual unsigned GetLineCount() = 0;
00269
00276
virtual BOOL
IsLineTerminal(
00277
unsigned line
00278 );
00279
00280
00283
virtual BOOL
IsLinePresent(
00284
unsigned line,
00285 BOOL force = FALSE
00286 );
00287
00288
00294
virtual BOOL
IsLineOffHook(
00295
unsigned line
00296 ) = 0;
00297
00303
virtual BOOL
SetLineOffHook(
00304
unsigned line,
00305 BOOL newState = TRUE
00306 ) = 0;
00307
00311 virtual BOOL
SetLineOnHook(
00312
unsigned line
00313 ) {
return SetLineOffHook(line, FALSE); }
00314
00318
virtual BOOL HookFlash(
00319
unsigned line,
00320
unsigned flashTime = 200
00321 );
00322
00325
virtual BOOL HasHookFlash(
unsigned line);
00326
00327
00338
virtual BOOL IsLineRinging(
00339
unsigned line,
00340 DWORD * cadence = NULL
00341 );
00342
00353
virtual BOOL RingLine(
00354
unsigned line,
00355 DWORD cadence
00356 );
00357
00372
virtual BOOL RingLine(
00373
unsigned line,
00374 PINDEX nCadence,
00375
unsigned * pattern
00376 );
00377
00378
00382
virtual BOOL IsLineDisconnected(
00383
unsigned line,
00384 BOOL checkForWink = TRUE
00385 );
00386
00387
00390
virtual BOOL SetLineToLineDirect(
00391
unsigned line1,
00392
unsigned line2,
00393 BOOL connect
00394 );
00395
00398
virtual BOOL IsLineToLineDirect(
00399
unsigned line1,
00400
unsigned line2
00401 );
00402
00403
00406
virtual OpalMediaFormat::List
GetMediaFormats() const = 0;
00407
00410 virtual BOOL SetReadFormat(
00411
unsigned line,
00412 const
OpalMediaFormat & mediaFormat
00413 ) = 0;
00414
00417 virtual BOOL SetWriteFormat(
00418
unsigned line,
00419 const
OpalMediaFormat & mediaFormat
00420 ) = 0;
00421
00424 virtual
OpalMediaFormat GetReadFormat(
00425
unsigned line
00426 ) = 0;
00427
00430 virtual
OpalMediaFormat GetWriteFormat(
00431
unsigned line
00432 ) = 0;
00433
00442 virtual BOOL SetReadCodec(
00443
unsigned line,
00444
RTP_DataFrame::PayloadTypes codec
00445 );
00446
00452 virtual BOOL SetWriteCodec(
00453
unsigned line,
00454
RTP_DataFrame::PayloadTypes codec
00455 );
00456
00467 virtual BOOL SetRawCodec(
00468
unsigned line
00469 );
00470
00473 virtual BOOL StopReadCodec(
00474
unsigned line
00475 );
00476
00479 virtual BOOL StopWriteCodec(
00480
unsigned line
00481 );
00482
00485 virtual BOOL StopRawCodec(
00486
unsigned line
00487 );
00488
00493 virtual BOOL SetReadFrameSize(
00494
unsigned line,
00495 PINDEX frameSize
00496 );
00497
00502 virtual BOOL SetWriteFrameSize(
00503
unsigned line,
00504 PINDEX frameSize
00505 );
00506
00510 virtual PINDEX GetReadFrameSize(
00511
unsigned line
00512 ) = 0;
00513
00517 virtual PINDEX GetWriteFrameSize(
00518
unsigned line
00519 ) = 0;
00520
00523 virtual BOOL ReadFrame(
00524
unsigned line,
00525
void * buf,
00526 PINDEX & count
00527 ) = 0;
00528
00531 virtual BOOL WriteFrame(
00532
unsigned line,
00533 const
void * buf,
00534 PINDEX count,
00535 PINDEX & written
00536 ) = 0;
00537
00541 virtual BOOL ReadBlock(
00542
unsigned line,
00543
void * buf,
00544 PINDEX count
00545 );
00546
00549 virtual BOOL WriteBlock(
00550
unsigned line,
00551 const
void * buf,
00552 PINDEX count
00553 );
00554
00555
00558 virtual
unsigned GetAverageSignalLevel(
00559
unsigned line,
00560 BOOL playback
00561 );
00562
00563
00566 virtual BOOL EnableAudio(
00567
unsigned line,
00568 BOOL enable = TRUE
00569 );
00570
00573 BOOL DisableAudio(
00574
unsigned line
00575 ) {
return EnableAudio(line, FALSE); }
00576
00579
virtual BOOL IsAudioEnabled(
00580
unsigned line
00581 );
00582
00583
00584
enum {
00585 MaxVolume = 100
00586 };
00587
00592
virtual BOOL
SetRecordVolume(
00593
unsigned line,
00594
unsigned volume
00595 );
00596
00601
virtual BOOL
SetPlayVolume(
00602
unsigned line,
00603
unsigned volume
00604 );
00605
00610
virtual BOOL
GetRecordVolume(
00611
unsigned line,
00612
unsigned & volume
00613 );
00614
00619
virtual BOOL
GetPlayVolume(
00620
unsigned line,
00621
unsigned & volume
00622 );
00623
00624
00625 enum AECLevels {
00626
AECOff,
00627
AECLow,
00628
AECMedium,
00629
AECHigh,
00630
AECAuto,
00631
AECAGC,
00632
AECError
00633 };
00634
00638
virtual AECLevels GetAEC(
00639
unsigned line
00640 );
00641
00645
virtual BOOL SetAEC(
00646
unsigned line,
00647 AECLevels level
00648 );
00649
00653
virtual unsigned GetWinkDuration(
00654
unsigned line
00655 );
00656
00660
virtual BOOL SetWinkDuration(
00661
unsigned line,
00662
unsigned winkDuration
00663 );
00664
00668
virtual BOOL GetVAD(
00669
unsigned line
00670 );
00671
00675
virtual BOOL SetVAD(
00676
unsigned line,
00677 BOOL enable
00678 );
00679
00680
00688
virtual BOOL GetCallerID(
00689
unsigned line,
00690 PString & idString,
00691 BOOL full = FALSE
00692 );
00693
00702
virtual BOOL SetCallerID(
00703
unsigned line,
00704
const PString & idString
00705 );
00706
00715
virtual BOOL SendCallerIDOnCallWaiting(
00716
unsigned line,
00717
const PString & idString
00718 );
00719
00722
virtual BOOL SendVisualMessageWaitingIndicator(
00723
unsigned line,
00724 BOOL on
00725 );
00726
00727
00728
enum {
00729 DefaultDTMFOnTime = 180,
00730 DefaultDTMFOffTime = 120
00731 };
00732
00736
virtual BOOL
PlayDTMF(
00737
unsigned line,
00738
const char * digits,
00739 DWORD onTime = DefaultDTMFOnTime,
00740 DWORD offTime = DefaultDTMFOffTime
00741 );
00742
00752
virtual char ReadDTMF(
00753
unsigned line
00754 );
00755
00760
virtual BOOL
GetRemoveDTMF(
00761
unsigned line
00762 );
00763
00768
virtual BOOL
SetRemoveDTMF(
00769
unsigned line,
00770 BOOL removeTones
00771 );
00772
00773
00774 enum CallProgressTones {
00775
NoTone = 0x00,
00776
DialTone = 0x01,
00777
RingTone = 0x02,
00778
BusyTone = 0x04,
00779
ClearTone = 0x08,
00780
CNGTone = 0x10,
00781
AllTones = 0x1f
00782 };
00783
00786
virtual unsigned IsToneDetected(
00787
unsigned line
00788 );
00789
00792
virtual unsigned WaitForToneDetect(
00793
unsigned line,
00794
unsigned timeout = 3000
00795 );
00796
00799
virtual BOOL WaitForTone(
00800
unsigned line,
00801 CallProgressTones tone,
00802
unsigned timeout = 3000
00803 );
00804
00822
virtual BOOL SetToneFilter(
00823
unsigned line,
00824 CallProgressTones tone,
00825
const PString & description
00826 );
00827
00830
virtual BOOL SetToneFilterParameters(
00831
unsigned line,
00832 CallProgressTones tone,
00833
unsigned lowFrequency,
00834
unsigned highFrequency,
00835 PINDEX numCadences,
00836
const unsigned * onTimes,
00837
const unsigned * offTimes
00838 );
00839
00842
virtual BOOL PlayTone(
00843
unsigned line,
00844 CallProgressTones tone
00845 );
00846
00849
virtual BOOL IsTonePlaying(
00850
unsigned line
00851 );
00852
00855
virtual BOOL StopTone(
00856
unsigned line
00857 );
00858
00861
virtual BOOL PlayAudio(
00862
unsigned line,
00863
const PString & filename
00864 );
00865
00868
virtual BOOL StopAudio(
00869
unsigned line
00870 );
00871
00872
00888
virtual CallProgressTones DialOut(
00889
unsigned line,
00890
const PString & number,
00891 BOOL requireTones = FALSE
00892 );
00893
00894
00895 enum T35CountryCodes {
00896
Japan,
Albania,
Algeria,
AmericanSamoa,
Germany,
Anguilla,
AntiguaAndBarbuda,
00897
Argentina,
Ascension,
Australia,
Austria,
Bahamas,
Bahrain,
Bangladesh,
00898
Barbados,
Belgium,
Belize,
Benin,
Bermudas,
Bhutan,
Bolivia,
Botswana,
00899
Brazil,
BritishAntarcticTerritory,
BritishIndianOceanTerritory,
00900
BritishVirginIslands,
BruneiDarussalam,
Bulgaria,
Myanmar,
Burundi,
00901
Byelorussia,
Cameroon,
Canada,
CapeVerde,
CaymanIslands,
00902
CentralAfricanRepublic,
Chad,
Chile,
China,
Colombia,
Comoros,
Congo,
00903
CookIslands,
CostaRica,
Cuba,
Cyprus,
Czechoslovakia,
Cambodia,
00904
DemocraticPeoplesRepublicOfKorea,
Denmark,
Djibouti,
DominicanRepublic,
00905
Dominica,
Ecuador,
Egypt,
ElSalvador,
EquatorialGuinea,
Ethiopia,
00906
FalklandIslands,
Fiji,
Finland,
France,
FrenchPolynesia,
00907
FrenchSouthernAndAntarcticLands,
Gabon,
Gambia,
Germany2,
Angola,
Ghana,
00908
Gibraltar,
Greece,
Grenada,
Guam,
Guatemala,
Guernsey,
Guinea,
GuineaBissau,
00909
Guayana,
Haiti,
Honduras,
Hongkong,
Hungary,
Iceland,
India,
Indonesia,
00910
Iran,
Iraq,
Ireland,
Israel,
Italy,
CotedIvoire,
Jamaica,
Afghanistan,
00911
Jersey,
Jordan,
Kenya,
Kiribati,
KoreaRepublic,
Kuwait,
Lao,
Lebanon,
00912
Lesotho,
Liberia,
Libya,
Liechtenstein,
Luxemborg,
Macao,
Madagascar,
00913
Malaysia,
Malawi,
Maldives,
Mali,
Malta,
Mauritania,
Mauritius,
Mexico,
00914
Monaco,
Mongolia,
Montserrat,
Morocco,
Mozambique,
Nauru,
Nepal,
00915
Netherlands,
NetherlandsAntilles,
NewCaledonia,
NewZealand,
Nicaragua,
00916
Niger,
Nigeria,
Norway,
Oman,
Pakistan,
Panama,
PapuaNewGuinea,
Paraguay,
00917
Peru,
Philippines,
Poland,
Portugal,
PuertoRico,
Qatar,
Romania,
Rwanda,
00918
SaintKittsAndNevis,
SaintCroix,
SaintHelenaAndAscension,
SaintLucia,
00919
SanMarino,
SaintThomas,
SaoTomeAndPrincipe,
SaintVicentAndTheGrenadines,
00920
SaudiArabia,
Senegal,
Seychelles,
SierraLeone,
Singapore,
SolomonIslands,
00921
Somalia,
SouthAfrica,
Spain,
SriLanka,
Sudan,
Suriname,
Swaziland,
Sweden,
00922
Switzerland,
Syria,
Tanzania,
Thailand,
Togo,
Tonga,
TrinidadAndTobago,
00923
Tunisia,
Turkey,
TurksAndCaicosIslands,
Tuvalu,
Uganda,
Ukraine,
00924
UnitedArabEmirates,
UnitedKingdom,
UnitedStates,
BurkinaFaso,
Uruguay,
00925
USSR,
Vanuatu,
VaticanCityState,
Venezuela,
VietNam,
WallisAndFutuna,
00926
WesternSamoa,
Yemen,
Yemen2,
Yugoslavia,
Zaire,
Zambia,
Zimbabwe,
00927
NumCountryCodes,
00928
UnknownCountry = -1
00929 };
00930
00933 T35CountryCodes GetCountryCode()
const {
return countryCode; }
00934
00937 PString
GetCountryCodeName() const;
00938
00941 static PString GetCountryCodeName(T35CountryCodes code);
00942 static T35CountryCodes GetCountryCode(const PString & name);
00943
00949 virtual BOOL SetCountryCode(
00950 T35CountryCodes country
00951 );
00952
00955 virtual BOOL SetCountryCodeName(
00956 const PString & countryName
00957 );
00958
00961 virtual PStringList GetCountryCodeNameList() const;
00962
00963
00966 int GetErrorNumber()
const {
return osError; }
00967
00970 PString
GetErrorText() const;
00971
00972 virtual
void PrintOn(
00973 ostream & strm
00974 ) const;
00975
00976 protected:
00977 int os_handle;
00978 int osError;
00979 T35CountryCodes countryCode;
00980 PBYTEArray readDeblockingBuffer, writeDeblockingBuffer;
00981 PINDEX readDeblockingOffset, writeDeblockingOffset;
00982
00983 #if PTRACING
00984 friend ostream & operator<<(ostream & o, CallProgressTones t);
00985 #endif
00986 };
00987
00988
00991 class
OpalLineChannel : public PChannel
00992 {
00993 PCLASSINFO(
OpalLineChannel, PChannel);
00994
00995
public:
00998
OpalLineChannel(
00999
OpalLineInterfaceDevice & device,
01000
unsigned line,
01001
const H323AudioCodec & codec
01002 );
01003 ~
OpalLineChannel();
01004
01007 PString
GetName()
const;
01008
01011 BOOL
Close();
01012
01025
virtual BOOL Read(
01026
void * buf,
01027 PINDEX len
01028 );
01029
01041
virtual BOOL Write(
01042
const void * buf,
01043 PINDEX len
01044 );
01045
01046
01049 OpalLineInterfaceDevice & GetDevice()
const {
return device; }
01050
01053 unsigned GetLineNumber()
const {
return lineNumber; }
01054
01055
01056
protected:
01057 OpalLineInterfaceDevice & device;
01058 unsigned lineNumber;
01059 BOOL reading;
01060 BOOL useDeblocking;
01061 };
01062
01063
01064
01065
01066
01069 class H323_LIDCapability :
public H323AudioCapability
01070 {
01071 PCLASSINFO(
H323_LIDCapability,
H323AudioCapability);
01072
01073
public:
01078
H323_LIDCapability(
01079
const OpalMediaFormat & mediaFormat
01080 );
01082
01087 Comparison Compare(
const PObject & obj)
const;
01088
01091
virtual PObject * Clone()
const;
01092
01095
virtual PString GetFormatName()
const;
01097
01105
virtual unsigned GetSubType()
const;
01107
01112
virtual H323Codec * CreateCodec(
01113 H323Codec::Direction direction
01114 )
const;
01115
01118 BOOL IsValid()
const;
01119
01122
static void AddAllCapabilities(
01123
const OpalLineInterfaceDevice & device,
01124
H323Capabilities & capabilities,
01125 PINDEX descriptorNum,
01126 PINDEX simultaneous
01127 );
01129
01139
virtual BOOL OnSendingPDU(
01140
H245_AudioCapability & pdu,
01141
unsigned packetSize
01142 )
const;
01143
01151
virtual BOOL OnReceivedPDU(
01152
const H245_AudioCapability & pdu,
01153
unsigned & packetSize
01154 );
01156
01157
protected:
01158 OpalMediaFormat mediaFormat;
01159 PINDEX codecTableIndex;
01160 };
01161
01162
01165 class H323_CiscoG7231aLIDCapability :
public H323NonStandardAudioCapability
01166 {
01167 PCLASSINFO(
H323_CiscoG7231aLIDCapability,
H323NonStandardAudioCapability);
01168
01169
public:
01174
H323_CiscoG7231aLIDCapability();
01176
01181
virtual PObject * Clone()
const;
01183
01188
virtual H323Codec * CreateCodec(
01189 H323Codec::Direction direction
01190 )
const;
01192
01197
virtual PString GetFormatName()
const;
01199 };
01200
01201
01205 class H323_LIDCodec :
public H323AudioCodec
01206 {
01207 PCLASSINFO(
H323_LIDCodec,
H323AudioCodec);
01208
01209
public:
01212
H323_LIDCodec(
01213
const char * mediaFormat,
01214 Direction direction,
01215
unsigned numFrames,
01216 PINDEX codecTableIndex
01217 );
01218
01235
virtual BOOL Read(
01236 BYTE * buffer,
01237
unsigned & length,
01238
RTP_DataFrame & rtpFrame
01239 );
01240
01253
virtual BOOL Write(
01254
const BYTE * buffer,
01255
unsigned length,
01256
const RTP_DataFrame & frame,
01257
unsigned & written
01258 );
01259
01266
virtual BOOL IsRawDataChannelNative()
const;
01267
01274
virtual BOOL DetectSilence();
01275
01280
virtual unsigned GetAverageSignalLevel();
01281
01282
01283 PINDEX GetCodecTableIndex()
const {
return codecTableIndex; }
01284
01285
protected:
01286 PINDEX codecTableIndex;
01287 unsigned packetSize;
01288 unsigned missedCount;
01289 BYTE lastSID[4];
01290 BOOL lastFrameWasSignal;
01291 };
01292
01293
01294
#endif // __OPAL_LID_H
01295
01296
01297