iax2con.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 OpalConnection 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: iax2con.h,v $
00028  *  Revision 1.6  2005/09/05 01:19:43  dereksmithies
00029  *  add patches from Adrian Sietsma to avoid multiple hangup packets at call end,
00030  *  and stop the sending of ping/lagrq packets at call end. Many thanks.
00031  *
00032  *  Revision 1.5  2005/08/26 03:07:38  dereksmithies
00033  *  Change naming convention, so all class names contain the string "IAX2"
00034  *
00035  *  Revision 1.4  2005/08/25 03:26:06  dereksmithies
00036  *  Add patch from Adrian Sietsma to correctly set the packet timestamps under windows.
00037  *  Many thanks.
00038  *
00039  *  Revision 1.3  2005/08/24 04:56:25  dereksmithies
00040  *  Add code from Adrian Sietsma to send FullFrameTexts and FullFrameDtmfs to
00041  *  the remote end.  Many Thanks.
00042  *
00043  *  Revision 1.2  2005/08/04 08:14:17  rjongbloed
00044  *  Fixed Windows build under DevStudio 2003 of IAX2 code
00045  *
00046  *  Revision 1.1  2005/07/30 07:01:32  csoutheren
00047  *  Added implementation of IAX2 (Inter Asterisk Exchange 2) protocol
00048  *  Thanks to Derek Smithies of Indranet Technologies Ltd. for
00049  *  writing and contributing this code
00050  *
00051  *
00052  *
00053  *
00054  *
00055  */
00056 
00057 #ifndef IAX_CONNECTION_H
00058 #define IAX_CONNECTION_H
00059 
00060 #include <ptlib.h>
00061 #include <opal/connection.h>
00062 
00063 #include <iax2/frame.h>
00064 #include <iax2/iedata.h>
00065 #include <iax2/processor.h>
00066 #include <iax2/safestrings.h>
00067 #include <iax2/sound.h>
00068 
00069 class IAX2EndPoint;
00070 
00071 
00073 
00079 class IAX2Connection : public OpalConnection
00080 { 
00081   PCLASSINFO(IAX2Connection, OpalConnection);
00082   
00083  public:  
00086   
00089   IAX2Connection(
00090     OpalCall & call,             
00091     IAX2EndPoint & endpoint,      
00092     const PString & token,       
00093     void *userData,              
00094     const PString & remoteParty  
00095   );
00096   
00100   ~IAX2Connection();
00102 
00105   
00107   void IncomingEthernetFrame (IAX2Frame *frame);
00108   
00111   static BOOL IsStatusQueryEthernetFrame(IAX2Frame *frame);
00112     
00114   IAX2EndPoint & GetEndPoint() { return endpoint; }
00115   
00118   void ReportStatistics();
00119   
00132   void Release( CallEndReason reason = EndedByLocalUser 
00133                 );
00134   
00139   void ClearCall(
00140       CallEndReason reason = EndedByLocalUser 
00141     );
00142 
00144   void EndCallNow(
00145       CallEndReason reason = EndedByLocalUser 
00146       );
00147 
00149   void SendDtmf(PString dtmf);
00150 
00152   virtual BOOL SendUserInputString(const PString & value );
00153   
00155   virtual BOOL SendUserInputTone(char tone, unsigned duration );
00156 
00157 
00160   void AcceptIncomingCall();
00161   
00163   BOOL IsCallTerminating() { return iax2Processor->IsCallTerminating(); }
00164   
00175   BOOL SetAlerting(
00176                            const PString & calleeName,   
00177                            BOOL withMedia                
00178                            ); 
00179   
00184   BOOL SetConnected();       
00185   
00192   OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
00193   
00194   
00206   OpalMediaStream * CreateMediaStream(
00207                                       const OpalMediaFormat & mediaFormat, 
00208                                       unsigned sessionID,                  
00209                                       BOOL isSource                        
00210                                       );
00211 
00222   void SetCallToken(PString newToken);
00223 
00225   PString GetCallToken() { return iax2Processor->GetCallToken(); }
00226 
00229   void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
00230  
00234   void PutSoundPacketToNetwork(PBYTEArray *sund);
00235 
00238   IAX2Frame *GetSoundPacketFromNetwork() { return iax2Processor->GetSoundPacketFromNetwork(); }
00239 
00241   IAX2Remote & GetRemoteInfo() { return iax2Processor->GetRemoteInfo(); }
00242 
00244   IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor->GetSequenceInfo(); }
00245   
00247   const PTimeInterval & GetCallStartTick() { return iax2Processor->GetCallStartTick(); } 
00248 
00272   virtual BOOL OnIncomingConnection();
00273   
00278     virtual void OnSetUp();
00279 
00295   virtual void OnAlerting();
00296 
00297 
00307   virtual void OnConnected();
00308   
00320   virtual void OnEstablished();
00321 
00322 
00323 
00342   void OnReleased();
00343 
00344 
00345 
00352   BOOL SetUpConnection();
00353 
00354 
00358   PINDEX GetSupportedCodecs();
00359   
00363   PINDEX GetPreferredCodec();
00364 
00367   void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
00368 
00369      
00377   unsigned int ChooseCodec();
00378 
00379  protected:
00380   
00384 
00386   IAX2EndPoint    &endpoint;
00387 
00390   OpalMediaFormatList remoteMediaFormats;
00391 
00394   OpalMediaFormatList localMediaFormats;
00395     
00397   IAX2Processor * iax2Processor;
00399 };
00400 
00401 
00403 
00404 
00405 
00406 #endif // IAX_CONNECTION_H
00407 /* The comment below is magic for those who use emacs to edit this file. */
00408 /* With the comment below, the tab key does auto indent to 4 spaces.     */
00409 
00410 /*
00411  * Local Variables:
00412  * mode:c
00413  * c-file-style:linux
00414  * c-basic-offset:2
00415  * End:
00416  */
00417 
00418 
00419 

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