1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419
|
/*
* main.h
*
* PWLib application header file for Voxilla
*
* A H.323 "net telephone" 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 of this code were written with the assisance of funding from
* Vovida Networks, Inc. http://www.vovida.com.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Log: main.h,v $
* Revision 1.37 2005/02/03 01:21:42 csoutheren
* Added called party to call log and command parameters
*
* Revision 1.36 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.35 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.34 2003/12/02 09:46:59 csoutheren
* Added --loop option thanks to Jan Willamowius
*
* Revision 1.33 2002/11/13 10:23:12 rogerh
* Enable Speex support by default.
*
* Revision 1.32 2002/08/16 02:04:30 craigs
* Ensure compilation without Speex installed
*
* Revision 1.31 2002/08/15 18:52:49 rogerh
* Add support for one of the Speex codecs
*
* Revision 1.30 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.29 2002/04/01 14:45:43 craigs
* Fixed flag to end call after OGM
*
* Revision 1.28 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.27 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.26 2002/01/22 04:15:04 craigs
* Updated for move of PWavFile to PTCLib
* Replaced AudioDelay with PAdaptiveDelay
*
* Revision 1.25 2001/10/15 14:10:01 rogerh
* Add new definitions
*
* Revision 1.24 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.23 2001/09/28 00:13:48 robertj
* Changed BYTE* to PBYTEArray so get automatic memory management.
*
* Revision 1.22 2001/09/24 22:39:42 craigs
* Added commands to play and record data files, esp G.723.1
*
* Revision 1.21 2001/07/23 09:17:36 rogerh
* Add the LPC10 codec, a low quality and low bitrate codec.
*
* Revision 1.20 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.19 2001/07/01 07:38:58 rogerh
* Add Microsoft GSM codec. Also allocate memory for frameBuffer dynamically
* as different codecs can have different frame sizes.
*
* Revision 1.18 2001/06/29 11:13:15 rogerh
* Add AudioDelay class which removes the jitter in recorded files.
*
* Revision 1.17 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.16 2000/08/29 12:32:08 craigs
* Fixed problems with recording messages
*
* Revision 1.15 2000/08/28 16:42:59 craigs
* Finally fixed problems with G.723.1. All codecs now working
*
* Revision 1.14 2000/08/28 07:49:51 craigs
* Added extra stuff
*
* Revision 1.13 2000/08/28 00:38:37 craigs
* Added support for setting listening port number
*
* Revision 1.12 2000/08/27 23:42:24 craigs
* Fixed problem with playback of messages
* Fixed problem with recording messages
*
* Revision 1.11 2000/05/25 12:06:17 robertj
* Added PConfigArgs class so can save program arguments to config files.
*
* Revision 1.10 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.9 2000/05/09 11:22:15 craigs
* Fixed problems caused by new jitter buffer code
* and fixed OGM problems
*
* Revision 1.8 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.7 2000/01/13 04:03:45 robertj
* Added video transmission
*
* Revision 1.6 1999/11/11 00:27:49 robertj
* Changed OnAnswerCall() call back function to allow for asyncronous response.
*
* Revision 1.5 1999/11/06 13:27:49 craigs
* Added extra output and changed for new library changes
*
* Revision 1.4 1999/10/24 12:50:37 craigs
* Fixed G723.1 capability, and added ability for discrete OGMs
*
* Revision 1.3 1999/10/24 03:08:49 craigs
* Fixed problem with recording zero length messages, and added autodelete of files
*
* Revision 1.2 1999/10/22 09:56:41 craigs
* Fixed compile warning
*
* Revision 1.1 1999/10/11 00:15:18 craigs
* Initial version
*
*
*/
#ifndef _Voxilla_MAIN_H
#define _Voxilla_MAIN_H
#include <h323.h>
#include <h323pdu.h>
#include <h245.h>
#include <lid.h>
#include <ptclib/pwavfile.h>
#include <ptclib/delaychan.h>
class OpenAm : public PProcess
{
PCLASSINFO(OpenAm, PProcess)
public:
OpenAm();
~OpenAm();
void Main();
void RecordFile(PArgList & args);
void PlayFile(PArgList & args);
protected:
long GetCodec(const PString & codecname);
OpalLineInterfaceDevice * GetDevice(const PString & device);
};
class MyH323EndPoint : public H323EndPoint
{
PCLASSINFO(MyH323EndPoint, H323EndPoint);
public:
MyH323EndPoint(unsigned callLimit,
const PString & runCmd,
const PDirectory & dir,
int flags);
// overrides from H323EndPoint
virtual H323Connection * CreateConnection(unsigned callReference);
BOOL OnIncomingCall(H323Connection &, const H323SignalPDU &, H323SignalPDU &);
// new functions
BOOL Initialise(PConfigArgs & args);
PString GetGSMOGM() const { return gsmOgm; }
void SetGSMOGM(const PString & s) { gsmOgm = s; }
PString GetG711OGM() const { return g711Ogm; }
void SetG711OGM(const PString & s) { g711Ogm = s; }
PString GetLPC10OGM() const { return lpc10Ogm; }
void SetLPC10OGM(const PString & s) { lpc10Ogm = s; }
PString GetSPEEXOGM() const { return speexOgm; }
void SetSPEEXOGM(const PString & s) { speexOgm = s; }
PString GetG7231OGM() const { return g7231Ogm; }
void SetG7231OGM(const PString & s) { g7231Ogm = s; }
PString GetiLBCOGM() const { return ilbcOgm; }
void SetiLBCOGM(const PString & s) { ilbcOgm = s; }
unsigned GetCallLimit() const { return callLimit; }
PString GetRunCmd() const { return runCmd; }
PDirectory GetDirectory() const { return dir; }
void SetRecordWav(const BOOL rec){ recordWav = rec; }
BOOL GetRecordWav() const { return recordWav; }
void SetLoopMessage(BOOL flag) { loopMessage = flag; }
BOOL GetLoopMessage() const { return loopMessage; }
enum {
DeleteAfterRecord = 0x01,
NoRecordG7231 = 0x02,
HangupAfterPlay = 0x04
};
BOOL GetDeleteAfterRecord() const { return flags & DeleteAfterRecord; }
BOOL GetNoRecordG7231() const { return flags & NoRecordG7231; }
BOOL GetHangupAfterPlay() const { return flags & HangupAfterPlay; }
protected:
unsigned callLimit;
PString pcmOgm, g711Ogm, gsmOgm, lpc10Ogm, g7231Ogm, runCmd;
PString speexOgm, ilbcOgm;
PDirectory dir;
int flags;
BOOL recordWav;
BOOL loopMessage;
};
class PCM_RecordFile;
class MyH323Connection;
PQUEUE(PStringQueue, PString);
class PCM_OGMChannel : public PIndirectChannel
{
PCLASSINFO(PCM_OGMChannel, PIndirectChannel);
public:
PCM_OGMChannel(MyH323Connection & conn);
BOOL Read(void * buffer, PINDEX amount);
void PlayFile(PFile * chan);
BOOL Close();
void QueueFile(const PString & cmd);
void FlushQueue();
void SetRecordTrigger();
void SetHangupTrigger();
void SetPlayOnce() { playOnce = TRUE; }
void SetLoopMessage() { loopMessage = TRUE; }
protected:
virtual BOOL ReadFrame(PINDEX amount);
virtual void CreateSilenceFrame(PINDEX amount);
virtual void Synchronise(PINDEX amount);
virtual BOOL IsWAVFileValid(PWAVFile *chan);
BOOL AdjustFrame(void * buffer, PINDEX amount);
PStringQueue playQueue;
MyH323Connection & conn;
PMutex chanMutex;
int silentCount;
int totalData;
BOOL recordTrigger, hangupTrigger;
BOOL closed;
BOOL playOnce;
BOOL loopMessage;
PAdaptiveDelay ogm_delay;
PBYTEArray frameBuffer;
PINDEX frameLen, frameOffs;
};
class G7231_OGMChannel : public PCM_OGMChannel
{
PCLASSINFO(G7231_OGMChannel, PCM_OGMChannel);
public:
G7231_OGMChannel(MyH323Connection & conn);
protected:
BOOL ReadFrame(PINDEX amount);
void CreateSilenceFrame(PINDEX amount);
void Synchronise(PINDEX amount);
BOOL IsWAVFileValid(PWAVFile *chan);
};
class MyH323Connection : public H323Connection
{
PCLASSINFO(MyH323Connection, H323Connection);
public:
MyH323Connection(MyH323EndPoint &, unsigned);
~MyH323Connection();
// overrides from H323Connection
BOOL OpenAudioChannel(BOOL, unsigned, H323AudioCodec & codec);
AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
BOOL OnStartLogicalChannel(H323Channel & channel);
void OnUserInputString(const PString & value);
BOOL OnReceivedSignalSetup(const H323SignalPDU & setupPDU);
// new functions
void StartRecording();
void Hangup();
void SetE164Number(const PString & _num)
{ e164Number = _num; }
PString GetE164Number() const
{ return e164Number; }
protected:
void OnUserInputChar(char ch);
BOOL StartMenu(int menuNumber);
BOOL ProcessMenuCmd(const PString & cmdStr);
const MyH323EndPoint & ep;
PString product;
PTime callStartTime;
PTime recordStartTime;
PString basename;
PFilePath recordFn;
PString transmitCodecName, receiveCodecName;
BOOL recordTrigger;
PString calledParty;
PMutex connMutex;
PCM_RecordFile * recordFile;
PCM_OGMChannel * ogmChannel;
PString digits, lastDigits;
int currentMenu;
PStringList menuNames;
PString securityToken, e164Number;
};
class PCM_RecordFile : public PIndirectChannel
{
PCLASSINFO(PCM_RecordFile, PIndirectChannel)
public:
PCM_RecordFile(MyH323Connection & conn, const PFilePath & fn, unsigned callLimit);
~PCM_RecordFile();
BOOL Write(const void * buf, PINDEX len);
BOOL Close();
void StartRecording();
virtual void DelayFrame(PINDEX len);
virtual BOOL WriteFrame(const void * buf, PINDEX len);
BOOL WasRecordStarted() const { return recordStarted; }
protected:
MyH323Connection & conn;
PTime finishTime;
PFilePath fn;
unsigned callLimit;
BOOL recordStarted;
BOOL timeLimitExceeded;
BOOL closed;
BOOL isPCM;
BOOL dataWritten;
PAdaptiveDelay delay;
PMutex pcmrecordMutex;
PFile *fileclass; // will point to a PWAVFile or PFile class
};
class G7231_RecordFile : public PCM_RecordFile
{
PCLASSINFO(G7231_RecordFile, PCM_RecordFile);
public:
G7231_RecordFile(MyH323Connection & conn, const PFilePath & fn, unsigned callLimit);
void DelayFrame(PINDEX len);
BOOL WriteFrame(const void * buf, PINDEX len);
};
#endif // _Voxilla_MAIN_H
// End of File ///////////////////////////////////////////////////////////////
|