main.h
上传用户:gnaf34
上传日期:2022-04-22
资源大小:1657k
文件大小:9k
源码类别:

IP电话/视频会议

开发平台:

Visual C++

  1. /*
  2.  * main.h
  3.  *
  4.  * Header file
  5.  *
  6.  * Copyright (c) ITEC-Ohio, 2002.
  7.  *
  8.  * The contents of this file are subject to the Mozilla Public License
  9.  * Version 1.0 (the "License"); you may not use this file except in
  10.  * compliance with the License. You may obtain a copy of the License at
  11.  * http://www.mozilla.org/MPL/
  12.  *
  13.  * Software distributed under the License is distributed on an "AS IS"
  14.  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  15.  * the License for the specific language governing rights and limitations
  16.  * under the License.
  17.  *
  18.  * The Original Code is Open H323 Library available at http://www.openh323.org
  19.  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
  20.  *
  21.  */
  22. #ifndef _BeaconClient_MAIN_H
  23. #define _BeaconClient_MAIN_H
  24. #include <h323.h>
  25. //#include <afxsock.h>
  26. //#include <afxtempl.h>
  27. #ifdef _WIN32
  28. #include <vblasterlid.h>
  29. #endif
  30. #ifdef HAS_IXJ
  31. #include <ixjlid.h>
  32. #endif
  33. #if defined(HAS_IXJ) || defined(HAS_VBLASTER)
  34. #define HAS_LIDDEVICE
  35. #endif
  36. #ifdef __BEOS__
  37. #ifndef _APPLICATION_H
  38. #include <Application.h>
  39. #endif
  40. //forward declaration
  41. //class MyH323EndPoint;
  42. class BeaconClientApplication : public BApplication 
  43. {
  44.   public:
  45.     BeaconClientApplication()
  46.       : BApplication("application/x-vnd.BeBeaconClient") { }
  47. };
  48. BeaconClientApplication BeaconClientApp;
  49. #endif
  50. /*class BeaconClient : public PProcess
  51. //class BeaconClient 
  52. {
  53.   PCLASSINFO(BeaconClient,PProcess);
  54.   public:
  55.     BeaconClient();
  56.     ~BeaconClient();
  57.     void Main();
  58. char* ipAddress;
  59. MyH323EndPoint* endpoint;
  60. };
  61. */
  62. class CallOptions : public PObject
  63. {
  64.   PCLASSINFO(CallOptions, PObject);
  65.   public:
  66.     BOOL Initialise(PArgList & args);
  67.     void PrintOn(ostream & str) const;
  68.     BOOL   noFastStart;
  69.     BOOL   noH245Tunnelling;
  70.     BOOL   noSilenceSuppression;
  71.     int    jitter;
  72.     PINDEX connectRing;
  73.     WORD   connectPort;
  74. };
  75. class MyH323EndPoint : public H323EndPoint
  76. {
  77.     PCLASSINFO(MyH323EndPoint, H323EndPoint);
  78.   public:
  79.     // overrides from H323EndPoint
  80.     virtual H323Connection * CreateConnection(unsigned callReference);
  81.     //virtual BOOL OnIncomingCall(H323Connection &, const H323SignalPDU &, H323SignalPDU &);
  82.     //virtual BOOL OnConnectionForwarded(H323Connection &, const PString &, const H323SignalPDU &);
  83.     virtual void OnConnectionEstablished(H323Connection &, const PString &);
  84.     virtual void OnConnectionCleared(H323Connection &, const PString &);
  85.     virtual BOOL OpenAudioChannel(H323Connection &, BOOL, unsigned, H323AudioCodec &);
  86.     virtual BOOL OpenVideoChannel(H323Connection &, BOOL, H323VideoCodec &);
  87.     //virtual H323Connection * SetupTransfer(const PString &, const PString &, const PString &, PString &);
  88.     // new functions
  89. BOOL MyH323EndPoint::Initialise(PString AudioCodec);
  90.     BOOL Initialise(PConfigArgs & args, int verbose, BOOL hasMenu);
  91.     void MakeOutgoingCall(const PString &, const PString &);
  92.     void MakeOutgoingCall(const PString &, const PString &, CallOptions callOptions);
  93.     void AwaitTermination();
  94.     void TriggerDisconnect();
  95.     void HandleUserInterface();
  96.     void StartRinging();
  97.     void StopRinging();
  98.     void HandleRinging();
  99.     //void TestVideoGrabber();
  100.     void TestHandleUserInterface();
  101. #ifdef HAS_LIDDEVICE
  102.     void HandleStateChange(BOOL onHook);
  103.     void HandleHandsetOffHook();
  104.     void HandleHandsetOnHook();
  105.     void HandleHandsetDTMF(PString & digits);
  106.     void HandleHandsetTimeouts(const PTime & offHookTime);
  107. #endif
  108.     void SendDTMF(const char * tone);
  109.     void StartCall(const PString & str);
  110.     //void NewSpeedDial(const PString & str);
  111.     //void ListSpeedDials();
  112.     PDECLARE_NOTIFIER(PTimer, MyH323EndPoint, OnAutoDisconnect);
  113.     PString GetCurrentCallToken() const
  114.       { return currentCallToken; }
  115.     BOOL       terminateOnHangup;
  116. PString currentCallToken;
  117.     PString callTransferCallToken;
  118.     enum {
  119.       uiDialtone,
  120.       uiAnsweringCall,
  121.       uiConnectingCall,
  122.       uiWaitingForAnswer,
  123.       uiCallInProgress,
  124.       uiCallHungup,
  125.       uiStateIllegal,
  126.     } uiState;
  127.   protected:
  128.     // only used internally
  129.     //BOOL SetSoundDevice(PConfigArgs &, const char *, PSoundChannel::Directions);
  130.     void AnswerCall(H323Connection::AnswerCallResponse response);
  131.     CallOptions defaultCallOptions;
  132.     CallOptions currentCallOptions;
  133.     int  verbose;
  134.     BOOL autoAnswer;
  135.     PString  alwaysForwardParty;
  136.     PString  busyForwardParty;
  137.     PString  noAnswerForwardParty;
  138.     unsigned noAnswerTime;
  139.     PTimer   noAnswerTimer;
  140.    
  141.     PString videoReceiveDevice;
  142.     int  videoQuality;
  143.     int  videoTxQuality;
  144.     int  videoSize;       //0=small, 1=large.
  145.     int  videoInput;
  146.     int  videoQ;           
  147.     int  videoFill;
  148.     int  videoFramesPS;
  149.     int  videoBitRate;
  150.     BOOL    videoIsPal;
  151.     BOOL    videoFake;    
  152.     BOOL    videoLocal;
  153.     BOOL    videoPIP;
  154.     PString videoDevice;
  155.     PString pfdColourFormat;
  156.     int     videoCu30Stats;
  157.     PString configDirectory;
  158. // used for testing the video (no connection made).
  159.     PVideoChannel *localVideoChannel; 
  160.     PString autoDial;
  161.     BOOL    dialAfterHangup;
  162.     BOOL    callerIdEnable;
  163.     BOOL    callerIdCallWaitingEnable;
  164.     PString setupParameter;
  165.     PFilePath ringFile;
  166.     int ringDelay;
  167.     PSyncPoint ringFlag;
  168.     PThread * ringThread;
  169.     int autoDisconnect;
  170.     PTimer autoDisconnectTimer;
  171.     int recordVolume;
  172.     int playVolume;
  173. #ifdef HAS_OSS
  174.     BOOL InitialiseMixer(PConfigArgs & args, int _verbose);
  175.     int  mixerDev;
  176.     int  mixerRecChan;
  177.     int  savedMixerRecChan;
  178.     int  ossRecVol;
  179.     int  ossPlayVol;
  180. #endif
  181.    
  182.     PMutex uiStateMutex;
  183.     PSyncPoint exitFlag;
  184.     BOOL       speakerphoneSwitch;
  185.     BOOL       hasMenu;
  186.     BOOL autoHook;
  187.     OpalLineInterfaceDevice * lidDevice;
  188.     BOOL isXJack;
  189.   friend class MyH323Connection;
  190. };
  191. /* New One */
  192. class MyH323Connection : public H323Connection
  193. {
  194.     PCLASSINFO(MyH323Connection, H323Connection);
  195.   public:
  196.     MyH323Connection(MyH323EndPoint &, unsigned, unsigned, WORD, int);
  197.     // overrides from H323Connection
  198.     BOOL OnSendSignalSetup(H323SignalPDU & setupPDU);
  199.     AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
  200.     BOOL OnStartLogicalChannel(H323Channel &);
  201.     void OnClosedLogicalChannel(H323Channel &);
  202.     BOOL OnAlerting(const H323SignalPDU &, const PString &);
  203.     void OnUserInputString(const PString &);
  204.     PString GetCallerIdString() const;
  205.   protected:
  206.     MyH323EndPoint & myEndpoint;
  207.     int verbose;
  208.     int channelsOpen;
  209. };
  210. /* Old one */
  211. /*
  212. class MyH323Connection : public H323Connection
  213. {
  214.     PCLASSINFO(MyH323Connection, H323Connection);
  215.   public:
  216.     MyH323Connection(MyH323EndPoint &, unsigned, BOOL, BOOL, WORD, int);
  217.     // overrides from H323Connection
  218.     BOOL OnSendSignalSetup(H323SignalPDU & setupPDU);
  219.     AnswerCallResponse OnAnswerCall(const PString &, const H323SignalPDU &, H323SignalPDU &);
  220.     BOOL OnStartLogicalChannel(H323Channel &);
  221.     void OnClosedLogicalChannel(H323Channel &);
  222.     BOOL OnAlerting(const H323SignalPDU &, const PString &);
  223.     void OnUserInputString(const PString &);
  224.     PString GetCallerIdString() const;
  225.   protected:
  226.     MyH323EndPoint & myEndpoint;
  227.     int verbose;
  228.     int channelsOpen;
  229. };
  230. */
  231. //////////////////////////////////////////////
  232. class UserInterfaceThread : public PThread
  233. {
  234.     PCLASSINFO(UserInterfaceThread, PThread);
  235.   public:
  236.     UserInterfaceThread(MyH323EndPoint & end)
  237.       : PThread(1000, NoAutoDeleteThread), endpoint(end) { Resume(); }
  238.     void Main()
  239.       { /*endpoint.HandleUserInterface();*/ }
  240.   protected:
  241.     MyH323EndPoint & endpoint;
  242. };
  243. //////////////////////////////////////////////
  244. class TestUserInterfaceThread : public PThread
  245. {
  246.     PCLASSINFO(TestUserInterfaceThread, PThread);
  247.   public:
  248.     TestUserInterfaceThread(MyH323EndPoint & end)
  249.       : PThread(1000, NoAutoDeleteThread), endpoint(end) { Resume(); }
  250.     void Main()
  251.       { /*endpoint.TestHandleUserInterface();*/ }
  252.   protected:
  253.     MyH323EndPoint & endpoint;
  254. };
  255. #endif  // _BeaconClient_MAIN_H
  256. class BeaconClient : public PProcess
  257. //class BeaconClient 
  258. {
  259.   PCLASSINFO(BeaconClient,PProcess);
  260.   public:
  261. //static const OnPhone myStaticInstance;
  262.     BeaconClient();
  263.     ~BeaconClient();
  264.     void Main();
  265. void Quit();
  266. int GetStatistics();
  267. int CheckConnections();
  268. PString GetCurrentToken();
  269. const char* ipAddress;
  270. MyH323EndPoint* endpoint;
  271. //GNUPlot related
  272. void PostString(HWND hwnd, CString pc1);
  273. char* FindUnquotedSpace( char *pc );
  274. int PrepareGnuPlot();
  275. int PrepareGnuPlotLatency();
  276. void ConvertPngToBmp(CString filepath);
  277. };
  278. ///////////////////////////////////////////////////////
  279. // End of File ///////////////////////////////////////////////////////////////