# 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: 27079 $
    00028  * $Author: rjongbloed $
    00029  * $Date: 2012-02-29 23:12:01 -0600 (Wed, 29 Feb 2012) $
    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 #include <rtp/jitter.h>
    00045
    00046 #include <iax2/frame.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
    00091   void StartOperation();
    00092
    00101     virtual bool IsNetworkConnection() const { return true; }
    00102
    00110     virtual bool TransferConnection(
    00111       const PString & remoteParty
    00112     );
    00113
    00132   virtual void OnReleased();
    00133
    00144   OpalMediaFormatList GetMediaFormats() const { return remoteMediaFormats; }
    00145
    00147   void EndCallNow(
    00148       CallEndReason reason = EndedByLocalUser
    00149       );
    00150
    00152   void SendDtmf(const PString & dtmf);
    00153
    00155   virtual PBoolean SendUserInputString(const PString & value );
    00156
    00158   virtual PBoolean SendUserInputTone(char tone, unsigned duration );
    00159
    00161   PBoolean IsCallTerminating() { return iax2Processor.IsCallTerminating(); }
    00162
    00171   virtual void AnsweringCall(
    00172                              AnswerCallResponse response
    00173                              );
    00174
    00182   void OnConnected();
    00183
    00195   virtual PBoolean SetConnected();
    00196
    00211   void OnEstablished();
    00212
    00224   PBoolean SetAlerting(
    00225                        const PString & calleeName,
    00226                        PBoolean withMedia
    00227                           );
    00228
    00236   virtual OpalMediaStream * CreateMediaStream(
    00237                                       const OpalMediaFormat & mediaFormat,
    00238                                       unsigned sessionID,
    00239                                       PBoolean isSource
    00240                                       );
    00241
    00252   void SetCallToken(PString newToken);
    00253
    00255   PString GetCallToken() { return iax2Processor.GetCallToken(); }
    00256
    00259   void TransmitFrameToRemoteEndpoint(IAX2Frame *src);
    00260
    00264   void PutSoundPacketToNetwork(PBYTEArray *sund);
    00265
    00268   void ReceivedSoundPacketFromNetwork(IAX2Frame *soundFrame);
    00269
    00274   PBoolean ReadSoundPacket(RTP_DataFrame & packet);
    00275
    00277   IAX2Remote & GetRemoteInfo() { return iax2Processor.GetRemoteInfo(); }
    00278
    00280   IAX2SequenceNumbers & GetSequenceInfo() { return iax2Processor.GetSequenceInfo(); }
    00281
    00283   const PTimeInterval & GetCallStartTick() { return iax2Processor.GetCallStartTick(); }
    00284
    00289   void OnSetUp();
    00290
    00291
    00299   PBoolean SetUpConnection();
    00300
    00301
    00305   PINDEX GetSupportedCodecs();
    00306
    00310   PINDEX GetPreferredCodec();
    00311
    00314   void BuildRemoteCapabilityTable(unsigned int remoteCapability, unsigned int format);
    00315
    00316
    00324   unsigned int ChooseCodec();
    00325
    00333     virtual bool Hold(
    00334       bool fromRemote,
    00335       bool placeOnHold
    00336     );
    00337
    00342     virtual bool IsOnHold(
    00343       bool fromRemote
    00344     );
    00345
    00347   void RemoteHoldConnection();
    00348
    00350   void RemoteRetrieveConnection();
    00351
    00358   void SetUserName(PString & inUserName) { userName = inUserName; };
    00359
    00361   PString GetUserName() const { return userName; };
    00362
    00369   void SetPassword(PString & inPassword) { password = inPassword; };
    00370
    00372   PString GetPassword() const { return password; };
    00373
    00374
    00384   virtual PBoolean ForwardCall(
    00385                                const PString & forwardParty
    00386                                );
    00387
    00391   void IncomingEthernetFrame (IAX2Frame *frame);
    00392
    00396   //static PBoolean IsStatusQueryEthernetFrame(IAX2Frame *frame);
    00397
    00399   IAX2EndPoint & GetEndPoint() { return endpoint; }
    00400
    00403   void ReportStatistics();
    00404
    00405
    00406  protected:
    00407
    00409   PString userName;
    00410
    00412   PString password;
    00413
    00417
    00419   IAX2EndPoint    &endpoint;
    00420
    00423   OpalMediaFormatList remoteMediaFormats;
    00424
    00427   OpalMediaFormatList localMediaFormats;
    00428
    00430   IAX2CallProcessor & iax2Processor;
    00431
    00433   PBoolean            local_hold;
    00434
    00436   PBoolean            remote_hold;
    00437
    00439
    00442   OpalJitterBuffer jitterBuffer;
    00443
    00451   RTP_DataFrame::PayloadTypes opalPayloadType;
    00452
    00453   friend class IAX2CallProcessor;
    00454 };
    00455
    00456
    00458
    00459
    00460 #endif // OPAL_IAX2
    00461
    00462 #endif // OPAL_IAX2_IAX2CON_H
    00463
    00464 /* The comment below is magic for those who use emacs to edit this file.
    00465  * With the comment below, the tab key does auto indent to 2 spaces.
    00466  *
    00467  * Local Variables:
    00468  * mode:c
    00469  * c-basic-offset:2
    00470  * End:
    00471  */