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  * $Revision: 21283 $
00028  * $Author: rjongbloed $
00029  * $Date: 2008-10-11 07:10:58 +0000 (Sat, 11 Oct 2008) $
00030  */
00031 
00032 #ifndef OPAL_IAX2_IAX2CON_H
00033 #define OPAL_IAX2_IAX2CON_H
00034 
00035 #ifndef _PTLIB_H
00036 #include <ptlib.h>
00037 #endif
00038 
00039 #include <opal/buildopts.h>
00040 
00041 #if OPAL_IAX2
00042 
00043 #include <opal/connection.h>
00044 
00045 #include <iax2/frame.h>
00046 #include <iax2/iax2jitter.h>
00047 #include <iax2/iedata.h>
00048 #include <iax2/processor.h>
00049 #include <iax2/callprocessor.h>
00050 #include <iax2/safestrings.h>
00051 #include <iax2/sound.h>
00052 
00053 class IAX2EndPoint;
00054 
00055 
00057 
00063 class IAX2Connection : public OpalConnection
00064 { 
00065   PCLASSINFO(IAX2Connection, OpalConnection);
00066   
00067  public:  
00070   
00073   IAX2Connection(
00074     OpalCall & call,             
00075     IAX2EndPoint & endpoint,     
00076     const PString & token,       
00077     void *userData,              
00078     const PString & remoteParty, 
00079     const PString & remotePartyName = PString::Empty() 
00080   );
00081   
00085   ~IAX2Connection();
00087 
00096     virtual bool IsNetworkConnection() const { return true; }
00097 
00105     virtual bool TransferConnection(
00106       const PString & remoteParty 
00107     );
00108 
00127   virtual void OnReleased();
00128 
00139   OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
00140 
00142   void EndCallNow(
00143       CallEndReason reason = EndedByLocalUser 
00144       );
00145 
00146   OpalConnection::SendUserInputModes GetRealSendUserInputMode() const;
00147 
00149   void SendDtmf(const PString & dtmf);
00150 
00152   virtual PBoolean SendUserInputString(const PString & value );
00153   
00155   virtual PBoolean SendUserInputTone(char tone, unsigned duration );
00156 
00158   PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); }
00159   
00168   virtual void AnsweringCall(
00169                              AnswerCallResponse response 
00170                              );
00171 
00179   void OnConnected();   
00180     
00192   virtual PBoolean SetConnected();
00193 
00208   void OnEstablished();
00209 
00224   virtual void Release( CallEndReason reason = EndedByLocalUser 
00225                 );
00226 
00238   PBoolean SetAlerting(   
00239                        const PString & calleeName,
00240                        PBoolean withMedia  
00241                           ); 
00242      
00250   OpalMediaStream * CreateMediaStream(
00251                                       const OpalMediaFormat & mediaFormat, 
00252                                       unsigned sessionID,
00253                                       PBoolean isSource  
00254                                       );
00255 
00266   void SetCallToken(PString newToken);
00267 
00269   PString GetCallToken() { return iax2Processor.GetCallToken(); }
00270 
00273   void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
00274  
00278   void PutSoundPacketToNetwork(PBYTEArray *sund);
00279 
00282   void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
00283 
00288   PBoolean ReadSoundPacket(RTP_DataFrame & packet);
00289 
00291   IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); }
00292 
00294   IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); }
00295   
00297   const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); } 
00298 
00303   void OnSetUp();
00304 
00305   PBoolean OnIncomingCall(
00306     unsigned int options, 
00307     OpalConnection::StringOptions * stringOptions
00308   );
00309 
00310 
00318   PBoolean SetUpConnection();
00319 
00320 
00324   PINDEX GetSupportedCodecs();
00325   
00329   PINDEX GetPreferredCodec();
00330 
00333   void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
00334 
00335      
00343   unsigned int ChooseCodec();
00344   
00346   virtual PBoolean IsConnectionOnHold();
00347   
00349   virtual bool RetrieveConnection();
00350   
00352   virtual bool HoldConnection();
00353   
00355   void RemoteHoldConnection();
00356   
00358   void RemoteRetrieveConnection();
00359 
00366   void SetUserName(PString & inUserName) { userName = inUserName; };
00367   
00369   PString GetUserName() const { return userName; };
00370   
00377   void SetPassword(PString & inPassword) { password = inPassword; };
00378   
00380   PString GetPassword() const { return password; };
00381   
00382     
00392   virtual PBoolean ForwardCall(
00393                                const PString & forwardParty   
00394                                );
00395   
00399   void IncomingEthernetFrame (IAX2Frame *frame);
00400   
00404   //static PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame);
00405     
00407   IAX2EndPoint & GetEndPoint() { return endpoint; }
00408   
00411   void ReportStatistics();
00412     
00413 
00414  protected:
00415   
00417   PString userName;
00418   
00420   PString password;
00421   
00425 
00427   IAX2EndPoint    &endpoint;
00428 
00431   OpalMediaFormatList remoteMediaFormats;
00432 
00435   OpalMediaFormatList localMediaFormats;
00436     
00438   IAX2CallProcessor & iax2Processor;
00439   
00441   PBoolean            local_hold;
00442   
00444   PBoolean            remote_hold;
00445 
00447 
00450   IAX2JitterBuffer jitterBuffer;
00451   
00459   RTP_DataFrame::PayloadTypes opalPayloadType;
00460 
00461   friend class IAX2CallProcessor;
00462 };
00463 
00464 
00466 
00467 
00468 #endif // OPAL_IAX2
00469 
00470 #endif // OPAL_IAX2_IAX2CON_H
00471 
00472 /* The comment below is magic for those who use emacs to edit this file. */
00473 /* With the comment below, the tab key does auto indent to 2 spaces.     */
00474 
00475 /*
00476  * Local Variables:
00477  * mode:c
00478  * c-basic-offset:2
00479  * End:
00480  */

Generated on Mon Feb 23 02:01:36 2009 for OPAL by  doxygen 1.5.1