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

Generated on Sat Jul 24 17:03:35 2004 for OpenH323 by doxygen 1.3.7