Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

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.67  2004/08/22 04:21:06  csoutheren
00031  * Added compiler.h for new glibc
00032  * Thanks to Klaus Kaempf
00033  *
00034  * Revision 1.66  2004/04/25 09:08:25  rjongbloed
00035  * Fixed being able to link of system does not have IxJ LID configured.
00036  *
00037  * Revision 1.65  2004/01/31 13:13:22  csoutheren
00038  * Fixed problem with HAS_IXJ being tested but not included
00039  *
00040  * Revision 1.64  2003/10/27 20:27:37  dereksmithies
00041  * Add log scale methods for audio.
00042  *
00043  * Revision 1.63  2003/04/29 08:27:47  robertj
00044  * Cleaned up documentation for new wink duration functions.
00045  *
00046  * Revision 1.62  2003/04/28 01:47:53  dereks
00047  * Add ability to set/get wink duration for ixj device.
00048  *
00049  * Revision 1.61  2002/11/06 04:03:38  dereks
00050  * Improve docs for  SetToneFilterParameters().
00051  *
00052  * Revision 1.60  2002/11/05 04:26:21  robertj
00053  * Imported RingLine() by array from OPAL.
00054  *
00055  * Revision 1.59  2002/09/16 01:14:15  robertj
00056  * Added #define so can select if #pragma interface/implementation is used on
00057  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00058  *
00059  * Revision 1.58  2002/09/03 06:19:37  robertj
00060  * Normalised the multi-include header prevention ifdef/define symbol.
00061  *
00062  * Revision 1.57  2002/08/05 10:03:47  robertj
00063  * Cosmetic changes to normalise the usage of pragma interface/implementation.
00064  *
00065  * Revision 1.56  2002/05/09 06:26:30  robertj
00066  * Added fuction to get the current audio enable state for line in device.
00067  * Changed IxJ EnableAudio() semantics so is exclusive, no direct switching
00068  *   from PSTN to POTS and vice versa without disabling the old one first.
00069  *
00070  * Revision 1.55  2001/09/24 12:31:35  robertj
00071  * Added backward compatibility with old drivers.
00072  *
00073  * Revision 1.54  2001/07/19 05:54:27  robertj
00074  * Updated interface to xJACK drivers to utilise cadence and filter functions
00075  *   for dial tone, busy tone and ringback tone detection.
00076  *
00077  * Revision 1.53  2001/05/21 06:36:46  craigs
00078  * Changed to allow optional wink detection for line disconnect
00079  *
00080  * Revision 1.52  2001/03/29 23:38:48  robertj
00081  * Added ability to get average signal level for both receive and transmit.
00082  *
00083  * Revision 1.51  2001/02/09 05:16:24  robertj
00084  * Added #pragma interface for GNU C++.
00085  *
00086  * Revision 1.50  2001/01/25 07:27:14  robertj
00087  * Major changes to add more flexible OpalMediaFormat class to normalise
00088  *   all information about media types, especially codecs.
00089  *
00090  * Revision 1.49  2001/01/24 05:34:49  robertj
00091  * Altered volume control range to be percentage, ie 100 is max volume.
00092  *
00093  * Revision 1.48  2000/12/19 06:38:57  robertj
00094  * Fixed missing virtual on IsTonePlaying() function.
00095  *
00096  * Revision 1.47  2000/12/11 01:47:28  robertj
00097  * Changed to use built PWLib class for overlapped I/O.
00098  *
00099  * Revision 1.46  2000/12/11 00:16:51  robertj
00100  * Removed unused filter/cadence function.
00101  *
00102  * Revision 1.45  2000/12/05 11:29:31  craigs
00103  * Fixed problem with DTMF signal by adding queue for DTMF digits
00104  *
00105  * Revision 1.44  2000/12/04 23:30:02  craigs
00106  * Added better initialisation of Quicknet devices
00107  *
00108  * Revision 1.43  2000/11/30 21:28:47  eokerson
00109  * Fixed DTMF signal handling to stop polling ixj driver.
00110  *
00111  * Revision 1.42  2000/11/30 08:48:35  robertj
00112  * Added functions to enable/disable Voice Activity Detection in LID's
00113  *
00114  * Revision 1.41  2000/11/27 10:30:01  craigs
00115  * Added SetRawCodec function
00116  *
00117  * Revision 1.40  2000/11/27 00:12:17  robertj
00118  * Added WIN32 version of hook flash detection function.
00119  *
00120  * Revision 1.39  2000/11/26 23:12:18  craigs
00121  * Added hook flash detection API
00122  *
00123  * Revision 1.38  2000/11/24 11:18:36  robertj
00124  * Don't need special raw modes for Linux drivers ... yet.
00125  *
00126  * Revision 1.37  2000/11/24 10:50:13  robertj
00127  * Added a raw PCM dta mode for generating/detecting standard tones.
00128  * Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
00129  * Fixed hook state debouncing.
00130  * Added codec to explicitly set LineJACK mixer settings to avoid funny modes
00131  *    the driver/hardware gets into sometimes.
00132  *
00133  * Revision 1.36  2000/11/20 03:15:13  craigs
00134  * Changed tone detection API slightly to allow detection of multiple
00135  * simultaneous tones
00136  * Added fax CNG tone to tone list
00137  *
00138  * Revision 1.35  2000/11/12 22:34:32  craigs
00139  * Changed Linux driver interface code to use signals
00140  *
00141  * Revision 1.34  2000/11/06 06:33:20  robertj
00142  * Changed hook state debounce so does not block for 200ms.
00143  *
00144  * Revision 1.33  2000/11/03 06:22:48  robertj
00145  * Added flag to IsLinePresent() to force slow test, guarenteeing correct value.
00146  *
00147  * Revision 1.32  2000/10/23 05:39:07  craigs
00148  * Added access to exception detection on Unix
00149  * Fixed problem with detecting available devices when
00150  * devices with lower ordinals were used
00151  *
00152  * Revision 1.31  2000/10/19 04:12:13  robertj
00153  * Added enum for xJACK card types.
00154  *
00155  * Revision 1.30  2000/10/19 04:00:35  robertj
00156  * Added functions to get xJACK card type and serial number.
00157  *
00158  * Revision 1.29  2000/10/13 02:21:40  robertj
00159  * Changed volume control code to set more mixer values on LineJACK.
00160  *
00161  * Revision 1.28  2000/09/25 23:59:42  craigs
00162  * Finally got G.728 working on boards which use the 8021
00163  * Added better handling for wink exceptions
00164  *
00165  * Revision 1.27  2000/09/22 01:35:03  robertj
00166  * Added support for handling LID's that only do symmetric codecs.
00167  *
00168  * Revision 1.26  2000/09/13 09:26:28  rogerh
00169  * Add location of FreeBSD header files
00170  *
00171  * Revision 1.25  2000/09/08 06:43:42  craigs
00172  * Added additional ioctl debugging
00173  * Added attempt to reduce ioctl count for hookstate monitoring
00174  *
00175  * Revision 1.24  2000/08/31 13:14:39  craigs
00176  * Added functions to LID
00177  * More bulletproofing to Linux driver
00178  *
00179  * Revision 1.23  2000/07/28 06:29:20  robertj
00180  * Fixed AEC under Win32 so can be changed from other processes.
00181  *
00182  * Revision 1.22  2000/06/22 02:47:12  craigs
00183  * Improved PSTN ring detection
00184  *
00185  * Revision 1.21  2000/06/17 09:34:45  robertj
00186  * Put back variables mistakenly thought to be Linux specific.
00187  *
00188  * Revision 1.20  2000/06/17 04:11:13  craigs
00189  * Fixed problem with potential codec startup problem in Linux IXJ driver
00190  * Moved Linux specific variables to Linux specific section
00191  *
00192  * Revision 1.19  2000/05/24 06:42:18  craigs
00193  * Added calls to get volume settings
00194  *
00195  * Revision 1.18  2000/05/02 04:32:24  robertj
00196  * Fixed copyright notice comment.
00197  *
00198  * Revision 1.17  2000/04/13 23:09:38  craigs
00199  * Fixed problem with callerId on some systems
00200  *
00201  * Revision 1.16  2000/04/06 20:36:25  robertj
00202  * Fixed some LineJACK compatbility problems (eg DTMF detect stopping).
00203  *
00204  * Revision 1.15  2000/04/06 19:37:50  craigs
00205  * Normalised bask to HAS_IXJ
00206  *
00207  * Revision 1.14  2000/04/06 19:29:04  craigs
00208  * Removed all vestiges of the old IXJ driver
00209  *
00210  * Revision 1.13  2000/04/06 17:49:40  craigs
00211  * Removed LINUX_TELEPHONY. Again.
00212  *
00213  * Revision 1.12  2000/04/05 18:04:12  robertj
00214  * Changed caller ID code for better portability.
00215  *
00216  * Revision 1.11  2000/04/05 16:28:05  craigs
00217  * Added caller ID function
00218  *
00219  * Revision 1.10  2000/03/29 20:46:47  robertj
00220  * Added function on LID to get available codecs.
00221  *
00222  * Revision 1.9  2000/03/28 03:47:12  craigs
00223  * Added stuff to stop tone playing from going wrong
00224  *
00225  * Revision 1.8  2000/03/22 17:18:48  robertj
00226  * Changed default DTMF tone string times.
00227  *
00228  * Revision 1.7  2000/03/17 20:58:51  robertj
00229  * Fixed line count to be xJACK card dependent.
00230  *
00231  * Revision 1.6  2000/03/14 11:20:49  rogerh
00232  * Compile the ixj code on FreeBSD. This is needed for openphone support.
00233  *
00234  * Revision 1.5  2000/02/22 09:44:33  robertj
00235  * Fixed compatibility with Linux systems not yet with the Linux Telephony code.
00236  *
00237  * Revision 1.4  2000/01/07 10:01:26  robertj
00238  * GCC/Linux compatibility
00239  *
00240  * Revision 1.3  2000/01/07 08:28:09  robertj
00241  * Additions and changes to line interface device base class.
00242  *
00243  * Revision 1.2  1999/12/24 00:28:03  robertj
00244  * Changes to IXJ interface to follow LID abstraction
00245  *
00246  * Revision 1.1  1999/12/23 23:02:35  robertj
00247  * File reorganision for separating RTP from H.323 and creation of LID for VPB support.
00248  *
00249  */
00250 
00251 #ifndef __OPAL_IXJLID_H
00252 #define __OPAL_IXJLID_H
00253 
00254 #ifdef P_USE_PRAGMA
00255 #pragma interface
00256 #endif
00257 
00258 #include "openh323buildopts.h"
00259 
00260 #ifdef HAS_IXJ
00261 
00262 #include "lid.h"
00263 #include "h323caps.h"
00264 
00265 
00266 #ifdef P_LINUX
00267 #include <linux/telephony.h>
00268 #include <linux/compiler.h>
00269 #include <linux/ixjuser.h>
00270 #endif
00271 
00272 #ifdef P_FREEBSD
00273 #include <sys/telephony.h>
00274 #include <sys/ixjuser.h>
00275 #endif
00276 
00277 
00278 
00280 
00283 class OpalIxJDevice : public OpalLineInterfaceDevice
00284 {
00285   PCLASSINFO(OpalIxJDevice, OpalLineInterfaceDevice);
00286 
00287   enum { MaxIxjDevices = 10 };
00288 
00289   public:
00292     OpalIxJDevice();
00293 
00297     ~OpalIxJDevice() { Close(); }
00298 
00301     virtual BOOL Open(
00302       const PString & device  
00303     );
00304 
00307     virtual BOOL Close();
00308 
00311     virtual PString GetName() const;
00312 
00313 
00314     enum {
00315       POTSLine,
00316       PSTNLine,
00317       NumLines
00318     };
00319 
00322     virtual unsigned GetLineCount();
00323 
00324 
00327     virtual BOOL IsLineTerminal(
00328       unsigned line   
00329     ) { return line == POTSLine; }
00330 
00331 
00334     virtual BOOL IsLinePresent(
00335       unsigned line,      
00336       BOOL force = FALSE  
00337     );
00338 
00339 
00344     virtual BOOL IsLineOffHook(
00345       unsigned line   
00346     );
00347 
00351     virtual BOOL SetLineOffHook(
00352       unsigned line,        
00353       BOOL newState = TRUE  
00354     );
00355 
00356 
00359     virtual BOOL IsLineRinging(
00360       unsigned line,          
00361       DWORD * cadence = NULL  
00362     );
00363 
00367     virtual BOOL RingLine(
00368       unsigned line,    
00369       DWORD cadence     
00370     );
00371 
00386     virtual BOOL RingLine(
00387       unsigned line,     
00388       PINDEX nCadence,   
00389       unsigned * pattern 
00390     );
00391 
00392 
00395     virtual BOOL IsLineDisconnected(
00396       unsigned line,   
00397       BOOL checkForWink = TRUE
00398     );
00399 
00400 
00403     BOOL SetLineToLineDirect(
00404       unsigned line1,   
00405       unsigned line2,   
00406       BOOL connect      
00407     );
00408 
00411     BOOL IsLineToLineDirect(
00412       unsigned line1,   
00413       unsigned line2    
00414     );
00415 
00416 
00419     virtual OpalMediaFormat::List GetMediaFormats() const;
00420 
00423     virtual BOOL SetReadFormat(
00424       unsigned line,    
00425       const OpalMediaFormat & mediaFormat   
00426     );
00427 
00430     virtual BOOL SetWriteFormat(
00431       unsigned line,    
00432       const OpalMediaFormat & mediaFormat   
00433     );
00434 
00437     virtual OpalMediaFormat GetReadFormat(
00438       unsigned line    
00439     );
00440 
00443     virtual OpalMediaFormat GetWriteFormat(
00444       unsigned line    
00445     );
00446 
00457     virtual BOOL SetRawCodec(
00458       unsigned line    
00459     );
00460 
00463     virtual BOOL StopRawCodec(
00464       unsigned line   
00465     );
00466 
00469     virtual BOOL StopReadCodec(
00470       unsigned line   
00471     );
00472 
00475     virtual BOOL StopWriteCodec(
00476       unsigned line   
00477     );
00478 
00482     virtual PINDEX GetReadFrameSize(
00483       unsigned line   
00484     );
00485 
00486     virtual BOOL SetReadFrameSize(unsigned, PINDEX);
00487 
00491     virtual PINDEX GetWriteFrameSize(
00492       unsigned line   
00493     );
00494 
00495     virtual BOOL SetWriteFrameSize(unsigned, PINDEX);
00496 
00499     virtual BOOL ReadFrame(
00500       unsigned line,    
00501       void * buf,       
00502       PINDEX & count    
00503     );
00504 
00507     virtual BOOL WriteFrame(
00508       unsigned line,    
00509       const void * buf, 
00510       PINDEX count,     
00511       PINDEX & written  
00512     );
00513 
00516     virtual unsigned GetAverageSignalLevel(
00517       unsigned line,  
00518       BOOL playback   
00519     );
00520 
00521 
00524     virtual BOOL EnableAudio(
00525       unsigned line,      
00526       BOOL enable = TRUE
00527     );
00528 
00531     virtual BOOL IsAudioEnabled(
00532       unsigned line      
00533     );
00534 
00535 
00540     virtual BOOL SetRecordVolume(
00541       unsigned line,    
00542       unsigned volume   
00543     );
00544 
00549     virtual BOOL SetPlayVolume(
00550       unsigned line,    
00551       unsigned volume   
00552     );
00553 
00558     virtual BOOL GetRecordVolume(
00559       unsigned line,      
00560       unsigned & volume   
00561     );
00562 
00567     virtual BOOL GetPlayVolume(
00568       unsigned line,      
00569       unsigned & volume   
00570     );
00571 
00574     AECLevels GetAEC(
00575       unsigned line    
00576     );
00577 
00580     BOOL SetAEC(
00581       unsigned line,    
00582       AECLevels level   
00583     );
00584 
00588     unsigned GetWinkDuration(
00589       unsigned line    
00590     );
00591 
00595     BOOL SetWinkDuration(
00596       unsigned line,        
00597       unsigned winkDuration 
00598     );
00599 
00603     virtual BOOL GetVAD(
00604       unsigned line    
00605     );
00606 
00610     virtual BOOL SetVAD(
00611       unsigned line,    
00612       BOOL enable       
00613     );
00614 
00615 
00623     virtual BOOL GetCallerID(
00624       unsigned line,      
00625       PString & idString, 
00626       BOOL full = FALSE   
00627     );
00628 
00637     virtual BOOL SetCallerID(
00638       unsigned line,            
00639       const PString & idString  
00640     );
00641 
00644     virtual BOOL SendCallerIDOnCallWaiting(
00645       unsigned line,            
00646       const PString & idString  
00647     );
00648 
00651     virtual BOOL SendVisualMessageWaitingIndicator(
00652       unsigned line,            
00653       BOOL on
00654     );
00655 
00656 
00657 
00661     virtual BOOL PlayDTMF(
00662       unsigned line,            
00663       const char * digits,      
00664       DWORD onTime = DefaultDTMFOnTime,  
00665       DWORD offTime = DefaultDTMFOffTime 
00666     );
00667 
00673     virtual char ReadDTMF(
00674       unsigned line   
00675     );
00676 
00681     virtual BOOL GetRemoveDTMF(
00682       unsigned line            
00683     );
00684 
00689     virtual BOOL SetRemoveDTMF(
00690       unsigned line,            
00691       BOOL removeTones   
00692     );
00693 
00694 
00697     virtual unsigned IsToneDetected(
00698       unsigned line   
00699     );
00700 
00706     virtual BOOL SetToneFilterParameters(
00707       unsigned line,            
00708       CallProgressTones tone,   
00709       unsigned lowFrequency,    
00710       unsigned highFrequency,   
00711       PINDEX numCadences,       
00712       const unsigned * onTimes, 
00713       const unsigned * offTimes 
00714     );
00715 
00718     virtual BOOL PlayTone(
00719       unsigned line,          
00720       CallProgressTones tone  
00721     );
00722 
00725     virtual BOOL IsTonePlaying(
00726       unsigned line   
00727     );
00728 
00731     virtual BOOL StopTone(
00732       unsigned line   
00733     );
00734 
00737     virtual BOOL HasHookFlash(unsigned line);
00738 
00744     virtual BOOL SetCountryCode(
00745       T35CountryCodes country   
00746     );
00747 
00748 
00751     virtual DWORD GetSerialNumber();
00752 
00753     enum CardTypes {
00754       PhoneJACK = 1,
00755       LineJACK = 3,
00756       PhoneJACK_Lite,
00757       PhoneJACK_PCI,
00758       PhoneCARD,
00759       PhoneJACK_PCI_TJ
00760     };
00761 
00764     DWORD GetCardType() const { return dwCardType; }
00765 
00766 
00769     static PStringArray GetDeviceNames();
00770 
00771 
00772   protected:
00773 
00774     PINDEX    LogScaleVolume(unsigned line, PINDEX volume, BOOL isPlay);
00775 
00776     PString   deviceName;
00777     DWORD     dwCardType;
00778     PMutex    readMutex, writeMutex;
00779     BOOL      readStopped, writeStopped;
00780     PINDEX    readFrameSize, writeFrameSize;
00781     PINDEX    readCodecType, writeCodecType;
00782     BOOL      lastHookState, currentHookState;
00783     PTimer    hookTimeout;
00784     BOOL      inRawMode;
00785     unsigned  enabledAudioLine;
00786     BOOL      exclusiveAudioMode;
00787 
00788 #if defined(WIN32)
00789     BOOL InternalSetVolume(BOOL record, unsigned id, int volume, int mute);
00790     BOOL InternalPlayTone(unsigned line,
00791                           DWORD toneIndex,
00792                           DWORD onTime, DWORD offTime,
00793                           BOOL synchronous);
00794     BOOL IoControl(DWORD dwIoControlCode,
00795                    DWORD inParam = 0,
00796                    DWORD * outParam = NULL);
00797     BOOL IoControl(DWORD dwIoControlCode,
00798                    LPVOID lpInBuffer,
00799                    DWORD nInBufferSize,
00800                    LPVOID lpOutBuffer,
00801                    DWORD nOutBufferSize,
00802                    LPDWORD lpdwBytesReturned,
00803                    PWin32Overlapped * overlap = NULL);
00804 
00805     HANDLE        hDriver;
00806     DWORD         driverVersion;
00807     PTimer        ringTimeout;
00808     DWORD         lastDTMFDigit;
00809     DWORD         lastFlashState;
00810     PTimeInterval toneSendCompletionTime;
00811     BOOL          vadEnabled;
00812     HANDLE        hReadEvent, hWriteEvent;
00813 
00814 #elif defined(HAS_IXJ)
00815 
00816   public:
00817     class ExceptionInfo {
00818       public:
00819         int fd;
00820 
00821         BOOL hasRing;
00822         BOOL hookState;
00823         BOOL hasWink;
00824         BOOL hasFlash;
00825         char dtmf[16];
00826         int dtmfIn;
00827         int dtmfOut;
00828 #ifdef IXJCTL_VMWI
00829         BOOL hasCid;
00830         PHONE_CID cid;
00831 #endif
00832         BOOL filter[4];
00833         BOOL cadence[4];
00834         telephony_exception data;
00835         timeval lastHookChange;
00836     };
00837 
00838     static void SignalHandler(int sig);
00839     ExceptionInfo * OpalIxJDevice::GetException();
00840     int GetOSHandle() { return os_handle; }
00841 
00842   protected:
00843     BOOL ConvertOSError(int err);
00844 
00845     static ExceptionInfo exceptionInfo[MaxIxjDevices];
00846     static PMutex        exceptionMutex;
00847     static BOOL          exceptionInit;
00848 
00849     AECLevels aecLevel;
00850     BOOL removeDTMF;
00851     PMutex toneMutex;
00852     BOOL tonePlaying;
00853     PTimer lastRingTime;
00854     BOOL pstnIsOffHook;
00855     BOOL gotWink;
00856     int  userPlayVol, userRecVol;
00857 
00858     int  savedPlayVol, savedRecVol;
00859     AECLevels savedAEC;
00860 
00861 #ifdef IXJCTL_VMWI
00862     PHONE_CID callerIdInfo;
00863 #endif
00864 
00865 #endif
00866 };
00867 
00868 
00869 #endif // HAS_IXJ
00870 
00871 #endif // __OPAL_IXJLID_H
00872 
00873 

Generated on Sat Mar 5 14:59:09 2005 for OpenH323 by  doxygen 1.4.1