main.h
上传用户:wgl386701
上传日期:2007-01-06
资源大小:22k
文件大小:8k
- /*
- * main.h
- *
- * PWLib application header file for Voxilla
- *
- * A H.323 "net telephone" application.
- *
- * Copyright (c) 1993-1998 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.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 <gsmcodec.h>
- #include <lid.h>
- class OpenAm : public PProcess
- {
- PCLASSINFO(OpenAm, PProcess)
- public:
- OpenAm();
- ~OpenAm();
- void Main();
- void RecordFile(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);
- // new functions
- virtual void ListenForIncomingCalls();
- virtual void AwaitTermination();
- 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 GetG7231OGM() const { return g7231Ogm; }
- void SetG7231OGM(const PString & s) { g7231Ogm = s; }
- unsigned GetCallLimit() const { return callLimit; }
- PString GetRunCmd() const { return runCmd; }
- PDirectory GetDirectory() const { return dir; }
- enum {
- DeleteAfterRecord = 0x01,
- NoRecordG7231 = 0x02
- };
- BOOL GetDeleteAfterRecord() const { return flags & DeleteAfterRecord; }
- BOOL GetNoRecordG7231() const { return flags & NoRecordG7231; }
- protected:
- unsigned callLimit;
- PString g711Ogm, gsmOgm, g7231Ogm, runCmd;
- PDirectory dir;
- int flags;
- };
- class RecordFile;
- class MyH323Connection;
- PQUEUE(PStringQueue, PString);
- class OGMChannel : public PIndirectChannel
- {
- PCLASSINFO(OGMChannel, PIndirectChannel);
- public:
- OGMChannel(MyH323Connection & conn);
- BOOL Read(void * buffer, PINDEX amount);
- void PlayFile(PFile * chan);
- BOOL Close();
- void SetIsPCM(BOOL _isPCM) { isPCM = _isPCM; }
- void SetExtension(const PString & _ext) { ext = _ext; }
- PString GetExtension() const { return ext; }
- void QueueFile(const PString & cmd);
- void FlushQueue();
- void SetRecordTrigger();
- void SetHangupTrigger();
- protected:
- void CreateSilence(void * buffer, PINDEX amount);
- PStringQueue playQueue;
- MyH323Connection & conn;
- PMutex chanMutex;
- BOOL isPCM;
- PString ext;
- PTime lastTime;
- int silentCount;
- int totalData;
- BOOL recordTrigger, hangupTrigger;
- BOOL closed;
- };
- 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);
- // new functions
- void StartRecording();
- void Hangup();
- 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;
- PMutex connMutex;
- RecordFile * recordFile;
- OGMChannel * ogmChannel;
- PString digits, lastDigits;
- int currentMenu;
- PStringList menuNames;
- };
- class RecordFile : public PFile
- {
- PCLASSINFO(RecordFile, PFile)
- public:
- RecordFile(MyH323Connection & conn, const PFilePath & fn, unsigned callLimit);
- ~RecordFile();
- BOOL Write(const void * buf, PINDEX len);
- BOOL Close();
- void StartRecording();
- BOOL WasRecordStarted() const { return recordStarted; }
- protected:
- MyH323Connection & conn;
- PTime finishTime;
- PFilePath fn;
- unsigned callLimit;
- BOOL recordStarted;
- BOOL closed;
- };
- class G7231_File_Codec : public H323AudioCodec
- {
- PCLASSINFO(G7231_File_Codec, H323AudioCodec);
- public:
- G7231_File_Codec(Direction dir);
- unsigned GetBandwidth() const;
-
- BOOL Read(BYTE * buffer, unsigned & length, RTP_DataFrame &);
- BOOL Write(const BYTE * buffer, unsigned length, const RTP_DataFrame & rtp, unsigned & frames);
- };
- class G7231_File_Capability : public H323AudioCapability
- {
- PCLASSINFO(G7231_File_Capability, H323AudioCapability)
- public:
- G7231_File_Capability();
- unsigned GetSubType() const { return H245_AudioCapability::e_g7231; }
- H323Codec * CreateCodec(H323Codec::Direction direction) const;
- PString GetFormatName() const;
- BOOL OnSendingPDU(H245_AudioCapability & cap, unsigned packetSize) const;
- BOOL OnReceivedPDU(const H245_AudioCapability & pdu, unsigned & packetSize);
- PObject * Clone() const;
- };
- #endif // _Voxilla_MAIN_H
- // End of File ///////////////////////////////////////////////////////////////