📄 ixjunix.cxx
字号:
/*
* ixjunix.cxx
*
* QuickNet Internet Phone/Line JACK codec interface
*
* Open H323 Library
*
* Copyright (c) 1999-2000 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Open H323 Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions of this code were written with the assisance of funding from
* Quicknet Technologies, Inc. http://www.quicknet.net.
*
* Contributor(s): ______________________________________.
*
* $Log: ixjunix.cxx,v $
* Revision 1.1 2006/06/26 03:03:21 joegenbaclor
* I have decided to include the latest development realease of OPAL tagged Deimos Devel 1 (June 8 2006) as inegrated classes to opensipstack to avoid future version conflicts due to the fast pace in OPAL development. This move is also aimed to reduce the size of projects using OPAL componets such as the soon to be relased OpenSIPPhone.
*
* Revision 2.11 2005/01/15 09:19:40 csoutheren
* Fixed compile problems and IXJ link problems
*
* Revision 2.10 2004/02/19 10:47:05 rjongbloed
* Merged OpenH323 version 1.13.1 changes.
*
* Revision 2.9 2003/03/24 07:18:29 robertj
* Added registration system for LIDs so can work with various LID types by
* name instead of class instance.
*
* Revision 2.8 2002/11/10 11:33:19 robertj
* Updated to OpenH323 v1.10.3
*
* Revision 2.7 2002/09/04 06:01:49 robertj
* Updated to OpenH323 v1.9.6
*
* Revision 2.6 2002/07/01 04:56:33 robertj
* Updated to OpenH323 v1.9.1
*
* Revision 2.5 2002/02/11 09:32:13 robertj
* Updated to openH323 v1.8.0
*
* Revision 2.4 2002/01/14 06:35:58 robertj
* Updated to OpenH323 v1.7.9
*
* Revision 2.3 2001/08/21 01:08:31 robertj
* Changed semantics of IsLineDisconnected() when on POTS line.
*
* Revision 2.2 2001/08/13 05:10:40 robertj
* Updates from OpenH323 v1.6.0 release.
*
* Revision 2.1 2001/08/01 05:21:21 robertj
* Made OpalMediaFormatList class global to help with documentation.
*
* Revision 2.0 2001/07/27 15:48:25 robertj
* Conversion of OpenH323 to Open Phone Abstraction Library (OPAL)
*
* Revision 1.143 2004/02/06 10:19:57 csoutheren
* Added PThread::Yield to ReadFrame and WriteFrame calls to see if this
* fixes the starvation problem on 2.6 kernels
*
* Revision 1.142 2004/01/31 13:13:22 csoutheren
* Fixed problem with HAS_IXJ being tested but not included
*
* Revision 1.141 2004/01/09 10:13:33 dereksmithies
* Reads hookstate at startup, and does not assume phone is on hook.
*
* Revision 1.140 2003/12/23 22:52:56 dsandras
* IXJ devices that fail opening because they are busy should be listed in the list of detected devices.
*
* Revision 1.139 2003/11/10 12:04:25 dsandras
* Added missing math.h include.
*
* Revision 1.138 2003/10/24 03:39:54 dereksmithies
* Add card dependant dsp maximums. and log scaling volumes.
*
* Revision 1.137 2003/10/17 01:33:24 dereksmithies
* Code now correctly reports the type string of the card.
*
* Revision 1.136 2003/04/29 08:31:44 robertj
* Fixed return type of get wink function.
*
* Revision 1.135 2003/04/28 01:47:52 dereks
* Add ability to set/get wink duration for ixj device.
*
* Revision 1.134 2002/11/05 04:44:20 robertj
* Fixed typo
*
* Revision 1.133 2002/11/05 04:38:07 robertj
* Changed IsLineDisconnected() to work with POTSLine
*
* Revision 1.132 2002/11/05 04:27:34 robertj
* Imported RingLine() by array from OPAL.
*
* Revision 1.131 2002/10/24 21:06:28 dereks
* Add additional PTRACE statements to aid in debugging.
*
* Revision 1.130 2002/10/01 06:43:01 robertj
* Removed GNU compiler warning
*
* Revision 1.129 2002/08/30 08:20:22 craigs
* Added G.723.1A based codecs
*
* Revision 1.128 2002/08/05 10:03:47 robertj
* Cosmetic changes to normalise the usage of pragma interface/implementation.
*
* Revision 1.127 2002/07/25 09:57:57 rogerh
* Make sure we pick the G.723.1 6.3k codec before the 5.3k codec
* if it is available.
*
* Revision 1.126 2002/07/19 10:47:16 robertj
* Fixed bug where can still receive 24 byte frames even whan selected
* G.723.1(5.3k) mode, it only controls what is transmitted.
*
* Revision 1.125 2002/06/25 09:56:07 robertj
* Fixed GNU warnings
*
* Revision 1.124 2002/05/21 10:21:39 robertj
* Fixed FLASH_TIME being correctly set, PHONE_RING_START getting correct
* argument, correct setting of ancestor variables when stopping codec,
* odd packet error if playout time passed, all thanks Artis Kugevics
*
* Revision 1.123 2002/05/09 06:26:34 robertj
* Added fuction to get the current audio enable state for line in device.
* Changed IxJ EnableAudio() semantics so is exclusive, no direct switching
* from PSTN to POTS and vice versa without disabling the old one first.
*
* Revision 1.122 2002/02/08 14:38:42 craigs
* Changed codec table to use defines from mediafmt.h. Thanks to Roger Hardiman
*
* Revision 1.121 2002/02/06 06:51:17 rogerh
* Correct a comment. There are 240 samples in PCM16 audio (not 250)
*
* Revision 1.120 2002/01/23 19:09:45 rogerh
* Return PCM as a supported format type
*
* Revision 1.119 2001/12/19 07:42:52 craigs
* Fixed problem with opening devices as returned by GetDeviceName
*
* Revision 1.118 2001/12/12 21:54:33 craigs
* Changed for changes for G723.1 5k3
*
* Revision 1.117 2001/11/22 02:55:13 robertj
* Fixed bug from previous fix, caused only /dev/phone0 to work!
*
* Revision 1.116 2001/11/09 07:48:01 craigs
* Changed to allow Open to accept string returned by GetName
*
* Revision 1.115 2001/08/08 15:55:56 rogerh
* Support the new ixj FreeBSD driver which can return values from the ioctl.
* This also fixes the capabilities problem.
*
* Revision 1.114 2001/08/08 11:00:25 rogerh
* Fix the ioctl wrappers to we can use the FreeBSD port of the IXJ driver
*
* Revision 1.113 2001/07/20 06:27:30 craigs
* Bulletproofed caller id routines
*
* Revision 1.112 2001/07/19 05:54:30 robertj
* Updated interface to xJACK drivers to utilise cadence and filter functions
* for dial tone, busy tone and ringback tone detection.
*
* Revision 1.111 2001/07/05 16:57:31 craigs
* Fixed problem with hook state not working in spkr/mic mode
*
* Revision 1.110 2001/05/25 04:54:33 robertj
* Fixed previous fix
*
* Revision 1.109 2001/05/25 02:19:53 robertj
* Fixed problem with codec data reblocking code not being reset when
* code is stopped and restarted, thanks Artis Kugevics
*
* Revision 1.108 2001/05/21 06:40:05 craigs
* Fixed stupid problem with missing close bracket
*
* Revision 1.107 2001/05/21 06:37:06 craigs
* Changed to allow optional wink detection for line disconnect
*
* Revision 1.106 2001/05/11 04:43:43 robertj
* Added variable names for standard PCM-16 media format name.
*
* Revision 1.105 2001/05/10 01:48:03 craigs
* Added implementation of SetLineToLine
*
* Revision 1.104 2001/04/03 23:38:38 craigs
* Added extra debugging for country change
*
* Revision 1.103 2001/03/29 23:40:09 robertj
* Added ability to get average signal level for both receive and transmit.
*
* Revision 1.102 2001/03/28 20:31:29 craigs
* Added detection of '0' prefix for old PhoneJACK cards
*
* Revision 1.101 2001/02/13 05:02:39 craigs
* Extended PlayDTMF to allow generation of additional simple tones
*
* Revision 1.100 2001/02/09 05:13:56 craigs
* Added pragma implementation to (hopefully) reduce the executable image size
* under Linux
*
* Revision 1.99 2001/02/09 01:50:22 robertj
* Fixed incorrect setting of writeCodecSize variable.
*
* Revision 1.98 2001/02/07 07:19:05 robertj
* Changed to fake a TELEPHONY_VERSION variable when there isn't one.
*
* Revision 1.97 2001/02/03 01:31:20 robertj
* Used new TELEPHONY_VERSION define for selecting API options.
*
* Revision 1.96 2001/01/28 10:32:52 rogerh
* Change an ifndef for G729B
*
* Revision 1.95 2001/01/25 07:27:16 robertj
* Major changes to add more flexible OpalMediaFormat class to normalise
* all information about media types, especially codecs.
*
* Revision 1.94 2001/01/24 05:34:49 robertj
* Altered volume control range to be percentage, ie 100 is max volume.
*
* Revision 1.93 2000/12/21 12:39:54 craigs
* Fixed debugging
*
* Revision 1.92 2000/12/11 01:23:32 craigs
* Added extra routines to allow country string manipulation
*
* Revision 1.91 2000/12/11 01:10:41 robertj
* Removed unused filter/cadence function.
*
* Revision 1.90 2000/12/05 08:19:16 craigs
* Added internal DTMF queue to ensure DTMF digits are extracted from the
* driver as soon as possible. This minimises the number of signals
* generated
*
* Revision 1.89 2000/12/04 08:04:21 craigs
* Fixed initialisation to be more friendly
*
* Revision 1.86 2000/11/30 08:48:36 robertj
* Added functions to enable/disable Voice Activity Detection in LID's
*
* Revision 1.85 2000/11/27 10:30:01 craigs
* Added SetRawCodec function
*
* Revision 1.84 2000/11/26 23:12:18 craigs
* Added hook flash detection API
*
* Revision 1.83 2000/11/24 11:19:36 robertj
* Modified the ReadFrame/WriteFrame functions to allow for variable length codecs.
*
* Revision 1.82 2000/11/22 02:36:53 robertj
* Fixed bug in supporting older drivers.
*
* Revision 1.81 2000/11/21 00:27:50 craigs
* Fixed problem with EINTR handling on ReadFrame and WriteFrame
*
* Revision 1.80 2000/11/20 03:15:13 craigs
* Changed tone detection API slightly to allow detection of multiple
* simultaneous tones
* Added fax CNG tone to tone list
*
* Revision 1.79 2000/11/12 22:34:32 craigs
* Changed Linux driver interface code to use signals
*
* Revision 1.78 2000/11/06 01:58:26 craigs
* Changed DSP buffer depths for non-PCM functions
*
* Revision 1.77 2000/10/26 06:46:18 robertj
* Removed unnecessary stop tone ioctls() on device opening. Can't do multiple open if left in.
*
* Revision 1.76 2000/10/23 05:39:07 craigs
* Added access to exception detection on Unix
* Fixed problem with detecting available devices when
* devices with lower ordinals were used
*
* Revision 1.75 2000/10/19 06:55:11 robertj
* Added functions to get xJACK card type and serial number.
*
* Revision 1.74 2000/10/06 09:05:00 rogerh
* Check the return value of ioctl PHONE_REC_START.
*
* Revision 1.73 2000/10/06 01:20:12 robertj
* Got conditional compile round the wrong way on previous fix
*
* Revision 1.72 2000/10/04 22:39:15 craigs
* Added extra guard to FormatCallerIdString so it will work on very old drivers
*
* Revision 1.71 2000/09/29 04:41:32 craigs
* Added protected for Quicknet drivers without PHONE_WINK
*
* Revision 1.70 2000/09/26 01:28:55 craigs
* Fixed problem with VMWI ioctl interface
*
* Revision 1.69 2000/09/26 00:04:19 craigs
* Added ability to send wink on POTS ports
*
* Revision 1.68 2000/09/25 23:59:42 craigs
* Finally got G.728 working on boards which use the 8021
* Added better handling for wink exceptions
*
* Revision 1.67 2000/09/23 08:04:37 robertj
* Added support for handling LID's that only do symmetric codecs.
*
* Revision 1.66 2000/09/13 10:08:03 rogerh
* BSD handles ioctls differently to Linux so add new macros for FreeBSD
*
* Revision 1.65 2000/09/08 06:43:42 craigs
* Added additional ioctl debugging
* Added attempt to reduce ioctl count for hookstate monitoring
*
* Revision 1.64 2000/08/31 13:16:07 craigs
* Disabled IOCTL debugging when in release mode
*
* Revision 1.63 2000/08/31 13:14:40 craigs
* Added functions to LID
* More bulletproofing to Linux driver
*
* Revision 1.62 2000/08/30 23:42:01 robertj
* Renamed string version of SetCountrCode() to SetCountryCodeName() to avoid
* C++ masking ancestor overloaded function when overriding numeric version.
*
* Revision 1.61 2000/08/28 07:13:36 craigs
* Added timeout to read codec operations
*
* Revision 1.60 2000/08/25 03:19:16 craigs
* Normalised checking of error return values from IXJ driver routines
*
* Revision 1.59 2000/08/18 04:56:20 craigs
* Added mutexes to EVERY hardware access. This fixed the G.723.1
* startup problem
*
* Revision 1.58 2000/07/03 10:33:38 craigs
* Fixed autohook option to work with PhoneCARD
*
* Revision 1.57 2000/07/02 14:13:19 craigs
* Added delay when reading from codec whilst writing stopped
*
* Revision 1.56 2000/06/22 02:46:16 craigs
* Improved ring detection
*
* Revision 1.55 2000/06/17 04:11:13 craigs
* Fixed problem with potential codec startup problem in Linux IXJ driver
* Moved Linux specific variables to Linux specific section
*
* Revision 1.54 2000/05/29 01:56:36 craigs
* Added timeout on WriteFrame to help avoid lockups
*
* Revision 1.53 2000/05/25 08:42:33 craigs
* Added detection of bugus get_rec_vol in ixj driver
*
* Revision 1.52 2000/05/24 12:44:41 craigs
* Fixed compile warnings
*
* Revision 1.51 2000/05/24 06:43:16 craigs
* Added routines to get xJack volume
* Fixed problem with receiving G>723.1 NULL frames
*
* Revision 1.50 2000/05/22 14:26:38 craigs
* Added read/write interlock to avoid codec lockup due to writing whilst read not enabled
* Added select before write to avoid EINTR under debugger
*
* Revision 1.49 2000/05/18 02:28:43 craigs
* Removed possibly dangerous checkes for uninitialised return values from
* ixj driver
*
* Revision 1.48 2000/05/02 04:32:27 robertj
* Fixed copyright notice comment.
*
* Revision 1.47 2000/04/17 07:25:08 craigs
* Fixed problems with incorrect caller ID parsing, and ensured that caller ID
* is cleared after every call
*
* Revision 1.46 2000/04/17 00:58:01 craigs
* Added support for latest Quicknet driver with caller ID transmission
*
* Revision 1.45 2000/04/13 23:08:01 craigs
* Fixed problems with callerId not compiling on all systems
*
* Revision 1.44 2000/04/10 21:23:41 robertj
* Removed "return" that disabled the dynamic changing of AEC levels.
*
* Revision 1.43 2000/04/06 19:29:04 craigs
* Removed all vestiges of the old IXJ driver
*
* Revision 1.42 2000/04/05 18:25:00 robertj
* Changed caller ID code for better portability.
*
* Revision 1.41 2000/04/05 18:15:18 craigs
* Added locks to prevent problems with codec lockup during fast start
*
* Revision 1.40 2000/04/05 16:27:16 craigs
* Added caller ID transmission, and started proper ring detection etc
*
* Revision 1.39 2000/04/05 04:09:49 robertj
* Removed PCM as valid codec type.
*
* Revision 1.38 2000/04/04 08:22:14 rogerh
* Wrap GetPayloadTypes() in #ifdef LINUX_TELEPHONY
*
* Revision 1.37 2000/04/04 01:34:03 craigs
* Added better detection of open errors
* Fixed problem with PlayTone
*
* Revision 1.36 2000/03/30 19:33:37 robertj
* Added function to get available codecs from driver.
* Fixed name strings for various card types.
*
* Revision 1.35 2000/03/28 05:24:08 craigs
* Fixed problem with country code
*
* Revision 1.34 2000/03/28 04:02:53 craigs
* Added code to stop codecs when PSTN line goes onhook
*
* Revision 1.33 2000/03/28 03:42:07 craigs
* Added extra stuff to try and make tones work properly
*
* Revision 1.32 2000/03/21 03:23:46 craigs
* Added GetLineCount function
*
* Revision 1.31 2000/03/08 00:25:52 robertj
* Fixed correct setting of country DAA codes from T35 country code.
*
* Revision 1.30 2000/02/19 23:49:33 robertj
* Fixed problem with unresolved SetRemoveDTMF function when not using linux telephony.
*
* Revision 1.29 2000/01/07 11:04:03 robertj
* New telephony API compatibility
*
* Revision 1.28 2000/01/07 10:01:03 robertj
* dditions and changes to line interface device base class.
*
* Revision 1.27 2000/01/04 00:21:55 craigs
* Fixed sense of line test
*
* Revision 1.26 1999/12/29 01:18:07 craigs
* Fixed problem with codecs other than G.711 not working after reorganisation
*
* Revision 1.25 1999/12/24 00:28:03 robertj
* Changes to IXJ interface to follow LID abstraction
*
* Revision 1.24 1999/12/19 23:48:50 craigs
* Added detection of multiple xJack cards
*
* Revision 1.23 1999/12/11 00:01:39 robertj
* Added Wink indication function.
*
* Revision 1.22 1999/12/08 21:54:05 craigs
* Removed extraneous DSP reset at the advice of Ed Okerson
*
* Revision 1.21 1999/11/29 04:50:11 robertj
* Added adaptive threshold calculation to silence detection.
*
* Revision 1.20 1999/11/19 09:29:53 robertj
* Fixed problems with aycnhronous shut down of logical channels.
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -