📄 main.cxx
字号:
/*
* main.cxx
*
* Main source for for OpenAM
*
* A H.323 answering machine application.
*
* Copyright (c) 1993-2001 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 Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Log: main.cxx,v $
* Revision 1.19 2008/02/07 08:38:04 shorne
* fix warning on VS 2008
*
* Revision 1.18 2008/01/02 19:12:30 willamowius
* better enforce limit on call duration for video channels
*
* Revision 1.17 2008/01/02 17:12:53 willamowius
* assign different name to each recorded video (same as with audio files)
*
* Revision 1.16 2007/11/22 22:31:13 willamowius
* remove uneccessary restriction to exactly one frame size
*
* Revision 1.15 2007/11/19 23:23:11 willamowius
* trace codec and frame size
*
* Revision 1.14 2007/11/19 00:28:17 willamowius
* limit the video size to size of the provided video OGM
*
* Revision 1.13 2007/11/17 13:52:25 willamowius
* cleanup
*
* Revision 1.12 2007/11/14 15:23:59 willamowius
* declare overloaded methods as virtual
*
* Revision 1.11 2007/11/14 14:16:43 willamowius
* always print message about call start/end to stdout
*
* Revision 1.10 2007/11/14 14:09:32 willamowius
* avoid using NULLOutput device since it doesn't work with 'make optnoshared'
*
* Revision 1.9 2007/11/14 13:12:44 willamowius
* trace message which output device is being created
*
* Revision 1.8 2007/11/14 11:53:47 willamowius
* delete endpoint object on shutdown
*
* Revision 1.7 2007/11/13 14:58:54 willamowius
* reduce read size for very short frame so G7231 OGMs work again
*
* Revision 1.6 2007/11/13 14:37:05 willamowius
* allow operation without audio OGM, only with video OGM
*
* Revision 1.5 2007/11/13 14:03:45 willamowius
* fix message about recording limit
*
* Revision 1.4 2007/11/13 13:51:04 willamowius
* more cleanup
*
* Revision 1.3 2007/11/13 13:18:24 willamowius
* cleanup
*
* Revision 1.2 2007/11/07 05:58:37 shorne
* Fixed Windows compile
*
* Revision 1.1 2007/11/07 03:42:13 willamowius
* port OpenAM to H323Plus
*
* Revision 1.102 2006/04/19 04:11:53 csoutheren
* Fix problem when outputting CIF stream using QCIF source
*
* Revision 1.101 2006/03/12 06:37:53 rjongbloed
* Fixed DevStudio warning
*
* Revision 1.100 2006/03/06 07:05:19 csoutheren
* Preliminary support for capturing video input
*
* Revision 1.99 2006/02/28 12:46:31 csoutheren
* Removed warning on Windows
*
* Revision 1.98 2006/02/28 12:36:31 csoutheren
* Fixed video capabilities
*
* Revision 1.97 2006/02/28 10:12:50 csoutheren
* Added support for NULL receive video
*
* Revision 1.96 2006/02/24 10:16:07 csoutheren
* Fixed for CIF
*
* Revision 1.95 2006/02/21 07:52:18 csoutheren
* Added outgoing video message functions
*
* Revision 1.94 2005/11/25 00:52:49 csoutheren
* Applied patch #1292653
* OpenAM patch to log calling number
*
* Revision 1.93 2005/02/03 01:21:42 csoutheren
* Added called party to call log and command parameters
*
* Revision 1.92 2004/05/26 04:01:57 csoutheren
* Changed to work completely with new plugin codecs
*
* Revision 1.91 2004/05/10 13:07:19 rjongbloed
* Changed G.726 and MS-ADPCM to plug in codecs.
*
* Revision 1.90 2004/05/04 12:21:16 rjongbloed
* Converted LPC-10 codec to plug in.
*
* Revision 1.89 2004/05/03 13:25:46 rjongbloed
* Converted everything to be codec plug in freindly
* Removed GSM and G.729 as now plug ins are "the way"!
*
* Revision 1.88 2004/04/06 11:27:49 rjongbloed
* Changes to support native C++ Run Time Type Information
* Changes for codec plug ins
*
* Revision 1.87 2004/01/31 07:38:21 rjongbloed
* Changed HAS_IXJ usage to if defined not if non-zero
*
* Revision 1.86 2004/01/02 02:52:10 csoutheren
* Thanks to Michal Zygmuntowicz for these changes
* Added support for iLBC codec
* Added ability to specify a gatekeeper password,
* Fixed small bug with Speex capabilities being accidentally included.
*
* Revision 1.85 2003/12/02 09:46:59 csoutheren
* Added --loop option thanks to Jan Willamowius
*
* Revision 1.84 2002/11/13 10:23:12 rogerh
* Enable Speex support by default.
*
* Revision 1.83 2002/11/10 08:12:42 robertj
* Moved constants for "well known" ports to better place (OPAL change).
*
* Revision 1.82 2002/08/21 08:48:09 rogerh
* Fix some problems caused by the user specif OGM changes
*
* Revision 1.81 2002/08/21 06:55:09 rogerh
* Support all 5 Speex bitrates.
*
* Revision 1.80 2002/08/16 02:04:30 craigs
* Ensure compilation without Speex installed
*
* Revision 1.79 2002/08/15 18:52:49 rogerh
* Add support for one of the Speex codecs
*
* Revision 1.78 2002/08/05 10:06:06 robertj
* Changed to use the version of G.7231. file capability/codec as used in
* opalvxml module. Prevents duplicate symbol link errors.
*
* Revision 1.77 2002/06/28 00:30:41 robertj
* Fixed Clone() for G.723 file capability, must clone contents!
*
* Revision 1.76 2002/05/08 03:15:35 robertj
* Removed unecessary initialisation of frameBuffer PBYTEArray
*
* Revision 1.75 2002/04/01 14:45:43 craigs
* Fixed flag to end call after OGM
*
* Revision 1.74 2002/04/01 13:16:09 craigs
* Added ability to kill calls at end of playing OGM
* Added ability to play different OGMs depending on target DN
*
* Revision 1.73 2002/02/21 07:21:52 rogerh
* Change the outgoing audio's FrameDelay() code to use the PAdaptiveDelay
* class which should give clearer audio for the OGMs.
*
* Revision 1.72 2002/02/04 13:23:24 rogerh
* Change the silence frame back to a 4 byte SID. It caused Quicnet cards
* to play a loud noise instead of silence.
*
* Revision 1.71 2002/01/31 16:12:26 rogerh
* Clear the end of the frame buffer if we cannot read a full frame.
*
* Revision 1.70 2002/01/26 09:40:03 rogerh
* Make OpenAM send out G.723.1 OGM audio files correctly.
*
* Revision 1.69 2002/01/25 11:50:10 rogerh
* dd --port option to play and record commands so you can use a
* telephone on the POTS port or use speakers and microphone.
*
* Revision 1.68 2002/01/25 08:58:46 rogerh
* Send out silence using a standard 24 byte frame instead of a 4 byte SID.
* This is a workaround to support an end point which does not understand SID.
*
* Revision 1.67 2002/01/22 04:15:04 craigs
* Updated for move of PWavFile to PTCLib
* Replaced AudioDelay with PAdaptiveDelay
*
* Revision 1.66 2002/01/11 16:07:15 rogerh
* Make PCMExt non static as it is used externally in cmds.cxx
*
* Revision 1.65 2001/11/18 23:07:36 craigs
* Fixed problem whereby recording could start when queue of OGMs was not empty
* Thanks to Frank Derks
*
* Revision 1.64 2001/10/24 10:45:33 rogerh
* replace 4 byte SID frames with 24 byte frames of silence. Windows Media
* Player's codec cannot handle SID frames.
*
* Revision 1.63 2001/10/24 10:28:59 rogerh
* Make -m option find g7231 wav files.
* Fix bug where record file format was set by the outgoing codec type.
* (fixes bug when NetMeeting decides to receive G.723.1 and send MS-GSM)
*
* Revision 1.62 2001/10/24 09:01:07 rogerh
* Fix a mistake in the 24 byte frames used for silence.
*
* Revision 1.61 2001/10/16 12:28:43 rogerh
* Add support for saving g.723.1 audio data into a g.723.1 WAV File
*
* Revision 1.60 2001/10/15 14:55:03 rogerh
* Add error message
*
* Revision 1.59 2001/10/15 14:20:10 rogerh
* Add support for reading G.723.1 WAV files for the G.723.1 codec.
* Recorded messages are still saved out in raw .g723 files.
*
* Revision 1.58 2001/10/15 07:09:38 rogerh
* New sox homepage
*
* Revision 1.57 2001/10/14 08:22:54 rogerh
* Record the silence in G.723.1 connections to the record file.
* This also gives a proper fix for the 100% CPU utilisation bug.
*
* Revision 1.56 2001/10/13 07:13:18 rogerh
* Add a 5ms sleep if the length of the G.723.1 audio data is zero.
* This hack stops the 100% CPU usage seen when recording G.723.1 files.
* Submitted by Maurizio Beni <m.beni@deimositalia.com>
*
* Revision 1.55 2001/10/04 23:55:00 craigs
* Added deletion of file in PCM_RecordFile destructor thanks to Patrick Koorevaar
*
* Revision 1.54 2001/10/02 11:02:31 rogerh
* Use the audio delay class when writing G723.1 audio files.
* Add a quick hack.Set the frameBuffer to 1024 so OpenAM tworks on Unix boxes
*
* Revision 1.53 2001/09/29 07:11:48 rogerh
* Delete ogmChanel in destructor - Patrick Koorevaar <pkoorevaar@hotmail.com>
* Only call conn.ClearCall() once after we pass the record time limit.
* Reported by Patrick.
*
* Revision 1.52 2001/09/28 00:14:30 robertj
* Changed BYTE* to PBYTEArray so get automatic memory management.
* Fixed redundant entries in argument parsing, thanks Patrick Koorevaar
*
* Revision 1.51 2001/09/24 22:39:42 craigs
* Added commands to play and record data files, esp G.723.1
*
* Revision 1.50 2001/08/24 14:04:29 rogerh
* Delete the listener if StartListener() fails.
*
* Revision 1.49 2001/08/13 00:01:15 robertj
* Fixed #ifdef for memory check code to use PMEMORY_CHECK and not _DEBUG
*
* Revision 1.48 2001/07/23 09:17:36 rogerh
* Add the LPC10 codec, a low quality and low bitrate codec.
*
* Revision 1.47 2001/07/23 04:01:10 rogerh
* remove debugging info
*
* Revision 1.46 2001/07/20 03:36:58 robertj
* Minor cosmetic changes to new PWAVFile class.
*
* Revision 1.45 2001/07/19 10:05:27 rogerh
* PWAVFile is now part of the standard PWLib.
*
* Revision 1.44 2001/07/17 14:33:01 rogerh
* Support writing of .wav audio files from PCM codecs (eg G711 and GSM).
* .wav files are written out by default now. If you still want to record
* to raw audio files with a .sw extension, use the --recordraw option.
*
* Revision 1.43 2001/07/17 12:02:37 rogerh
* Change title, OpenAm -> OpenAM
*
* Revision 1.42 2001/07/14 07:44:29 rogerh
* Add .wav file support to the OGM.
* The -m option now looks for .wav and then .sw file extensions.
* .wav file must be 16 bit mono at 8000 Hz
*
* Revision 1.41 2001/07/11 15:47:55 rogerh
* Add G711 A-Law codec, reported by Niels Svennekj鎟 <linux@post.tele.dk>
*
* Revision 1.40 2001/07/01 07:38:57 rogerh
* Add Microsoft GSM codec. Also allocate memory for frameBuffer dynamically
* as different codecs can have different frame sizes.
*
* Revision 1.39 2001/06/29 11:13:15 rogerh
* Add AudioDelay class which removes the jitter in recorded files.
*
* Revision 1.38 2001/06/29 09:01:17 rogerh
* Put back a line accidentally deleted in the last commit
*
* Revision 1.37 2001/06/29 06:34:57 rogerh
* Add mutex locks in PCM_Recordfile. This solves the race condition where
* Close() was called while Write() was still running.
*
* Revision 1.36 2001/04/27 07:08:46 robertj
* Fixed 100% Cip problem, thanks APinaev@microtest.ru
*
* Revision 1.35 2001/03/20 23:42:55 robertj
* Used the new PTrace::Initialise function for starting trace code.
*
* Revision 1.34 2001/01/25 07:27:14 robertj
* Major changes to add more flexible OpalMediaFormat class to normalise
* all information about media types, especially codecs.
*
* Revision 1.33 2000/10/20 23:11:29 robertj
* Fixed incorrect parameter parsing string that stopped -l from working, thanks Bruno BOSQUED
*
* Revision 1.32 2000/10/19 06:55:41 robertj
* Fixed compiler crash by rearranging loop.
*
* Revision 1.31 2000/08/29 23:11:41 robertj
* Fixed MSVC warnings.
*
* Revision 1.30 2000/08/29 12:32:07 craigs
* Fixed problems with recording messages
*
* Revision 1.29 2000/08/28 16:42:59 craigs
* Finally fixed problems with G.723.1. All codecs now working
*
* Revision 1.28 2000/08/28 09:13:54 robertj
* Fixed MSVC compiler warnings.
*
* Revision 1.27 2000/08/28 07:49:26 craigs
* New code to maybe get G.723.1 replaying working
*
* Revision 1.26 2000/08/28 00:38:37 craigs
* Added support for setting listening port number
*
* Revision 1.25 2000/08/27 23:42:24 craigs
* Fixed problem with playback of messages
* Fixed problem with recording messages
*
* Revision 1.24 2000/06/20 02:38:27 robertj
* Changed H323TransportAddress to default to IP.
*
* Revision 1.23 2000/06/17 09:14:52 robertj
* Added setting of closed flag when closing OGM.
*
* Revision 1.22 2000/05/25 13:25:47 robertj
* Fixed incorrect "save" parameter specification.
*
* Revision 1.21 2000/05/25 12:06:17 robertj
* Added PConfigArgs class so can save program arguments to config files.
*
* Revision 1.20 2000/05/11 11:47:11 robertj
* Fixed alpha linux GNU compiler problems.
*
* Revision 1.19 2000/05/10 05:14:25 robertj
* Changed capabilities so has a function to get name of codec, instead of relying on PrintOn.
*
* Revision 1.18 2000/05/09 11:22:15 craigs
* Fixed problems caused by new jitter buffer code
* and fixed OGM problems
*
* Revision 1.17 2000/05/09 02:41:32 craigs
* Added extra debugging, and fixed problems with OGM in non-IVR mode
*
* Revision 1.16 2000/04/26 03:18:38 craigs
* Fixed problem when GSM specified as preferred codec
*
* Revision 1.15 2000/04/25 23:34:22 craigs
* Added lots of new code, including outgoing and incoming
* multiplexors, and the start of an IVR system
*
* Revision 1.14 2000/01/13 04:03:45 robertj
* Added video transmission
*
* Revision 1.13 2000/01/07 08:28:09 robertj
* Additions and changes to line interface device base class.
*
* Revision 1.12 1999/12/10 01:44:46 craigs
* Added ability to set interface
*
* Revision 1.11 1999/12/01 04:38:25 robertj
* Added gatekeeper support to OpenAM
*
* Revision 1.10 1999/11/11 00:27:49 robertj
* Changed OnAnswerCall() call back function to allow for asyncronous response.
*
* Revision 1.9 1999/11/06 13:27:48 craigs
* Added extra output and changed for new library changes
*
* Revision 1.8 1999/10/29 10:57:04 robertj
* Added answering machine project.
*
* Revision 1.7 1999/10/24 12:50:37 craigs
* Fixed G723.1 capability, and added ability for discrete OGMs
*
* Revision 1.6 1999/10/24 08:24:56 craigs
* Added GSM capability back in
*
* Revision 1.5 1999/10/24 08:19:58 craigs
* Fixed problem that caused crash when unknown codecs used
*
* Revision 1.4 1999/10/24 03:29:07 craigs
* Fixed problem with -h parsing
*
* Revision 1.3 1999/10/24 03:08:49 craigs
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -