lid.h

Go to the documentation of this file.
00001 /*
00002  * lid.h
00003  *
00004  * Line Interface Device
00005  *
00006  * Open Phone Abstraction Library
00007  *
00008  * Copyright (c) 1999-2001 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Open H323 Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions of this code were written with the assisance of funding from 
00025  * Quicknet Technologies, Inc. http://www.quicknet.net.
00026  * 
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: lid.h,v $
00030  * Revision 2.17  2006/11/05 05:04:46  rjongbloed
00031  * Improved the terminal LID line ringing, epecially for country emulation.
00032  *
00033  * Revision 2.16  2006/10/25 22:26:14  rjongbloed
00034  * Changed LID tone handling to use new tone generation for accurate country based tones.
00035  *
00036  * Revision 2.15  2006/10/22 12:05:54  rjongbloed
00037  * Fixed correct usage of read/write buffer sizes in LID endpoints.
00038  *
00039  * Revision 2.14  2006/10/15 06:27:16  rjongbloed
00040  * Fixed problem with duplicate registrations of LID plug ins.
00041  * Added code to remember if line audio was enabled/disabled, helps with LID endpoint logic.
00042  *
00043  * Revision 2.13  2006/10/02 13:30:50  rjongbloed
00044  * Added LID plug ins
00045  *
00046  * Revision 2.12  2006/06/27 13:50:24  csoutheren
00047  * Patch 1375137 - Voicetronix patches and lid enhancements
00048  * Thanks to Frederich Heem
00049  *
00050  * Revision 2.11  2005/11/30 13:35:26  csoutheren
00051  * Changed tags for Doxygen
00052  *
00053  * Revision 2.10  2004/10/06 13:03:41  rjongbloed
00054  * Added "configure" support for known LIDs
00055  * Changed LID GetName() function to be normalised against the GetAllNames()
00056  *   return values and fixed the pre-factory registration system.
00057  * Added a GetDescription() function to do what the previous GetName() did.
00058  *
00059  * Revision 2.9  2004/02/19 10:46:44  rjongbloed
00060  * Merged OpenH323 version 1.13.1 changes.
00061  *
00062  * Revision 2.8  2003/03/24 07:18:29  robertj
00063  * Added registration system for LIDs so can work with various LID types by
00064  *   name instead of class instance.
00065  *
00066  * Revision 2.7  2002/11/10 11:33:17  robertj
00067  * Updated to OpenH323 v1.10.3
00068  *
00069  * Revision 2.6  2002/09/16 02:52:34  robertj
00070  * Added #define so can select if #pragma interface/implementation is used on
00071  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00072  *
00073  * Revision 2.5  2002/09/04 06:01:47  robertj
00074  * Updated to OpenH323 v1.9.6
00075  *
00076  * Revision 2.4  2002/07/01 04:56:30  robertj
00077  * Updated to OpenH323 v1.9.1
00078  *
00079  * Revision 2.3  2002/02/11 09:32:12  robertj
00080  * Updated to openH323 v1.8.0
00081  *
00082  * Revision 2.2  2001/08/17 01:10:48  robertj
00083  * Added ability to add whole LID's to LID endpoint.
00084  *
00085  * Revision 2.1  2001/08/01 05:18:51  robertj
00086  * Made OpalMediaFormatList class global to help with documentation.
00087  *
00088  * Revision 2.0  2001/07/27 15:48:24  robertj
00089  * Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
00090  *
00091  * Revision 1.56  2003/04/29 08:29:13  robertj
00092  * Cleaned up documentation for new wink duration functions.
00093  *
00094  * Revision 1.55  2003/04/28 01:47:52  dereks
00095  * Add ability to set/get wink duration for ixj device.
00096  *
00097  * Revision 1.54  2003/03/05 06:26:40  robertj
00098  * Added function to play a WAV file to LID, thanks Pietro Ravasio
00099  *
00100  * Revision 1.53  2002/11/05 04:26:48  robertj
00101  * Imported RingLine() by array from OPAL.
00102  *
00103  * Revision 1.52  2002/10/29 00:46:04  dereks
00104  * Fix typo in comments.
00105  *
00106  * Revision 1.51  2002/09/16 01:14:15  robertj
00107  * Added #define so can select if #pragma interface/implementation is used on
00108  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00109  *
00110  * Revision 1.50  2002/09/03 06:19:37  robertj
00111  * Normalised the multi-include header prevention ifdef/define symbol.
00112  *
00113  * Revision 1.49  2002/08/05 10:03:47  robertj
00114  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00115  *
00116  * Revision 1.48  2002/06/27 08:52:53  robertj
00117  * Fixed typo and naming convention for Cisco G.723.1 annex A capability.
00118  *
00119  * Revision 1.47  2002/06/26 05:45:41  robertj
00120  * Added capability for Cisco IOS non-standard name for G.723.1 Annex A so
00121  *   can now utilise SID frames with Cisco gateways.
00122  *
00123  * Revision 1.46  2002/06/25 08:30:08  robertj
00124  * Changes to differentiate between stright G.723.1 and G.723.1 Annex A using
00125  *   the OLC dataType silenceSuppression field so does not send SID frames
00126  *   to receiver codecs that do not understand them.
00127  *
00128  * Revision 1.45  2002/05/09 06:26:30  robertj
00129  * Added fuction to get the current audio enable state for line in device.
00130  * Changed IxJ EnableAudio() semantics so is exclusive, no direct switching
00131  *   from PSTN to POTS and vice versa without disabling the old one first.
00132  *
00133  * Revision 1.44  2002/01/23 01:58:25  robertj
00134  * Added function to determine if codecs raw data channel is native format.
00135  *
00136  * Revision 1.43  2001/07/19 05:54:27  robertj
00137  * Updated interface to xJACK drivers to utilise cadence and filter functions
00138  *   for dial tone, busy tone and ringback tone detection.
00139  *
00140  * Revision 1.42  2001/05/22 00:31:41  robertj
00141  * Changed to allow optional wink detection for line disconnect
00142  *
00143  * Revision 1.41  2001/03/29 23:42:34  robertj
00144  * Added ability to get average signal level for both receive and transmit.
00145  * Changed silence detection to use G.723.1 SID frames as indicator of
00146  *   silence instead of using the average energy and adaptive threshold.
00147  *
00148  * Revision 1.40  2001/02/13 05:02:39  craigs
00149  * Extended PlayDTMF to allow generation of additional simple tones
00150  *
00151  * Revision 1.39  2001/02/09 05:16:24  robertj
00152  * Added #pragma interface for GNU C++.
00153  *
00154  * Revision 1.38  2001/01/25 07:27:14  robertj
00155  * Major changes to add more flexible OpalMediaFormat class to normalise
00156  *   all information about media types, especially codecs.
00157  *
00158  * Revision 1.37  2001/01/24 05:34:49  robertj
00159  * Altered volume control range to be percentage, ie 100 is max volume.
00160  *
00161  * Revision 1.36  2001/01/11 05:39:44  robertj
00162  * Fixed usage of G.723.1 CNG 1 byte frames.
00163  *
00164  * Revision 1.35  2000/12/19 06:38:57  robertj
00165  * Fixed missing virtual on IsTonePlaying() function.
00166  *
00167  * Revision 1.34  2000/12/17 22:08:20  craigs
00168  * Changed GetCountryCodeList to return PStringList
00169  *
00170  * Revision 1.33  2000/12/11 01:23:32  craigs
00171  * Added extra routines to allow country string manipulation
00172  *
00173  * Revision 1.32  2000/11/30 08:48:35  robertj
00174  * Added functions to enable/disable Voice Activity Detection in LID's
00175  *
00176  * Revision 1.31  2000/11/26 23:12:18  craigs
00177  * Added hook flash detection API
00178  *
00179  * Revision 1.30  2000/11/24 10:46:12  robertj
00180  * Added a raw PCM dta mode for generating/detecting standard tones.
00181  * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
00182  *
00183  * Revision 1.29  2000/11/20 03:15:13  craigs
00184  * Changed tone detection API slightly to allow detection of multiple
00185  * simultaneous tones
00186  * Added fax CNG tone to tone list
00187  *
00188  * Revision 1.28  2000/11/06 02:00:18  eokerson
00189  * Added support for AGC on ixj devices under Linux.
00190  *
00191  * Revision 1.27  2000/11/03 06:22:48  robertj
00192  * Added flag to IsLinePresent() to force slow test, guarenteeing correct value.
00193  *
00194  * Revision 1.26  2000/10/13 02:24:06  robertj
00195  * Moved frame reblocking code from LID channel to LID itself and added
00196  *    ReadBlock/WriteBlock functions to allow non integral frame sizes.
00197  *
00198  * Revision 1.25  2000/09/25 22:31:19  craigs
00199  * Added G.723.1 frame erasure capability
00200  *
00201  * Revision 1.24  2000/09/23 07:20:28  robertj
00202  * Fixed problem with being able to distinguish between sw and hw codecs in LID channel.
00203  *
00204  * Revision 1.23  2000/09/22 01:35:03  robertj
00205  * Added support for handling LID's that only do symmetric codecs.
00206  *
00207  * Revision 1.22  2000/08/31 13:14:40  craigs
00208  * Added functions to LID
00209  * More bulletproofing to Linux driver
00210  *
00211  * Revision 1.21  2000/08/30 23:24:24  robertj
00212  * Renamed string version of SetCountrCode() to SetCountryCodeName() to avoid
00213  *    C++ masking ancestor overloaded function when overriding numeric version.
00214  *
00215  * Revision 1.20  2000/08/18 04:17:48  robertj
00216  * Added Auto setting to AEC enum.
00217  *
00218  * Revision 1.19  2000/06/19 00:32:13  robertj
00219  * Changed functionf or adding all lid capabilities to not assume it is to an endpoint.
00220  *
00221  * Revision 1.18  2000/06/01 07:52:19  robertj
00222  * Changed some LID capability code back again so does not unneedfully break existing API.
00223  *
00224  * Revision 1.17  2000/05/30 10:19:17  robertj
00225  * Added function to add capabilities given a LID.
00226  * Improved LID capabilities so cannot create one that is not explicitly supported.
00227  *
00228  * Revision 1.16  2000/05/24 06:42:18  craigs
00229  * Added calls to get volume settings
00230  *
00231  * Revision 1.15  2000/05/10 04:05:26  robertj
00232  * Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
00233  *
00234  * Revision 1.14  2000/05/02 04:32:24  robertj
00235  * Fixed copyright notice comment.
00236  *
00237  * Revision 1.13  2000/04/14 17:18:25  robertj
00238  * Fixed problem with error reporting from LID hardware.
00239  *
00240  * Revision 1.12  2000/04/10 17:44:52  robertj
00241  * Added higher level "DialOut" function for PSTN lines.
00242  * Added hook flash function.
00243  *
00244  * Revision 1.11  2000/04/05 18:04:12  robertj
00245  * Changed caller ID code for better portability.
00246  *
00247  * Revision 1.10  2000/03/30 23:10:50  robertj
00248  * Fixed error in comments regarding GetFramerate() function.
00249  *
00250  * Revision 1.9  2000/03/29 20:54:19  robertj
00251  * Added function on LID to get available codecs.
00252  * Changed codec to use number of frames rather than number of bytes.
00253  *
00254  * Revision 1.8  2000/03/23 23:36:48  robertj
00255  * Added more calling tone detection functionality.
00256  *
00257  * Revision 1.7  2000/03/23 02:43:15  robertj
00258  * Fixed default DTMF timing.
00259  *
00260  * Revision 1.6  2000/03/22 17:18:49  robertj
00261  * Changed default DTMF tone string times.
00262  *
00263  * Revision 1.5  2000/03/21 03:06:48  robertj
00264  * Changes to make RTP TX of exact numbers of frames in some codecs.
00265  *
00266  * Revision 1.4  2000/01/13 12:39:29  robertj
00267  * Added string based country codes to LID.
00268  *
00269  * Revision 1.3  2000/01/13 04:03:45  robertj
00270  * Added video transmission
00271  *
00272  * Revision 1.2  2000/01/07 08:28:09  robertj
00273  * Additions and changes to line interface device base class.
00274  *
00275  * Revision 1.1  1999/12/23 23:02:35  robertj
00276  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00277  *
00278  */
00279 
00280 #ifndef __OPAL_LID_H
00281 #define __OPAL_LID_H
00282 
00283 #ifdef P_USE_PRAGMA
00284 #pragma interface
00285 #endif
00286 
00287 
00288 #include <opal/mediafmt.h>
00289 
00290 
00292 
00296 class OpalLineInterfaceDevice : public PObject
00297 {
00298   PCLASSINFO(OpalLineInterfaceDevice, PObject);
00299 
00300   public:
00303     OpalLineInterfaceDevice();
00304 
00307     virtual BOOL Open(
00308       const PString & device      
00309     ) = 0;
00310 
00313     virtual BOOL IsOpen() const;
00314 
00317     virtual BOOL Close();
00318 
00322     virtual PString GetDeviceType() const = 0;
00323 
00328     virtual PString GetDeviceName() const = 0;
00329 
00332     virtual PStringArray GetAllNames() const = 0;
00333 
00339     virtual PString GetDescription() const = 0;
00340 
00343     virtual unsigned GetLineCount() = 0;
00344 
00351     virtual BOOL IsLineTerminal(
00352       unsigned line   
00353     ) = 0;
00354 
00355 
00358     virtual BOOL IsLinePresent(
00359       unsigned line,      
00360       BOOL force = FALSE  
00361     );
00362 
00363 
00369     virtual BOOL IsLineOffHook(
00370       unsigned line   
00371     ) = 0;
00372 
00378     virtual BOOL SetLineOffHook(
00379       unsigned line,        
00380       BOOL newState = TRUE  
00381     ) = 0;
00382 
00386     virtual BOOL SetLineOnHook(
00387       unsigned line        
00388     ) { return SetLineOffHook(line, FALSE); }
00389 
00393     virtual BOOL HookFlash(
00394       unsigned line,              
00395       unsigned flashTime = 200    
00396     );
00397 
00400     virtual BOOL HasHookFlash(unsigned line);
00401 
00402 
00413     virtual BOOL IsLineRinging(
00414       unsigned line,          
00415       DWORD * cadence = NULL  
00416     );
00417 
00435     virtual BOOL RingLine(
00436       unsigned line,                   
00437       PINDEX nCadence,                 
00438       const unsigned * pattern = NULL, 
00439       unsigned frequency = 400         
00440     );
00441 
00442 
00449     virtual BOOL IsLineDisconnected(
00450       unsigned line,   
00451       BOOL checkForWink = TRUE
00452     );
00453 
00454 
00457     virtual BOOL SetLineToLineDirect(
00458       unsigned line1,   
00459       unsigned line2,   
00460       BOOL connect      
00461     );
00462 
00465     virtual BOOL IsLineToLineDirect(
00466       unsigned line1,   
00467       unsigned line2    
00468     );
00469 
00470 
00473     virtual OpalMediaFormatList GetMediaFormats() const = 0;
00474 
00477     virtual BOOL SetReadFormat(
00478       unsigned line,    
00479       const OpalMediaFormat & mediaFormat   
00480     ) = 0;
00481 
00484     virtual BOOL SetWriteFormat(
00485       unsigned line,    
00486       const OpalMediaFormat & mediaFormat   
00487     ) = 0;
00488 
00491     virtual OpalMediaFormat GetReadFormat(
00492       unsigned line    
00493     ) = 0;
00494 
00497     virtual OpalMediaFormat GetWriteFormat(
00498       unsigned line    
00499     ) = 0;
00500 
00503     virtual BOOL StopReading(
00504       unsigned line   
00505     );
00506 
00509     virtual BOOL StopWriting(
00510       unsigned line   
00511     );
00512 
00517     virtual BOOL SetReadFrameSize(
00518       unsigned line,    
00519       PINDEX frameSize  
00520     ) = 0;
00521 
00526     virtual BOOL SetWriteFrameSize(
00527       unsigned line,    
00528       PINDEX frameSize  
00529     ) = 0;
00530 
00534     virtual PINDEX GetReadFrameSize(
00535       unsigned line   
00536     ) = 0;
00537 
00541     virtual PINDEX GetWriteFrameSize(
00542       unsigned line   
00543     ) = 0;
00544 
00547     virtual BOOL ReadFrame(
00548       unsigned line,    
00549       void * buf,       
00550       PINDEX & count    
00551     ) = 0;
00552 
00555     virtual BOOL WriteFrame(
00556       unsigned line,    
00557       const void * buf, 
00558       PINDEX count,     
00559       PINDEX & written  
00560     ) = 0;
00561 
00565     virtual BOOL ReadBlock(
00566       unsigned line,    
00567       void * buf,   
00568       PINDEX count  
00569     );
00570 
00573     virtual BOOL WriteBlock(
00574       unsigned line,    
00575       const void * buf, 
00576       PINDEX count      
00577     );
00578 
00579 
00582     virtual unsigned GetAverageSignalLevel(
00583       unsigned line,  
00584       BOOL playback   
00585     );
00586 
00587 
00590     virtual BOOL EnableAudio(
00591       unsigned line,      
00592       BOOL enable = TRUE
00593     );
00594 
00597     BOOL DisableAudio(
00598       unsigned line   
00599     ) { return EnableAudio(line, FALSE); }
00600 
00603     virtual BOOL IsAudioEnabled(
00604       unsigned line      
00605     );
00606 
00607 
00608     enum {
00609       MaxVolume = 100
00610     };
00611 
00616     virtual BOOL SetRecordVolume(
00617       unsigned line,    
00618       unsigned volume   
00619     );
00620 
00625     virtual BOOL SetPlayVolume(
00626       unsigned line,    
00627       unsigned volume   
00628     );
00629 
00634     virtual BOOL GetRecordVolume(
00635       unsigned line,      
00636       unsigned & volume   
00637     );
00638 
00643     virtual BOOL GetPlayVolume(
00644       unsigned line,      
00645       unsigned & volume   
00646     );
00647 
00648 
00649     enum AECLevels {
00650       AECOff,
00651       AECLow,
00652       AECMedium,
00653       AECHigh,
00654       AECAuto,
00655       AECAGC,
00656       AECError
00657     };
00658 
00662     virtual AECLevels GetAEC(
00663       unsigned line    
00664     );
00665 
00669     virtual BOOL SetAEC(
00670       unsigned line,    
00671       AECLevels level   
00672     );
00673 
00677     virtual BOOL GetVAD(
00678       unsigned line    
00679     );
00680 
00684     virtual BOOL SetVAD(
00685       unsigned line,    
00686       BOOL enable       
00687     );
00688 
00689 
00697     virtual BOOL GetCallerID(
00698       unsigned line,      
00699       PString & idString, 
00700       BOOL full = FALSE   
00701     );
00702 
00711     virtual BOOL SetCallerID(
00712       unsigned line,            
00713       const PString & idString  
00714     );
00715 
00724     virtual BOOL SendCallerIDOnCallWaiting(
00725       unsigned line,            
00726       const PString & idString  
00727     );
00728 
00731     virtual BOOL SendVisualMessageWaitingIndicator(
00732       unsigned line,            
00733       BOOL on
00734     );
00735 
00736 
00737     enum {
00738       DefaultDTMFOnTime = 180,
00739       DefaultDTMFOffTime = 120
00740     };
00741 
00745     virtual BOOL PlayDTMF(
00746       unsigned line,            
00747       const char * digits,      
00748       DWORD onTime = DefaultDTMFOnTime,  
00749       DWORD offTime = DefaultDTMFOffTime 
00750     );
00751 
00761     virtual char ReadDTMF(
00762       unsigned line   
00763     );
00764 
00769     virtual BOOL GetRemoveDTMF(
00770       unsigned line   
00771     );
00772 
00777     virtual BOOL SetRemoveDTMF(
00778       unsigned line,     
00779       BOOL removeTones   
00780     );
00781 
00782 
00783     enum CallProgressTones {
00784       NoTone = -1, // indicates no tones
00785       DialTone,    // Dial tone
00786       RingTone,    // Ring indication tone
00787       BusyTone,    // Line engaged tone
00788       CongestionTone,// aka fast busy tone
00789       ClearTone,   // Call failed/disconnected tone (often same as busy tone)
00790       MwiTone,     // Message Waiting Tone
00791       CNGTone,     // Fax CNG tone
00792       NumTones
00793     };
00794 
00797     virtual CallProgressTones IsToneDetected(
00798       unsigned line   
00799     );
00800 
00803     virtual CallProgressTones WaitForToneDetect(
00804       unsigned line,          
00805       unsigned timeout = 3000 
00806     );
00807 
00810     virtual BOOL WaitForTone(
00811       unsigned line,          
00812       CallProgressTones tone, 
00813       unsigned timeout = 3000 
00814     );
00815 
00833     virtual BOOL SetToneFilter(
00834       unsigned line,              
00835       CallProgressTones tone,     
00836       const PString & description 
00837     );
00838 
00841     virtual BOOL SetToneFilterParameters(
00842       unsigned line,            
00843       CallProgressTones tone,   
00844       unsigned lowFrequency,    
00845       unsigned highFrequency,   
00846       PINDEX numCadences,       
00847       const unsigned * onTimes, 
00848       const unsigned * offTimes 
00849     );
00850 
00853     virtual BOOL PlayTone(
00854       unsigned line,          
00855       CallProgressTones tone  
00856     );
00857 
00860     virtual BOOL IsTonePlaying(
00861       unsigned line   
00862     );
00863 
00866     virtual BOOL StopTone(
00867       unsigned line   
00868     );
00869 
00870 
00871     enum { DIAL_TONE_TIMEOUT = 10000 };
00872 
00888     virtual CallProgressTones DialOut(
00889       unsigned line,                
00890       const PString & number,       
00891       BOOL requireTones = FALSE,    
00892       unsigned uiDialDelay = 0      
00893     );
00894 
00895 
00899     virtual unsigned GetWinkDuration(
00900       unsigned line    
00901     );
00902 
00906     virtual BOOL SetWinkDuration(
00907       unsigned line,        
00908       unsigned winkDuration 
00909     );
00910 
00911 
00912     enum T35CountryCodes {
00913       Japan, Albania, Algeria, AmericanSamoa, Germany, Anguilla, AntiguaAndBarbuda,
00914       Argentina, Ascension, Australia, Austria, Bahamas, Bahrain, Bangladesh,
00915       Barbados, Belgium, Belize, Benin, Bermudas, Bhutan, Bolivia, Botswana,
00916       Brazil, BritishAntarcticTerritory, BritishIndianOceanTerritory, 
00917       BritishVirginIslands, BruneiDarussalam, Bulgaria, Myanmar, Burundi,
00918       Byelorussia, Cameroon, Canada, CapeVerde, CaymanIslands,
00919       CentralAfricanRepublic, Chad, Chile, China, Colombia, Comoros, Congo,
00920       CookIslands, CostaRica, Cuba, Cyprus, Czechoslovakia, Cambodia,
00921       DemocraticPeoplesRepublicOfKorea, Denmark, Djibouti, DominicanRepublic,
00922       Dominica, Ecuador, Egypt, ElSalvador, EquatorialGuinea, Ethiopia,
00923       FalklandIslands, Fiji, Finland, France, FrenchPolynesia,
00924       FrenchSouthernAndAntarcticLands, Gabon, Gambia, Germany2, Angola, Ghana,
00925       Gibraltar, Greece, Grenada, Guam, Guatemala, Guernsey, Guinea, GuineaBissau,
00926       Guayana, Haiti, Honduras, Hongkong, Hungary, Iceland, India, Indonesia,
00927       Iran, Iraq, Ireland, Israel, Italy, CotedIvoire, Jamaica, Afghanistan,
00928       Jersey, Jordan, Kenya, Kiribati, KoreaRepublic, Kuwait, Lao, Lebanon,
00929       Lesotho, Liberia, Libya, Liechtenstein, Luxemborg, Macao, Madagascar,
00930       Malaysia, Malawi, Maldives, Mali, Malta, Mauritania, Mauritius, Mexico,
00931       Monaco, Mongolia, Montserrat, Morocco, Mozambique, Nauru, Nepal,
00932       Netherlands, NetherlandsAntilles, NewCaledonia, NewZealand, Nicaragua,
00933       Niger, Nigeria, Norway, Oman, Pakistan, Panama, PapuaNewGuinea, Paraguay,
00934       Peru, Philippines, Poland, Portugal, PuertoRico, Qatar, Romania, Rwanda,
00935       SaintKittsAndNevis, SaintCroix, SaintHelenaAndAscension, SaintLucia,
00936       SanMarino, SaintThomas, SaoTomeAndPrincipe, SaintVicentAndTheGrenadines,
00937       SaudiArabia, Senegal, Seychelles, SierraLeone, Singapore, SolomonIslands,
00938       Somalia, SouthAfrica, Spain, SriLanka, Sudan, Suriname, Swaziland, Sweden,
00939       Switzerland, Syria, Tanzania, Thailand, Togo, Tonga, TrinidadAndTobago,
00940       Tunisia, Turkey, TurksAndCaicosIslands, Tuvalu, Uganda, Ukraine,
00941       UnitedArabEmirates, UnitedKingdom, UnitedStates, BurkinaFaso, Uruguay,
00942       USSR, Vanuatu, VaticanCityState, Venezuela, VietNam, WallisAndFutuna,
00943       WesternSamoa, Yemen, Yemen2, Yugoslavia, Zaire, Zambia, Zimbabwe,
00944       NumCountryCodes,
00945       UnknownCountry = -1
00946     };
00947 
00950     T35CountryCodes GetCountryCode() const { return countryCode; }
00951 
00954     PString GetCountryCodeName() const;
00955 
00958     static PString GetCountryCodeName(T35CountryCodes code);
00959     static T35CountryCodes GetCountryCode(const PString & name);
00960 
00966     virtual BOOL SetCountryCode(
00967       T35CountryCodes country   
00968     );
00969 
00972     virtual BOOL SetCountryCodeName(
00973       const PString & countryName   
00974     );
00975 
00978     virtual PStringList GetCountryCodeNameList() const;
00979 
00980 
00983     virtual BOOL PlayAudio(
00984       unsigned line,            
00985       const PString & filename  
00986     );
00987     
00990     virtual BOOL StopAudio(
00991       unsigned line   
00992     );
00993 
00994 
00998     virtual BOOL RecordAudioStart(
00999       unsigned line,            
01000       const PString & filename  
01001     );
01002     
01007     virtual BOOL RecordAudioStop(
01008       unsigned line            
01009     );
01010     
01011 
01014     int GetErrorNumber() const { return osError; }
01015 
01018     PString GetErrorText() const;
01019 
01020     virtual void PrintOn(
01021       ostream & strm
01022     ) const;
01023 
01026     static OpalLineInterfaceDevice * Create(
01027       const PString & type,     
01028       void * parameters = NULL  
01029     );
01030 
01033     static PStringList GetAllTypes();
01034 
01039     static PStringList GetAllDevices();
01040 
01041         
01042   protected:
01043     int    getOsHandle() const {return os_handle;};
01044     void   setOsHandle(int os_handleToSet) {os_handle = os_handleToSet;};
01045     
01046     int    getOsError() const {return osError;};
01047     void   setOsError(int osErrorToSet) {osError = osErrorToSet;};
01048     
01049     const PBYTEArray& getReadDeblockingBuffer(){return m_readDeblockingBuffer;};
01050     const PBYTEArray& getWriteDeblockingBuffer(){return m_writeDeblockingBuffer;};
01051     PINDEX getReadDeblockingOffset() const {return m_readDeblockingOffset;};
01052     void   setReadDeblockingOffset(PINDEX readDeblockingOffset) {m_readDeblockingOffset = readDeblockingOffset;};
01053     
01054     PINDEX getWriteDeblockingOffset() const {return m_writeDeblockingOffset;};
01055     void   setWriteDeblockingOffset(PINDEX writeDeblockingOffset) {m_writeDeblockingOffset = writeDeblockingOffset;};
01056     
01057     unsigned int getDialToneTimeout() const {return m_uiDialToneTimeout;};
01058     void   setDialToneTimeout(unsigned int uiDialToneTimeout) {m_uiDialToneTimeout = uiDialToneTimeout;};
01059         
01060     int               os_handle;
01061     mutable int       osError;
01062     T35CountryCodes   countryCode;
01063     PBYTEArray        m_readDeblockingBuffer, m_writeDeblockingBuffer;
01064     PINDEX            m_readDeblockingOffset, m_writeDeblockingOffset;
01065     unsigned int      m_uiDialToneTimeout;
01066     std::vector<bool> m_LineAudioEnabled;
01067     PString           m_callProgressTones[NumTones];
01068 #if PTRACING
01069     friend ostream & operator<<(ostream & o, CallProgressTones t);
01070 #endif
01071 };
01072 
01073 
01074 PLIST(OpalLIDList, OpalLineInterfaceDevice);
01075 
01076 
01077 
01080 class OpalLine : public PObject
01081 {
01082     PCLASSINFO(OpalLine, PObject);
01083   public:
01088     OpalLine(
01089       OpalLineInterfaceDevice & device, 
01090       unsigned lineNumber,              
01091       const char * description = NULL   
01092     );
01094 
01101     void PrintOn(
01102       ostream & strm    
01103     ) const;
01105 
01114     virtual BOOL IsTerminal() { return device.IsLineTerminal(lineNumber); }
01115 
01116 
01119     virtual BOOL IsPresent(
01120       BOOL force = FALSE  
01121     ) { return device.IsLinePresent(lineNumber, force); }
01122 
01123 
01129     virtual BOOL IsOffHook() { return device.IsLineOffHook(lineNumber); }
01130 
01136     virtual BOOL SetOffHook() { return device.SetLineOffHook(lineNumber, TRUE); }
01137 
01141     virtual BOOL SetOnHook() { return device.SetLineOffHook(lineNumber, FALSE); }
01142 
01146     virtual BOOL HookFlash(
01147       unsigned flashTime = 200    
01148     ) { return device.HookFlash(lineNumber, flashTime); }
01149 
01152     virtual BOOL HasHookFlash() { return device.HasHookFlash(lineNumber); }
01153 
01154 
01165     virtual BOOL IsRinging(
01166       DWORD * cadence = NULL  
01167     ) { return device.IsLineRinging(lineNumber, cadence); }
01168 
01172     virtual unsigned GetRingCount(
01173       DWORD * cadence = NULL  
01174     );
01175 
01193     virtual BOOL Ring(
01194       PINDEX nCadence,                 
01195       const unsigned * pattern = NULL, 
01196       unsigned frequency = 400         
01197     ) { return device.RingLine(lineNumber, nCadence, pattern, frequency); }
01198 
01199 
01203     virtual BOOL IsDisconnected() { return device.IsLineDisconnected(lineNumber); }
01204 
01207     virtual BOOL SetReadFormat(
01208       const OpalMediaFormat & mediaFormat   
01209     ) { return device.SetReadFormat(lineNumber, mediaFormat); }
01210 
01213     virtual BOOL SetWriteFormat(
01214       const OpalMediaFormat & mediaFormat   
01215     ) { return device.SetWriteFormat(lineNumber, mediaFormat); }
01216 
01219     virtual OpalMediaFormat GetReadFormat() { return device.GetReadFormat(lineNumber); }
01220 
01223     virtual OpalMediaFormat GetWriteFormat() { return device.GetWriteFormat(lineNumber); }
01224 
01227     virtual BOOL StopReading() { return device.StopReading(lineNumber); }
01228 
01231     virtual BOOL StopWriting() { return device.StopWriting(lineNumber); }
01232 
01237     virtual BOOL SetReadFrameSize(
01238       PINDEX frameSize  
01239     ) { return device.SetReadFrameSize(lineNumber, frameSize); }
01240 
01245     virtual BOOL SetWriteFrameSize(
01246       PINDEX frameSize  
01247     ) { return device.SetWriteFrameSize(lineNumber, frameSize); }
01248 
01252     virtual PINDEX GetReadFrameSize() { return device.GetReadFrameSize(lineNumber); }
01253 
01257     virtual PINDEX GetWriteFrameSize() { return device.GetWriteFrameSize(lineNumber); }
01258 
01261     virtual BOOL ReadFrame(
01262       void * buf,       
01263       PINDEX & count    
01264     ) { return device.ReadFrame(lineNumber, buf, count); }
01265 
01268     virtual BOOL WriteFrame(
01269       const void * buf, 
01270       PINDEX count,     
01271       PINDEX & written  
01272     ) { return device.WriteFrame(lineNumber, buf, count, written); }
01273 
01277     virtual BOOL ReadBlock(
01278       void * buf,   
01279       PINDEX count  
01280     ) { return device.ReadBlock(lineNumber, buf, count); }
01281 
01284     virtual BOOL WriteBlock(
01285       const void * buf, 
01286       PINDEX count      
01287     ) { return device.WriteBlock(lineNumber, buf, count); }
01288 
01289 
01292     virtual unsigned GetAverageSignalLevel(
01293       BOOL playback   
01294     ) { return device.GetAverageSignalLevel(lineNumber, playback); }
01295 
01296 
01299     virtual BOOL EnableAudio(
01300       BOOL enable = TRUE
01301     ) { return device.EnableAudio(lineNumber, enable); }
01302 
01305     BOOL DisableAudio() { return EnableAudio(FALSE); }
01306 
01309     virtual BOOL IsAudioEnabled() { return device.IsAudioEnabled(lineNumber); }
01310 
01311 
01316     virtual BOOL SetRecordVolume(
01317       unsigned volume   
01318     ) { return device.SetRecordVolume(lineNumber, volume); }
01319 
01324     virtual BOOL SetPlayVolume(
01325       unsigned volume   
01326     ) { return device.SetPlayVolume(lineNumber, volume); }
01327 
01332     virtual BOOL GetRecordVolume(
01333       unsigned & volume   
01334     ) { return device.GetRecordVolume(lineNumber, volume); }
01335 
01340     virtual BOOL GetPlayVolume(
01341       unsigned & volume   
01342     ) { return device.GetPlayVolume(lineNumber, volume); }
01343 
01344 
01348     virtual OpalLineInterfaceDevice::AECLevels GetAEC() { return device.GetAEC(lineNumber); }
01349 
01353     virtual BOOL SetAEC(
01354       OpalLineInterfaceDevice::AECLevels level  
01355     ) { return device.SetAEC(lineNumber, level); }
01356 
01357 
01361     virtual BOOL GetVAD() { return device.GetVAD(lineNumber); }
01362 
01366     virtual BOOL SetVAD(
01367       BOOL enable       
01368     ) { return device.SetVAD(lineNumber, enable); }
01369 
01370 
01378     virtual BOOL GetCallerID(
01379       PString & idString, 
01380       BOOL full = FALSE   
01381     ) { return device.GetCallerID(lineNumber, idString, full); }
01382 
01391     virtual BOOL SetCallerID(
01392       const PString & idString  
01393     ) { return device.SetCallerID(lineNumber, idString); }
01394 
01403     virtual BOOL SendCallerIDOnCallWaiting(
01404       const PString & idString  
01405     ) { return device.SendCallerIDOnCallWaiting(lineNumber, idString); }
01406 
01409     virtual BOOL SendVisualMessageWaitingIndicator(
01410       BOOL on
01411     ) { return device.SendVisualMessageWaitingIndicator(lineNumber, on); }
01412 
01413 
01417     virtual BOOL PlayDTMF(
01418       const char * digits,      
01419       DWORD onTime = OpalLineInterfaceDevice::DefaultDTMFOnTime,  
01420       DWORD offTime = OpalLineInterfaceDevice::DefaultDTMFOffTime 
01421     ) { return device.PlayDTMF(lineNumber, digits, onTime, offTime); }
01422 
01432     virtual char ReadDTMF() { return device.ReadDTMF(lineNumber); }
01433 
01438     virtual BOOL GetRemoveDTMF() { return device.GetRemoveDTMF(lineNumber); }
01439 
01444     virtual BOOL SetRemoveDTMF(
01445       BOOL removeTones   
01446     ) { return device.SetRemoveDTMF(lineNumber, removeTones); }
01447 
01448 
01451     virtual unsigned IsToneDetected() { return device.IsToneDetected(lineNumber); }
01452 
01455     virtual OpalLineInterfaceDevice::CallProgressTones WaitForToneDetect(
01456       unsigned timeout = 3000 
01457     ) { return device.WaitForToneDetect(lineNumber, timeout); }
01458 
01461     virtual BOOL WaitForTone(
01462       OpalLineInterfaceDevice::CallProgressTones tone, 
01463       unsigned timeout = 3000 
01464     ) { return device.WaitForTone(lineNumber, tone, timeout); }
01465 
01468     virtual BOOL PlayTone(
01469       OpalLineInterfaceDevice::CallProgressTones tone  
01470     ) { return device.PlayTone(lineNumber, tone); }
01471 
01474     virtual BOOL IsTonePlaying() { return device.IsTonePlaying(lineNumber); }
01475 
01478     virtual BOOL StopTone() { return device.StopTone(lineNumber); }
01479 
01480 
01496     virtual OpalLineInterfaceDevice::CallProgressTones DialOut(
01497       const PString & number,       
01498       BOOL requireTones = FALSE,    
01499       unsigned uiDialDelay = 0      
01500     ) { return device.DialOut(lineNumber, number, requireTones, uiDialDelay); }
01502 
01507     OpalLineInterfaceDevice & GetDevice() const { return device; }
01508 
01511     unsigned GetLineNumber() const { return lineNumber; }
01512 
01515     PString GetToken() const { return token; }
01516 
01519     PString GetDescription() const { return description; }
01521 
01522   protected:
01523     OpalLineInterfaceDevice & device;
01524     unsigned                  lineNumber;
01525     PString                   token;
01526     PString                   description;
01527     unsigned                  ringCount;
01528     PTimeInterval             ringTick;
01529     PTimeInterval             ringStoppedTime;
01530     PTimeInterval             ringInterCadenceTime;
01531 };
01532 
01533 
01534 PLIST(OpalLineList, OpalLine);
01535 
01536 
01543 class OpalLIDRegistration : public PCaselessString
01544 {
01545     PCLASSINFO(OpalLIDRegistration, PCaselessString);
01546   public:
01551     OpalLIDRegistration(
01552       const char * name  
01553     );
01554 
01557     ~OpalLIDRegistration();
01559 
01564     virtual OpalLineInterfaceDevice * Create(
01565       void * parameters   
01566     ) const = 0;
01568 
01569   protected:
01570     OpalLIDRegistration * link;
01571     bool                  duplicate;
01572 
01573   friend class OpalLineInterfaceDevice;
01574 };
01575 
01576 
01577 #define OPAL_REGISTER_LID_FUNCTION(cls, type, param) \
01578 static class cls##_Registration : public OpalLIDRegistration { \
01579   public: \
01580     cls##_Registration() : OpalLIDRegistration(type) { } \
01581     OpalLineInterfaceDevice * Create(void * param) const; \
01582 } instance_##cls##_Registration; \
01583 OpalLineInterfaceDevice * cls##_Registration::Create(void * param) const
01584 
01585 #ifndef OPAL_NO_PARAM
01586 #define OPAL_NO_PARAM
01587 #endif
01588 
01589 #define OPAL_REGISTER_LID(cls, type) \
01590   OPAL_REGISTER_LID_FUNCTION(cls, type, OPAL_NO_PARAM) \
01591   { return new cls; }
01592 
01593 #define OPAL_REGISTER_LID_PARAM(cls, type) \
01594   OPAL_REGISTER_LID_FUNCTION(cls, type, parameter) \
01595   { return new cls(parameter); }
01596 
01597 
01598 #endif // __OPAL_LID_H
01599 
01600 
01601 // End of File ///////////////////////////////////////////////////////////////

Generated on Fri Mar 7 06:33:38 2008 for OPAL by  doxygen 1.5.1