www.pudn.com > openphone_1.9.1.zip > main.h, change:2003-05-14,size:20146b


/* 
 * main.h 
 * 
 * PWLib application header file for OpenPhone 
 * 
 * Open H323 Library 
 * 
 * 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 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 
 * Vovida Networks, Inc. http://www.vovida.com. 
 * 
 * Portions are Copyright (C) 1993 Free Software Foundation, Inc. 
 * All Rights Reserved. 
 * 
 * Contributor(s): Portions Copyright 1999 NEWLINK 
 * 
 * $Log: main.h,v $ 
 * Revision 1.61  2003/05/14 13:53:48  rjongbloed 
 * Added "Start Video" menu item. 
 * 
 * Revision 1.60  2003/05/02 05:28:54  craigs 
 * Added support for H.263 
 * 
 * Revision 1.59  2003/03/17 08:23:53  robertj 
 * Removed openh323 versions of videoio.h classes as PVideoOutputDevice 
 *   descendants for NULL and PPM files added to PWLib. 
 * Moved window PVideoOutputDevice descendant to PWlib. 
 * 
 * Revision 1.58  2003/02/05 04:16:15  robertj 
 * Added MicroTelco configuration dialog. 
 * 
 * Revision 1.57  2002/11/27 06:55:04  robertj 
 * Added Call Credit display if gatekeeper supports it. 
 * 
 * Revision 1.56  2002/11/10 09:02:25  robertj 
 * Added ability to set router and interface addresses and listener port. 
 * 
 * Revision 1.55  2002/09/16 03:47:29  robertj 
 * Added ability to set font for controls. 
 * 
 * Revision 1.54  2002/06/22 05:49:11  robertj 
 * Added partial implementation for H.450.11 Call Intrusion 
 * 
 * Revision 1.53  2002/05/21 02:43:40  robertj 
 * Added ability to record incoming media to WAV file. 
 * 
 * Revision 1.52  2002/05/17 05:56:47  robertj 
 * Removed T.38 as is this app is useless for testing. 
 * 
 * Revision 1.51  2002/04/12 06:08:42  robertj 
 * Added ability to set ports for TCP and RTP IDP. 
 * 
 * Revision 1.50  2002/03/05 08:02:55  robertj 
 * Added caller id output to Quicknet card. 
 * 
 * Revision 1.49  2002/02/01 01:46:08  robertj 
 * Fixed T.120 and T.38 callbacks, still debugging them! 
 * 
 * Revision 1.48  2002/01/17 07:03:30  robertj 
 * Added support for RFC2833 embedded DTMF in the RTP stream 
 * 
 * Revision 1.47  2002/01/15 06:39:54  robertj 
 * Added support for VOIP blaster 
 * 
 * Revision 1.46  2002/01/08 02:12:00  robertj 
 * Fixed bad override of PVideoDevice::SetFrameSize so didn't resize window. 
 * 
 * Revision 1.45  2001/11/01 01:35:25  robertj 
 * Added default Fast Start disabled and H.245 tunneling disable flags 
 *   to the endpoint instance. 
 * 
 * Revision 1.44  2001/10/25 01:21:31  robertj 
 * Fixed incorrect type for virtual so does not override correctly, this causing 
 *   video window not to be opened, thanks Robert Lupa & Kurt Michael Krauss 
 * 
 * Revision 1.43  2001/07/17 04:44:32  robertj 
 * Partial implementation of T.120 and T.38 logical channels. 
 * 
 * Revision 1.42  2001/05/23 10:06:58  robertj 
 * Added ability to send fake video, thanks Paonza 
 * 
 * Revision 1.41  2001/05/01 05:25:34  robertj 
 * Added command to do H.450.x call hold function. 
 * 
 * Revision 1.40  2001/04/11 03:01:30  robertj 
 * Added H.450.2 (call transfer), thanks a LOT to Graeme Reid & Norwood Systems 
 * 
 * Revision 1.39  2001/03/30 07:54:46  robertj 
 * Added VU meters. 
 * 
 * Revision 1.38  2001/03/03 05:59:17  robertj 
 * Major upgrade of video conversion and grabbing classes. 
 * 
 * Revision 1.37  2000/12/19 22:43:13  dereks 
 * Add calls to use the video channel, rather than video device 
 * Better handles the case where the grabber could not be opened. 
 * 
 * Revision 1.36  2000/12/01 00:09:53  robertj 
 * Rearranged sliders for adjusting silence detect delays. 
 * 
 * Revision 1.35  2000/11/30 05:16:24  robertj 
 * Added ability to adjust the silence detection deadband times. 
 * 
 * Revision 1.34  2000/11/27 00:42:42  robertj 
 * Added detection of tones and hookflash on xJACK to be sent via UserIndication. 
 * Added forced test for PSTN line on startup. 
 * 
 * Revision 1.33  2000/07/31 14:08:19  robertj 
 * Added fast start and H.245 tunneling flags to the H323Connection constructor so can 
 *    disabled these features in easier manner to overriding virtuals. 
 * 
 * Revision 1.32  2000/07/02 09:14:09  robertj 
 * Fixed problems with closing video receive window under Win32. 
 * 
 * Revision 1.31  2000/06/29 06:20:53  robertj 
 * Fixed deadlock when exiting application while in a call. 
 * 
 * Revision 1.30  2000/06/15 01:46:15  robertj 
 * Added channel pause (aka mute) functions. 
 * 
 * Revision 1.29  2000/06/07 05:48:06  robertj 
 * Added call forwarding. 
 * 
 * Revision 1.28  2000/05/10 05:16:00  robertj 
 * Added hook flash to user indications. Also allowed selection of the User Indication 
 *    method to be used in the H.245 protocol. 
 * 
 * Revision 1.27  2000/05/04 11:53:38  robertj 
 * Added Packets Too Late statistics. 
 * Fixed gatekeeper detection so if "required", disables call menus. 
 * 
 * Revision 1.26  2000/05/01 08:20:28  robertj 
 * Fixed capability loading so do not need to restart program when altering video parameters. 
 * 
 * Revision 1.25  2000/04/19 02:07:29  robertj 
 * Fixed problems with video window. 
 * 
 * Revision 1.24  2000/04/11 03:59:33  robertj 
 * Added new call end reasons for gatekeeper denied calls. 
 * 
 * Revision 1.23  2000/04/05 20:56:47  robertj 
 * Added more statistics. 
 * 
 * Revision 1.22  2000/03/04 13:44:00  robertj 
 * Added timer to ring every 5 seconds and not just once! 
 * 
 * Revision 1.21  2000/03/04 12:16:55  robertj 
 * Added ring sound file to standard sound device on incoming calls. 
 * 
 * Revision 1.20  2000/02/17 12:25:17  robertj 
 * Added user indication send/receive and option to disable H.245 tunneling. 
 * 
 * Revision 1.19  1999/12/23 23:02:35  robertj 
 * File reorganision for separating RTP from H.323 and creation of LID for VPB support. 
 * 
 * Revision 1.18  1999/11/22 11:20:47  robertj 
 * Fixed problem with handset pick up while making H.323 call but before connected. 
 * 
 * Revision 1.17  1999/11/19 13:00:52  robertj 
 * Added HangingUp state so can't start new call till old one fully cleared. 
 * 
 * Revision 1.16  1999/11/17 03:49:51  robertj 
 * Added RTP statistics display. 
 * 
 * Revision 1.15  1999/11/16 13:22:24  robertj 
 * Improved versioning in about dialog (version number now in single place) 
 * 
 * Revision 1.14  1999/11/13 14:11:56  robertj 
 * Changes to make silence detection selectable. 
 * 
 * Revision 1.13  1999/11/11 23:14:40  robertj 
 * Fixed turning off ring on answering call and disabling call menu if initialisation failed. 
 * 
 * Revision 1.12  1999/11/11 08:54:27  robertj 
 * Changed preferred codec function to be full codec ordering. 
 * 
 * Revision 1.11  1999/11/11 01:20:48  robertj 
 * Numerous enhancements to get nearly feature complete for version 1. 
 * 
 * Revision 1.10  1999/11/06 03:48:36  robertj 
 * Added shells for mute functions 
 * 
 * Revision 1.9  1999/11/05 08:54:41  robertj 
 * Rewrite of ixj interface code to fix support for arbitrary codecs. 
 * 
 * Revision 1.8  1999/11/01 00:50:16  robertj 
 * Added receive H.261 video window 
 * 
 * Revision 1.7  1999/10/30 12:45:47  robertj 
 * Added stop channel message, outside line message and G728/G729 interlock for LineJACK 
 * 
 * Revision 1.6  1999/10/29 02:26:52  robertj 
 * Added scrollable status window and better termination information. 
 * 
 * Revision 1.5  1999/10/28 12:21:34  robertj 
 * Added AEC support and speakerphone switching button. 
 * 
 * Revision 1.4  1999/10/27 06:32:50  robertj 
 * Changes to prevent H225 alerting message being sent if "engaged". 
 * 
 * Revision 1.3  1999/10/24 12:59:40  robertj 
 * Added platform independent support for Quicknet xJACK cards. 
 * 
 * Revision 1.2  1999/10/07 07:37:31  robertj 
 * Added auto-answer and trace options (thanks David Iodice of NEWLINK) 
 * 
 * Revision 1.1  1999/08/25 05:16:11  robertj 
 * GUI test application. 
 * 
 * Revision 1.3  1999/05/24 03:03:08  robertj 
 * Fixed include paths after restructure (much belated). 
 * 
 * Revision 1.2  1999/01/26 06:35:08  robertj 
 * Fixed $LOG$ variable in template files 
 * 
 */ 
 
#ifndef _OpenPhone_MAIN_H 
#define _OpenPhone_MAIN_H 
 
#include "h323.h" 
#include <pwclib/vidwin.h> 
 
 
//#define TESTING_T120 
//#define TESTING_T38 
 
#ifdef TESTING_T120 
#include "t120proto.h" 
#endif 
 
#ifdef TESTING_T38 
#include "t38proto.h" 
#endif 
 
 
class MainWindow; 
class MainMenu; 
class StatisticsDlg; 
class OpalLineInterfaceDevice; 
class OpalRtpToWavFile; 
 
 
/////////////////////////////////////////////////////// 
 
class OpenPhoneEndPoint : public H323EndPoint 
{ 
  PCLASSINFO(OpenPhoneEndPoint, H323EndPoint); 
 
  public: 
    OpenPhoneEndPoint(MainWindow * mainWindow); 
    ~OpenPhoneEndPoint(); 
 
    // overrides from H323EndPoint 
    BOOL OnIncomingCall(H323Connection &, const H323SignalPDU &, H323SignalPDU &); 
    BOOL OnConnectionForwarded(H323Connection &, const PString &, const H323SignalPDU &); 
    void OnConnectionEstablished(H323Connection &, const PString &); 
    void OnConnectionCleared    (H323Connection &, const PString &); 
  
    H323Connection * CreateConnection(unsigned callReference); 
    void TranslateTCPAddress(PIPSocket::Address &localAddr, const PIPSocket::Address &remoteAddr); 
    BOOL OpenAudioChannel(H323Connection &, BOOL, unsigned, H323AudioCodec &); 
    BOOL OpenVideoChannel(H323Connection &, BOOL, H323VideoCodec &); 
    BOOL OnStartLogicalChannel(H323Connection &, H323Channel &); 
    void OnClosedLogicalChannel(H323Connection &, const H323Channel &); 
    void OnRTPStatistics(const H323Connection &, const RTP_Session &) const; 
    void OnCallCreditServiceControl(const PString &, BOOL); 
 
#ifdef TESTING_T120 
    virtual OpalT120Protocol * CreateT120ProtocolHandler(const H323Connection &) const; 
#endif 
 
    // new functions 
    BOOL Initialise(PConfig & config); 
    BOOL OpenLID(PConfig & config); 
    void CloseLID(); 
    BOOL FindGatekeeper(PConfig & config); 
    void LoadCapabilities(PConfig & config); 
 
    OpalLineInterfaceDevice * lid; 
    unsigned potsLine, pstnLine; 
    unsigned silenceDeadband, signalDeadband; 
    PIPSocket::Address router; 
    PString alwaysForwardParty; 
    PString busyForwardParty; 
    int  videoSize; 
    int videoWidth; 
    int videoHeight; 
    BOOL localVideo; 
    BOOL localFlip; 
    BOOL remoteFlip; 
    BOOL h261Enable; 
    BOOL h263Enable; 
    int fps; 
    int maxbw; 
 
  protected: 
    PDECLARE_NOTIFIER(PThread, OpenPhoneEndPoint, HandleLID); 
 
    MainWindow * mainWindow; 
    PThread    * phoneThread; 
    BOOL         findingGatekeeper; 
    unsigned     creditMsgId; 
    PString      creditAmount; 
}; 
 
 
/////////////////////////////////////////////////////// 
 
class OpenPhoneConnection : public H323Connection 
{ 
  PCLASSINFO(OpenPhoneConnection, H323Connection); 
 
  public: 
    OpenPhoneConnection( 
      OpenPhoneEndPoint & mgr, 
      unsigned callReference, 
      MainWindow * mainWindow 
    ); 
 
    // overrides from H323Connection 
    AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &); 
    BOOL OnAlerting(const H323SignalPDU &, const PString &); 
    void OnUserInputString(const PString &); 
 
  protected: 
    OpenPhoneEndPoint & myEndpoint; 
    MainWindow * mainWindow; 
}; 
 
 
/////////////////////////////////////////////////////// 
 
class MyVideoWindow : public PVideoOutputFloatingDialog 
{ 
  PCLASSINFO(MyVideoWindow, PVideoOutputFloatingDialog); 
  
  public: 
    MyVideoWindow( 
      PInteractor * parent, 
      const PString & title, 
      BOOL local 
    ); 
 
    virtual void OnClose(); 
    virtual void _SetDimensions( 
      PDIMENSION width,         /// New width to apply to interactor. 
      PDIMENSION height,        /// New height to apply to interactor. 
      CoordinateSystem coords   /// Coordinate system to use. 
    ); 
 
  protected: 
    BOOL localVideo; 
};  
 
 
/////////////////////////////////////////////////////// 
 
class VUMeter : public PInteractor 
{ 
  PCLASSINFO(VUMeter, PInteractor); 
  
  public: 
    VUMeter( 
      PInteractor * parent,       // Parent interactor 
      unsigned maxLevel = 32767, 
      BOOL logScale = FALSE 
    ); 
 
    void SetMaximumLevel( 
      unsigned level 
    ); 
 
    void SetMarkerLevel( 
      unsigned level 
    ); 
 
    void SetCurrentLevel( 
      unsigned level 
    ); 
 
  protected: 
    virtual unsigned ScaleLevel(unsigned level); 
 
    virtual void OnRedraw(PCanvas &); 
 
    BOOL     logarithmic; 
    unsigned maximumLevel; 
 
    unsigned markerPosition;  // These are always log scaled. 
    unsigned currentPosition; 
}; 
 
 
/////////////////////////////////////////////////////// 
 
class MainWindow : public PTopLevelWindow 
{ 
  PCLASSINFO(MainWindow, PTopLevelWindow) 
   
  public: 
    MainWindow(PArgList & args); 
    ~MainWindow(); 
 
    PDECLARE_COMMAND_ENABLE("MakeCall",    MainWindow, CallCmd, CanMakeCall); 
    PDECLARE_COMMAND_ENABLE("HangupCall",  MainWindow, HangupCmd, CanHangupCall); 
    PDECLARE_COMMAND_ENABLE("AcceptCall",  MainWindow, AcceptCallCmd, CanAcceptCall); 
    PDECLARE_COMMAND_ENABLE("RefuseCall",  MainWindow, RefuseCallCmd, CanRefuseCall); 
    PDECLARE_COMMAND_ENABLE("TransferCall",MainWindow, TransferCmd, CanTransferCall); 
    PDECLARE_COMMAND_ENABLE("HoldCall",    MainWindow, HoldCmd, CanHoldCall); 
    PDECLARE_COMMAND_ENABLE("IntrudeCall", MainWindow, IntrudeCmd, CanIntrudeCall); 
 
    PDECLARE_NOTIFIER(PMenuItem, MainWindow, UserInputCmd); 
 
    PDECLARE_COMMAND_ENABLE("ShowStats",   MainWindow, ShowStatsCmd, CanShowStats); 
    PDECLARE_COMMAND_ENABLE("StartVideo",  MainWindow, StartVideoCmd, CanStartVideo); 
    PDECLARE_COMMAND_ENABLE("MuteMicrophone", MainWindow, MuteMicrophoneCmd, CanMuteMicrophone); 
    PDECLARE_COMMAND_ENABLE("MuteSpeaker", MainWindow, MuteSpeakerCmd, CanMuteSpeaker); 
    PDECLARE_COMMAND_ENABLE("RecordMedia", MainWindow, RecordMediaCmd, CanRecordMedia); 
    PDECLARE_COMMAND_ENABLE("StopRecording", MainWindow, StopRecordingCmd, CanStopRecording); 
 
    PDECLARE_COMMAND("ExitCmd", MainWindow, ExitCmd); 
 
    PDECLARE_COMMAND("SpeedDialOptions",  MainWindow, SpeedDialOptionsCmd); 
    PDECLARE_COMMAND("GeneralOptions",    MainWindow, GeneralOptionsCmd); 
    PDECLARE_COMMAND("FontOption",        MainWindow, FontOptionCmd); 
    PDECLARE_COMMAND("NetworkingOptions", MainWindow, NetworkingOptionsCmd); 
    PDECLARE_COMMAND("ForwardingOptions", MainWindow, ForwardingOptionsCmd); 
    PDECLARE_COMMAND_ENABLE("GatekeeperOptions", MainWindow, GatekeeperOptionsCmd, CanSetGatekeeper); 
    PDECLARE_COMMAND_ENABLE("MicroTelcoSetUp", MainWindow, MicroTelcoSetUpCmd, CanSetMicroTelcoSetUp); 
    PDECLARE_COMMAND("AudioDeviceOptions",MainWindow, AudioDeviceOptionsCmd); 
    PDECLARE_COMMAND("AudioCodecOptions", MainWindow, AudioCodecOptionsCmd); 
    PDECLARE_COMMAND("VideoOptions",      MainWindow, VideoOptionsCmd); 
#if PTRACING 
    PDECLARE_COMMAND("TraceOptions",      MainWindow, TraceOptionsCmd); 
#endif 
 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnCallButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnIntrudeButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnAnswerButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnRefuseButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnHangUpButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnSpeakerButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnTransferButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnHoldButton); 
    PDECLARE_NOTIFIER(PTextButton, MainWindow, OnSpeedDialButton); 
    PDECLARE_NOTIFIER(PCheckBox, MainWindow, OnSpeakerEnable); 
    PDECLARE_NOTIFIER(PCheckBox, MainWindow, OnMicrophoneEnable); 
    PDECLARE_NOTIFIER(PHorizontalScrollBar, MainWindow, OnSpeakerVolume); 
    PDECLARE_NOTIFIER(PHorizontalScrollBar, MainWindow, OnMicrophoneVolume); 
 
    void OutputStatus(PRESOURCE_ID strId, ...); 
 
    virtual BOOL AllowClose(BOOL closingAll); 
    virtual void OnClose(); 
    virtual void OnResize(const PDim & newSize, ResizeType type); 
 
    BOOL OnAnswerCall(const H323Connection & connection); 
    BOOL OnConnectionForwarded(const PString &); 
    void OnConnectionEstablished(const PString & token, const PString & party); 
    void OnConnectionCleared(const H323Connection & connection); 
    void OnLogicalChannel(const H323Channel & channel, unsigned txStrID, unsigned rxStrID); 
    void OnHandsetLifted(OpalLineInterfaceDevice & lid); 
    void OnHandsetReturned(OpalLineInterfaceDevice & lid); 
    void SendUserInput(char tone); 
 
    enum CallMode { 
      IdleCallMode, 
      MakingCallMode, 
      HangingUpMode, 
      IncomingCallWait, 
      IncomingLineCall, 
      Active323CallMode, 
      ActiveLineCallMode, 
      NoGatekeeperMode, 
      ApplicationShuttingDown, 
      IncomingCallIntrusion 
    }; 
    CallMode GetCallMode() const { return currentCallMode; } 
    void SetCallMode(CallMode mode); 
 
    StatisticsDlg * statisticsDialog; 
 
 
  private: 
    void AddSpeedDialButtons(); 
    BOOL SpeedDial(const PString & key); 
    BOOL MakeCall(const PString & address, const PString & gateway); 
    BOOL IntrudeCall(const PString & address, const PString & gateway, unsigned capabilityLevel); 
    void AnswerCall(BOOL accept); 
 
    OpenPhoneEndPoint endpoint; 
 
    // User interface variables 
    MainMenu *  myMainMenu; 
    PStringListBox * statusWindow; 
    PTextButton * makeCallButton; 
    PTextButton * answerButton; 
    PTextButton * refuseButton; 
    PTextButton * hangUpButton; 
    PTextButton * transferButton; 
    PTextButton * holdButton; 
    PTextButton * intrudeCallButton; 
 
    PTextButton * speakerButton; 
    PCheckBox * speakerEnable; 
    PHorizontalScrollBar * speakerVolume; 
    VUMeter * speakerVU; 
 
    PCheckBox * microphoneEnable; 
    PHorizontalScrollBar * microphoneVolume; 
    VUMeter * microphoneVU; 
 
    PInteractorList speedDialButtons; 
 
    PTimer ringSoundTimer; 
    PDECLARE_NOTIFIER(PTimer, MainWindow, OnRingSoundAgain); 
 
    PString       noAnswerForwardParty; 
    PTimeInterval noAnswerTime; 
    PTimer        noAnswerTimer; 
    PDECLARE_NOTIFIER(PTimer, MainWindow, OnNoAnswerTimeout); 
 
    PTimer vuTimer; 
    PDECLARE_NOTIFIER(PTimer, MainWindow, OnUpdateVU); 
 
    // Configuration variables 
    BOOL    autoAnswer; 
    PINDEX  maxRecentCalls; 
    PString ringSoundFile; 
 
    // State variables 
    CallMode currentCallMode; 
    PMutex   callModeMutex; 
    PString  currentCallToken; 
    BOOL     speakerphoneSwitch; 
 
    OpalRtpToWavFile * recorder; 
 
#if PTRACING 
    BOOL OpenTraceFile(PConfig & config); 
    PTextFile * myTraceFile; 
#endif 
}; 
 
 
/////////////////////////////////////////////////////// 
 
#ifdef TESTING_T120 
class MyT120Protocol : public OpalT120Protocol 
{ 
    PCLASSINFO(MyT120Protocol, OpalT120Protocol); 
  public: 
    MyT120Protocol() { } 
}; 
#endif 
 
     
/////////////////////////////////////////////////////// 
 
#ifdef TESTING_T38 
class MyT38Protocol : public OpalT38Protocol 
{ 
    PCLASSINFO(MyT38Protocol, OpalT38Protocol); 
  public: 
    MyT38Protocol() { } 
}; 
#endif 
 
 
/////////////////////////////////////////////////////// 
 
class OpenPhone : public PApplication 
{ 
  PCLASSINFO(OpenPhone, PApplication) 
 
  public: 
    OpenPhone(); 
    void Main(); 
    void OnAbout(); 
}; 
 
 
#endif  // _OpenPhone_MAIN_H 
 
 
// End of File ///////////////////////////////////////////////////////////////