iax2ep.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * Inter Asterisk Exchange 2
00004  * 
00005  * Open Phone Abstraction Library (OPAL)
00006  *
00007  * Describes the IAX2 extension of the OpalEndpoint class.
00008  *
00009  * Copyright (c) 2005 Indranet Technologies Ltd.
00010  *
00011  * The contents of this file are subject to the Mozilla Public License
00012  * Version 1.0 (the "License"); you may not use this file except in
00013  * compliance with the License. You may obtain a copy of the License at
00014  * http://www.mozilla.org/MPL/
00015  *
00016  * Software distributed under the License is distributed on an "AS IS"
00017  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00018  * the License for the specific language governing rights and limitations
00019  * under the License.
00020  *
00021  * The Original Code is Open Phone Abstraction Library.
00022  *
00023  * The Initial Developer of the Original Code is Indranet Technologies Ltd.
00024  *
00025  * The author of this code is Derek J Smithies
00026  *
00027  *  $Log: iax2ep.h,v $
00028  *  Revision 1.4  2005/08/26 03:07:38  dereksmithies
00029  *  Change naming convention, so all class names contain the string "IAX2"
00030  *
00031  *  Revision 1.3  2005/08/24 01:38:38  dereksmithies
00032  *  Add encryption, iax2 style. Numerous tidy ups. Use the label iax2, not iax
00033  *
00034  *  Revision 1.2  2005/08/04 08:14:17  rjongbloed
00035  *  Fixed Windows build under DevStudio 2003 of IAX2 code
00036  *
00037  *  Revision 1.1  2005/07/30 07:01:32  csoutheren
00038  *  Added implementation of IAX2 (Inter Asterisk Exchange 2) protocol
00039  *  Thanks to Derek Smithies of Indranet Technologies Ltd. for
00040  *  writing and contributing this code
00041  *
00042  *
00043  *
00044  *
00045  *
00046  */
00047 
00048 #ifndef IAX_ENDPOINT_H
00049 #define IAX_ENDPOINT_H
00050 
00051 #include <ptlib.h>
00052 
00053 #ifdef P_USE_PRAGMA
00054 #pragma interface
00055 #endif
00056 
00057 #include <opal/endpoint.h>
00058 #include <iax2/iax2con.h>
00059 
00060 class IAX2Receiver;
00061 class IAX2Transmit;
00062 
00066 class IAX2IncomingEthernetFrames : public PThread
00067 {
00068   PCLASSINFO(IAX2IncomingEthernetFrames, PThread);
00069 public:
00070 
00074   IAX2IncomingEthernetFrames();
00075    
00077   ~IAX2IncomingEthernetFrames() { }
00078 
00081   /*The method which gets everythig to happen */
00082   virtual void Main();
00083    
00085   void Assign(IAX2EndPoint *ep);
00086 
00089   void ProcessList();
00090 
00092   void Terminate();
00093 
00095  protected:
00097   IAX2EndPoint *endpoint;
00098    
00100   PSyncPoint activate;
00101 
00103   BOOL           keepGoing;
00104 };
00105 
00106 
00108 class IAX2EndPoint : public OpalEndPoint
00109 {
00110   PCLASSINFO(IAX2EndPoint, OpalEndPoint);
00111  public:
00116   IAX2EndPoint(
00117     OpalManager & manager
00118   );
00119   
00121   ~IAX2EndPoint();
00123   
00130   virtual BOOL NewIncomingConnection(
00131     OpalTransport * transport  
00132   );
00133   
00163   virtual BOOL MakeConnection(
00164                               OpalCall & call,        
00165                               const PString & party,  
00166                               void * userData = NULL  
00167                               );
00168   
00172   virtual IAX2Connection * CreateConnection(
00173                                            OpalCall & call,            
00174                                            const PString & token,      
00175                                            void * userData,             
00176                                            const PString & remoteParty 
00177                                            );
00179   
00184   BOOL Initialise();
00185 
00187   virtual void IncomingEthernetFrame (IAX2Frame *frame);
00188   
00194   BOOL ConectionForFrameIsAlive(IAX2Frame *f);
00195   
00198   int NextSrcCallNumber();
00199     
00202   void ReportStoredConnections();
00203 
00205   WORD ListenPortNumber()  { return 4569; }
00206       
00208   IAX2Transmit *transmitter;
00209   
00211   IAX2Receiver    *receiver;
00212   
00214   PString GetLocalUserName() { return localUserName; }
00215   
00217   PString GetLocalNumber() { return localNumber; }
00218   
00220   void SetLocalUserName(PString newValue); 
00221   
00223   void SetLocalNumber(PString newValue);
00224   
00226   PString & GetPassword() { return password; }
00227   
00229   void SetPassword(PString newValue);
00230     
00234   BOOL ConnectionForFrameIsAlive(IAX2Frame *f);
00235   
00237   PINDEX GetOutSequenceNumberForStatusQuery();
00238   
00240   void StartRinging(PString remoteCaller);
00241   
00243   void OnConnectionClose(IAX2Connection & con);
00244 
00255   void NewIncomingConnection(IAX2Frame *f  
00256                              );
00257 
00258 
00261   void OnEstablished(OpalConnection & con);
00262 
00272     virtual OpalMediaFormatList GetMediaFormats() const;
00273 
00275   PINDEX GetSupportedCodecs(OpalMediaFormatList & list);
00276   
00278   PINDEX GetPreferredCodec(OpalMediaFormatList & list);
00279 
00282   void GetCodecLengths(PINDEX src, PINDEX &compressedBytes, PINDEX &duration);
00283   
00289   enum IAX2RemoteAddressFields {
00290     protoIndex     = 0,     
00291     userIndex      = 1,     
00292     transportIndex = 2,     
00293     addressIndex   = 3,     
00294     extensionIndex = 4,     
00295     contextIndex   = 5,     
00296     maximumIndex   = 6      
00297   };
00298 
00305   static PStringList DissectRemoteParty(const PString & other);
00306 
00310   void ProcessReceivedEthernetFrames();
00311 
00312 
00315   void ReportTransmitterLists();
00316 
00318   void CopyLocalMediaFormats(OpalMediaFormatList & list);
00319     
00321   
00322  protected:
00329   IAX2IncomingEthernetFrames incomingFrameHandler;
00330 
00333   IAX2FrameList   packetsReadFromEthernet;
00334   
00336   PUDPSocket  *sock;
00337   
00339   int callnumbs;
00340   
00342   PMutex callNumbLock;
00343   
00345   PTime callStartTime;
00346   
00348   PString localUserName;
00349   
00351   PString localNumber;
00352   
00354   PString password;
00355   
00357   PINDEX statusQueryCounter;
00358   
00360   PMutex statusQueryMutex;
00361   
00364   IAX2Processor * specialPacketHandler;
00365     
00372   BOOL ProcessInMatchingConnection(IAX2Frame *f);  
00373   
00381   BOOL AddNewTranslationEntry(IAX2Frame *f);
00382   
00395   PStringToString    tokenTable;
00396   
00398   PMutex             mutexTokenTable;
00399 
00402   PAtomicInteger callsEstablished;
00403 
00405   OpalMediaFormatList localMediaFormats;
00406 };
00407 
00408 #endif // IAX_ENDPOINT_H
00409 /* The comment below is magic for those who use emacs to edit this file. */
00410 /* With the comment below, the tab key does auto indent to 4 spaces.     */
00411 
00412 /*
00413  * Local Variables:
00414  * mode:c
00415  * c-file-style:linux
00416  * c-basic-offset:2
00417  * End:
00418  */
00419 

Generated on Mon Sep 25 16:20:06 2006 for OPAL by  doxygen 1.4.7