ixjlid.h

Go to the documentation of this file.
00001 /*
00002  * ixjlid.h
00003  *
00004  * QuickNet Internet Phone/Line JACK codec interface
00005  *
00006  * Open H323 Library
00007  *
00008  * Copyright (c) 1999-2000 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: ixjlid.h,v $
00030  * Revision 1.68.2.1  2006/03/02 11:12:52  csoutheren
00031  * Backport gcc 4.1.0 fix from CVS head
00032  *
00033  * Revision 1.69  2006/03/02 05:49:44  csoutheren
00034  * Fix for gcc 4.1.0
00035  *
00036  * Revision 1.68  2005/11/30 13:05:01  csoutheren
00037  * Changed tags for Doxygen
00038  *
00039  * Revision 1.67  2004/08/22 04:21:06  csoutheren
00040  * Added compiler.h for new glibc
00041  * Thanks to Klaus Kaempf
00042  *
00043  * Revision 1.66  2004/04/25 09:08:25  rjongbloed
00044  * Fixed being able to link of system does not have IxJ LID configured.
00045  *
00046  * Revision 1.65  2004/01/31 13:13:22  csoutheren
00047  * Fixed problem with HAS_IXJ being tested but not included
00048  *
00049  * Revision 1.64  2003/10/27 20:27:37  dereksmithies
00050  * Add log scale methods for audio.
00051  *
00052  * Revision 1.63  2003/04/29 08:27:47  robertj
00053  * Cleaned up documentation for new wink duration functions.
00054  *
00055  * Revision 1.62  2003/04/28 01:47:53  dereks
00056  * Add ability to set/get wink duration for ixj device.
00057  *
00058  * Revision 1.61  2002/11/06 04:03:38  dereks
00059  * Improve docs for  SetToneFilterParameters().
00060  *
00061  * Revision 1.60  2002/11/05 04:26:21  robertj
00062  * Imported RingLine() by array from OPAL.
00063  *
00064  * Revision 1.59  2002/09/16 01:14:15  robertj
00065  * Added #define so can select if #pragma interface/implementation is used on
00066  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00067  *
00068  * Revision 1.58  2002/09/03 06:19:37  robertj
00069  * Normalised the multi-include header prevention ifdef/define symbol.
00070  *
00071  * Revision 1.57  2002/08/05 10:03:47  robertj
00072  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00073  *
00074  * Revision 1.56  2002/05/09 06:26:30  robertj
00075  * Added fuction to get the current audio enable state for line in device.
00076  * Changed IxJ EnableAudio() semantics so is exclusive, no direct switching
00077  *   from PSTN to POTS and vice versa without disabling the old one first.
00078  *
00079  * Revision 1.55  2001/09/24 12:31:35  robertj
00080  * Added backward compatibility with old drivers.
00081  *
00082  * Revision 1.54  2001/07/19 05:54:27  robertj
00083  * Updated interface to xJACK drivers to utilise cadence and filter functions
00084  *   for dial tone, busy tone and ringback tone detection.
00085  *
00086  * Revision 1.53  2001/05/21 06:36:46  craigs
00087  * Changed to allow optional wink detection for line disconnect
00088  *
00089  * Revision 1.52  2001/03/29 23:38:48  robertj
00090  * Added ability to get average signal level for both receive and transmit.
00091  *
00092  * Revision 1.51  2001/02/09 05:16:24  robertj
00093  * Added #pragma interface for GNU C++.
00094  *
00095  * Revision 1.50  2001/01/25 07:27:14  robertj
00096  * Major changes to add more flexible OpalMediaFormat class to normalise
00097  *   all information about media types, especially codecs.
00098  *
00099  * Revision 1.49  2001/01/24 05:34:49  robertj
00100  * Altered volume control range to be percentage, ie 100 is max volume.
00101  *
00102  * Revision 1.48  2000/12/19 06:38:57  robertj
00103  * Fixed missing virtual on IsTonePlaying() function.
00104  *
00105  * Revision 1.47  2000/12/11 01:47:28  robertj
00106  * Changed to use built PWLib class for overlapped I/O.
00107  *
00108  * Revision 1.46  2000/12/11 00:16:51  robertj
00109  * Removed unused filter/cadence function.
00110  *
00111  * Revision 1.45  2000/12/05 11:29:31  craigs
00112  * Fixed problem with DTMF signal by adding queue for DTMF digits
00113  *
00114  * Revision 1.44  2000/12/04 23:30:02  craigs
00115  * Added better initialisation of Quicknet devices
00116  *
00117  * Revision 1.43  2000/11/30 21:28:47  eokerson
00118  * Fixed DTMF signal handling to stop polling ixj driver.
00119  *
00120  * Revision 1.42  2000/11/30 08:48:35  robertj
00121  * Added functions to enable/disable Voice Activity Detection in LID's
00122  *
00123  * Revision 1.41  2000/11/27 10:30:01  craigs
00124  * Added SetRawCodec function
00125  *
00126  * Revision 1.40  2000/11/27 00:12:17  robertj
00127  * Added WIN32 version of hook flash detection function.
00128  *
00129  * Revision 1.39  2000/11/26 23:12:18  craigs
00130  * Added hook flash detection API
00131  *
00132  * Revision 1.38  2000/11/24 11:18:36  robertj
00133  * Don't need special raw modes for Linux drivers ... yet.
00134  *
00135  * Revision 1.37  2000/11/24 10:50:13  robertj
00136  * Added a raw PCM dta mode for generating/detecting standard tones.
00137  * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
00138  * Fixed hook state debouncing.
00139  * Added codec to explicitly set LineJACK mixer settings to avoid funny modes
00140  *    the driver/hardware gets into sometimes.
00141  *
00142  * Revision 1.36  2000/11/20 03:15:13  craigs
00143  * Changed tone detection API slightly to allow detection of multiple
00144  * simultaneous tones
00145  * Added fax CNG tone to tone list
00146  *
00147  * Revision 1.35  2000/11/12 22:34:32  craigs
00148  * Changed Linux driver interface code to use signals
00149  *
00150  * Revision 1.34  2000/11/06 06:33:20  robertj
00151  * Changed hook state debounce so does not block for 200ms.
00152  *
00153  * Revision 1.33  2000/11/03 06:22:48  robertj
00154  * Added flag to IsLinePresent() to force slow test, guarenteeing correct value.
00155  *
00156  * Revision 1.32  2000/10/23 05:39:07  craigs
00157  * Added access to exception detection on Unix
00158  * Fixed problem with detecting available devices when
00159  * devices with lower ordinals were used
00160  *
00161  * Revision 1.31  2000/10/19 04:12:13  robertj
00162  * Added enum for xJACK card types.
00163  *
00164  * Revision 1.30  2000/10/19 04:00:35  robertj
00165  * Added functions to get xJACK card type and serial number.
00166  *
00167  * Revision 1.29  2000/10/13 02:21:40  robertj
00168  * Changed volume control code to set more mixer values on LineJACK.
00169  *
00170  * Revision 1.28  2000/09/25 23:59:42  craigs
00171  * Finally got G.728 working on boards which use the 8021
00172  * Added better handling for wink exceptions
00173  *
00174  * Revision 1.27  2000/09/22 01:35:03  robertj
00175  * Added support for handling LID's that only do symmetric codecs.
00176  *
00177  * Revision 1.26  2000/09/13 09:26:28  rogerh
00178  * Add location of FreeBSD header files
00179  *
00180  * Revision 1.25  2000/09/08 06:43:42  craigs
00181  * Added additional ioctl debugging
00182  * Added attempt to reduce ioctl count for hookstate monitoring
00183  *
00184  * Revision 1.24  2000/08/31 13:14:39  craigs
00185  * Added functions to LID
00186  * More bulletproofing to Linux driver
00187  *
00188  * Revision 1.23  2000/07/28 06:29:20  robertj
00189  * Fixed AEC under Win32 so can be changed from other processes.
00190  *
00191  * Revision 1.22  2000/06/22 02:47:12  craigs
00192  * Improved PSTN ring detection
00193  *
00194  * Revision 1.21  2000/06/17 09:34:45  robertj
00195  * Put back variables mistakenly thought to be Linux specific.
00196  *
00197  * Revision 1.20  2000/06/17 04:11:13  craigs
00198  * Fixed problem with potential codec startup problem in Linux IXJ driver
00199  * Moved Linux specific variables to Linux specific section
00200  *
00201  * Revision 1.19  2000/05/24 06:42:18  craigs
00202  * Added calls to get volume settings
00203  *
00204  * Revision 1.18  2000/05/02 04:32:24  robertj
00205  * Fixed copyright notice comment.
00206  *
00207  * Revision 1.17  2000/04/13 23:09:38  craigs
00208  * Fixed problem with callerId on some systems
00209  *
00210  * Revision 1.16  2000/04/06 20:36:25  robertj
00211  * Fixed some LineJACK compatbility problems (eg DTMF detect stopping).
00212  *
00213  * Revision 1.15  2000/04/06 19:37:50  craigs
00214  * Normalised bask to HAS_IXJ
00215  *
00216  * Revision 1.14  2000/04/06 19:29:04  craigs
00217  * Removed all vestiges of the old IXJ driver
00218  *
00219  * Revision 1.13  2000/04/06 17:49:40  craigs
00220  * Removed LINUX_TELEPHONY. Again.
00221  *
00222  * Revision 1.12  2000/04/05 18:04:12  robertj
00223  * Changed caller ID code for better portability.
00224  *
00225  * Revision 1.11  2000/04/05 16:28:05  craigs
00226  * Added caller ID function
00227  *
00228  * Revision 1.10  2000/03/29 20:46:47  robertj
00229  * Added function on LID to get available codecs.
00230  *
00231  * Revision 1.9  2000/03/28 03:47:12  craigs
00232  * Added stuff to stop tone playing from going wrong
00233  *
00234  * Revision 1.8  2000/03/22 17:18:48  robertj
00235  * Changed default DTMF tone string times.
00236  *
00237  * Revision 1.7  2000/03/17 20:58:51  robertj
00238  * Fixed line count to be xJACK card dependent.
00239  *
00240  * Revision 1.6  2000/03/14 11:20:49  rogerh
00241  * Compile the ixj code on FreeBSD. This is needed for openphone support.
00242  *
00243  * Revision 1.5  2000/02/22 09:44:33  robertj
00244  * Fixed compatibility with Linux systems not yet with the Linux Telephony code.
00245  *
00246  * Revision 1.4  2000/01/07 10:01:26  robertj
00247  * GCC/Linux compatibility
00248  *
00249  * Revision 1.3  2000/01/07 08:28:09  robertj
00250  * Additions and changes to line interface device base class.
00251  *
00252  * Revision 1.2  1999/12/24 00:28:03  robertj
00253  * Changes to IXJ interface to follow LID abstraction
00254  *
00255  * Revision 1.1  1999/12/23 23:02:35  robertj
00256  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
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 

Generated on Thu May 18 00:24:38 2006 for OpenH323 by  doxygen 1.4.6