main.h
上传用户:sdyzjx
上传日期:2007-01-06
资源大小:47k
文件大小:14k
- /*
- * 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.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 "videoio.h"
- #include "ixjlid.h"
- class MainWindow;
- class MainMenu;
- class QuicknetThread;
- class StatisticsDlg;
- ///////////////////////////////////////////////////////
- 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);
- BOOL OpenAudioChannel(H323Connection &, BOOL, unsigned, H323AudioCodec &);
- BOOL OpenVideoDevice(H323Connection &, BOOL, H323VideoCodec &);
- BOOL OnStartLogicalChannel(H323Connection &, H323Channel &);
- void OnClosedLogicalChannel(H323Connection &, const H323Channel &);
- void OnRTPStatistics(const H323Connection &, const RTP_Session &) const;
- // new functions
- BOOL Initialise(PConfig & config);
- BOOL OpenQuicknet(PConfig & config);
- void CloseQuicknet();
- BOOL FindGatekeeper(PConfig & config);
- void LoadCapabilities(PConfig & config);
- OpalIxJDevice xJack;
- BOOL noFastStart;
- BOOL noTunneling;
- BOOL silenceDetect;
- PString alwaysForwardParty;
- PString busyForwardParty;
- int videoSize;
- protected:
- MainWindow * mainWindow;
- QuicknetThread * phoneThread;
- };
- ///////////////////////////////////////////////////////
- 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 OnSelectLogicalChannels();
- BOOL OnOpenLogicalChannel(const H245_OpenLogicalChannel &,
- H245_OpenLogicalChannelAck &,
- unsigned &);
- void OnUserInputString(const PString &);
- protected:
- OpenPhoneEndPoint & myEndpoint;
- MainWindow * mainWindow;
- };
- ///////////////////////////////////////////////////////
- class QuicknetThread : public PThread
- {
- PCLASSINFO(QuicknetThread, PThread);
- public:
- QuicknetThread(MainWindow * mainWindow, OpalIxJDevice & xJack);
- void Main();
- private:
- MainWindow * mainWindow;
- OpalIxJDevice & xJack;
- };
- ///////////////////////////////////////////////////////
- class VideoDevice;
- class VideoWindow : public PFloatingDialog
- {
- PCLASSINFO(VideoWindow, PFloatingDialog);
-
- public:
- VideoWindow(PInteractor * parent, VideoDevice * device, BOOL local);
- ~VideoWindow();
- void SetVideoSize(int _width, int _height);
- BOOL WriteLineSegment(int x, int y, unsigned len, const BYTE * data);
- virtual void OnCancel();
- protected:
- virtual void OnClose();
- virtual void OnRedraw(PCanvas &);
- void Shutdown();
- VideoDevice * device;
- BOOL localVideo;
- PDrawCanvas * canvas;
- PPixelImage image;
- PPixelImage raster;
- PMutex mutex;
- };
- ///////////////////////////////////////////////////////
- class VideoDevice : public H323VideoDevice
- {
- PCLASSINFO(VideoDevice, H323VideoDevice);
-
- public:
- VideoDevice(MainWindow * mainWindow, BOOL local, const PString & title);
- ~VideoDevice();
- void SetSize(int _width, int _height);
- protected:
- BOOL WriteLineSegment(int x, int y, unsigned len, const BYTE * data);
- VideoWindow * window;
- BOOL windowOpen;
- friend class VideoWindow;
- };
- ///////////////////////////////////////////////////////
- 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_NOTIFIER(PMenuItem, MainWindow, UserInputCmd);
- PDECLARE_COMMAND_ENABLE("ShowStats", MainWindow, ShowStatsCmd, CanShowStats);
- PDECLARE_COMMAND_ENABLE("MuteMicrophone", MainWindow, MuteMicrophoneCmd, CanMuteMicrophone);
- PDECLARE_COMMAND_ENABLE("MuteSpeaker", MainWindow, MuteSpeakerCmd, CanMuteSpeaker);
- PDECLARE_COMMAND("ExitCmd", MainWindow, ExitCmd);
- PDECLARE_COMMAND("SpeedDialOptions", MainWindow, SpeedDialOptionsCmd);
- PDECLARE_COMMAND("GeneralOptions", MainWindow, GeneralOptionsCmd);
- PDECLARE_COMMAND("ForwardingOptions", MainWindow, ForwardingOptionsCmd);
- PDECLARE_COMMAND_ENABLE("GatekeeperOptions", MainWindow, GatekeeperOptionsCmd, CanSetGatekeeper);
- PDECLARE_COMMAND("AudioOptions", MainWindow, AudioOptionsCmd);
- PDECLARE_COMMAND("VideoOptions", MainWindow, VideoOptionsCmd);
- #if PTRACING
- PDECLARE_COMMAND("TraceOptions", MainWindow, TraceOptionsCmd);
- #endif
- PDECLARE_NOTIFIER(PTextButton, MainWindow, OnCallButton);
- PDECLARE_NOTIFIER(PTextButton, MainWindow, OnAnswerButton);
- PDECLARE_NOTIFIER(PTextButton, MainWindow, OnRefuseButton);
- PDECLARE_NOTIFIER(PTextButton, MainWindow, OnHangUpButton);
- PDECLARE_NOTIFIER(PTextButton, MainWindow, OnSpeakerButton);
- 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 PString & token, const PString & caller);
- 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(OpalIxJDevice & xJack);
- void OnHandsetReturned(OpalIxJDevice & xJack);
- enum CallMode {
- IdleCallMode,
- MakingCallMode,
- HangingUpMode,
- IncomingCallWait,
- IncomingLineCall,
- Active323CallMode,
- ActiveLineCallMode,
- NoGatekeeperMode,
- ApplicationShuttingDown
- };
- 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);
- void AnswerCall(BOOL accept);
- OpenPhoneEndPoint endpoint;
- // User interface variables
- MainMenu * myMainMenu;
- PStringListBox * statusWindow;
- PTextButton * makeCallButton;
- PTextButton * answerButton;
- PTextButton * refuseButton;
- PTextButton * hangUpButton;
- PTextButton * speakerButton;
- PCheckBox * speakerEnable;
- PHorizontalScrollBar * speakerVolume;
- PCheckBox * microphoneEnable;
- PHorizontalScrollBar * microphoneVolume;
- PInteractorList speedDialButtons;
- PTimer ringSoundTimer;
- PDECLARE_NOTIFIER(PTimer, MainWindow, OnRingSoundAgain);
- PString noAnswerForwardParty;
- PTimeInterval noAnswerTime;
- PTimer noAnswerTimer;
- PDECLARE_NOTIFIER(PTimer, MainWindow, OnNoAnswerTimeout);
- // Configuration variables
- BOOL autoAnswer;
- BOOL dtmfAsString;
- PINDEX maxRecentCalls;
- PString ringSoundFile;
- // State variables
- CallMode currentCallMode;
- PMutex callModeMutex;
- PString currentCallToken;
- BOOL speakerphoneSwitch;
- #if PTRACING
- BOOL OpenTraceFile(PConfig & config);
- PTextFile * myTraceFile;
- #endif
- };
- ///////////////////////////////////////////////////////
- class OpenPhone : public PApplication
- {
- PCLASSINFO(OpenPhone, PApplication)
- public:
- OpenPhone();
- void Main();
- void OnAbout();
- };
- #endif // _OpenPhone_MAIN_H
- // End of File ///////////////////////////////////////////////////////////////